Reputation: 3412
I integrated ACE editor in my site. I want to retrieve the text in a certain line. I've searched and found This and This. But unfortunately, I can't understand those, as I'm a newbie to the subject. Can anyone give an example for it ? I got the lines to an array using the following code.
var line = document.getElementsByClassName("ace_line");
Are there any methods like
line[count].getValue
Which can return the string of the text in that line ?
Upvotes: 1
Views: 1601
Reputation: 5745
line[count]
already returns the DOM element of that line. So all you have to do is to extract the plain text from that element. if you are using jQuery you could do:
To get the text of the first line for example (line[0]
)
var lineText = line[0].text();
If you are not using jQuery and want to do that in javascipt:
var lineText = line[0].innerHTML.replace(/<[^>]*>/g, "");
Upvotes: 0
Reputation: 24159
You need to call
line0 = editor.session.getLine(0);
using getElementsByClassName("ace_line")
or similar won't work since
Upvotes: 4