@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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -4
  3. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  4. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  5. package/dist/anchor.cjs.js +11 -11
  6. package/dist/anchor.esm.js +130 -107
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +447 -0
  10. package/dist/approval-workflow.esm.js +1070 -0
  11. package/dist/background-color.cjs.js +3 -3
  12. package/dist/background-color.esm.js +116 -119
  13. package/dist/blocks-library.cjs.js +442 -0
  14. package/dist/blocks-library.esm.js +1317 -0
  15. package/dist/citations.cjs.js +548 -0
  16. package/dist/citations.esm.js +1457 -0
  17. package/dist/code.cjs.js +82 -102
  18. package/dist/code.esm.js +1172 -662
  19. package/dist/comments.cjs.js +10 -10
  20. package/dist/comments.esm.js +195 -177
  21. package/dist/conditional-content.cjs.js +626 -0
  22. package/dist/conditional-content.esm.js +1360 -0
  23. package/dist/content-rules.cjs.js +408 -0
  24. package/dist/content-rules.esm.js +1093 -0
  25. package/dist/data-binding.cjs.js +321 -0
  26. package/dist/data-binding.esm.js +913 -0
  27. package/dist/doc-schema.cjs.js +398 -0
  28. package/dist/doc-schema.esm.js +1310 -0
  29. package/dist/document-manager.cjs.js +1 -1
  30. package/dist/document-manager.esm.js +1 -1
  31. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  32. package/dist/documentManager-Jf0RbSks.js +17 -0
  33. package/dist/embed-iframe.cjs.js +2 -2
  34. package/dist/embed-iframe.esm.js +8 -5
  35. package/dist/emojis.cjs.js +64 -39
  36. package/dist/emojis.esm.js +133 -104
  37. package/dist/enterprise.cjs.js +1 -0
  38. package/dist/enterprise.esm.js +56 -0
  39. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  40. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  41. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  42. package/dist/index-CvJk4DKa.js +221 -0
  43. package/dist/index-D3CycEFU.mjs +16543 -0
  44. package/dist/index-tqLTHcO6.js +1 -0
  45. package/dist/index.cjs.js +1 -1
  46. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  47. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  48. package/dist/index.esm.js +111 -75
  49. package/dist/jspdf.es.min-BoS80556.js +77 -0
  50. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  51. package/dist/link.cjs.js +6 -6
  52. package/dist/link.esm.js +41 -39
  53. package/dist/math.cjs.js +21 -21
  54. package/dist/math.esm.js +151 -112
  55. package/dist/media-manager.cjs.js +15 -15
  56. package/dist/media-manager.esm.js +227 -206
  57. package/dist/mentions.cjs.js +105 -0
  58. package/dist/mentions.esm.js +726 -0
  59. package/dist/merge-tag.cjs.js +44 -12
  60. package/dist/merge-tag.esm.js +368 -241
  61. package/dist/page-break.cjs.js +2 -2
  62. package/dist/page-break.esm.js +85 -77
  63. package/dist/pii-redaction.cjs.js +436 -0
  64. package/dist/pii-redaction.esm.js +1377 -0
  65. package/dist/preview.cjs.js +3 -3
  66. package/dist/preview.esm.js +29 -29
  67. package/dist/slash-commands.cjs.js +90 -0
  68. package/dist/slash-commands.esm.js +752 -0
  69. package/dist/smart-paste.cjs.js +398 -0
  70. package/dist/smart-paste.esm.js +1388 -0
  71. package/dist/special-characters.cjs.js +83 -45
  72. package/dist/special-characters.esm.js +149 -100
  73. package/dist/spell-check.cjs.js +9 -9
  74. package/dist/spell-check.esm.js +235 -216
  75. package/dist/template.cjs.js +14 -14
  76. package/dist/template.esm.js +157 -131
  77. package/dist/text-color.cjs.js +9 -9
  78. package/dist/text-color.esm.js +131 -115
  79. package/dist/track-changes.cjs.js +77 -0
  80. package/dist/track-changes.esm.js +755 -0
  81. package/dist/translation-workflow.cjs.js +626 -0
  82. package/dist/translation-workflow.esm.js +1718 -0
  83. package/dist/version-diff.cjs.js +362 -0
  84. package/dist/version-diff.esm.js +768 -0
  85. package/index.d.ts +849 -1
  86. package/package.json +105 -6
  87. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  88. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  89. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  90. package/dist/documentManager-_tQQfQi9.js +0 -317
  91. package/dist/index-D3pJyAsj.js +0 -1
