Skip to content

Commit 4a9d2e9

Browse files
committed
MC-4189: IE11 - PageBuilder Does Not Load
- Fix tinymce adapters clear selection logic for IE 11
1 parent 6f599f3 commit 4a9d2e9

File tree

2 files changed

+39
-8
lines changed
  • app/code/Magento/PageBuilder/view/adminhtml/web

2 files changed

+39
-8
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/wysiwyg/tinymce4.js

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/wysiwyg/tinymce4.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ export default class Wysiwyg implements WysiwygInterface {
118118
* Called for the onFocus event
119119
*/
120120
private onFocus() {
121-
// Clear any existing document selections
122-
window.getSelection().empty();
121+
this.clearSelection();
123122

124123
$(`#${this.elementId}`)
125124
.closest(`${this.config.adapter.settings.fixed_toolbar_container}`)
@@ -138,8 +137,8 @@ export default class Wysiwyg implements WysiwygInterface {
138137
* Called for the onBlur events
139138
*/
140139
private onBlur() {
141-
// Clear any selections in the editable area
142-
window.getSelection().empty();
140+
this.clearSelection();
141+
143142
$(`#${this.elementId}`)
144143
.closest(`${this.config.adapter.settings.fixed_toolbar_container}`)
145144
.removeClass("pagebuilder-toolbar-active");
@@ -164,4 +163,19 @@ export default class Wysiwyg implements WysiwygInterface {
164163
this.dataStore.get(this.fieldName) as string,
165164
);
166165
}
166+
167+
/**
168+
* Clear any selections in the editable area
169+
*/
170+
private clearSelection(): void {
171+
if (window.getSelection) {
172+
if (window.getSelection().empty) { // Chrome
173+
window.getSelection().empty();
174+
} else if (window.getSelection().removeAllRanges) { // Firefox
175+
window.getSelection().removeAllRanges();
176+
}
177+
} else if ((document as any).selection) { // IE?
178+
(document as any).selection.empty();
179+
}
180+
}
167181
}

0 commit comments

Comments
 (0)