From e57829183db6eec90b11b5da825a914c5768b4d9 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 27 Feb 2021 21:02:43 -0500 Subject: [PATCH] ace: Pass objects to Ace2Inner via function args --- src/static/js/ace.js | 2 +- src/static/js/ace2_inner.js | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/static/js/ace.js b/src/static/js/ace.js index eaea9d8aa..4a6c4060a 100644 --- a/src/static/js/ace.js +++ b/src/static/js/ace.js @@ -209,7 +209,7 @@ const Ace2Editor = function () { 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(''); diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 5ae4f0660..8fef627b5 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -30,7 +30,7 @@ const htmlPrettyEscape = Ace2Common.htmlPrettyEscape; const noop = Ace2Common.noop; const hooks = require('./pluginfw/hooks'); -function Ace2Inner() { +function Ace2Inner(editorInfo) { const makeChangesetTracker = require('./changesettracker').makeChangesetTracker; const colorutils = require('./colorutils').colorutils; const makeContentCollector = require('./contentcollector').makeContentCollector; @@ -57,7 +57,6 @@ function Ace2Inner() { let thisAuthor = ''; let disposed = false; - const editorInfo = parent.editorInfo; const focus = () => { window.focus(); @@ -3896,7 +3895,7 @@ function Ace2Inner() { editorInfo.ace_performDocumentApplyAttributesToRange = (...args) => documentAttributeManager.setAttributesOnRange(...args); - this.init = () => { + this.init = (cb) => { $(document).ready(() => { doc = document; // defined as a var in scope outside inCallStack('setup', () => { @@ -3928,14 +3927,12 @@ function Ace2Inner() { documentAttributeManager, }); - scheduler.setTimeout(() => { - parent.readyFunc(); // defined in code that sets up the inner iframe - }, 0); + scheduler.setTimeout(cb, 0); }); }; } -exports.init = () => { - const editor = new Ace2Inner(); - editor.init(); +exports.init = (editorInfo, cb) => { + const editor = new Ace2Inner(editorInfo); + editor.init(cb); };