ace: Lint and simplify script strings

pull/4903/head
Richard Hansen 2021-02-26 01:09:19 -05:00 committed by John McLear
parent c9b1f17f25
commit 3a311d2182
1 changed files with 27 additions and 31 deletions

View File

@ -197,22 +197,21 @@ const Ace2Editor = function () {
iframeHTML.push(`<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js?callback=require.define&v=${clientVars.randomVersionString}"></script>`); iframeHTML.push(`<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_inner.js?callback=require.define&v=${clientVars.randomVersionString}"></script>`);
iframeHTML.push(`<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define&v=${clientVars.randomVersionString}"></script>`); iframeHTML.push(`<script type="text/javascript" src="../javascripts/lib/ep_etherpad-lite/static/js/ace2_common.js?callback=require.define&v=${clientVars.randomVersionString}"></script>`);
iframeHTML.push(scriptTag(` iframeHTML.push(scriptTag(`(() => {
require.setRootURI("../javascripts/src"); const require = window.require;
require.setLibraryURI("../javascripts/lib"); require.setRootURI('../javascripts/src');
require.setGlobalKeyPath("require"); require.setLibraryURI('../javascripts/lib');
require.setGlobalKeyPath('require');
// intentially moved before requiring client_plugins to save a 307 // intentially moved before requiring client_plugins to save a 307
var Ace2Inner = require("ep_etherpad-lite/static/js/ace2_inner"); window.Ace2Inner = require('ep_etherpad-lite/static/js/ace2_inner');
var plugins = require("ep_etherpad-lite/static/js/pluginfw/client_plugins"); window.plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins');
plugins.adoptPluginsFromAncestorsOf(window); window.plugins.adoptPluginsFromAncestorsOf(window);
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").jQuery; // Expose jQuery #HACK window.$ = window.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery;
plugins.ensure(function () { window.plugins.ensure(() => { window.Ace2Inner.init(); });
Ace2Inner.init(); })();`));
});
`));
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>'); iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
@ -227,34 +226,31 @@ const Ace2Editor = function () {
const gt = typeof globalThis === 'object' ? globalThis : window; const gt = typeof globalThis === 'object' ? globalThis : window;
gt.ChildAccessibleAce2Editor = Ace2Editor; gt.ChildAccessibleAce2Editor = Ace2Editor;
const outerScript = ` const outerScript = `(() => {
editorId = ${JSON.stringify(info.id)}; window.editorInfo = parent.ChildAccessibleAce2Editor.registry[${JSON.stringify(info.id)}];
editorInfo = parent.ChildAccessibleAce2Editor.registry[editorId]; window.onload = () => {
window.onload = function () {
window.onload = null; window.onload = null;
setTimeout(function () { setTimeout(() => {
var iframe = document.createElement("IFRAME"); 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';
var outerdocbody = document.getElementById("outerdocbody");
iframe.frameBorder = 0; iframe.frameBorder = 0;
iframe.allowTransparency = true; // for IE iframe.allowTransparency = true; // for IE
outerdocbody.insertBefore(iframe, outerdocbody.firstChild);
iframe.ace_outerWin = window; iframe.ace_outerWin = window;
readyFunc = function () { document.body.insertBefore(iframe, document.body.firstChild);
editorInfo.onEditorReady(); window.readyFunc = () => {
readyFunc = null; delete window.readyFunc;
editorInfo = null; window.editorInfo.onEditorReady();
delete window.editorInfo;
}; };
var doc = iframe.contentWindow.document; const doc = iframe.contentWindow.document;
doc.open(); doc.open();
var text = (${JSON.stringify(iframeHTML.join('\n'))}); doc.write(${JSON.stringify(iframeHTML.join('\n'))});
doc.write(text);
doc.close(); doc.close();
}, 0); }, 0);
} }
`; })();`;
const outerHTML = const outerHTML =
[doctype, `<html class="inner-editor outerdoc ${clientVars.skinVariants}"><head>`]; [doctype, `<html class="inner-editor outerdoc ${clientVars.skinVariants}"><head>`];