Ace2Inner: Promisify init()

This commit is contained in:
Richard Hansen 2021-03-19 16:21:25 -04:00 committed by John McLear
parent 742a7cd430
commit 81e36cf3c7
2 changed files with 28 additions and 32 deletions

View file

@ -307,8 +307,7 @@ const Ace2Editor = function () {
await new Promise((resolve, reject) => innerWindow.plugins.ensure( await new Promise((resolve, reject) => innerWindow.plugins.ensure(
(err) => err != null ? reject(err) : resolve())); (err) => err != null ? reject(err) : resolve()));
debugLog('Ace2Editor.init() waiting for Ace2Inner.init()'); debugLog('Ace2Editor.init() waiting for Ace2Inner.init()');
await new Promise((resolve, reject) => innerWindow.Ace2Inner.init( await innerWindow.Ace2Inner.init(info);
info, (err) => err != null ? reject(err) : resolve()));
debugLog('Ace2Editor.init() Ace2Inner.init() returned'); debugLog('Ace2Editor.init() Ace2Inner.init() returned');
loaded = true; loaded = true;
doActionsPendingInit(); doActionsPendingInit();

View file

@ -3895,8 +3895,8 @@ function Ace2Inner(editorInfo) {
editorInfo.ace_performDocumentApplyAttributesToRange = editorInfo.ace_performDocumentApplyAttributesToRange =
(...args) => documentAttributeManager.setAttributesOnRange(...args); (...args) => documentAttributeManager.setAttributesOnRange(...args);
this.init = (cb) => { this.init = async () => {
$(document).ready(() => { await $.ready;
doc = document; // defined as a var in scope outside doc = document; // defined as a var in scope outside
inCallStack('setup', () => { inCallStack('setup', () => {
const body = doc.getElementById('innerdocbody'); const body = doc.getElementById('innerdocbody');
@ -3926,13 +3926,10 @@ function Ace2Inner(editorInfo) {
rep, rep,
documentAttributeManager, documentAttributeManager,
}); });
scheduler.setTimeout(cb, 0);
});
}; };
} }
exports.init = (editorInfo, cb) => { exports.init = async (editorInfo) => {
const editor = new Ace2Inner(editorInfo); const editor = new Ace2Inner(editorInfo);
editor.init(cb); await editor.init();
}; };