Hello all,
I am working on a package that will use the CodeMirror file editor in my package.
For part of the package it will highlight errors in the file, by marking the lines in red.
The JS Api for CodeMirror allows this to be done, I am just having a problem getting the existing code editor as a Javascript Object, allowing me to run the functions & methods available on the CodeMirror object.
Here is my attempt, but without luck:
<script type="text/javascript"> function highlightLine(lineNumber) { //This seems to re-inititalize var editor = CodeMirror.fromTextArea(document.getElementById("body_CodeTextBox"), { lineNumbers: true, matchBrackets: true });//Log the editor object
console.log(editor);//Then highlight the line
var line = editor.getLineHandle(lineNumber);
console.log(line);
//Set line css class
editor.addLineClass(line, ‘background’, ‘line-error’);
}
</script>
Any ideas please?
Thanks,
Warren
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/42232-codemirror-trying-to-highlight-a-line