Ace editor gets value in one line

I am trying to get the value in one line in the Ace editor.

According to Ace Editor documentation:

  • gotoLine() to go to one line
  • getLine() to get one line
  • getLines() to get multiple rows

Here is what I tried:

 var html = ace.edit("html"); html.getSession().setMode("ace/mode/html"); html.setTheme("ace/theme/eclipse"); html.setPrintMarginColumn(false); html.resize(); var line4 = html.gotoLine(4); var getfour = html.getLine(4); var getfoureight = html.getLines(4,8); 

gotoLine() works. getLine() and getLines() do not work.

What am I doing wrong?

+6
source share
1 answer

getLine and getLines are session functions, so they should be called as

 var editor = ace.edit("html"); editor.setValue("line0 \n line1 \n line2 \n line3") editor.session.getLine(2) // returns " line2 " editor.session.getLines(1, 2) // returns [" line1 ", " line2 "] 
+7
source

Source: https://habr.com/ru/post/975258/


All Articles