最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to add emmet support in ace js code editor? - Stack Overflow

programmeradmin2浏览0评论

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

I need help in 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 am adding the ace.js on top of the page. I can provide more details if needed.

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

I need help in 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 am adding the ace.js on top of the page. I can provide more details if needed.

Share Improve this question edited Jul 12, 2013 at 8:08 a user 24.2k6 gold badges62 silver badges91 bronze badges asked Jul 10, 2013 at 20:56 ʞɹᴉʞ ǝʌɐpʞɹᴉʞ ǝʌɐp 5,6508 gold badges42 silver badges65 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

See Lines 539-543 in ace demo.

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

发布评论

评论列表(0)

  1. 暂无评论