How to add emmet support to ace js code editor?

I am trying to embed ace code editor in my project. I initialize my code editor with the following code, and now I want to enable emmet js . I can see that the ext-emmet.js extension is already them in the src ace.js directory of the pre-packaged version

I need help enabling emmet extension features . So here is my initialization code.

var e = ace.edit("editorId"); // id of the code editor div e.setTheme("ace/theme/monokai"); e.getSession().setMode("ace/mode/html"); e.setBehavioursEnabled(true); e.getSession().setTabSize(2); 

Obviously I'm adding ace.js on top of the page. If necessary, I can provide more detailed information.

+4
source share
1 answer

See Lines 539-543 in the demo version.

Basically, you need to load the emmet script source (e.g. from https://github.com/nightwing/emmet-core/blob/master/emmet.js ) and the ace extension from / src / ext -emmet.js call require("ace/ext/emmet"); so that requirejs execute the script
And after that call editor.setOption("enableEmmet", true); .
See Jsbin.com/ace-emmet/1/edit for a live demo.

+4
source

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


All Articles