@templatical/editor 0.54.2 → 0.55.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/dist/{AiAltTextPopover-BBKVJ6HA.js → AiAltTextPopover-D5QosKvB.js} +1 -1
- package/dist/{AiAltTextReview-BuVbeQh-.js → AiAltTextReview-D1W_lrI_.js} +1 -1
- package/dist/{AiRewriteMenu-ZpYJfm-O.js → AiRewriteMenu-BwztoMov.js} +4 -4
- package/dist/{BlockPreviewCanvas-DtOo5y3U.js → BlockPreviewCanvas-C23A6FRm.js} +4 -4
- package/dist/{CloudPanels-DQRWMc59.js → CloudPanels-Baoaj6Xf.js} +1 -1
- package/dist/{CountdownToolbar-DTpMEDyh.js → CountdownToolbar-CA_gDIdZ.js} +4 -4
- package/dist/{IssuesPanel-BZn7-p9e.js → IssuesPanel-nmFhWG1p.js} +1 -1
- package/dist/{LanguageMenu-OOmQWVzO.js → LanguageMenu-DcABUYop.js} +3 -3
- package/dist/{LogicTagInsertButton-XESwnJia.js → LogicTagInsertButton-qZ82VMFx.js} +284 -279
- package/dist/{MergeTagInput-CAsBRoSm.js → MergeTagInput-JJeZbFkD.js} +1 -1
- package/dist/{MergeTagModeToggle-bOf27Hg1.js → MergeTagModeToggle-DDucd1eC.js} +1 -1
- package/dist/{MergeTagTextarea-DH_6JFui.js → MergeTagTextarea-dQ2LRrNB.js} +2 -2
- package/dist/{ParagraphEditor-XGUkV5Uw.js → ParagraphEditor-VXYwGoz_.js} +8 -8
- package/dist/{RestoreVersionDialog-C72kWccI.js → RestoreVersionDialog-BibNvAaJ.js} +1 -1
- package/dist/{RichTextEditorContent-BZN8KRvR.js → RichTextEditorContent-CU5EOlM_.js} +2 -2
- package/dist/{SaveBlockDialog-CKOnTMTU.js → SaveBlockDialog-S9aFi0cy.js} +4 -4
- package/dist/{SavedBlocksBrowserModal-BrlNxqDH.js → SavedBlocksBrowserModal-DIdn6B0J.js} +4 -4
- package/dist/{SavedBlocksPanels--lPR6gdh.js → SavedBlocksPanels-Cme2M6u8.js} +1 -1
- package/dist/{SavedBlocksPickBar-4ON4_KKl.js → SavedBlocksPickBar-BDmA7r3m.js} +1 -1
- package/dist/{TemplateSettings-BE0jZmRJ.js → TemplateSettings-C_LHLm5M.js} +4 -4
- package/dist/{TestEmailModal-BKmNGrZN.js → TestEmailModal-CLIRn7eL.js} +5 -5
- package/dist/{TestEmailPanel-DT1wllX3.js → TestEmailPanel-frdtjC8h.js} +1 -1
- package/dist/{TitleEditor-HjVZuUTB.js → TitleEditor-D5kC56Jl.js} +4 -4
- package/dist/{Toolbar-BppchV2k.js → Toolbar-D904Yw_R.js} +551 -503
- package/dist/{TplModal-BFWOoK8l.js → TplModal-BBdotDf1.js} +1 -1
- package/dist/{VersionHistoryPanels-D4yNVLvq.js → VersionHistoryPanels-DhagEgOk.js} +1 -1
- package/dist/{WrapperBlock-BUzQTZuu.js → WrapperBlock-BAT3T0Cz.js} +3 -3
- package/dist/{blockTypeIcons-D91v9k0x.js → blockTypeIcons-CoRQV_hP.js} +1 -1
- package/dist/bundle-stats.json +6 -6
- package/dist/{cdn/chunks/ca-DOuIxWRv.js → ca-DIkMxYCN.js} +10 -3
- package/dist/cdn/chunks/{AiAltTextPopover-CAI18sdv.js → AiAltTextPopover-CUGOPuRo.js} +2 -2
- package/dist/cdn/chunks/{AiAltTextPopover-CAI18sdv.js.map → AiAltTextPopover-CUGOPuRo.js.map} +1 -1
- package/dist/cdn/chunks/{AiAltTextReview-CWEyMOF-.js → AiAltTextReview-B9vm_L-8.js} +2 -2
- package/dist/cdn/chunks/{AiAltTextReview-CWEyMOF-.js.map → AiAltTextReview-B9vm_L-8.js.map} +1 -1
- package/dist/cdn/chunks/{AiRewriteMenu-BEepu1vo.js → AiRewriteMenu-BvV_7tNZ.js} +7 -7
- package/dist/cdn/chunks/{AiRewriteMenu-BEepu1vo.js.map → AiRewriteMenu-BvV_7tNZ.js.map} +1 -1
- package/dist/cdn/chunks/{BlockPreviewCanvas-B6ndvof2.js → BlockPreviewCanvas-Dr-xGq6v.js} +7 -7
- package/dist/cdn/chunks/{BlockPreviewCanvas-B6ndvof2.js.map → BlockPreviewCanvas-Dr-xGq6v.js.map} +1 -1
- package/dist/cdn/chunks/{CloudPanels-BGwDb0jB.js → CloudPanels-CQ0vNgsH.js} +2 -2
- package/dist/cdn/chunks/{CloudPanels-BGwDb0jB.js.map → CloudPanels-CQ0vNgsH.js.map} +1 -1
- package/dist/cdn/chunks/{CountdownToolbar-B-0FsTj-.js → CountdownToolbar-BxW-J7DX.js} +5 -5
- package/dist/cdn/chunks/{CountdownToolbar-B-0FsTj-.js.map → CountdownToolbar-BxW-J7DX.js.map} +1 -1
- package/dist/cdn/chunks/{IssuesPanel-LyjMBDok.js → IssuesPanel-BoHeIjvw.js} +3 -3
- package/dist/cdn/chunks/{IssuesPanel-LyjMBDok.js.map → IssuesPanel-BoHeIjvw.js.map} +1 -1
- package/dist/cdn/chunks/{LanguageMenu-CGwMCOQ5.js → LanguageMenu-BnYN5N1h.js} +7 -7
- package/dist/cdn/chunks/{LanguageMenu-CGwMCOQ5.js.map → LanguageMenu-BnYN5N1h.js.map} +1 -1
- package/dist/cdn/chunks/{LogicTagInsertButton-PDKuo2J3.js → LogicTagInsertButton-Bt2PXbQ0.js} +255 -250
- package/dist/cdn/chunks/LogicTagInsertButton-Bt2PXbQ0.js.map +1 -0
- package/dist/cdn/chunks/{MergeTagInput-DoQHBJk2.js → MergeTagInput-BELdMRni.js} +2 -2
- package/dist/cdn/chunks/{MergeTagInput-DoQHBJk2.js.map → MergeTagInput-BELdMRni.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagModeToggle-Ct5IG4VW.js → MergeTagModeToggle-DKfMDIEF.js} +2 -2
- package/dist/cdn/chunks/{MergeTagModeToggle-Ct5IG4VW.js.map → MergeTagModeToggle-DKfMDIEF.js.map} +1 -1
- package/dist/cdn/chunks/{MergeTagTextarea-BMsnjphR.js → MergeTagTextarea-w6xen3Xh.js} +5 -5
- package/dist/cdn/chunks/{MergeTagTextarea-BMsnjphR.js.map → MergeTagTextarea-w6xen3Xh.js.map} +1 -1
- package/dist/cdn/chunks/{ParagraphEditor-CVW-kuHW.js → ParagraphEditor-Cal9hY3U.js} +9 -9
- package/dist/cdn/chunks/{ParagraphEditor-CVW-kuHW.js.map → ParagraphEditor-Cal9hY3U.js.map} +1 -1
- package/dist/cdn/chunks/{RestoreVersionDialog-7MFZz-Sb.js → RestoreVersionDialog-f_ulmASY.js} +2 -2
- package/dist/cdn/chunks/{RestoreVersionDialog-7MFZz-Sb.js.map → RestoreVersionDialog-f_ulmASY.js.map} +1 -1
- package/dist/cdn/chunks/{RichTextEditorContent-CiL-SkZg.js → RichTextEditorContent-C_v0kS4A.js} +3 -3
- package/dist/cdn/chunks/{RichTextEditorContent-CiL-SkZg.js.map → RichTextEditorContent-C_v0kS4A.js.map} +1 -1
- package/dist/cdn/chunks/{SaveBlockDialog-CxdekCYy.js → SaveBlockDialog-C6N9RFls.js} +5 -5
- package/dist/cdn/chunks/{SaveBlockDialog-CxdekCYy.js.map → SaveBlockDialog-C6N9RFls.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksBrowserModal-D9CAa2U3.js → SavedBlocksBrowserModal-Bl2sl09D.js} +4 -4
- package/dist/cdn/chunks/{SavedBlocksBrowserModal-D9CAa2U3.js.map → SavedBlocksBrowserModal-Bl2sl09D.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPanels-jfkYWtss.js → SavedBlocksPanels-DqVcmEUK.js} +2 -2
- package/dist/cdn/chunks/{SavedBlocksPanels-jfkYWtss.js.map → SavedBlocksPanels-DqVcmEUK.js.map} +1 -1
- package/dist/cdn/chunks/{SavedBlocksPickBar-yaCumC4j.js → SavedBlocksPickBar-DE-J1JVL.js} +2 -2
- package/dist/cdn/chunks/{SavedBlocksPickBar-yaCumC4j.js.map → SavedBlocksPickBar-DE-J1JVL.js.map} +1 -1
- package/dist/cdn/chunks/{TemplateSettings-SaV2UVh_.js → TemplateSettings-CpoKZ8oV.js} +5 -5
- package/dist/cdn/chunks/{TemplateSettings-SaV2UVh_.js.map → TemplateSettings-CpoKZ8oV.js.map} +1 -1
- package/dist/cdn/chunks/{TestEmailModal-ByfhP_sm.js → TestEmailModal-DI3z__Bd.js} +8 -8
- package/dist/cdn/chunks/{TestEmailModal-ByfhP_sm.js.map → TestEmailModal-DI3z__Bd.js.map} +1 -1
- package/dist/cdn/chunks/{TestEmailPanel-CfzpqpDs.js → TestEmailPanel-Cp5d2YGn.js} +2 -2
- package/dist/cdn/chunks/{TestEmailPanel-CfzpqpDs.js.map → TestEmailPanel-Cp5d2YGn.js.map} +1 -1
- package/dist/cdn/chunks/{TitleEditor-Ceb0YfWv.js → TitleEditor-C2syRLdZ.js} +4 -4
- package/dist/cdn/chunks/{TitleEditor-Ceb0YfWv.js.map → TitleEditor-C2syRLdZ.js.map} +1 -1
- package/dist/cdn/chunks/{Toolbar-Cv6Rv1S-.js → Toolbar-NEE8qxYh.js} +754 -706
- package/dist/cdn/chunks/Toolbar-NEE8qxYh.js.map +1 -0
- package/dist/cdn/chunks/{TplModal-DGpGdwgf.js → TplModal-B1MgvtX8.js} +2 -2
- package/dist/cdn/chunks/{TplModal-DGpGdwgf.js.map → TplModal-B1MgvtX8.js.map} +1 -1
- package/dist/cdn/chunks/{VersionHistoryPanels-BJnHCMAH.js → VersionHistoryPanels-Cefd8i_e.js} +2 -2
- package/dist/cdn/chunks/{VersionHistoryPanels-BJnHCMAH.js.map → VersionHistoryPanels-Cefd8i_e.js.map} +1 -1
- package/dist/cdn/chunks/{WrapperBlock-C_uE5rPJ.js → WrapperBlock-DFY-7YSs.js} +4 -4
- package/dist/cdn/chunks/{WrapperBlock-C_uE5rPJ.js.map → WrapperBlock-DFY-7YSs.js.map} +1 -1
- package/dist/{ca-DOuIxWRv.js → cdn/chunks/ca-DIkMxYCN.js} +12 -1
- package/dist/cdn/chunks/{ca-DOuIxWRv.js.map → ca-DIkMxYCN.js.map} +1 -1
- package/dist/cdn/chunks/{composables-BxikPuC1.js → composables-nyxwrM27.js} +610 -594
- package/dist/cdn/chunks/composables-nyxwrM27.js.map +1 -0
- package/dist/cdn/chunks/{createCloudRuntime-D2DUaudp.js → createCloudRuntime-DJkDGKQ_.js} +3 -3
- package/dist/cdn/chunks/{createCloudRuntime-D2DUaudp.js.map → createCloudRuntime-DJkDGKQ_.js.map} +1 -1
- package/dist/{de-DaOUfYBX.js → cdn/chunks/de-Cc6Ue0UD.js} +12 -1
- package/dist/cdn/chunks/de-Cc6Ue0UD.js.map +1 -0
- package/dist/cdn/chunks/{en-C0pHHMiR.js → en-BX4FujAQ.js} +11 -2
- package/dist/cdn/chunks/en-BX4FujAQ.js.map +1 -0
- package/dist/{es-CxyEKr6n.js → cdn/chunks/es-Do5b-MKU.js} +12 -1
- package/dist/cdn/chunks/es-Do5b-MKU.js.map +1 -0
- package/dist/cdn/chunks/{extensions-DuDWpKo7.js → extensions-BcwkOjVq.js} +76 -70
- package/dist/cdn/chunks/extensions-BcwkOjVq.js.map +1 -0
- package/dist/{fr-CYbamiI6.js → cdn/chunks/fr-S1n2Ebzp.js} +12 -1
- package/dist/cdn/chunks/fr-S1n2Ebzp.js.map +1 -0
- package/dist/cdn/chunks/{ja-DfaIAoGI.js → ja-DLwcq4bA.js} +11 -2
- package/dist/cdn/chunks/ja-DLwcq4bA.js.map +1 -0
- package/dist/{nl-DkrB-VKZ.js → cdn/chunks/nl-0JSWaZpT.js} +12 -1
- package/dist/cdn/chunks/nl-0JSWaZpT.js.map +1 -0
- package/dist/cdn/chunks/{normalizeMergeTagMarkup-Bn_hl4jd.js → normalizeMergeTagMarkup-BrGw5jxk.js} +99 -89
- package/dist/cdn/chunks/normalizeMergeTagMarkup-BrGw5jxk.js.map +1 -0
- package/dist/cdn/chunks/{preRenderCustomBlocks-C9oavydG.js → preRenderCustomBlocks-Cj0XYwuh.js} +4 -4
- package/dist/cdn/chunks/{preRenderCustomBlocks-C9oavydG.js.map → preRenderCustomBlocks-Cj0XYwuh.js.map} +1 -1
- package/dist/{pt-BR-CY5Ye7eP.js → cdn/chunks/pt-BR-D3VlIMDZ.js} +12 -1
- package/dist/cdn/chunks/pt-BR-D3VlIMDZ.js.map +1 -0
- package/dist/cdn/chunks/{sanitizeHtml-DfXoetOm.js → sanitizeHtml-GxJCxKcP.js} +3 -3
- package/dist/cdn/chunks/{sanitizeHtml-DfXoetOm.js.map → sanitizeHtml-GxJCxKcP.js.map} +1 -1
- package/dist/cdn/chunks/{socialIcons-DPwkrn5v.js → socialIcons-B5zrrV8-.js} +387 -386
- package/dist/cdn/chunks/{socialIcons-DPwkrn5v.js.map → socialIcons-B5zrrV8-.js.map} +1 -1
- package/dist/cdn/chunks/{src-712f3ofG.js → src-Diw9SLIe.js} +673 -554
- package/dist/cdn/chunks/src-Diw9SLIe.js.map +1 -0
- package/dist/cdn/chunks/{src-B2tQbzf6.js → src-UR3AQocX.js} +221 -215
- package/dist/cdn/chunks/src-UR3AQocX.js.map +1 -0
- package/dist/cdn/chunks/{src-ZFw5fg_z.js → src-v47QHNmB.js} +809 -659
- package/dist/cdn/chunks/src-v47QHNmB.js.map +1 -0
- package/dist/cdn/chunks/useLocalizedDisplay-DekV8qar.js +33 -0
- package/dist/cdn/chunks/{useLocalizedDisplay-DiNjT22M.js.map → useLocalizedDisplay-DekV8qar.js.map} +1 -1
- package/dist/cdn/chunks/{useLogicTag-SvMW4g00.js → useLogicTag-Cbp3I7UN.js} +2 -2
- package/dist/cdn/chunks/{useLogicTag-SvMW4g00.js.map → useLogicTag-Cbp3I7UN.js.map} +1 -1
- package/dist/cdn/chunks/{useMergeTag-JLz3Pqcw.js → useMergeTag-1lrpNyR5.js} +4 -4
- package/dist/cdn/chunks/{useMergeTag-JLz3Pqcw.js.map → useMergeTag-1lrpNyR5.js.map} +1 -1
- package/dist/cdn/chunks/{withCurrentFont-BcoPpkDS.js → withCurrentFont-DZfmiv8V.js} +2 -2
- package/dist/cdn/chunks/{withCurrentFont-BcoPpkDS.js.map → withCurrentFont-DZfmiv8V.js.map} +1 -1
- package/dist/cdn/editor.js +284 -284
- package/dist/cdn/editor.js.map +1 -1
- package/dist/{composables-BbPFRlBf.js → composables-DPgNn9GZ.js} +929 -913
- package/dist/{createCloudRuntime-Dlrg88gS.js → createCloudRuntime-Bw8TLmQ8.js} +2 -2
- package/dist/{cdn/chunks/de-DaOUfYBX.js → de-Cc6Ue0UD.js} +10 -3
- package/dist/{dist-C34cYI5S.js → dist-CBdk1Vcb.js} +963 -813
- package/dist/{en-C0pHHMiR.js → en-BX4FujAQ.js} +10 -1
- package/dist/{cdn/chunks/es-CxyEKr6n.js → es-Do5b-MKU.js} +10 -3
- package/dist/{extensions-xCiyqSg7.js → extensions-QFAARrjF.js} +338 -332
- package/dist/{cdn/chunks/fr-CYbamiI6.js → fr-S1n2Ebzp.js} +10 -3
- package/dist/index.d.ts +14 -1
- package/dist/{ja-DfaIAoGI.js → ja-DLwcq4bA.js} +10 -1
- package/dist/{cdn/chunks/nl-DkrB-VKZ.js → nl-0JSWaZpT.js} +10 -3
- package/dist/{normalizeMergeTagMarkup-C7FGNURu.js → normalizeMergeTagMarkup-BS0nRvhq.js} +89 -79
- package/dist/{preRenderCustomBlocks-DvbRa3L3.js → preRenderCustomBlocks-CiKvKd8V.js} +1 -1
- package/dist/{cdn/chunks/pt-BR-CY5Ye7eP.js → pt-BR-D3VlIMDZ.js} +10 -3
- package/dist/{sanitizeHtml-D_ab7dD6.js → sanitizeHtml-USjTyALR.js} +1 -1
- package/dist/{socialIcons-DhAolBjt.js → socialIcons-NvIg5ahU.js} +338 -337
- package/dist/templatical-editor.js +41 -41
- package/dist/{useLocalizedDisplay-C9MBFUr4.js → useLocalizedDisplay-LdjosX4w.js} +1 -1
- package/dist/{useLogicTag-BmuakZBd.js → useLogicTag-D8zgkXfb.js} +1 -1
- package/dist/{useMergeTag-DC4a8b_v.js → useMergeTag-k7Kr0nMd.js} +1 -1
- package/dist/{withCurrentFont-BSxJai99.js → withCurrentFont-Bzeg_gfH.js} +1 -1
- package/package.json +7 -7
- package/dist/cdn/chunks/LogicTagInsertButton-PDKuo2J3.js.map +0 -1
- package/dist/cdn/chunks/Toolbar-Cv6Rv1S-.js.map +0 -1
- package/dist/cdn/chunks/composables-BxikPuC1.js.map +0 -1
- package/dist/cdn/chunks/de-DaOUfYBX.js.map +0 -1
- package/dist/cdn/chunks/en-C0pHHMiR.js.map +0 -1
- package/dist/cdn/chunks/es-CxyEKr6n.js.map +0 -1
- package/dist/cdn/chunks/extensions-DuDWpKo7.js.map +0 -1
- package/dist/cdn/chunks/fr-CYbamiI6.js.map +0 -1
- package/dist/cdn/chunks/ja-DfaIAoGI.js.map +0 -1
- package/dist/cdn/chunks/nl-DkrB-VKZ.js.map +0 -1
- package/dist/cdn/chunks/normalizeMergeTagMarkup-Bn_hl4jd.js.map +0 -1
- package/dist/cdn/chunks/pt-BR-CY5Ye7eP.js.map +0 -1
- package/dist/cdn/chunks/src-712f3ofG.js.map +0 -1
- package/dist/cdn/chunks/src-B2tQbzf6.js.map +0 -1
- package/dist/cdn/chunks/src-ZFw5fg_z.js.map +0 -1
- package/dist/cdn/chunks/useLocalizedDisplay-DiNjT22M.js +0 -33
package/dist/cdn/chunks/{normalizeMergeTagMarkup-Bn_hl4jd.js → normalizeMergeTagMarkup-BrGw5jxk.js}
RENAMED
|
@@ -1,26 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as e, H as t, Nt as n, Pt as r, Qt as i, U as a, W as o, Xt as s, et as c, nn as l, nt as u, tn as d } from "./src-v47QHNmB.js";
|
|
2
2
|
// src/utils/normalizeMergeTagMarkup.ts
|
|
3
|
-
function
|
|
3
|
+
function f(e) {
|
|
4
4
|
let t = e.flags.includes("g") ? e.flags : `${e.flags}g`;
|
|
5
5
|
return new RegExp(e.source, t);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
value:
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
function p(n, r, i) {
|
|
8
|
+
let a = [], s = Object.values(t).includes(i), c = [], l = 0, d = (e, t, r, o) => {
|
|
9
|
+
t === "value" && (l = 0);
|
|
10
|
+
let d = s ? null : f(e), p = s ? u(n, i, t) : null, m = d?.exec(n) ?? null, h = 0;
|
|
11
|
+
for (; s ? h < p.length : m !== null;) {
|
|
12
|
+
let e = s ? p[h].index : m.index, i = s ? p[h].value : m[0], u = e + i.length;
|
|
13
|
+
if (i.length === 0) d.lastIndex++;
|
|
14
|
+
else {
|
|
15
|
+
if (t === "value") for (; c[l]?.end <= e;) l++;
|
|
16
|
+
let n = t === "value" ? c[l] : a[a.length - 1];
|
|
17
|
+
if (!n || e >= n.end || u <= n.start) {
|
|
18
|
+
let n = {
|
|
19
|
+
start: e,
|
|
20
|
+
end: u,
|
|
21
|
+
attr: r,
|
|
22
|
+
value: i,
|
|
23
|
+
label: o(i)
|
|
24
|
+
};
|
|
25
|
+
a.push(n), t === "logic" && c.push(n);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
s ? h++ : m = d.exec(n);
|
|
19
29
|
}
|
|
20
30
|
};
|
|
21
|
-
return
|
|
31
|
+
return d(i.logic, "logic", "data-logic-merge-tag", (e) => o(e, i)), d(i.value, "value", "data-merge-tag", (t) => e(t, r)), a.sort((e, t) => e.start - t.start);
|
|
22
32
|
}
|
|
23
|
-
function
|
|
33
|
+
function m(e) {
|
|
24
34
|
let t = e.createTreeWalker(e.body, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, { acceptNode(e) {
|
|
25
35
|
if (e.nodeType !== 1) return NodeFilter.FILTER_ACCEPT;
|
|
26
36
|
let t = e;
|
|
@@ -29,11 +39,11 @@ function f(e) {
|
|
|
29
39
|
for (; r !== null;) n.push(r), r = t.nextNode();
|
|
30
40
|
return n;
|
|
31
41
|
}
|
|
32
|
-
function
|
|
33
|
-
if (!e || !
|
|
42
|
+
function h(e, t, n) {
|
|
43
|
+
if (!e || !a(e, n) || typeof DOMParser > "u") return e;
|
|
34
44
|
let r = new DOMParser().parseFromString(`<!doctype html><body>${e}</body>`, "text/html"), i = 0;
|
|
35
|
-
for (let e of
|
|
36
|
-
let a = e.data, o =
|
|
45
|
+
for (let e of m(r)) {
|
|
46
|
+
let a = e.data, o = p(a, t, n);
|
|
37
47
|
if (o.length === 0) continue;
|
|
38
48
|
let s = r.createDocumentFragment(), c = 0;
|
|
39
49
|
for (let e of o) {
|
|
@@ -45,9 +55,9 @@ function p(e, t, n) {
|
|
|
45
55
|
}
|
|
46
56
|
return i === 0 ? e : r.body.innerHTML;
|
|
47
57
|
}
|
|
48
|
-
function
|
|
58
|
+
function g(e, t, n, r) {
|
|
49
59
|
if (e !== "title" && e !== "paragraph" && e !== "html" || typeof t?.content?.value != "string") return t;
|
|
50
|
-
let i = t.content, a =
|
|
60
|
+
let i = t.content, a = h(i.value, n, r);
|
|
51
61
|
return a === i.value ? t : {
|
|
52
62
|
...t,
|
|
53
63
|
content: {
|
|
@@ -56,17 +66,17 @@ function m(e, t, n, r) {
|
|
|
56
66
|
}
|
|
57
67
|
};
|
|
58
68
|
}
|
|
59
|
-
function
|
|
60
|
-
let
|
|
61
|
-
if (
|
|
62
|
-
let
|
|
63
|
-
let o =
|
|
64
|
-
return o === a.text ? [
|
|
69
|
+
function _(e, t, n) {
|
|
70
|
+
let r = e.l10n;
|
|
71
|
+
if (r) {
|
|
72
|
+
let i = !1, a = Object.fromEntries(Object.entries(r).map(([r, a]) => {
|
|
73
|
+
let o = g(e.type, a.text, t, n);
|
|
74
|
+
return o === a.text ? [r, a] : (i = !0, [r, {
|
|
65
75
|
...a,
|
|
66
76
|
text: o
|
|
67
77
|
}]);
|
|
68
78
|
}));
|
|
69
|
-
|
|
79
|
+
i && (e = {
|
|
70
80
|
...e,
|
|
71
81
|
l10n: a
|
|
72
82
|
});
|
|
@@ -76,7 +86,7 @@ function h(e, t, n) {
|
|
|
76
86
|
let r = !1, i = e.children.map((e) => {
|
|
77
87
|
if (!Array.isArray(e)) return e;
|
|
78
88
|
let i = !1, a = e.map((e) => {
|
|
79
|
-
let r =
|
|
89
|
+
let r = _(e, t, n);
|
|
80
90
|
return r !== e && (i = !0), r;
|
|
81
91
|
});
|
|
82
92
|
return i ? (r = !0, a) : e;
|
|
@@ -89,7 +99,7 @@ function h(e, t, n) {
|
|
|
89
99
|
if (e.type === "wrapper") {
|
|
90
100
|
if (!Array.isArray(e.children)) return e;
|
|
91
101
|
let r = !1, i = e.children.map((e) => {
|
|
92
|
-
let i =
|
|
102
|
+
let i = _(e, t, n);
|
|
93
103
|
return i !== e && (r = !0), i;
|
|
94
104
|
});
|
|
95
105
|
return r ? {
|
|
@@ -98,9 +108,9 @@ function h(e, t, n) {
|
|
|
98
108
|
} : e;
|
|
99
109
|
}
|
|
100
110
|
if (e.type !== "title" && e.type !== "paragraph" || typeof e.content != "string") return e;
|
|
101
|
-
let a =
|
|
111
|
+
let a = h(e.content, t, n);
|
|
102
112
|
if (a === e.content) return e;
|
|
103
|
-
let o =
|
|
113
|
+
let o = i(e.content), s = i(a), c = e.l10n && Object.fromEntries(Object.entries(e.l10n).map(([e, t]) => {
|
|
104
114
|
let n = t.text?.content;
|
|
105
115
|
return [e, n?.sourceHash === o ? {
|
|
106
116
|
...t,
|
|
@@ -119,10 +129,10 @@ function h(e, t, n) {
|
|
|
119
129
|
...c ? { l10n: c } : {}
|
|
120
130
|
};
|
|
121
131
|
}
|
|
122
|
-
function
|
|
132
|
+
function v(e, t, n) {
|
|
123
133
|
if (!e || !Array.isArray(e.blocks)) return e;
|
|
124
134
|
let r = !1, i = e.blocks.map((e) => {
|
|
125
|
-
let i =
|
|
135
|
+
let i = _(e, t, n);
|
|
126
136
|
return i !== e && (r = !0), i;
|
|
127
137
|
});
|
|
128
138
|
return r ? {
|
|
@@ -130,16 +140,16 @@ function g(e, t, n) {
|
|
|
130
140
|
blocks: i
|
|
131
141
|
} : e;
|
|
132
142
|
}
|
|
133
|
-
function
|
|
134
|
-
return
|
|
143
|
+
function y(e, t) {
|
|
144
|
+
return v(x(e), t?.tags ?? [], c(t?.syntax));
|
|
135
145
|
}
|
|
136
|
-
function
|
|
137
|
-
return
|
|
146
|
+
function b(e, t) {
|
|
147
|
+
return _(e, t?.tags ?? [], c(t?.syntax));
|
|
138
148
|
}
|
|
139
|
-
function
|
|
140
|
-
return typeof e == "object" && e ?
|
|
149
|
+
function x(e) {
|
|
150
|
+
return typeof e == "object" && e ? l(e) : e;
|
|
141
151
|
}
|
|
142
|
-
function
|
|
152
|
+
function S(e, t) {
|
|
143
153
|
return {
|
|
144
154
|
get state() {
|
|
145
155
|
return e.state;
|
|
@@ -147,51 +157,51 @@ function b(e, t) {
|
|
|
147
157
|
get content() {
|
|
148
158
|
return e.content;
|
|
149
159
|
},
|
|
150
|
-
setContent: (n, r) => e.setContent(
|
|
160
|
+
setContent: (n, r) => e.setContent(y(n, t), r)
|
|
151
161
|
};
|
|
152
162
|
}
|
|
153
|
-
function
|
|
163
|
+
function C(e, t) {
|
|
154
164
|
return {
|
|
155
165
|
...e,
|
|
156
166
|
async load(n) {
|
|
157
167
|
let r = await e.load(n);
|
|
158
168
|
return {
|
|
159
169
|
...r,
|
|
160
|
-
content:
|
|
170
|
+
content: y(r.content, t)
|
|
161
171
|
};
|
|
162
172
|
}
|
|
163
173
|
};
|
|
164
174
|
}
|
|
165
|
-
function
|
|
175
|
+
function w(e, t) {
|
|
166
176
|
if (Array.isArray(e)) for (let n of e) {
|
|
167
177
|
if (!n || typeof n != "object") continue;
|
|
168
178
|
if (n.id === t) return n.type;
|
|
169
179
|
let e = n.children;
|
|
170
180
|
if (n.type === "section" && Array.isArray(e)) for (let n of e) {
|
|
171
|
-
let e =
|
|
181
|
+
let e = w(n, t);
|
|
172
182
|
if (e) return e;
|
|
173
183
|
}
|
|
174
184
|
else if (n.type === "wrapper") {
|
|
175
|
-
let n =
|
|
185
|
+
let n = w(e, t);
|
|
176
186
|
if (n) return n;
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
189
|
}
|
|
180
|
-
function
|
|
190
|
+
function T(e, t) {
|
|
181
191
|
typeof e.id == "string" && t.set(e.id, e.type);
|
|
182
192
|
let n = e.children;
|
|
183
193
|
if (!Array.isArray(n)) return;
|
|
184
194
|
let r = e.type === "section" ? n.flat() : n;
|
|
185
|
-
for (let e of r) e && typeof e == "object" &&
|
|
195
|
+
for (let e of r) e && typeof e == "object" && T(e, t);
|
|
186
196
|
}
|
|
187
|
-
function
|
|
188
|
-
let
|
|
197
|
+
function E(e, t, a) {
|
|
198
|
+
let o = a?.tags ?? [], u = c(a?.syntax), f = /* @__PURE__ */ new Map(), p = e.some((e) => e.op === "updateBlockLocale"), m = l(t), y = l(t), b = (e, t, i) => {
|
|
189
199
|
try {
|
|
190
|
-
if (!("expect" in t)) return
|
|
191
|
-
let { expect:
|
|
192
|
-
return
|
|
200
|
+
if (!("expect" in t)) return r(e, [t]);
|
|
201
|
+
let { expect: n, ...i } = t;
|
|
202
|
+
return r(e, [i]);
|
|
193
203
|
} catch (e) {
|
|
194
|
-
throw e instanceof
|
|
204
|
+
throw e instanceof n ? new n(e.code, i, e.message, e.blockId) : e;
|
|
195
205
|
}
|
|
196
206
|
}, x = (e, t) => {
|
|
197
207
|
let n = (e) => {
|
|
@@ -203,34 +213,34 @@ function w(i, o, l) {
|
|
|
203
213
|
}
|
|
204
214
|
};
|
|
205
215
|
return n(e?.blocks);
|
|
206
|
-
},
|
|
207
|
-
if (!
|
|
208
|
-
let
|
|
209
|
-
for (let [
|
|
210
|
-
if (!
|
|
211
|
-
let
|
|
212
|
-
p !==
|
|
213
|
-
...
|
|
214
|
-
[
|
|
215
|
-
...
|
|
216
|
+
}, S = (e, t, n, r) => {
|
|
217
|
+
if (!e) return e;
|
|
218
|
+
let a = e;
|
|
219
|
+
for (let [o, c] of Object.entries(e)) {
|
|
220
|
+
if (!c) continue;
|
|
221
|
+
let e = r ? t?.l10n?.[r]?.text?.[o] : void 0, l = r ? n?.l10n?.[r]?.text?.[o] : void 0, u = s(t, o), f = s(n, o), p = e && l && d(c, e) ? l.sourceHash : typeof u == "string" && typeof f == "string" && c.sourceHash === i(u) ? i(f) : c.sourceHash;
|
|
222
|
+
p !== c.sourceHash && (a = {
|
|
223
|
+
...a,
|
|
224
|
+
[o]: {
|
|
225
|
+
...c,
|
|
216
226
|
sourceHash: p
|
|
217
227
|
}
|
|
218
228
|
});
|
|
219
229
|
}
|
|
220
|
-
return
|
|
221
|
-
},
|
|
230
|
+
return a;
|
|
231
|
+
}, C = !1, E = (e) => {
|
|
222
232
|
if (e.op === "addBlock") {
|
|
223
233
|
if (!e.block || typeof e.block != "object") return e;
|
|
224
|
-
|
|
225
|
-
let t =
|
|
226
|
-
return t === e.block ? e : (
|
|
234
|
+
T(e.block, f);
|
|
235
|
+
let t = _(e.block, o, u);
|
|
236
|
+
return t === e.block ? e : (C = !0, {
|
|
227
237
|
...e,
|
|
228
238
|
block: t
|
|
229
239
|
});
|
|
230
240
|
}
|
|
231
241
|
if (e.op === "deleteBlock" && e.expect?.block) {
|
|
232
|
-
let t =
|
|
233
|
-
return t === e.expect.block ? e : (
|
|
242
|
+
let t = _(e.expect.block, o, u);
|
|
243
|
+
return t === e.expect.block ? e : (C = !0, {
|
|
234
244
|
...e,
|
|
235
245
|
expect: {
|
|
236
246
|
...e.expect,
|
|
@@ -239,28 +249,28 @@ function w(i, o, l) {
|
|
|
239
249
|
});
|
|
240
250
|
}
|
|
241
251
|
if (e.op === "updateBlockLocale") {
|
|
242
|
-
let t = f.get(e.blockId) ??
|
|
252
|
+
let t = f.get(e.blockId) ?? w(m?.blocks, e.blockId), n = x(m, e.blockId), r = x(y, e.blockId), i = g(t, S(e.text, n, r), o, u), a = g(t, S(e.expect?.text, n, r, e.locale), o, u), s = e.expect && a !== e.expect.text ? {
|
|
243
253
|
...e.expect,
|
|
244
254
|
text: a
|
|
245
255
|
} : e.expect;
|
|
246
|
-
return i === e.text &&
|
|
256
|
+
return i === e.text && s === e.expect ? e : (C = !0, {
|
|
247
257
|
...e,
|
|
248
258
|
...i ? { text: i } : {},
|
|
249
|
-
...
|
|
259
|
+
...s ? { expect: s } : {}
|
|
250
260
|
});
|
|
251
261
|
}
|
|
252
262
|
if (e.op === "updateBlock") {
|
|
253
|
-
let t = f.get(e.blockId) ??
|
|
263
|
+
let t = f.get(e.blockId) ?? w(m?.blocks, e.blockId);
|
|
254
264
|
if (t !== "title" && t !== "paragraph") return e;
|
|
255
265
|
let n = (e) => {
|
|
256
266
|
if (typeof e?.content != "string") return e;
|
|
257
|
-
let t =
|
|
267
|
+
let t = h(e.content, o, u);
|
|
258
268
|
return t === e.content ? e : {
|
|
259
269
|
...e,
|
|
260
270
|
content: t
|
|
261
271
|
};
|
|
262
272
|
}, r = n(e.set), i = n(e.expect);
|
|
263
|
-
return r === e.set && i === e.expect ? e : (
|
|
273
|
+
return r === e.set && i === e.expect ? e : (C = !0, {
|
|
264
274
|
...e,
|
|
265
275
|
...r ? { set: r } : {},
|
|
266
276
|
...i ? { expect: i } : {}
|
|
@@ -268,23 +278,23 @@ function w(i, o, l) {
|
|
|
268
278
|
}
|
|
269
279
|
if (e.op === "setContent") {
|
|
270
280
|
f.clear();
|
|
271
|
-
let t =
|
|
272
|
-
return t === e.content ? e : (
|
|
281
|
+
let t = v(e.content, o, u);
|
|
282
|
+
return t === e.content ? e : (C = !0, {
|
|
273
283
|
...e,
|
|
274
284
|
content: t
|
|
275
285
|
});
|
|
276
286
|
}
|
|
277
287
|
return e;
|
|
278
|
-
}, D =
|
|
288
|
+
}, D = e.map((e, t) => {
|
|
279
289
|
let n = E(e);
|
|
280
|
-
if (
|
|
281
|
-
let r = b(
|
|
282
|
-
|
|
283
|
-
} else e.op === "setContent" && (
|
|
290
|
+
if (p) {
|
|
291
|
+
let r = b(m, e, t), i = b(y, n, t);
|
|
292
|
+
m = r, y = i;
|
|
293
|
+
} else e.op === "setContent" && (m = e.content);
|
|
284
294
|
return n;
|
|
285
295
|
});
|
|
286
|
-
return
|
|
296
|
+
return C ? D : e;
|
|
287
297
|
}
|
|
288
|
-
export {
|
|
298
|
+
export { S as a, E as i, y as n, C as o, h as r, b as t };
|
|
289
299
|
|
|
290
|
-
//# sourceMappingURL=normalizeMergeTagMarkup-
|
|
300
|
+
//# sourceMappingURL=normalizeMergeTagMarkup-BrGw5jxk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeMergeTagMarkup-BrGw5jxk.js","names":["getMergeTagLabel","SYNTAX_PRESETS","OperationError","applyOperations","sourceHash","containsMergeTag","getLogicMergeTagKeyword","readPath","resolveSyntax","safeClone","scanSyntaxMatches","deepEqual","globalRegex","flags","pattern","collectHits","hits","builtin","syntax","logicHits","logicIndex","scan","kind","regex","matches","text","match","index","start","value","end","other","hit","label","mergeTags","a","b","collectNormalizableTextNodes","walker","doc","node","el","nodes","current","normalizeMergeTagsInHtml","html","replacements","fragment","cursor","span","normalizeLocaleText","blockType","entry","normalizeBlock","l10n","block","changed","next","locale","layer","children","column","columnChanged","normalized","child","content","before","after","restamped","normalizeMergeTagMarkup","blocks","normalizeContentForConfig","copyIncomingContent","normalizeBlockForConfig","withNormalizedContentWrites","editor","markDirty","withNormalizedTemplateLoads","provider","template","id","blockTypeOf","found","collectBlockTypes","into","nested","normalizeRemoteOperations","tags","added","needsLocaleState","ops","op","original","normalizedState","advance","state","_expect","unguarded","error","blockIn","find","restamp","entries","result","path","oldEntry","newEntry","oldBase","newBase","hash","normalizeOne","type","expectText","expect","normalizeField","fields","set","nextOriginal","nextNormalized"],"sources":["../../../src/utils/normalizeMergeTagMarkup.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type {\n Block,\n MergeTag,\n LocalizedText,\n MergeTagsConfig,\n Operation,\n SectionBlock,\n SyntaxPreset,\n TemplateContent,\n TemplatesProvider,\n WrapperBlock,\n} from \"@templatical/types\";\nimport {\n sourceHash,\n readPath,\n deepEqual,\n applyOperations,\n containsMergeTag,\n getLogicMergeTagKeyword,\n getMergeTagLabel,\n OperationError,\n resolveSyntax,\n safeClone,\n scanSyntaxMatches,\n SYNTAX_PRESETS,\n} from \"@templatical/types\";\n\n/**\n * Convert bare merge-tag tokens in rich-text HTML into the `<span\n * data-merge-tag>` nodes the editor understands.\n *\n * A tag reaches stored content in one of two physical shapes. Anything a user\n * types or pastes is already a node, because `MergeTagNode`'s input and paste\n * rules convert it on the spot. What stays a bare token is content that never\n * passed through that pipeline — `init({ content })`, `setContent()`, a\n * template loaded from a store, or one produced by the `@templatical/import-*`\n * converters. A bare token renders as literal text: no label, no highlight, no\n * `sample` substitution, and it cannot be selected or deleted as a unit.\n *\n * Three properties of this implementation are load-bearing:\n *\n * 1. **It walks text nodes, never markup.** A token in attribute position —\n * `<a href=\"{{unsubscribe_url}}\">` is the common one — must be left exactly\n * as it is; wrapping it injects an element into an attribute value and\n * corrupts the document. A `TreeWalker` over text nodes cannot reach an\n * attribute at all, so this holds by construction rather than by guard.\n * A regex cannot do this job. Guarding with a `(?<!data-merge-tag=\")`\n * lookbehind protects the attribute of an already-converted span and\n * nothing else, so `<a href=\"{{unsubscribe_url}}\">` becomes an anchor whose\n * href contains a `<span>`. Telling text position from attribute position\n * needs parsing; no amount of lookbehind substitutes for it.\n *\n * 2. **It is idempotent structurally.** The walk rejects the whole subtree of\n * any element already carrying `data-merge-tag` / `data-logic-merge-tag`,\n * so an existing span's inner text is unreachable no matter what it says.\n * That covers the case where a tag's label *is* its value.\n *\n * 3. **It never builds markup by concatenation.** A consumer may configure a\n * syntax whose delimiters contain `<` / `>` — Smarty-style `<% $email %>` —\n * so a template string would emit an attribute no scanner could re-read.\n * Spans are created as elements and filled via `setAttribute` /\n * `textContent`, which leaves escaping to the serializer.\n *\n * Matching is driven by `syntax`, not by the declared tag list, so a template\n * migrated from another ESP has all of its tags made atomic rather than only\n * the handful the consumer has declared so far. An undeclared token falls back\n * to showing its raw value as the label, which `getMergeTagLabel` already does.\n * This mirrors typing: the input and paste rules are registered unconditionally\n * and match on syntax alone.\n */\n\ninterface TagHit {\n start: number;\n end: number;\n attr: string;\n value: string;\n label: string;\n}\n\nfunction globalRegex(pattern: RegExp): RegExp {\n const flags = pattern.flags.includes(\"g\")\n ? pattern.flags\n : `${pattern.flags}g`;\n return new RegExp(pattern.source, flags);\n}\n\nexport function collectHits(\n text: string,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): TagHit[] {\n const hits: TagHit[] = [];\n const builtin = Object.values(SYNTAX_PRESETS).includes(\n syntax as Required<SyntaxPreset>,\n );\n const logicHits: TagHit[] = [];\n let logicIndex = 0;\n\n const scan = (\n pattern: RegExp,\n kind: \"logic\" | \"value\",\n attr: string,\n label: (match: string) => string,\n ): void => {\n if (kind === \"value\") logicIndex = 0;\n const regex = builtin ? null : globalRegex(pattern);\n const matches = builtin ? scanSyntaxMatches(text, syntax, kind) : null;\n let match = regex?.exec(text) ?? null;\n let index = 0;\n while (builtin ? index < matches!.length : match !== null) {\n const start = builtin ? matches![index].index : match!.index;\n const value = builtin ? matches![index].value : match![0];\n const end = start + value.length;\n if (value.length === 0) {\n regex!.lastIndex++;\n } else {\n if (kind === \"value\") {\n while (logicHits[logicIndex]?.end <= start) logicIndex++;\n }\n const other =\n kind === \"value\" ? logicHits[logicIndex] : hits[hits.length - 1];\n if (!other || start >= other.end || end <= other.start) {\n const hit = {\n start,\n end,\n attr,\n value,\n label: label(value),\n };\n hits.push(hit);\n if (kind === \"logic\") logicHits.push(hit);\n }\n }\n if (builtin) index++;\n else match = regex!.exec(text);\n }\n };\n\n // Logic first, so it wins any overlap. Some syntaxes' value regex is liberal\n // enough to also match a logic tag — handlebars' `{{.+?}}` swallows\n // `{{#each items}}` — and `isMergeTagValue` resolves that same way.\n scan(syntax.logic, \"logic\", \"data-logic-merge-tag\", (value) =>\n getLogicMergeTagKeyword(value, syntax),\n );\n scan(syntax.value, \"value\", \"data-merge-tag\", (value) =>\n getMergeTagLabel(value, mergeTags),\n );\n\n return hits.sort((a, b) => a.start - b.start);\n}\n\n/** Text nodes not already inside a merge-tag span, in document order. */\nfunction collectNormalizableTextNodes(doc: Document): Text[] {\n const walker = doc.createTreeWalker(\n doc.body,\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,\n {\n acceptNode(node: Node): number {\n if (node.nodeType !== 1) return NodeFilter.FILTER_ACCEPT;\n const el = node as Element;\n // REJECT (not SKIP) prunes the subtree, which is what makes a second\n // pass unable to see an existing span's inner text.\n return el.hasAttribute(\"data-merge-tag\") ||\n el.hasAttribute(\"data-logic-merge-tag\")\n ? NodeFilter.FILTER_REJECT\n : NodeFilter.FILTER_SKIP;\n },\n },\n );\n\n // Collected up front: replacing a node mid-walk invalidates the walker.\n const nodes: Text[] = [];\n let current = walker.nextNode();\n while (current !== null) {\n nodes.push(current as Text);\n current = walker.nextNode();\n }\n return nodes;\n}\n\nexport function normalizeMergeTagsInHtml(\n html: string,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): string {\n if (!html) return html;\n // Cheap reject before paying for a parse. A token that exists only in an\n // attribute still gets past this, and is then caught by the zero-replacement\n // short-circuit below.\n if (!containsMergeTag(html, syntax)) return html;\n if (typeof DOMParser === \"undefined\") return html;\n\n const doc = new DOMParser().parseFromString(\n `<!doctype html><body>${html}</body>`,\n \"text/html\",\n );\n\n let replacements = 0;\n for (const node of collectNormalizableTextNodes(doc)) {\n const text = node.data;\n const hits = collectHits(text, mergeTags, syntax);\n if (hits.length === 0) continue;\n\n const fragment = doc.createDocumentFragment();\n let cursor = 0;\n for (const hit of hits) {\n if (hit.start > cursor) {\n fragment.appendChild(\n doc.createTextNode(text.substring(cursor, hit.start)),\n );\n }\n const span = doc.createElement(\"span\");\n span.setAttribute(hit.attr, hit.value);\n span.textContent = hit.label;\n fragment.appendChild(span);\n cursor = hit.end;\n }\n if (cursor < text.length) {\n fragment.appendChild(doc.createTextNode(text.substring(cursor)));\n }\n\n node.parentNode?.replaceChild(fragment, node);\n replacements += hits.length;\n }\n\n // Nothing matched in text position, so return the input verbatim rather than\n // a re-serialization of it — otherwise content with no tags at all would be\n // rewritten (`<br/>` → `<br>`, attribute quoting, entity encoding) for no\n // reason. Where a replacement does happen some churn is unavoidable, and the\n // renderer accepts both shapes.\n if (replacements === 0) return html;\n\n return doc.body.innerHTML;\n}\n\n/** Normalize localized rich content without changing source hashes or caller-owned objects. */\nfunction normalizeLocaleText<T extends LocalizedText | null>(\n blockType: string | undefined,\n text: Record<string, T> | undefined,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): Record<string, T> | undefined {\n if (\n (blockType !== \"title\" &&\n blockType !== \"paragraph\" &&\n blockType !== \"html\") ||\n typeof text?.content?.value !== \"string\"\n )\n return text;\n const entry = text.content;\n const value = normalizeMergeTagsInHtml(entry.value, mergeTags, syntax);\n return value === entry.value\n ? text\n : { ...text, content: { ...entry, value } };\n}\n\n/**\n * Localized layers normalize only content on titles, paragraphs and HTML\n * blocks. Among base fields, only title and paragraph rich text is normalized. Every other merge-tag-bearing field —\n * `ButtonBlock.text`/`url`, `ImageBlock.alt`, `HtmlBlock.content`, custom-block\n * `fieldValues`, `settings.preheaderText` — is a plain string rendered as text,\n * so a span written into one would be displayed literally on the canvas and\n * emitted into a `url=` attribute by the renderer.\n *\n * `TableCellData.content` is span-bearing to the renderer but is deliberately\n * excluded: `TableBlock.vue` hydrates a cell with `textContent` and writes\n * `innerText` back on blur, so the first focus-and-leave on a normalized cell\n * would persist the literal markup into stored content as text. The\n * editor/renderer asymmetry there is a separate, pre-existing gap.\n */\nfunction normalizeBlock(\n block: Block,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): Block {\n const l10n = block.l10n;\n if (l10n) {\n let changed = false;\n const next = Object.fromEntries(\n Object.entries(l10n).map(([locale, layer]) => {\n const text = normalizeLocaleText(\n block.type,\n layer.text,\n mergeTags,\n syntax,\n );\n if (text === layer.text) return [locale, layer];\n changed = true;\n return [locale, { ...layer, text }];\n }),\n );\n if (changed) block = { ...block, l10n: next };\n }\n if (block.type === \"section\") {\n if (!Array.isArray(block.children)) return block;\n let changed = false;\n const children = block.children.map((column) => {\n if (!Array.isArray(column)) return column;\n let columnChanged = false;\n const next = column.map((child) => {\n const normalized = normalizeBlock(child, mergeTags, syntax);\n if (normalized !== child) columnChanged = true;\n return normalized;\n });\n if (!columnChanged) return column;\n changed = true;\n return next;\n });\n return changed ? ({ ...block, children } as SectionBlock) : block;\n }\n\n if (block.type === \"wrapper\") {\n if (!Array.isArray(block.children)) return block;\n let changed = false;\n const children = block.children.map((child) => {\n const normalized = normalizeBlock(child, mergeTags, syntax);\n if (normalized !== child) changed = true;\n return normalized;\n });\n return changed ? ({ ...block, children } as WrapperBlock) : block;\n }\n\n if (block.type !== \"title\" && block.type !== \"paragraph\") return block;\n if (typeof block.content !== \"string\") return block;\n\n const content = normalizeMergeTagsInHtml(block.content, mergeTags, syntax);\n if (content === block.content) return block;\n const before = sourceHash(block.content);\n const after = sourceHash(content);\n const restamped =\n block.l10n &&\n Object.fromEntries(\n Object.entries(block.l10n).map(([locale, layer]) => {\n const entry = layer.text?.content;\n return [\n locale,\n entry?.sourceHash === before\n ? {\n ...layer,\n text: {\n ...layer.text,\n content: { ...entry, sourceHash: after },\n },\n }\n : layer,\n ];\n }),\n );\n return { ...block, content, ...(restamped ? { l10n: restamped } : {}) };\n}\n\n/**\n * Normalize every rich-text field in a template. Returns the input reference\n * unchanged when nothing matched, so a template with no bare tokens costs no\n * allocation and keeps its object identity; otherwise returns a copy, leaving\n * the caller's content untouched.\n *\n * Shape is checked rather than trusted at every level. `TemplateContent` types\n * `blocks` as required and `SectionBlock.children` as a `Block[][]`, but this\n * runs at the SDK's entry points on an object the consumer hands us — a partial\n * or hand-rolled template must come back untouched, not turn a working `init()`\n * into a `TypeError`.\n */\nexport function normalizeMergeTagMarkup(\n content: TemplateContent,\n mergeTags: MergeTag[],\n syntax: SyntaxPreset,\n): TemplateContent {\n if (!content || !Array.isArray(content.blocks)) return content;\n\n let changed = false;\n const blocks = content.blocks.map((block) => {\n const normalized = normalizeBlock(block, mergeTags, syntax);\n if (normalized !== block) changed = true;\n return normalized;\n });\n\n return changed ? { ...content, blocks } : content;\n}\n\n/**\n * `normalizeMergeTagMarkup` bound to the editor's own config shape, so the hook\n * sites don't each resolve tags and syntax themselves.\n *\n * An absent `mergeTags` still normalizes, under the liquid default. That is not\n * an oversight: `MergeTagNode`'s input and paste rules are registered\n * unconditionally with the same default, so a consumer who configured nothing\n * already gets a node the instant a user types `{{x}}`. Loading the same text\n * and leaving it inert would be the inconsistency.\n *\n * It always returns a copy. Every content-in path runs through here, and the\n * editor edits the object it holds in place, so holding the caller's own one\n * leaks each edit into it, and one that another Vue made reactive or that a\n * store froze hides edits from the editor's bundled Vue or throws on the first.\n */\nexport function normalizeContentForConfig(\n content: TemplateContent,\n mergeTags: MergeTagsConfig | undefined,\n): TemplateContent {\n return normalizeMergeTagMarkup(\n copyIncomingContent(content),\n mergeTags?.tags ?? [],\n resolveSyntax(mergeTags?.syntax),\n );\n}\n\n/** {@link normalizeContentForConfig} for a single block. */\nexport function normalizeBlockForConfig(\n block: Block,\n mergeTags: MergeTagsConfig | undefined,\n): Block {\n return normalizeBlock(\n block,\n mergeTags?.tags ?? [],\n resolveSyntax(mergeTags?.syntax),\n );\n}\n\n/**\n * A non-object passes through: `normalizeMergeTagMarkup` already hands back\n * whatever is not shaped like content, and `safeClone(undefined)` would throw.\n */\nfunction copyIncomingContent(content: TemplateContent): TemplateContent {\n return typeof content === \"object\" && content !== null\n ? safeClone(content)\n : content;\n}\n\n/**\n * Wrap a `TemplatesProvider` so content arriving from the store is normalized\n * before the editor ever sees it.\n *\n * Only `load` is wrapped. `save` sends content *out*, and what it sends is\n * already-normalized editor state; rewriting it here would change what the\n * store keeps for no benefit. `create` likewise carries content outward, and\n * the template it returns supplies identity and timestamps rather than the\n * content the editor goes on to edit.\n *\n * Wrapping the provider — rather than normalizing after `load()` resolves —\n * is what keeps Q4 true: core assigns already-normalized content to its state\n * and observes no mutation, so there is no dirty flag to suppress and no\n * autosave tick to swallow.\n */\n/**\n * The slice of the editor a content-restoring feature consumes. Structural on\n * purpose: it matches `useVersionHistoryFeature`'s own `VersionHistoryEditor`\n * without importing it, so this util keeps no dependency on a composable.\n */\ninterface ContentWritingEditor {\n state: {\n readonly template?: { id: string } | null;\n readonly isDirty: boolean;\n };\n content: Ref<TemplateContent>;\n setContent: (content: TemplateContent, markDirty?: boolean) => void;\n}\n\n/**\n * Wrap an editor so content written through `setContent` is normalized first.\n *\n * This is how version history is covered. Its content reaches the canvas by\n * three routes — `version.content` off a hydrated list, a `fetched` cache, and\n * `provider.get()` — so wrapping the *provider*, the way the `templates` path\n * does, would miss two of them. `setContent` is the one chokepoint they share.\n *\n * A version is not guaranteed to hold normalized content just because a save\n * produced it: a store carries whatever was written to it, and a backend may\n * version a template it imported rather than one the editor round-tripped.\n * Previewing such a version without this would put bare tokens back on a canvas\n * where every other tag is a chip.\n *\n * `markDirty` is forwarded untouched: every version-history write passes\n * `false`, and swallowing that would turn opening a preview into an unsaved\n * change. `setContent` is resolved per call rather than captured, so a\n * wrapper installed on the editor later still sees every write.\n */\nexport function withNormalizedContentWrites<T extends ContentWritingEditor>(\n editor: T,\n mergeTags: MergeTagsConfig | undefined,\n): ContentWritingEditor {\n return {\n get state() {\n return editor.state;\n },\n get content() {\n return editor.content;\n },\n setContent: (content: TemplateContent, markDirty?: boolean) =>\n editor.setContent(\n normalizeContentForConfig(content, mergeTags),\n markDirty,\n ),\n };\n}\n\nexport function withNormalizedTemplateLoads(\n provider: TemplatesProvider,\n mergeTags: MergeTagsConfig | undefined,\n): TemplatesProvider {\n return {\n ...provider,\n async load(id: string) {\n const template = await provider.load(id);\n return {\n ...template,\n content: normalizeContentForConfig(template.content, mergeTags),\n };\n },\n };\n}\n\n/**\n * The type of the block `id` names — at the top level, in a section's columns\n * or inside a wrapper — or `undefined` when no block has that id.\n */\nfunction blockTypeOf(blocks: unknown, id: string): string | undefined {\n if (!Array.isArray(blocks)) return undefined;\n for (const block of blocks as Block[]) {\n if (!block || typeof block !== \"object\") continue;\n if (block.id === id) return block.type;\n const children = (block as { children?: unknown }).children;\n if (block.type === \"section\" && Array.isArray(children)) {\n for (const column of children) {\n const found = blockTypeOf(column, id);\n if (found) return found;\n }\n } else if (block.type === \"wrapper\") {\n const found = blockTypeOf(children, id);\n if (found) return found;\n }\n }\n return undefined;\n}\n\n/** Every block id in `block`, a section's or a wrapper's children included, with its type. */\nfunction collectBlockTypes(block: Block, into: Map<string, string>): void {\n if (typeof block.id === \"string\") into.set(block.id, block.type);\n const children = (block as { children?: unknown }).children;\n if (!Array.isArray(children)) return;\n const nested =\n block.type === \"section\" ? (children as unknown[]).flat() : children;\n for (const child of nested) {\n if (child && typeof child === \"object\") {\n collectBlockTypes(child as Block, into);\n }\n }\n}\n\n/**\n * Normalize the merge tags in a batch another session made, before the editor\n * applies it — the collaboration counterpart of {@link withNormalizedTemplateLoads}.\n * An agent writes `{{first_name}}` as text and a headless write stores it bare;\n * both arrive as operations, and normalizing them on arrival turns each token\n * into a tag at once. Nothing is sent back for it: the canvas and the\n * controller's copy of the backend's content change together.\n *\n * The rich-text fields only, as for loads: an `addBlock`'s block (a section's\n * children included), an `updateBlock`'s `set.content` when the block it names\n * is a title or a paragraph, its `expect.content`, and a deletion’s `expect.block` — found in `content`, or among the blocks the batch\n * itself added — and a `setContent`'s content. Returns `ops` itself when\n * nothing matched, and never changes it.\n */\nexport function normalizeRemoteOperations(\n ops: readonly Operation[],\n content: TemplateContent,\n mergeTags: MergeTagsConfig | undefined,\n): Operation[] {\n const tags = mergeTags?.tags ?? [];\n const syntax = resolveSyntax(mergeTags?.syntax);\n const added = new Map<string, string>();\n // Markup-only normalization also supports partial input and layout wrappers.\n // Locale hashes require engine-valid, evolving simulation states.\n const needsLocaleState = ops.some((op) => op.op === \"updateBlockLocale\");\n let original = safeClone(content);\n let normalizedState = safeClone(content);\n const advance = (\n state: TemplateContent,\n op: Operation,\n index: number,\n ): TemplateContent => {\n try {\n if (!(\"expect\" in op)) return applyOperations(state, [op]);\n // The backend already checked guards against its raw representation.\n const { expect: _expect, ...unguarded } = op;\n return applyOperations(state, [unguarded as Operation]);\n } catch (error) {\n if (!(error instanceof OperationError)) throw error;\n throw new OperationError(error.code, index, error.message, error.blockId);\n }\n };\n const blockIn = (state: TemplateContent, id: string): Block | undefined => {\n const find = (blocks: unknown): Block | undefined => {\n if (!Array.isArray(blocks)) return undefined;\n for (const block of blocks) {\n if (!block || typeof block !== \"object\") continue;\n if (block.id === id) return block;\n const children = block.children;\n const found = find(\n block.type === \"section\" && Array.isArray(children)\n ? children.flat()\n : children,\n );\n if (found) return found;\n }\n };\n return find(state?.blocks);\n };\n const restamp = <T extends LocalizedText | null>(\n entries: Record<string, T> | undefined,\n before: Block | undefined,\n after: Block | undefined,\n locale?: string,\n ): Record<string, T> | undefined => {\n if (!entries) return entries;\n let result = entries;\n for (const [path, entry] of Object.entries(entries)) {\n if (!entry) continue;\n const oldEntry = locale\n ? before?.l10n?.[locale]?.text?.[path]\n : undefined;\n const newEntry = locale ? after?.l10n?.[locale]?.text?.[path] : undefined;\n const oldBase = readPath(before, path);\n const newBase = readPath(after, path);\n const hash =\n oldEntry && newEntry && deepEqual(entry, oldEntry)\n ? newEntry.sourceHash\n : typeof oldBase === \"string\" &&\n typeof newBase === \"string\" &&\n entry.sourceHash === sourceHash(oldBase)\n ? sourceHash(newBase)\n : entry.sourceHash;\n if (hash !== entry.sourceHash)\n result = { ...result, [path]: { ...entry, sourceHash: hash } };\n }\n return result;\n };\n let changed = false;\n\n const normalizeOne = (op: Operation): Operation => {\n if (op.op === \"addBlock\") {\n if (!op.block || typeof op.block !== \"object\") return op;\n collectBlockTypes(op.block, added);\n const block = normalizeBlock(op.block, tags, syntax);\n if (block === op.block) return op;\n changed = true;\n return { ...op, block };\n }\n if (op.op === \"deleteBlock\" && op.expect?.block) {\n const block = normalizeBlock(op.expect.block, tags, syntax);\n if (block === op.expect.block) return op;\n changed = true;\n return { ...op, expect: { ...op.expect, block } };\n }\n if (op.op === \"updateBlockLocale\") {\n const type =\n added.get(op.blockId) ?? blockTypeOf(original?.blocks, op.blockId);\n const before = blockIn(original, op.blockId);\n const after = blockIn(normalizedState, op.blockId);\n const text = normalizeLocaleText(\n type,\n restamp(op.text, before, after),\n tags,\n syntax,\n );\n const expectText = normalizeLocaleText(\n type,\n restamp(op.expect?.text, before, after, op.locale),\n tags,\n syntax,\n );\n const expect =\n op.expect && expectText !== op.expect.text\n ? { ...op.expect, text: expectText }\n : op.expect;\n if (text === op.text && expect === op.expect) return op;\n changed = true;\n return {\n ...op,\n ...(text ? { text } : {}),\n ...(expect ? { expect } : {}),\n };\n }\n if (op.op === \"updateBlock\") {\n const type =\n added.get(op.blockId) ?? blockTypeOf(original?.blocks, op.blockId);\n if (type !== \"title\" && type !== \"paragraph\") return op;\n const normalizeField = (fields: Record<string, unknown> | undefined) => {\n if (typeof fields?.content !== \"string\") return fields;\n const normalized = normalizeMergeTagsInHtml(\n fields.content,\n tags,\n syntax,\n );\n return normalized === fields.content\n ? fields\n : { ...fields, content: normalized };\n };\n const set = normalizeField(op.set);\n const expect = normalizeField(op.expect);\n if (set === op.set && expect === op.expect) return op;\n changed = true;\n return { ...op, ...(set ? { set } : {}), ...(expect ? { expect } : {}) };\n }\n if (op.op === \"setContent\") {\n added.clear();\n const normalized = normalizeMergeTagMarkup(op.content, tags, syntax);\n if (normalized === op.content) return op;\n changed = true;\n return { ...op, content: normalized };\n }\n return op;\n };\n const next = ops.map((op, index) => {\n const normalized = normalizeOne(op);\n if (needsLocaleState) {\n // Fail before returning any batch if either state cannot advance. The\n // collaboration caller reports the error and applies its existing fallback.\n const nextOriginal = advance(original, op, index);\n const nextNormalized = advance(normalizedState, normalized, index);\n original = nextOriginal;\n normalizedState = nextNormalized;\n } else if (op.op === \"setContent\") {\n // Keep type lookup current without imposing engine validation on the\n // existing markup-only path. Added blocks are tracked in `added`.\n original = op.content;\n }\n return normalized;\n });\n\n return changed ? next : (ops as Operation[]);\n}\n"],"mappings":";;AAgFA,SAASY,EAAY,GAAyB;CAC5C,IAAMC,IAAQC,EAAQ,MAAM,SAAS,GAAG,IACpCA,EAAQ,QACR,GAAGA,EAAQ,MAAM;CACrB,OAAO,IAAI,OAAOA,EAAQ,QAAQD,CAAK;AACzC;AAEA,SAAgBE,EACd,GACA,GACA,GACU;CACV,IAAMC,IAAiB,CAAC,GAClBC,IAAU,OAAO,OAAOhB,CAAc,CAAC,CAAC,SAC5CiB,CACF,GACMC,IAAsB,CAAC,GACzBC,IAAa,GAEXC,KACJ,GACA,GACA,GACA,MACS;EACT,AAAIC,MAAS,YAAS,IAAa;EACnC,IAAMC,IAAQN,IAAU,OAAOL,EAAYE,CAAO,GAC5CU,IAAUP,IAAUP,EAAkBe,GAAMP,GAAQI,CAAI,IAAI,MAC9DI,IAAQH,GAAO,KAAKE,CAAI,KAAK,MAC7BE,IAAQ;EACZ,OAAOV,IAAUU,IAAQH,EAAS,SAASE,MAAU,OAAM;GACzD,IAAME,IAAQX,IAAUO,EAASG,EAAM,CAAC,QAAQD,EAAO,OACjDG,IAAQZ,IAAUO,EAASG,EAAM,CAAC,QAAQD,EAAO,IACjDI,IAAMF,IAAQC,EAAM;GAC1B,IAAIA,EAAM,WAAW,GACnB,EAAO;QACF;IACL,IAAIP,MAAS,SACX,OAAOH,EAAUC,EAAW,EAAE,OAAOQ,IAAO;IAE9C,IAAMG,IACJT,MAAS,UAAUH,EAAUC,KAAcJ,EAAKA,EAAK,SAAS;IAChE,IAAI,CAACe,KAASH,KAASG,EAAM,OAAOD,KAAOC,EAAM,OAAO;KACtD,IAAMC,IAAM;MACV;MACA;MACA;MACA;MACA,OAAOC,EAAMJ,CAAK;KACpB;KAEA,AADAb,EAAK,KAAKgB,C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ADA,IAAW0F,GACX,IAAkBC;EACpB,OAAO,AAAI3B,EAAG,OAAO,iBAGnB,IAAWA,EAAG;EAEhB,OAAO5B;CACT,CAAC;CAED,OAAOP,IAAUC,IAAQiC;AAC3B"}
|
package/dist/cdn/chunks/{preRenderCustomBlocks-C9oavydG.js → preRenderCustomBlocks-Cj0XYwuh.js}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { At as e, Ct as t, _t as n } from "./src-v47QHNmB.js";
|
|
2
2
|
// src/utils/preRenderCustomBlocks.ts
|
|
3
3
|
async function r(r, i) {
|
|
4
4
|
let a = async (r) => {
|
|
5
|
-
if (
|
|
5
|
+
if (n(r)) {
|
|
6
6
|
let e = r;
|
|
7
7
|
try {
|
|
8
8
|
e.renderedHtml = await i.renderCustomBlock(e);
|
|
@@ -12,11 +12,11 @@ async function r(r, i) {
|
|
|
12
12
|
let t = i.getCustomBlockStylesheet(e.customType);
|
|
13
13
|
t?.trim() ? e.renderedStylesheet = t : delete e.renderedStylesheet;
|
|
14
14
|
}
|
|
15
|
-
if (
|
|
15
|
+
if (t(r)) for (let e of r.children) for (let t of e) await a(t);
|
|
16
16
|
else if (e(r)) for (let e of r.children) await a(e);
|
|
17
17
|
};
|
|
18
18
|
for (let e of r.blocks) await a(e);
|
|
19
19
|
}
|
|
20
20
|
export { r as t };
|
|
21
21
|
|
|
22
|
-
//# sourceMappingURL=preRenderCustomBlocks-
|
|
22
|
+
//# sourceMappingURL=preRenderCustomBlocks-Cj0XYwuh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preRenderCustomBlocks-
|
|
1
|
+
{"version":3,"file":"preRenderCustomBlocks-Cj0XYwuh.js","names":["isWrapper","isSection","isCustomBlock","preRenderCustomBlocks","renderBlock","block","customBlock","registry","stylesheet","column","child","content"],"sources":["../../../src/utils/preRenderCustomBlocks.ts"],"sourcesContent":["import type { Block, CustomBlock, TemplateContent } from \"@templatical/types\";\nimport { isCustomBlock, isSection, isWrapper } from \"@templatical/types\";\n\n/**\n * The only things this needs from the block registry. Named as a slice rather\n * than taking `UseBlockRegistryReturn` so the render-payload builder can supply\n * the editor instance's own methods without reaching for the registry.\n */\nexport interface CustomBlockResolver {\n renderCustomBlock: (block: CustomBlock) => Promise<string>;\n getCustomBlockStylesheet: (customType: string) => string | undefined;\n}\n\n/**\n * Renders every custom block in the content tree to its HTML representation\n * and stores the result on `block.renderedHtml`, with the definition's\n * stylesheet on `block.renderedStylesheet`.\n *\n * **A contract obligation of every render, not a save-path detail.** A renderer\n * handed a custom block with neither a resolver nor `renderedHtml` omits it from\n * the output silently, and a backend has no way to resolve one: the HTML comes\n * from the consumer's liquid template plus the block's field values, and the\n * definition is registered in the browser. So this runs before a\n * `RenderProvider` sees the content, and before Cloud persists it.\n *\n * Failures per-block are swallowed (and replaced with a comment placeholder)\n * so one broken block doesn't block the save of the rest.\n */\nexport async function preRenderCustomBlocks(\n content: TemplateContent,\n registry: CustomBlockResolver,\n): Promise<void> {\n const renderBlock = async (block: Block): Promise<void> => {\n if (isCustomBlock(block)) {\n const customBlock = block as CustomBlock;\n try {\n customBlock.renderedHtml =\n await registry.renderCustomBlock(customBlock);\n } catch {\n customBlock.renderedHtml = `<!-- Custom block render error: ${customBlock.customType} -->`;\n }\n // Removed when the definition has none, so a copy written before its\n // stylesheet was deleted doesn't outlive it.\n const stylesheet = registry.getCustomBlockStylesheet(\n customBlock.customType,\n );\n if (stylesheet?.trim()) customBlock.renderedStylesheet = stylesheet;\n else delete customBlock.renderedStylesheet;\n }\n\n if (isSection(block)) {\n for (const column of block.children) {\n for (const child of column) {\n await renderBlock(child);\n }\n }\n } else if (isWrapper(block)) {\n for (const child of block.children) {\n await renderBlock(child);\n }\n }\n };\n\n for (const block of content.blocks) {\n await renderBlock(block);\n }\n}\n"],"mappings":";;AA4BA,eAAsBG,EACpB,GACA,GACe;CACf,IAAMC,IAAc,OAAO,MAAgC;EACzD,IAAIF,EAAcG,CAAK,GAAG;GACxB,IAAMC,IAAcD;GACpB,IAAI;IACF,EAAY,eACV,MAAME,EAAS,kBAAkBD,CAAW;GAChD,QAAQ;IACN,EAAY,eAAe,mCAAmCA,EAAY,WAAW;GACvF;GAGA,IAAME,IAAaD,EAAS,yBAC1BD,EAAY,UACd;GACA,AAAIE,GAAY,KAAK,IAAG,EAAY,qBAAqBA,IACpD,OAAOF,EAAY;EAC1B;EAEA,IAAIL,EAAUI,CAAK,GACjB,KAAK,IAAMI,KAAUJ,EAAM,UACzB,KAAK,IAAMK,KAASD,GAClB,MAAML,EAAYM,CAAK;OAGtB,IAAIV,EAAUK,CAAK,GACxB,KAAK,IAAMK,KAASL,EAAM,UACxB,MAAMD,EAAYM,CAAK;CAG7B;CAEA,KAAK,IAAML,KAASM,EAAQ,QAC1B,MAAMP,EAAYC,CAAK;AAE3B"}
|
|
@@ -303,7 +303,11 @@ var e = {
|
|
|
303
303
|
dropToUpload: "Solte a imagem para enviar",
|
|
304
304
|
uploading: "Enviando…",
|
|
305
305
|
decorative: "Imagem decorativa",
|
|
306
|
-
decorativeHint: "Oculta para leitores de tela. Use apenas para espaçadores e elementos visuais."
|
|
306
|
+
decorativeHint: "Oculta para leitores de tela. Use apenas para espaçadores e elementos visuais.",
|
|
307
|
+
fluidOnMobile: "Largura total no celular",
|
|
308
|
+
fluidOnMobileAuto: "Automática",
|
|
309
|
+
fluidOnMobileAlways: "Sempre",
|
|
310
|
+
fluidOnMobileNever: "Nunca"
|
|
307
311
|
},
|
|
308
312
|
video: {
|
|
309
313
|
videoUrl: "URL do Vídeo",
|
|
@@ -336,6 +340,10 @@ var e = {
|
|
|
336
340
|
textColor: "Cor do Texto",
|
|
337
341
|
borderRadius: "Arredondamento das Bordas",
|
|
338
342
|
fontSize: "Tamanho da Fonte",
|
|
343
|
+
fontWeight: "Peso",
|
|
344
|
+
fontWeightRegular: "Comum",
|
|
345
|
+
fontWeightMedium: "Médio",
|
|
346
|
+
fontWeightBold: "Negrito",
|
|
339
347
|
width: "Largura",
|
|
340
348
|
widthAuto: "Ajustar ao conteúdo",
|
|
341
349
|
fullWidth: "Largura Total",
|
|
@@ -377,6 +385,7 @@ var e = {
|
|
|
377
385
|
twitter: "X (Twitter)",
|
|
378
386
|
instagram: "Instagram",
|
|
379
387
|
linkedin: "LinkedIn",
|
|
388
|
+
xing: "XING",
|
|
380
389
|
youtube: "YouTube",
|
|
381
390
|
tiktok: "TikTok",
|
|
382
391
|
pinterest: "Pinterest",
|
|
@@ -929,3 +938,5 @@ var e = {
|
|
|
929
938
|
}
|
|
930
939
|
};
|
|
931
940
|
export { e as default };
|
|
941
|
+
|
|
942
|
+
//# sourceMappingURL=pt-BR-D3VlIMDZ.js.map
|