Merge branch 'master' of github.com:ajaxorg/ace into server-side-rendering
This commit is contained in:
commit
dff21be992
23 changed files with 91 additions and 154 deletions
|
|
@ -23,6 +23,7 @@
|
|||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Julian Viereck <julian DOT viereck AT gmail DOT com>
|
||||
* Mihai Sucan <mihai.sucan@gmail.com>
|
||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -121,8 +122,8 @@ var Text = function(parentEl) {
|
|||
// Note: characterWidth can be a float!
|
||||
measureNode.innerHTML = lang.stringRepeat("Xy", n);
|
||||
|
||||
if (document.body) {
|
||||
document.body.appendChild(measureNode);
|
||||
if (this.element.ownerDocument.body) {
|
||||
this.element.ownerDocument.body.appendChild(measureNode);
|
||||
} else {
|
||||
var container = this.element.parentNode;
|
||||
while (!dom.hasCssClass(container, "ace_editor"))
|
||||
|
|
@ -257,7 +258,7 @@ var Text = function(parentEl) {
|
|||
};
|
||||
|
||||
this.$renderLinesFragment = function(config, firstRow, lastRow) {
|
||||
var fragment = document.createDocumentFragment(),
|
||||
var fragment = this.element.ownerDocument.createDocumentFragment(),
|
||||
row = firstRow,
|
||||
fold = this.session.getNextFold(row),
|
||||
foldStart = fold ?fold.start.row :Infinity;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -39,10 +40,11 @@ define(function(require, exports, module) {
|
|||
|
||||
var event = require("pilot/event");
|
||||
|
||||
var RenderLoop = function(onRender) {
|
||||
var RenderLoop = function(onRender, window) {
|
||||
this.onRender = onRender;
|
||||
this.pending = false;
|
||||
this.changes = 0;
|
||||
this.setTimeoutZero = this.setTimeoutZero.bind(window);
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
@ -70,31 +72,31 @@ var RenderLoop = function(onRender) {
|
|||
window.msRequestAnimationFrame;
|
||||
|
||||
if (this.setTimeoutZero) {
|
||||
|
||||
this.setTimeoutZero = this.setTimeoutZero.bind(window)
|
||||
this.setTimeoutZero = this.setTimeoutZero;
|
||||
} else if (window.postMessage) {
|
||||
|
||||
this.messageName = "zero-timeout-message";
|
||||
this.setTimeoutZero = (function(messageName, attached, listener) {
|
||||
return function setTimeoutZero(callback) {
|
||||
// Set up listener if not listening already.
|
||||
if (!attached) {
|
||||
event.addListener(this, "message", function(e) {
|
||||
if (listener && e.data == messageName) {
|
||||
event.stopPropagation(e);
|
||||
listener();
|
||||
}
|
||||
});
|
||||
attached = true;
|
||||
}
|
||||
|
||||
this.setTimeoutZero = function(callback) {
|
||||
if (!this.attached) {
|
||||
var _self = this;
|
||||
event.addListener(window, "message", function(e) {
|
||||
if (_self.callback && e.data == _self.messageName) {
|
||||
event.stopPropagation(e);
|
||||
_self.callback();
|
||||
}
|
||||
});
|
||||
this.attached = true;
|
||||
}
|
||||
this.callback = callback;
|
||||
window.postMessage(this.messageName, "*");
|
||||
}
|
||||
listener = callback;
|
||||
this.postMessage(messageName, "*");
|
||||
};
|
||||
})("zero-timeout-message", false, null);
|
||||
|
||||
} else {
|
||||
|
||||
this.setTimeoutZero = function(callback) {
|
||||
setTimeout(callback, 0);
|
||||
this.setTimeout(callback, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Fabian Jakobs <fabian AT ajax DOT org>
|
||||
* Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
@ -56,7 +57,7 @@ var ScrollBar = function(parent) {
|
|||
// of 0px
|
||||
// in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar
|
||||
// make element a little bit wider to retain scrollbar when page is zoomed
|
||||
this.width = dom.scrollbarWidth();
|
||||
this.width = dom.scrollbarWidth(parent.ownerDocument);
|
||||
this.element.style.width = (this.width || 15) + 5 + "px";
|
||||
|
||||
event.addListener(this.element, "scroll", this.onScroll.bind(this));
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-clouds .ace_editor {\
|
||||
exports.cssClass = "ace-clouds";
|
||||
exports.cssText = ".ace-clouds .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -252,8 +251,4 @@ define(function(require, exports, module) {
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
exports.cssClass = "ace-clouds";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-clouds-midnight .ace_editor {\
|
||||
exports.cssClass = "ace-clouds-midnight";
|
||||
exports.cssText = ".ace-clouds-midnight .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -253,8 +252,4 @@ background-color:#E92E2E;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
exports.cssClass = "ace-clouds-midnight";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-cobalt .ace_editor {\
|
||||
exports.cssClass = "ace-cobalt";
|
||||
exports.cssText = ".ace-cobalt .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -255,8 +254,4 @@ background-color:#001221;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
exports.cssClass = "ace-cobalt";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-crimson-editor .ace_editor {\
|
||||
exports.cssText = ".ace-crimson-editor .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -195,8 +193,6 @@ define(function(require, exports, module) {
|
|||
color: rgb(192, 0, 192);\
|
||||
}";
|
||||
|
||||
// Import CSS once.
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-crimson-editor";
|
||||
|
||||
exports.cssClass = "ace-crimson-editor";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-dawn .ace_editor {\
|
||||
exports.cssText = ".ace-dawn .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -258,8 +256,6 @@ color:#5A525F;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-dawn";
|
||||
|
||||
exports.cssClass = "ace-dawn";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-eclipse .ace_editor {\
|
||||
exports.cssText = ".ace-eclipse .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -143,8 +141,6 @@ define(function(require, exports, module) {
|
|||
background: rgb(232, 242, 254);\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-eclipse";
|
||||
|
||||
exports.cssClass = "ace-eclipse";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-idle-fingers .ace_editor {\
|
||||
exports.cssText = ".ace-idle-fingers .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -255,8 +253,6 @@ color:#BC9458;\
|
|||
background-color:#FFF980; \
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-idle-fingers";
|
||||
|
||||
exports.cssClass = "ace-idle-fingers";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-kr-theme .ace_editor {\
|
||||
exports.cssText = ".ace-kr-theme .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -254,8 +252,6 @@ color:#706D5B;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-kr-theme";
|
||||
|
||||
exports.cssClass = "ace-kr-theme";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-merbivore .ace_editor {\
|
||||
exports.cssText = ".ace-merbivore .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -246,8 +244,6 @@ background-color:#990000;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-merbivore";
|
||||
|
||||
exports.cssClass = "ace-merbivore";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-merbivore-soft .ace_editor {\
|
||||
exports.cssText = ".ace-merbivore-soft .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -246,8 +244,6 @@ background-color:#FE3838;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-merbivore-soft";
|
||||
|
||||
exports.cssClass = "ace-merbivore-soft";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-mono-industrial .ace_editor {\
|
||||
exports.cssText = ".ace-mono-industrial .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -254,8 +252,6 @@ background-color:#151C19;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-mono-industrial";
|
||||
|
||||
exports.cssClass = "ace-mono-industrial";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-monokai .ace_editor {\
|
||||
exports.cssText = ".ace-monokai .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -254,8 +252,6 @@ background-color:#AE81FF;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-monokai";
|
||||
|
||||
exports.cssClass = "ace-monokai";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-pastel-on-dark .ace_editor {\
|
||||
exports.cssText = ".ace-pastel-on-dark .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -195,8 +193,6 @@ color:#D2A8A1;\
|
|||
color:#494949;\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-pastel-on-dark";
|
||||
|
||||
exports.cssClass = "ace-pastel-on-dark";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-solarized-dark .ace_editor {\
|
||||
exports.cssText = ".ace-solarized-dark .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -253,8 +251,6 @@ color:#657B83;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-solarized-dark";
|
||||
|
||||
exports.cssClass = "ace-solarized-dark";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-solarized-light .ace_editor {\
|
||||
exports.cssText = ".ace-solarized-light .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -252,8 +250,6 @@ define(function(require, exports, module) {
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-solarized-light";
|
||||
|
||||
exports.cssClass = "ace-solarized-light";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-tm .ace_editor {\
|
||||
exports.cssClass = "ace-tm";
|
||||
exports.cssText = ".ace-tm .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -206,8 +206,4 @@ define(function(require, exports, module) {
|
|||
color: rgb(255, 0, 0)\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
exports.cssClass = "ace-tm";
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-twilight .ace_editor {\
|
||||
exports.cssClass = "ace-twilight";
|
||||
exports.cssText = ".ace-twilight .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -256,8 +255,4 @@ color:#5F5A60;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
|
||||
exports.cssClass = "ace-twilight";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
|
||||
define(function(require, exports, module) {
|
||||
|
||||
var dom = require("pilot/dom");
|
||||
|
||||
var cssText = ".ace-vibrant-ink .ace_editor {\
|
||||
exports.cssText = ".ace-vibrant-ink .ace_editor {\
|
||||
border: 2px solid rgb(159, 159, 159);\
|
||||
}\
|
||||
\
|
||||
|
|
@ -255,8 +253,6 @@ color:#99CC99;\
|
|||
\
|
||||
}";
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(cssText);
|
||||
exports.cssClass = "ace-vibrant-ink";
|
||||
|
||||
exports.cssClass = "ace-vibrant-ink";
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ var RenderLoop = require("ace/renderloop").RenderLoop;
|
|||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
var editorCss = require("ace/requirejs/text!ace/css/editor.css");
|
||||
|
||||
// import CSS once
|
||||
dom.importCssString(editorCss);
|
||||
|
||||
var VirtualRenderer = function(container, theme) {
|
||||
this.container = container;
|
||||
|
||||
// Imports CSS once per DOM document ('ace_editor' serves as an identifier).
|
||||
dom.importCssString(editorCss, "ace_editor", container.ownerDocument);
|
||||
dom.addCssClass(this.container, "ace_editor");
|
||||
|
||||
this.setTheme(theme);
|
||||
|
|
@ -135,7 +135,10 @@ var VirtualRenderer = function(container, theme) {
|
|||
height : 1
|
||||
};
|
||||
|
||||
this.$loop = new RenderLoop(this.$renderChanges.bind(this));
|
||||
this.$loop = new RenderLoop(
|
||||
this.$renderChanges.bind(this),
|
||||
this.container.ownerDocument.defaultView
|
||||
);
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
|
||||
this.setPadding(4);
|
||||
|
|
@ -800,6 +803,12 @@ var VirtualRenderer = function(container, theme) {
|
|||
}
|
||||
|
||||
function afterLoad(theme) {
|
||||
dom.importCssString(
|
||||
theme.cssText,
|
||||
theme.cssClass,
|
||||
_self.container.ownerDocument
|
||||
);
|
||||
|
||||
if (_self.$theme)
|
||||
dom.removeCssClass(_self.container, _self.$theme);
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 48ddaa841476ddf9210ccbb2b310952db8212084
|
||||
Subproject commit c720ab56a80ba8cc10d0c86a9c4f1fa9cfc83b1b
|
||||
Loading…
Add table
Add a link
Reference in a new issue