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