如何在文件中加载和设置ace编辑器中的规则?

时间:2016-06-20 09:16:17

标签: javascript ace-editor

我正在尝试从外部文件设置规则,但由于请求是异步的,我无法找到使其正常工作的方式...任何帮助表示赞赏。

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;
});

0 个答案:

没有答案