Skip to content

Commit 38196b7

Browse files
committed
MC-4014: PageBuilder Performance Is Bad With Minimal Content
- Smooth WYSIWYG init scripts
1 parent 929a724 commit 38196b7

File tree

4 files changed

+74
-66
lines changed

4 files changed

+74
-66
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/css/source/content-type/slide/_default.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
}
4343
}
4444
.inline-wysiwyg {
45+
line-height: 1.3;
4546
min-height: 50px;
4647
}
4748
.mce-tinymce-inline {

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

Lines changed: 44 additions & 40 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/slide/preview.ts

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,32 @@ export default class Preview extends BasePreview {
234234
events.trigger("stage:interactionStop");
235235
}
236236

237+
/**
238+
* Init the WYSIWYG
239+
*/
240+
public initWysiwyg(focus: boolean = false) {
241+
if (this.wysiwyg) {
242+
return;
243+
}
244+
245+
const wysiwygConfig = this.config.additional_data.wysiwygConfig.wysiwygConfigData;
246+
247+
if (focus) {
248+
wysiwygConfig.adapter.settings.auto_focus = this.element.id;
249+
}
250+
251+
return WysiwygFactory(
252+
this.parent.id,
253+
this.element.id,
254+
this.config.name,
255+
wysiwygConfig,
256+
this.parent.dataStore,
257+
"content",
258+
).then((wysiwyg: WysiwygInterface): void => {
259+
this.wysiwyg = wysiwyg;
260+
});
261+
}
262+
237263
/**
238264
* @inheritDoc
239265
*/
@@ -291,28 +317,6 @@ export default class Preview extends BasePreview {
291317
});
292318
}
293319

294-
/**
295-
* Init the WYSIWYG
296-
*/
297-
private initWysiwyg(focus: boolean = false) {
298-
const wysiwygConfig = this.config.additional_data.wysiwygConfig.wysiwygConfigData;
299-
300-
if (focus) {
301-
wysiwygConfig.adapter.settings.auto_focus = this.element.id;
302-
}
303-
304-
return WysiwygFactory(
305-
this.parent.id,
306-
this.element.id,
307-
this.config.name,
308-
wysiwygConfig,
309-
this.parent.dataStore,
310-
"content",
311-
).then((wysiwyg: WysiwygInterface): void => {
312-
this.wysiwyg = wysiwyg;
313-
});
314-
}
315-
316320
/**
317321
* Update image data inside data store
318322
*

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import ContentTypeRemovedEventParamsInterface from "../content-type-removed-even
2929
import ObservableUpdater from "../observable-updater";
3030
import PreviewCollection from "../preview-collection";
3131
import Slide from "../slide/preview";
32-
import {default as SliderPreview} from "../slider/preview";
3332

3433
/**
3534
* @api
@@ -82,7 +81,7 @@ export default class Preview extends PreviewCollection {
8281
// Update our KO pointer to the active slide on change
8382
$(this.element).on(
8483
"beforeChange",
85-
(event: Event, slick: {}, currentSlide: any, nextSlide: any) => {
84+
(event: Event, slick: {}, currentSlide: number, nextSlide: number) => {
8685
this.setActiveSlide(nextSlide);
8786
},
8887
).on("afterChange", () => {
@@ -329,7 +328,7 @@ export default class Preview extends PreviewCollection {
329328
_.defer(() => {
330329
if (newItemIndex !== null) {
331330
newItemIndex = null;
332-
(this as SliderPreview).navigateToSlide(itemIndex, true, true);
331+
this.navigateToSlide(itemIndex, true, true);
333332
_.defer(() => {
334333
this.focusedSlide(null);
335334
this.focusedSlide(itemIndex);
@@ -366,7 +365,7 @@ export default class Preview extends PreviewCollection {
366365
if (duplicatedSlide && args.id === duplicatedSlide.id) {
367366
_.defer(() => {
368367
// Mark the new duplicate slide as active
369-
(this as SliderPreview).navigateToSlide(duplicatedSlideIndex, true, true);
368+
this.navigateToSlide(duplicatedSlideIndex, true, true);
370369
duplicatedSlide = duplicatedSlideIndex = null;
371370
});
372371
}

0 commit comments

Comments
 (0)