Skip to content

Commit 9edfa5f

Browse files
committed
PB-170: TinyMCE Performance is very poor with multiple instances on Stage
- Fix widget insertion
1 parent 4f8e301 commit 9edfa5f

File tree

11 files changed

+61
-14
lines changed

11 files changed

+61
-14
lines changed

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/OverlayActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
</arguments>
162162
<!-- Validate bottom edge of overlay -->
163163
<comment userInput="Validate bottom edge of overlay" stepKey="commentValidateBottomEdgeOfOverlay"/>
164-
<executeJS function="return {{page.wrapperJS(index)}}.getBoundingClientRect().top+{{padding.paddingTop}}+120" stepKey="wrapperTopPaddingContent"/>
164+
<executeJS function="return {{page.wrapperJS(index)}}.getBoundingClientRect().top+{{padding.paddingTop}}+110" stepKey="wrapperTopPaddingContent"/>
165165
<executeJS function="return {{page.overlayJS(index)}}.getBoundingClientRect().bottom" stepKey="overlayBottomPosition"/>
166166
<executeJS function="return Math.round(({$wrapperTopPaddingContent}/{$overlayBottomPosition})*100)/100" stepKey="overlayBottomRatio"/>
167167
<assertEquals stepKey="assertOverlayBottomRatio">

app/code/Magento/PageBuilder/Test/Mftf/Section/PageBuilderTextSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<element name="text" type="text" selector="(//div[contains(@class,'pagebuilder-text')])[{{arg1}}]/div//*[contains(.,'{{arg2}}')]" parameterized="true"/>
1717
<element name="textAnchorText" type="text" selector="(//div[@data-content-type='text'])[{{arg1}}]//div[contains(@class,'inline-wysiwyg')]//a[text()='{{arg2}}']" parameterized="true"/>
1818
<element name="directive" type="text" selector="(//div[contains(@class,'pagebuilder-text')])[{{arg1}}]/div//span[contains(.,'{{arg2}}')]" parameterized="true"/>
19+
<element name="directiveFocused" type="text" selector="(//div[contains(@class,'pagebuilder-text')])[{{arg1}}]/div//span[contains(.,'{{arg2}}') and @data-mce-selected='1']" parameterized="true"/>
1920
<element name="mcePlaceholder" type="text" selector="(//div[contains(@class,'pagebuilder-text')])[{{arg1}}]/div//*[starts-with(@id, '{{arg2}}')]" parameterized="true"/>
2021
<element name="variablePlaceholder" type="text" selector="(//div[contains(@class,'pagebuilder-text')])[{{arg}}]/div//*[contains(@class, 'magento-variable') and contains(@class, 'magento-placeholder')]" parameterized="true"/>
2122
<element name="widgetPlaceholder" type="text" selector="(//div[contains(@class,'pagebuilder-text')])[{{arg}}]/div//*[contains(@class, 'magento-placeholder') and contains(@class, 'magento-widget')]" parameterized="true"/>

app/code/Magento/PageBuilder/Test/Mftf/Test/AdminPageBuilderTextTest.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,20 @@
28342834
<dontSeeElement selector="{{TextOnStage.text('1', PageBuilderVariableWidgetText.value)}}" stepKey="dontSeeOriginalTextOnStage"/>
28352835
<seeElement selector="{{TextOnStage.text('1', PageBuilderVariableWidgetText.expectedString1)}}" stepKey="seeExpectedString" />
28362836
<seeElement selector="{{TextOnStage.text('1', PageBuilderVariableWidgetText.expectedString2)}}" stepKey="seeExpectedString1" />
2837+
<!-- Verify clicking the variable focuses the directive -->
2838+
<actionGroup ref="unFocusOptionMenu" stepKey="unFocusEditor">
2839+
<argument name="contentType" value="PageBuilderTextContentType"/>
2840+
</actionGroup>
2841+
<click selector="{{TextOnStage.directive('1', TinyMCEVariableBaseURL.editPanelValue)}}" stepKey="clickOnWidgetPlaceholder"/>
2842+
<waitForElementVisible selector="{{TextOnStage.directiveFocused('1', TinyMCEVariableBaseURL.editPanelValue)}}" stepKey="waitForDirectiveFocused"/>
2843+
<seeElement selector="{{TextOnStage.directiveFocused('1', TinyMCEVariableBaseURL.editPanelValue)}}" stepKey="verifyDirectiveIsFocused"/>
2844+
<!-- Save page and verify single clicking on widget will retain selection -->
2845+
<actionGroup ref="saveAndContinueEditCmsPage" stepKey="saveAndContinueEditCmsPage"/>
2846+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
2847+
<click selector="{{TextOnStage.directive('1', TinyMCEVariableBaseURL.editPanelValue)}}" stepKey="clickOnWidgetPlaceholder2"/>
2848+
<waitForElementVisible selector="{{TextOnStage.tinymceInFocus('1')}}" stepKey="waitForTinyMCEFocus"/>
2849+
<waitForElementVisible selector="{{TextOnStage.directiveFocused('1', TinyMCEVariableBaseURL.editPanelValue)}}" stepKey="waitForDirectiveFocused2"/>
2850+
<seeElement selector="{{TextOnStage.directiveFocused('1', TinyMCEVariableBaseURL.editPanelValue)}}" stepKey="verifyDirectiveIsFocused2"/>
28372851
</test>
28382852
<test name="TextAddWidgetWithinStringInlineWYSIWYG">
28392853
<annotations>
@@ -2884,6 +2898,20 @@
28842898
<dontSeeElement selector="{{TextOnStage.text('1', PageBuilderVariableWidgetText.value)}}" stepKey="dontSeeOriginalTextOnStage"/>
28852899
<seeElement selector="{{TextOnStage.text('1', PageBuilderVariableWidgetText.expectedString1)}}" stepKey="seeExpectedString" />
28862900
<seeElement selector="{{TextOnStage.text('1', PageBuilderVariableWidgetText.expectedString2)}}" stepKey="seeExpectedString1" />
2901+
<!-- Verify clicking the variable focuses the directive -->
2902+
<actionGroup ref="unFocusOptionMenu" stepKey="unFocusEditor">
2903+
<argument name="contentType" value="PageBuilderTextContentType"/>
2904+
</actionGroup>
2905+
<click selector="{{TextOnStage.directive('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="clickOnWidgetPlaceholder"/>
2906+
<waitForElementVisible selector="{{TextOnStage.directiveFocused('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="waitForDirectiveFocused"/>
2907+
<seeElement selector="{{TextOnStage.directiveFocused('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="verifyDirectiveIsFocused"/>
2908+
<!-- Save page and verify single clicking on widget will retain selection -->
2909+
<actionGroup ref="saveAndContinueEditCmsPage" stepKey="saveAndContinueEditCmsPage"/>
2910+
<actionGroup ref="switchToPageBuilderStage" stepKey="switchToPageBuilderStage"/>
2911+
<click selector="{{TextOnStage.directive('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="clickOnWidgetPlaceholder2"/>
2912+
<waitForElementVisible selector="{{TextOnStage.tinymceInFocus('1')}}" stepKey="waitForTinyMCEFocus"/>
2913+
<waitForElementVisible selector="{{TextOnStage.directiveFocused('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="waitForDirectiveFocused2"/>
2914+
<seeElement selector="{{TextOnStage.directiveFocused('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="verifyDirectiveIsFocused2"/>
28872915
</test>
28882916
<test name="TextCopyAndPasteAllTextInlineWYSIWYG">
28892917
<annotations>

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

