javascript - ACE editor installed with bower does not find my mode -
i wrote custom mode ace editor
my-mode.js
ace.define('my-mode', [/* ... */], function(require, exports, module) { /* ... */ });
that try use
index.js
var editor = ace.edit('editor'); editor.getsession().setmode('my-mode');
i installed ace editor (ace-builds) , requirejs bower
bower.json
{ "name": "my-project", "dependencies": { "ace-builds": "^1.2.3", "requirejs": "^2.2.0" } }
and configured requirejs
requirejs-config.js
require.config({ paths: { ace: "bower_components/ace-builds/src-noconflict/ace" } });
my page looks this
index.html
<body> <div id="editor"></div> <script src="bower_components/requirejs/require.js"></script> <script src="requirejs-config.js"></script> <script src="bower_components/ace-builds/src-noconflict/ace.js"></script> <script src="my-mode.js"></script> <script src="index.js"></script> </body>
sadly, call
editor.getsession().setmode('my-mode');
leads error
failed load resource: http://localhost:5555/bower_components/ace-builds/src-noconflict/mode-my-mode.js server responded status of 404 (not found)
how can configure ace , requirejs such my-mode found?
i found solution. before my-mode used (for example @ beginning of index.js) call
ace.config.setmoduleurl('my-mode', '/path/to/my-mode.js');
Comments
Post a Comment