This commit is contained in:
webzwo0i 2021-02-27 19:10:29 +01:00
parent 7cb6b2f515
commit 23f3483e11

View file

@ -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,69 +196,65 @@ 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; iframe.name = 'ace_inner';
const window = outerWindow; iframe.title = 'pad';
const document = outerDocument; iframe.scrolling = 'no';
setTimeout(() => { iframe.frameBorder = 0;
const iframe = document.createElement('iframe'); iframe.allowTransparency = true; // for IE
iframe.name = 'ace_inner'; iframe.ace_outerWin = outerWindow;
iframe.title = 'pad'; const innerOnloadHandler = () => {
iframe.scrolling = 'no'; const require = window[1].frames[0].require;
iframe.frameBorder = 0; if(!require) {
iframe.allowTransparency = true; // for IE setTimeout(innerOnloadHandler, 10);
iframe.ace_outerWin = window; } else {
document.body.insertBefore(iframe, document.body.firstChild); require.setRootURI('../javascripts/src');
window.readyFunc = () => { require.setLibraryURI('../javascripts/lib');
delete window.readyFunc; require.setGlobalKeyPath('require');
window.editorInfo.onEditorReady();
delete window.editorInfo;
};
const innerWindow = iframe.contentWindow;
const innerDocument = innerWindow.document;
innerDocument.documentElement.classList.add('inner-editor', ...skinVariants);
addStyleTagsFor(innerDocument, includedCSS);
const script = innerDocument.createElement('script'); const plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
script.type = 'text/javascript'; plugins.adoptPluginsFromAncestorsOf(window);
script.src = `../static/js/require-kernel.js?v=${clientVars.randomVersionString}`;
innerDocument.head.appendChild(script);
innerWindow.onload = () => { const jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery;
innerWindow.onload = null; window[1].frames[0].$ = jQuery;
const window = innerWindow; const Ace2Inner = require('ep_etherpad-lite/static/js/ace2_inner');
const require = window.require;
require.setRootURI('../javascripts/src');
require.setLibraryURI('../javascripts/lib');
require.setGlobalKeyPath('require');
window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); plugins.ensure(() => Ace2Inner.init());
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 = [];
hooks.callAll('aceInitInnerdocbodyHead', {iframeHTML: headLines});
const tmp = innerDocument.createElement('div');
tmp.innerHTML = headLines.join('\n');
while (tmp.firstChild) innerDocument.head.appendChild(tmp.firstChild);
innerDocument.body.id = 'innerdocbody';
innerDocument.body.classList.add('innerdocbody');
innerDocument.body.setAttribute('role', 'application');
innerDocument.body.setAttribute('spellcheck', 'false');
innerDocument.body.appendChild(innerDocument.createTextNode('\u00A0')); //  
}, 0);
}; };
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 innerDocument = innerWindow.document;
innerDocument.documentElement.classList.add('inner-editor', ...skinVariants);
addStyleTagsFor(innerDocument, includedCSS);
const script = innerDocument.createElement('script');
script.type = 'text/javascript';
script.src = `../static/js/require-kernel.js?v=${clientVars.randomVersionString}`;
innerDocument.head.appendChild(script);
const styleI = innerDocument.createElement('style');
styleI.type = 'text/css';
styleI.title = 'dynamicsyntax';
innerDocument.head.appendChild(styleI);
const headLines = [];
hooks.callAll('aceInitInnerdocbodyHead', {iframeHTML: headLines});
const tmp = innerDocument.createElement('div');
tmp.innerHTML = headLines.join('\n');
while (tmp.firstChild) innerDocument.head.appendChild(tmp.firstChild);
innerDocument.body.id = 'innerdocbody';
innerDocument.body.classList.add('innerdocbody');
innerDocument.body.setAttribute('role', 'application');
innerDocument.body.setAttribute('spellcheck', 'false');
innerDocument.body.appendChild(innerDocument.createTextNode('\u00A0')); //  
outerDocument.body.id = 'outerdocbody'; outerDocument.body.id = 'outerdocbody';
outerDocument.body.classList.add('outerdocbody', ...pluginUtils.clientPluginNames()); outerDocument.body.classList.add('outerdocbody', ...pluginUtils.clientPluginNames());