@editora/core 1.0.15 → 1.0.17

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 (68) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-XsYC_KdJ.mjs +3923 -0
  48. package/dist/index-_eKRBZPq.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2055 -476
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2223 -643
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
@@ -1,45 +1,46 @@
1
- const C = /* @__PURE__ */ new WeakMap();
2
- let x = null, S = !1, k = 0;
3
- const E = "User";
4
- function v(e) {
5
- return k += 1, `${e}-${Date.now()}-${k}`;
1
+ import { r as D } from "./historyHelpers-B0-4mq1E.mjs";
2
+ const w = /* @__PURE__ */ new WeakMap();
3
+ let x = null, R = !1, H = 0;
4
+ const T = "User";
5
+ function S(e) {
6
+ return H += 1, `${e}-${Date.now()}-${H}`;
6
7
  }
7
- function y(e) {
8
+ function v(e) {
8
9
  if (!e) return null;
9
10
  const t = e instanceof Element ? e : e.parentElement;
10
11
  return t ? t.closest("[data-editora-editor]") || t.closest(".rte-editor") || t.closest(".editora-editor") : null;
11
12
  }
12
- function A(e) {
13
+ function q(e) {
13
14
  const t = (e == null ? void 0 : e.editorElement) || (e == null ? void 0 : e.contentElement) || null;
14
15
  if (!(t instanceof HTMLElement)) return;
15
16
  const r = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null);
16
17
  r && (x = r);
17
18
  }
18
- function w(e, t) {
19
+ function k(e, t) {
19
20
  return t.contains(e.commonAncestorContainer);
20
21
  }
21
- function $() {
22
+ function B() {
22
23
  if (typeof window != "undefined") {
23
24
  const o = window.__editoraCommandEditorRoot;
24
25
  if (o instanceof HTMLElement) {
25
- const a = o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (o.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? o : null);
26
- if (a)
27
- return x = a, window.__editoraCommandEditorRoot = null, a;
26
+ const n = o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (o.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? o : null);
27
+ if (n)
28
+ return x = n, window.__editoraCommandEditorRoot = null, n;
28
29
  }
29
30
  }
30
- const e = document.activeElement, t = e ? y(e) : null;
31
+ const e = document.activeElement, t = e ? v(e) : null;
31
32
  if (t) return t;
32
33
  const r = window.getSelection();
33
34
  if (r && r.rangeCount > 0) {
34
- const o = y(
35
+ const o = v(
35
36
  r.getRangeAt(0).commonAncestorContainer
36
37
  );
37
38
  if (o) return o;
38
39
  }
39
40
  return x;
40
41
  }
41
- function q(e) {
42
- const t = C.get(e);
42
+ function $(e) {
43
+ const t = w.get(e);
43
44
  if (t) return t;
44
45
  const r = {
45
46
  root: e,
@@ -52,35 +53,50 @@ function q(e) {
52
53
  newCommentText: "",
53
54
  selectionChangeListener: null
54
55
  };
55
- return C.set(e, r), r;
56
+ return w.set(e, r), r;
56
57
  }
57
58
  function u() {
58
- const e = $();
59
- return e ? (x = e, q(e)) : null;
59
+ const e = B();
60
+ return e ? (x = e, $(e)) : null;
60
61
  }
61
- function R(e) {
62
+ function M(e) {
62
63
  const t = window.getSelection();
63
64
  if (!t || t.rangeCount === 0 || t.isCollapsed) return null;
64
65
  const r = t.getRangeAt(0);
65
- return w(r, e) ? r.cloneRange() : null;
66
+ return k(r, e) ? r.cloneRange() : null;
67
+ }
68
+ function O(e) {
69
+ return e.root.querySelector(".rte-content") || e.root.querySelector("[contenteditable]");
66
70
  }
67
- function I(e, t) {
68
- if (!t.anchorId) return;
69
- const r = e.root.querySelector(`#${t.anchorId}`);
71
+ function E(e, t) {
72
+ return t.anchorId ? e.root.querySelector(`[id="${t.anchorId}"]`) : null;
73
+ }
74
+ function P(e) {
75
+ const t = [];
76
+ return e.comments.forEach((r) => {
77
+ if (r.anchorId) {
78
+ const o = E(e, r);
79
+ if (!o) return;
80
+ r.resolved = o.classList.contains("rte-comment-anchor-resolved");
81
+ }
82
+ t.push(r);
83
+ }), t;
84
+ }
85
+ function A(e, t) {
86
+ const r = O(e), o = r ? r.innerHTML : "", n = t();
87
+ return r && r.innerHTML !== o && (D(r, o), r.dispatchEvent(new Event("input", { bubbles: !0 }))), n;
88
+ }
89
+ function N(e, t) {
90
+ const r = E(e, t);
70
91
  r && r.classList.toggle("rte-comment-anchor-resolved", t.resolved);
71
92
  }
72
- function b(e, t, r) {
93
+ function y(e, t, r) {
73
94
  const o = e.comments.get(t);
74
- if (!o || !o.anchorId) return;
75
- const a = e.root.querySelector(`#${o.anchorId}`);
76
- a && a.classList.toggle("highlighted", r);
77
- }
78
- function N(e, t, r) {
79
- t.onclick = (o) => {
80
- o.preventDefault(), o.stopPropagation(), x = e.root, e.expandedComments.add(r), h(e, !0), m(e);
81
- };
95
+ if (!o) return;
96
+ const n = E(e, o);
97
+ n && n.classList.toggle("highlighted", r);
82
98
  }
83
- function z(e) {
99
+ function _(e) {
84
100
  const t = e.parentNode;
85
101
  if (t) {
86
102
  for (; e.firstChild; )
@@ -88,126 +104,130 @@ function z(e) {
88
104
  e.remove();
89
105
  }
90
106
  }
91
- function h(e, t) {
107
+ function C(e, t) {
92
108
  if (e.panelVisible = t, t) {
93
- Z(), V(e), e.root.setAttribute("data-rte-comments-open", "true"), e.panelElement && (e.panelElement.classList.add("is-open"), e.panelElement.setAttribute("aria-hidden", "false")), B(e);
109
+ Y(), j(e), e.root.setAttribute("data-rte-comments-open", "true"), e.panelElement && (e.panelElement.classList.add("is-open"), e.panelElement.setAttribute("aria-hidden", "false")), F(e);
94
110
  return;
95
111
  }
96
- e.root.removeAttribute("data-rte-comments-open"), M(e), e.panelElement && (e.panelElement.remove(), e.panelElement = null);
112
+ e.root.removeAttribute("data-rte-comments-open"), Z(e), e.panelElement && (e.panelElement.remove(), e.panelElement = null);
97
113
  }
98
- function V(e) {
114
+ function j(e) {
99
115
  if (e.panelElement) return;
100
116
  const t = document.createElement("aside");
101
117
  t.className = "rte-comments-panel", t.setAttribute("role", "complementary"), t.setAttribute("aria-label", "Comments"), t.setAttribute("aria-hidden", "true"), window.getComputedStyle(e.root).position === "static" && (e.root.style.position = "relative"), e.root.appendChild(t), e.panelElement = t;
102
118
  }
103
- function B(e) {
119
+ function F(e) {
104
120
  e.selectionChangeListener || (e.selectionChangeListener = () => {
105
121
  const t = window.getSelection();
106
122
  if (!t || t.rangeCount === 0 || t.isCollapsed) return;
107
123
  const r = t.getRangeAt(0);
108
- w(r, e.root) && (e.savedSelection = r.cloneRange(), x = e.root);
124
+ k(r, e.root) && (e.savedSelection = r.cloneRange(), x = e.root);
109
125
  }, document.addEventListener("selectionchange", e.selectionChangeListener));
110
126
  }
111
- function M(e) {
127
+ function Z(e) {
112
128
  e.selectionChangeListener && (document.removeEventListener("selectionchange", e.selectionChangeListener), e.selectionChangeListener = null);
113
129
  }
114
- function H(e) {
115
- return Array.from(e.comments.values()).sort(
116
- (t, r) => r.createdAt.localeCompare(t.createdAt)
117
- );
130
+ function z(e) {
131
+ return P(e).sort((t, r) => r.createdAt.localeCompare(t.createdAt));
118
132
  }
119
- function L(e) {
133
+ function V(e) {
120
134
  return new Date(e).toLocaleString();
121
135
  }
122
- function D(e, t) {
136
+ function K(e, t) {
123
137
  const r = e.expandedComments.has(t.id), o = document.createElement("article");
124
138
  o.className = `rte-comment-item${t.resolved ? " resolved" : ""}`, o.innerHTML = `
125
139
  <header class="rte-comment-header">
126
140
  <div class="rte-comment-meta">
127
- <strong class="rte-comment-author">${t.author}</strong>
128
- <time class="rte-comment-date">${L(t.createdAt)}</time>
141
+ <strong class="rte-comment-author"></strong>
142
+ <time class="rte-comment-date">${V(t.createdAt)}</time>
129
143
  </div>
130
144
  <button class="rte-comment-expand" type="button" aria-label="Toggle details">
131
145
  ${r ? "▾" : "▸"}
132
146
  </button>
133
147
  </header>
134
148
  <div class="rte-comment-text"></div>
135
- ${t.selectedText ? `<blockquote class="rte-comment-selection">${t.selectedText}</blockquote>` : ""}
149
+ ${t.selectedText ? '<blockquote class="rte-comment-selection"></blockquote>' : ""}
136
150
  <section class="rte-comment-expanded${r ? " show" : ""}"></section>
137
151
  `;
138
- const a = o.querySelector(".rte-comment-text");
139
- a && (a.textContent = t.text);
140
- const i = o.querySelector(".rte-comment-expand");
141
- i == null || i.addEventListener("click", () => {
142
- e.expandedComments.has(t.id) ? e.expandedComments.delete(t.id) : e.expandedComments.add(t.id), m(e);
152
+ const n = o.querySelector(".rte-comment-author");
153
+ n && (n.textContent = t.author);
154
+ const i = o.querySelector(".rte-comment-text");
155
+ i && (i.textContent = t.text);
156
+ const f = o.querySelector(".rte-comment-selection");
157
+ f && (f.textContent = t.selectedText);
158
+ const d = o.querySelector(".rte-comment-expand");
159
+ d == null || d.addEventListener("click", () => {
160
+ e.expandedComments.has(t.id) ? e.expandedComments.delete(t.id) : e.expandedComments.add(t.id), p(e);
143
161
  });
144
- const f = o.querySelector(".rte-comment-expanded");
145
- if (f && r) {
162
+ const l = o.querySelector(".rte-comment-expanded");
163
+ if (l && r) {
146
164
  if (t.replies.length > 0) {
147
- const n = document.createElement("div");
148
- n.className = "rte-comment-replies", t.replies.forEach((s) => {
149
- const p = document.createElement("div");
150
- p.className = "rte-comment-reply", p.innerHTML = `
165
+ const a = document.createElement("div");
166
+ a.className = "rte-comment-replies", t.replies.forEach((c) => {
167
+ const m = document.createElement("div");
168
+ m.className = "rte-comment-reply", m.innerHTML = `
151
169
  <div class="rte-comment-reply-header">
152
- <strong>${s.author}</strong>
153
- <time>${L(s.createdAt)}</time>
170
+ <strong class="rte-comment-reply-author"></strong>
171
+ <time>${V(c.createdAt)}</time>
154
172
  </div>
155
173
  <div class="rte-comment-reply-text"></div>
156
174
  `;
157
- const d = p.querySelector(".rte-comment-reply-text");
158
- d && (d.textContent = s.text), n.appendChild(p);
159
- }), f.appendChild(n);
175
+ const g = m.querySelector(".rte-comment-reply-author");
176
+ g && (g.textContent = c.author);
177
+ const b = m.querySelector(".rte-comment-reply-text");
178
+ b && (b.textContent = c.text), a.appendChild(m);
179
+ }), l.appendChild(a);
160
180
  }
161
181
  if (!t.resolved) {
162
- const n = document.createElement("div");
163
- n.className = "rte-comment-reply-composer", n.innerHTML = `
182
+ const a = document.createElement("div");
183
+ a.className = "rte-comment-reply-composer", a.innerHTML = `
164
184
  <textarea class="rte-comment-reply-textarea" rows="2" placeholder="Reply..."></textarea>
165
185
  <button type="button" class="rte-comment-btn primary">Reply</button>
166
186
  `;
167
- const s = n.querySelector(
187
+ const c = a.querySelector(
168
188
  ".rte-comment-reply-textarea"
169
- ), p = n.querySelector(
189
+ ), m = a.querySelector(
170
190
  ".rte-comment-btn.primary"
171
191
  );
172
- if (s && p) {
173
- s.value = e.replyTexts[t.id] || "";
174
- const d = () => {
175
- const g = !!s.value.trim();
176
- p.disabled = !g;
192
+ if (c && m) {
193
+ c.value = e.replyTexts[t.id] || "";
194
+ const g = () => {
195
+ const b = !!c.value.trim();
196
+ m.disabled = !b;
177
197
  };
178
- d(), s.addEventListener("input", () => {
179
- e.replyTexts[t.id] = s.value, d();
180
- }), p.addEventListener("click", () => {
181
- const g = s.value.trim();
182
- g && (F(t.id, E, g), e.replyTexts[t.id] = "", m(e));
198
+ g(), c.addEventListener("input", () => {
199
+ e.replyTexts[t.id] = c.value, g();
200
+ }), m.addEventListener("click", () => {
201
+ const b = c.value.trim();
202
+ b && (Q(t.id, T, b), e.replyTexts[t.id] = "", p(e));
183
203
  });
184
204
  }
185
- f.appendChild(n);
205
+ l.appendChild(a);
186
206
  }
187
- const l = document.createElement("div");
188
- if (l.className = "rte-comment-actions", t.anchorId) {
189
- const n = document.createElement("button");
190
- n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Jump to text", n.onclick = () => {
191
- const s = e.root.querySelector(`#${t.anchorId}`);
192
- s && (s.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), b(e, t.id, !0), window.setTimeout(() => b(e, t.id, !1), 1200));
193
- }, l.appendChild(n);
207
+ const s = document.createElement("div");
208
+ if (s.className = "rte-comment-actions", t.anchorId) {
209
+ const a = document.createElement("button");
210
+ a.type = "button", a.className = "rte-comment-btn ghost", a.textContent = "Jump to text", a.onclick = () => {
211
+ const c = E(e, t);
212
+ c && (c.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), y(e, t.id, !0), window.setTimeout(() => y(e, t.id, !1), 1200));
213
+ }, s.appendChild(a);
194
214
  }
195
215
  if (t.resolved) {
196
- const n = document.createElement("button");
197
- n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => _(t.id), l.appendChild(n);
216
+ const a = document.createElement("button");
217
+ a.type = "button", a.className = "rte-comment-btn ghost", a.textContent = "Reopen", a.onclick = () => G(t.id), s.appendChild(a);
198
218
  } else {
199
- const n = document.createElement("button");
200
- n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => P(t.id, E), l.appendChild(n);
219
+ const a = document.createElement("button");
220
+ a.type = "button", a.className = "rte-comment-btn success", a.textContent = "Resolve", a.onclick = () => X(t.id, T), s.appendChild(a);
201
221
  }
202
- const c = document.createElement("button");
203
- c.type = "button", c.className = "rte-comment-btn danger", c.textContent = "Delete", c.onclick = () => j(t.id), l.appendChild(c), f.appendChild(l);
222
+ const h = document.createElement("button");
223
+ h.type = "button", h.className = "rte-comment-btn danger", h.textContent = "Delete", h.onclick = () => J(t.id), s.appendChild(h), l.appendChild(s);
204
224
  }
205
- return o.addEventListener("mouseenter", () => b(e, t.id, !0)), o.addEventListener("mouseleave", () => b(e, t.id, !1)), o;
225
+ return o.addEventListener("mouseenter", () => y(e, t.id, !0)), o.addEventListener("mouseleave", () => y(e, t.id, !1)), o;
206
226
  }
207
- function m(e) {
227
+ function p(e) {
208
228
  const t = e || u();
209
229
  if (!(t != null && t.panelElement)) return;
210
- const r = H(t);
230
+ const r = z(t);
211
231
  t.panelElement.innerHTML = `
212
232
  <div class="rte-comments-header">
213
233
  <div>
@@ -226,148 +246,168 @@ function m(e) {
226
246
  `;
227
247
  const o = t.panelElement.querySelector(".rte-comments-close");
228
248
  o == null || o.addEventListener("click", () => {
229
- h(t, !1);
249
+ C(t, !1);
230
250
  });
231
- const a = t.panelElement.querySelector(
251
+ const n = t.panelElement.querySelector(
232
252
  ".new-comment-textarea"
233
253
  ), i = t.panelElement.querySelector(
234
254
  ".add-comment-btn"
235
255
  );
236
- if (a && i) {
237
- a.value = t.newCommentText;
238
- const l = () => {
239
- const c = !!a.value.trim();
240
- i.disabled = !c;
256
+ if (n && i) {
257
+ n.value = t.newCommentText;
258
+ const d = () => {
259
+ const l = !!n.value.trim();
260
+ i.disabled = !l;
241
261
  };
242
- l(), a.addEventListener("input", () => {
243
- t.newCommentText = a.value, l();
244
- }), a.addEventListener("keydown", (c) => {
245
- (c.ctrlKey || c.metaKey) && c.key === "Enter" && (c.preventDefault(), i.click());
262
+ d(), n.addEventListener("input", () => {
263
+ t.newCommentText = n.value, d();
264
+ }), n.addEventListener("keydown", (l) => {
265
+ (l.ctrlKey || l.metaKey) && l.key === "Enter" && (l.preventDefault(), i.click());
246
266
  }), i.addEventListener("click", () => {
247
- const c = a.value.trim();
248
- if (!c) return;
249
- const n = !!t.savedSelection;
250
- O(E, c, !n), t.newCommentText = "", m(t);
267
+ const l = n.value.trim();
268
+ if (!l) return;
269
+ const s = !!t.savedSelection;
270
+ W(T, l, !s), t.newCommentText = "", p(t);
251
271
  });
252
272
  }
253
273
  const f = t.panelElement.querySelector(".rte-comments-list");
254
- f && r.forEach((l) => {
255
- f.appendChild(D(t, l));
274
+ f && r.forEach((d) => {
275
+ f.appendChild(K(t, d));
256
276
  });
257
277
  }
258
- function T() {
259
- S || (S = !0, document.addEventListener("focusin", (e) => {
260
- const t = y(e.target);
278
+ const L = /* @__PURE__ */ new WeakMap();
279
+ function U(e) {
280
+ L.has(e) || L.set(
281
+ e,
282
+ window.setTimeout(() => {
283
+ L.delete(e), e.panelVisible && p(e);
284
+ }, 120)
285
+ );
286
+ }
287
+ function I() {
288
+ R || (R = !0, document.addEventListener("focusin", (e) => {
289
+ const t = v(e.target);
261
290
  t && (x = t);
291
+ }), document.addEventListener("click", (e) => {
292
+ const t = e.target instanceof Element ? e.target : null, r = t == null ? void 0 : t.closest(".rte-comment-anchor");
293
+ if (!r) return;
294
+ const o = v(r), n = o ? w.get(o) : null, i = r.getAttribute("data-comment-id");
295
+ !n || !i || !n.comments.has(i) || (e.preventDefault(), e.stopPropagation(), x = n.root, n.expandedComments.add(i), C(n, !0), p(n));
296
+ }), document.addEventListener("input", (e) => {
297
+ const t = e.target instanceof Element ? e.target : null;
298
+ if (!t || t.closest(".rte-comments-panel")) return;
299
+ const r = v(t), o = r ? w.get(r) : null;
300
+ o != null && o.panelVisible && U(o);
262
301
  }), document.addEventListener("selectionchange", () => {
263
302
  const e = window.getSelection();
264
303
  if (!e || e.rangeCount === 0) return;
265
- const t = e.getRangeAt(0), r = y(t.commonAncestorContainer);
304
+ const t = e.getRangeAt(0), r = v(t.commonAncestorContainer);
266
305
  if (!r) return;
267
306
  x = r;
268
- const o = C.get(r);
269
- !o || e.isCollapsed || w(t, r) && (o.savedSelection = t.cloneRange());
307
+ const o = w.get(r);
308
+ !o || e.isCollapsed || k(t, r) && (o.savedSelection = t.cloneRange());
270
309
  }), document.addEventListener(
271
310
  "keydown",
272
311
  (e) => {
273
312
  if (e.key !== "Escape") return;
274
313
  const t = u();
275
- !t || !t.panelVisible || (e.preventDefault(), e.stopPropagation(), h(t, !1));
314
+ !t || !t.panelVisible || (e.preventDefault(), e.stopPropagation(), C(t, !1));
276
315
  },
277
316
  !0
278
317
  ));
279
318
  }
280
- function K() {
319
+ function te() {
281
320
  const e = u();
282
- return e ? H(e) : [];
321
+ return e ? z(e) : [];
283
322
  }
284
- function O(e, t, r = !1) {
285
- var p;
323
+ function W(e, t, r = !1) {
286
324
  const o = u();
287
325
  if (!o) return "";
288
- const a = t.trim();
289
- if (!a) return "";
326
+ const n = t.trim();
327
+ if (!n) return "";
290
328
  if (r) {
291
- const d = v("comment");
292
- return o.comments.set(d, {
293
- id: d,
329
+ const c = S("comment");
330
+ return o.comments.set(c, {
331
+ id: c,
294
332
  anchorId: "",
295
333
  selectedText: "",
296
334
  author: e,
297
- text: a,
335
+ text: n,
298
336
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
299
337
  resolved: !1,
300
338
  replies: []
301
- }), m(o), d;
339
+ }), p(o), c;
302
340
  }
303
- const i = o.savedSelection || R(o.root);
304
- if (!i || !w(i, o.root)) return "";
341
+ const i = o.savedSelection || M(o.root);
342
+ if (!i || !k(i, o.root)) return "";
305
343
  const f = i.toString().trim();
306
344
  if (!f) return "";
307
- const l = v("comment"), c = v("comment-anchor"), n = document.createElement("span");
308
- n.id = c, n.className = "rte-comment-anchor", n.setAttribute("data-comment-id", l), n.setAttribute("title", "Commented text");
309
- try {
310
- const d = i.cloneRange(), g = d.extractContents();
311
- if (!((p = g.textContent) != null && p.trim())) return "";
312
- n.appendChild(g), d.insertNode(n);
313
- } catch (d) {
314
- return "";
315
- }
316
- N(o, n, l), o.comments.set(l, {
317
- id: l,
318
- anchorId: c,
345
+ const d = S("comment"), l = S("comment-anchor"), s = document.createElement("span");
346
+ if (s.id = l, s.className = "rte-comment-anchor", s.setAttribute("data-comment-id", d), s.setAttribute("title", "Commented text"), !A(o, () => {
347
+ var c;
348
+ try {
349
+ const m = i.cloneRange(), g = m.extractContents();
350
+ return (c = g.textContent) != null && c.trim() ? (s.appendChild(g), m.insertNode(s), !0) : !1;
351
+ } catch (m) {
352
+ return !1;
353
+ }
354
+ })) return "";
355
+ o.comments.set(d, {
356
+ id: d,
357
+ anchorId: l,
319
358
  selectedText: f,
320
359
  author: e,
321
- text: a,
360
+ text: n,
322
361
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
323
362
  resolved: !1,
324
363
  replies: []
325
364
  }), o.savedSelection = null;
326
- const s = window.getSelection();
327
- return s == null || s.removeAllRanges(), m(o), l;
365
+ const a = window.getSelection();
366
+ return a == null || a.removeAllRanges(), p(o), d;
328
367
  }
329
- function P(e, t) {
368
+ function X(e, t) {
330
369
  const r = u();
331
370
  if (!r) return;
332
371
  const o = r.comments.get(e);
333
- o && (o.resolved = !0, o.resolvedBy = t, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), I(r, o), m(r));
372
+ o && (o.resolved = !0, o.resolvedBy = t, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), A(r, () => N(r, o)), p(r));
334
373
  }
335
- function _(e) {
374
+ function G(e) {
336
375
  const t = u();
337
376
  if (!t) return;
338
377
  const r = t.comments.get(e);
339
- r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, I(t, r), m(t));
378
+ r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, A(t, () => N(t, r)), p(t));
340
379
  }
341
- function j(e) {
380
+ function J(e) {
342
381
  const t = u();
343
382
  if (!t) return;
344
383
  const r = t.comments.get(e);
345
384
  if (r) {
346
385
  if (r.anchorId) {
347
- const o = t.root.querySelector(`#${r.anchorId}`);
348
- o && z(o);
349
- }
350
- t.comments.delete(e), t.expandedComments.delete(e), delete t.replyTexts[e], m(t);
386
+ const o = E(t, r);
387
+ o && A(t, () => _(o));
388
+ } else
389
+ t.comments.delete(e), t.expandedComments.delete(e), delete t.replyTexts[e];
390
+ p(t);
351
391
  }
352
392
  }
353
- function F(e, t, r) {
393
+ function Q(e, t, r) {
354
394
  const o = u();
355
395
  if (!o) return;
356
- const a = o.comments.get(e);
357
- if (!a) return;
396
+ const n = o.comments.get(e);
397
+ if (!n) return;
358
398
  const i = r.trim();
359
- i && (a.replies.push({
360
- id: v("reply"),
399
+ i && (n.replies.push({
400
+ id: S("reply"),
361
401
  author: t,
362
402
  text: i,
363
403
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
364
- }), m(o));
404
+ }), p(o));
365
405
  }
366
- function U(e, t) {
406
+ function re(e, t) {
367
407
  const r = u();
368
- r && b(r, e, t);
408
+ r && y(r, e, t);
369
409
  }
370
- function Z() {
410
+ function Y() {
371
411
  if (document.getElementById("rte-comments-panel-styles")) return;
372
412
  const e = document.createElement("style");
373
413
  e.id = "rte-comments-panel-styles", e.textContent = `
@@ -688,14 +728,22 @@ function Z() {
688
728
  }
689
729
  `, document.head.appendChild(e);
690
730
  }
691
- const X = () => ({
731
+ const oe = () => ({
692
732
  name: "comments",
693
733
  toolbar: [
694
734
  {
695
735
  label: "Add Comment",
696
736
  command: "addComment",
697
737
  type: "button",
698
- icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect class="cls-1" width="32" height="32"></rect></svg>'
738
+ // The upstream SVGRepo export used a class-based <style> block for the
739
+ // transparent bounding rect (`.cls-1{fill:none}`). That's fine when an
740
+ // icon is scoped (shadow DOM, or one icon per page) but this markup is
741
+ // inserted via raw innerHTML into plain light-DOM content alongside
742
+ // every other plugin's icons, so the <style> tag applies document-wide
743
+ // - any other icon reusing the same auto-generated class name would
744
+ // collide with it. Inlined the one declaration it held (fill="none")
745
+ // directly on the rect instead, so there's nothing to leak.
746
+ icon: '<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect fill="none" width="32" height="32"></rect></svg>'
699
747
  },
700
748
  {
701
749
  label: "Show / Hide Comments",
@@ -706,36 +754,36 @@ const X = () => ({
706
754
  ],
707
755
  commands: {
708
756
  addComment: (e, t) => {
709
- var a;
710
- A(t), T();
757
+ var n;
758
+ q(t), I();
711
759
  const r = u();
712
760
  if (!r) return !1;
713
- if (r.savedSelection = R(r.root), r.savedSelection) {
761
+ if (r.savedSelection = M(r.root), r.savedSelection) {
714
762
  const i = window.getSelection();
715
763
  i == null || i.removeAllRanges();
716
764
  }
717
- h(r, !0), m(r);
718
- const o = (a = r.panelElement) == null ? void 0 : a.querySelector(
765
+ C(r, !0), p(r);
766
+ const o = (n = r.panelElement) == null ? void 0 : n.querySelector(
719
767
  ".new-comment-textarea"
720
768
  );
721
769
  return o == null || o.focus({ preventScroll: !0 }), !0;
722
770
  },
723
771
  toggleComments: (e, t) => {
724
- A(t), T();
772
+ q(t), I();
725
773
  const r = u();
726
- return r ? (h(r, !r.panelVisible), r.panelVisible && m(r), !0) : !1;
774
+ return r ? (C(r, !r.panelVisible), r.panelVisible && p(r), !0) : !1;
727
775
  }
728
776
  },
729
777
  keymap: {}
730
778
  });
731
779
  export {
732
- X as CommentsPlugin,
733
- O as addCommentCommand,
734
- j as deleteComment,
735
- K as getAllComments,
736
- U as highlightComment,
737
- _ as reopenComment,
738
- F as replyToComment,
739
- P as resolveComment
780
+ oe as CommentsPlugin,
781
+ W as addCommentCommand,
782
+ J as deleteComment,
783
+ te as getAllComments,
784
+ re as highlightComment,
785
+ G as reopenComment,
786
+ Q as replyToComment,
787
+ X as resolveComment
740
788
  };
741
- //# sourceMappingURL=CommentsPlugin.native-DPSqTkiv.mjs.map
789
+ //# sourceMappingURL=CommentsPlugin.native-CLip9wAO.mjs.map