@editora/plugins 1.0.10 → 1.0.12
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 +1 -1
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +80 -98
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +115 -128
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +208 -249
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +55 -68
- package/dist/blockquote.esm.js +1 -2
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +178 -245
- package/dist/capitalization.esm.js +1 -2
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +58 -82
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +439 -512
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +27 -33
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +82 -93
- package/dist/code.cjs.js +119 -42
- package/dist/code.esm.js +2560 -760
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +116 -158
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +371 -432
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +105 -159
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +328 -368
- package/dist/direction.esm.js +9 -18
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +240 -308
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +4 -5
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +73 -81
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +65 -77
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +54 -56
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +39 -47
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +37 -53
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +76 -117
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +70 -92
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +12 -24
- package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-CE_A4QSm.js +5 -0
- package/dist/index.es-DQ78mYYo.mjs +6665 -0
- package/dist/index.esm.js +125 -128
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +8 -9
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +11 -24
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +24 -30
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +20 -25
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +59 -61
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +139 -146
- package/dist/media-manager.cjs.js +31 -31
- package/dist/media-manager.esm.js +285 -300
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +238 -286
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +177 -216
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +33 -49
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +393 -463
- package/dist/plugins.css +1 -0
- package/dist/preview.esm.js +5 -10
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +17 -20
- package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
- package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
- package/dist/slash-commands.cjs.js +2 -2
- package/dist/slash-commands.esm.js +39 -75
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +280 -336
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +61 -69
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +97 -123
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +14 -19
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +191 -225
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +715 -196
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +21 -27
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +70 -87
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +100 -162
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +602 -678
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +128 -157
- package/package.json +1 -1
- package/dist/_commonjsHelpers-6763f629.js +0 -1
- package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
- package/dist/anchoredPopover-33f1358d.mjs +0 -109
- package/dist/anchoredPopover-8151d535.js +0 -1
- package/dist/documentManager-25b6203c.mjs +0 -9122
- package/dist/documentManager-b69e7054.js +0 -17
- package/dist/html2canvas.esm-09133e29.js +0 -22
- package/dist/index-656d224b.js +0 -231
- package/dist/index-6a8c48bb.js +0 -1
- package/dist/index-d027b7e2.mjs +0 -16859
- package/dist/index.es-730f2d98.mjs +0 -5775
- package/dist/index.es-dd40173b.js +0 -18
- package/dist/jspdf.es.min-90db2c97.js +0 -243
- package/dist/style.css +0 -1
- /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
package/dist/merge-tag.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const h = ".rte-content, .editora-content", Q = '[data-theme="dark"], .dark, .editora-theme-dark', ee = {
|
|
2
2
|
title: "Insert Merge Tag",
|
|
3
3
|
searchPlaceholder: "Search merge tags...",
|
|
4
4
|
emptyStateText: "No merge tags found",
|
|
@@ -6,7 +6,7 @@ const k = ".rte-content, .editora-content", ee = '[data-theme="dark"], .dark, .e
|
|
|
6
6
|
insertText: "Insert",
|
|
7
7
|
showPreview: !0
|
|
8
8
|
};
|
|
9
|
-
function
|
|
9
|
+
function te() {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
12
12
|
id: "USER",
|
|
@@ -46,41 +46,41 @@ function re() {
|
|
|
46
46
|
}
|
|
47
47
|
];
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function M(t, r) {
|
|
50
50
|
return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `CATEGORY_${r + 1}`;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function re(t, r) {
|
|
53
53
|
return (t.key || t.value || t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `tag_${r + 1}`;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function ne(t) {
|
|
56
56
|
const r = (() => {
|
|
57
|
-
if (Array.isArray(t
|
|
57
|
+
if (Array.isArray(t?.categories) && t.categories.length > 0)
|
|
58
58
|
return t.categories;
|
|
59
|
-
if (Array.isArray(t
|
|
59
|
+
if (Array.isArray(t?.tags) && t.tags.length > 0) {
|
|
60
60
|
const c = /* @__PURE__ */ new Map();
|
|
61
|
-
return t.tags.forEach((
|
|
62
|
-
const g = (
|
|
63
|
-
|
|
64
|
-
}), Array.from(c.entries()).map(([
|
|
65
|
-
id:
|
|
66
|
-
name:
|
|
61
|
+
return t.tags.forEach((d) => {
|
|
62
|
+
const g = (d.category || "Custom").trim() || "Custom", i = c.get(g);
|
|
63
|
+
i ? i.push(d) : c.set(g, [d]);
|
|
64
|
+
}), Array.from(c.entries()).map(([d, g], i) => ({
|
|
65
|
+
id: M(d, i),
|
|
66
|
+
name: d,
|
|
67
67
|
tags: g
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return te();
|
|
71
71
|
})(), e = {}, n = [];
|
|
72
|
-
if (r.forEach((c,
|
|
73
|
-
const g =
|
|
72
|
+
if (r.forEach((c, d) => {
|
|
73
|
+
const g = M(c.id || c.name, d);
|
|
74
74
|
n.push(g), e[g] = {
|
|
75
75
|
name: c.name,
|
|
76
|
-
tags: (Array.isArray(c.tags) ? c.tags : []).map((
|
|
77
|
-
const u =
|
|
76
|
+
tags: (Array.isArray(c.tags) ? c.tags : []).map((i, b) => {
|
|
77
|
+
const u = re(i, b), f = (i.category || c.name).trim() || c.name;
|
|
78
78
|
return {
|
|
79
|
-
...
|
|
79
|
+
...i,
|
|
80
80
|
key: u,
|
|
81
|
-
category:
|
|
81
|
+
category: f,
|
|
82
82
|
categoryKey: g,
|
|
83
|
-
searchIndex: `${
|
|
83
|
+
searchIndex: `${i.label} ${u} ${f} ${i.description ?? ""} ${i.value ?? ""}`.toLowerCase()
|
|
84
84
|
};
|
|
85
85
|
})
|
|
86
86
|
};
|
|
@@ -88,38 +88,33 @@ function ae(t) {
|
|
|
88
88
|
const c = "CUSTOM";
|
|
89
89
|
n.push(c), e[c] = { name: "Custom", tags: [] };
|
|
90
90
|
}
|
|
91
|
-
const a = t
|
|
91
|
+
const a = t?.defaultCategory ? M(t.defaultCategory, 0) : null, l = a && n.includes(a) ? a : n[0];
|
|
92
92
|
return {
|
|
93
93
|
categoriesByKey: e,
|
|
94
94
|
categoryKeys: n,
|
|
95
95
|
defaultCategory: l
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
const r = t
|
|
98
|
+
function ae(t) {
|
|
99
|
+
const r = t?.tokenTemplate;
|
|
100
100
|
return typeof r == "function" ? (e) => {
|
|
101
|
-
var a;
|
|
102
101
|
const n = r(e);
|
|
103
|
-
return typeof n == "string" && n.trim() ? n :
|
|
104
|
-
} : typeof r == "string" && r.trim() ? (e) => r.replace(/\{key\}/gi, e.key).replace(/\{label\}/gi, e.label).replace(/\{category\}/gi, e.category).replace(/\{value\}/gi, e.value ?? "") : (e) => {
|
|
105
|
-
var n;
|
|
106
|
-
return ((n = e.value) == null ? void 0 : n.trim()) || `{{ ${e.label} }}`;
|
|
107
|
-
};
|
|
102
|
+
return typeof n == "string" && n.trim() ? n : e.value?.trim() || `{{ ${e.label} }}`;
|
|
103
|
+
} : typeof r == "string" && r.trim() ? (e) => r.replace(/\{key\}/gi, e.key).replace(/\{label\}/gi, e.label).replace(/\{category\}/gi, e.category).replace(/\{value\}/gi, e.value ?? "") : (e) => e.value?.trim() || `{{ ${e.label} }}`;
|
|
108
104
|
}
|
|
109
|
-
function
|
|
105
|
+
function oe(t) {
|
|
110
106
|
return {
|
|
111
|
-
catalog:
|
|
107
|
+
catalog: ne(t),
|
|
112
108
|
dialog: {
|
|
113
|
-
...
|
|
114
|
-
...
|
|
109
|
+
...ee,
|
|
110
|
+
...t?.dialog || {}
|
|
115
111
|
},
|
|
116
|
-
formatToken:
|
|
112
|
+
formatToken: ae(t)
|
|
117
113
|
};
|
|
118
114
|
}
|
|
119
|
-
let K = !1,
|
|
120
|
-
function
|
|
121
|
-
if (r === t.innerHTML)
|
|
122
|
-
return;
|
|
115
|
+
let K = !1, P = !1, S = null, N = null, E = null, H = !1;
|
|
116
|
+
function J(t, r) {
|
|
117
|
+
if (r === t.innerHTML) return;
|
|
123
118
|
const e = window.execEditorCommand || window.executeEditorCommand;
|
|
124
119
|
if (typeof e == "function")
|
|
125
120
|
try {
|
|
@@ -127,9 +122,8 @@ function Y(t, r) {
|
|
|
127
122
|
} catch {
|
|
128
123
|
}
|
|
129
124
|
}
|
|
130
|
-
function
|
|
131
|
-
if (K || typeof document > "u")
|
|
132
|
-
return;
|
|
125
|
+
function R() {
|
|
126
|
+
if (K || typeof document > "u") return;
|
|
133
127
|
K = !0;
|
|
134
128
|
const t = document.createElement("style");
|
|
135
129
|
t.id = "merge-tag-plugin-styles", t.textContent = `
|
|
@@ -258,72 +252,61 @@ function I() {
|
|
|
258
252
|
}
|
|
259
253
|
`, document.head.appendChild(t);
|
|
260
254
|
}
|
|
261
|
-
function
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
e && (
|
|
255
|
+
function j() {
|
|
256
|
+
P || typeof document > "u" || (P = !0, document.addEventListener("focusin", (t) => {
|
|
257
|
+
const e = t.target?.closest(h);
|
|
258
|
+
e && (S = e);
|
|
265
259
|
}), document.addEventListener("selectionchange", () => {
|
|
266
|
-
const t =
|
|
267
|
-
t && (
|
|
260
|
+
const t = Y();
|
|
261
|
+
t && (S = t);
|
|
268
262
|
}));
|
|
269
263
|
}
|
|
270
|
-
function
|
|
264
|
+
function Y() {
|
|
271
265
|
const t = window.getSelection();
|
|
272
|
-
if (!t || t.rangeCount === 0)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return (n == null ? void 0 : n.closest(k)) || null;
|
|
266
|
+
if (!t || t.rangeCount === 0) return null;
|
|
267
|
+
const e = t.getRangeAt(0).startContainer;
|
|
268
|
+
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(h) || null;
|
|
276
269
|
}
|
|
277
|
-
function
|
|
278
|
-
const t =
|
|
279
|
-
if (t)
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return e || (h != null && h.isConnected ? h : document.querySelector(k));
|
|
270
|
+
function X() {
|
|
271
|
+
const t = Y();
|
|
272
|
+
if (t) return t;
|
|
273
|
+
const e = document.activeElement?.closest(h);
|
|
274
|
+
return e || (S?.isConnected ? S : document.querySelector(h));
|
|
283
275
|
}
|
|
284
|
-
function
|
|
276
|
+
function le(t) {
|
|
285
277
|
const r = t.parentNode;
|
|
286
|
-
if (!r)
|
|
287
|
-
return;
|
|
278
|
+
if (!r) return;
|
|
288
279
|
const e = window.getSelection();
|
|
289
|
-
if (!e)
|
|
290
|
-
return;
|
|
280
|
+
if (!e) return;
|
|
291
281
|
const n = document.createRange(), l = Array.from(r.childNodes).indexOf(t);
|
|
292
282
|
l < 0 || (n.setStart(r, l), n.setEnd(r, l + 1), e.removeAllRanges(), e.addRange(n));
|
|
293
283
|
}
|
|
294
|
-
function
|
|
295
|
-
|
|
296
|
-
t instanceof Text && t.data.length !== 0 && (r ? (t.data.startsWith(" ") || t.data.startsWith(" ")) && t.deleteData(0, 1) : (t.data.endsWith(" ") || t.data.endsWith(" ")) && t.deleteData(t.data.length - 1, 1), t.data.length === 0 && ((e = t.parentNode) == null || e.removeChild(t)));
|
|
284
|
+
function q(t, r) {
|
|
285
|
+
t instanceof Text && t.data.length !== 0 && (r ? (t.data.startsWith(" ") || t.data.startsWith(" ")) && t.deleteData(0, 1) : (t.data.endsWith(" ") || t.data.endsWith(" ")) && t.deleteData(t.data.length - 1, 1), t.data.length === 0 && t.parentNode?.removeChild(t));
|
|
297
286
|
}
|
|
298
|
-
function
|
|
287
|
+
function W(t, r) {
|
|
299
288
|
const e = window.getSelection();
|
|
300
|
-
if (!e)
|
|
301
|
-
return;
|
|
289
|
+
if (!e) return;
|
|
302
290
|
const n = document.createRange(), a = Math.max(0, Math.min(r, t.childNodes.length));
|
|
303
291
|
n.setStart(t, a), n.collapse(!0), e.removeAllRanges(), e.addRange(n);
|
|
304
292
|
}
|
|
305
|
-
function
|
|
306
|
-
const e = t.closest(
|
|
307
|
-
if (!a)
|
|
308
|
-
return !1;
|
|
293
|
+
function ce(t, r) {
|
|
294
|
+
const e = t.closest(h), n = e?.innerHTML ?? "", a = t.parentNode;
|
|
295
|
+
if (!a) return !1;
|
|
309
296
|
const c = Array.from(a.childNodes).indexOf(t);
|
|
310
|
-
if (c < 0)
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return a.removeChild(t), r === "Backspace" ? (W(g, !0), V(a, c)) : (W(i, !1), V(a, c)), e && (Y(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
|
|
297
|
+
if (c < 0) return !1;
|
|
298
|
+
const d = t.previousSibling, g = t.nextSibling;
|
|
299
|
+
return a.removeChild(t), r === "Backspace" ? (q(g, !0), W(a, c)) : (q(d, !1), W(a, c)), e && (J(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
|
|
314
300
|
}
|
|
315
|
-
function
|
|
316
|
-
if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1)
|
|
317
|
-
return null;
|
|
301
|
+
function ie(t) {
|
|
302
|
+
if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1) return null;
|
|
318
303
|
const r = t.startContainer;
|
|
319
|
-
if (!(r instanceof Element || r instanceof DocumentFragment))
|
|
320
|
-
return null;
|
|
304
|
+
if (!(r instanceof Element || r instanceof DocumentFragment)) return null;
|
|
321
305
|
const e = r.childNodes[t.startOffset];
|
|
322
306
|
return e instanceof HTMLElement && e.classList.contains("rte-merge-tag") ? e : null;
|
|
323
307
|
}
|
|
324
|
-
function
|
|
325
|
-
if (!t.collapsed)
|
|
326
|
-
return null;
|
|
308
|
+
function se(t, r) {
|
|
309
|
+
if (!t.collapsed) return null;
|
|
327
310
|
const { startContainer: e, startOffset: n } = t, a = (l) => l instanceof HTMLElement && l.classList.contains("rte-merge-tag") ? l : null;
|
|
328
311
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
329
312
|
const l = e;
|
|
@@ -335,121 +318,112 @@ function de(t, r) {
|
|
|
335
318
|
}
|
|
336
319
|
return null;
|
|
337
320
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
if (!e)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), ce(e));
|
|
321
|
+
function V() {
|
|
322
|
+
H || typeof document > "u" || (H = !0, document.addEventListener("click", (t) => {
|
|
323
|
+
const e = t.target?.closest(".rte-merge-tag");
|
|
324
|
+
if (!e) return;
|
|
325
|
+
const n = e.closest(h);
|
|
326
|
+
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), le(e));
|
|
345
327
|
}), document.addEventListener("keydown", (t) => {
|
|
346
|
-
if (t.key !== "Backspace" && t.key !== "Delete")
|
|
347
|
-
return;
|
|
328
|
+
if (t.key !== "Backspace" && t.key !== "Delete") return;
|
|
348
329
|
const r = window.getSelection();
|
|
349
|
-
if (!r || r.rangeCount === 0)
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
let a = se(e);
|
|
355
|
-
a || (a = de(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), ie(a, t.key));
|
|
330
|
+
if (!r || r.rangeCount === 0) return;
|
|
331
|
+
const e = r.getRangeAt(0), n = X();
|
|
332
|
+
if (!n || !n.contains(e.commonAncestorContainer)) return;
|
|
333
|
+
let a = ie(e);
|
|
334
|
+
a || (a = se(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), ce(a, t.key));
|
|
356
335
|
}));
|
|
357
336
|
}
|
|
358
|
-
function
|
|
359
|
-
return t ? !!t.closest(
|
|
337
|
+
function de(t) {
|
|
338
|
+
return t ? !!t.closest(Q) : !1;
|
|
360
339
|
}
|
|
361
|
-
function
|
|
362
|
-
|
|
340
|
+
function ge() {
|
|
341
|
+
E && (E(), E = null), N = null;
|
|
363
342
|
}
|
|
364
|
-
function
|
|
343
|
+
function G(t) {
|
|
365
344
|
const r = document.createRange();
|
|
366
345
|
return r.selectNodeContents(t), r.collapse(!1), r;
|
|
367
346
|
}
|
|
368
|
-
function
|
|
369
|
-
const e = window.getSelection(), n = r ? r.cloneRange() :
|
|
347
|
+
function me(t, r) {
|
|
348
|
+
const e = window.getSelection(), n = r ? r.cloneRange() : G(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : G(t);
|
|
370
349
|
return e && (e.removeAllRanges(), e.addRange(l)), l;
|
|
371
350
|
}
|
|
372
|
-
function
|
|
351
|
+
function ue(t, r) {
|
|
373
352
|
const e = document.createElement("span");
|
|
374
353
|
e.className = "rte-merge-tag", e.setAttribute("contenteditable", "false"), e.setAttribute("data-key", t.key), e.setAttribute("data-category", t.category), e.setAttribute("data-label", t.label), t.value && e.setAttribute("data-value", t.value);
|
|
375
354
|
const n = r(t);
|
|
376
355
|
return e.setAttribute("data-token", n), e.setAttribute("aria-label", `Merge tag: ${t.label}`), e.textContent = n, e;
|
|
377
356
|
}
|
|
378
|
-
function
|
|
357
|
+
function fe(t, r, e, n) {
|
|
379
358
|
const a = window.getSelection();
|
|
380
|
-
if (!a)
|
|
381
|
-
return !1;
|
|
359
|
+
if (!a) return !1;
|
|
382
360
|
const l = t.innerHTML;
|
|
383
361
|
t.focus({ preventScroll: !0 });
|
|
384
|
-
const c =
|
|
362
|
+
const c = me(t, r), g = (c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement)?.closest(".rte-merge-tag");
|
|
385
363
|
g && t.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
|
|
386
364
|
try {
|
|
387
365
|
c.deleteContents();
|
|
388
|
-
const
|
|
389
|
-
u.appendChild(
|
|
390
|
-
const
|
|
391
|
-
return
|
|
392
|
-
} catch (
|
|
393
|
-
return console.error("Failed to insert merge tag:",
|
|
366
|
+
const i = ue(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
|
|
367
|
+
u.appendChild(i), u.appendChild(b), c.insertNode(u);
|
|
368
|
+
const f = document.createRange();
|
|
369
|
+
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f), J(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
370
|
+
} catch (i) {
|
|
371
|
+
return console.error("Failed to insert merge tag:", i), !1;
|
|
394
372
|
}
|
|
395
373
|
}
|
|
396
|
-
function
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return a ? n.filter((c) => c.searchIndex.includes(a)) : n;
|
|
374
|
+
function pe(t, r, e) {
|
|
375
|
+
const n = t.catalog.categoriesByKey[r]?.tags || [], a = e.trim().toLowerCase();
|
|
376
|
+
return a ? n.filter((l) => l.searchIndex.includes(a)) : n;
|
|
400
377
|
}
|
|
401
|
-
function
|
|
402
|
-
|
|
403
|
-
me(), I();
|
|
378
|
+
function be(t, r) {
|
|
379
|
+
ge(), R();
|
|
404
380
|
const e = {
|
|
405
381
|
category: r.catalog.defaultCategory,
|
|
406
382
|
searchTerm: "",
|
|
407
|
-
filteredTags:
|
|
383
|
+
filteredTags: r.catalog.categoriesByKey[r.catalog.defaultCategory]?.tags || [],
|
|
408
384
|
selectedIndex: 0,
|
|
409
385
|
savedRange: (() => {
|
|
410
386
|
const o = window.getSelection();
|
|
411
|
-
if (!o || o.rangeCount === 0)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return t.contains(d.commonAncestorContainer) ? d.cloneRange() : null;
|
|
387
|
+
if (!o || o.rangeCount === 0) return null;
|
|
388
|
+
const s = o.getRangeAt(0);
|
|
389
|
+
return t.contains(s.commonAncestorContainer) ? s.cloneRange() : null;
|
|
415
390
|
})(),
|
|
416
391
|
searchRaf: null
|
|
417
392
|
}, n = document.createElement("div");
|
|
418
|
-
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"),
|
|
393
|
+
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), de(t) && n.classList.add("rte-ui-theme-dark");
|
|
419
394
|
const a = document.createElement("div");
|
|
420
395
|
a.className = "rte-merge-tag-dialog";
|
|
421
396
|
const l = document.createElement("div");
|
|
422
397
|
l.className = "rte-merge-tag-header";
|
|
423
398
|
const c = document.createElement("h2");
|
|
424
399
|
c.style.margin = "0", c.style.fontSize = "18px", c.style.fontWeight = "700", c.textContent = r.dialog.title;
|
|
425
|
-
const
|
|
426
|
-
|
|
400
|
+
const d = document.createElement("button");
|
|
401
|
+
d.className = "rte-merge-tag-close", d.setAttribute("aria-label", "Close"), d.style.background = "none", d.style.border = "none", d.style.color = "inherit", d.style.cursor = "pointer", d.style.fontSize = "20px", d.textContent = "✕", l.appendChild(c), l.appendChild(d);
|
|
427
402
|
const g = document.createElement("div");
|
|
428
403
|
g.className = "rte-merge-tag-body";
|
|
429
|
-
const
|
|
430
|
-
|
|
404
|
+
const i = document.createElement("input");
|
|
405
|
+
i.type = "text", i.className = "rte-merge-tag-input", i.placeholder = r.dialog.searchPlaceholder, i.setAttribute("aria-label", "Search merge tags");
|
|
431
406
|
const b = document.createElement("div");
|
|
432
407
|
b.className = "rte-merge-tag-tabs", r.catalog.categoryKeys.forEach((o) => {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
d.type = "button", d.className = "rte-merge-tag-tab", d.setAttribute("data-category", o), d.textContent = ((f = r.catalog.categoriesByKey[o]) == null ? void 0 : f.name) || o, b.appendChild(d);
|
|
408
|
+
const s = document.createElement("button");
|
|
409
|
+
s.type = "button", s.className = "rte-merge-tag-tab", s.setAttribute("data-category", o), s.textContent = r.catalog.categoriesByKey[o]?.name || o, b.appendChild(s);
|
|
436
410
|
});
|
|
437
411
|
const u = document.createElement("div");
|
|
438
412
|
u.className = "rte-merge-tag-list";
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
|
|
413
|
+
const f = document.createElement("div");
|
|
414
|
+
f.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(b), g.appendChild(u), g.appendChild(f);
|
|
415
|
+
const w = document.createElement("div");
|
|
416
|
+
w.className = "rte-merge-tag-footer";
|
|
443
417
|
const v = document.createElement("button");
|
|
444
418
|
v.type = "button", v.className = "rte-merge-tag-btn-secondary", v.textContent = r.dialog.cancelText;
|
|
445
419
|
const y = document.createElement("button");
|
|
446
|
-
y.type = "button", y.className = "rte-merge-tag-btn-primary", y.textContent = r.dialog.insertText,
|
|
420
|
+
y.type = "button", y.className = "rte-merge-tag-btn-primary", y.textContent = r.dialog.insertText, w.appendChild(v), w.appendChild(y), a.appendChild(l), a.appendChild(g), a.appendChild(w), n.appendChild(a), document.body.appendChild(n), N = n;
|
|
447
421
|
const _ = () => {
|
|
448
|
-
b.querySelectorAll(".rte-merge-tag-tab").forEach((
|
|
449
|
-
const
|
|
450
|
-
|
|
422
|
+
b.querySelectorAll(".rte-merge-tag-tab").forEach((s) => {
|
|
423
|
+
const p = s.dataset.category === e.category;
|
|
424
|
+
s.classList.toggle("active", p);
|
|
451
425
|
});
|
|
452
|
-
},
|
|
426
|
+
}, L = () => {
|
|
453
427
|
if (e.filteredTags.length === 0) {
|
|
454
428
|
e.selectedIndex = -1;
|
|
455
429
|
return;
|
|
@@ -457,106 +431,93 @@ function ye(t, r) {
|
|
|
457
431
|
e.selectedIndex < 0 && (e.selectedIndex = 0), e.selectedIndex >= e.filteredTags.length && (e.selectedIndex = e.filteredTags.length - 1);
|
|
458
432
|
}, O = () => {
|
|
459
433
|
if (!r.dialog.showPreview) {
|
|
460
|
-
|
|
434
|
+
f.style.display = "none", y.disabled = e.filteredTags.length === 0;
|
|
461
435
|
return;
|
|
462
436
|
}
|
|
463
|
-
|
|
437
|
+
L();
|
|
464
438
|
const o = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
|
|
465
439
|
if (!o) {
|
|
466
|
-
|
|
440
|
+
f.style.display = "none", y.disabled = !0;
|
|
467
441
|
return;
|
|
468
442
|
}
|
|
469
|
-
|
|
470
|
-
},
|
|
471
|
-
if (e.selectedIndex < 0)
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
},
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
d == null || d.classList.add("selected");
|
|
480
|
-
}
|
|
481
|
-
O(), Q();
|
|
482
|
-
}, S = () => {
|
|
483
|
-
if (e.filteredTags = be(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), A(), u.innerHTML = "", e.filteredTags.length === 0) {
|
|
484
|
-
const d = document.createElement("div");
|
|
485
|
-
d.className = "rte-merge-tag-empty", d.textContent = r.dialog.emptyStateText, u.appendChild(d), O();
|
|
443
|
+
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`, y.disabled = !1;
|
|
444
|
+
}, Z = () => {
|
|
445
|
+
if (e.selectedIndex < 0) return;
|
|
446
|
+
u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({ block: "nearest" });
|
|
447
|
+
}, k = () => {
|
|
448
|
+
u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"), e.selectedIndex >= 0 && u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"), O(), Z();
|
|
449
|
+
}, A = () => {
|
|
450
|
+
if (e.filteredTags = pe(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), L(), u.innerHTML = "", e.filteredTags.length === 0) {
|
|
451
|
+
const s = document.createElement("div");
|
|
452
|
+
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s), O();
|
|
486
453
|
return;
|
|
487
454
|
}
|
|
488
455
|
const o = document.createDocumentFragment();
|
|
489
|
-
e.filteredTags.forEach((
|
|
456
|
+
e.filteredTags.forEach((s, p) => {
|
|
490
457
|
const m = document.createElement("div");
|
|
491
|
-
m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(
|
|
458
|
+
m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(p)), m.classList.toggle("selected", p === e.selectedIndex);
|
|
492
459
|
const D = document.createElement("div");
|
|
493
|
-
if (D.className = "rte-merge-tag-item-label", D.textContent =
|
|
494
|
-
const
|
|
495
|
-
|
|
460
|
+
if (D.className = "rte-merge-tag-item-label", D.textContent = s.label, m.appendChild(D), s.preview) {
|
|
461
|
+
const I = document.createElement("div");
|
|
462
|
+
I.className = "rte-merge-tag-item-preview", I.textContent = s.preview, m.appendChild(I);
|
|
496
463
|
}
|
|
497
464
|
o.appendChild(m);
|
|
498
|
-
}), u.appendChild(o),
|
|
465
|
+
}), u.appendChild(o), k();
|
|
499
466
|
}, z = () => {
|
|
500
467
|
e.searchRaf !== null && cancelAnimationFrame(e.searchRaf), e.searchRaf = requestAnimationFrame(() => {
|
|
501
|
-
e.searchRaf = null, e.searchTerm =
|
|
468
|
+
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, A();
|
|
502
469
|
});
|
|
503
470
|
}, x = () => {
|
|
504
|
-
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(),
|
|
505
|
-
},
|
|
506
|
-
if (
|
|
507
|
-
return;
|
|
471
|
+
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), N === n && (N = null, E = null);
|
|
472
|
+
}, T = () => {
|
|
473
|
+
if (L(), e.selectedIndex < 0) return;
|
|
508
474
|
const o = e.filteredTags[e.selectedIndex];
|
|
509
|
-
|
|
475
|
+
fe(t, e.savedRange, o, r.formatToken) && x();
|
|
510
476
|
}, F = (o) => {
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
477
|
+
const p = o.target.closest(".rte-merge-tag-tab");
|
|
478
|
+
if (!p) return;
|
|
479
|
+
const m = p.dataset.category;
|
|
480
|
+
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, _(), A());
|
|
481
|
+
}, B = (o) => {
|
|
482
|
+
const p = o.target.closest(".rte-merge-tag-item");
|
|
483
|
+
if (!p) return;
|
|
484
|
+
const m = Number(p.dataset.index || "-1");
|
|
485
|
+
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, k());
|
|
516
486
|
}, U = (o) => {
|
|
517
|
-
const
|
|
518
|
-
if (!
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}, $ = (o) => {
|
|
523
|
-
const f = o.target.closest(".rte-merge-tag-item");
|
|
524
|
-
if (!f)
|
|
525
|
-
return;
|
|
526
|
-
const m = Number(f.dataset.index || "-1");
|
|
527
|
-
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, C());
|
|
528
|
-
}, N = (o) => {
|
|
487
|
+
const p = o.target.closest(".rte-merge-tag-item");
|
|
488
|
+
if (!p) return;
|
|
489
|
+
const m = Number(p.dataset.index || "-1");
|
|
490
|
+
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, T());
|
|
491
|
+
}, C = (o) => {
|
|
529
492
|
if (o.key === "Escape") {
|
|
530
493
|
o.preventDefault(), x();
|
|
531
494
|
return;
|
|
532
495
|
}
|
|
533
496
|
if (o.key === "ArrowDown") {
|
|
534
|
-
if (o.preventDefault(), e.filteredTags.length === 0)
|
|
535
|
-
|
|
536
|
-
e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1), E();
|
|
497
|
+
if (o.preventDefault(), e.filteredTags.length === 0) return;
|
|
498
|
+
e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1), k();
|
|
537
499
|
return;
|
|
538
500
|
}
|
|
539
501
|
if (o.key === "ArrowUp") {
|
|
540
|
-
if (o.preventDefault(), e.filteredTags.length === 0)
|
|
541
|
-
|
|
542
|
-
e.selectedIndex = Math.max(0, e.selectedIndex - 1), E();
|
|
502
|
+
if (o.preventDefault(), e.filteredTags.length === 0) return;
|
|
503
|
+
e.selectedIndex = Math.max(0, e.selectedIndex - 1), k();
|
|
543
504
|
return;
|
|
544
505
|
}
|
|
545
|
-
o.key === "Enter" && (o.preventDefault(),
|
|
546
|
-
},
|
|
506
|
+
o.key === "Enter" && (o.preventDefault(), T());
|
|
507
|
+
}, $ = (o) => {
|
|
547
508
|
o.target === n && x();
|
|
548
509
|
};
|
|
549
|
-
b.addEventListener("click", F), u.addEventListener("click",
|
|
550
|
-
b.removeEventListener("click", F), u.removeEventListener("click",
|
|
551
|
-
}, _(),
|
|
552
|
-
|
|
510
|
+
b.addEventListener("click", F), u.addEventListener("click", B), u.addEventListener("dblclick", U), i.addEventListener("input", z), i.addEventListener("keydown", C), n.addEventListener("click", $), a.addEventListener("keydown", C), d?.addEventListener("click", x), v.addEventListener("click", x), y.addEventListener("click", T), E = () => {
|
|
511
|
+
b.removeEventListener("click", F), u.removeEventListener("click", B), u.removeEventListener("dblclick", U), i.removeEventListener("input", z), i.removeEventListener("keydown", C), n.removeEventListener("click", $), a.removeEventListener("keydown", C), d?.removeEventListener("click", x), v.removeEventListener("click", x), y.removeEventListener("click", T), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
|
|
512
|
+
}, _(), A(), setTimeout(() => {
|
|
513
|
+
i.focus();
|
|
553
514
|
}, 0);
|
|
554
515
|
}
|
|
555
|
-
const
|
|
516
|
+
const ye = (t) => ({
|
|
556
517
|
name: "mergeTag",
|
|
557
518
|
config: t,
|
|
558
519
|
init: () => {
|
|
559
|
-
|
|
520
|
+
R(), j(), V();
|
|
560
521
|
},
|
|
561
522
|
toolbar: [
|
|
562
523
|
{
|
|
@@ -567,12 +528,12 @@ const xe = (t) => ({
|
|
|
567
528
|
],
|
|
568
529
|
commands: {
|
|
569
530
|
insertMergeTag: () => {
|
|
570
|
-
|
|
571
|
-
const r =
|
|
572
|
-
return r ? (
|
|
531
|
+
R(), j(), V();
|
|
532
|
+
const r = X();
|
|
533
|
+
return r ? (be(r, oe(t)), !0) : !1;
|
|
573
534
|
}
|
|
574
535
|
}
|
|
575
536
|
});
|
|
576
537
|
export {
|
|
577
|
-
|
|
538
|
+
ye as MergeTagPlugin
|
|
578
539
|
};
|