Skip to content

Commit 65a96d1

Browse files
MC-34620: Page builder editor breaks Cms pages with non Latin1 characters
1 parent 2c225ef commit 65a96d1

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

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)