ace: Pass objects to Ace2Inner via function args

This commit is contained in:
Richard Hansen 2021-02-27 21:02:43 -05:00 committed by John McLear
parent 6fe0154129
commit e57829183d
2 changed files with 7 additions and 10 deletions

View file

@ -209,7 +209,7 @@ const Ace2Editor = function () {
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; window.$ = window.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery;
window.plugins.ensure(() => { window.Ace2Inner.init(); }); window.plugins.ensure(() => { window.Ace2Inner.init(parent.editorInfo, parent.readyFunc); });
})();`)); })();`));
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>'); iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');

View file

@ -30,7 +30,7 @@ const htmlPrettyEscape = Ace2Common.htmlPrettyEscape;
const noop = Ace2Common.noop; const noop = Ace2Common.noop;
const hooks = require('./pluginfw/hooks'); const hooks = require('./pluginfw/hooks');
function Ace2Inner() { function Ace2Inner(editorInfo) {
const makeChangesetTracker = require('./changesettracker').makeChangesetTracker; const makeChangesetTracker = require('./changesettracker').makeChangesetTracker;
const colorutils = require('./colorutils').colorutils; const colorutils = require('./colorutils').colorutils;
const makeContentCollector = require('./contentcollector').makeContentCollector; const makeContentCollector = require('./contentcollector').makeContentCollector;
@ -57,7 +57,6 @@ function Ace2Inner() {
let thisAuthor = ''; let thisAuthor = '';
let disposed = false; let disposed = false;
const editorInfo = parent.editorInfo;
const focus = () => { const focus = () => {
window.focus(); window.focus();
@ -3896,7 +3895,7 @@ function Ace2Inner() {
editorInfo.ace_performDocumentApplyAttributesToRange = editorInfo.ace_performDocumentApplyAttributesToRange =
(...args) => documentAttributeManager.setAttributesOnRange(...args); (...args) => documentAttributeManager.setAttributesOnRange(...args);
this.init = () => { this.init = (cb) => {
$(document).ready(() => { $(document).ready(() => {
doc = document; // defined as a var in scope outside doc = document; // defined as a var in scope outside
inCallStack('setup', () => { inCallStack('setup', () => {
@ -3928,14 +3927,12 @@ function Ace2Inner() {
documentAttributeManager, documentAttributeManager,
}); });
scheduler.setTimeout(() => { scheduler.setTimeout(cb, 0);
parent.readyFunc(); // defined in code that sets up the inner iframe
}, 0);
}); });
}; };
} }
exports.init = () => { exports.init = (editorInfo, cb) => {
const editor = new Ace2Inner(); const editor = new Ace2Inner(editorInfo);
editor.init(); editor.init(cb);
}; };