diff --git a/src/core/js/ext_editmode_wysiwyg_text.js b/src/core/js/ext_editmode_wysiwyg_text.js index 745189b38a2a2226900c4ce748a6e2e6b75065b1..a95b9911e37bfd2cff7022a624b64942b10655d8 100644 --- a/src/core/js/ext_editmode_wysiwyg_text.js +++ b/src/core/js/ext_editmode_wysiwyg_text.js @@ -39,42 +39,35 @@ */ var ext_editmode_wysiwyg_text = function ($, logger, ClassicEditor, edit_mode, getPropertyElements, getPropertyDatatype, getPropertyName) { - var insertEditorInProperty = function (prop) { + var insertEditorInProperty = async function (prop) { if (!(getPropertyDatatype(prop) === 'TEXT')) { // Ignore anything that isn't a list property, even LIST<TEXT> return; } - let editor; - - ClassicEditor - .create(prop.querySelector('textarea'), { - // use all plugins since we built the editor dependency to - // contain only those we need. - plugins: ClassicEditor.builtinPlugins, - // Markdown needs a header row so enforce this - table: { - defaultHeadings: { - rows: 1, - columns: 0 + try{ + const editor = await ClassicEditor + .create(prop.querySelector('textarea'), { + // use all plugins since we built the editor dependency to + // contain only those we need. + plugins: ClassicEditor.builtinPlugins, + // Markdown needs a header row so enforce this + table: { + defaultHeadings: { + rows: 1, + columns: 0 + }, }, - }, - }) - .then(newEditor => { - console.log('Initialized editor for ' + getPropertyName(prop)); - editor = newEditor; - }).then( - () => { - // Manually implement saving the data since edit mode is not - // a form to be submitted. - editor.model.document.on("change:data", (e) => { - editor.updateSourceElement(); - }); - } - ) - .catch(error => { - console.error(error.stack); + }) + console.log('Initialized editor for ' + getPropertyName(prop)); + // Manually implement saving the data since edit mode is not + // a form to be submitted. + editor.model.document.on("change:data", (e) => { + editor.updateSourceElement(); }); + } catch(error) { + console.error(error.stack); + } } var replaceTextAreas = function (entity) {