works
parent
7cb6b2f515
commit
23f3483e11
|
@ -184,10 +184,10 @@ const Ace2Editor = function () {
|
||||||
outerDocument.documentElement.classList.add('inner-editor', 'outerdoc', ...skinVariants);
|
outerDocument.documentElement.classList.add('inner-editor', 'outerdoc', ...skinVariants);
|
||||||
addStyleTagsFor(outerDocument, includedCSS);
|
addStyleTagsFor(outerDocument, includedCSS);
|
||||||
|
|
||||||
const style = outerDocument.createElement('style');
|
const styleO = outerDocument.createElement('style');
|
||||||
style.type = 'text/css';
|
styleO.type = 'text/css';
|
||||||
style.title = 'dynamicsyntax';
|
styleO.title = 'dynamicsyntax';
|
||||||
outerDocument.head.appendChild(style);
|
outerDocument.head.appendChild(styleO);
|
||||||
|
|
||||||
const link = outerDocument.createElement('link');
|
const link = outerDocument.createElement('link');
|
||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
|
@ -196,23 +196,38 @@ const Ace2Editor = function () {
|
||||||
outerDocument.head.appendChild(link);
|
outerDocument.head.appendChild(link);
|
||||||
|
|
||||||
outerWindow.editorInfo = Ace2Editor.registry[info.id];
|
outerWindow.editorInfo = Ace2Editor.registry[info.id];
|
||||||
outerWindow.onload = () => {
|
const iframe = outerDocument.createElement('iframe');
|
||||||
outerWindow.onload = null;
|
|
||||||
const window = outerWindow;
|
|
||||||
const document = outerDocument;
|
|
||||||
setTimeout(() => {
|
|
||||||
const iframe = document.createElement('iframe');
|
|
||||||
iframe.name = 'ace_inner';
|
iframe.name = 'ace_inner';
|
||||||
iframe.title = 'pad';
|
iframe.title = 'pad';
|
||||||
iframe.scrolling = 'no';
|
iframe.scrolling = 'no';
|
||||||
iframe.frameBorder = 0;
|
iframe.frameBorder = 0;
|
||||||
iframe.allowTransparency = true; // for IE
|
iframe.allowTransparency = true; // for IE
|
||||||
iframe.ace_outerWin = window;
|
iframe.ace_outerWin = outerWindow;
|
||||||
document.body.insertBefore(iframe, document.body.firstChild);
|
const innerOnloadHandler = () => {
|
||||||
window.readyFunc = () => {
|
const require = window[1].frames[0].require;
|
||||||
delete window.readyFunc;
|
if(!require) {
|
||||||
window.editorInfo.onEditorReady();
|
setTimeout(innerOnloadHandler, 10);
|
||||||
delete window.editorInfo;
|
} else {
|
||||||
|
require.setRootURI('../javascripts/src');
|
||||||
|
require.setLibraryURI('../javascripts/lib');
|
||||||
|
require.setGlobalKeyPath('require');
|
||||||
|
|
||||||
|
const plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
||||||
|
plugins.adoptPluginsFromAncestorsOf(window);
|
||||||
|
|
||||||
|
const jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery;
|
||||||
|
window[1].frames[0].$ = jQuery;
|
||||||
|
const Ace2Inner = require('ep_etherpad-lite/static/js/ace2_inner');
|
||||||
|
|
||||||
|
plugins.ensure(() => Ace2Inner.init());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
iframe.addEventListener('load', innerOnloadHandler);
|
||||||
|
outerDocument.body.insertBefore(iframe, outerDocument.body.firstChild);
|
||||||
|
outerWindow.readyFunc = () => {
|
||||||
|
delete outerWindow.readyFunc;
|
||||||
|
outerWindow.editorInfo.onEditorReady();
|
||||||
|
delete outerWindow.editorInfo;
|
||||||
};
|
};
|
||||||
const innerWindow = iframe.contentWindow;
|
const innerWindow = iframe.contentWindow;
|
||||||
const innerDocument = innerWindow.document;
|
const innerDocument = innerWindow.document;
|
||||||
|
@ -224,27 +239,10 @@ const Ace2Editor = function () {
|
||||||
script.src = `../static/js/require-kernel.js?v=${clientVars.randomVersionString}`;
|
script.src = `../static/js/require-kernel.js?v=${clientVars.randomVersionString}`;
|
||||||
innerDocument.head.appendChild(script);
|
innerDocument.head.appendChild(script);
|
||||||
|
|
||||||
innerWindow.onload = () => {
|
const styleI = innerDocument.createElement('style');
|
||||||
innerWindow.onload = null;
|
styleI.type = 'text/css';
|
||||||
const window = innerWindow;
|
styleI.title = 'dynamicsyntax';
|
||||||
const require = window.require;
|
innerDocument.head.appendChild(styleI);
|
||||||
require.setRootURI('../javascripts/src');
|
|
||||||
require.setLibraryURI('../javascripts/lib');
|
|
||||||
require.setGlobalKeyPath('require');
|
|
||||||
|
|
||||||
window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
|
|
||||||
window.plugins.adoptPluginsFromAncestorsOf(window);
|
|
||||||
|
|
||||||
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery;
|
|
||||||
window.Ace2Inner = require('ep_etherpad-lite/static/js/ace2_inner');
|
|
||||||
|
|
||||||
window.plugins.ensure(() => window.Ace2Inner.init());
|
|
||||||
};
|
|
||||||
|
|
||||||
const style = innerDocument.createElement('style');
|
|
||||||
style.type = 'text/css';
|
|
||||||
style.title = 'dynamicsyntax';
|
|
||||||
innerDocument.head.appendChild(style);
|
|
||||||
|
|
||||||
const headLines = [];
|
const headLines = [];
|
||||||
hooks.callAll('aceInitInnerdocbodyHead', {iframeHTML: headLines});
|
hooks.callAll('aceInitInnerdocbodyHead', {iframeHTML: headLines});
|
||||||
|
@ -257,8 +255,6 @@ const Ace2Editor = function () {
|
||||||
innerDocument.body.setAttribute('role', 'application');
|
innerDocument.body.setAttribute('role', 'application');
|
||||||
innerDocument.body.setAttribute('spellcheck', 'false');
|
innerDocument.body.setAttribute('spellcheck', 'false');
|
||||||
innerDocument.body.appendChild(innerDocument.createTextNode('\u00A0')); //
|
innerDocument.body.appendChild(innerDocument.createTextNode('\u00A0')); //
|
||||||
}, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
outerDocument.body.id = 'outerdocbody';
|
outerDocument.body.id = 'outerdocbody';
|
||||||
outerDocument.body.classList.add('outerdocbody', ...pluginUtils.clientPluginNames());
|
outerDocument.body.classList.add('outerdocbody', ...pluginUtils.clientPluginNames());
|
||||||
|
|
Loading…
Reference in New Issue