Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ace Editor addMarker throwing erro

So I have literally copied the "get started" code from ACE and then tried to add a marker. I copied the syntax from ACE's website which is the same as recommended here: How can I highlight multiple lines with Ace?

All I get is an error in the console saying Undefined is not a function.

My goal is to add a marker so I can highlight a line of text. Any ideas why this is not working?

var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
editor.getSession().addMarker(new Range(1,0,1,200),"ace_active_line","background");
like image 555
RyanY Avatar asked Dec 18 '25 01:12

RyanY


1 Answers

Looks like you forgot to import Range

var Range = ace.require("ace/range").Range
var editor = ace.edit("editor");
editor.session.addMarker(new Range(1,0,1,200),"ace_active-line","fullLine");

also class name for active line marker have changed.

Generally when asking questions like this it is a good idea to create a jsbin like http://jsbin.com/ojijeb/570/edit, since it helps answering a lot

like image 95
a user Avatar answered Dec 19 '25 15:12

a user



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!