@editora/plugins 1.0.6 → 1.0.8
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 +57 -4
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/anchor.cjs.js +11 -11
- package/dist/anchor.esm.js +130 -107
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/background-color.cjs.js +3 -3
- package/dist/background-color.esm.js +116 -119
- package/dist/code.cjs.js +82 -102
- package/dist/code.esm.js +1172 -662
- package/dist/comments.cjs.js +10 -10
- package/dist/comments.esm.js +195 -177
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/embed-iframe.cjs.js +2 -2
- package/dist/embed-iframe.esm.js +8 -5
- package/dist/emojis.cjs.js +64 -39
- package/dist/emojis.esm.js +133 -104
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
- package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
- package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
- package/dist/index.esm.js +87 -79
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
- package/dist/link.cjs.js +6 -6
- package/dist/link.esm.js +41 -39
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +151 -112
- package/dist/media-manager.cjs.js +15 -15
- package/dist/media-manager.esm.js +227 -206
- package/dist/merge-tag.cjs.js +44 -12
- package/dist/merge-tag.esm.js +368 -241
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +77 -69
- package/dist/special-characters.cjs.js +83 -45
- package/dist/special-characters.esm.js +149 -100
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +235 -216
- package/dist/template.cjs.js +14 -14
- package/dist/template.esm.js +157 -131
- package/dist/text-color.cjs.js +9 -9
- package/dist/text-color.esm.js +131 -115
- package/index.d.ts +51 -1
- package/package.json +6 -4
- package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
- package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
- package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
- package/dist/documentManager-_tQQfQi9.js +0 -317
- package/dist/index-D3pJyAsj.js +0 -1
package/dist/merge-tag.esm.js
CHANGED
|
@@ -1,47 +1,130 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
const h = ".rte-content, .editora-content", Q = '[data-theme="dark"], .dark, .editora-theme-dark', ee = {
|
|
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 te() {
|
|
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 M(t, r) {
|
|
50
|
+
return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `CATEGORY_${r + 1}`;
|
|
51
|
+
}
|
|
52
|
+
function re(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 ne(t) {
|
|
56
|
+
const r = (() => {
|
|
57
|
+
if (Array.isArray(t?.categories) && t.categories.length > 0)
|
|
58
|
+
return t.categories;
|
|
59
|
+
if (Array.isArray(t?.tags) && t.tags.length > 0) {
|
|
60
|
+
const c = /* @__PURE__ */ new Map();
|
|
61
|
+
return t.tags.forEach((d) => {
|
|
62
|
+
const g = (d.category || "Custom").trim() || "Custom", i = c.get(g);
|
|
63
|
+
i ? i.push(d) : c.set(g, [d]);
|
|
64
|
+
}), Array.from(c.entries()).map(([d, g], i) => ({
|
|
65
|
+
id: M(d, i),
|
|
66
|
+
name: d,
|
|
67
|
+
tags: g
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
return te();
|
|
71
|
+
})(), e = {}, n = [];
|
|
72
|
+
if (r.forEach((c, d) => {
|
|
73
|
+
const g = M(c.id || c.name, d);
|
|
74
|
+
n.push(g), e[g] = {
|
|
75
|
+
name: c.name,
|
|
76
|
+
tags: (Array.isArray(c.tags) ? c.tags : []).map((i, b) => {
|
|
77
|
+
const u = re(i, b), f = (i.category || c.name).trim() || c.name;
|
|
78
|
+
return {
|
|
79
|
+
...i,
|
|
80
|
+
key: u,
|
|
81
|
+
category: f,
|
|
82
|
+
categoryKey: g,
|
|
83
|
+
searchIndex: `${i.label} ${u} ${f} ${i.description ?? ""} ${i.value ?? ""}`.toLowerCase()
|
|
84
|
+
};
|
|
85
|
+
})
|
|
86
|
+
};
|
|
87
|
+
}), n.length === 0) {
|
|
88
|
+
const c = "CUSTOM";
|
|
89
|
+
n.push(c), e[c] = { name: "Custom", tags: [] };
|
|
33
90
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
91
|
+
const a = t?.defaultCategory ? M(t.defaultCategory, 0) : null, l = a && n.includes(a) ? a : n[0];
|
|
92
|
+
return {
|
|
93
|
+
categoriesByKey: e,
|
|
94
|
+
categoryKeys: n,
|
|
95
|
+
defaultCategory: l
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function ae(t) {
|
|
99
|
+
const r = t?.tokenTemplate;
|
|
100
|
+
return typeof r == "function" ? (e) => {
|
|
101
|
+
const n = r(e);
|
|
102
|
+
return typeof n == "string" && n.trim() ? n : e.value?.trim() || `{{ ${e.label} }}`;
|
|
103
|
+
} : typeof r == "string" && r.trim() ? (e) => r.replace(/\{key\}/gi, e.key).replace(/\{label\}/gi, e.label).replace(/\{category\}/gi, e.category).replace(/\{value\}/gi, e.value ?? "") : (e) => e.value?.trim() || `{{ ${e.label} }}`;
|
|
104
|
+
}
|
|
105
|
+
function oe(t) {
|
|
106
|
+
return {
|
|
107
|
+
catalog: ne(t),
|
|
108
|
+
dialog: {
|
|
109
|
+
...ee,
|
|
110
|
+
...t?.dialog || {}
|
|
111
|
+
},
|
|
112
|
+
formatToken: ae(t)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
let K = !1, P = !1, S = null, N = null, E = null, H = !1;
|
|
116
|
+
function J(t, r) {
|
|
117
|
+
if (r === t.innerHTML) return;
|
|
118
|
+
const e = window.execEditorCommand || window.executeEditorCommand;
|
|
119
|
+
if (typeof e == "function")
|
|
120
|
+
try {
|
|
121
|
+
e("recordDomTransaction", t, r, t.innerHTML);
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function R() {
|
|
126
|
+
if (K || typeof document > "u") return;
|
|
127
|
+
K = !0;
|
|
45
128
|
const t = document.createElement("style");
|
|
46
129
|
t.id = "merge-tag-plugin-styles", t.textContent = `
|
|
47
130
|
.rte-merge-tag-overlay {
|
|
@@ -93,19 +176,54 @@ function A() {
|
|
|
93
176
|
}
|
|
94
177
|
|
|
95
178
|
.rte-merge-tag-header { padding: 16px; border-bottom: 1px solid var(--rte-mt-border); display:flex; justify-content:space-between; align-items:center; }
|
|
96
|
-
.rte-merge-tag-body {
|
|
97
|
-
|
|
98
|
-
|
|
179
|
+
.rte-merge-tag-body {
|
|
180
|
+
padding: 16px;
|
|
181
|
+
flex: 1;
|
|
182
|
+
min-height: 0;
|
|
183
|
+
display: flex;
|
|
184
|
+
flex-direction: column;
|
|
185
|
+
overflow: hidden;
|
|
186
|
+
}
|
|
187
|
+
.rte-merge-tag-input {
|
|
188
|
+
width:100%;
|
|
189
|
+
padding:11px 12px;
|
|
190
|
+
border:1px solid var(--rte-mt-border);
|
|
191
|
+
border-radius:6px;
|
|
192
|
+
background:var(--rte-mt-subtle-bg);
|
|
193
|
+
color:var(--rte-mt-dialog-text);
|
|
194
|
+
font-size:14px;
|
|
195
|
+
line-height:1.45;
|
|
196
|
+
box-sizing:border-box;
|
|
197
|
+
}
|
|
198
|
+
.rte-merge-tag-tabs { display:flex; flex-wrap: wrap; gap:8px; margin: 12px 0; }
|
|
99
199
|
.rte-merge-tag-tab { padding:8px 12px; background:none; border:none; cursor:pointer; color:var(--rte-mt-muted-text); border-bottom:3px solid transparent; }
|
|
100
200
|
.rte-merge-tag-tab.active { color:var(--rte-mt-accent); border-bottom-color:var(--rte-mt-accent); }
|
|
101
|
-
.rte-merge-tag-list {
|
|
102
|
-
|
|
201
|
+
.rte-merge-tag-list {
|
|
202
|
+
border:1px solid var(--rte-mt-border);
|
|
203
|
+
border-radius:4px;
|
|
204
|
+
flex: 1;
|
|
205
|
+
min-height: 180px;
|
|
206
|
+
max-height: 300px;
|
|
207
|
+
overflow-y:auto;
|
|
208
|
+
overflow-x:hidden;
|
|
209
|
+
margin-bottom:12px;
|
|
210
|
+
background:var(--rte-mt-subtle-bg);
|
|
211
|
+
}
|
|
212
|
+
.rte-merge-tag-item {
|
|
213
|
+
padding:8px 12px;
|
|
214
|
+
border-bottom:1px solid var(--rte-mt-border);
|
|
215
|
+
cursor:pointer;
|
|
216
|
+
transition:background-color 0.16s;
|
|
217
|
+
color:var(--rte-mt-dialog-text);
|
|
218
|
+
overflow-wrap:anywhere;
|
|
219
|
+
word-break:break-word;
|
|
220
|
+
}
|
|
103
221
|
.rte-merge-tag-item:last-child { border-bottom: none; }
|
|
104
222
|
.rte-merge-tag-item.selected, .rte-merge-tag-item:hover { background-color:var(--rte-mt-subtle-hover); }
|
|
105
223
|
.rte-merge-tag-item-label { font-weight: 600; }
|
|
106
|
-
.rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; }
|
|
224
|
+
.rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; overflow-wrap:anywhere; word-break:break-word; }
|
|
107
225
|
.rte-merge-tag-empty { padding: 24px; text-align: center; color: var(--rte-mt-muted-text); }
|
|
108
|
-
.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); }
|
|
226
|
+
.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; }
|
|
109
227
|
.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); }
|
|
110
228
|
.rte-merge-tag-btn-primary { padding:8px 16px; border:none; border-radius:4px; background:var(--rte-mt-accent); color:#fff; cursor:pointer; }
|
|
111
229
|
.rte-merge-tag-btn-primary:hover { background: var(--rte-mt-accent-strong); }
|
|
@@ -134,263 +252,272 @@ function A() {
|
|
|
134
252
|
}
|
|
135
253
|
`, document.head.appendChild(t);
|
|
136
254
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
255
|
+
function j() {
|
|
256
|
+
P || typeof document > "u" || (P = !0, document.addEventListener("focusin", (t) => {
|
|
257
|
+
const e = t.target?.closest(h);
|
|
258
|
+
e && (S = e);
|
|
141
259
|
}), document.addEventListener("selectionchange", () => {
|
|
142
|
-
const t =
|
|
143
|
-
t && (
|
|
260
|
+
const t = Y();
|
|
261
|
+
t && (S = t);
|
|
144
262
|
}));
|
|
145
263
|
}
|
|
146
|
-
function
|
|
264
|
+
function Y() {
|
|
147
265
|
const t = window.getSelection();
|
|
148
266
|
if (!t || t.rangeCount === 0) return null;
|
|
149
|
-
const
|
|
150
|
-
return (
|
|
267
|
+
const e = t.getRangeAt(0).startContainer;
|
|
268
|
+
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(h) || null;
|
|
151
269
|
}
|
|
152
|
-
function
|
|
153
|
-
const t =
|
|
270
|
+
function X() {
|
|
271
|
+
const t = Y();
|
|
154
272
|
if (t) return t;
|
|
155
|
-
const
|
|
156
|
-
return
|
|
273
|
+
const e = document.activeElement?.closest(h);
|
|
274
|
+
return e || (S?.isConnected ? S : document.querySelector(h));
|
|
157
275
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
160
|
-
if (!e) return;
|
|
161
|
-
const r = window.getSelection();
|
|
276
|
+
function le(t) {
|
|
277
|
+
const r = t.parentNode;
|
|
162
278
|
if (!r) return;
|
|
163
|
-
const
|
|
164
|
-
|
|
279
|
+
const e = window.getSelection();
|
|
280
|
+
if (!e) return;
|
|
281
|
+
const n = document.createRange(), l = Array.from(r.childNodes).indexOf(t);
|
|
282
|
+
l < 0 || (n.setStart(r, l), n.setEnd(r, l + 1), e.removeAllRanges(), e.addRange(n));
|
|
165
283
|
}
|
|
166
|
-
function
|
|
167
|
-
t instanceof Text && t.data.length !== 0 && (
|
|
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));
|
|
168
286
|
}
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
const n = document.createRange(),
|
|
173
|
-
n.setStart(t,
|
|
287
|
+
function W(t, r) {
|
|
288
|
+
const e = window.getSelection();
|
|
289
|
+
if (!e) return;
|
|
290
|
+
const n = document.createRange(), a = Math.max(0, Math.min(r, t.childNodes.length));
|
|
291
|
+
n.setStart(t, a), n.collapse(!0), e.removeAllRanges(), e.addRange(n);
|
|
174
292
|
}
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const d = r instanceof HTMLElement ? r.closest(v) : r.parentElement?.closest(v) || null;
|
|
183
|
-
return d && d.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
293
|
+
function ce(t, r) {
|
|
294
|
+
const e = t.closest(h), n = e?.innerHTML ?? "", a = t.parentNode;
|
|
295
|
+
if (!a) return !1;
|
|
296
|
+
const c = Array.from(a.childNodes).indexOf(t);
|
|
297
|
+
if (c < 0) return !1;
|
|
298
|
+
const d = t.previousSibling, g = t.nextSibling;
|
|
299
|
+
return a.removeChild(t), r === "Backspace" ? (q(g, !0), W(a, c)) : (q(d, !1), W(a, c)), e && (J(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
|
|
184
300
|
}
|
|
185
|
-
function
|
|
301
|
+
function ie(t) {
|
|
186
302
|
if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1) return null;
|
|
187
|
-
const
|
|
188
|
-
if (!(
|
|
189
|
-
const
|
|
190
|
-
return
|
|
303
|
+
const r = t.startContainer;
|
|
304
|
+
if (!(r instanceof Element || r instanceof DocumentFragment)) return null;
|
|
305
|
+
const e = r.childNodes[t.startOffset];
|
|
306
|
+
return e instanceof HTMLElement && e.classList.contains("rte-merge-tag") ? e : null;
|
|
191
307
|
}
|
|
192
|
-
function
|
|
308
|
+
function se(t, r) {
|
|
193
309
|
if (!t.collapsed) return null;
|
|
194
|
-
const { startContainer:
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
return
|
|
310
|
+
const { startContainer: e, startOffset: n } = t, a = (l) => l instanceof HTMLElement && l.classList.contains("rte-merge-tag") ? l : null;
|
|
311
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
312
|
+
const l = e;
|
|
313
|
+
return r === "Backspace" && n > 0 ? a(l.childNodes[n - 1] || null) : r === "Delete" ? a(l.childNodes[n] || null) : null;
|
|
198
314
|
}
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
return
|
|
315
|
+
if (e.nodeType === Node.TEXT_NODE) {
|
|
316
|
+
const l = e;
|
|
317
|
+
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;
|
|
202
318
|
}
|
|
203
319
|
return null;
|
|
204
320
|
}
|
|
205
|
-
function
|
|
321
|
+
function V() {
|
|
206
322
|
H || typeof document > "u" || (H = !0, document.addEventListener("click", (t) => {
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
209
|
-
const n =
|
|
210
|
-
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }),
|
|
323
|
+
const e = t.target?.closest(".rte-merge-tag");
|
|
324
|
+
if (!e) return;
|
|
325
|
+
const n = e.closest(h);
|
|
326
|
+
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), le(e));
|
|
211
327
|
}), document.addEventListener("keydown", (t) => {
|
|
212
328
|
if (t.key !== "Backspace" && t.key !== "Delete") return;
|
|
213
|
-
const
|
|
214
|
-
if (!
|
|
215
|
-
const
|
|
216
|
-
if (!n || !n.contains(
|
|
217
|
-
let
|
|
218
|
-
|
|
329
|
+
const r = window.getSelection();
|
|
330
|
+
if (!r || r.rangeCount === 0) return;
|
|
331
|
+
const e = r.getRangeAt(0), n = X();
|
|
332
|
+
if (!n || !n.contains(e.commonAncestorContainer)) return;
|
|
333
|
+
let a = ie(e);
|
|
334
|
+
a || (a = se(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), ce(a, t.key));
|
|
219
335
|
}));
|
|
220
336
|
}
|
|
221
|
-
function
|
|
222
|
-
return t ? !!t.closest(
|
|
337
|
+
function de(t) {
|
|
338
|
+
return t ? !!t.closest(Q) : !1;
|
|
223
339
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
340
|
+
function ge() {
|
|
341
|
+
E && (E(), E = null), N = null;
|
|
226
342
|
}
|
|
227
|
-
function
|
|
228
|
-
const
|
|
229
|
-
return
|
|
343
|
+
function G(t) {
|
|
344
|
+
const r = document.createRange();
|
|
345
|
+
return r.selectNodeContents(t), r.collapse(!1), r;
|
|
230
346
|
}
|
|
231
|
-
function
|
|
232
|
-
const
|
|
233
|
-
return
|
|
347
|
+
function me(t, r) {
|
|
348
|
+
const e = window.getSelection(), n = r ? r.cloneRange() : G(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : G(t);
|
|
349
|
+
return e && (e.removeAllRanges(), e.addRange(l)), l;
|
|
234
350
|
}
|
|
235
|
-
function
|
|
351
|
+
function ue(t, r) {
|
|
236
352
|
const e = document.createElement("span");
|
|
237
|
-
|
|
353
|
+
e.className = "rte-merge-tag", e.setAttribute("contenteditable", "false"), e.setAttribute("data-key", t.key), e.setAttribute("data-category", t.category), e.setAttribute("data-label", t.label), t.value && e.setAttribute("data-value", t.value);
|
|
354
|
+
const n = r(t);
|
|
355
|
+
return e.setAttribute("data-token", n), e.setAttribute("aria-label", `Merge tag: ${t.label}`), e.textContent = n, e;
|
|
238
356
|
}
|
|
239
|
-
function
|
|
240
|
-
const
|
|
241
|
-
if (!
|
|
357
|
+
function fe(t, r, e, n) {
|
|
358
|
+
const a = window.getSelection();
|
|
359
|
+
if (!a) return !1;
|
|
360
|
+
const l = t.innerHTML;
|
|
242
361
|
t.focus({ preventScroll: !0 });
|
|
243
|
-
const
|
|
244
|
-
|
|
362
|
+
const c = me(t, r), g = (c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement)?.closest(".rte-merge-tag");
|
|
363
|
+
g && t.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
|
|
245
364
|
try {
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
u.appendChild(
|
|
365
|
+
c.deleteContents();
|
|
366
|
+
const i = ue(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
|
|
367
|
+
u.appendChild(i), u.appendChild(b), c.insertNode(u);
|
|
249
368
|
const f = document.createRange();
|
|
250
|
-
return f.setStartAfter(
|
|
251
|
-
} catch (
|
|
252
|
-
return console.error("Failed to insert merge tag:",
|
|
369
|
+
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f), J(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
|
|
370
|
+
} catch (i) {
|
|
371
|
+
return console.error("Failed to insert merge tag:", i), !1;
|
|
253
372
|
}
|
|
254
373
|
}
|
|
255
|
-
function
|
|
256
|
-
const
|
|
257
|
-
return
|
|
374
|
+
function pe(t, r, e) {
|
|
375
|
+
const n = t.catalog.categoriesByKey[r]?.tags || [], a = e.trim().toLowerCase();
|
|
376
|
+
return a ? n.filter((l) => l.searchIndex.includes(a)) : n;
|
|
258
377
|
}
|
|
259
|
-
function
|
|
260
|
-
|
|
378
|
+
function be(t, r) {
|
|
379
|
+
ge(), R();
|
|
261
380
|
const e = {
|
|
262
|
-
category:
|
|
381
|
+
category: r.catalog.defaultCategory,
|
|
263
382
|
searchTerm: "",
|
|
264
|
-
filteredTags:
|
|
383
|
+
filteredTags: r.catalog.categoriesByKey[r.catalog.defaultCategory]?.tags || [],
|
|
265
384
|
selectedIndex: 0,
|
|
266
385
|
savedRange: (() => {
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
const
|
|
270
|
-
return t.contains(
|
|
386
|
+
const o = window.getSelection();
|
|
387
|
+
if (!o || o.rangeCount === 0) return null;
|
|
388
|
+
const s = o.getRangeAt(0);
|
|
389
|
+
return t.contains(s.commonAncestorContainer) ? s.cloneRange() : null;
|
|
271
390
|
})(),
|
|
272
391
|
searchRaf: null
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
i.className = "rte-merge-tag-body";
|
|
284
|
-
const c = document.createElement("input");
|
|
285
|
-
c.type = "text", c.className = "rte-merge-tag-input", c.placeholder = "Search merge tags...", c.setAttribute("aria-label", "Search merge tags");
|
|
286
|
-
const d = document.createElement("div");
|
|
287
|
-
d.className = "rte-merge-tag-tabs", L.forEach((a) => {
|
|
288
|
-
const l = document.createElement("button");
|
|
289
|
-
l.type = "button", l.className = "rte-merge-tag-tab", l.setAttribute("data-category", a), l.textContent = R[a].name, d.appendChild(l);
|
|
290
|
-
});
|
|
392
|
+
}, n = document.createElement("div");
|
|
393
|
+
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), de(t) && n.classList.add("rte-ui-theme-dark");
|
|
394
|
+
const a = document.createElement("div");
|
|
395
|
+
a.className = "rte-merge-tag-dialog";
|
|
396
|
+
const l = document.createElement("div");
|
|
397
|
+
l.className = "rte-merge-tag-header";
|
|
398
|
+
const c = document.createElement("h2");
|
|
399
|
+
c.style.margin = "0", c.style.fontSize = "18px", c.style.fontWeight = "700", c.textContent = r.dialog.title;
|
|
400
|
+
const d = document.createElement("button");
|
|
401
|
+
d.className = "rte-merge-tag-close", d.setAttribute("aria-label", "Close"), d.style.background = "none", d.style.border = "none", d.style.color = "inherit", d.style.cursor = "pointer", d.style.fontSize = "20px", d.textContent = "✕", l.appendChild(c), l.appendChild(d);
|
|
291
402
|
const g = document.createElement("div");
|
|
292
|
-
g.className = "rte-merge-tag-
|
|
403
|
+
g.className = "rte-merge-tag-body";
|
|
404
|
+
const i = document.createElement("input");
|
|
405
|
+
i.type = "text", i.className = "rte-merge-tag-input", i.placeholder = r.dialog.searchPlaceholder, i.setAttribute("aria-label", "Search merge tags");
|
|
406
|
+
const b = document.createElement("div");
|
|
407
|
+
b.className = "rte-merge-tag-tabs", r.catalog.categoryKeys.forEach((o) => {
|
|
408
|
+
const s = document.createElement("button");
|
|
409
|
+
s.type = "button", s.className = "rte-merge-tag-tab", s.setAttribute("data-category", o), s.textContent = r.catalog.categoriesByKey[o]?.name || o, b.appendChild(s);
|
|
410
|
+
});
|
|
293
411
|
const u = document.createElement("div");
|
|
294
|
-
u.className = "rte-merge-tag-
|
|
412
|
+
u.className = "rte-merge-tag-list";
|
|
295
413
|
const f = document.createElement("div");
|
|
296
|
-
f.className = "rte-merge-tag-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
414
|
+
f.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(b), g.appendChild(u), g.appendChild(f);
|
|
415
|
+
const w = document.createElement("div");
|
|
416
|
+
w.className = "rte-merge-tag-footer";
|
|
417
|
+
const v = document.createElement("button");
|
|
418
|
+
v.type = "button", v.className = "rte-merge-tag-btn-secondary", v.textContent = r.dialog.cancelText;
|
|
419
|
+
const y = document.createElement("button");
|
|
420
|
+
y.type = "button", y.className = "rte-merge-tag-btn-primary", y.textContent = r.dialog.insertText, w.appendChild(v), w.appendChild(y), a.appendChild(l), a.appendChild(g), a.appendChild(w), n.appendChild(a), document.body.appendChild(n), N = n;
|
|
421
|
+
const _ = () => {
|
|
422
|
+
b.querySelectorAll(".rte-merge-tag-tab").forEach((s) => {
|
|
423
|
+
const p = s.dataset.category === e.category;
|
|
424
|
+
s.classList.toggle("active", p);
|
|
305
425
|
});
|
|
306
|
-
},
|
|
426
|
+
}, L = () => {
|
|
307
427
|
if (e.filteredTags.length === 0) {
|
|
308
428
|
e.selectedIndex = -1;
|
|
309
429
|
return;
|
|
310
430
|
}
|
|
311
431
|
e.selectedIndex < 0 && (e.selectedIndex = 0), e.selectedIndex >= e.filteredTags.length && (e.selectedIndex = e.filteredTags.length - 1);
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (!a) {
|
|
316
|
-
u.style.display = "none", p.disabled = !0;
|
|
432
|
+
}, O = () => {
|
|
433
|
+
if (!r.dialog.showPreview) {
|
|
434
|
+
f.style.display = "none", y.disabled = e.filteredTags.length === 0;
|
|
317
435
|
return;
|
|
318
436
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
if (
|
|
322
|
-
|
|
323
|
-
}, h = () => {
|
|
324
|
-
if (e.filteredTags = le(e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), w(), g.innerHTML = "", e.filteredTags.length === 0) {
|
|
325
|
-
const l = document.createElement("div");
|
|
326
|
-
l.className = "rte-merge-tag-empty", l.textContent = "No merge tags found", g.appendChild(l), I();
|
|
437
|
+
L();
|
|
438
|
+
const o = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
|
|
439
|
+
if (!o) {
|
|
440
|
+
f.style.display = "none", y.disabled = !0;
|
|
327
441
|
return;
|
|
328
442
|
}
|
|
329
|
-
|
|
330
|
-
|
|
443
|
+
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`, y.disabled = !1;
|
|
444
|
+
}, Z = () => {
|
|
445
|
+
if (e.selectedIndex < 0) return;
|
|
446
|
+
u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({ block: "nearest" });
|
|
447
|
+
}, k = () => {
|
|
448
|
+
u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"), e.selectedIndex >= 0 && u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"), O(), Z();
|
|
449
|
+
}, A = () => {
|
|
450
|
+
if (e.filteredTags = pe(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), L(), u.innerHTML = "", e.filteredTags.length === 0) {
|
|
331
451
|
const s = document.createElement("div");
|
|
332
|
-
s.className = "rte-merge-tag-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
452
|
+
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s), O();
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const o = document.createDocumentFragment();
|
|
456
|
+
e.filteredTags.forEach((s, p) => {
|
|
457
|
+
const m = document.createElement("div");
|
|
458
|
+
m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(p)), m.classList.toggle("selected", p === e.selectedIndex);
|
|
459
|
+
const D = document.createElement("div");
|
|
460
|
+
if (D.className = "rte-merge-tag-item-label", D.textContent = s.label, m.appendChild(D), s.preview) {
|
|
461
|
+
const I = document.createElement("div");
|
|
462
|
+
I.className = "rte-merge-tag-item-preview", I.textContent = s.preview, m.appendChild(I);
|
|
337
463
|
}
|
|
338
|
-
|
|
339
|
-
}),
|
|
340
|
-
},
|
|
464
|
+
o.appendChild(m);
|
|
465
|
+
}), u.appendChild(o), k();
|
|
466
|
+
}, z = () => {
|
|
341
467
|
e.searchRaf !== null && cancelAnimationFrame(e.searchRaf), e.searchRaf = requestAnimationFrame(() => {
|
|
342
|
-
e.searchRaf = null, e.searchTerm =
|
|
468
|
+
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, A();
|
|
343
469
|
});
|
|
344
|
-
},
|
|
345
|
-
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null),
|
|
346
|
-
},
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
},
|
|
351
|
-
const
|
|
352
|
-
if (!
|
|
353
|
-
const
|
|
354
|
-
!
|
|
355
|
-
},
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
358
|
-
const
|
|
359
|
-
Number.isNaN(
|
|
360
|
-
},
|
|
361
|
-
const
|
|
362
|
-
if (!
|
|
363
|
-
const
|
|
364
|
-
Number.isNaN(
|
|
365
|
-
},
|
|
366
|
-
if (
|
|
367
|
-
|
|
470
|
+
}, x = () => {
|
|
471
|
+
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), N === n && (N = null, E = null);
|
|
472
|
+
}, T = () => {
|
|
473
|
+
if (L(), e.selectedIndex < 0) return;
|
|
474
|
+
const o = e.filteredTags[e.selectedIndex];
|
|
475
|
+
fe(t, e.savedRange, o, r.formatToken) && x();
|
|
476
|
+
}, F = (o) => {
|
|
477
|
+
const p = o.target.closest(".rte-merge-tag-tab");
|
|
478
|
+
if (!p) return;
|
|
479
|
+
const m = p.dataset.category;
|
|
480
|
+
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, _(), A());
|
|
481
|
+
}, B = (o) => {
|
|
482
|
+
const p = o.target.closest(".rte-merge-tag-item");
|
|
483
|
+
if (!p) return;
|
|
484
|
+
const m = Number(p.dataset.index || "-1");
|
|
485
|
+
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, k());
|
|
486
|
+
}, U = (o) => {
|
|
487
|
+
const p = o.target.closest(".rte-merge-tag-item");
|
|
488
|
+
if (!p) return;
|
|
489
|
+
const m = Number(p.dataset.index || "-1");
|
|
490
|
+
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, T());
|
|
491
|
+
}, C = (o) => {
|
|
492
|
+
if (o.key === "Escape") {
|
|
493
|
+
o.preventDefault(), x();
|
|
368
494
|
return;
|
|
369
495
|
}
|
|
370
|
-
if (
|
|
371
|
-
if (
|
|
372
|
-
e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1),
|
|
496
|
+
if (o.key === "ArrowDown") {
|
|
497
|
+
if (o.preventDefault(), e.filteredTags.length === 0) return;
|
|
498
|
+
e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1), k();
|
|
373
499
|
return;
|
|
374
500
|
}
|
|
375
|
-
if (
|
|
376
|
-
if (
|
|
377
|
-
e.selectedIndex = Math.max(0, e.selectedIndex - 1),
|
|
501
|
+
if (o.key === "ArrowUp") {
|
|
502
|
+
if (o.preventDefault(), e.filteredTags.length === 0) return;
|
|
503
|
+
e.selectedIndex = Math.max(0, e.selectedIndex - 1), k();
|
|
378
504
|
return;
|
|
379
505
|
}
|
|
380
|
-
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
},
|
|
387
|
-
|
|
506
|
+
o.key === "Enter" && (o.preventDefault(), T());
|
|
507
|
+
}, $ = (o) => {
|
|
508
|
+
o.target === n && x();
|
|
509
|
+
};
|
|
510
|
+
b.addEventListener("click", F), u.addEventListener("click", B), u.addEventListener("dblclick", U), i.addEventListener("input", z), i.addEventListener("keydown", C), n.addEventListener("click", $), a.addEventListener("keydown", C), d?.addEventListener("click", x), v.addEventListener("click", x), y.addEventListener("click", T), E = () => {
|
|
511
|
+
b.removeEventListener("click", F), u.removeEventListener("click", B), u.removeEventListener("dblclick", U), i.removeEventListener("input", z), i.removeEventListener("keydown", C), n.removeEventListener("click", $), a.removeEventListener("keydown", C), d?.removeEventListener("click", x), v.removeEventListener("click", x), y.removeEventListener("click", T), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
|
|
512
|
+
}, _(), A(), setTimeout(() => {
|
|
513
|
+
i.focus();
|
|
388
514
|
}, 0);
|
|
389
515
|
}
|
|
390
|
-
const
|
|
516
|
+
const ye = (t) => ({
|
|
391
517
|
name: "mergeTag",
|
|
518
|
+
config: t,
|
|
392
519
|
init: () => {
|
|
393
|
-
|
|
520
|
+
R(), j(), V();
|
|
394
521
|
},
|
|
395
522
|
toolbar: [
|
|
396
523
|
{
|
|
@@ -401,12 +528,12 @@ const ce = () => ({
|
|
|
401
528
|
],
|
|
402
529
|
commands: {
|
|
403
530
|
insertMergeTag: () => {
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
return
|
|
531
|
+
R(), j(), V();
|
|
532
|
+
const r = X();
|
|
533
|
+
return r ? (be(r, oe(t)), !0) : !1;
|
|
407
534
|
}
|
|
408
535
|
}
|
|
409
536
|
});
|
|
410
537
|
export {
|
|
411
|
-
|
|
538
|
+
ye as MergeTagPlugin
|
|
412
539
|
};
|