Skip to content

Commit bd005cb

Browse files
committed
Merge remote-tracking branch 'origin/MC-3918' into cms-team-1-delivery
2 parents 139c361 + 8b31338 commit bd005cb

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ define([
3737
this.config = config;
3838
this.schema = config.schema || html5Schema;
3939

40-
_.bindAll(this, 'beforeSetContent', 'saveContent', 'onChangeContent', 'openFileBrowser', 'updateTextArea');
40+
_.bindAll(
41+
this,
42+
'beforeSetContent',
43+
'saveContent',
44+
'onChangeContent',
45+
'openFileBrowser',
46+
'updateTextArea',
47+
'removeEvents'
48+
);
4149

4250
varienGlobalEvents.attachEventHandler('tinymceChange', this.onChangeContent);
4351
varienGlobalEvents.attachEventHandler('tinymceBeforeSetContent', this.beforeSetContent);
@@ -72,6 +80,17 @@ define([
7280
tinyMCE3.init(this.getSettings(mode));
7381
},
7482

83+
/**
84+
* Remove events from instance.
85+
*
86+
* @param {String} wysiwygId
87+
*/
88+
removeEvents: function (wysiwygId) {
89+
var editor = tinyMceEditors.get(wysiwygId);
90+
91+
varienGlobalEvents.removeEventHandler('tinymceChange', editor.onChangeContent);
92+
},
93+
7594
/**
7695
* @param {*} mode
7796
* @return {Object}

app/code/Magento/Ui/Component/Form/Element/Wysiwyg.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public function __construct(
5050
) {
5151
$wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : [];
5252
$this->form = $formFactory->create();
53+
$wysiwygId = $context->getNamespace() . '_' . $data['name'];
5354
$this->editor = $this->form->addField(
54-
$context->getNamespace() . '_' . $data['name'],
55+
$wysiwygId,
5556
\Magento\Framework\Data\Form\Element\Editor::class,
5657
[
5758
'force_load' => true,
@@ -62,6 +63,7 @@ public function __construct(
6263
]
6364
);
6465
$data['config']['content'] = $this->editor->getElementHtml();
66+
$data['config']['wysiwygId'] = $wysiwygId;
6567

6668
parent::__construct($context, $components, $data);
6769
}

app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ define([
6161
return this;
6262
},
6363

64+
/**
65+
* @inheritdoc
66+
*/
67+
destroy: function () {
68+
this._super();
69+
wysiwyg.removeEvents(this.wysiwygId);
70+
},
71+
6472
/**
6573
*
6674
* @returns {exports}

lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ define([
4040
'onChangeContent',
4141
'openFileBrowser',
4242
'updateTextArea',
43-
'onUndo'
43+
'onUndo',
44+
'removeEvents'
4445
);
4546

4647
varienGlobalEvents.attachEventHandler('tinymceChange', this.onChangeContent);
@@ -110,7 +111,7 @@ define([
110111
tinyMCE4.ui.FloatPanel.zIndex = settings.toolbarZIndex;
111112
}
112113

113-
varienGlobalEvents.removeEventHandler('tinymceChange', this.onChangeContent);
114+
this.removeEvents(self.id);
114115
}
115116

116117
jQuery.when.apply(jQuery, deferreds).done(function () {
@@ -120,6 +121,17 @@ define([
120121
}.bind(this));
121122
},
122123

124+
/**
125+
* Remove events from instance.
126+
*
127+
* @param {String} wysiwygId
128+
*/
129+
removeEvents: function (wysiwygId) {
130+
var editor = tinyMceEditors.get(wysiwygId);
131+
132+
varienGlobalEvents.removeEventHandler('tinymceChange', editor.onChangeContent);
133+
},
134+
123135
/**
124136
* Add plugin to the toolbar if not added.
125137
*

0 commit comments

Comments
 (0)