admin管理员组

文章数量:1291519

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

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

Share asked Oct 22, 2016 at 5:27 Corentin CaerCorentin Caer 3313 silver badges10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

First, you have to add the scrollpastend.js file (https://cdnjs.cloudflare./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.

本文标签: javascriptCodemirrorhow to add addonsStack Overflow