@@ -1,19 +1,28 @@
1
- import { f as S, g as D } from "./editorContainerHelpers-C7kdWnS0.mjs";
2
- const h = /* @__PURE__ */ new Set(), m = '[data-theme="dark"], .dark, .editora-theme-dark';
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((l) => {
6
- l.forEach((i) => {
7
- i.removedNodes.forEach((r) => {
8
- if (r.nodeType === Node.ELEMENT_NODE) {
9
- const d = r;
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 a = d.id;
12
- a && h.delete(a);
20
+ const r = d.id;
21
+ r && b.delete(r);
13
22
  }
14
- d.querySelectorAll?.(".rte-anchor")?.forEach((a) => {
15
- const u = a.id;
16
- u && h.delete(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(o) {
27
- return !o || o.trim().length === 0 ? { valid: !1, error: "Anchor ID cannot be empty" } : o.length > 256 ? { valid: !1, error: "Anchor ID must be less than 256 characters" } : /^[a-z_]/.test(o) ? /^[a-z0-9\-_]+$/.test(o) ? { 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" };
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 N() {
30
- const o = S();
31
- if (!o) return;
32
- const l = D(o);
33
- if (!l) return;
34
- const i = l.querySelectorAll(".rte-anchor"), r = /* @__PURE__ */ new Set();
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 && r.add(e);
38
- }), h.clear(), r.forEach((d) => h.add(d));
46
+ e && n.add(e);
47
+ }), b.clear(), n.forEach((d) => b.add(d));
39
48
  }
40
- function M(o) {
41
- if (o) {
42
- const r = o.startContainer;
43
- if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(m)) return !0;
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 l = window.getSelection();
46
- if (l && l.rangeCount > 0) {
47
- const r = l.getRangeAt(0).startContainer;
48
- if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(m)) return !0;
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(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
59
+ return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
51
60
  }
52
- function _(o, l, i, r) {
53
- N();
54
- const d = M(r), e = 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
- }, a = document.createElement("div");
103
- a.className = "rte-anchor-dialog-overlay", a.style.cssText = `
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 p = "";
139
- const x = document.createElement("div");
140
- x.style.cssText = `
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 c = document.createElement("button");
151
- c.textContent = "✕", c.style.cssText = `
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
- `, c.onmouseover = () => {
166
- c.style.background = e.closeHoverBg, c.style.color = "#f8fafc";
167
- }, c.onmouseout = () => {
168
- c.style.background = "none", c.style.color = e.muted;
169
- }, x.appendChild(w), x.appendChild(c);
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 b = document.createElement("div");
173
- b.style.cssText = "margin-bottom: 0;";
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 t = document.createElement("input");
177
- t.id = "anchor-id-input", t.type = "text", t.placeholder = "e.g., section-introduction", t.value = "", t.style.cssText = `
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
- `, t.style.setProperty("caret-color", e.fieldText);
189
- const f = document.createElement("div");
190
- f.style.cssText = `
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;`, b.appendChild(y), b.appendChild(t), b.appendChild(f), b.appendChild(B), C.appendChild(b);
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 n = document.createElement("button");
220
- n.textContent = "Add Anchor", n.style.cssText = `
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
- `, n.disabled = !t.value.trim();
231
- const z = () => {
232
- t.value.trim() ? (n.disabled = !1, n.style.background = e.saveBg, n.style.color = "white", n.style.cursor = "pointer") : (n.disabled = !0, n.style.background = e.saveDisabledBg, n.style.color = e.saveDisabledText, n.style.cursor = "not-allowed");
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
- n.onmouseover = () => {
235
- n.disabled || (n.style.background = e.saveHover, n.style.boxShadow = d ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
236
- }, n.onmouseout = () => {
237
- n.disabled || (n.style.background = e.saveBg, n.style.boxShadow = "none");
238
- }, v.appendChild(g), v.appendChild(n), t.oninput = () => {
239
- const s = t.value;
240
- if (z(), s.trim()) {
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 ? h.has(s) ? (p = `Anchor ID already exists: ${s}`, f.textContent = "⚠ " + p, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg) : (p = "", f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg) : (p = k.error, f.textContent = "⚠ " + p, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg);
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
- f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg;
245
- }, t.onfocus = () => {
246
- t.style.borderColor = p ? e.fieldErrorBorder : e.saveBg, t.style.boxShadow = p ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, t.style.background = p ? e.fieldErrorBg : e.fieldFocusBg;
247
- }, t.onblur = () => {
248
- t.style.boxShadow = "none", p || (t.style.background = e.fieldBg);
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 = t.value.trim();
252
- !s || !A(s).valid || h.has(s) || (i && i(s), a.remove());
260
+ const s = o.value.trim();
261
+ !s || !A(s).valid || b.has(s) || (i && i(s), r.remove());
253
262
  }, E = () => {
254
- a.remove();
263
+ r.remove();
255
264
  };
256
- n.onclick = T, g.onclick = E, c.onclick = E, t.onkeydown = (s) => {
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
- }, a.onclick = (s) => {
259
- s.target === a && E();
260
- }, u.appendChild(x), u.appendChild(C), u.appendChild(v), a.appendChild(u), document.body.appendChild(a), setTimeout(() => t.focus(), 100);
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 H(o, l) {
271
+ function I(t, c) {
263
272
  let i;
264
- if (l)
265
- i = l;
273
+ if (c)
274
+ i = c;
266
275
  else {
267
- const a = window.getSelection();
268
- if (!a || a.rangeCount === 0) return;
269
- i = a.getRangeAt(0);
276
+ const l = window.getSelection();
277
+ if (!l || l.rangeCount === 0) return;
278
+ i = l.getRangeAt(0);
270
279
  }
271
- const r = document.createElement("span");
272
- r.id = o, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", o), r.setAttribute("title", `Anchor: ${o}`), r.style.cssText = `
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), h.add(o), i.setStart(r.nextSibling || r.parentNode, 0), i.collapse(!0);
277
- const d = window.getSelection();
278
- d && (d.removeAllRanges(), d.addRange(i));
279
- const e = S();
280
- if (e) {
281
- const a = D(e);
282
- a && a.dispatchEvent(new Event("input", { bubbles: !0 }));
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 o = document.createElement("style");
289
- o.id = "rte-anchor-styles", o.textContent = `
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(o);
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 o = window.getSelection();
383
- if (!o || o.rangeCount === 0)
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 l = o.getRangeAt(0).cloneRange();
408
+ const c = t.getRangeAt(0).cloneRange();
386
409
  return _("add", "", (i) => {
387
- H(i, l);
388
- }, l), !0;
389
- } catch (o) {
390
- return console.error("Failed to insert anchor:", o), !1;
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
+ };