Skip to content

Commit 38c15aa

Browse files
Merge pull request #505 from magento-tsg-csl3/MC-34590
MC-34590: Page builder editor breaks Cms pages with non Latin1 charac…
2 parents cf75746 + 10a56d0 commit 38c15aa

File tree

6 files changed

+57
-5
lines changed

6 files changed

+57
-5
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,19 @@
160160
<actualResult type="variable">getText</actualResult>
161161
</assertContains>
162162
</actionGroup>
163+
<actionGroup name="AddPageLinkWidgetToTinyMCEWithAnchorAndTitleActionGroup" extends="addPageLinkWidgetToTinyMCE">
164+
<arguments>
165+
<argument name="anchor" defaultValue="" type="string"/>
166+
<argument name="title" defaultValue="" type="string"/>
167+
</arguments>
168+
<comment userInput="Insert anchor and title text" stepKey="commentAddAnchorAndTitleText" after="waitForLoadingMaskToDisappear2"/>
169+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomText}}" stepKey="waitForInputAnchorCustomText" after="commentAddAnchorAndTitleText"/>
170+
<fillField selector="{{WidgetSection.InputAnchorCustomText}}" userInput="{{anchor}}" stepKey="insertTextToDisplay" after="waitForInputAnchorCustomText" />
171+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomTitle}}" stepKey="waitForInputAnchorCustomTitle" after="insertTextToDisplay"/>
172+
<fillField selector="{{WidgetSection.InputAnchorCustomTitle}}" userInput="{{title}}" stepKey="insertTitle" after="waitForInputAnchorCustomTitle"/>
173+
<waitForElementVisible selector="{{TinyMCESection.InsertWidgetIcon}}" stepKey="waitForInsertWidget1" after="waitForInsertWidgetModalToClose"/>
174+
<click selector="{{TinyMCESection.InsertWidgetIcon}}" stepKey="clickAddWidgetBtn"/>
175+
</actionGroup>
163176
<actionGroup name="validateTextInTinyMCE">
164177
<arguments>
165178
<argument name="property" defaultValue=""/>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
<data key="stageValue">{{widget type=&quot;Magento\Cms\Block\Widget\Page\Link&quot; template=&quot;widget/link/link_block.phtml&quot; page_id=</data>
6666
<data key="stageValueEncoded">e3t3aWRnZXQgdHlwZT0iTWFnZW50b1xDbXNcQmxvY2tcV2lkZ2V0XFBhZ2VcTGluayIgdGVtcGxhdGU9IndpZGdldC9saW5rL2xpbmtfYmxvY2sucGh0bWwiIHBhZ2VfaWQ9</data>
6767
</entity>
68+
<entity name="TinyMCEWidgetCMSPageLinkWithAnchorAndTitle" type="pagebuilder_text_widget_property" extends="TinyMCEWidgetCMSPageLink">
69+
<data key="anchorText">Piiramatult kõnesid ja SMSe Eestis ja ELi rändluses</data>
70+
<data key="title">Piiramatult kõnesid ja SMSe Eestis ja ELi rändluses</data>
71+
</entity>
6872
<entity name="PageBuilderTextArea_WidgetCMSPageLink" type="pagebuilder_text_widget_property">
6973
<data key="widgetType">Magento\Cms\Block\Widget\Page\Link</data>
7074
<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.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,9 +745,10 @@
745745
<argument name="contentType" value="PageBuilderTextContentType"/>
746746
</actionGroup>
747747
<clickWithLeftButton x="10" y="10" selector="{{TextOnStage.tinymce('1')}}" stepKey="focusOnTextEditorArea"/>
748-
<actionGroup ref="addPageLinkWidgetToTinyMCEInline" stepKey="addPageLinkWidgetToTinyMCE">
749-
<argument name="widget" value="TinyMCEWidgetCMSPageLink"/>
748+
<actionGroup ref="AddPageLinkWidgetToTinyMCEWithAnchorAndTitleActionGroup" stepKey="addPageLinkWidgetToTinyMCE">
750749
<argument name="page" value="$$createCMSPageB.identifier$$"/>
750+
<argument name="anchor" value="{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.anchorText}}"/>
751+
<argument name="title" value="{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.title}}"/>
751752
</actionGroup>
752753
<waitForElementVisible selector="{{TextOnStage.text('1', TinyMCEWidgetCMSPageLink.editPanelValue)}}" stepKey="waitForWidgetStage1"/>
753754
<!--Verify widget edit page-->
@@ -778,6 +779,19 @@
778779
<actionGroup ref="doubleClickWidgetTinyMCE" stepKey="doubleClickWidget">
779780
<argument name="widget" value="TinyMCEWidgetCMSPageLink.editPanelValue"/>
780781
</actionGroup>
782+
<!-- Grab a value from the link-->
783+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomText}}" stepKey="waitForInputAnchorCustomText"/>
784+
<grabValueFrom selector="{{WidgetSection.InputAnchorCustomText}}" stepKey="grabAnchorText"/>
785+
<waitForElementVisible selector="{{WidgetSection.InputAnchorCustomTitle}}" stepKey="waitForInputAnchorCustomTitle"/>
786+
<grabValueFrom selector="{{WidgetSection.InputAnchorCustomTitle}}" stepKey="grabTitleText"/>
787+
<assertEquals stepKey="assertAnchorTextCMSWidgetLink" message="pass">
788+
<expectedResult type="string">{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.anchorText}}</expectedResult>
789+
<actualResult type="string">{$grabAnchorText}</actualResult>
790+
</assertEquals>
791+
<assertEquals stepKey="assertTitleCMSWidgetLink" message="pass">
792+
<expectedResult type="string">{{TinyMCEWidgetCMSPageLinkWithAnchorAndTitle.title}}</expectedResult>
793+
<actualResult type="string">{$grabTitleText}</actualResult>
794+
</assertEquals>
781795
<actionGroup ref="closeWidgetPanelTinyMCE" stepKey="closeWidgetPanelTinyMCE"/>
782796
<!-- Validate Storefront -->
783797
<comment userInput="Verify Widget Content Type on storefront" stepKey="commentVerifyWidgetOnStorefront"/>

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

Lines changed: 2 additions & 2 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)