scniro / react-codemirror2

Codemirror integrated components for React
MIT License
1.66k stars 193 forks source link

markText() method #192

Open VicenteVicente opened 4 years ago

VicenteVicente commented 4 years ago

Is the method markText() supported? If it's not, is it possible to make this method work, for example as a prop with a an array of "range objects", with keys start s and end e. i.e:

marks={[
    {s: 0, e: 5},
    {s:3, e: 6}
]}

So the default value would be marks={[]}. I think this can be done by many other ways but this is mi proposal. Here's the original method of CodeMirror

doc.markText(from: {line, ch}, to: {line, ch}, ?options: object) → TextMarker
Can be used to mark a range of text with a specific CSS class name. from and to should be {line, ch} objects. 

Thank you!

johnnytolengo commented 3 years ago

readOnly doesn't work:

editor.markText({line: 0, ch: 0}, {line: 0, ch: 26}, { readOnly:true });

any idea why?