Skip to content

Commit 6e352ef

Browse files
committed
ACP2E-2903: Page Builder replaces image when trying to add link and other usability glitches.
1 parent 36c0f5d commit 6e352ef

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/text/preview.js

Lines changed: 8 additions & 1 deletion
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/js/utils/editor.js

Lines changed: 2 additions & 1 deletion
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/text/preview.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import $ from "jquery";
77
import events from "Magento_PageBuilder/js/events";
8+
import {Editor} from "tinymce";
89
import _ from "underscore";
910
import HideShowOption from "../../content-type-menu/hide-show-option";
1011
import {OptionsInterface} from "../../content-type-menu/option.types";
@@ -158,7 +159,16 @@ export default class Preview extends BasePreview {
158159

159160
if (focus) {
160161
wysiwygConfig.adapter.settings.auto_focus = this.element.id;
161-
wysiwygConfig.adapter.settings.init_instance_callback = () => {
162+
wysiwygConfig.adapter.settings.init_instance_callback = (editor: Editor) => {
163+
editor.on("mousedown", (event) => {
164+
if (event.target.nodeName === "IMG"
165+
&& event.button !== 2
166+
&& editor.dom.getRoot() !== document.activeElement
167+
) {
168+
editor.selection.select(event.target);
169+
editor.nodeChanged();
170+
}
171+
});
162172
_.defer(() => {
163173
this.element.blur();
164174
this.element.focus();

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/utils/editor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ export function createBookmark(event: JQueryEventObject): Bookmark {
279279
* @param bookmark
280280
*/
281281
export function moveToBookmark(bookmark: Bookmark) {
282-
((window as any).tinymce.activeEditor as Editor).selection.moveToBookmark(bookmark);
282+
getActiveEditor().selection.moveToBookmark(bookmark);
283+
getActiveEditor().nodeChanged();
283284
}
284285

285286
/**

0 commit comments

Comments
 (0)