From fee3022ad8d073c8b169cb8f38b85baf8a3ebdfc Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Mon, 25 Jul 2022 19:56:01 +0100 Subject: [PATCH] Added tinymce de-focus toolbar hack for drawing editor load The tinymce event system would not pick up the focus within the loaded draw.io instance, after the drawing toolbar button was clicked, hence the toolbar would hang around. This adds a hack to dispatch a mousedown event on the body to get the toolbar to hide. For #3597 --- resources/js/wysiwyg/plugin-codeeditor.js | 1 - resources/js/wysiwyg/plugin-drawio.js | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/wysiwyg/plugin-codeeditor.js b/resources/js/wysiwyg/plugin-codeeditor.js index db4490215..82052a40d 100644 --- a/resources/js/wysiwyg/plugin-codeeditor.js +++ b/resources/js/wysiwyg/plugin-codeeditor.js @@ -165,7 +165,6 @@ function register(editor, url) { showPopup(editor, textContent, '', (newCode, newLang) => { const pre = doc.createElement('pre'); const code = doc.createElement('code'); - console.log(newCode); code.classList.add(`language-${newLang}`); code.innerText = newCode; pre.append(code); diff --git a/resources/js/wysiwyg/plugin-drawio.js b/resources/js/wysiwyg/plugin-drawio.js index 7d679d539..54a160921 100644 --- a/resources/js/wysiwyg/plugin-drawio.js +++ b/resources/js/wysiwyg/plugin-drawio.js @@ -106,6 +106,8 @@ export function getPlugin(providedOptions) { icon: 'diagram', onAction() { editor.execCommand('drawio'); + // Hack to de-focus the tinymce editor toolbar + window.document.body.dispatchEvent(new Event('mousedown', {bubbles: true})); }, fetch(callback) { callback([