simplify config
This commit is contained in:
parent
4abb08fa92
commit
6bb805b40f
5 changed files with 44 additions and 24 deletions
|
|
@ -62,8 +62,7 @@ require("./worker/worker_client");
|
|||
require("./keyboard/hash_handler");
|
||||
require("./keyboard/state_handler");
|
||||
require("./placeholder");
|
||||
require("./config").init();
|
||||
|
||||
exports.config = require("./config");
|
||||
/**
|
||||
* Ace.edit(el) -> Editor
|
||||
* - el (String | DOMElement): Either the id of an element, or the element itself
|
||||
|
|
@ -76,6 +75,9 @@ exports.edit = function(el) {
|
|||
el = document.getElementById(el);
|
||||
}
|
||||
|
||||
if (el.env && el.env.editor instanceof Editor)
|
||||
return el.env.editor;
|
||||
|
||||
var doc = new EditSession(Dom.getInnerText(el));
|
||||
doc.setUndoManager(new UndoManager());
|
||||
el.innerHTML = '';
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ exports.init = function() {
|
|||
|
||||
var scriptOptions = {};
|
||||
var scriptUrl = "";
|
||||
var suffix;
|
||||
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
for (var i=0; i<scripts.length; i++) {
|
||||
|
|
@ -98,10 +97,9 @@ exports.init = function() {
|
|||
}
|
||||
}
|
||||
|
||||
var m = src.match(/^(?:(.*\/)ace\.js|(.*\/)ace((-uncompressed)?(-noconflict)?\.js))(?:\?|$)/);
|
||||
var m = src.match(/^(?:(.*\/)ace\.js)(?:\?|$)/);
|
||||
if (m) {
|
||||
scriptUrl = m[1] || m[2];
|
||||
suffix = m[3];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +108,6 @@ exports.init = function() {
|
|||
scriptOptions.packaged = true;
|
||||
}
|
||||
|
||||
scriptOptions.suffix = scriptOptions.suffix || suffix;
|
||||
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
|
||||
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
|
||||
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
|
||||
|
|
|
|||
|
|
@ -798,7 +798,7 @@ var EditSession = function(text, mode) {
|
|||
return callback();
|
||||
|
||||
var base = mode.split("/").pop();
|
||||
var filename = config.get("modePath") + "/mode-" + base + config.get("suffix");
|
||||
var filename = config.get("modePath") + "/mode-" + base + ".js";
|
||||
net.loadScript(filename, callback);
|
||||
}
|
||||
};
|
||||
|
|
@ -820,8 +820,8 @@ var EditSession = function(text, mode) {
|
|||
} else {
|
||||
this.bgTokenizer.setTokenizer(tokenizer);
|
||||
}
|
||||
this.bgTokenizer.setDocument(this.getDocument());
|
||||
|
||||
this.bgTokenizer.setDocument(this.getDocument());
|
||||
|
||||
this.tokenRe = this.$mode.tokenRe;
|
||||
this.nonTokenRe = this.$mode.nonTokenRe;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue