This repository is no longer being maintained.
All development work has shifted to https://github.com/marijnh/CodeMirror.
An editable-iframe based code editor in JavaScript. See https://github.com/marijnh/CodeMirror for the currently maintained version
Home Page: http://codemirror.net/
License: Other
This repository is no longer being maintained.
All development work has shifted to https://github.com/marijnh/CodeMirror.
And while I know this is maybe unlikely, if you might be able to implement an XQuery parser (e.g., maybe the dev. who implemented SPARQL?), I could have complete syntax coloring to my XQuery add-on (XqUSEme) as I'm doing now for my XSL Results extension...
Hello!
I'm creating a tabbed application with CodeMirror. Each tab is a separate editor.
When another tab is selected, I call editor.focus() on its editor.
When I switch back, after editor.focus() the cursor becomes positioned on the beginning on the reselected tab. the cursor to keep same position as it was prior to switching.
IE8 works right here, Firefox 3.6 has the problem.
I appear to be getting an infinite loop according to recent changes made in CodeMirror and line 369 of /js/codemirror.js being referenced.
Operators in the C# parser does not work because of a typo line 211 of file tokenizecsharp.js
instead of :
else if (ch = "@") {
we should have :
else if (ch == "@") {
Thanks
I'm seeing this in Opera Linux's error console :
Uncaught exception: TypeError: 'win.getSelection' is not a function
Error thrown at line 423, column 6 in (win) in http://localhost/admin/jscript/editor-plugins/codemirror/js/select.js:
var selection = win.getSelection();
called from line 1299, column 8 in () in http://localhost/admin/jscript/editor-plugins/codemirror/js/editor.js:
select.markSelection(self.win);
Can't see function getSelection(); defined anywhere.
Thanks
Hi,
I am trying to have multiple codemirror editors in the same html document. I am using Codemirror Version: 2.2
The way I am getting the different instances of codemirror is :
var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
However I see that the history is shared between the different instances. In the codemirror.js I see that the instance does not get a new history object.
I need to be able to track the history of each codemirror instance separately. Is there a way I can do that?
Is there a different way of instantiating codemirror so that I can get a separate history per instance?
Will appreciate any help on this.
Thanks,
Ananya
Try autoidenting the following.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
alert('Hello, world!')
alert('I am javascript!')
</script>
</body>
</html>
Sure you'll notice that alerts don't match. There are other consequences of this bug too, I'll retest after fix.
P.S. I'm using mixed HTML/JS from example:
var editor = CodeMirror.fromTextArea('code', {
height: "500px",
parserfile: ["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsehtmlmixed.js"],
stylesheet: ["css/xmlcolors.css", "css/jscolors.css", "css/csscolors.css", "try.css"],
path: "js/",
reindentOnLoad: true,
initCallback: init
})
Cloned with commit 3da6cea
Nothing pastes via keyboard on OS X. It works fine from the menu, or cmd+option+shift+v (Paste and match style)
Hi,
I know I need to get back to you on another issue (XHTML), but for work I've come into an issue. Would you be open to allowing CodeMirror to be configurable as far as tabs? When tabs are normalized, one can't maintain the fidelity, esp. important for diffs, etc. Maybe the key code combo for indenting could be specified by the user (e.g., as tab by default)?
I haven't looked at your code too closely yet, but wanted to know if you'd be open to such changes.
thanks!
For learning purposes ONLY! NEWBIE ZONE
There seems to be a this missing at line 241 in undo.js, introduce with this commit
codemirror/codemirror5@b621f90
It would be great if the editor completed keywords, constructs, or common names.
It would also be great if parenthesis, brackets, and braces were also automatically terminated.
{ -> {}
[ -> []
( -> ()
< -> <>
Hi,
it seems that indentation does not wirk with the foreach keyword using the C# parser.
in the provided sample, add a foreach :
...
...
public decimal CalculateSalary(int grade)
{
string[] strs=new string[]{"test"};
foreach(string s in strs)
{
//DOH! What's wrong ?!
}
if (grade > 10)
return 1000;
return 500;
}
CodeMirror's CSS parser does not support CSS3 Media Queries.
@media screen {
body {font-family: sans-serif}
}
Rules inside @media screen {}
do not highlighted properly.
When you try to use a email or hyperlink surrounded by quotes in codemirror the quotes get removed after typing any character.
EG:
"[email protected]"
becomes
[email protected]
On Firefox (tested on Mac FF 3.5), the delete key stops working.
To reproduce:
In Chrome, I can click on either line and delete as normal.
(You can edit this code snippet at http://jsbin.com/ocamu/edit )
Hi,
it seems that the C# parser can't deal with verbatim strings.
It tries to indent new lines into the verbatim string (which add spaces in it) and does not recognize those new lines as part of the string (wrong colors).
Also, next lines does not have a good indent because of this error.
Sample :
public decimal CalculateSalary(int grade)
{
string str=@"verbatim test
seems to fail";
if (grade > 10)
return 1000;
return 500;
}
Could you check if it can be fixed ?
\u200b chars are not removed if textWrapping is false.
To reproduce:
editor.mirror.setTextWrapping(false);
/\u200b/.test(editor.mirror.getCode()) // --> false
/\u200b/.test(editor.mirror.getCode()) // --> true
These chars break indentation.
Currently, there are a bunch of really involved workarounds for bugs in, mostly, webkit, which don't even work all the time. It's not that expensive to add a node, take its offset, and remove it again.
When you scroll to the far right in a document that does not have wordwrap activated, and paste code, you are automatically "scrolled back" to the left of the document onkeyup. Confirmed in Firefox, Chrome and Safari.
Small issue for an apparently awesome syntax highlighter, but thought I'd report anyways...
In mixedtest.html, when I add a tag just inside the root, and start typing an attribute before closing the tag, some of the rest of the text becomes red (which is fine), but when I close the tag, the closing and tags are left in red color.
Similarly, if I add a tag above the but after (e.g., I type my own and then remove the previous ), the closing tag for also stays in red even after fixing the markup.
Thanks!
I'm getting a this.win is null
error in WebKit browsers because this.win = frame.contentWindow
is done before the frame is ready. Running that block of code at the bottom of the constructor in a setTimeout
alleviates this problem, though it probably should be done on the load event.
When calling setValue() the undo history gets cleared. A real-world example of when this would be undesirable is as follows:
This is one of the ways I'm using CodeMirror 2, which is why I've come across this issue. I think the following may be a feasible solution:
What are your thoughts on this, Marijn?
Directly inside the 'CodeMirror-wrapping' div is a textarea whose purpose i am not sure of. It comes just before the iframe and gets tab focused before the edit area. If possible it should be placed after the edit area, or better, the tabindex should be set very high since it is not used for anything visible. Possibly even betterer, It could also automatically send the focus to the edit area when focused.
Weird bug I found... enterMode only seems to work if I remove the height attribute. Anyone seen this / know the fix?
Hey guys,
is anyone working on Liquid mode for CodeMirror2?
Liquid templates are used in LocomotiveCMS and current branch uses CodeMirror 1 as main editor. I've integrated second version of CodeMirror and CoffeeScript support to LocomotiveCMS: https://github.com/alexkravets/engine - but there is no support for Liquid mode in CodeMirror 2 and now HTML mixed mode is used while editing Liquid templates and it doesn't highlight tags.
I wonder if there is anyone who may port Liquid mode for CM1 to CM2: https://github.com/tobi/liquid-editor/tree/master/public/codemirror/js
Thanks.
(And find a better name for them too.)
Error is thrown in FF4 after ctrl-f5 page reload. Codemirror itself works, but subsequent code is not run. Solution seems to be simple, instead of
if (this.editor.selectionSnapshot) // IE hack
I used
if (this.editor && this.editor.selectionSnapshot) // IE hack
Pressing tab causes entire line to indent in CM2.
I dont want that to happen. instead it should just add the tab at the cursor position.
Using the CodeMirror.fromTextArea()
method, the textarea is hidden and replaced by the CodeMirror element.
Submission is done by the hack:
if (textarea.form) {
// Deplorable hack to make the submit method do the right thing.
var rmSubmit = connect(textarea.form, "submit", save, true);
if (typeof textarea.form.submit == "function") {
var realSubmit = textarea.form.submit;
function wrappedSubmit() {
save();
textarea.form.submit = realSubmit;
textarea.form.submit();
textarea.form.submit = wrappedSubmit;
}
textarea.form.submit = wrappedSubmit;
}
}
If the real (and hidden) textarea has the HTML5 required
attribute, modern browsers check the textarea value before calling textarea.fom.submit()
(so before "saving" the data) and tries to display an error notice.
The error notice may fail because the textarea is not focusable (it does on my browser, Chrome 15.0).
In short, the form is never submitted and no error is displayed.
As mentioned in the Google Group, there is a small flaw in the PHP Parser.
I couldn't get the Code examples into Github without being interpreted (the HTML was always rendered) so please check them out at the initial Google Group discussion.
Hi,
I was able to get your code to work in Firefox extensions with two changes:
Switch all cases of
.createElement(xx);
to
.createElementNS('http://www.w3.org/1999/xhtml', xx);
In the CodeMirror constructor, keeping "frame.style.height" at 100% caused problems for me, but when I based it on my own needs (calculating the container's available height and using that for both the frame's height and the div height) and passed that value in instead, it all worked.
Would you be open to adding an XHTML mode and a frame height configuration? I could make a pull request, but I'm not sure if you'd have a particular way to implement this in mind.
It'd be nice to know what version of CodeMirror I am using on older sites without having to DIFF everything.
It'd also be nice if there was a branch or repo that contained just the code without the website or examples so I could use it as a git submodule. But I realize that's a hassle and is not going to be useful for too many people.
This error shows up in my inspector sometimes (I'm using the latest Chrome). I can sort of guess at the meaning from the name but I don't know what's causing it.
Content does not show when show hidden div.
Here are steps:
This scenerio can be apply on tabs.
I see a :
JSC_SUSPICIOUS_SEMICOLON: If this if/for/while really shouldnt have a body, use {} at line 393 character 0
for (var match = 0; match < cursor.offset &&
warning using closure.
I guess that line 394 can be :
line.text.charAt(match) == prev.text.charAt(match); match++){}
then?
Thanks
I use hideLine for code folding. When i fire this method first time in my editor(more than 100 lines to hide) it takes about 30 seconds. On next call it takes about 30 millis.
Maybe it would be better to write some method for hide range e.g hideLines(from, to)?
I'm trying to use CodeMirror for javascript without autoindent.
In newest codemirror, it seems to be configurable like:
tabMode: "shift", enterMode: "keep", electricChars: false,
But when I write this and press enter:
function f() { a = 5(cursor here)
The cursor appears at the beginning of next line, not indented same as "a=5".
Is that correct? I guess, should be indented... I mean, keep same indentation as a=5.
OS is Windows 7, browser is Firefox 3.6.10, codemirror from Git.
Hi,
I am trying to use tab with the default config in Chrome 7.0.517.44. Wether I have selected text or not, the error I get is:
Uncaught TypeError: Property 'indentation' of object #<an HTMLBRElement> is not a function editor.js:958 Editor.indentLineAftereditor.js:958 Editor.indentAtCursoreditor.js:1210 Editor.reindentSelectioneditor.js:738 Editor.handleTabeditor.js:1023 Editor.keyDowneditor.js:803 (anonymous function)util.js:5 wrapHandlerutil.js:98
Using tabMode = 'spaces
this error dissappears.
There are already implementations for zen-coding on various editors. Why not make the first in-page editor that supports it? see: http://code.google.com/p/zen-coding/downloads/list?can=2&q=&sort=-downloadcount&colspec=Summary%20Uploaded%20Size%20DownloadCount%20Filename
The json mode works with the mode being {name:'javascript',json:true}
.
Running
CodeMirror.autoLoadMode(editor,{name:'javascript',json:true});
results in mode being converted to string and not being loaded. A simple type check for mode being an object fixes this (in loadmode.js)
mode = typeof mode == 'object' ? mode.name : mode;
script.src = CodeMirror.modeURL.replace(/%N/g, mode);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.