diff --git a/src/static/js/ace.js b/src/static/js/ace.js
index 2255a7a9a..8613d9e37 100644
--- a/src/static/js/ace.js
+++ b/src/static/js/ace.js
@@ -150,15 +150,9 @@ const Ace2Editor = function () {
info = null; // prevent IE 6 closure memory leaks
});
- this.init = function (containerId, initialCode, doneFunc) {
+ this.init = async function (containerId, initialCode) {
this.importText(initialCode);
- info.onEditorReady = () => {
- loaded = true;
- doActionsPendingInit();
- doneFunc();
- };
-
// calls to these functions ($$INCLUDE_...) are replaced when this file is processed
// and compressed, putting the compressed code from the named file directly into the
// source here.
@@ -190,7 +184,7 @@ const Ace2Editor = function () {
iframeHTML.push(``);
}
- iframeHTML.push(scriptTag(`(() => {
+ iframeHTML.push(scriptTag(`(async () => {
const require = window.require;
require.setRootURI(${JSON.stringify(absUrl('../javascripts/src'))});
require.setLibraryURI(${JSON.stringify(absUrl('../javascripts/lib'))});
@@ -203,10 +197,12 @@ const Ace2Editor = function () {
window.$ = window.jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery;
- window.plugins.ensure(() => {
- const editorInfo = parent.parent.ace2EditorInfo;
- window.Ace2Inner.init(editorInfo, editorInfo.onEditorReady);
- });
+ await new Promise((resolve, reject) => window.plugins.ensure(
+ (err) => err != null ? reject(err) : resolve()));
+ const editorInfo = parent.parent.ace2EditorInfo;
+ await new Promise((resolve, reject) => window.Ace2Inner.init(
+ editorInfo, (err) => err != null ? reject(err) : resolve()));
+ editorInfo.onEditorReady();
})();`));
iframeHTML.push('');
@@ -218,24 +214,22 @@ const Ace2Editor = function () {
iframeHTML.push('