I am trying to add the scroll past end
add-on for codemirror but I cannot add it to my codemirror instance.
I tried calling it like this scrollPastEnd: true
in the options but that didn't work. I also tried using the defineOption
function but the console says it is undefined
.
Thanks for the help
First, you have to add the scrollpastend.js
file ( https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/addon/scroll/scrollpastend.min.js ) to your HTML document and not to the editor.
As the following code from scrollpastend.js
file says, the scrollPastEnd
option is off by default:
CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) {..});
Then It only remains to activate your add-on by setting new option like this:
editor.setOption("scrollPastEnd", true);
or adding scrollPastEnd
option to the object option list:
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "html",
lineNumbers: true,
scrollPastEnd: true
});
Hoping to help you, I wish you a good day.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.