@editora/core 1.0.9 → 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 (99) hide show
  1. package/README.md +1 -1
  2. package/dist/{A11yCheckerPlugin.native-58d12bed.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +12 -23
  3. package/dist/{AnchorPlugin.native-289a112a.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +102 -112
  4. package/dist/{ApprovalWorkflowPlugin.native-449ce66c.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +173 -209
  5. package/dist/{BackgroundColorPlugin.native-8aceb5cc.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +9 -16
  6. package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
  7. package/dist/{BlocksLibraryPlugin.native-1cc51e63.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +149 -205
  8. package/dist/{BoldPlugin.native-f9d7f8e4.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
  9. package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
  10. package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
  11. package/dist/{CitationsPlugin.native-169fb1e8.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +196 -261
  12. package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
  13. package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
  14. package/dist/{CodeSamplePlugin.native-6cc0148e.mjs → CodeSamplePlugin.native-CgGoH-X4.mjs} +10 -19
  15. package/dist/{CommentsPlugin.native-03659874.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +28 -55
  16. package/dist/{ConditionalContentPlugin.native-4983143a.mjs → ConditionalContentPlugin.native-CfhY46rU.mjs} +51 -108
  17. package/dist/{ContentRulesPlugin.native-63ed405b.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +153 -200
  18. package/dist/{DataBindingPlugin.native-427e9d75.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +88 -124
  19. package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
  20. package/dist/{DocSchemaPlugin.native-8e41eda0.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +112 -166
  21. package/dist/{DocumentManagerPlugin.native-e69895ad.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +4 -4
  22. package/dist/EmbedIframePlugin.native-BF_-LjTq.mjs +740 -0
  23. package/dist/{EmojisPlugin.native-65c5ac47.mjs → EmojisPlugin.native-CitxxlWX.mjs} +6 -11
  24. package/dist/{FontFamilyPlugin.native-f9bc255a.mjs → FontFamilyPlugin.native-j8hMTbg4.mjs} +4 -7
  25. package/dist/{FontSizePlugin.native-f5647872.mjs → FontSizePlugin.native-B_jCh7dY.mjs} +10 -19
  26. package/dist/{FootnotePlugin.native-494657b3.mjs → FootnotePlugin.native-D730OGRm.mjs} +39 -77
  27. package/dist/{FullscreenPlugin.native-87ce92e9.mjs → FullscreenPlugin.native-ChXyxeNw.mjs} +1 -1
  28. package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
  29. package/dist/{HistoryPlugin.native-92ed4be4.mjs → HistoryPlugin.native-D2wl32jV.mjs} +107 -143
  30. package/dist/{IndentPlugin.native-e4ee902b.mjs → IndentPlugin.native-BHixp8sP.mjs} +12 -23
  31. package/dist/{ItalicPlugin.native-7c95cfbc.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
  32. package/dist/{LineHeightPlugin.native-5668f78c.mjs → LineHeightPlugin.native-CM7iXdQj.mjs} +10 -19
  33. package/dist/{LinkPlugin.native-6df29111.mjs → LinkPlugin.native-DYCIcdTm.mjs} +5 -9
  34. package/dist/{ListPlugin.native-fe2e115a.mjs → ListPlugin.native-V7EZC1lM.mjs} +5 -9
  35. package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
  36. package/dist/{MediaManagerPlugin.native-3cf48a00.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +11 -21
  37. package/dist/{MentionPlugin.native-3b1e8c05.mjs → MentionPlugin.native-BMDlOqur.mjs} +45 -89
  38. package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
  39. package/dist/{PIIRedactionPlugin.native-7ab10b9f.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +210 -260
  40. package/dist/{PageBreakPlugin.native-1794c5fb.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +16 -31
  41. package/dist/{PreviewPlugin.native-f7b67cc0.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +6 -11
  42. package/dist/{PrintPlugin.native-f6a168c2.mjs → PrintPlugin.native-7qt5v7L5.mjs} +3 -5
  43. package/dist/{SlashCommandsPlugin.native-8d45e511.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +36 -71
  44. package/dist/{SmartPastePlugin.native-a6c5efec.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +173 -219
  45. package/dist/{SpecialCharactersPlugin.native-7f06d4ba.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +101 -85
  46. package/dist/{SpellCheckPlugin.native-04e20834.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +21 -41
  47. package/dist/{StrikethroughPlugin.native-905e9501.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -30
  48. package/dist/{TablePlugin.native-7d5458c1.mjs → TablePlugin.native-DrHX-efe.mjs} +30 -58
  49. package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
  50. package/dist/{TextAlignmentPlugin.native-9357b3ed.mjs → TextAlignmentPlugin.native-sM_1s00t.mjs} +6 -11
  51. package/dist/{TextColorPlugin.native-d53ed459.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +14 -26
  52. package/dist/{TrackChangesPlugin.native-e96da509.mjs → TrackChangesPlugin.native-Bghu2q4a.mjs} +58 -115
  53. package/dist/{TranslationWorkflowPlugin.native-4e711b1e.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +191 -257
  54. package/dist/{UnderlinePlugin.native-8080c998.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
  55. package/dist/{VersionDiffPlugin.native-5bbeff85.mjs → VersionDiffPlugin.native-Bvxgy--t.mjs} +26 -51
  56. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  57. package/dist/{anchoredPopover-5cca53ba.mjs → anchoredPopover-Bxds0VoB.mjs} +1 -1
  58. package/dist/core.css +1 -0
  59. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  60. package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +2 -3
  61. package/dist/editora.min.js +13 -14
  62. package/dist/editora.umd.js +13 -14
  63. package/dist/{html2canvas.esm-c51cb3b9.mjs → html2canvas.esm-AYkPY5LS.mjs} +894 -978
  64. package/dist/index-BslAFzmv.mjs +16544 -0
  65. package/dist/index-CPMGUZfB.js +10 -0
  66. package/dist/{index-7da30697.mjs → index-DBoj6QfW.mjs} +127 -164
  67. package/dist/index.cjs.js +1 -1
  68. package/dist/index.es-BYD2KEo6.mjs +6666 -0
  69. package/dist/index.esm.js +7 -12
  70. package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
  71. package/dist/{jspdf.es.min-780c82db.mjs → jspdf.es.min-BJGtOnRT.mjs} +3784 -4808
  72. package/dist/plugin-loader.js +67 -67
  73. package/dist/{purify.es-3bdbcfc5.mjs → purify.es-CKpwg8Tk.mjs} +10 -20
  74. package/dist/webcomponent-core.js +131 -168
  75. package/dist/webcomponent-core.min.css +1 -1
  76. package/dist/webcomponent-core.min.js +139 -63
  77. package/dist/webcomponent.cjs.js +1 -1
  78. package/dist/webcomponent.esm.js +1 -1
  79. package/dist/webcomponent.js +191 -228
  80. package/dist/webcomponent.min.css +1 -1
  81. package/dist/webcomponent.min.js +1240 -1344
  82. package/package.json +1 -1
  83. package/dist/BlockquotePlugin.native-3541c714.mjs +0 -49
  84. package/dist/CapitalizationPlugin.native-42c135dc.mjs +0 -80
  85. package/dist/ChecklistPlugin.native-3b397ee9.mjs +0 -330
  86. package/dist/ClearFormattingPlugin.native-77baa514.mjs +0 -145
  87. package/dist/CodePlugin.native-989cf0aa.mjs +0 -2740
  88. package/dist/DirectionPlugin.native-4e742f42.mjs +0 -139
  89. package/dist/EmbedIframePlugin.native-55209c87.mjs +0 -568
  90. package/dist/HeadingPlugin.native-e38c4a16.mjs +0 -64
  91. package/dist/MathPlugin.native-735bbac2.mjs +0 -296
  92. package/dist/MergeTagPlugin.native-31cf7d48.mjs +0 -584
  93. package/dist/TemplatePlugin.native-580f0f63.mjs +0 -617
  94. package/dist/_commonjsHelpers-69d58be2.mjs +0 -31
  95. package/dist/documentManager-8327fb6e.mjs +0 -9166
  96. package/dist/index-072ef022.js +0 -11
  97. package/dist/index-49d31221.mjs +0 -16860
  98. package/dist/index.es-b47a189f.mjs +0 -5782
  99. package/dist/style.css +0 -1
@@ -0,0 +1,580 @@
1
+ const T = ".rte-content, .editora-content", re = '[data-theme="dark"], .dark, .editora-theme-dark', ne = {
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 ae() {
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 I(e, r) {
50
+ return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `CATEGORY_${r + 1}`;
51
+ }
52
+ function oe(e, r) {
53
+ return (e.key || e.value || e.label).trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `tag_${r + 1}`;
54
+ }
55
+ function le(e) {
56
+ const r = (() => {
57
+ if (Array.isArray(e == null ? void 0 : e.categories) && e.categories.length > 0)
58
+ return e.categories;
59
+ if (Array.isArray(e == null ? void 0 : e.tags) && e.tags.length > 0) {
60
+ const c = /* @__PURE__ */ new Map();
61
+ return e.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: I(s, i),
66
+ name: s,
67
+ tags: g
68
+ }));
69
+ }
70
+ return ae();
71
+ })(), t = {}, n = [];
72
+ if (r.forEach((c, s) => {
73
+ const g = I(c.id || c.name, s);
74
+ n.push(g), t[g] = {
75
+ name: c.name,
76
+ tags: (Array.isArray(c.tags) ? c.tags : []).map((i, y) => {
77
+ var h, x;
78
+ const u = oe(i, y), 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} ${(h = i.description) != null ? h : ""} ${(x = i.value) != null ? x : ""}`.toLowerCase()
85
+ };
86
+ })
87
+ };
88
+ }), n.length === 0) {
89
+ const c = "CUSTOM";
90
+ n.push(c), t[c] = { name: "Custom", tags: [] };
91
+ }
92
+ const a = e != null && e.defaultCategory ? I(e.defaultCategory, 0) : null, o = a && n.includes(a) ? a : n[0];
93
+ return {
94
+ categoriesByKey: t,
95
+ categoryKeys: n,
96
+ defaultCategory: o
97
+ };
98
+ }
99
+ function ce(e) {
100
+ const r = e == null ? void 0 : e.tokenTemplate;
101
+ return typeof r == "function" ? (t) => {
102
+ var a;
103
+ const n = r(t);
104
+ return typeof n == "string" && n.trim() ? n : ((a = t.value) == null ? void 0 : a.trim()) || `{{ ${t.label} }}`;
105
+ } : typeof r == "string" && r.trim() ? (t) => {
106
+ var n;
107
+ return r.replace(/\{key\}/gi, t.key).replace(/\{label\}/gi, t.label).replace(/\{category\}/gi, t.category).replace(/\{value\}/gi, (n = t.value) != null ? n : "");
108
+ } : (t) => {
109
+ var n;
110
+ return ((n = t.value) == null ? void 0 : n.trim()) || `{{ ${t.label} }}`;
111
+ };
112
+ }
113
+ function ie(e) {
114
+ return {
115
+ catalog: le(e),
116
+ dialog: {
117
+ ...ne,
118
+ ...(e == null ? void 0 : e.dialog) || {}
119
+ },
120
+ formatToken: ce(e)
121
+ };
122
+ }
123
+ let B = !1, q = !1, k = null, A = null, E = null, W = !1, b = null;
124
+ function Z(e, r) {
125
+ if (r === e.innerHTML) return;
126
+ const t = window.execEditorCommand || window.executeEditorCommand;
127
+ if (typeof t == "function")
128
+ try {
129
+ t("recordDomTransaction", e, r, e.innerHTML);
130
+ } catch (n) {
131
+ }
132
+ }
133
+ function _() {
134
+ if (B || typeof document == "undefined") return;
135
+ B = !0;
136
+ const e = document.createElement("style");
137
+ e.id = "merge-tag-plugin-styles", e.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
+ .rte-merge-tag.rte-merge-tag-selected {
257
+ outline: 2px solid #2563eb;
258
+ outline-offset: 2px;
259
+ box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
260
+ }
261
+
262
+ :is([data-theme="dark"], .dark, .editora-theme-dark) .rte-merge-tag {
263
+ background: #223247;
264
+ border-color: #3f5f84;
265
+ color: #8dc4ff;
266
+ }
267
+ `, document.head.appendChild(e);
268
+ }
269
+ function V() {
270
+ q || typeof document == "undefined" || (q = !0, document.addEventListener("focusin", (e) => {
271
+ const r = e.target, t = r == null ? void 0 : r.closest(T);
272
+ t && (k = t);
273
+ }), document.addEventListener("selectionchange", () => {
274
+ const e = Q();
275
+ e && (k = e);
276
+ }));
277
+ }
278
+ function Q() {
279
+ const e = window.getSelection();
280
+ if (!e || e.rangeCount === 0) return null;
281
+ const t = e.getRangeAt(0).startContainer, n = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
282
+ return (n == null ? void 0 : n.closest(T)) || null;
283
+ }
284
+ function ee() {
285
+ const e = Q();
286
+ if (e) return e;
287
+ const r = document.activeElement, t = r == null ? void 0 : r.closest(T);
288
+ return t || (k != null && k.isConnected ? k : document.querySelector(T));
289
+ }
290
+ function O() {
291
+ b && (b.classList.remove("rte-merge-tag-selected"), b.removeAttribute("data-rte-selected-object"), b = null);
292
+ }
293
+ function se(e) {
294
+ b !== e && (O(), b = e, e.classList.add("rte-merge-tag-selected"), e.setAttribute("data-rte-selected-object", "true")), de(e);
295
+ }
296
+ function de(e) {
297
+ const r = e.parentNode;
298
+ if (!r) return;
299
+ const t = window.getSelection();
300
+ if (!t) return;
301
+ const n = document.createRange(), o = Array.from(r.childNodes).indexOf(e);
302
+ o < 0 || (n.setStart(r, o), n.setEnd(r, o + 1), t.removeAllRanges(), t.addRange(n));
303
+ }
304
+ function G(e, r) {
305
+ var t;
306
+ e instanceof Text && e.data.length !== 0 && (r ? (e.data.startsWith(" ") || e.data.startsWith(" ")) && e.deleteData(0, 1) : (e.data.endsWith(" ") || e.data.endsWith(" ")) && e.deleteData(e.data.length - 1, 1), e.data.length === 0 && ((t = e.parentNode) == null || t.removeChild(e)));
307
+ }
308
+ function J(e, r) {
309
+ const t = window.getSelection();
310
+ if (!t) return;
311
+ const n = document.createRange(), a = Math.max(0, Math.min(r, e.childNodes.length));
312
+ n.setStart(e, a), n.collapse(!0), t.removeAllRanges(), t.addRange(n);
313
+ }
314
+ function ge(e, r) {
315
+ var i;
316
+ const t = e.closest(T), n = (i = t == null ? void 0 : t.innerHTML) != null ? i : "", a = e.parentNode;
317
+ if (!a) return !1;
318
+ const c = Array.from(a.childNodes).indexOf(e);
319
+ if (c < 0) return !1;
320
+ const s = e.previousSibling, g = e.nextSibling;
321
+ return a.removeChild(e), b === e && (b = null), r === "Backspace" ? (G(g, !0), J(a, c)) : (G(s, !1), J(a, c)), t && (Z(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
322
+ }
323
+ function me(e) {
324
+ if (e.collapsed || !(e.startContainer instanceof HTMLElement || e.startContainer instanceof Text) || e.startContainer !== e.endContainer || e.endOffset !== e.startOffset + 1) return null;
325
+ const r = e.startContainer;
326
+ if (!(r instanceof Element || r instanceof DocumentFragment)) return null;
327
+ const t = r.childNodes[e.startOffset];
328
+ return t instanceof HTMLElement && t.classList.contains("rte-merge-tag") ? t : null;
329
+ }
330
+ function ue(e, r) {
331
+ if (!e.collapsed) return null;
332
+ const { startContainer: t, startOffset: n } = e, a = (o) => o instanceof HTMLElement && o.classList.contains("rte-merge-tag") ? o : null;
333
+ if (t.nodeType === Node.ELEMENT_NODE) {
334
+ const o = t;
335
+ return r === "Backspace" && n > 0 ? a(o.childNodes[n - 1] || null) : r === "Delete" ? a(o.childNodes[n] || null) : null;
336
+ }
337
+ if (t.nodeType === Node.TEXT_NODE) {
338
+ const o = t;
339
+ return r === "Backspace" ? n === 0 ? a(o.previousSibling) : n === 1 && (o.data[0] === " " || o.data[0] === " ") && o.previousSibling instanceof HTMLElement && o.previousSibling.classList.contains("rte-merge-tag") ? o.previousSibling : null : n === o.data.length ? a(o.nextSibling) : null;
340
+ }
341
+ return null;
342
+ }
343
+ function Y() {
344
+ W || typeof document == "undefined" || (W = !0, document.addEventListener("pointerdown", (e) => {
345
+ var a;
346
+ const r = e.target, t = r == null ? void 0 : r.closest(".rte-merge-tag");
347
+ if (!t) {
348
+ const o = e.target;
349
+ (a = o == null ? void 0 : o.closest) != null && a.call(o, ".rte-merge-tag-overlay") || O();
350
+ return;
351
+ }
352
+ const n = t.closest(T);
353
+ n && (e.preventDefault(), e.stopPropagation(), n.focus({ preventScroll: !0 }), se(t));
354
+ }, !0), document.addEventListener("keydown", (e) => {
355
+ if (e.key === "Escape" && b) {
356
+ O();
357
+ return;
358
+ }
359
+ if (e.key !== "Backspace" && e.key !== "Delete") return;
360
+ const r = window.getSelection();
361
+ if (!r || r.rangeCount === 0) return;
362
+ const t = r.getRangeAt(0), n = ee();
363
+ if (!n || !n.contains(t.commonAncestorContainer)) return;
364
+ let a = b != null && b.isConnected ? b : null;
365
+ a && !n.contains(a) && (a = null), a || (a = me(t)), a || (a = ue(t, e.key)), a && (e.preventDefault(), e.stopPropagation(), ge(a, e.key));
366
+ }));
367
+ }
368
+ function fe(e) {
369
+ return e ? !!e.closest(re) : !1;
370
+ }
371
+ function pe() {
372
+ E && (E(), E = null), A = null;
373
+ }
374
+ function X(e) {
375
+ const r = document.createRange();
376
+ return r.selectNodeContents(e), r.collapse(!1), r;
377
+ }
378
+ function be(e, r) {
379
+ const t = window.getSelection(), n = r ? r.cloneRange() : X(e), o = n.startContainer.isConnected && n.endContainer.isConnected && e.contains(n.commonAncestorContainer) ? n : X(e);
380
+ return t && (t.removeAllRanges(), t.addRange(o)), o;
381
+ }
382
+ function ye(e, r) {
383
+ const t = document.createElement("span");
384
+ t.className = "rte-merge-tag", t.setAttribute("contenteditable", "false"), t.setAttribute("data-key", e.key), t.setAttribute("data-category", e.category), t.setAttribute("data-label", e.label), e.value && t.setAttribute("data-value", e.value);
385
+ const n = r(e);
386
+ return t.setAttribute("data-token", n), t.setAttribute("aria-label", `Merge tag: ${e.label}`), t.textContent = n, t;
387
+ }
388
+ function xe(e, r, t, n) {
389
+ const a = window.getSelection();
390
+ if (!a) return !1;
391
+ const o = e.innerHTML;
392
+ e.focus({ preventScroll: !0 });
393
+ const c = be(e, r), s = c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement, g = s == null ? void 0 : s.closest(".rte-merge-tag");
394
+ g && e.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
395
+ try {
396
+ c.deleteContents();
397
+ const i = ye(t, n), y = document.createTextNode(" "), u = document.createDocumentFragment();
398
+ u.appendChild(i), u.appendChild(y), c.insertNode(u);
399
+ const p = document.createRange();
400
+ return p.setStartAfter(y), p.collapse(!0), a.removeAllRanges(), a.addRange(p), Z(e, o), e.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
401
+ } catch (i) {
402
+ return console.error("Failed to insert merge tag:", i), !1;
403
+ }
404
+ }
405
+ function ve(e, r, t) {
406
+ var o;
407
+ const n = ((o = e.catalog.categoriesByKey[r]) == null ? void 0 : o.tags) || [], a = t.trim().toLowerCase();
408
+ return a ? n.filter((c) => c.searchIndex.includes(a)) : n;
409
+ }
410
+ function he(e, r) {
411
+ var j;
412
+ pe(), _();
413
+ const t = {
414
+ category: r.catalog.defaultCategory,
415
+ searchTerm: "",
416
+ filteredTags: ((j = r.catalog.categoriesByKey[r.catalog.defaultCategory]) == null ? void 0 : j.tags) || [],
417
+ selectedIndex: 0,
418
+ savedRange: (() => {
419
+ const l = window.getSelection();
420
+ if (!l || l.rangeCount === 0) return null;
421
+ const d = l.getRangeAt(0);
422
+ return e.contains(d.commonAncestorContainer) ? d.cloneRange() : null;
423
+ })(),
424
+ searchRaf: null
425
+ }, n = document.createElement("div");
426
+ n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), fe(e) && n.classList.add("rte-ui-theme-dark");
427
+ const a = document.createElement("div");
428
+ a.className = "rte-merge-tag-dialog";
429
+ const o = document.createElement("div");
430
+ o.className = "rte-merge-tag-header";
431
+ const c = document.createElement("h2");
432
+ c.style.margin = "0", c.style.fontSize = "18px", c.style.fontWeight = "700", c.textContent = r.dialog.title;
433
+ const s = document.createElement("button");
434
+ 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 = "✕", o.appendChild(c), o.appendChild(s);
435
+ const g = document.createElement("div");
436
+ g.className = "rte-merge-tag-body";
437
+ const i = document.createElement("input");
438
+ i.type = "text", i.className = "rte-merge-tag-input", i.placeholder = r.dialog.searchPlaceholder, i.setAttribute("aria-label", "Search merge tags");
439
+ const y = document.createElement("div");
440
+ y.className = "rte-merge-tag-tabs", r.catalog.categoryKeys.forEach((l) => {
441
+ var f;
442
+ const d = document.createElement("button");
443
+ d.type = "button", d.className = "rte-merge-tag-tab", d.setAttribute("data-category", l), d.textContent = ((f = r.catalog.categoriesByKey[l]) == null ? void 0 : f.name) || l, y.appendChild(d);
444
+ });
445
+ const u = document.createElement("div");
446
+ u.className = "rte-merge-tag-list";
447
+ const p = document.createElement("div");
448
+ p.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(y), g.appendChild(u), g.appendChild(p);
449
+ const h = document.createElement("div");
450
+ h.className = "rte-merge-tag-footer";
451
+ const x = document.createElement("button");
452
+ x.type = "button", x.className = "rte-merge-tag-btn-secondary", x.textContent = r.dialog.cancelText;
453
+ const v = document.createElement("button");
454
+ v.type = "button", v.className = "rte-merge-tag-btn-primary", v.textContent = r.dialog.insertText, h.appendChild(x), h.appendChild(v), a.appendChild(o), a.appendChild(g), a.appendChild(h), n.appendChild(a), document.body.appendChild(n), A = n;
455
+ const z = () => {
456
+ y.querySelectorAll(".rte-merge-tag-tab").forEach((d) => {
457
+ const f = d.dataset.category === t.category;
458
+ d.classList.toggle("active", f);
459
+ });
460
+ }, S = () => {
461
+ if (t.filteredTags.length === 0) {
462
+ t.selectedIndex = -1;
463
+ return;
464
+ }
465
+ t.selectedIndex < 0 && (t.selectedIndex = 0), t.selectedIndex >= t.filteredTags.length && (t.selectedIndex = t.filteredTags.length - 1);
466
+ }, F = () => {
467
+ if (!r.dialog.showPreview) {
468
+ p.style.display = "none", v.disabled = t.filteredTags.length === 0;
469
+ return;
470
+ }
471
+ S();
472
+ const l = t.selectedIndex >= 0 ? t.filteredTags[t.selectedIndex] : null;
473
+ if (!l) {
474
+ p.style.display = "none", v.disabled = !0;
475
+ return;
476
+ }
477
+ p.style.display = "block", p.textContent = `Preview: ${r.formatToken(l)}`, v.disabled = !1;
478
+ }, te = () => {
479
+ if (t.selectedIndex < 0) return;
480
+ const l = u.querySelector(`.rte-merge-tag-item[data-index="${t.selectedIndex}"]`);
481
+ l == null || l.scrollIntoView({ block: "nearest" });
482
+ }, C = () => {
483
+ const l = u.querySelector(".rte-merge-tag-item.selected");
484
+ if (l == null || l.classList.remove("selected"), t.selectedIndex >= 0) {
485
+ const d = u.querySelector(`.rte-merge-tag-item[data-index="${t.selectedIndex}"]`);
486
+ d == null || d.classList.add("selected");
487
+ }
488
+ F(), te();
489
+ }, D = () => {
490
+ if (t.filteredTags = ve(r, t.category, t.searchTerm), t.filteredTags.length > 0 && t.selectedIndex < 0 && (t.selectedIndex = 0), S(), u.innerHTML = "", t.filteredTags.length === 0) {
491
+ const d = document.createElement("div");
492
+ d.className = "rte-merge-tag-empty", d.textContent = r.dialog.emptyStateText, u.appendChild(d), F();
493
+ return;
494
+ }
495
+ const l = document.createDocumentFragment();
496
+ t.filteredTags.forEach((d, f) => {
497
+ const m = document.createElement("div");
498
+ m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(f)), m.classList.toggle("selected", f === t.selectedIndex);
499
+ const M = document.createElement("div");
500
+ if (M.className = "rte-merge-tag-item-label", M.textContent = d.label, m.appendChild(M), d.preview) {
501
+ const R = document.createElement("div");
502
+ R.className = "rte-merge-tag-item-preview", R.textContent = d.preview, m.appendChild(R);
503
+ }
504
+ l.appendChild(m);
505
+ }), u.appendChild(l), C();
506
+ }, U = () => {
507
+ t.searchRaf !== null && cancelAnimationFrame(t.searchRaf), t.searchRaf = requestAnimationFrame(() => {
508
+ t.searchRaf = null, t.searchTerm = i.value, t.selectedIndex = 0, D();
509
+ });
510
+ }, w = () => {
511
+ t.searchRaf !== null && (cancelAnimationFrame(t.searchRaf), t.searchRaf = null), n.remove(), A === n && (A = null, E = null);
512
+ }, N = () => {
513
+ if (S(), t.selectedIndex < 0) return;
514
+ const l = t.filteredTags[t.selectedIndex];
515
+ xe(e, t.savedRange, l, r.formatToken) && w();
516
+ }, $ = (l) => {
517
+ const f = l.target.closest(".rte-merge-tag-tab");
518
+ if (!f) return;
519
+ const m = f.dataset.category;
520
+ !m || !r.catalog.categoriesByKey[m] || (t.category = m, t.searchTerm = "", i.value = "", t.selectedIndex = 0, z(), D());
521
+ }, P = (l) => {
522
+ const f = l.target.closest(".rte-merge-tag-item");
523
+ if (!f) return;
524
+ const m = Number(f.dataset.index || "-1");
525
+ Number.isNaN(m) || m < 0 || m >= t.filteredTags.length || (t.selectedIndex = m, C());
526
+ }, H = (l) => {
527
+ const f = l.target.closest(".rte-merge-tag-item");
528
+ if (!f) return;
529
+ const m = Number(f.dataset.index || "-1");
530
+ Number.isNaN(m) || m < 0 || m >= t.filteredTags.length || (t.selectedIndex = m, N());
531
+ }, L = (l) => {
532
+ if (l.key === "Escape") {
533
+ l.preventDefault(), w();
534
+ return;
535
+ }
536
+ if (l.key === "ArrowDown") {
537
+ if (l.preventDefault(), t.filteredTags.length === 0) return;
538
+ t.selectedIndex = Math.min(t.filteredTags.length - 1, t.selectedIndex + 1), C();
539
+ return;
540
+ }
541
+ if (l.key === "ArrowUp") {
542
+ if (l.preventDefault(), t.filteredTags.length === 0) return;
543
+ t.selectedIndex = Math.max(0, t.selectedIndex - 1), C();
544
+ return;
545
+ }
546
+ l.key === "Enter" && (l.preventDefault(), N());
547
+ }, K = (l) => {
548
+ l.target === n && w();
549
+ };
550
+ y.addEventListener("click", $), u.addEventListener("click", P), u.addEventListener("dblclick", H), i.addEventListener("input", U), i.addEventListener("keydown", L), n.addEventListener("click", K), a.addEventListener("keydown", L), s == null || s.addEventListener("click", w), x.addEventListener("click", w), v.addEventListener("click", N), E = () => {
551
+ y.removeEventListener("click", $), u.removeEventListener("click", P), u.removeEventListener("dblclick", H), i.removeEventListener("input", U), i.removeEventListener("keydown", L), n.removeEventListener("click", K), a.removeEventListener("keydown", L), s == null || s.removeEventListener("click", w), x.removeEventListener("click", w), v.removeEventListener("click", N), t.searchRaf !== null && (cancelAnimationFrame(t.searchRaf), t.searchRaf = null), n.remove();
552
+ }, z(), D(), setTimeout(() => {
553
+ i.focus();
554
+ }, 0);
555
+ }
556
+ const we = (e) => ({
557
+ name: "mergeTag",
558
+ config: e,
559
+ init: () => {
560
+ _(), V(), Y();
561
+ },
562
+ toolbar: [
563
+ {
564
+ label: "Merge Tag",
565
+ command: "insertMergeTag",
566
+ icon: "{{ }}"
567
+ }
568
+ ],
569
+ commands: {
570
+ insertMergeTag: () => {
571
+ _(), V(), Y();
572
+ const r = ee();
573
+ return r ? (he(r, ie(e)), !0) : !1;
574
+ }
575
+ }
576
+ });
577
+ export {
578
+ we as MergeTagPlugin
579
+ };
580
+ //# sourceMappingURL=MergeTagPlugin.native-BzRVoD9-.mjs.map