Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 320
idude Avatar asked Sep 07 '14 23:09

idude


People also ask

How do I use CodeMirror in textarea?

This could be used to, for example, replace a textarea with a real editor: var myCodeMirror = CodeMirror(function(elt) { myTextArea. parentNode. replaceChild(elt, myTextArea); }, {value: myTextArea.

What is CodeMirror CSS?

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.

Does GitHub use CodeMirror?

About. CodeMirror is open source under a permissive license (MIT). It is being developed on GitHub. Contributions are welcome.

How do I set up CodeMirror?

Download CodeMirror files. Download jQuery file. Inside the codemirror project folder create subfolders and name them js, css and plugin. The js folder will hold all the javascript files.


1 Answers

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.

like image 181
idude Avatar answered Sep 17 '22 04:09

idude