Search code examples
javascripthtmlcodemirror

CodeMirror MarkText


In the codemirror documentation, they have a method called markText (http://codemirror.net/doc/manual.html#api_marker). I have looked over the documentation and still do not understand what to do.

var word = CodeMirror.fromTextArea(document.getElementById('words'), {
    mode: "text/html",
});
word.markText({1,1},{3,1}, readOnly: true);

The code above does not seam to work. Please tell me how to correctly use the markText method.

Thanks in advance!


Solution

  • After some more thinking I found out how to do it.

    word.markText({line:1,ch:1},{line:3,ch:1},{readOnly:true});
    

    I simply forgot that it had to be an object. My bad.