@editora/core 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.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  3. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  4. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  5. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  6. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  7. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  8. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  9. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  10. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  11. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  12. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  13. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  14. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  15. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  16. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  17. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  18. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  19. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  20. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  21. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  22. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +86 -77
  23. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  24. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  25. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  26. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  27. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  28. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  29. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  30. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  31. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  32. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  33. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  34. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  35. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  36. package/dist/editora.min.js +13 -13
  37. package/dist/editora.umd.js +13 -13
  38. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  39. package/dist/index-BslAFzmv.mjs +16544 -0
  40. package/dist/index-D1LOqg5C.js +10 -0
  41. package/dist/{index-OwnkG39N.mjs → index-DqC57IEH.mjs} +438 -328
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  44. package/dist/index.esm.js +2 -2
  45. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  46. package/dist/plugin-loader.js +77 -40
  47. package/dist/webcomponent-core.js +456 -346
  48. package/dist/webcomponent-core.min.css +1 -1
  49. package/dist/webcomponent-core.min.js +87 -107
  50. package/dist/webcomponent.cjs.js +1 -1
  51. package/dist/webcomponent.esm.js +1 -1
  52. package/dist/webcomponent.js +503 -356
  53. package/dist/webcomponent.min.css +1 -1
  54. package/dist/webcomponent.min.js +6003 -658
  55. package/package.json +2 -2
  56. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  57. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  58. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  59. package/dist/documentManager-irzj9n3V.mjs +0 -37627
  60. package/dist/index-CqWQFb3D.js +0 -10
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ajay Kumar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,10 +1,19 @@
1
- import { f as S, g as D } from "./editorContainerHelpers-C7kdWnS0.mjs";
2
- const b = /* @__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(), y = '[data-theme="dark"], .dark, .editora-theme-dark';
3
+ function z(t, l) {
4
+ if (l === t.innerHTML) return;
5
+ const i = window.execEditorCommand || window.executeEditorCommand;
6
+ if (typeof i == "function")
7
+ try {
8
+ i("recordDomTransaction", t, l, t.innerHTML);
9
+ } catch (r) {
10
+ }
11
+ }
3
12
  function R() {
4
13
  if (typeof window == "undefined" || window.__anchorObserverInitialized) return;
5
14
  window.__anchorObserverInitialized = !0, new MutationObserver((l) => {
6
- l.forEach((d) => {
7
- d.removedNodes.forEach((r) => {
15
+ l.forEach((i) => {
16
+ i.removedNodes.forEach((r) => {
8
17
  var n, e;
9
18
  if (r.nodeType === Node.ELEMENT_NODE) {
10
19
  const a = r;
@@ -12,10 +21,10 @@ function R() {
12
21
  const c = a.id;
13
22
  c && b.delete(c);
14
23
  }
15
- const u = (e = a.querySelectorAll) == null ? void 0 : e.call(a, ".rte-anchor");
16
- u == null || u.forEach((c) => {
17
- const h = c.id;
18
- h && b.delete(h);
24
+ const f = (e = a.querySelectorAll) == null ? void 0 : e.call(a, ".rte-anchor");
25
+ f == null || f.forEach((c) => {
26
+ const u = c.id;
27
+ u && b.delete(u);
19
28
  });
20
29
  }
21
30
  });
@@ -25,36 +34,36 @@ function R() {
25
34
  subtree: !0
26
35
  });
27
36
  }
28
- function A(o) {
29
- 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" };
37
+ function A(t) {
38
+ 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" };
30
39
  }
31
- function N() {
32
- const o = S();
33
- if (!o) return;
34
- const l = D(o);
40
+ function M() {
41
+ const t = D();
42
+ if (!t) return;
43
+ const l = S(t);
35
44
  if (!l) return;
36
- const d = l.querySelectorAll(".rte-anchor"), r = /* @__PURE__ */ new Set();
37
- d.forEach((n) => {
45
+ const i = l.querySelectorAll(".rte-anchor"), r = /* @__PURE__ */ new Set();
46
+ i.forEach((n) => {
38
47
  const e = n.id;
39
48
  e && r.add(e);
40
49
  }), b.clear(), r.forEach((n) => b.add(n));
41
50
  }
42
- function M(o) {
43
- if (o) {
44
- const r = o.startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
45
- if (n != null && n.closest(m)) return !0;
51
+ function H(t) {
52
+ if (t) {
53
+ const r = t.startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
54
+ if (n != null && n.closest(y)) return !0;
46
55
  }
47
56
  const l = window.getSelection();
48
57
  if (l && l.rangeCount > 0) {
49
58
  const r = l.getRangeAt(0).startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
50
- if (n != null && n.closest(m)) return !0;
59
+ if (n != null && n.closest(y)) return !0;
51
60
  }
52
- const d = document.activeElement;
53
- return d != null && d.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
61
+ const i = document.activeElement;
62
+ return i != null && i.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
54
63
  }
55
- function _(o, l, d, r) {
56
- N();
57
- const n = M(r), e = n ? {
64
+ function _(t, l, i, r) {
65
+ M();
66
+ const n = H(r), e = n ? {
58
67
  overlay: "rgba(0, 0, 0, 0.62)",
59
68
  dialogBg: "#1f2937",
60
69
  panelBg: "#222d3a",
@@ -116,8 +125,8 @@ function _(o, l, d, r) {
116
125
  z-index: 10000;
117
126
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
118
127
  `;
119
- const u = document.createElement("div");
120
- if (u.className = "rte-anchor-dialog", u.style.cssText = `
128
+ const f = document.createElement("div");
129
+ if (f.className = "rte-anchor-dialog", f.style.cssText = `
121
130
  background: ${e.dialogBg};
122
131
  border: 1px solid ${e.border};
123
132
  border-radius: 8px;
@@ -127,8 +136,8 @@ function _(o, l, d, r) {
127
136
  overflow: hidden;
128
137
  animation: rte-anchor-dialog-appear 0.2s ease;
129
138
  `, !document.getElementById("rte-anchor-dialog-styles")) {
130
- const s = document.createElement("style");
131
- s.id = "rte-anchor-dialog-styles", s.textContent = `
139
+ const d = document.createElement("style");
140
+ d.id = "rte-anchor-dialog-styles", d.textContent = `
132
141
  @keyframes rte-anchor-dialog-appear {
133
142
  from { opacity: 0; transform: scale(0.95); }
134
143
  to { opacity: 1; transform: scale(1); }
@@ -136,11 +145,11 @@ function _(o, l, d, r) {
136
145
  .rte-anchor-dialog input:focus {
137
146
  outline: none !important;
138
147
  }
139
- `, document.head.appendChild(s);
148
+ `, document.head.appendChild(d);
140
149
  }
141
150
  let c = "";
142
- const h = document.createElement("div");
143
- h.style.cssText = `
151
+ const u = document.createElement("div");
152
+ u.style.cssText = `
144
153
  display: flex;
145
154
  align-items: center;
146
155
  justify-content: space-between;
@@ -148,8 +157,8 @@ function _(o, l, d, r) {
148
157
  border-bottom: 1px solid ${e.border};
149
158
  background: ${e.panelBg};
150
159
  `;
151
- const E = document.createElement("h3");
152
- E.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, E.textContent = "Add Anchor";
160
+ const m = document.createElement("h3");
161
+ m.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, m.textContent = "Add Anchor";
153
162
  const p = document.createElement("button");
154
163
  p.textContent = "✕", p.style.cssText = `
155
164
  background: none;
@@ -169,15 +178,15 @@ function _(o, l, d, r) {
169
178
  p.style.background = e.closeHoverBg, p.style.color = "#f8fafc";
170
179
  }, p.onmouseout = () => {
171
180
  p.style.background = "none", p.style.color = e.muted;
172
- }, h.appendChild(E), h.appendChild(p);
181
+ }, u.appendChild(m), u.appendChild(p);
173
182
  const C = document.createElement("div");
174
183
  C.style.cssText = "padding: 20px;";
175
184
  const x = document.createElement("div");
176
185
  x.style.cssText = "margin-bottom: 0;";
177
- const y = document.createElement("label");
178
- 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");
179
- const t = document.createElement("input");
180
- t.id = "anchor-id-input", t.type = "text", t.placeholder = "e.g., section-introduction", t.value = "", t.style.cssText = `
186
+ const v = document.createElement("label");
187
+ v.textContent = "Anchor ID", v.style.cssText = `display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`, v.setAttribute("for", "anchor-id-input");
188
+ const o = document.createElement("input");
189
+ o.id = "anchor-id-input", o.type = "text", o.placeholder = "e.g., section-introduction", o.value = "", o.style.cssText = `
181
190
  width: 100%;
182
191
  padding: 10px 12px;
183
192
  font-size: 14px;
@@ -188,18 +197,18 @@ function _(o, l, d, r) {
188
197
  background: ${e.fieldBg};
189
198
  transition: all 0.2s ease;
190
199
  box-sizing: border-box;
191
- `, t.style.setProperty("caret-color", e.fieldText);
192
- const f = document.createElement("div");
193
- f.style.cssText = `
200
+ `, o.style.setProperty("caret-color", e.fieldText);
201
+ const g = document.createElement("div");
202
+ g.style.cssText = `
194
203
  color: #d32f2f;
195
204
  font-size: 12px;
196
205
  margin-top: 6px;
197
206
  display: none;
198
207
  `;
199
208
  const B = document.createElement("div");
200
- 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;`, x.appendChild(y), x.appendChild(t), x.appendChild(f), x.appendChild(B), C.appendChild(x);
201
- const v = document.createElement("div");
202
- v.style.cssText = `
209
+ 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;`, x.appendChild(v), x.appendChild(o), x.appendChild(g), x.appendChild(B), C.appendChild(x);
210
+ const w = document.createElement("div");
211
+ w.style.cssText = `
203
212
  display: flex;
204
213
  gap: 12px;
205
214
  padding: 16px 20px;
@@ -207,8 +216,8 @@ function _(o, l, d, r) {
207
216
  background: ${e.panelBg};
208
217
  justify-content: flex-end;
209
218
  `;
210
- const g = document.createElement("button");
211
- g.textContent = "Cancel", g.style.cssText = `
219
+ const h = document.createElement("button");
220
+ h.textContent = "Cancel", h.style.cssText = `
212
221
  padding: 8px 16px;
213
222
  font-size: 14px;
214
223
  font-weight: 500;
@@ -218,9 +227,9 @@ function _(o, l, d, r) {
218
227
  transition: all 0.2s ease;
219
228
  background: ${e.cancelBg};
220
229
  color: ${e.cancelText};
221
- `, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
222
- const i = document.createElement("button");
223
- i.textContent = "Add Anchor", i.style.cssText = `
230
+ `, h.onmouseover = () => h.style.background = e.cancelHover, h.onmouseout = () => h.style.background = e.cancelBg;
231
+ const s = document.createElement("button");
232
+ s.textContent = "Add Anchor", s.style.cssText = `
224
233
  padding: 8px 16px;
225
234
  font-size: 14px;
226
235
  font-weight: 500;
@@ -230,66 +239,81 @@ function _(o, l, d, r) {
230
239
  transition: all 0.2s ease;
231
240
  background: ${e.saveBg};
232
241
  color: white;
233
- `, i.disabled = !t.value.trim();
234
- const z = () => {
235
- t.value.trim() ? (i.disabled = !1, i.style.background = e.saveBg, i.style.color = "white", i.style.cursor = "pointer") : (i.disabled = !0, i.style.background = e.saveDisabledBg, i.style.color = e.saveDisabledText, i.style.cursor = "not-allowed");
242
+ `, s.disabled = !o.value.trim();
243
+ const $ = () => {
244
+ o.value.trim() ? (s.disabled = !1, s.style.background = e.saveBg, s.style.color = "white", s.style.cursor = "pointer") : (s.disabled = !0, s.style.background = e.saveDisabledBg, s.style.color = e.saveDisabledText, s.style.cursor = "not-allowed");
236
245
  };
237
- i.onmouseover = () => {
238
- i.disabled || (i.style.background = e.saveHover, i.style.boxShadow = n ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
239
- }, i.onmouseout = () => {
240
- i.disabled || (i.style.background = e.saveBg, i.style.boxShadow = "none");
241
- }, v.appendChild(g), v.appendChild(i), t.oninput = () => {
242
- const s = t.value;
243
- if (z(), s.trim()) {
244
- const k = A(s);
245
- k.valid ? b.has(s) ? (c = `Anchor ID already exists: ${s}`, f.textContent = "⚠ " + c, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg) : (c = "", f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg) : (c = k.error, f.textContent = "⚠ " + c, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg);
246
+ s.onmouseover = () => {
247
+ s.disabled || (s.style.background = e.saveHover, s.style.boxShadow = n ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
248
+ }, s.onmouseout = () => {
249
+ s.disabled || (s.style.background = e.saveBg, s.style.boxShadow = "none");
250
+ }, w.appendChild(h), w.appendChild(s), o.oninput = () => {
251
+ const d = o.value;
252
+ if ($(), d.trim()) {
253
+ const k = A(d);
254
+ k.valid ? b.has(d) ? (c = `Anchor ID already exists: ${d}`, g.textContent = "⚠ " + c, g.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (c = "", g.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (c = k.error, g.textContent = "⚠ " + c, g.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg);
246
255
  } else
247
- f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg;
248
- }, t.onfocus = () => {
249
- t.style.borderColor = c ? e.fieldErrorBorder : e.saveBg, t.style.boxShadow = c ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, t.style.background = c ? e.fieldErrorBg : e.fieldFocusBg;
250
- }, t.onblur = () => {
251
- t.style.boxShadow = "none", c || (t.style.background = e.fieldBg);
256
+ g.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg;
257
+ }, o.onfocus = () => {
258
+ o.style.borderColor = c ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = c ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = c ? e.fieldErrorBg : e.fieldFocusBg;
259
+ }, o.onblur = () => {
260
+ o.style.boxShadow = "none", c || (o.style.background = e.fieldBg);
252
261
  };
253
262
  const T = () => {
254
- const s = t.value.trim();
255
- !s || !A(s).valid || b.has(s) || (d && d(s), a.remove());
256
- }, w = () => {
263
+ const d = o.value.trim();
264
+ !d || !A(d).valid || b.has(d) || (i && i(d), a.remove());
265
+ }, E = () => {
257
266
  a.remove();
258
267
  };
259
- i.onclick = T, g.onclick = w, p.onclick = w, t.onkeydown = (s) => {
260
- s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), w());
261
- }, a.onclick = (s) => {
262
- s.target === a && w();
263
- }, u.appendChild(h), u.appendChild(C), u.appendChild(v), a.appendChild(u), document.body.appendChild(a), setTimeout(() => t.focus(), 100);
268
+ s.onclick = T, h.onclick = E, p.onclick = E, o.onkeydown = (d) => {
269
+ d.key === "Enter" ? (d.preventDefault(), T()) : d.key === "Escape" && (d.preventDefault(), E());
270
+ }, a.onclick = (d) => {
271
+ d.target === a && E();
272
+ }, f.appendChild(u), f.appendChild(C), f.appendChild(w), a.appendChild(f), document.body.appendChild(a), setTimeout(() => o.focus(), 100);
264
273
  }
265
- function H(o, l) {
266
- let d;
274
+ function I(t, l) {
275
+ var c;
276
+ let i;
267
277
  if (l)
268
- d = l;
278
+ i = l;
269
279
  else {
270
- const a = window.getSelection();
271
- if (!a || a.rangeCount === 0) return;
272
- d = a.getRangeAt(0);
280
+ const u = window.getSelection();
281
+ if (!u || u.rangeCount === 0) return;
282
+ i = u.getRangeAt(0);
273
283
  }
274
- const r = document.createElement("span");
275
- 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 = `
284
+ let r = null, n = i.startContainer;
285
+ for (; n && n !== document.body; ) {
286
+ if (n.nodeType === Node.ELEMENT_NODE) {
287
+ const u = n;
288
+ if (u.getAttribute("contenteditable") === "true") {
289
+ r = u;
290
+ break;
291
+ }
292
+ }
293
+ n = n.parentNode;
294
+ }
295
+ const e = (c = r == null ? void 0 : r.innerHTML) != null ? c : "", a = document.createElement("span");
296
+ a.id = t, a.className = "rte-anchor", a.setAttribute("data-type", "anchor"), a.setAttribute("data-anchor-id", t), a.setAttribute("title", `Anchor: ${t}`), a.style.cssText = `
276
297
  display: inline;
277
298
  position: relative;
278
299
  cursor: pointer;
279
- `, d.insertNode(r), b.add(o), d.setStart(r.nextSibling || r.parentNode, 0), d.collapse(!0);
280
- const n = window.getSelection();
281
- n && (n.removeAllRanges(), n.addRange(d));
282
- const e = S();
283
- if (e) {
284
- const a = D(e);
285
- a && a.dispatchEvent(new Event("input", { bubbles: !0 }));
300
+ `, i.insertNode(a), b.add(t), i.setStart(a.nextSibling || a.parentNode, 0), i.collapse(!0);
301
+ const f = window.getSelection();
302
+ if (f && (f.removeAllRanges(), f.addRange(i)), r)
303
+ z(r, e), r.dispatchEvent(new Event("input", { bubbles: !0 }));
304
+ else {
305
+ const u = D();
306
+ if (u) {
307
+ const m = S(u);
308
+ m && m.dispatchEvent(new Event("input", { bubbles: !0 }));
309
+ }
286
310
  }
287
- $();
311
+ N();
288
312
  }
289
- function $() {
313
+ function N() {
290
314
  if (document.getElementById("rte-anchor-styles")) return;
291
- const o = document.createElement("style");
292
- o.id = "rte-anchor-styles", o.textContent = `
315
+ const t = document.createElement("style");
316
+ t.id = "rte-anchor-styles", t.textContent = `
293
317
  .rte-anchor {
294
318
  display: inline;
295
319
  position: relative;
@@ -367,9 +391,9 @@ function $() {
367
391
  outline: 2px solid #0066cc;
368
392
  outline-offset: 2px;
369
393
  }
370
- `, document.head.appendChild(o);
394
+ `, document.head.appendChild(t);
371
395
  }
372
- const O = () => (typeof window != "undefined" && (R(), $()), {
396
+ const O = () => (typeof window != "undefined" && (R(), N()), {
373
397
  name: "anchor",
374
398
  toolbar: [
375
399
  {
@@ -382,15 +406,15 @@ const O = () => (typeof window != "undefined" && (R(), $()), {
382
406
  commands: {
383
407
  insertAnchor: () => {
384
408
  try {
385
- const o = window.getSelection();
386
- if (!o || o.rangeCount === 0)
409
+ const t = window.getSelection();
410
+ if (!t || t.rangeCount === 0)
387
411
  return alert("Please place your cursor where you want to insert the anchor."), !1;
388
- const l = o.getRangeAt(0).cloneRange();
389
- return _("add", "", (d) => {
390
- H(d, l);
412
+ const l = t.getRangeAt(0).cloneRange();
413
+ return _("add", "", (i) => {
414
+ I(i, l);
391
415
  }, l), !0;
392
- } catch (o) {
393
- return console.error("Failed to insert anchor:", o), !1;
416
+ } catch (t) {
417
+ return console.error("Failed to insert anchor:", t), !1;
394
418
  }
395
419
  }
396
420
  },
@@ -401,4 +425,4 @@ const O = () => (typeof window != "undefined" && (R(), $()), {
401
425
  export {
402
426
  O as AnchorPlugin
403
427
  };
404
- //# sourceMappingURL=AnchorPlugin.native-C1Rw5m04.mjs.map
428
+ //# sourceMappingURL=AnchorPlugin.native-BcYGEtd9.mjs.map