我正在尝试从外部文件设置规则,但由于请求是异步的,我无法找到使其正常工作的方式...任何帮助表示赞赏。
window.define = window.define || ace.define;
define('ace/mode/myCustomMode', function(require, exports, module) {
var oop = require('ace/lib/oop');
var TextMode = require('ace/mode/text').Mode;
var Tokenizer = require('ace/tokenizer').Tokenizer;
var TextHighlightRules = require('ace/mode/text_highlight_rules').TextHighlightRules;
var myCustomRules = function() {
this.$rules = {};
};
oop.inherits(myCustomRules, TextHighlightRules);
var Mode = function() {
this.$tokenizer = new Tokenizer();
};
oop.inherits(Mode, TextMode);
d3.json('rules.json', function (error, data) {
var myCustomRules = function() {
this.addRules(data);
};
Mode.$tokenizer = new Tokenizer(new myCustomRules().getRules());
});
exports.Mode = Mode;
});