@useinsider/guido 3.25.0 → 3.26.0
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/README.md +10 -0
- package/dist/@types/config/schemas.js +24 -20
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +94 -90
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
- package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
- package/dist/composables/useModuleRepair.js +33 -24
- package/dist/composables/useSave.js +57 -52
- package/dist/composables/useSaveValidation.js +118 -110
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +48 -33
- package/dist/config/migrator/index.js +8 -7
- package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
- package/dist/enums/academy.js +2 -1
- package/dist/enums/save-validation.js +1 -1
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/useModuleRepair.d.ts +2 -11
- package/dist/src/composables/useSaveValidation.d.ts +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +4 -0
- package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/save-validation.d.ts +2 -1
- package/dist/src/stores/config.d.ts +40 -0
- package/dist/src/stores/editor.d.ts +27 -0
- package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
- package/dist/stores/editor.js +1 -0
- package/dist/utils/legacyUnsubscribeConversion.js +49 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const LEGACY_UNSUBSCRIBE_SELECTOR = "td.unsubscribe-block";
|
|
2
|
+
export declare const LEGACY_UNSUBSCRIBE_LINK_SELECTORS: readonly ["a.unsubscribe-link", "a[href*=\"unsubscribe\"]"];
|
|
3
|
+
export interface LegacyUnsubscribeConversionResult {
|
|
4
|
+
html: string;
|
|
5
|
+
converted: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const hasLegacyUnsubscribeClass: (html: string) => boolean;
|
|
8
|
+
export declare const convertLinklessLegacyUnsubscribeBlocks: (root: ParentNode) => number;
|
|
9
|
+
export declare const convertLegacyUnsubscribeInModuleHtml: (html: string) => LegacyUnsubscribeConversionResult;
|
|
10
|
+
export declare const convertLegacyUnsubscribeInDocumentHtml: (html: string) => LegacyUnsubscribeConversionResult;
|
package/dist/stores/editor.js
CHANGED
|
@@ -16,6 +16,7 @@ const o = e("guidoEditor", {
|
|
|
16
16
|
// that need every change (the outbound state bridge) watch this instead.
|
|
17
17
|
changeSeq: 0,
|
|
18
18
|
isStripoInitialized: !1,
|
|
19
|
+
isLegacyUnsubscribeModalRequested: !1,
|
|
19
20
|
templateId: "",
|
|
20
21
|
syncModulesEnabled: !1,
|
|
21
22
|
// In-session id high-water mark; floors tracking-id minting so ids
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { protectLiquid as a, restoreLiquid as u } from "./liquidProtection.js";
|
|
2
|
+
const b = "td.unsubscribe-block", l = ["a.unsubscribe-link", 'a[href*="unsubscribe"]'], d = "esd-block-text", m = [
|
|
3
|
+
"unsubscribe-block",
|
|
4
|
+
"esd-extension",
|
|
5
|
+
"esd-extension-block",
|
|
6
|
+
"esd-unsubscribe-block",
|
|
7
|
+
"esd-block-unsubscribe"
|
|
8
|
+
], L = "esd-extension-block-id", S = "data-unsubscribe-", E = "address,article,aside,blockquote,center,details,dialog,dir,div,dd,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,listing,main,menu,nav,ol,p,plaintext,pre,search,section,summary,table,ul,xmp", f = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?![\\w-])`, "i"), p = (e) => typeof e == "string" && f.test(e), y = (e) => l.some((t) => e.querySelector(t) !== null), g = (e) => {
|
|
9
|
+
e.classList.remove(...m), e.classList.add(d), e.removeAttribute(L), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(S)).forEach(({ name: t }) => e.removeAttribute(t)), e.querySelector(E) || (e.innerHTML = `<p path="1">${e.innerHTML}</p>`);
|
|
10
|
+
}, h = (e) => {
|
|
11
|
+
const t = Array.from(e.querySelectorAll(b)).filter((r) => !y(r));
|
|
12
|
+
return t.forEach(g), t.length;
|
|
13
|
+
}, v = (e) => {
|
|
14
|
+
const t = e.trimStart(), r = new DOMParser();
|
|
15
|
+
return /^<t[dh][\s>]/i.test(t) ? r.parseFromString(`<table><tbody><tr>${e}</tr></tbody></table>`, "text/html").querySelector("tr") : /^<tr[\s>]/i.test(t) ? r.parseFromString(`<table><tbody>${e}</tbody></table>`, "text/html").querySelector("tbody") : /^<table[\s>]/i.test(t) ? r.parseFromString(e, "text/html").body : (console.debug("[LegacyUnsubscribeConversion] Skipped module with a non-table root"), null);
|
|
16
|
+
}, c = (e) => {
|
|
17
|
+
const t = e.search(/<html[\s>]/i), r = [...e.matchAll(/<\/html\s*>/gi)].at(-1), s = (r == null ? void 0 : r.index) === void 0 ? -1 : r.index + r[0].length;
|
|
18
|
+
return t < 0 || s <= t ? { head: "", root: e, tail: "" } : { head: e.slice(0, t), root: e.slice(t, s), tail: e.slice(s) };
|
|
19
|
+
}, i = (e, t, r, s) => {
|
|
20
|
+
if (!p(e))
|
|
21
|
+
return { html: e, converted: !1 };
|
|
22
|
+
try {
|
|
23
|
+
const o = a(e), n = t(o);
|
|
24
|
+
return !n || h(n) === 0 ? { html: e, converted: !1 } : { html: u(r(n, o)), converted: !0 };
|
|
25
|
+
} catch (o) {
|
|
26
|
+
return console.error(`Failed to convert legacy unsubscribe blocks in ${s}:`, o), { html: e, converted: !1 };
|
|
27
|
+
}
|
|
28
|
+
}, C = (e) => i(
|
|
29
|
+
e,
|
|
30
|
+
v,
|
|
31
|
+
(t) => t.innerHTML,
|
|
32
|
+
"module"
|
|
33
|
+
), _ = (e) => i(
|
|
34
|
+
e,
|
|
35
|
+
(t) => new DOMParser().parseFromString(c(t).root, "text/html"),
|
|
36
|
+
(t, r) => {
|
|
37
|
+
const { head: s, tail: o } = c(r);
|
|
38
|
+
return `${s}${t.documentElement.outerHTML}${o}`;
|
|
39
|
+
},
|
|
40
|
+
"document"
|
|
41
|
+
);
|
|
42
|
+
export {
|
|
43
|
+
l as LEGACY_UNSUBSCRIBE_LINK_SELECTORS,
|
|
44
|
+
b as LEGACY_UNSUBSCRIBE_SELECTOR,
|
|
45
|
+
_ as convertLegacyUnsubscribeInDocumentHtml,
|
|
46
|
+
C as convertLegacyUnsubscribeInModuleHtml,
|
|
47
|
+
h as convertLinklessLegacyUnsubscribeBlocks,
|
|
48
|
+
p as hasLegacyUnsubscribeClass
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.26.0",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|