@useinsider/guido 3.30.0 → 3.30.1-beta.c6a213b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +11 -16
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +51 -51
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/composables/useExport.js +8 -7
- package/dist/composables/useHtmlValidator.js +102 -100
- package/dist/composables/useToaster.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +22 -21
- package/dist/composables/validators/useLiquidValidator.js +26 -24
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +148 -141
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +53 -53
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +40 -39
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +27 -26
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +33 -32
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +23 -22
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +79 -78
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +50 -41
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +2 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/ampPreviewSanitizer.d.ts +5 -0
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/stores/preview.js +21 -15
- package/dist/utils/ampPreviewSanitizer.js +46 -0
- package/dist/utils/htmlEscape.js +5 -1
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -1,98 +1,107 @@
|
|
|
1
|
-
import { ATTR_CUSTOM_PREFIX as o, ATTR_PRODUCT_PRICE as
|
|
1
|
+
import { ATTR_CUSTOM_PREFIX as o, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OLD_PRICE as C, PRODUCT_ATTRIBUTE_PREFIX as f, ATTR_DATA_ATTRIBUTE_TYPE as a, ATTR_PRODUCT_ATTR as c, SELECTOR_ATTRIBUTE_ROW as y } from "../constants/selectors.js";
|
|
2
2
|
function q(t) {
|
|
3
|
-
return !t.startsWith(
|
|
3
|
+
return !t.startsWith(f);
|
|
4
4
|
}
|
|
5
5
|
function $(t) {
|
|
6
|
-
return t.startsWith(
|
|
6
|
+
return t.startsWith(f) ? t.substring(f.length) : t;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function T(t) {
|
|
9
9
|
return t.startsWith(o) ? t.substring(o.length) : t;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function A(t) {
|
|
12
12
|
return `${o}${t}`;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const g = /[<>"`]/;
|
|
15
|
+
function m(t) {
|
|
16
|
+
return !g.test(t);
|
|
17
|
+
}
|
|
18
|
+
function O(t) {
|
|
19
|
+
return t.filter((r) => !r.startsWith(o) || m(T(r)));
|
|
16
20
|
}
|
|
17
|
-
function h(t
|
|
21
|
+
function h(t) {
|
|
22
|
+
return t.type === "defaultAttribute" ? t.attributeName : `${f}${t.attributeName}`;
|
|
23
|
+
}
|
|
24
|
+
function S(t, r) {
|
|
18
25
|
const n = Object.values(r).filter((e) => e.attributeName === t);
|
|
19
26
|
return n.find((e) => e.type === "defaultAttribute") ?? n[0];
|
|
20
27
|
}
|
|
21
28
|
function l(t, r) {
|
|
22
29
|
return t && "getAttribute" in t ? t.getAttribute(r) : null;
|
|
23
30
|
}
|
|
24
|
-
function
|
|
31
|
+
function E(t, r, n = {}) {
|
|
25
32
|
const e = `${o}${t}`, u = r == null ? void 0 : r.querySelector(
|
|
26
|
-
`${y}[${
|
|
33
|
+
`${y}[${a}="${e}"]`
|
|
27
34
|
), i = l(u, c) ?? l(u == null ? void 0 : u.querySelector(`[${c}]`), c);
|
|
28
35
|
if (i)
|
|
29
36
|
return i;
|
|
30
|
-
const s =
|
|
31
|
-
return s ?
|
|
37
|
+
const s = S(t, n);
|
|
38
|
+
return s ? h(s) : t;
|
|
32
39
|
}
|
|
33
40
|
function P(t, r, n = {}) {
|
|
34
|
-
return t.startsWith(
|
|
41
|
+
return t.startsWith(f) ? t : E(t, r, n);
|
|
35
42
|
}
|
|
36
|
-
function
|
|
43
|
+
function U(t, r, n = {}) {
|
|
37
44
|
return t.map((e) => {
|
|
38
45
|
if (!e.startsWith(o))
|
|
39
46
|
return e;
|
|
40
|
-
const u =
|
|
41
|
-
return
|
|
47
|
+
const u = T(e);
|
|
48
|
+
return A(P(u, r, n));
|
|
42
49
|
});
|
|
43
50
|
}
|
|
44
|
-
function
|
|
51
|
+
function D(t, r, n = {}) {
|
|
45
52
|
return t.map((e) => P(e, r, n));
|
|
46
53
|
}
|
|
47
54
|
function b(t) {
|
|
48
|
-
const r = l(t,
|
|
55
|
+
const r = l(t, a);
|
|
49
56
|
if (!(r != null && r.startsWith(o)))
|
|
50
57
|
return r;
|
|
51
58
|
const n = "querySelector" in t ? t.querySelector(`[${c}]`) : void 0, e = l(n, c);
|
|
52
|
-
return e ?
|
|
59
|
+
return e ? A(e) : r;
|
|
53
60
|
}
|
|
54
|
-
function
|
|
61
|
+
function p(t) {
|
|
55
62
|
return !!(t && "querySelector" in t && t.querySelector(".product-price") && t.querySelector(".product-old-price"));
|
|
56
63
|
}
|
|
57
|
-
function
|
|
64
|
+
function I(t) {
|
|
58
65
|
const r = b(t);
|
|
59
|
-
return r ?
|
|
66
|
+
return r ? p(t) ? [_, C] : [r] : [];
|
|
60
67
|
}
|
|
61
68
|
function R(t, r, n) {
|
|
62
69
|
const e = l(t, c), u = l(t.querySelector(`[${c}]`), c), i = e ?? u;
|
|
63
70
|
return i === null ? n : i === r;
|
|
64
71
|
}
|
|
65
|
-
function
|
|
66
|
-
const n = (
|
|
67
|
-
`${y}[${
|
|
72
|
+
function v(t, r) {
|
|
73
|
+
const n = (d) => t.querySelector(
|
|
74
|
+
`${y}[${a}="${d}"]`
|
|
68
75
|
);
|
|
69
76
|
if (!r.startsWith(o))
|
|
70
77
|
return n(r) ?? null;
|
|
71
|
-
const e =
|
|
78
|
+
const e = T(r), u = n(r);
|
|
72
79
|
if (u && R(u, e, !0))
|
|
73
80
|
return u;
|
|
74
|
-
const i =
|
|
81
|
+
const i = A($(e)), s = i === r ? void 0 : n(i);
|
|
75
82
|
return s && R(s, e, !1) ? s : null;
|
|
76
83
|
}
|
|
77
|
-
function
|
|
78
|
-
const n =
|
|
84
|
+
function B(t, r) {
|
|
85
|
+
const n = T(r), e = A($(n));
|
|
79
86
|
return e === r ? t : t.replace(
|
|
80
|
-
`${
|
|
81
|
-
`${
|
|
87
|
+
`${a}="${e}"`,
|
|
88
|
+
`${a}="${r}"`
|
|
82
89
|
);
|
|
83
90
|
}
|
|
84
91
|
export {
|
|
85
92
|
$ as bareAttributeName,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
T as compositionKeyToProductAttr,
|
|
94
|
+
O as dropMalformedCompositionKeys,
|
|
95
|
+
h as filterToProductAttrValue,
|
|
96
|
+
v as findAttributeRow,
|
|
97
|
+
S as findFilterByBareName,
|
|
90
98
|
q as isDefaultProductAttr,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
p as isMergedInlinePriceRow,
|
|
100
|
+
m as isWellFormedProductAttr,
|
|
101
|
+
U as normalizeCompositionKeys,
|
|
102
|
+
D as normalizeCustomAttrValues,
|
|
103
|
+
A as productAttrToCompositionKey,
|
|
95
104
|
b as resolveRowCompositionKey,
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
I as resolveRowVisibilityKeys,
|
|
106
|
+
B as rewriteLegacyRowKeyHtml
|
|
98
107
|
};
|
package/dist/guido.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";.auth-error-modal[data-v-b4d7ae51]{position:relative;z-index:145}.gap-16[data-v-5553d071],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-9d988e4b] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-2cb418af] .in-progress-wrapper__progress p span:last-child{display:none!important}[data-v-2cb418af] .in-progress-description-status{display:none!important}.color-vision-select__dropdown[data-v-64cb50da]{z-index:20;width:387px}.accessibility-toolbar[data-v-391019bc]{gap:16px}.accessibility-toolbar[data-v-391019bc] .in-segments-wrapper__button svg{margin-right:0}.accessibility-toolbar[data-v-391019bc] .in-segments-wrapper__button .clearfix:after{content:none}.view-options-wrapper[data-v-87033101]{position:relative;display:inline-block}.new-tag[data-v-87033101]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-87033101] .guido__view-option-selection-desktop svg,[data-v-87033101] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-87033101] .in-segments-wrapper__button_selected,[data-v-87033101] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-87033101] .in-tooltip-wrapper-v2__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-fad98586]{gap:8px}.version-history__toolbar[data-v-fad98586]{gap:4px}.view-options-wrapper[data-v-6ebabfe4]{position:relative;display:inline-block}.new-tag[data-v-6ebabfe4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-6ebabfe4] .guido__verion-history-view-option-selection-desktop svg,[data-v-6ebabfe4] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-6ebabfe4] .in-segments-wrapper__button_selected,[data-v-6ebabfe4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-6ebabfe4] .in-tooltip-wrapper-v2__icon{cursor:pointer}.editor-actions-menu__dropdown[data-v-bdb3b37a]{z-index:20;width:222px}.editor-actions[data-v-9a028d08]{gap:16px}.editor-actions__divider[data-v-9a028d08]{width:1px;height:40px;background-color:#e1e1e1}.right-slot[data-v-77451c9a]{gap:16px}.header-wrapper[data-v-3c713746]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.validation-error-list[data-v-
|
|
1
|
+
@charset "UTF-8";.auth-error-modal[data-v-b4d7ae51]{position:relative;z-index:145}.gap-16[data-v-5553d071],.gap-16[data-v-0e1b0c54]{gap:16px}[data-v-9d988e4b] .in-button-v2__wrapper{line-height:0}[data-v-22226124] .in-segments-wrapper__button_selected,[data-v-22226124] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb;color:#0010ac;border-color:#0010ac}[data-v-2cb418af] .in-progress-wrapper__progress p span:last-child{display:none!important}[data-v-2cb418af] .in-progress-description-status{display:none!important}.color-vision-select__dropdown[data-v-64cb50da]{z-index:20;width:387px}.accessibility-toolbar[data-v-391019bc]{gap:16px}.accessibility-toolbar[data-v-391019bc] .in-segments-wrapper__button svg{margin-right:0}.accessibility-toolbar[data-v-391019bc] .in-segments-wrapper__button .clearfix:after{content:none}.view-options-wrapper[data-v-87033101]{position:relative;display:inline-block}.new-tag[data-v-87033101]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-87033101] .guido__view-option-selection-desktop svg,[data-v-87033101] .guido__view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-87033101] .in-segments-wrapper__button_selected,[data-v-87033101] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-87033101] .in-tooltip-wrapper-v2__icon{cursor:pointer}.editor-toolbar[data-v-173c3a40]{gap:4px}.version-history-item[data-v-ee4b9c3f]{flex-basis:200px}.version-history[data-v-fad98586]{gap:8px}.version-history__toolbar[data-v-fad98586]{gap:4px}.view-options-wrapper[data-v-6ebabfe4]{position:relative;display:inline-block}.new-tag[data-v-6ebabfe4]{position:absolute;top:-8px;right:-16px;z-index:10}[data-v-6ebabfe4] .guido__verion-history-view-option-selection-desktop svg,[data-v-6ebabfe4] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-6ebabfe4] .in-segments-wrapper__button_selected,[data-v-6ebabfe4] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}[data-v-6ebabfe4] .in-tooltip-wrapper-v2__icon{cursor:pointer}.editor-actions-menu__dropdown[data-v-bdb3b37a]{z-index:20;width:222px}.editor-actions[data-v-9a028d08]{gap:16px}.editor-actions__divider[data-v-9a028d08]{width:1px;height:40px;background-color:#e1e1e1}.right-slot[data-v-77451c9a]{gap:16px}.header-wrapper[data-v-3c713746]{min-width:1000px}.guido-loading__wrapper[data-v-07c4b2d8]{height:100%;top:75px!important;bottom:0!important}.validation-error-list[data-v-c8351f74]{gap:16px}.validation-error-row[data-v-c8351f74]{gap:8px;padding:24px;border:1px solid #E1E1E1;border-radius:8px}.validation-error-row__icon[data-v-c8351f74]{flex-shrink:0;font-size:24px;line-height:0}.validation-error-row__text[data-v-c8351f74]{font-size:13px;line-height:16px;color:#292929;word-break:break-word}.guido-editor__wrapper[data-v-0c5f11a1]{--ribbon-offset: 0px;position:relative;width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__container[data-v-0c5f11a1]{width:100%;height:calc(100vh - 128px - var(--ribbon-offset))}.guido-editor__no-header[data-v-0c5f11a1]{height:calc(100vh - 75px - var(--ribbon-offset))}[data-v-293f1c47] .in-breadcrumb-wrapper__links{cursor:pointer}.templates-wrapper[data-v-eaf8e461]{gap:16px;grid-template-columns:repeat(3,1fr)}.templates-wrapper .template-wrapper[data-v-eaf8e461]{cursor:pointer}.templates-wrapper .template-wrapper .template-container[data-v-eaf8e461]{height:274px;padding:2px;transition:none}.templates-wrapper .template-wrapper .template-container.selected[data-v-eaf8e461]{padding:1px}.templates-wrapper .template-wrapper .template-container .thumbnail[data-v-eaf8e461]{object-fit:cover;transform:scale(1)}[data-v-b9a93c6e] .guido__verion-history-view-option-selection-desktop svg,[data-v-b9a93c6e] .guido__verion-history-view-option-selection-mobile svg{margin:0 0 0 2px}[data-v-b9a93c6e] .in-segments-wrapper__button_selected,[data-v-b9a93c6e] .in-segments-wrapper__button_selected:hover{background-color:#dae1fb}.error-list[data-v-c3fd5d4b]{gap:16px}.desktop-browser-header[data-v-d86c5af5]{height:79px;min-height:79px}.desktop-browser-header__left[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:378px}.desktop-browser-header__center[data-v-d86c5af5]{height:79px;background-repeat:repeat-x;background-size:auto 100%;background-position:left top}.desktop-browser-header__right[data-v-d86c5af5]{-webkit-user-drag:none;height:79px;width:112px}.desktop-preview[data-v-f5ff6219]{min-width:602px;height:70vh;min-height:583px;border-radius:10px}.desktop-preview iframe[data-v-f5ff6219]{min-height:504px}.iframe-wrapper[data-v-a7102458]{width:258px}.iframe-scaled[data-v-a7102458]{width:320px;height:124.0310077519%;transform:scale(.80625);transform-origin:top left}.cropped-text[data-v-eb3d05d7]{width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mobile-preview-wrapper__phone[data-v-3f472f96]{width:282px}.mobile-preview-wrapper__phone img[data-v-3f472f96]{object-fit:cover;border-radius:44px}.mobile-preview-wrapper__content[data-v-3f472f96]{width:258px;height:450px;left:12px}[data-v-6bcaca8a] .vueperslides__parallax-wrapper{padding-bottom:110px!important}.guido-tab-bar-onboarding[data-v-219b4f7c]{z-index:21}[data-v-fcba7e99] .vueperslides__bullets{pointer-events:none!important}[data-v-fcba7e99] .vueperslides__parallax-wrapper{padding-bottom:110px!important}[data-v-1a34025a] .vueperslides__bullets{pointer-events:none!important}[data-v-1a34025a] .vueperslides__parallax-wrapper{height:110px!important;padding-bottom:110px!important}[data-v-8fc96a58] .vueperslides__bullets,[data-v-ec2027ff] .vueperslides__bullets,[data-v-b09e80c4] .vueperslides__bullets{pointer-events:none!important}[data-v-b09e80c4] .vueperslides__parallax-wrapper{height:110px!important;padding-bottom:110px!important}[data-v-9bdef600] .vueperslides__parallax-wrapper{padding-bottom:110px!important}.assign-strategy-drawer .spaced-dot-sep{background-image:linear-gradient(90deg,#91949f 20%,#fff0 0);background-position:center bottom;background-repeat:repeat-x;background-size:5px 1px}.assign-strategy-drawer .spaced-dot-sep--top{background-position:center top}.assign-strategy-drawer .spaced-dot-sep--fc-n:first-child{background:none}.guido-display-condition-create__separator[data-v-929822bc]{height:1px;margin:0 0 24px;background-image:linear-gradient(to right,currentColor 1px,transparent 1px);background-size:5px 1px}.guido-display-condition-create__methods[data-v-929822bc]{gap:16px}.guido-display-condition-select-root[data-v-0d740001] .in-drawer__footer{justify-content:flex-start}.guido-display-condition-select__delete-modal[data-v-0d740001]{position:relative;z-index:145}.guido-display-condition-select__delete-modal[data-v-0d740001] .in-modal-v2-wrapper__header-title{margin-bottom:0}.guido-display-condition-select-root[data-v-0d740001] .in-drawer__content>div{display:flex;flex-direction:column;min-height:100%}.guido-display-condition-select__list[data-v-0d740001]{display:flex;flex-direction:column;gap:24px;margin:0;padding:0;list-style:none}.guido-display-condition-card__header[data-v-0d740001]{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:15px}.guido-display-condition-card__text[data-v-0d740001]{min-width:0}.guido-display-condition-card__name[data-v-0d740001],.guido-display-condition-card__description[data-v-0d740001]{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.guido-display-condition-card__actions[data-v-0d740001]{display:flex;flex-shrink:0;align-items:center;gap:16px}.guido-display-condition-card__split[data-v-0d740001]{position:relative;display:flex;gap:1px}.guido-display-condition-card__menu[data-v-0d740001]{z-index:2;min-width:115px}.guido-display-condition-card__divider[data-v-0d740001]{width:1px;height:24px}.guido-display-condition-card__code[data-v-0d740001]{margin:1px 15px 15px;padding:8px;font-family:inherit;white-space:pre-wrap;word-break:break-word}.legacy-strategy-updated-modal[data-v-da2225a1]{position:relative;z-index:145}.ambiguous-dynamic-content-modal__content[data-v-2643213c]{padding-bottom:150px}
|
package/dist/package.json.js
CHANGED
|
@@ -11,6 +11,8 @@ export declare function isDefaultProductAttr(productAttrValue: string): boolean;
|
|
|
11
11
|
export declare function bareAttributeName(productAttrValue: string): string;
|
|
12
12
|
export declare function compositionKeyToProductAttr(compositionKey: string): string;
|
|
13
13
|
export declare function productAttrToCompositionKey(productAttrValue: string): string;
|
|
14
|
+
export declare function isWellFormedProductAttr(productAttrValue: string): boolean;
|
|
15
|
+
export declare function dropMalformedCompositionKeys(composition: string[]): string[];
|
|
14
16
|
/**
|
|
15
17
|
* Canonical identity of a filter entry. Reads the type off the entry itself, so
|
|
16
18
|
* two same-named filters never collapse onto one value.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { PreviewState, EmailFormat } from '@@/Types/preview';
|
|
2
|
+
export declare const HTML_PREVIEW_SANDBOX = "allow-same-origin allow-popups allow-popups-to-escape-sandbox";
|
|
3
|
+
export declare const AMP_PREVIEW_SANDBOX = "allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox";
|
|
2
4
|
export declare const usePreviewStore: import("pinia").StoreDefinition<"guidoPreview", PreviewState, {
|
|
3
5
|
isAMPModeEnabled: (state: {
|
|
4
6
|
emailFormat: EmailFormat;
|
|
@@ -10,6 +12,7 @@ export declare const usePreviewStore: import("pinia").StoreDefinition<"guidoPrev
|
|
|
10
12
|
emailSizeKB: number;
|
|
11
13
|
} & import("pinia").PiniaCustomStateProperties<PreviewState>) => boolean;
|
|
12
14
|
previewHtml(): string;
|
|
15
|
+
previewSandbox(): string;
|
|
13
16
|
hasAMP: (state: {
|
|
14
17
|
emailFormat: EmailFormat;
|
|
15
18
|
ampHtml: string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips script-running markup from AMP preview HTML, which needs `allow-scripts` for the AMP runtime.
|
|
3
|
+
* Preview only: the DOM round-trip re-encodes attribute text, so never feed the result back into saved HTML.
|
|
4
|
+
*/
|
|
5
|
+
export declare const sanitizeAmpPreviewHtml: (html: string) => string;
|
|
@@ -3,3 +3,8 @@
|
|
|
3
3
|
* or text content. Use for any string that may contain untrusted input.
|
|
4
4
|
*/
|
|
5
5
|
export declare function escapeHtml(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Escape untrusted text but keep attribute-free line breaks and inline emphasis
|
|
8
|
+
* (`br`, `b`, `strong`, `i`, `em`, `u`) that translated copy carries.
|
|
9
|
+
*/
|
|
10
|
+
export declare function escapeHtmlKeepFormatting(text: string): string;
|
package/dist/stores/preview.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { sanitizeAmpPreviewHtml as s } from "../utils/ampPreviewSanitizer.js";
|
|
2
|
+
import { defineStore as r } from "pinia";
|
|
3
|
+
const o = "allow-same-origin allow-popups allow-popups-to-escape-sandbox", i = "allow-same-origin allow-scripts allow-popups allow-popups-to-escape-sandbox", a = () => ({
|
|
3
4
|
emailFormat: "html",
|
|
4
5
|
ampHtml: "",
|
|
5
6
|
ampErrors: [],
|
|
@@ -7,18 +8,21 @@ const i = () => ({
|
|
|
7
8
|
isLoaded: !1,
|
|
8
9
|
isAMPErrorModalVisible: !1,
|
|
9
10
|
emailSizeKB: 0
|
|
10
|
-
}),
|
|
11
|
-
state: () =>
|
|
11
|
+
}), p = r("guidoPreview", {
|
|
12
|
+
state: () => a(),
|
|
12
13
|
getters: {
|
|
13
|
-
isAMPModeEnabled: (
|
|
14
|
+
isAMPModeEnabled: (e) => e.emailFormat === "AMP",
|
|
14
15
|
previewHtml() {
|
|
15
|
-
return this.isAMPModeEnabled ? this.ampHtml : this.templateHtml;
|
|
16
|
+
return this.isAMPModeEnabled ? s(this.ampHtml) : this.templateHtml;
|
|
16
17
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return !!((r = t.ampHtml) != null && r.trim());
|
|
18
|
+
previewSandbox() {
|
|
19
|
+
return this.isAMPModeEnabled ? i : o;
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
hasAMP: (e) => {
|
|
22
|
+
var t;
|
|
23
|
+
return !!((t = e.ampHtml) != null && t.trim());
|
|
24
|
+
},
|
|
25
|
+
hasAMPErrors: (e) => e.ampErrors.length > 0,
|
|
22
26
|
showAMPErrorButton() {
|
|
23
27
|
return this.isAMPModeEnabled && this.hasAMPErrors;
|
|
24
28
|
},
|
|
@@ -27,11 +31,11 @@ const i = () => ({
|
|
|
27
31
|
}
|
|
28
32
|
},
|
|
29
33
|
actions: {
|
|
30
|
-
updateAMPData(
|
|
31
|
-
this.ampHtml =
|
|
34
|
+
updateAMPData(e) {
|
|
35
|
+
this.ampHtml = e.ampHtml ?? "", this.ampErrors = e.ampErrors ?? [], this.emailFormat = e.ampHtml ? "AMP" : "html";
|
|
32
36
|
},
|
|
33
|
-
setEmailFormat(
|
|
34
|
-
this.emailFormat =
|
|
37
|
+
setEmailFormat(e) {
|
|
38
|
+
this.emailFormat = e;
|
|
35
39
|
},
|
|
36
40
|
closeErrorModal() {
|
|
37
41
|
this.isAMPErrorModalVisible = !1;
|
|
@@ -42,5 +46,7 @@ const i = () => ({
|
|
|
42
46
|
}
|
|
43
47
|
});
|
|
44
48
|
export {
|
|
45
|
-
|
|
49
|
+
i as AMP_PREVIEW_SANDBOX,
|
|
50
|
+
o as HTML_PREVIEW_SANDBOX,
|
|
51
|
+
p as usePreviewStore
|
|
46
52
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BASE_SAFE_URL_SCHEMES as c } from "./urlSchemes.js";
|
|
2
|
+
const i = "https://cdn.ampproject.org/", a = "http://www.w3.org/1999/xhtml", l = ["application/json", "application/ld+json"], E = [...c, "tel:", "sms:"], u = ["href", "src", "action", "action-xhr", "formaction", "xlink:href", "poster", "background"], m = "iframe, frame, frameset, object, embed, base, noscript, amp-script, animate, set", p = /^on./i, f = "https://preview.invalid/", A = 4, S = (e) => {
|
|
3
|
+
const t = e.trim();
|
|
4
|
+
if (t === "")
|
|
5
|
+
return !0;
|
|
6
|
+
try {
|
|
7
|
+
const { protocol: r } = new URL(t, f);
|
|
8
|
+
return E.includes(r) || /^data:image\//i.test(t);
|
|
9
|
+
} catch {
|
|
10
|
+
return !1;
|
|
11
|
+
}
|
|
12
|
+
}, h = (e) => {
|
|
13
|
+
if (e.namespaceURI !== a)
|
|
14
|
+
return !1;
|
|
15
|
+
const t = e.getAttribute("src");
|
|
16
|
+
return t !== null ? t.trim().startsWith(i) : l.includes((e.getAttribute("type") ?? "").trim().toLowerCase());
|
|
17
|
+
}, _ = (e) => {
|
|
18
|
+
Array.from(e.attributes).forEach(({ name: t, value: r }) => {
|
|
19
|
+
const o = u.includes(t.toLowerCase()) && !S(r);
|
|
20
|
+
(p.test(t) || o) && e.removeAttribute(t);
|
|
21
|
+
});
|
|
22
|
+
}, s = (e) => {
|
|
23
|
+
e.querySelectorAll(m).forEach((t) => t.remove()), e.querySelectorAll("meta[http-equiv]").forEach((t) => {
|
|
24
|
+
var r;
|
|
25
|
+
((r = t.getAttribute("http-equiv")) == null ? void 0 : r.trim().toLowerCase()) === "refresh" && t.remove();
|
|
26
|
+
}), e.querySelectorAll("script").forEach((t) => {
|
|
27
|
+
h(t) || t.remove();
|
|
28
|
+
}), e.querySelectorAll("*").forEach(_), e.querySelectorAll("template").forEach((t) => s(t.content));
|
|
29
|
+
}, n = (e) => {
|
|
30
|
+
const t = new DOMParser().parseFromString(e, "text/html");
|
|
31
|
+
return s(t), `${t.doctype ? `<!DOCTYPE ${t.doctype.name}>` : ""}${t.documentElement.outerHTML}`;
|
|
32
|
+
}, T = (e) => {
|
|
33
|
+
if (e.trim() === "")
|
|
34
|
+
return "";
|
|
35
|
+
let t = n(e);
|
|
36
|
+
for (let r = 1; r < A; r++) {
|
|
37
|
+
const o = n(t);
|
|
38
|
+
if (o === t)
|
|
39
|
+
return t;
|
|
40
|
+
t = o;
|
|
41
|
+
}
|
|
42
|
+
return "";
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
T as sanitizeAmpPreviewHtml
|
|
46
|
+
};
|
package/dist/utils/htmlEscape.js
CHANGED
|
@@ -8,6 +8,10 @@ const c = {
|
|
|
8
8
|
function n(t) {
|
|
9
9
|
return t.replace(/[&<>"']/g, (e) => c[e]);
|
|
10
10
|
}
|
|
11
|
+
function o(t) {
|
|
12
|
+
return n(t).replace(/<\/?br\s*\/?>/gi, "<br>").replace(/<(\/?)(b|strong|i|em|u)>/gi, (e, r, a) => `<${r}${a.toLowerCase()}>`);
|
|
13
|
+
}
|
|
11
14
|
export {
|
|
12
|
-
n as escapeHtml
|
|
15
|
+
n as escapeHtml,
|
|
16
|
+
o as escapeHtmlKeepFormatting
|
|
13
17
|
};
|