diff --git a/node/utils/Minify.js b/node/utils/Minify.js
index 859ee07a..baeaee68 100644
--- a/node/utils/Minify.js
+++ b/node/utils/Minify.js
@@ -213,72 +213,6 @@ function _handle(req, res, jsFilename, jsFiles) {
}
}
-// find all includes in ace.js and embed them.
-function getAceFile(callback) {
- fs.readFile(JS_DIR + 'ace.js', "utf8", function(err, data) {
- if(ERR(err, callback)) return;
-
- // Find all includes in ace.js and embed them
- var founds = data.match(/\$\$INCLUDE_[a-zA-Z_]+\([a-zA-Z0-9.\/_"-]+\)/gi);
- if (!settings.minify) {
- founds = [];
- }
- founds.push('$$INCLUDE_JS("../static/js/require-kernel.js")');
-
- data += ';\n';
- data += 'Ace2Editor.EMBEDED = Ace2Editor.EMBEDED || {};\n';
-
- //go trough all includes
- async.forEach(founds, function (item, callback) {
- var filename = item.match(/"([^"]*)"/)[1];
- var type = item.match(/INCLUDE_([A-Z]+)/)[1];
- var shortFilename = (filename.match(/^..\/static\/js\/(.*)$/, '')||[])[1];
-
- //read the included files
- if (shortFilename) {
- if (shortFilename == 'require-kernel.js') {
- // the kernel isn’t actually on the file system.
- handleEmbed(null, requireDefinition());
- } else {
- var contents = '';
- tarCode(tar[shortFilename] || shortFilename
- , function (content) {
- contents += content;
- }
- , function () {
- handleEmbed(null, contents);
- }
- );
- }
- } else {
- fs.readFile(ROOT_DIR + filename, "utf8", handleEmbed);
- }
-
- function handleEmbed(error, data_) {
- if (error) {
- return; // Don't bother to include it.
- }
- if (settings.minify) {
- if (type == "JS") {
- try {
- data_ = compressJS([data_]);
- } catch (e) {
- // Ignore, include uncompresseed, which will break in browser.
- }
- } else {
- data_ = compressCSS([data_]);
- }
- }
- data += 'Ace2Editor.EMBEDED[' + JSON.stringify(filename) + '] = '
- + JSON.stringify(data_) + ';\n';
- callback();
- }
- }, function(error) {
- callback(error, data);
- });
- });
-}
-
exports.requireDefinition = requireDefinition;
function requireDefinition() {
return 'var require = ' + RequireKernel.kernelSource + ';\n';
@@ -288,12 +222,8 @@ function tarCode(jsFiles, write, callback) {
write('require.define({');
var initialEntry = true;
async.forEach(jsFiles, function (filename, callback){
- if (filename == 'ace.js') {
- getAceFile(handleFile);
- } else {
- fs.readFile(JS_DIR + filename, "utf8", handleFile);
- }
-
+ fs.readFile(JS_DIR + filename, "utf8", handleFile);
+
function handleFile(err, data) {
if(ERR(err, callback)) return;
var srcPath = JSON.stringify('/' + filename);
diff --git a/static/css/iframe_editor.css b/static/css/iframe_editor.css
index 6a483c07..d2d2f977 100644
--- a/static/css/iframe_editor.css
+++ b/static/css/iframe_editor.css
@@ -170,34 +170,3 @@ p {
}
#overlaysdiv { position: absolute; left: -1000px; top: -1000px; }
-
-/* ---------- Used by JavaScript Lexer ---------- */
-.syntax .c { color: #bd3f00; font-style: italic } /* Comment */
-.syntax .o { font-weight: bold; } /* Operator */
-.syntax .p { font-weight: bold; } /* Punctuation */
-.syntax .k { color: blue; } /* Keyword */
-.syntax .kc { color: purple } /* Keyword.Constant */
-.syntax .nx { } /* Name.Other */
-.syntax .mf { color: purple } /* Literal.Number.Float */
-.syntax .mh { color: purple } /* Literal.Number.Hex */
-.syntax .mi { color: purple } /* Literal.Number.Integer */
-.syntax .sr { color: purple } /* Literal.String.Regex */
-.syntax .s2 { color: purple } /* Literal.String.Double */
-.syntax .s1 { color: purple } /* Literal.String.Single */
-.syntax .sd { color: purple } /* Literal.String.Doc */
-.syntax .cs { color: #00aa33; font-weight: bold; font-style: italic } /* Comment.Special */
-.syntax .err { color: #cc0000; font-weight: bold; text-decoration: underline; } /* Error */
-
-/* css */
-.syntax .nt { font-weight: bold; } /* tag */
-.syntax .nc { color: #336; } /* class */
-.syntax .nf { color: #336; } /* id */
-.syntax .nd { color: #999; } /* :foo */
-.syntax .m { color: purple } /* number */
-.syntax .nb { color: purple } /* built-in */
-.syntax .cp { color: #bd3f00; } /* !important */
-
-.syntax .flash { background-color: #adf !important; }
-.syntax .flashbad { background-color: #f55 !important; }
-
-
diff --git a/static/js/ace.js b/static/js/ace.js
index 04930910..63b1e61f 100644
--- a/static/js/ace.js
+++ b/static/js/ace.js
@@ -49,8 +49,7 @@ function Ace2Editor()
{
var that = this;
var args = arguments;
-
- function action()
+ var action = function()
{
func.apply(that, args);
}
@@ -71,78 +70,47 @@ function Ace2Editor()
function doActionsPendingInit()
{
- for (var i = 0; i < actionsPendingInit.length; i++)
- {
- actionsPendingInit[i]();
- }
+ $.each(actionsPendingInit, function(i,fn){
+ fn()
+ });
actionsPendingInit = [];
}
-
+
ace2.registry[info.id] = info;
- editor.importText = pendingInit(function(newCode, undoable)
- {
- info.ace_importText(newCode, undoable);
- });
- editor.importAText = pendingInit(function(newCode, apoolJsonObj, undoable)
- {
- info.ace_importAText(newCode, apoolJsonObj, undoable);
+ // The following functions (prefixed by 'ace_') are exposed by editor, but
+ // execution is delayed until init is complete
+ var aceFunctionsPendingInit = ['importText', 'importAText', 'focus',
+ 'setEditable', 'getFormattedCode', 'setOnKeyPress', 'setOnKeyDown',
+ 'setNotifyDirty', 'setProperty', 'setBaseText', 'setBaseAttributedText',
+ 'applyChangesToBase', 'applyPreparedChangesetToBase',
+ 'setUserChangeNotificationCallback', 'setAuthorInfo',
+ 'setAuthorSelectionRange', 'callWithAce', 'execCommand', 'replaceRange'];
+
+ $.each(aceFunctionsPendingInit, function(i,fnName){
+ var prefix = 'ace_';
+ var name = prefix + fnName;
+ editor[fnName] = pendingInit(function(){
+ info[prefix + fnName].apply(this, arguments);
+ });
});
+
editor.exportText = function()
{
if (!loaded) return "(awaiting init)\n";
return info.ace_exportText();
};
+
editor.getFrame = function()
{
return info.frame || null;
};
- editor.focus = pendingInit(function()
- {
- info.ace_focus();
- });
- editor.setEditable = pendingInit(function(newVal)
- {
- info.ace_setEditable(newVal);
- });
- editor.getFormattedCode = function()
- {
- return info.ace_getFormattedCode();
- };
- editor.setOnKeyPress = pendingInit(function(handler)
- {
- info.ace_setOnKeyPress(handler);
- });
- editor.setOnKeyDown = pendingInit(function(handler)
- {
- info.ace_setOnKeyDown(handler);
- });
- editor.setNotifyDirty = pendingInit(function(handler)
- {
- info.ace_setNotifyDirty(handler);
- });
-
- editor.setProperty = pendingInit(function(key, value)
- {
- info.ace_setProperty(key, value);
- });
+
editor.getDebugProperty = function(prop)
{
return info.ace_getDebugProperty(prop);
};
- editor.setBaseText = pendingInit(function(txt)
- {
- info.ace_setBaseText(txt);
- });
- editor.setBaseAttributedText = pendingInit(function(atxt, apoolJsonObj)
- {
- info.ace_setBaseAttributedText(atxt, apoolJsonObj);
- });
- editor.applyChangesToBase = pendingInit(function(changes, optAuthor, apoolJsonObj)
- {
- info.ace_applyChangesToBase(changes, optAuthor, apoolJsonObj);
- });
// prepareUserChangeset:
// Returns null if no new changes or ACE not ready. Otherwise, bundles up all user changes
// to the latest base text into a Changeset, which is returned (as a string if encodeAsString).
@@ -157,24 +125,6 @@ function Ace2Editor()
if (!loaded) return null;
return info.ace_prepareUserChangeset();
};
- editor.applyPreparedChangesetToBase = pendingInit(
-
- function()
- {
- info.ace_applyPreparedChangesetToBase();
- });
- editor.setUserChangeNotificationCallback = pendingInit(function(callback)
- {
- info.ace_setUserChangeNotificationCallback(callback);
- });
- editor.setAuthorInfo = pendingInit(function(author, authorInfo)
- {
- info.ace_setAuthorInfo(author, authorInfo);
- });
- editor.setAuthorSelectionRange = pendingInit(function(author, start, end)
- {
- info.ace_setAuthorSelectionRange(author, start, end);
- });
editor.getUnhandledErrors = function()
{
@@ -183,86 +133,6 @@ function Ace2Editor()
return info.ace_getUnhandledErrors();
};
- editor.callWithAce = pendingInit(function(fn, callStack, normalize)
- {
- return info.ace_callWithAce(fn, callStack, normalize);
- });
-
- editor.execCommand = pendingInit(function(cmd, arg1)
- {
- info.ace_execCommand(cmd, arg1);
- });
- editor.replaceRange = pendingInit(function(start, end, text)
- {
- info.ace_replaceRange(start, end, text);
- });
-
- function sortFilesByEmbeded(files) {
- var embededFiles = [];
- var remoteFiles = [];
-
- if (Ace2Editor.EMBEDED) {
- for (var i = 0, ii = files.length; i < ii; i++) {
- var file = files[i];
- if (Object.prototype.hasOwnProperty.call(Ace2Editor.EMBEDED, file)) {
- embededFiles.push(file);
- } else {
- remoteFiles.push(file);
- }
- }
- } else {
- remoteFiles = files;
- }
-
- return {embeded: embededFiles, remote: remoteFiles};
- }
- function pushRequireScriptTo(buffer) {
- var KERNEL_SOURCE = '../static/js/require-kernel.js';
- var KERNEL_BOOT = 'require.setRootURI("../minified/");\nrequire.setGlobalKeyPath("require");'
- if (Ace2Editor.EMBEDED && Ace2Editor.EMBEDED[KERNEL_SOURCE]) {
- buffer.push('');
+ iframeHTML.push('\
-');
- pushScriptsTo(iframeHTML);
-
+ iframeHTML.push('require.define("/plugins", null);');
+ iframeHTML.push('require.define("/plugins.js", function (require, exports, module) {');
+ iframeHTML.push('module.exports = parent.parent.require("/plugins");');
+ iframeHTML.push('});');
+ iframeHTML.push('<\/script>');
+
+ // Require ace2
+ iframeHTML.push('');
+ iframeHTML.push('