diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 77a37cd1f..485a4b2fe 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -501,7 +501,7 @@ const pad = { // order of inits is important here: padimpexp.init(this); padsavedrevs.init(this); - padeditor.init(postAceInit, pad.padOptions.view || {}, this); + padeditor.init(pad.padOptions.view || {}, this).then(postAceInit); paduserlist.init(pad.myUserInfo, this); padconnectionstatus.init(); padmodals.init(this); diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js index 75481fe5e..d8c3ae5ac 100644 --- a/src/static/js/pad_editor.js +++ b/src/static/js/pad_editor.js @@ -34,30 +34,20 @@ const padeditor = (() => { ace: null, // this is accessed directly from other files viewZoom: 100, - init: (readyFunc, initialViewOptions, _pad) => { + init: async (initialViewOptions, _pad) => { Ace2Editor = require('./ace').Ace2Editor; pad = _pad; settings = pad.settings; - - const aceReady = () => { - $('#editorloadingbox').hide(); - if (readyFunc) { - readyFunc(); - - // Listen for clicks on sidediv items - const $outerdoc = $('iframe[name="ace_outer"]').contents().find('#outerdocbody'); - $outerdoc.find('#sidedivinner').on('click', 'div', function () { - const targetLineNumber = $(this).index() + 1; - window.location.hash = `L${targetLineNumber}`; - }); - - exports.focusOnLine(self.ace); - } - }; - self.ace = new Ace2Editor(); - self.ace.init('editorcontainer', '').then( - () => aceReady(), (err) => { throw err || new Error(err); }); + await self.ace.init('editorcontainer', ''); + $('#editorloadingbox').hide(); + // Listen for clicks on sidediv items + const $outerdoc = $('iframe[name="ace_outer"]').contents().find('#outerdocbody'); + $outerdoc.find('#sidedivinner').on('click', 'div', function () { + const targetLineNumber = $(this).index() + 1; + window.location.hash = `L${targetLineNumber}`; + }); + exports.focusOnLine(self.ace); self.ace.setProperty('wraps', true); if (pad.getIsDebugEnabled()) { self.ace.setProperty('dmesg', pad.dmesg);