How to use mirror worker for ace editor with ace-builds

拟墨画扇 提交于 2019-12-23 09:17:13

问题


I am using ace-builds to build my ace editor app with webpack.

I need to use a custom worker for syntax validation. The wiki page here suggests to extend a worker named mirror obtained by following.

var Mirror = require("ace/worker/mirror").Mirror;

But ace-builds does not seem to provide this worker. How do I create a custom worker for syntax validation using ace-builds?

Any other advice on how to build an ace editor app with a custom syntax validating worker (for a custom programming language) is much appreciated. (I cannot use the ace library supposed to be used with require.js, as it uses require.toUrl which webpack does not know about. See github issue)


回答1:


ace-builds repository provides only built workers, and doesn't have source of ace/worker/mirror in a separate file.

You can use json worker to bootstrap your custom one, since it contains only 200 lines of extra code https://github.com/ajaxorg/ace-builds/blob/master/src/worker-json.js#L1409-L1699

rename that file to "<mymode>_worker.js" and add worker definition at the end.

define("ace/mode/<mymode>_worker",["require","exports","module"], function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;

...

});


来源:https://stackoverflow.com/questions/42465341/how-to-use-mirror-worker-for-ace-editor-with-ace-builds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!