diff --git a/src/core/js/ext_editmode_wysiwyg_text.js b/src/core/js/ext_editmode_wysiwyg_text.js index 2ee27ab6d80015e5b4faf0131be25e7c7b166ff3..101c77bd7712b94699bd993e9515d058a8c9a510 100644 --- a/src/core/js/ext_editmode_wysiwyg_text.js +++ b/src/core/js/ext_editmode_wysiwyg_text.js @@ -23,14 +23,39 @@ /** * Replaces textareas in the edit mode by a wysiwyg editor */ -var ext_editmode_wysiwyg_text = function ($, logger) { +var ext_editmode_wysiwyg_text = function ($, logger, ClassicEditor) { + + var _insertEditor = function (fieldId) { + ClassicEditor + .create(document.querySelector('#' + fieldId), { + plugins: ClassicEditor.builtinPlugins, + }) + .then(editor => { + console.log('Initialized editor for ' + fieldId); + }) + .catch(error => { + console.error(error.stack); + }); + } + + var replaceTextAreas = function () { + const fields = $('textarea'); + for (let field of fields) { + // TODO(fspreck): This will be replaced by a whitelist of properties + // in the future + if (field.id) { + _insertEditor(field.id); + } + } + } var init = function () {}; return { init: init, + replaceTextAreas: replaceTextAreas, }; -}($, log.getLogger("ext_editmode_wysiwyg_text")); +}($, log.getLogger("ext_editmode_wysiwyg_text"), ClassicEditor); $(document).ready(() => { if ("${BUILD_MODULE_EXT_EDITMODE_WYSIWYG_TEXT}" == "ENABLED") {