Lines changed: 1 addition & 3 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/js/content-type/slide/preview.js

Lines changed: 1 addition & 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/content-type/text/preview.js

Lines changed: 1 addition & 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: 9 additions & 0 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/banner/preview.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Uploader from "../../uploader";
1313
import delayUntil from "../../utils/delay-until";
1414
import {
1515
createBookmark, createDoubleClickEvent,
16-
findNodeIndex, getNodeByIndex,
16+
findNodeIndex, getActiveEditor, getNodeByIndex,
1717
isWysiwygSupported,
1818
lockImageSize,
1919
moveToBookmark,
@@ -105,7 +105,9 @@ export default class Preview extends BasePreview {
105105
element.innerHTML = this.data.content.html();
106106
this.contentType.dataStore.subscribe(() => {
107107
// If we're not focused into TinyMCE inline, update the value when it changes in the data store
108-
if (!element.classList.contains("mce-edit-focus")) {
108+
if (!element.classList.contains("mce-edit-focus")
109+
&& this.wysiwyg.getAdapter().id !== getActiveEditor().id
110+
) {
109111
element.innerHTML = this.data.content.html();
110112
}
111113
}, "message");
@@ -196,7 +198,6 @@ export default class Preview extends BasePreview {
196198
public activateEditor(preview: Preview, event: JQueryEventObject) {
197199
if (this.element && !this.wysiwyg && !this.handledDoubleClick) {
198200
const bookmark = createBookmark(event);
199-
console.log(bookmark);
200201
lockImageSize(this.element);
201202
this.element.removeAttribute("contenteditable");
202203
_.defer(() => {
@@ -325,7 +326,6 @@ export default class Preview extends BasePreview {
325326
{
326327
this.adjustTextareaHeightBasedOnScrollHeight();
327328
this.contentType.dataStore.set("message", this.textarea.value);
328-
console.log(this.textarea.value);
329329
}
330330

331331
/**

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Uploader from "../../uploader";
1616
import delayUntil from "../../utils/delay-until";
1717
import {
1818
createBookmark, createDoubleClickEvent,
19-
findNodeIndex, getNodeByIndex,
19+
findNodeIndex, getActiveEditor, getNodeByIndex,
2020
isWysiwygSupported,
2121
lockImageSize,
2222
moveToBookmark,
@@ -81,7 +81,9 @@ export default class Preview extends BasePreview {
8181
element.innerHTML = this.data.content.html();
8282
this.contentType.dataStore.subscribe(() => {
8383
// If we're not focused into TinyMCE inline, update the value when it changes in the data store
84-
if (!element.classList.contains("mce-edit-focus")) {
84+
if (!element.classList.contains("mce-edit-focus")
85+
&& this.wysiwyg.getAdapter().id !== getActiveEditor().id
86+
) {
8587
element.innerHTML = this.data.content.html();
8688
}
8789
}, "content");

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {OptionsInterface} from "../../content-type-menu/option.types";
1111
import delayUntil from "../../utils/delay-until";
1212
import {
1313
createBookmark, createDoubleClickEvent,
14-
findNodeIndex, getNodeByIndex,
14+
findNodeIndex, getActiveEditor, getNodeByIndex,
1515
isWysiwygSupported,
1616
lockImageSize,
1717
moveToBookmark,
@@ -94,7 +94,9 @@ export default class Preview extends BasePreview {
9494
element.innerHTML = this.data.main.html();
9595
this.contentType.dataStore.subscribe(() => {
9696
// If we're not focused into TinyMCE inline, update the value when it changes in the data store
97-
if (!element.classList.contains("mce-edit-focus")) {
97+
if (!element.classList.contains("mce-edit-focus")
98+
&& this.wysiwyg.getAdapter().id !== getActiveEditor().id
99+
) {
98100
element.innerHTML = this.data.main.html();
99101
}
100102
}, "content");

0 commit comments

Comments
 (0)