Skip to content

Commit f5597ef

Browse files
Merge pull request #506 from magento-tsg-csl3/MC-34620
MC-34620: Page builder editor breaks Cms pages with non Latin1 charac…
2 parents 70c3aad + 064327a commit f5597ef

File tree

6 files changed

+68
-6
lines changed

6 files changed

+68
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="AddPageLinkWidgetToTinyMCEWithAnchorAndTitleActionGroup" extends="addPageLinkWidgetToTinyMCE">
11+
<arguments>
12+
<argument name="anchor" defaultValue="" type="string"/>
13+
<argument name="title" defaultValue="" type="string"/>
14+
</arguments>
15+
<comment userInput="Insert anchor and title text" stepKey="commentAddAnchorAndTitleText" after="waitForLoadingMaskToDisappear2"/>
16+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomText}}" stepKey="waitForInputAnchorCustomText" after="commentAddAnchorAndTitleText"/>
17+
<fillField selector="{{WidgetSection.InputAnchorCustomText}}" userInput="{{anchor}}" stepKey="insertTextToDisplay" after="waitForInputAnchorCustomText" />
18+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomTitle}}" stepKey="waitForInputAnchorCustomTitle" after="insertTextToDisplay"/>
19+
<fillField selector="{{WidgetSection.InputAnchorCustomTitle}}" userInput="{{title}}" stepKey="insertTitle" after="waitForInputAnchorCustomTitle"/>
20+
<waitForElementVisible selector="{{TinyMCESection.InsertWidgetIcon}}" stepKey="waitForInsertWidget1" after="waitForInsertWidgetModalToClose"/>
21+
<click selector="{{TinyMCESection.InsertWidgetIcon}}" stepKey="clickAddWidgetBtn"/>
22+
</actionGroup>
23+
</actionGroups>

app/code/Magento/PageBuilder/Test/Mftf/Data/TinyMCEData.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
<data key="stageValue">{{widget type=&quot;Magento\Cms\Block\Widget\Page\Link&quot; template=&quot;widget/link/link_block.phtml&quot; page_id=</data>
4040
<data key="stageValueEncoded">e3t3aWRnZXQgdHlwZT0iTWFnZW50b1xDbXNcQmxvY2tcV2lkZ2V0XFBhZ2VcTGluayIgdGVtcGxhdGU9IndpZGdldC9saW5rL2xpbmtfYmxvY2sucGh0bWwiIHBhZ2VfaWQ9</data>
4141
</entity>
42+
<entity name="TinyMCEWidgetCMSPageLinkWithAnchorAndTitle" extends="TinyMCEWidgetCMSPageLink" type="pagebuilder_text_widget_property">
43+
<data key="anchorText">Piiramatult kõnesid ja SMSe Eestis ja ELi rändluses</data>
44+
<data key="title">Piiramatult kõnesid ja SMSe Eestis ja ELi rändluses</data>
45+
</entity>
4246
<entity name="PageBuilderTextArea_WidgetCMSPageLink" type="pagebuilder_text_widget_property">
4347
<data key="widgetType">Magento\Cms\Block\Widget\Page\Link</data>
4448
<data key="editPanelValue">{{widget type=&quot;Magento\\Cms\\Block\\Widget\\Page\\Link&quot; template=&quot;widget/link/link_block.phtml&quot; page_id=</data>

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@
4040
<argument name="contentType" value="PageBuilderTextContentType"/>
4141
</actionGroup>
4242
<clickWithLeftButton x="10" y="10" selector="{{TextOnStage.tinymce('1')}}" stepKey="focusOnTextEditorArea"/>
43-
<actionGroup ref="addPageLinkWidgetToTinyMCEInline" stepKey="addPageLinkWidgetToTinyMCE">
44-
<argument name="widget" value="TinyMCEWidgetCMSPageLink"/>
43+
<actionGroup ref="AddPageLinkWidgetToTinyMCEWithAnchorAndTitleActionGroup" stepKey="addPageLinkWidgetToTinyMCE">
4544
<argument name="page" value="$$createCMSPageB.identifier$$"/>
45+
<argument name="anchor" value="{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.anchorText}}"/>
46+
<argument name="title" value="{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.title}}"/>
4647
</actionGroup>
4748
<waitForElementVisible selector="{{TextOnStage.text('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="waitForWidgetStage1"/>
4849
<!--Verify widget edit page-->
@@ -73,6 +74,19 @@
7374
<actionGroup ref="doubleClickWidgetTinyMCE" stepKey="doubleClickWidget">
7475
<argument name="widget" value="TinyMCEWidgetCMSPageLink.editPanelValue"/>
7576
</actionGroup>
77+
<!-- Grab a value from the link-->
78+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomText}}" stepKey="waitForInputAnchorCustomText"/>
79+
<grabValueFrom selector="{{WidgetSection.InputAnchorCustomText}}" stepKey="grabAnchorText"/>
80+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomTitle}}" stepKey="waitForInputAnchorCustomTitle"/>
81+
<grabValueFrom selector="{{WidgetSection.InputAnchorCustomTitle}}" stepKey="grabTitleText"/>
82+
<assertEquals stepKey="assertAnchorTextCMSWidgetLink" message="pass">
83+
<expectedResult type="string">{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.anchorText}}</expectedResult>
84+
<actualResult type="string">{$grabAnchorText}</actualResult>
85+
</assertEquals>
86+
<assertEquals stepKey="assertTitleCMSWidgetLink" message="pass">
87+
<expectedResult type="string">{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.title}}</expectedResult>
88+
<actualResult type="string">{$grabTitleText}</actualResult>
89+
</assertEquals>
7690
<actionGroup ref="closeWidgetPanelTinyMCE" stepKey="closeWidgetPanelTinyMCE"/>
7791
<!-- Validate Storefront -->
7892
<comment userInput="Verify Widget Content Type on storefront" stepKey="commentVerifyWidgetOnStorefront"/>

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

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
interface Base64 {
7+
_keyStr: string;
8+
encode: (input: string) => string;
9+
decode: (input: string) => string;
10+
mageEncode: (input: string) => string;
11+
mageDecode: (output: string) => string;
12+
idEncode: (input: string) => string;
13+
idDecode: (output: string) => string;
14+
_utf8_encode: (input: string) => string;
15+
_utf8_decode: (utftext: string) => string;
16+
}
17+
18+
interface Window {
19+
Base64: Base64;
20+
}

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
@@ -4,6 +4,7 @@
44
*/
55

66
import $ from "jquery";
7+
import "mage/adminhtml/tools";
78
import $t from "mage/translate";
89
import mageUtils from "mageUtils";
910
import {Editor} from "tinymce";
@@ -125,7 +126,7 @@ function convertWidgetsToHtmlPreview(content: string) {
125126
}
126127

127128
const image = $("<img />")
128-
.prop("id", btoa(match).replace(/\+/g, ":").replace(/\//g, "_").replace(/=/g, "-"))
129+
.prop("id", window.Base64.idEncode(match))
129130
.prop("src", imageSrc);
130131

131132
placeholder.append(image);

0 commit comments

Comments
 (0)