diff --git a/private/js/cms.dialog.js b/private/js/cms.dialog.js index 447ce6c7..c11265fa 100644 --- a/private/js/cms.dialog.js +++ b/private/js/cms.dialog.js @@ -330,7 +330,6 @@ class CmsForm { } close(event) { - console.log(event); if (!event || !this.dialog.contains(event.target)) { if (this.cancel) { diff --git a/private/js/cms.editor.js b/private/js/cms.editor.js index 2f0d01fc..10fd9eef 100644 --- a/private/js/cms.editor.js +++ b/private/js/cms.editor.js @@ -171,7 +171,6 @@ class CMSEditor { wrapper = this._initInlineRichText(document.getElementsByClassName(plugin[0]), url, id); if (wrapper) { wrapper.dataset.cmsCsrfToken = this.CMS.config.csrf; - wrapper.dataset.onClose = plugin[1].onClose; wrapper.dataset.cmsField = edit_fields; wrapper.dataset.cmsType = ( generic_inline_fields[search_key] === 'HTMLFormField' ? @@ -188,22 +187,21 @@ class CMSEditor { // Catch CMS double click event if present, since double click is needed by Editor this.observer.observe(wrapper); if (this.CMS) { - this.CMS.$(wrapper).on('dblclick.cms-editor', function (event) { + // Remove django CMS core's double click event handler which opens an edit dialog + this.CMS.$(wrapper).off('dblclick.cms.plugin') + .on('dblclick.cms-editor', function (event) { event.stopPropagation(); }); wrapper.addEventListener('focusin.cms-editor', () => { this._highlightTextplugin(id); }, true); + // Prevent tooltip on hover + this.CMS.$(wrapper).off('pointerover.cms.plugin pointerout.cms.plugin') + .on('pointerover.cms-editor', function (event) { + this.CMS.API.Tooltip.displayToggle(false, event.target, '', id); + event.stopPropagation(); + }); } - - // Prevent tooltip on hover - document.addEventListener('pointerover.cms-editor', (event) => { - // use time out to let other event handlers (CMS' !) run first. - setTimeout(function () { - // do not show tooltip on inline editing text fields. - this.CMS.API.Tooltip.displayToggle(false, event.target, '', id); - }, 0); - }); } } }, this); @@ -397,6 +395,11 @@ class CMSEditor { } return; // No databridge to evaluate } + if (this.CMS) { + // Success: + // Remove an error message from a previous save attempt + this.CMS.API.Messages.close(); + } const script = dom.querySelector('script#data-bridge'); el.dataset.changed = 'false'; if (script && script.textContent.length > 2) { @@ -428,9 +431,7 @@ class CMSEditor { } window.console.error(error.message); }); - return el.dataset.changed === 'false'; } - return true; } // CMS Editor: addPluginForm diff --git a/private/js/cms.texteditor.js b/private/js/cms.texteditor.js index cae5ca8a..858c5bfa 100644 --- a/private/js/cms.texteditor.js +++ b/private/js/cms.texteditor.js @@ -10,9 +10,7 @@ class CmsTextEditor { this.plugin_id = parseInt(id_split[id_split.length-1]); this.options = options; this.events = {}; - this.save = (el) => { - return save_callback(el); - }; + this.save = save_callback; this.init(); } @@ -62,13 +60,18 @@ class CmsTextEditor { } _blur (e) { - const success = this.save(e.target); - console.log(success); - if (!success) { - e.target.innerText = this.options.undo; - e.target.dataset.changed = 'false'; - e.target.focus(); - } + this.save(e.target, (el, response) => { + console.log("timer set"); + console.log(response); + setTimeout(() => { + console.log(e.target); + if (e.target.dataset.changed === 'true') { + e.target.innerText = this.options.undo; + e.target.dataset.changed = 'false'; + e.target.focus(); + } + }, 100); + }); } _paste (e) {