From 3bcf0d8cbf0330f3a65b25f74f0193961607ebe4 Mon Sep 17 00:00:00 2001 From: James Dinsdale Date: Thu, 10 Jan 2019 13:36:44 +0000 Subject: [PATCH 1/2] Fix issues inserting Widgets with nested WYSIWYGs This PR is a potential fix for issues #19742 and #13409 (Thanks to @EduardTd for pointing me in the right direction). I've tested this briefly in my own install and it appears to resolve the issue. Submitting this PR so that the issue can be tested fully. --- lib/web/mage/adminhtml/wysiwyg/widget.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/web/mage/adminhtml/wysiwyg/widget.js b/lib/web/mage/adminhtml/wysiwyg/widget.js index 68206fdec6201..ea85185954d18 100644 --- a/lib/web/mage/adminhtml/wysiwyg/widget.js +++ b/lib/web/mage/adminhtml/wysiwyg/widget.js @@ -456,7 +456,7 @@ define([ parameters: params, onComplete: function (transport) { try { - editor = wysiwyg.activeEditor(); + editor = tinyMCE.get(this.widgetTargetId); widgetTools.onAjaxSuccess(transport); widgetTools.dialogWindow.modal('closeModal'); @@ -469,7 +469,7 @@ define([ editor.selection.select(activeNode); editor.selection.setContent(transport.responseText); } else if (this.bMark) { - wysiwyg.activeEditor().selection.moveToBookmark(this.bMark); + editor.selection.moveToBookmark(this.bMark); } } @@ -513,7 +513,7 @@ define([ * @return {null|wysiwyg.Editor|*} */ getWysiwyg: function () { - return wysiwyg.activeEditor(); + return tinyMCE.get(this.widgetTargetId); }, /** From d4e0c28cc3e9016d640f53e5fc27d56c6a1067ab Mon Sep 17 00:00:00 2001 From: James Dinsdale Date: Thu, 17 Jan 2019 15:58:34 +0000 Subject: [PATCH 2/2] Use wysiwygAdapter instead of global tinyMCE variable I realised that tinyMCE is already being required as the wysiwygAdapter, so I've updated the code to point to that dependency instead. Still works. --- lib/web/mage/adminhtml/wysiwyg/widget.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/web/mage/adminhtml/wysiwyg/widget.js b/lib/web/mage/adminhtml/wysiwyg/widget.js index ea85185954d18..aa38e2e1875f6 100644 --- a/lib/web/mage/adminhtml/wysiwyg/widget.js +++ b/lib/web/mage/adminhtml/wysiwyg/widget.js @@ -456,7 +456,7 @@ define([ parameters: params, onComplete: function (transport) { try { - editor = tinyMCE.get(this.widgetTargetId); + editor = wysiwyg.get(this.widgetTargetId); widgetTools.onAjaxSuccess(transport); widgetTools.dialogWindow.modal('closeModal'); @@ -513,7 +513,7 @@ define([ * @return {null|wysiwyg.Editor|*} */ getWysiwyg: function () { - return tinyMCE.get(this.widgetTargetId); + return wysiwyg.get(this.widgetTargetId); }, /**