|
6 | 6 | import $ from "jquery";
|
7 | 7 | import $t from "mage/translate";
|
8 | 8 | import events from "Magento_PageBuilder/js/events";
|
| 9 | +import {PreviewSortableSortUpdateEventParams} from "../../binding/sortable-children"; |
9 | 10 | import Config from "../../config";
|
10 | 11 | import ConditionalRemoveOption from "../../content-type-menu/conditional-remove-option";
|
11 | 12 | import {OptionsInterface} from "../../content-type-menu/option.d";
|
@@ -206,9 +207,10 @@ export default class Preview extends BasePreview {
|
206 | 207 | * @returns {Boolean}
|
207 | 208 | */
|
208 | 209 | public activateEditor(preview: Preview, event: JQueryEventObject) {
|
209 |
| - const element = this.element || this.textarea; |
| 210 | + const element = this.wysiwyg && this.element || this.textarea; |
210 | 211 |
|
211 |
| - if (event.currentTarget !== event.target && |
| 212 | + if (!element || |
| 213 | + event.currentTarget !== event.target && |
212 | 214 | event.target !== element &&
|
213 | 215 | !element.contains(event.target)
|
214 | 216 | ) {
|
@@ -295,6 +297,13 @@ export default class Preview extends BasePreview {
|
295 | 297 | events.trigger(`image:${this.parent.id}:assignAfter`, imageObject);
|
296 | 298 | });
|
297 | 299 |
|
| 300 | + // Remove wysiwyg before assign new instance. |
| 301 | + events.on("childContentType:sortUpdate", (args: PreviewSortableSortUpdateEventParams) => { |
| 302 | + if (args.instance.id === this.parent.parent.id) { |
| 303 | + this.wysiwyg = null; |
| 304 | + } |
| 305 | + }); |
| 306 | + |
298 | 307 | events.on(`${this.config.name}:mountAfter`, (args: ContentTypeMountEventParamsInterface) => {
|
299 | 308 | if (args.id === this.parent.id) {
|
300 | 309 | const dataStore = this.parent.dataStore.get();
|
|
0 commit comments