@editora/core 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.
Files changed (58) hide show
  1. package/README.md +6 -1
  2. package/dist/{ApprovalWorkflowPlugin.native-C3jtAYjG.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +136 -133
  3. package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
  4. package/dist/{BlocksLibraryPlugin.native-HMWKxWNs.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +90 -87
  5. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
  6. package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
  7. package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
  8. package/dist/{CitationsPlugin.native-BnU0qCwR.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +132 -129
  9. package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
  10. package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
  11. package/dist/{ContentRulesPlugin.native-nBLQ8QFZ.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +105 -102
  12. package/dist/{DataBindingPlugin.native-jQ1JPRTp.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +49 -46
  13. package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
  14. package/dist/{DocSchemaPlugin.native-CHOge18O.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +55 -52
  15. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-BF_-LjTq.mjs} +287 -115
  16. package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
  17. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-D2wl32jV.mjs} +88 -103
  18. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
  19. package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
  20. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +204 -202
  21. package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
  22. package/dist/{PIIRedactionPlugin.native-DcsjmtV1.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +158 -155
  23. package/dist/{SlashCommandsPlugin.native-CmxvMEaE.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +2 -2
  24. package/dist/{SmartPastePlugin.native-BOKKtF07.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +127 -124
  25. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +100 -76
  26. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -26
  27. package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
  28. package/dist/{TranslationWorkflowPlugin.native-Bz6jDGvj.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +104 -101
  29. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
  30. package/dist/editora.min.js +1 -1
  31. package/dist/editora.umd.js +1 -1
  32. package/dist/index-CPMGUZfB.js +10 -0
  33. package/dist/{index-DqC57IEH.mjs → index-DBoj6QfW.mjs} +17 -15
  34. package/dist/index.cjs.js +1 -1
  35. package/dist/index.esm.js +2 -2
  36. package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
  37. package/dist/plugin-loader.js +37 -37
  38. package/dist/webcomponent-core.js +18 -16
  39. package/dist/webcomponent-core.min.css +1 -1
  40. package/dist/webcomponent-core.min.js +139 -62
  41. package/dist/webcomponent.cjs.js +1 -1
  42. package/dist/webcomponent.esm.js +1 -1
  43. package/dist/webcomponent.js +50 -48
  44. package/dist/webcomponent.min.css +1 -1
  45. package/dist/webcomponent.min.js +1174 -1071
  46. package/package.json +11 -5
  47. package/LICENSE +0 -21
  48. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs +0 -48
  49. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs +0 -79
  50. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +0 -309
  51. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +0 -140
  52. package/dist/CodePlugin.native-DlpTPdkd.mjs +0 -2691
  53. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +0 -130
  54. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs +0 -64
  55. package/dist/MathPlugin.native-f_mDp8VL.mjs +0 -292
  56. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +0 -559
  57. package/dist/TemplatePlugin.native-CrpfKRJ8.mjs +0 -602
  58. package/dist/index-D1LOqg5C.js +0 -10
@@ -1,559 +0,0 @@
1
- const w = ".rte-content, .editora-content", ee = '[data-theme="dark"], .dark, .editora-theme-dark', te = {
2
- title: "Insert Merge Tag",
3
- searchPlaceholder: "Search merge tags...",
4
- emptyStateText: "No merge tags found",
5
- cancelText: "Cancel",
6
- insertText: "Insert",
7
- showPreview: !0
8
- };
9
- function re() {
10
- return [
11
- {
12
- id: "USER",
13
- name: "User",
14
- tags: [
15
- { key: "first_name", label: "First Name", category: "User", preview: "John" },
16
- { key: "last_name", label: "Last Name", category: "User", preview: "Doe" },
17
- { key: "email", label: "Email", category: "User", preview: "john@example.com" },
18
- { key: "phone", label: "Phone", category: "User", preview: "+1-555-1234" },
19
- { key: "full_name", label: "Full Name", category: "User", preview: "John Doe" },
20
- { key: "username", label: "Username", category: "User", preview: "johndoe" }
21
- ]
22
- },
23
- {
24
- id: "COMPANY",
25
- name: "Company",
26
- tags: [
27
- { key: "company_name", label: "Company Name", category: "Company", preview: "Acme Corp" },
28
- { key: "company_address", label: "Company Address", category: "Company", preview: "123 Main St" },
29
- { key: "company_phone", label: "Company Phone", category: "Company", preview: "+1-555-0000" },
30
- { key: "company_email", label: "Company Email", category: "Company", preview: "info@acme.com" }
31
- ]
32
- },
33
- {
34
- id: "DATE",
35
- name: "Date",
36
- tags: [
37
- { key: "today", label: "Today", category: "Date", preview: (/* @__PURE__ */ new Date()).toLocaleDateString() },
38
- { key: "tomorrow", label: "Tomorrow", category: "Date", preview: new Date(Date.now() + 864e5).toLocaleDateString() },
39
- { key: "next_week", label: "Next Week", category: "Date", preview: new Date(Date.now() + 6048e5).toLocaleDateString() }
40
- ]
41
- },
42
- {
43
- id: "CUSTOM",
44
- name: "Custom",
45
- tags: []
46
- }
47
- ];
48
- }
49
- function R(t, r) {
50
- return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `CATEGORY_${r + 1}`;
51
- }
52
- function ne(t, r) {
53
- return (t.key || t.value || t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `tag_${r + 1}`;
54
- }
55
- function ae(t) {
56
- const r = (() => {
57
- if (Array.isArray(t == null ? void 0 : t.categories) && t.categories.length > 0)
58
- return t.categories;
59
- if (Array.isArray(t == null ? void 0 : t.tags) && t.tags.length > 0) {
60
- const c = /* @__PURE__ */ new Map();
61
- return t.tags.forEach((s) => {
62
- const g = (s.category || "Custom").trim() || "Custom", i = c.get(g);
63
- i ? i.push(s) : c.set(g, [s]);
64
- }), Array.from(c.entries()).map(([s, g], i) => ({
65
- id: R(s, i),
66
- name: s,
67
- tags: g
68
- }));
69
- }
70
- return re();
71
- })(), e = {}, n = [];
72
- if (r.forEach((c, s) => {
73
- const g = R(c.id || c.name, s);
74
- n.push(g), e[g] = {
75
- name: c.name,
76
- tags: (Array.isArray(c.tags) ? c.tags : []).map((i, b) => {
77
- var v, y;
78
- const u = ne(i, b), p = (i.category || c.name).trim() || c.name;
79
- return {
80
- ...i,
81
- key: u,
82
- category: p,
83
- categoryKey: g,
84
- searchIndex: `${i.label} ${u} ${p} ${(v = i.description) != null ? v : ""} ${(y = i.value) != null ? y : ""}`.toLowerCase()
85
- };
86
- })
87
- };
88
- }), n.length === 0) {
89
- const c = "CUSTOM";
90
- n.push(c), e[c] = { name: "Custom", tags: [] };
91
- }
92
- const a = t != null && t.defaultCategory ? R(t.defaultCategory, 0) : null, l = a && n.includes(a) ? a : n[0];
93
- return {
94
- categoriesByKey: e,
95
- categoryKeys: n,
96
- defaultCategory: l
97
- };
98
- }
99
- function oe(t) {
100
- const r = t == null ? void 0 : t.tokenTemplate;
101
- return typeof r == "function" ? (e) => {
102
- var a;
103
- const n = r(e);
104
- return typeof n == "string" && n.trim() ? n : ((a = e.value) == null ? void 0 : a.trim()) || `{{ ${e.label} }}`;
105
- } : typeof r == "string" && r.trim() ? (e) => {
106
- var n;
107
- return r.replace(/\{key\}/gi, e.key).replace(/\{label\}/gi, e.label).replace(/\{category\}/gi, e.category).replace(/\{value\}/gi, (n = e.value) != null ? n : "");
108
- } : (e) => {
109
- var n;
110
- return ((n = e.value) == null ? void 0 : n.trim()) || `{{ ${e.label} }}`;
111
- };
112
- }
113
- function le(t) {
114
- return {
115
- catalog: ae(t),
116
- dialog: {
117
- ...te,
118
- ...(t == null ? void 0 : t.dialog) || {}
119
- },
120
- formatToken: oe(t)
121
- };
122
- }
123
- let K = !1, B = !1, k = null, L = null, T = null, j = !1;
124
- function Y(t, r) {
125
- if (r === t.innerHTML) return;
126
- const e = window.execEditorCommand || window.executeEditorCommand;
127
- if (typeof e == "function")
128
- try {
129
- e("recordDomTransaction", t, r, t.innerHTML);
130
- } catch (n) {
131
- }
132
- }
133
- function I() {
134
- if (K || typeof document == "undefined") return;
135
- K = !0;
136
- const t = document.createElement("style");
137
- t.id = "merge-tag-plugin-styles", t.textContent = `
138
- .rte-merge-tag-overlay {
139
- --rte-mt-overlay-bg: rgba(15, 23, 36, 0.56);
140
- --rte-mt-dialog-bg: #ffffff;
141
- --rte-mt-dialog-text: #101828;
142
- --rte-mt-border: #d6dbe4;
143
- --rte-mt-subtle-bg: #f7f9fc;
144
- --rte-mt-subtle-hover: #eef2f7;
145
- --rte-mt-muted-text: #5f6b7d;
146
- --rte-mt-accent: #1976d2;
147
- --rte-mt-accent-strong: #1565c0;
148
- position: fixed;
149
- inset: 0;
150
- background-color: var(--rte-mt-overlay-bg);
151
- backdrop-filter: blur(2px);
152
- display: flex;
153
- align-items: center;
154
- justify-content: center;
155
- z-index: 10000;
156
- padding: 16px;
157
- box-sizing: border-box;
158
- }
159
-
160
- .rte-merge-tag-overlay.rte-ui-theme-dark {
161
- --rte-mt-overlay-bg: rgba(2, 8, 20, 0.72);
162
- --rte-mt-dialog-bg: #202938;
163
- --rte-mt-dialog-text: #e8effc;
164
- --rte-mt-border: #49566c;
165
- --rte-mt-subtle-bg: #2a3444;
166
- --rte-mt-subtle-hover: #344256;
167
- --rte-mt-muted-text: #a5b1c5;
168
- --rte-mt-accent: #58a6ff;
169
- --rte-mt-accent-strong: #4598f4;
170
- }
171
-
172
- .rte-merge-tag-dialog {
173
- background: var(--rte-mt-dialog-bg);
174
- color: var(--rte-mt-dialog-text);
175
- border: 1px solid var(--rte-mt-border);
176
- border-radius: 12px;
177
- box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
178
- width: 500px;
179
- max-width: 90vw;
180
- max-height: 80vh;
181
- display: flex;
182
- flex-direction: column;
183
- overflow: hidden;
184
- }
185
-
186
- .rte-merge-tag-header { padding: 16px; border-bottom: 1px solid var(--rte-mt-border); display:flex; justify-content:space-between; align-items:center; }
187
- .rte-merge-tag-body {
188
- padding: 16px;
189
- flex: 1;
190
- min-height: 0;
191
- display: flex;
192
- flex-direction: column;
193
- overflow: hidden;
194
- }
195
- .rte-merge-tag-input {
196
- width:100%;
197
- padding:11px 12px;
198
- border:1px solid var(--rte-mt-border);
199
- border-radius:6px;
200
- background:var(--rte-mt-subtle-bg);
201
- color:var(--rte-mt-dialog-text);
202
- font-size:14px;
203
- line-height:1.45;
204
- box-sizing:border-box;
205
- }
206
- .rte-merge-tag-tabs { display:flex; flex-wrap: wrap; gap:8px; margin: 12px 0; }
207
- .rte-merge-tag-tab { padding:8px 12px; background:none; border:none; cursor:pointer; color:var(--rte-mt-muted-text); border-bottom:3px solid transparent; }
208
- .rte-merge-tag-tab.active { color:var(--rte-mt-accent); border-bottom-color:var(--rte-mt-accent); }
209
- .rte-merge-tag-list {
210
- border:1px solid var(--rte-mt-border);
211
- border-radius:4px;
212
- flex: 1;
213
- min-height: 180px;
214
- max-height: 300px;
215
- overflow-y:auto;
216
- overflow-x:hidden;
217
- margin-bottom:12px;
218
- background:var(--rte-mt-subtle-bg);
219
- }
220
- .rte-merge-tag-item {
221
- padding:8px 12px;
222
- border-bottom:1px solid var(--rte-mt-border);
223
- cursor:pointer;
224
- transition:background-color 0.16s;
225
- color:var(--rte-mt-dialog-text);
226
- overflow-wrap:anywhere;
227
- word-break:break-word;
228
- }
229
- .rte-merge-tag-item:last-child { border-bottom: none; }
230
- .rte-merge-tag-item.selected, .rte-merge-tag-item:hover { background-color:var(--rte-mt-subtle-hover); }
231
- .rte-merge-tag-item-label { font-weight: 600; }
232
- .rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; overflow-wrap:anywhere; word-break:break-word; }
233
- .rte-merge-tag-empty { padding: 24px; text-align: center; color: var(--rte-mt-muted-text); }
234
- .rte-merge-tag-preview { padding:8px; background:var(--rte-mt-subtle-bg); border-radius:4px; font-family:monospace; font-size:12px; color:var(--rte-mt-dialog-text); overflow-wrap:anywhere; word-break:break-word; }
235
- .rte-merge-tag-footer { padding:12px 16px; border-top:1px solid var(--rte-mt-border); display:flex; gap:8px; justify-content:flex-end; background:var(--rte-mt-subtle-bg); }
236
- .rte-merge-tag-btn-primary { padding:8px 16px; border:none; border-radius:4px; background:var(--rte-mt-accent); color:#fff; cursor:pointer; }
237
- .rte-merge-tag-btn-primary:hover { background: var(--rte-mt-accent-strong); }
238
- .rte-merge-tag-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
239
- .rte-merge-tag-btn-secondary { padding:8px 16px; border:1px solid var(--rte-mt-border); border-radius:4px; background:var(--rte-mt-subtle-bg); color:var(--rte-mt-dialog-text); cursor:pointer; }
240
-
241
- .rte-merge-tag {
242
- display: inline-flex;
243
- align-items: center;
244
- white-space: nowrap;
245
- user-select: none;
246
- background-color: #e3f2fd;
247
- border: 1px solid #bbdefb;
248
- border-radius: 3px;
249
- padding: 1px 6px;
250
- margin: 0 2px;
251
- color: #1976d2;
252
- font-weight: 600;
253
- line-height: 1.3;
254
- }
255
-
256
- :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-merge-tag {
257
- background: #223247;
258
- border-color: #3f5f84;
259
- color: #8dc4ff;
260
- }
261
- `, document.head.appendChild(t);
262
- }
263
- function q() {
264
- B || typeof document == "undefined" || (B = !0, document.addEventListener("focusin", (t) => {
265
- const r = t.target, e = r == null ? void 0 : r.closest(w);
266
- e && (k = e);
267
- }), document.addEventListener("selectionchange", () => {
268
- const t = X();
269
- t && (k = t);
270
- }));
271
- }
272
- function X() {
273
- const t = window.getSelection();
274
- if (!t || t.rangeCount === 0) return null;
275
- const e = t.getRangeAt(0).startContainer, n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
276
- return (n == null ? void 0 : n.closest(w)) || null;
277
- }
278
- function Z() {
279
- const t = X();
280
- if (t) return t;
281
- const r = document.activeElement, e = r == null ? void 0 : r.closest(w);
282
- return e || (k != null && k.isConnected ? k : document.querySelector(w));
283
- }
284
- function ce(t) {
285
- const r = t.parentNode;
286
- if (!r) return;
287
- const e = window.getSelection();
288
- if (!e) return;
289
- const n = document.createRange(), l = Array.from(r.childNodes).indexOf(t);
290
- l < 0 || (n.setStart(r, l), n.setEnd(r, l + 1), e.removeAllRanges(), e.addRange(n));
291
- }
292
- function W(t, r) {
293
- var e;
294
- 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)));
295
- }
296
- function V(t, r) {
297
- const e = window.getSelection();
298
- if (!e) return;
299
- const n = document.createRange(), a = Math.max(0, Math.min(r, t.childNodes.length));
300
- n.setStart(t, a), n.collapse(!0), e.removeAllRanges(), e.addRange(n);
301
- }
302
- function ie(t, r) {
303
- var i;
304
- const e = t.closest(w), n = (i = e == null ? void 0 : e.innerHTML) != null ? i : "", a = t.parentNode;
305
- if (!a) return !1;
306
- const c = Array.from(a.childNodes).indexOf(t);
307
- if (c < 0) return !1;
308
- const s = t.previousSibling, g = t.nextSibling;
309
- return a.removeChild(t), r === "Backspace" ? (W(g, !0), V(a, c)) : (W(s, !1), V(a, c)), e && (Y(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
310
- }
311
- function se(t) {
312
- if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1) return null;
313
- const r = t.startContainer;
314
- if (!(r instanceof Element || r instanceof DocumentFragment)) return null;
315
- const e = r.childNodes[t.startOffset];
316
- return e instanceof HTMLElement && e.classList.contains("rte-merge-tag") ? e : null;
317
- }
318
- function de(t, r) {
319
- if (!t.collapsed) return null;
320
- const { startContainer: e, startOffset: n } = t, a = (l) => l instanceof HTMLElement && l.classList.contains("rte-merge-tag") ? l : null;
321
- if (e.nodeType === Node.ELEMENT_NODE) {
322
- const l = e;
323
- return r === "Backspace" && n > 0 ? a(l.childNodes[n - 1] || null) : r === "Delete" ? a(l.childNodes[n] || null) : null;
324
- }
325
- if (e.nodeType === Node.TEXT_NODE) {
326
- const l = e;
327
- return r === "Backspace" ? n === 0 ? a(l.previousSibling) : n === 1 && (l.data[0] === " " || l.data[0] === " ") && l.previousSibling instanceof HTMLElement && l.previousSibling.classList.contains("rte-merge-tag") ? l.previousSibling : null : n === l.data.length ? a(l.nextSibling) : null;
328
- }
329
- return null;
330
- }
331
- function G() {
332
- j || typeof document == "undefined" || (j = !0, document.addEventListener("click", (t) => {
333
- const r = t.target, e = r == null ? void 0 : r.closest(".rte-merge-tag");
334
- if (!e) return;
335
- const n = e.closest(w);
336
- n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), ce(e));
337
- }), document.addEventListener("keydown", (t) => {
338
- if (t.key !== "Backspace" && t.key !== "Delete") return;
339
- const r = window.getSelection();
340
- if (!r || r.rangeCount === 0) return;
341
- const e = r.getRangeAt(0), n = Z();
342
- if (!n || !n.contains(e.commonAncestorContainer)) return;
343
- let a = se(e);
344
- a || (a = de(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), ie(a, t.key));
345
- }));
346
- }
347
- function ge(t) {
348
- return t ? !!t.closest(ee) : !1;
349
- }
350
- function me() {
351
- T && (T(), T = null), L = null;
352
- }
353
- function J(t) {
354
- const r = document.createRange();
355
- return r.selectNodeContents(t), r.collapse(!1), r;
356
- }
357
- function ue(t, r) {
358
- const e = window.getSelection(), n = r ? r.cloneRange() : J(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : J(t);
359
- return e && (e.removeAllRanges(), e.addRange(l)), l;
360
- }
361
- function fe(t, r) {
362
- const e = document.createElement("span");
363
- 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);
364
- const n = r(t);
365
- return e.setAttribute("data-token", n), e.setAttribute("aria-label", `Merge tag: ${t.label}`), e.textContent = n, e;
366
- }
367
- function pe(t, r, e, n) {
368
- const a = window.getSelection();
369
- if (!a) return !1;
370
- const l = t.innerHTML;
371
- t.focus({ preventScroll: !0 });
372
- const c = ue(t, r), s = c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement, g = s == null ? void 0 : s.closest(".rte-merge-tag");
373
- g && t.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
374
- try {
375
- c.deleteContents();
376
- const i = fe(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
377
- u.appendChild(i), u.appendChild(b), c.insertNode(u);
378
- const p = document.createRange();
379
- return p.setStartAfter(b), p.collapse(!0), a.removeAllRanges(), a.addRange(p), Y(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
380
- } catch (i) {
381
- return console.error("Failed to insert merge tag:", i), !1;
382
- }
383
- }
384
- function be(t, r, e) {
385
- var l;
386
- const n = ((l = t.catalog.categoriesByKey[r]) == null ? void 0 : l.tags) || [], a = e.trim().toLowerCase();
387
- return a ? n.filter((c) => c.searchIndex.includes(a)) : n;
388
- }
389
- function ye(t, r) {
390
- var H;
391
- me(), I();
392
- const e = {
393
- category: r.catalog.defaultCategory,
394
- searchTerm: "",
395
- filteredTags: ((H = r.catalog.categoriesByKey[r.catalog.defaultCategory]) == null ? void 0 : H.tags) || [],
396
- selectedIndex: 0,
397
- savedRange: (() => {
398
- const o = window.getSelection();
399
- if (!o || o.rangeCount === 0) return null;
400
- const d = o.getRangeAt(0);
401
- return t.contains(d.commonAncestorContainer) ? d.cloneRange() : null;
402
- })(),
403
- searchRaf: null
404
- }, n = document.createElement("div");
405
- n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), ge(t) && n.classList.add("rte-ui-theme-dark");
406
- const a = document.createElement("div");
407
- a.className = "rte-merge-tag-dialog";
408
- const l = document.createElement("div");
409
- l.className = "rte-merge-tag-header";
410
- const c = document.createElement("h2");
411
- c.style.margin = "0", c.style.fontSize = "18px", c.style.fontWeight = "700", c.textContent = r.dialog.title;
412
- const s = document.createElement("button");
413
- s.className = "rte-merge-tag-close", s.setAttribute("aria-label", "Close"), s.style.background = "none", s.style.border = "none", s.style.color = "inherit", s.style.cursor = "pointer", s.style.fontSize = "20px", s.textContent = "✕", l.appendChild(c), l.appendChild(s);
414
- const g = document.createElement("div");
415
- g.className = "rte-merge-tag-body";
416
- const i = document.createElement("input");
417
- i.type = "text", i.className = "rte-merge-tag-input", i.placeholder = r.dialog.searchPlaceholder, i.setAttribute("aria-label", "Search merge tags");
418
- const b = document.createElement("div");
419
- b.className = "rte-merge-tag-tabs", r.catalog.categoryKeys.forEach((o) => {
420
- var f;
421
- const d = document.createElement("button");
422
- 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);
423
- });
424
- const u = document.createElement("div");
425
- u.className = "rte-merge-tag-list";
426
- const p = document.createElement("div");
427
- p.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(b), g.appendChild(u), g.appendChild(p);
428
- const v = document.createElement("div");
429
- v.className = "rte-merge-tag-footer";
430
- const y = document.createElement("button");
431
- y.type = "button", y.className = "rte-merge-tag-btn-secondary", y.textContent = r.dialog.cancelText;
432
- const x = document.createElement("button");
433
- x.type = "button", x.className = "rte-merge-tag-btn-primary", x.textContent = r.dialog.insertText, v.appendChild(y), v.appendChild(x), a.appendChild(l), a.appendChild(g), a.appendChild(v), n.appendChild(a), document.body.appendChild(n), L = n;
434
- const _ = () => {
435
- b.querySelectorAll(".rte-merge-tag-tab").forEach((d) => {
436
- const f = d.dataset.category === e.category;
437
- d.classList.toggle("active", f);
438
- });
439
- }, A = () => {
440
- if (e.filteredTags.length === 0) {
441
- e.selectedIndex = -1;
442
- return;
443
- }
444
- e.selectedIndex < 0 && (e.selectedIndex = 0), e.selectedIndex >= e.filteredTags.length && (e.selectedIndex = e.filteredTags.length - 1);
445
- }, O = () => {
446
- if (!r.dialog.showPreview) {
447
- p.style.display = "none", x.disabled = e.filteredTags.length === 0;
448
- return;
449
- }
450
- A();
451
- const o = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
452
- if (!o) {
453
- p.style.display = "none", x.disabled = !0;
454
- return;
455
- }
456
- p.style.display = "block", p.textContent = `Preview: ${r.formatToken(o)}`, x.disabled = !1;
457
- }, Q = () => {
458
- if (e.selectedIndex < 0) return;
459
- const o = u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`);
460
- o == null || o.scrollIntoView({ block: "nearest" });
461
- }, E = () => {
462
- const o = u.querySelector(".rte-merge-tag-item.selected");
463
- if (o == null || o.classList.remove("selected"), e.selectedIndex >= 0) {
464
- const d = u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`);
465
- d == null || d.classList.add("selected");
466
- }
467
- O(), Q();
468
- }, S = () => {
469
- 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) {
470
- const d = document.createElement("div");
471
- d.className = "rte-merge-tag-empty", d.textContent = r.dialog.emptyStateText, u.appendChild(d), O();
472
- return;
473
- }
474
- const o = document.createDocumentFragment();
475
- e.filteredTags.forEach((d, f) => {
476
- const m = document.createElement("div");
477
- m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(f)), m.classList.toggle("selected", f === e.selectedIndex);
478
- const D = document.createElement("div");
479
- if (D.className = "rte-merge-tag-item-label", D.textContent = d.label, m.appendChild(D), d.preview) {
480
- const M = document.createElement("div");
481
- M.className = "rte-merge-tag-item-preview", M.textContent = d.preview, m.appendChild(M);
482
- }
483
- o.appendChild(m);
484
- }), u.appendChild(o), E();
485
- }, z = () => {
486
- e.searchRaf !== null && cancelAnimationFrame(e.searchRaf), e.searchRaf = requestAnimationFrame(() => {
487
- e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, S();
488
- });
489
- }, h = () => {
490
- e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), L === n && (L = null, T = null);
491
- }, C = () => {
492
- if (A(), e.selectedIndex < 0) return;
493
- const o = e.filteredTags[e.selectedIndex];
494
- pe(t, e.savedRange, o, r.formatToken) && h();
495
- }, F = (o) => {
496
- const f = o.target.closest(".rte-merge-tag-tab");
497
- if (!f) return;
498
- const m = f.dataset.category;
499
- !m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, _(), S());
500
- }, U = (o) => {
501
- const f = o.target.closest(".rte-merge-tag-item");
502
- if (!f) return;
503
- const m = Number(f.dataset.index || "-1");
504
- Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, E());
505
- }, $ = (o) => {
506
- const f = o.target.closest(".rte-merge-tag-item");
507
- if (!f) return;
508
- const m = Number(f.dataset.index || "-1");
509
- Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, C());
510
- }, N = (o) => {
511
- if (o.key === "Escape") {
512
- o.preventDefault(), h();
513
- return;
514
- }
515
- if (o.key === "ArrowDown") {
516
- if (o.preventDefault(), e.filteredTags.length === 0) return;
517
- e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1), E();
518
- return;
519
- }
520
- if (o.key === "ArrowUp") {
521
- if (o.preventDefault(), e.filteredTags.length === 0) return;
522
- e.selectedIndex = Math.max(0, e.selectedIndex - 1), E();
523
- return;
524
- }
525
- o.key === "Enter" && (o.preventDefault(), C());
526
- }, P = (o) => {
527
- o.target === n && h();
528
- };
529
- b.addEventListener("click", F), u.addEventListener("click", U), u.addEventListener("dblclick", $), i.addEventListener("input", z), i.addEventListener("keydown", N), n.addEventListener("click", P), a.addEventListener("keydown", N), s == null || s.addEventListener("click", h), y.addEventListener("click", h), x.addEventListener("click", C), T = () => {
530
- b.removeEventListener("click", F), u.removeEventListener("click", U), u.removeEventListener("dblclick", $), i.removeEventListener("input", z), i.removeEventListener("keydown", N), n.removeEventListener("click", P), a.removeEventListener("keydown", N), s == null || s.removeEventListener("click", h), y.removeEventListener("click", h), x.removeEventListener("click", C), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
531
- }, _(), S(), setTimeout(() => {
532
- i.focus();
533
- }, 0);
534
- }
535
- const xe = (t) => ({
536
- name: "mergeTag",
537
- config: t,
538
- init: () => {
539
- I(), q(), G();
540
- },
541
- toolbar: [
542
- {
543
- label: "Merge Tag",
544
- command: "insertMergeTag",
545
- icon: "{{ }}"
546
- }
547
- ],
548
- commands: {
549
- insertMergeTag: () => {
550
- I(), q(), G();
551
- const r = Z();
552
- return r ? (ye(r, le(t)), !0) : !1;
553
- }
554
- }
555
- });
556
- export {
557
- xe as MergeTagPlugin
558
- };
559
- //# sourceMappingURL=MergeTagPlugin.native-C3eOfEgw.mjs.map