GithubHelp home page GithubHelp logo

codemirror / codemirror-v1 Goto Github PK

View Code? Open in Web Editor NEW
360.0 8.0 64.0 1.1 MB

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

JavaScript 66.29% HTML 30.17% CSS 3.53%

codemirror-v1's Introduction

codemirror-v1's People

Contributors

artdent avatar brettz9 avatar briantemple avatar crookasacat avatar d3x avatar dandv avatar deleteme avatar erickedji avatar fsw avatar gbeddow avatar jasongrout avatar marijnh avatar mbrevoort avatar neilfraser avatar phallguy avatar rcopera avatar rgbkrk avatar willmoffat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codemirror-v1's Issues

unable to get separate history for multiple instances of codemirror

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

C# parser problem with verbatim string

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 ?

setValue() clears undo history

When calling setValue() the undo history gets cleared. A real-world example of when this would be undesirable is as follows:

  1. User loads CodeMirror-enabled page to edit something
  2. User makes a few changes to the source
  3. User clicks on a "Cleanup" button that sends an AJAX request to Tidy, BeautifyJS, or something similar.
  4. Source gets updated programmatically (using setValue) and undo history is cleared
  5. User wishes to undo his changes

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:

  1. Don't clear the undo history on setValue()
  2. Add a reset method to clear the undo/redo levels programmatically

What are your thoughts on this, Marijn?

Autocomplete

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.

{ -> {}
[ -> []
( -> ()
< -> <>

Infinite loop

I appear to be getting an infinite loop according to recent changes made in CodeMirror and line 369 of /js/codemirror.js being referenced.

Speed up hideLine method

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)?

HTML5 required attribute breaks hack for form submission

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.

textarea inside wrapper gets focused first

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.

Add release/version numbers in commented code headers of the CSS/JS libraries

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.

undo.js semicolon warning when compiling using closure

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

C# parser problem with foreach

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;
    }

Liquid Mode for Codemirror2

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.

TypeError on tab

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.

Uncaught exception: TypeError: 'win.getSelection' is not a function

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

content does not show

Content does not show when show hidden div.
Here are steps:

  1. populate content in hidden div.
  2. apply codemirror on hidden div.
  3. show hidden div then it will not show content.

This scenerio can be apply on tabs.

Tab

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!

Untitled

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!

C# parser : bug with operators (fix inside)

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

XQuery

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...

Restore cursor position on refocus (Firefox issue)

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.

Tries to access `frame.contentWindow` too early

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.

Working in XHTML/Firefox extensions

Hi,

I was able to get your code to work in Firefox extensions with two changes:

  1. Switch all cases of
    .createElement(xx);
    to
    .createElementNS('http://www.w3.org/1999/xhtml', xx);

  2. 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.

loadmode plugin does not work over non string modes

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);

this.editor is undefined (codemirror.js row 203)

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

bad identation

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
  })

enterMode "keep" does not keep the line

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.