@editora/plugins 1.0.7 → 1.0.9
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/LICENSE +21 -0
- package/README.md +72 -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/approval-workflow.cjs.js +447 -0
- package/dist/approval-workflow.esm.js +1070 -0
- package/dist/background-color.cjs.js +3 -3
- package/dist/background-color.esm.js +116 -119
- package/dist/blocks-library.cjs.js +442 -0
- package/dist/blocks-library.esm.js +1317 -0
- package/dist/citations.cjs.js +548 -0
- package/dist/citations.esm.js +1457 -0
- 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/conditional-content.cjs.js +626 -0
- package/dist/conditional-content.esm.js +1360 -0
- package/dist/content-rules.cjs.js +408 -0
- package/dist/content-rules.esm.js +1093 -0
- package/dist/data-binding.cjs.js +321 -0
- package/dist/data-binding.esm.js +913 -0
- package/dist/doc-schema.cjs.js +398 -0
- package/dist/doc-schema.esm.js +1310 -0
- 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/enterprise.cjs.js +1 -0
- package/dist/enterprise.esm.js +56 -0
- 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 +111 -75
- 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/mentions.cjs.js +105 -0
- package/dist/mentions.esm.js +726 -0
- 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 +85 -77
- package/dist/pii-redaction.cjs.js +436 -0
- package/dist/pii-redaction.esm.js +1377 -0
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +29 -29
- package/dist/slash-commands.cjs.js +90 -0
- package/dist/slash-commands.esm.js +752 -0
- package/dist/smart-paste.cjs.js +398 -0
- package/dist/smart-paste.esm.js +1388 -0
- 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/dist/track-changes.cjs.js +77 -0
- package/dist/track-changes.esm.js +755 -0
- package/dist/translation-workflow.cjs.js +626 -0
- package/dist/translation-workflow.esm.js +1718 -0
- package/dist/version-diff.cjs.js +362 -0
- package/dist/version-diff.esm.js +768 -0
- package/index.d.ts +849 -1
- package/package.json +105 -6
- 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/anchor.esm.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { f as
|
|
2
|
-
const
|
|
1
|
+
import { f as D, g as S } from "./editorContainerHelpers-C7kdWnS0.mjs";
|
|
2
|
+
const b = /* @__PURE__ */ new Set(), x = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
3
|
+
function z(t, c) {
|
|
4
|
+
if (c === t.innerHTML) return;
|
|
5
|
+
const i = window.execEditorCommand || window.executeEditorCommand;
|
|
6
|
+
if (typeof i == "function")
|
|
7
|
+
try {
|
|
8
|
+
i("recordDomTransaction", t, c, t.innerHTML);
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
function R() {
|
|
4
13
|
if (typeof window > "u" || window.__anchorObserverInitialized) return;
|
|
5
|
-
window.__anchorObserverInitialized = !0, new MutationObserver((
|
|
6
|
-
|
|
7
|
-
i.removedNodes.forEach((
|
|
8
|
-
if (
|
|
9
|
-
const d =
|
|
14
|
+
window.__anchorObserverInitialized = !0, new MutationObserver((c) => {
|
|
15
|
+
c.forEach((i) => {
|
|
16
|
+
i.removedNodes.forEach((n) => {
|
|
17
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
18
|
+
const d = n;
|
|
10
19
|
if (d.classList?.contains("rte-anchor")) {
|
|
11
|
-
const
|
|
12
|
-
|
|
20
|
+
const r = d.id;
|
|
21
|
+
r && b.delete(r);
|
|
13
22
|
}
|
|
14
|
-
d.querySelectorAll?.(".rte-anchor")?.forEach((
|
|
15
|
-
const u =
|
|
16
|
-
u &&
|
|
23
|
+
d.querySelectorAll?.(".rte-anchor")?.forEach((r) => {
|
|
24
|
+
const u = r.id;
|
|
25
|
+
u && b.delete(u);
|
|
17
26
|
});
|
|
18
27
|
}
|
|
19
28
|
});
|
|
@@ -23,35 +32,35 @@ function R() {
|
|
|
23
32
|
subtree: !0
|
|
24
33
|
});
|
|
25
34
|
}
|
|
26
|
-
function A(
|
|
27
|
-
return !
|
|
35
|
+
function A(t) {
|
|
36
|
+
return !t || t.trim().length === 0 ? { valid: !1, error: "Anchor ID cannot be empty" } : t.length > 256 ? { valid: !1, error: "Anchor ID must be less than 256 characters" } : /^[a-z_]/.test(t) ? /^[a-z0-9\-_]+$/.test(t) ? { valid: !0, error: "" } : { valid: !1, error: "Anchor ID can only contain letters, numbers, hyphens, and underscores" } : { valid: !1, error: "Anchor ID must start with a letter or underscore" };
|
|
28
37
|
}
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
34
|
-
const i =
|
|
38
|
+
function M() {
|
|
39
|
+
const t = D();
|
|
40
|
+
if (!t) return;
|
|
41
|
+
const c = S(t);
|
|
42
|
+
if (!c) return;
|
|
43
|
+
const i = c.querySelectorAll(".rte-anchor"), n = /* @__PURE__ */ new Set();
|
|
35
44
|
i.forEach((d) => {
|
|
36
45
|
const e = d.id;
|
|
37
|
-
e &&
|
|
38
|
-
}),
|
|
46
|
+
e && n.add(e);
|
|
47
|
+
}), b.clear(), n.forEach((d) => b.add(d));
|
|
39
48
|
}
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
if ((
|
|
49
|
+
function H(t) {
|
|
50
|
+
if (t) {
|
|
51
|
+
const n = t.startContainer;
|
|
52
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
|
|
44
53
|
}
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
if ((
|
|
54
|
+
const c = window.getSelection();
|
|
55
|
+
if (c && c.rangeCount > 0) {
|
|
56
|
+
const n = c.getRangeAt(0).startContainer;
|
|
57
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
|
|
49
58
|
}
|
|
50
|
-
return document.activeElement?.closest(
|
|
59
|
+
return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
|
|
51
60
|
}
|
|
52
|
-
function _(
|
|
53
|
-
|
|
54
|
-
const d =
|
|
61
|
+
function _(t, c, i, n) {
|
|
62
|
+
M();
|
|
63
|
+
const d = H(n), e = d ? {
|
|
55
64
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
56
65
|
dialogBg: "#1f2937",
|
|
57
66
|
panelBg: "#222d3a",
|
|
@@ -99,8 +108,8 @@ function _(o, l, i, r) {
|
|
|
99
108
|
help: "#999999",
|
|
100
109
|
focusRing: "rgba(0, 102, 204, 0.1)",
|
|
101
110
|
errorRing: "rgba(211, 47, 47, 0.1)"
|
|
102
|
-
},
|
|
103
|
-
|
|
111
|
+
}, r = document.createElement("div");
|
|
112
|
+
r.className = "rte-anchor-dialog-overlay", r.style.cssText = `
|
|
104
113
|
position: fixed;
|
|
105
114
|
top: 0;
|
|
106
115
|
left: 0;
|
|
@@ -135,9 +144,9 @@ function _(o, l, i, r) {
|
|
|
135
144
|
}
|
|
136
145
|
`, document.head.appendChild(s);
|
|
137
146
|
}
|
|
138
|
-
let
|
|
139
|
-
const
|
|
140
|
-
|
|
147
|
+
let l = "";
|
|
148
|
+
const h = document.createElement("div");
|
|
149
|
+
h.style.cssText = `
|
|
141
150
|
display: flex;
|
|
142
151
|
align-items: center;
|
|
143
152
|
justify-content: space-between;
|
|
@@ -147,8 +156,8 @@ function _(o, l, i, r) {
|
|
|
147
156
|
`;
|
|
148
157
|
const w = document.createElement("h3");
|
|
149
158
|
w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = "Add Anchor";
|
|
150
|
-
const
|
|
151
|
-
|
|
159
|
+
const f = document.createElement("button");
|
|
160
|
+
f.textContent = "✕", f.style.cssText = `
|
|
152
161
|
background: none;
|
|
153
162
|
border: none;
|
|
154
163
|
font-size: 24px;
|
|
@@ -162,19 +171,19 @@ function _(o, l, i, r) {
|
|
|
162
171
|
justify-content: center;
|
|
163
172
|
border-radius: 4px;
|
|
164
173
|
transition: all 0.2s ease;
|
|
165
|
-
`,
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
},
|
|
174
|
+
`, f.onmouseover = () => {
|
|
175
|
+
f.style.background = e.closeHoverBg, f.style.color = "#f8fafc";
|
|
176
|
+
}, f.onmouseout = () => {
|
|
177
|
+
f.style.background = "none", f.style.color = e.muted;
|
|
178
|
+
}, h.appendChild(w), h.appendChild(f);
|
|
170
179
|
const C = document.createElement("div");
|
|
171
180
|
C.style.cssText = "padding: 20px;";
|
|
172
|
-
const
|
|
173
|
-
|
|
181
|
+
const m = document.createElement("div");
|
|
182
|
+
m.style.cssText = "margin-bottom: 0;";
|
|
174
183
|
const y = document.createElement("label");
|
|
175
184
|
y.textContent = "Anchor ID", y.style.cssText = `display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`, y.setAttribute("for", "anchor-id-input");
|
|
176
|
-
const
|
|
177
|
-
|
|
185
|
+
const o = document.createElement("input");
|
|
186
|
+
o.id = "anchor-id-input", o.type = "text", o.placeholder = "e.g., section-introduction", o.value = "", o.style.cssText = `
|
|
178
187
|
width: 100%;
|
|
179
188
|
padding: 10px 12px;
|
|
180
189
|
font-size: 14px;
|
|
@@ -185,16 +194,16 @@ function _(o, l, i, r) {
|
|
|
185
194
|
background: ${e.fieldBg};
|
|
186
195
|
transition: all 0.2s ease;
|
|
187
196
|
box-sizing: border-box;
|
|
188
|
-
`,
|
|
189
|
-
const
|
|
190
|
-
|
|
197
|
+
`, o.style.setProperty("caret-color", e.fieldText);
|
|
198
|
+
const p = document.createElement("div");
|
|
199
|
+
p.style.cssText = `
|
|
191
200
|
color: #d32f2f;
|
|
192
201
|
font-size: 12px;
|
|
193
202
|
margin-top: 6px;
|
|
194
203
|
display: none;
|
|
195
204
|
`;
|
|
196
205
|
const B = document.createElement("div");
|
|
197
|
-
B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,
|
|
206
|
+
B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`, m.appendChild(y), m.appendChild(o), m.appendChild(p), m.appendChild(B), C.appendChild(m);
|
|
198
207
|
const v = document.createElement("div");
|
|
199
208
|
v.style.cssText = `
|
|
200
209
|
display: flex;
|
|
@@ -216,8 +225,8 @@ function _(o, l, i, r) {
|
|
|
216
225
|
background: ${e.cancelBg};
|
|
217
226
|
color: ${e.cancelText};
|
|
218
227
|
`, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
|
|
219
|
-
const
|
|
220
|
-
|
|
228
|
+
const a = document.createElement("button");
|
|
229
|
+
a.textContent = "Add Anchor", a.style.cssText = `
|
|
221
230
|
padding: 8px 16px;
|
|
222
231
|
font-size: 14px;
|
|
223
232
|
font-weight: 500;
|
|
@@ -227,66 +236,80 @@ function _(o, l, i, r) {
|
|
|
227
236
|
transition: all 0.2s ease;
|
|
228
237
|
background: ${e.saveBg};
|
|
229
238
|
color: white;
|
|
230
|
-
`,
|
|
231
|
-
const
|
|
232
|
-
|
|
239
|
+
`, a.disabled = !o.value.trim();
|
|
240
|
+
const $ = () => {
|
|
241
|
+
o.value.trim() ? (a.disabled = !1, a.style.background = e.saveBg, a.style.color = "white", a.style.cursor = "pointer") : (a.disabled = !0, a.style.background = e.saveDisabledBg, a.style.color = e.saveDisabledText, a.style.cursor = "not-allowed");
|
|
233
242
|
};
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
}, v.appendChild(g), v.appendChild(
|
|
239
|
-
const s =
|
|
240
|
-
if (
|
|
243
|
+
a.onmouseover = () => {
|
|
244
|
+
a.disabled || (a.style.background = e.saveHover, a.style.boxShadow = d ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
|
|
245
|
+
}, a.onmouseout = () => {
|
|
246
|
+
a.disabled || (a.style.background = e.saveBg, a.style.boxShadow = "none");
|
|
247
|
+
}, v.appendChild(g), v.appendChild(a), o.oninput = () => {
|
|
248
|
+
const s = o.value;
|
|
249
|
+
if ($(), s.trim()) {
|
|
241
250
|
const k = A(s);
|
|
242
|
-
k.valid ?
|
|
251
|
+
k.valid ? b.has(s) ? (l = `Anchor ID already exists: ${s}`, p.textContent = "⚠ " + l, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (l = "", p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (l = k.error, p.textContent = "⚠ " + l, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg);
|
|
243
252
|
} else
|
|
244
|
-
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
|
|
253
|
+
p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg;
|
|
254
|
+
}, o.onfocus = () => {
|
|
255
|
+
o.style.borderColor = l ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = l ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = l ? e.fieldErrorBg : e.fieldFocusBg;
|
|
256
|
+
}, o.onblur = () => {
|
|
257
|
+
o.style.boxShadow = "none", l || (o.style.background = e.fieldBg);
|
|
249
258
|
};
|
|
250
259
|
const T = () => {
|
|
251
|
-
const s =
|
|
252
|
-
!s || !A(s).valid ||
|
|
260
|
+
const s = o.value.trim();
|
|
261
|
+
!s || !A(s).valid || b.has(s) || (i && i(s), r.remove());
|
|
253
262
|
}, E = () => {
|
|
254
|
-
|
|
263
|
+
r.remove();
|
|
255
264
|
};
|
|
256
|
-
|
|
265
|
+
a.onclick = T, g.onclick = E, f.onclick = E, o.onkeydown = (s) => {
|
|
257
266
|
s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), E());
|
|
258
|
-
},
|
|
259
|
-
s.target ===
|
|
260
|
-
}, u.appendChild(
|
|
267
|
+
}, r.onclick = (s) => {
|
|
268
|
+
s.target === r && E();
|
|
269
|
+
}, u.appendChild(h), u.appendChild(C), u.appendChild(v), r.appendChild(u), document.body.appendChild(r), setTimeout(() => o.focus(), 100);
|
|
261
270
|
}
|
|
262
|
-
function
|
|
271
|
+
function I(t, c) {
|
|
263
272
|
let i;
|
|
264
|
-
if (
|
|
265
|
-
i =
|
|
273
|
+
if (c)
|
|
274
|
+
i = c;
|
|
266
275
|
else {
|
|
267
|
-
const
|
|
268
|
-
if (!
|
|
269
|
-
i =
|
|
276
|
+
const l = window.getSelection();
|
|
277
|
+
if (!l || l.rangeCount === 0) return;
|
|
278
|
+
i = l.getRangeAt(0);
|
|
270
279
|
}
|
|
271
|
-
|
|
272
|
-
|
|
280
|
+
let n = null, d = i.startContainer;
|
|
281
|
+
for (; d && d !== document.body; ) {
|
|
282
|
+
if (d.nodeType === Node.ELEMENT_NODE) {
|
|
283
|
+
const l = d;
|
|
284
|
+
if (l.getAttribute("contenteditable") === "true") {
|
|
285
|
+
n = l;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
d = d.parentNode;
|
|
290
|
+
}
|
|
291
|
+
const e = n?.innerHTML ?? "", r = document.createElement("span");
|
|
292
|
+
r.id = t, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", t), r.setAttribute("title", `Anchor: ${t}`), r.style.cssText = `
|
|
273
293
|
display: inline;
|
|
274
294
|
position: relative;
|
|
275
295
|
cursor: pointer;
|
|
276
|
-
`, i.insertNode(r),
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
296
|
+
`, i.insertNode(r), b.add(t), i.setStart(r.nextSibling || r.parentNode, 0), i.collapse(!0);
|
|
297
|
+
const u = window.getSelection();
|
|
298
|
+
if (u && (u.removeAllRanges(), u.addRange(i)), n)
|
|
299
|
+
z(n, e), n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
300
|
+
else {
|
|
301
|
+
const l = D();
|
|
302
|
+
if (l) {
|
|
303
|
+
const h = S(l);
|
|
304
|
+
h && h.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
305
|
+
}
|
|
283
306
|
}
|
|
284
|
-
|
|
307
|
+
N();
|
|
285
308
|
}
|
|
286
|
-
function
|
|
309
|
+
function N() {
|
|
287
310
|
if (document.getElementById("rte-anchor-styles")) return;
|
|
288
|
-
const
|
|
289
|
-
|
|
311
|
+
const t = document.createElement("style");
|
|
312
|
+
t.id = "rte-anchor-styles", t.textContent = `
|
|
290
313
|
.rte-anchor {
|
|
291
314
|
display: inline;
|
|
292
315
|
position: relative;
|
|
@@ -364,9 +387,9 @@ function $() {
|
|
|
364
387
|
outline: 2px solid #0066cc;
|
|
365
388
|
outline-offset: 2px;
|
|
366
389
|
}
|
|
367
|
-
`, document.head.appendChild(
|
|
390
|
+
`, document.head.appendChild(t);
|
|
368
391
|
}
|
|
369
|
-
const O = () => (typeof window < "u" && (R(),
|
|
392
|
+
const O = () => (typeof window < "u" && (R(), N()), {
|
|
370
393
|
name: "anchor",
|
|
371
394
|
toolbar: [
|
|
372
395
|
{
|
|
@@ -379,15 +402,15 @@ const O = () => (typeof window < "u" && (R(), $()), {
|
|
|
379
402
|
commands: {
|
|
380
403
|
insertAnchor: () => {
|
|
381
404
|
try {
|
|
382
|
-
const
|
|
383
|
-
if (!
|
|
405
|
+
const t = window.getSelection();
|
|
406
|
+
if (!t || t.rangeCount === 0)
|
|
384
407
|
return alert("Please place your cursor where you want to insert the anchor."), !1;
|
|
385
|
-
const
|
|
408
|
+
const c = t.getRangeAt(0).cloneRange();
|
|
386
409
|
return _("add", "", (i) => {
|
|
387
|
-
|
|
388
|
-
},
|
|
389
|
-
} catch (
|
|
390
|
-
return console.error("Failed to insert anchor:",
|
|
410
|
+
I(i, c);
|
|
411
|
+
}, c), !0;
|
|
412
|
+
} catch (t) {
|
|
413
|
+
return console.error("Failed to insert anchor:", t), !1;
|
|
391
414
|
}
|
|
392
415
|
}
|
|
393
416
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const b="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function p(e){return!!e.cloneContents().querySelector(b)}function v(e,t){return(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest('[contenteditable="true"]')||t()?.querySelector('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function C(e,t){const n=v(e,t);n&&n.dispatchEvent(new Event("input",{bubbles:!0}))}function A(e,t){let r=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentElement:e.startContainer;for(;r&&r!==document.body;){if(r.classList.contains(t)){const c=document.createRange();if(c.selectNodeContents(r),c.compareBoundaryPoints(Range.START_TO_START,e)<=0&&c.compareBoundaryPoints(Range.END_TO_END,e)>=0)return r}r=r.parentElement}return null}function S(e){try{if(e.savedRange){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(e.savedRange.cloneRange()))}const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0);if(n.collapsed)return!1;const r=A(n,e.className);if(r)return e.styleProperty==="backgroundColor"?r.style.backgroundColor=e.color:r.style.color=e.color,C(r,e.getActiveEditorRoot),!0;v(n.commonAncestorContainer,e.getActiveEditorRoot)?.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let l=!1;if(e.commands.forEach(o=>{l||(l=document.execCommand(o,!1,e.color))}),!l&&!p(n)){const o=document.createElement("span");e.styleProperty==="backgroundColor"?o.style.backgroundColor=e.color:o.style.color=e.color,o.className=e.className;const a=n.extractContents();o.appendChild(a),n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),l=!0}return l?(C(n.commonAncestorContainer,e.getActiveEditorRoot),!0):(e.warnMessage&&console.warn(e.warnMessage),!1)}catch(t){return e.warnMessage?console.error(e.warnMessage,t):console.error("[ColorApply] Failed to apply color",t),!1}}function T({popover:e,anchor:t,onClose:n,gap:r=6,margin:c=8,zIndex:l=1e4}){e.style.position="fixed",e.style.zIndex=`${l}`,e.style.visibility="hidden";const o=()=>{if(!e.isConnected||!t.isConnected){n();return}const s=t.getBoundingClientRect();if(s.width===0&&s.height===0){n();return}const i=e.getBoundingClientRect(),y=i.width||e.offsetWidth||220,f=i.height||e.offsetHeight||260,w=window.innerWidth,E=window.innerHeight;let u=s.left,d=s.bottom+r;if(u+y>w-c&&(u=w-y-c),u=Math.max(c,u),d+f>E-c){const g=s.top-f-r;g>=c?d=g:d=Math.max(c,E-f-c)}d<c&&(d=c),e.style.left=`${Math.round(u)}px`,e.style.top=`${Math.round(d)}px`,e.style.visibility="visible"},a=()=>{o()},m=s=>{const i=s.target;i&&(e.contains(i)||t.contains(i)||n())},h=s=>{s.key==="Escape"&&n()};window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),document.addEventListener("keydown",h);const R=window.requestAnimationFrame(()=>{document.addEventListener("mousedown",m,!0)});return o(),{reposition:o,destroy:()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),document.removeEventListener("keydown",h),document.removeEventListener("mousedown",m,!0)}}}exports.applyColorToSelection=S;exports.attachAnchoredPopover=T;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
const b = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
|
|
2
|
+
function p(e) {
|
|
3
|
+
return !!e.cloneContents().querySelector(b);
|
|
4
|
+
}
|
|
5
|
+
function v(e, t) {
|
|
6
|
+
return (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest('[contenteditable="true"]') || t()?.querySelector('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
|
|
7
|
+
}
|
|
8
|
+
function C(e, t) {
|
|
9
|
+
const n = v(e, t);
|
|
10
|
+
n && n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
11
|
+
}
|
|
12
|
+
function A(e, t) {
|
|
13
|
+
let r = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
|
|
14
|
+
for (; r && r !== document.body; ) {
|
|
15
|
+
if (r.classList.contains(t)) {
|
|
16
|
+
const c = document.createRange();
|
|
17
|
+
if (c.selectNodeContents(r), c.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && c.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
r = r.parentElement;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function N(e) {
|
|
25
|
+
try {
|
|
26
|
+
if (e.savedRange) {
|
|
27
|
+
const o = window.getSelection();
|
|
28
|
+
o && (o.removeAllRanges(), o.addRange(e.savedRange.cloneRange()));
|
|
29
|
+
}
|
|
30
|
+
const t = window.getSelection();
|
|
31
|
+
if (!t || t.rangeCount === 0 || t.isCollapsed)
|
|
32
|
+
return !1;
|
|
33
|
+
const n = t.getRangeAt(0);
|
|
34
|
+
if (n.collapsed)
|
|
35
|
+
return !1;
|
|
36
|
+
const r = A(n, e.className);
|
|
37
|
+
if (r)
|
|
38
|
+
return e.styleProperty === "backgroundColor" ? r.style.backgroundColor = e.color : r.style.color = e.color, C(r, e.getActiveEditorRoot), !0;
|
|
39
|
+
v(
|
|
40
|
+
n.commonAncestorContainer,
|
|
41
|
+
e.getActiveEditorRoot
|
|
42
|
+
)?.focus({ preventScroll: !0 });
|
|
43
|
+
try {
|
|
44
|
+
document.execCommand("styleWithCSS", !1, "true");
|
|
45
|
+
} catch {
|
|
46
|
+
}
|
|
47
|
+
let l = !1;
|
|
48
|
+
if (e.commands.forEach((o) => {
|
|
49
|
+
l || (l = document.execCommand(o, !1, e.color));
|
|
50
|
+
}), !l && !p(n)) {
|
|
51
|
+
const o = document.createElement("span");
|
|
52
|
+
e.styleProperty === "backgroundColor" ? o.style.backgroundColor = e.color : o.style.color = e.color, o.className = e.className;
|
|
53
|
+
const a = n.extractContents();
|
|
54
|
+
o.appendChild(a), n.insertNode(o), n.setStartAfter(o), n.collapse(!0), t.removeAllRanges(), t.addRange(n), l = !0;
|
|
55
|
+
}
|
|
56
|
+
return l ? (C(n.commonAncestorContainer, e.getActiveEditorRoot), !0) : (e.warnMessage && console.warn(e.warnMessage), !1);
|
|
57
|
+
} catch (t) {
|
|
58
|
+
return e.warnMessage ? console.error(e.warnMessage, t) : console.error("[ColorApply] Failed to apply color", t), !1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function T({
|
|
62
|
+
popover: e,
|
|
63
|
+
anchor: t,
|
|
64
|
+
onClose: n,
|
|
65
|
+
gap: r = 6,
|
|
66
|
+
margin: c = 8,
|
|
67
|
+
zIndex: l = 1e4
|
|
68
|
+
}) {
|
|
69
|
+
e.style.position = "fixed", e.style.zIndex = `${l}`, e.style.visibility = "hidden";
|
|
70
|
+
const o = () => {
|
|
71
|
+
if (!e.isConnected || !t.isConnected) {
|
|
72
|
+
n();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const s = t.getBoundingClientRect();
|
|
76
|
+
if (s.width === 0 && s.height === 0) {
|
|
77
|
+
n();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const i = e.getBoundingClientRect(), w = i.width || e.offsetWidth || 220, f = i.height || e.offsetHeight || 260, y = window.innerWidth, E = window.innerHeight;
|
|
81
|
+
let u = s.left, d = s.bottom + r;
|
|
82
|
+
if (u + w > y - c && (u = y - w - c), u = Math.max(c, u), d + f > E - c) {
|
|
83
|
+
const g = s.top - f - r;
|
|
84
|
+
g >= c ? d = g : d = Math.max(c, E - f - c);
|
|
85
|
+
}
|
|
86
|
+
d < c && (d = c), e.style.left = `${Math.round(u)}px`, e.style.top = `${Math.round(d)}px`, e.style.visibility = "visible";
|
|
87
|
+
}, a = () => {
|
|
88
|
+
o();
|
|
89
|
+
}, m = (s) => {
|
|
90
|
+
const i = s.target;
|
|
91
|
+
i && (e.contains(i) || t.contains(i) || n());
|
|
92
|
+
}, h = (s) => {
|
|
93
|
+
s.key === "Escape" && n();
|
|
94
|
+
};
|
|
95
|
+
window.addEventListener("resize", a), window.addEventListener("scroll", a, !0), document.addEventListener("keydown", h);
|
|
96
|
+
const R = window.requestAnimationFrame(() => {
|
|
97
|
+
document.addEventListener("mousedown", m, !0);
|
|
98
|
+
});
|
|
99
|
+
return o(), { reposition: o, destroy: () => {
|
|
100
|
+
window.cancelAnimationFrame(R), window.removeEventListener("resize", a), window.removeEventListener("scroll", a, !0), document.removeEventListener("keydown", h), document.removeEventListener("mousedown", m, !0);
|
|
101
|
+
} };
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
N as a,
|
|
105
|
+
T as b
|
|
106
|
+
};
|