@editora/plugins 1.0.12 → 1.0.13
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/approval-workflow.cjs.js +14 -14
- package/dist/approval-workflow.esm.js +265 -262
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +177 -15
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +95 -92
- package/dist/bold.cjs.js +1 -1
- package/dist/bold.esm.js +10 -6
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +124 -44
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +251 -191
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +131 -128
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +68 -36
- package/dist/content-rules.cjs.js +5 -5
- package/dist/content-rules.esm.js +104 -101
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +51 -48
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +97 -74
- package/dist/doc-schema.cjs.js +4 -4
- package/dist/doc-schema.esm.js +104 -101
- package/dist/embed-iframe.cjs.js +21 -4
- package/dist/embed-iframe.esm.js +279 -116
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +239 -56
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +74 -89
- package/dist/inlineFormatting-DOYOJdnD.js +1 -0
- package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +12 -8
- package/dist/math.cjs.js +27 -21
- package/dist/math.esm.js +218 -146
- package/dist/merge-tag.cjs.js +8 -2
- package/dist/merge-tag.esm.js +130 -111
- package/dist/pii-redaction.cjs.js +6 -6
- package/dist/pii-redaction.esm.js +169 -166
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +120 -117
- package/dist/special-characters.cjs.js +6 -10
- package/dist/special-characters.esm.js +97 -75
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +11 -25
- package/dist/translation-workflow.cjs.js +7 -7
- package/dist/translation-workflow.esm.js +103 -100
- package/dist/underline.cjs.js +1 -1
- package/dist/underline.esm.js +7 -3
- package/package.json +3 -3
package/dist/merge-tag.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E = ".rte-content, .editora-content", te = '[data-theme="dark"], .dark, .editora-theme-dark', re = {
|
|
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 ne() {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
12
12
|
id: "USER",
|
|
@@ -46,13 +46,13 @@ 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 ae(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 oe(t) {
|
|
56
56
|
const r = (() => {
|
|
57
57
|
if (Array.isArray(t?.categories) && t.categories.length > 0)
|
|
58
58
|
return t.categories;
|
|
@@ -62,19 +62,19 @@ function ne(t) {
|
|
|
62
62
|
const g = (d.category || "Custom").trim() || "Custom", i = c.get(g);
|
|
63
63
|
i ? i.push(d) : c.set(g, [d]);
|
|
64
64
|
}), Array.from(c.entries()).map(([d, g], i) => ({
|
|
65
|
-
id:
|
|
65
|
+
id: R(d, i),
|
|
66
66
|
name: d,
|
|
67
67
|
tags: g
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
|
-
return
|
|
70
|
+
return ne();
|
|
71
71
|
})(), e = {}, n = [];
|
|
72
72
|
if (r.forEach((c, d) => {
|
|
73
|
-
const g =
|
|
73
|
+
const g = R(c.id || c.name, d);
|
|
74
74
|
n.push(g), e[g] = {
|
|
75
75
|
name: c.name,
|
|
76
76
|
tags: (Array.isArray(c.tags) ? c.tags : []).map((i, b) => {
|
|
77
|
-
const u =
|
|
77
|
+
const u = ae(i, b), f = (i.category || c.name).trim() || c.name;
|
|
78
78
|
return {
|
|
79
79
|
...i,
|
|
80
80
|
key: u,
|
|
@@ -88,32 +88,32 @@ function ne(t) {
|
|
|
88
88
|
const c = "CUSTOM";
|
|
89
89
|
n.push(c), e[c] = { name: "Custom", tags: [] };
|
|
90
90
|
}
|
|
91
|
-
const a = t?.defaultCategory ?
|
|
91
|
+
const a = 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
|
|
98
|
+
function le(t) {
|
|
99
99
|
const r = t?.tokenTemplate;
|
|
100
100
|
return typeof r == "function" ? (e) => {
|
|
101
101
|
const n = r(e);
|
|
102
102
|
return typeof n == "string" && n.trim() ? n : e.value?.trim() || `{{ ${e.label} }}`;
|
|
103
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} }}`;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function ce(t) {
|
|
106
106
|
return {
|
|
107
|
-
catalog:
|
|
107
|
+
catalog: oe(t),
|
|
108
108
|
dialog: {
|
|
109
|
-
...
|
|
109
|
+
...re,
|
|
110
110
|
...t?.dialog || {}
|
|
111
111
|
},
|
|
112
|
-
formatToken:
|
|
112
|
+
formatToken: le(t)
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
let
|
|
116
|
-
function
|
|
115
|
+
let H = !1, j = !1, L = null, S = null, w = null, q = !1, y = null;
|
|
116
|
+
function X(t, r) {
|
|
117
117
|
if (r === t.innerHTML) return;
|
|
118
118
|
const e = window.execEditorCommand || window.executeEditorCommand;
|
|
119
119
|
if (typeof e == "function")
|
|
@@ -122,9 +122,9 @@ function J(t, r) {
|
|
|
122
122
|
} catch {
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
function
|
|
126
|
-
if (
|
|
127
|
-
|
|
125
|
+
function _() {
|
|
126
|
+
if (H || typeof document > "u") return;
|
|
127
|
+
H = !0;
|
|
128
128
|
const t = document.createElement("style");
|
|
129
129
|
t.id = "merge-tag-plugin-styles", t.textContent = `
|
|
130
130
|
.rte-merge-tag-overlay {
|
|
@@ -245,6 +245,12 @@ function R() {
|
|
|
245
245
|
line-height: 1.3;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
.rte-merge-tag.rte-merge-tag-selected {
|
|
249
|
+
outline: 2px solid #2563eb;
|
|
250
|
+
outline-offset: 2px;
|
|
251
|
+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
|
|
252
|
+
}
|
|
253
|
+
|
|
248
254
|
:is([data-theme="dark"], .dark, .editora-theme-dark) .rte-merge-tag {
|
|
249
255
|
background: #223247;
|
|
250
256
|
border-color: #3f5f84;
|
|
@@ -252,28 +258,34 @@ function R() {
|
|
|
252
258
|
}
|
|
253
259
|
`, document.head.appendChild(t);
|
|
254
260
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
const e = t.target?.closest(
|
|
258
|
-
e && (
|
|
261
|
+
function W() {
|
|
262
|
+
j || typeof document > "u" || (j = !0, document.addEventListener("focusin", (t) => {
|
|
263
|
+
const e = t.target?.closest(E);
|
|
264
|
+
e && (L = e);
|
|
259
265
|
}), document.addEventListener("selectionchange", () => {
|
|
260
|
-
const t =
|
|
261
|
-
t && (
|
|
266
|
+
const t = Z();
|
|
267
|
+
t && (L = t);
|
|
262
268
|
}));
|
|
263
269
|
}
|
|
264
|
-
function
|
|
270
|
+
function Z() {
|
|
265
271
|
const t = window.getSelection();
|
|
266
272
|
if (!t || t.rangeCount === 0) return null;
|
|
267
273
|
const e = t.getRangeAt(0).startContainer;
|
|
268
|
-
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(
|
|
274
|
+
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(E) || null;
|
|
269
275
|
}
|
|
270
|
-
function
|
|
271
|
-
const t =
|
|
276
|
+
function Q() {
|
|
277
|
+
const t = Z();
|
|
272
278
|
if (t) return t;
|
|
273
|
-
const e = document.activeElement?.closest(
|
|
274
|
-
return e || (
|
|
279
|
+
const e = document.activeElement?.closest(E);
|
|
280
|
+
return e || (L?.isConnected ? L : document.querySelector(E));
|
|
275
281
|
}
|
|
276
|
-
function
|
|
282
|
+
function O() {
|
|
283
|
+
y && (y.classList.remove("rte-merge-tag-selected"), y.removeAttribute("data-rte-selected-object"), y = null);
|
|
284
|
+
}
|
|
285
|
+
function ie(t) {
|
|
286
|
+
y !== t && (O(), y = t, t.classList.add("rte-merge-tag-selected"), t.setAttribute("data-rte-selected-object", "true")), se(t);
|
|
287
|
+
}
|
|
288
|
+
function se(t) {
|
|
277
289
|
const r = t.parentNode;
|
|
278
290
|
if (!r) return;
|
|
279
291
|
const e = window.getSelection();
|
|
@@ -281,31 +293,31 @@ function le(t) {
|
|
|
281
293
|
const n = document.createRange(), l = Array.from(r.childNodes).indexOf(t);
|
|
282
294
|
l < 0 || (n.setStart(r, l), n.setEnd(r, l + 1), e.removeAllRanges(), e.addRange(n));
|
|
283
295
|
}
|
|
284
|
-
function
|
|
296
|
+
function V(t, r) {
|
|
285
297
|
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
298
|
}
|
|
287
|
-
function
|
|
299
|
+
function G(t, r) {
|
|
288
300
|
const e = window.getSelection();
|
|
289
301
|
if (!e) 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(
|
|
305
|
+
function de(t, r) {
|
|
306
|
+
const e = t.closest(E), n = e?.innerHTML ?? "", a = t.parentNode;
|
|
295
307
|
if (!a) return !1;
|
|
296
308
|
const c = Array.from(a.childNodes).indexOf(t);
|
|
297
309
|
if (c < 0) return !1;
|
|
298
310
|
const d = t.previousSibling, g = t.nextSibling;
|
|
299
|
-
return a.removeChild(t), r === "Backspace" ? (
|
|
311
|
+
return a.removeChild(t), y === t && (y = null), r === "Backspace" ? (V(g, !0), G(a, c)) : (V(d, !1), G(a, c)), e && (X(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
|
|
300
312
|
}
|
|
301
|
-
function
|
|
313
|
+
function ge(t) {
|
|
302
314
|
if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1) return null;
|
|
303
315
|
const r = t.startContainer;
|
|
304
316
|
if (!(r instanceof Element || r instanceof DocumentFragment)) return null;
|
|
305
317
|
const e = r.childNodes[t.startOffset];
|
|
306
318
|
return e instanceof HTMLElement && e.classList.contains("rte-merge-tag") ? e : null;
|
|
307
319
|
}
|
|
308
|
-
function
|
|
320
|
+
function me(t, r) {
|
|
309
321
|
if (!t.collapsed) return null;
|
|
310
322
|
const { startContainer: e, startOffset: n } = t, a = (l) => l instanceof HTMLElement && l.classList.contains("rte-merge-tag") ? l : null;
|
|
311
323
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -318,65 +330,72 @@ function se(t, r) {
|
|
|
318
330
|
}
|
|
319
331
|
return null;
|
|
320
332
|
}
|
|
321
|
-
function
|
|
322
|
-
|
|
333
|
+
function J() {
|
|
334
|
+
q || typeof document > "u" || (q = !0, document.addEventListener("pointerdown", (t) => {
|
|
323
335
|
const e = t.target?.closest(".rte-merge-tag");
|
|
324
|
-
if (!e)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
336
|
+
if (!e) {
|
|
337
|
+
t.target?.closest?.(".rte-merge-tag-overlay") || O();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const n = e.closest(E);
|
|
341
|
+
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), ie(e));
|
|
342
|
+
}, !0), document.addEventListener("keydown", (t) => {
|
|
343
|
+
if (t.key === "Escape" && y) {
|
|
344
|
+
O();
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
328
347
|
if (t.key !== "Backspace" && t.key !== "Delete") return;
|
|
329
348
|
const r = window.getSelection();
|
|
330
349
|
if (!r || r.rangeCount === 0) return;
|
|
331
|
-
const e = r.getRangeAt(0), n =
|
|
350
|
+
const e = r.getRangeAt(0), n = Q();
|
|
332
351
|
if (!n || !n.contains(e.commonAncestorContainer)) return;
|
|
333
|
-
let a =
|
|
334
|
-
a || (a =
|
|
352
|
+
let a = y?.isConnected ? y : null;
|
|
353
|
+
a && !n.contains(a) && (a = null), a || (a = ge(e)), a || (a = me(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), de(a, t.key));
|
|
335
354
|
}));
|
|
336
355
|
}
|
|
337
|
-
function
|
|
338
|
-
return t ? !!t.closest(
|
|
356
|
+
function ue(t) {
|
|
357
|
+
return t ? !!t.closest(te) : !1;
|
|
339
358
|
}
|
|
340
|
-
function
|
|
341
|
-
|
|
359
|
+
function fe() {
|
|
360
|
+
w && (w(), w = null), S = null;
|
|
342
361
|
}
|
|
343
|
-
function
|
|
362
|
+
function Y(t) {
|
|
344
363
|
const r = document.createRange();
|
|
345
364
|
return r.selectNodeContents(t), r.collapse(!1), r;
|
|
346
365
|
}
|
|
347
|
-
function
|
|
348
|
-
const e = window.getSelection(), n = r ? r.cloneRange() :
|
|
366
|
+
function pe(t, r) {
|
|
367
|
+
const e = window.getSelection(), n = r ? r.cloneRange() : Y(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : Y(t);
|
|
349
368
|
return e && (e.removeAllRanges(), e.addRange(l)), l;
|
|
350
369
|
}
|
|
351
|
-
function
|
|
370
|
+
function be(t, r) {
|
|
352
371
|
const e = document.createElement("span");
|
|
353
372
|
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
373
|
const n = r(t);
|
|
355
374
|
return e.setAttribute("data-token", n), e.setAttribute("aria-label", `Merge tag: ${t.label}`), e.textContent = n, e;
|
|
356
375
|
}
|
|
357
|
-
function
|
|
376
|
+
function ye(t, r, e, n) {
|
|
358
377
|
const a = window.getSelection();
|
|
359
378
|
if (!a) return !1;
|
|
360
379
|
const l = t.innerHTML;
|
|
361
380
|
t.focus({ preventScroll: !0 });
|
|
362
|
-
const c =
|
|
381
|
+
const c = pe(t, r), g = (c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement)?.closest(".rte-merge-tag");
|
|
363
382
|
g && t.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
|
|
364
383
|
try {
|
|
365
384
|
c.deleteContents();
|
|
366
|
-
const i =
|
|
385
|
+
const i = be(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
|
|
367
386
|
u.appendChild(i), u.appendChild(b), c.insertNode(u);
|
|
368
387
|
const f = document.createRange();
|
|
369
|
-
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f),
|
|
388
|
+
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f), X(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
370
389
|
} catch (i) {
|
|
371
390
|
return console.error("Failed to insert merge tag:", i), !1;
|
|
372
391
|
}
|
|
373
392
|
}
|
|
374
|
-
function
|
|
393
|
+
function xe(t, r, e) {
|
|
375
394
|
const n = t.catalog.categoriesByKey[r]?.tags || [], a = e.trim().toLowerCase();
|
|
376
395
|
return a ? n.filter((l) => l.searchIndex.includes(a)) : n;
|
|
377
396
|
}
|
|
378
|
-
function
|
|
379
|
-
|
|
397
|
+
function ve(t, r) {
|
|
398
|
+
fe(), _();
|
|
380
399
|
const e = {
|
|
381
400
|
category: r.catalog.defaultCategory,
|
|
382
401
|
searchTerm: "",
|
|
@@ -390,7 +409,7 @@ function be(t, r) {
|
|
|
390
409
|
})(),
|
|
391
410
|
searchRaf: null
|
|
392
411
|
}, n = document.createElement("div");
|
|
393
|
-
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"),
|
|
412
|
+
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), ue(t) && n.classList.add("rte-ui-theme-dark");
|
|
394
413
|
const a = document.createElement("div");
|
|
395
414
|
a.className = "rte-merge-tag-dialog";
|
|
396
415
|
const l = document.createElement("div");
|
|
@@ -412,85 +431,85 @@ function be(t, r) {
|
|
|
412
431
|
u.className = "rte-merge-tag-list";
|
|
413
432
|
const f = document.createElement("div");
|
|
414
433
|
f.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(b), g.appendChild(u), g.appendChild(f);
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
const
|
|
434
|
+
const T = document.createElement("div");
|
|
435
|
+
T.className = "rte-merge-tag-footer";
|
|
436
|
+
const h = document.createElement("button");
|
|
437
|
+
h.type = "button", h.className = "rte-merge-tag-btn-secondary", h.textContent = r.dialog.cancelText;
|
|
438
|
+
const x = document.createElement("button");
|
|
439
|
+
x.type = "button", x.className = "rte-merge-tag-btn-primary", x.textContent = r.dialog.insertText, T.appendChild(h), T.appendChild(x), a.appendChild(l), a.appendChild(g), a.appendChild(T), n.appendChild(a), document.body.appendChild(n), S = n;
|
|
440
|
+
const z = () => {
|
|
422
441
|
b.querySelectorAll(".rte-merge-tag-tab").forEach((s) => {
|
|
423
442
|
const p = s.dataset.category === e.category;
|
|
424
443
|
s.classList.toggle("active", p);
|
|
425
444
|
});
|
|
426
|
-
},
|
|
445
|
+
}, A = () => {
|
|
427
446
|
if (e.filteredTags.length === 0) {
|
|
428
447
|
e.selectedIndex = -1;
|
|
429
448
|
return;
|
|
430
449
|
}
|
|
431
450
|
e.selectedIndex < 0 && (e.selectedIndex = 0), e.selectedIndex >= e.filteredTags.length && (e.selectedIndex = e.filteredTags.length - 1);
|
|
432
|
-
},
|
|
451
|
+
}, F = () => {
|
|
433
452
|
if (!r.dialog.showPreview) {
|
|
434
|
-
f.style.display = "none",
|
|
453
|
+
f.style.display = "none", x.disabled = e.filteredTags.length === 0;
|
|
435
454
|
return;
|
|
436
455
|
}
|
|
437
|
-
|
|
456
|
+
A();
|
|
438
457
|
const o = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
|
|
439
458
|
if (!o) {
|
|
440
|
-
f.style.display = "none",
|
|
459
|
+
f.style.display = "none", x.disabled = !0;
|
|
441
460
|
return;
|
|
442
461
|
}
|
|
443
|
-
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`,
|
|
444
|
-
},
|
|
462
|
+
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`, x.disabled = !1;
|
|
463
|
+
}, ee = () => {
|
|
445
464
|
if (e.selectedIndex < 0) return;
|
|
446
465
|
u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({ block: "nearest" });
|
|
447
466
|
}, 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"),
|
|
449
|
-
},
|
|
450
|
-
if (e.filteredTags =
|
|
467
|
+
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"), F(), ee();
|
|
468
|
+
}, D = () => {
|
|
469
|
+
if (e.filteredTags = xe(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), A(), u.innerHTML = "", e.filteredTags.length === 0) {
|
|
451
470
|
const s = document.createElement("div");
|
|
452
|
-
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s),
|
|
471
|
+
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s), F();
|
|
453
472
|
return;
|
|
454
473
|
}
|
|
455
474
|
const o = document.createDocumentFragment();
|
|
456
475
|
e.filteredTags.forEach((s, p) => {
|
|
457
476
|
const m = document.createElement("div");
|
|
458
477
|
m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(p)), m.classList.toggle("selected", p === e.selectedIndex);
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
478
|
+
const M = document.createElement("div");
|
|
479
|
+
if (M.className = "rte-merge-tag-item-label", M.textContent = s.label, m.appendChild(M), s.preview) {
|
|
461
480
|
const I = document.createElement("div");
|
|
462
481
|
I.className = "rte-merge-tag-item-preview", I.textContent = s.preview, m.appendChild(I);
|
|
463
482
|
}
|
|
464
483
|
o.appendChild(m);
|
|
465
484
|
}), u.appendChild(o), k();
|
|
466
|
-
},
|
|
485
|
+
}, B = () => {
|
|
467
486
|
e.searchRaf !== null && cancelAnimationFrame(e.searchRaf), e.searchRaf = requestAnimationFrame(() => {
|
|
468
|
-
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0,
|
|
487
|
+
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, D();
|
|
469
488
|
});
|
|
470
|
-
},
|
|
471
|
-
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(),
|
|
472
|
-
},
|
|
473
|
-
if (
|
|
489
|
+
}, v = () => {
|
|
490
|
+
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), S === n && (S = null, w = null);
|
|
491
|
+
}, C = () => {
|
|
492
|
+
if (A(), e.selectedIndex < 0) return;
|
|
474
493
|
const o = e.filteredTags[e.selectedIndex];
|
|
475
|
-
|
|
476
|
-
},
|
|
494
|
+
ye(t, e.savedRange, o, r.formatToken) && v();
|
|
495
|
+
}, U = (o) => {
|
|
477
496
|
const p = o.target.closest(".rte-merge-tag-tab");
|
|
478
497
|
if (!p) return;
|
|
479
498
|
const m = p.dataset.category;
|
|
480
|
-
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0,
|
|
481
|
-
},
|
|
499
|
+
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, z(), D());
|
|
500
|
+
}, $ = (o) => {
|
|
482
501
|
const p = o.target.closest(".rte-merge-tag-item");
|
|
483
502
|
if (!p) return;
|
|
484
503
|
const m = Number(p.dataset.index || "-1");
|
|
485
504
|
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, k());
|
|
486
|
-
},
|
|
505
|
+
}, K = (o) => {
|
|
487
506
|
const p = o.target.closest(".rte-merge-tag-item");
|
|
488
507
|
if (!p) return;
|
|
489
508
|
const m = Number(p.dataset.index || "-1");
|
|
490
|
-
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m,
|
|
491
|
-
},
|
|
509
|
+
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, C());
|
|
510
|
+
}, N = (o) => {
|
|
492
511
|
if (o.key === "Escape") {
|
|
493
|
-
o.preventDefault(),
|
|
512
|
+
o.preventDefault(), v();
|
|
494
513
|
return;
|
|
495
514
|
}
|
|
496
515
|
if (o.key === "ArrowDown") {
|
|
@@ -503,21 +522,21 @@ function be(t, r) {
|
|
|
503
522
|
e.selectedIndex = Math.max(0, e.selectedIndex - 1), k();
|
|
504
523
|
return;
|
|
505
524
|
}
|
|
506
|
-
o.key === "Enter" && (o.preventDefault(),
|
|
507
|
-
},
|
|
508
|
-
o.target === n &&
|
|
525
|
+
o.key === "Enter" && (o.preventDefault(), C());
|
|
526
|
+
}, P = (o) => {
|
|
527
|
+
o.target === n && v();
|
|
509
528
|
};
|
|
510
|
-
b.addEventListener("click",
|
|
511
|
-
b.removeEventListener("click",
|
|
512
|
-
},
|
|
529
|
+
b.addEventListener("click", U), u.addEventListener("click", $), u.addEventListener("dblclick", K), i.addEventListener("input", B), i.addEventListener("keydown", N), n.addEventListener("click", P), a.addEventListener("keydown", N), d?.addEventListener("click", v), h.addEventListener("click", v), x.addEventListener("click", C), w = () => {
|
|
530
|
+
b.removeEventListener("click", U), u.removeEventListener("click", $), u.removeEventListener("dblclick", K), i.removeEventListener("input", B), i.removeEventListener("keydown", N), n.removeEventListener("click", P), a.removeEventListener("keydown", N), d?.removeEventListener("click", v), h.removeEventListener("click", v), x.removeEventListener("click", C), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
|
|
531
|
+
}, z(), D(), setTimeout(() => {
|
|
513
532
|
i.focus();
|
|
514
533
|
}, 0);
|
|
515
534
|
}
|
|
516
|
-
const
|
|
535
|
+
const he = (t) => ({
|
|
517
536
|
name: "mergeTag",
|
|
518
537
|
config: t,
|
|
519
538
|
init: () => {
|
|
520
|
-
|
|
539
|
+
_(), W(), J();
|
|
521
540
|
},
|
|
522
541
|
toolbar: [
|
|
523
542
|
{
|
|
@@ -528,12 +547,12 @@ const ye = (t) => ({
|
|
|
528
547
|
],
|
|
529
548
|
commands: {
|
|
530
549
|
insertMergeTag: () => {
|
|
531
|
-
|
|
532
|
-
const r =
|
|
533
|
-
return r ? (
|
|
550
|
+
_(), W(), J();
|
|
551
|
+
const r = Q();
|
|
552
|
+
return r ? (ve(r, ce(t)), !0) : !1;
|
|
534
553
|
}
|
|
535
554
|
}
|
|
536
555
|
});
|
|
537
556
|
export {
|
|
538
|
-
|
|
557
|
+
he as MergeTagPlugin
|
|
539
558
|
};
|