@editora/plugins 1.0.17 → 1.0.19

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 (100) hide show
  1. package/dist/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
  2. package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
  3. package/dist/a11y-checker.cjs.js +16 -16
  4. package/dist/a11y-checker.esm.js +79 -75
  5. package/dist/anchor.cjs.js +9 -9
  6. package/dist/anchor.esm.js +61 -60
  7. package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
  8. package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
  9. package/dist/approval-workflow.cjs.js +5 -5
  10. package/dist/approval-workflow.esm.js +105 -104
  11. package/dist/background-color.cjs.js +1 -1
  12. package/dist/background-color.esm.js +1 -1
  13. package/dist/blocks-library.cjs.js +6 -6
  14. package/dist/blocks-library.esm.js +226 -202
  15. package/dist/capitalization.cjs.js +1 -1
  16. package/dist/capitalization.esm.js +9 -4
  17. package/dist/checklist.cjs.js +1 -1
  18. package/dist/checklist.esm.js +154 -116
  19. package/dist/citations.cjs.js +43 -18
  20. package/dist/citations.esm.js +465 -446
  21. package/dist/clear-formatting.cjs.js +1 -1
  22. package/dist/clear-formatting.esm.js +21 -20
  23. package/dist/code-sample.cjs.js +85 -66
  24. package/dist/code-sample.esm.js +301 -190
  25. package/dist/code.cjs.js +1 -1
  26. package/dist/code.esm.js +1 -1
  27. package/dist/collaboration.cjs.js +68 -0
  28. package/dist/collaboration.esm.js +7428 -0
  29. package/dist/comments.cjs.js +11 -11
  30. package/dist/comments.esm.js +284 -237
  31. package/dist/conditional-content.cjs.js +67 -60
  32. package/dist/conditional-content.esm.js +270 -220
  33. package/dist/data-binding.cjs.js +3 -3
  34. package/dist/data-binding.esm.js +28 -27
  35. package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
  36. package/dist/dialogHelpers-zU6zpMIA.js +12 -0
  37. package/dist/document-manager.cjs.js +1 -1
  38. package/dist/document-manager.esm.js +1 -1
  39. package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
  40. package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
  41. package/dist/embed-iframe.cjs.js +37 -17
  42. package/dist/embed-iframe.esm.js +188 -143
  43. package/dist/emojis.cjs.js +13 -10
  44. package/dist/emojis.esm.js +288 -76
  45. package/dist/enterprise.cjs.js +1 -1
  46. package/dist/enterprise.esm.js +9 -7
  47. package/dist/escapeHtml-D2Zh82pD.js +1 -0
  48. package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
  49. package/dist/font-family.cjs.js +1 -1
  50. package/dist/font-family.esm.js +48 -41
  51. package/dist/font-size.cjs.js +1 -1
  52. package/dist/font-size.esm.js +67 -60
  53. package/dist/format-painter.cjs.js +1 -1
  54. package/dist/format-painter.esm.js +2 -1
  55. package/dist/history.cjs.js +1 -1
  56. package/dist/history.esm.js +40 -36
  57. package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
  58. package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
  59. package/dist/index-Bm1eqYHh.mjs +194 -0
  60. package/dist/index-CoflqYuK.js +30 -0
  61. package/dist/index.cjs.js +1 -1
  62. package/dist/index.esm.js +17 -15
  63. package/dist/link.cjs.js +17 -13
  64. package/dist/link.esm.js +138 -69
  65. package/dist/list.cjs.js +1 -1
  66. package/dist/list.esm.js +66 -33
  67. package/dist/math.cjs.js +22 -22
  68. package/dist/math.esm.js +221 -126
  69. package/dist/media-manager.cjs.js +12 -12
  70. package/dist/media-manager.esm.js +55 -50
  71. package/dist/mentions.cjs.js +2 -2
  72. package/dist/mentions.esm.js +17 -12
  73. package/dist/merge-tag.cjs.js +2 -2
  74. package/dist/merge-tag.esm.js +43 -42
  75. package/dist/plugins.css +1 -1
  76. package/dist/preview.cjs.js +3 -3
  77. package/dist/preview.esm.js +30 -27
  78. package/dist/slash-commands.cjs.js +13 -7
  79. package/dist/slash-commands.esm.js +90 -79
  80. package/dist/smart-paste.cjs.js +5 -5
  81. package/dist/smart-paste.esm.js +85 -81
  82. package/dist/special-characters.cjs.js +6 -3
  83. package/dist/special-characters.esm.js +72 -25
  84. package/dist/spell-check.cjs.js +8 -8
  85. package/dist/spell-check.esm.js +10189 -295
  86. package/dist/table.cjs.js +166 -13
  87. package/dist/table.esm.js +543 -266
  88. package/dist/template.cjs.js +11 -11
  89. package/dist/template.esm.js +290 -264
  90. package/dist/text-color.cjs.js +1 -1
  91. package/dist/text-color.esm.js +1 -1
  92. package/dist/translation-workflow.cjs.js +4 -4
  93. package/dist/translation-workflow.esm.js +33 -31
  94. package/dist/version-diff.cjs.js +6 -6
  95. package/dist/version-diff.esm.js +40 -40
  96. package/package.json +12 -5
  97. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  98. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  99. package/dist/index-CJ90EVWy.mjs +0 -145
  100. package/dist/index-DTkvH8gX.js +0 -1
@@ -1,48 +1,49 @@
1
- const C = /* @__PURE__ */ new WeakMap();
2
- let x = null, S = !1, k = 0;
3
- const E = "User";
4
- function v(t) {
5
- return k += 1, `${t}-${Date.now()}-${k}`;
1
+ import { r as N } from "./historyHelpers-BEKwNOtA.mjs";
2
+ const y = /* @__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(t) {
8
- if (!t) return null;
9
- const e = t instanceof Element ? t : t.parentElement;
10
- return e ? e.closest("[data-editora-editor]") || e.closest(".rte-editor") || e.closest(".editora-editor") : null;
8
+ function h(e) {
9
+ if (!e) return null;
10
+ const t = e instanceof Element ? e : e.parentElement;
11
+ return t ? t.closest("[data-editora-editor]") || t.closest(".rte-editor") || t.closest(".editora-editor") : null;
11
12
  }
12
- function A(t) {
13
- const e = t?.editorElement || t?.contentElement || null;
14
- if (!(e instanceof HTMLElement)) return;
15
- const r = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
13
+ function q(e) {
14
+ const t = e?.editorElement || e?.contentElement || null;
15
+ if (!(t instanceof HTMLElement)) return;
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(t, e) {
19
- return e.contains(t.commonAncestorContainer);
19
+ function k(e, t) {
20
+ return t.contains(e.commonAncestorContainer);
20
21
  }
21
- function B() {
22
+ function z() {
22
23
  if (typeof window < "u") {
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 t = document.activeElement, e = t ? y(t) : null;
31
- if (e) return e;
31
+ const e = document.activeElement, t = e ? h(e) : null;
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 = h(
35
36
  r.getRangeAt(0).commonAncestorContainer
36
37
  );
37
38
  if (o) return o;
38
39
  }
39
40
  return x;
40
41
  }
41
- function H(t) {
42
- const e = C.get(t);
43
- if (e) return e;
42
+ function D(e) {
43
+ const t = y.get(e);
44
+ if (t) return t;
44
45
  const r = {
45
- root: t,
46
+ root: e,
46
47
  comments: /* @__PURE__ */ new Map(),
47
48
  panelVisible: !1,
48
49
  panelElement: null,
@@ -52,161 +53,180 @@ function H(t) {
52
53
  newCommentText: "",
53
54
  selectionChangeListener: null
54
55
  };
55
- return C.set(t, r), r;
56
+ return y.set(e, r), r;
56
57
  }
57
58
  function u() {
58
- const t = B();
59
- return t ? (x = t, H(t)) : null;
59
+ const e = z();
60
+ return e ? (x = e, D(e)) : null;
60
61
  }
61
- function R(t) {
62
- const e = window.getSelection();
63
- if (!e || e.rangeCount === 0 || e.isCollapsed) return null;
64
- const r = e.getRangeAt(0);
65
- return w(r, t) ? r.cloneRange() : null;
62
+ function I(e) {
63
+ const t = window.getSelection();
64
+ if (!t || t.rangeCount === 0 || t.isCollapsed) return null;
65
+ const r = t.getRangeAt(0);
66
+ return k(r, e) ? r.cloneRange() : null;
66
67
  }
67
- function I(t, e) {
68
- if (!e.anchorId) return;
69
- const r = t.root.querySelector(`#${e.anchorId}`);
70
- r && r.classList.toggle("rte-comment-anchor-resolved", e.resolved);
68
+ function $(e) {
69
+ return e.root.querySelector(".rte-content") || e.root.querySelector("[contenteditable]");
71
70
  }
72
- function h(t, e, r) {
73
- const o = t.comments.get(e);
74
- if (!o || !o.anchorId) return;
75
- const a = t.root.querySelector(`#${o.anchorId}`);
76
- a && a.classList.toggle("highlighted", r);
71
+ function C(e, t) {
72
+ return t.anchorId ? e.root.querySelector(`[id="${t.anchorId}"]`) : null;
77
73
  }
78
- function $(t, e, r) {
79
- e.onclick = (o) => {
80
- o.preventDefault(), o.stopPropagation(), x = t.root, t.expandedComments.add(r), g(t, !0), m(t);
81
- };
74
+ function O(e) {
75
+ const t = [];
76
+ return e.comments.forEach((r) => {
77
+ if (r.anchorId) {
78
+ const o = C(e, r);
79
+ if (!o) return;
80
+ r.resolved = o.classList.contains("rte-comment-anchor-resolved");
81
+ }
82
+ t.push(r);
83
+ }), t;
82
84
  }
83
- function q(t) {
84
- const e = t.parentNode;
85
- if (e) {
86
- for (; t.firstChild; )
87
- e.insertBefore(t.firstChild, t);
88
- t.remove();
85
+ function A(e, t) {
86
+ const r = $(e), o = r ? r.innerHTML : "", n = t();
87
+ return r && r.innerHTML !== o && (N(r, o), r.dispatchEvent(new Event("input", { bubbles: !0 }))), n;
88
+ }
89
+ function M(e, t) {
90
+ const r = C(e, t);
91
+ r && r.classList.toggle("rte-comment-anchor-resolved", t.resolved);
92
+ }
93
+ function E(e, t, r) {
94
+ const o = e.comments.get(t);
95
+ if (!o) return;
96
+ const n = C(e, o);
97
+ n && n.classList.toggle("highlighted", r);
98
+ }
99
+ function P(e) {
100
+ const t = e.parentNode;
101
+ if (t) {
102
+ for (; e.firstChild; )
103
+ t.insertBefore(e.firstChild, e);
104
+ e.remove();
89
105
  }
90
106
  }
91
- function g(t, e) {
92
- if (t.panelVisible = e, e) {
93
- Z(), N(t), t.root.setAttribute("data-rte-comments-open", "true"), t.panelElement && (t.panelElement.classList.add("is-open"), t.panelElement.setAttribute("aria-hidden", "false")), z(t);
107
+ function w(e, t) {
108
+ if (e.panelVisible = t, t) {
109
+ Y(), _(e), e.root.setAttribute("data-rte-comments-open", "true"), e.panelElement && (e.panelElement.classList.add("is-open"), e.panelElement.setAttribute("aria-hidden", "false")), j(e);
94
110
  return;
95
111
  }
96
- t.root.removeAttribute("data-rte-comments-open"), V(t), t.panelElement && (t.panelElement.remove(), t.panelElement = null);
112
+ e.root.removeAttribute("data-rte-comments-open"), F(e), e.panelElement && (e.panelElement.remove(), e.panelElement = null);
97
113
  }
98
- function N(t) {
99
- if (t.panelElement) return;
100
- const e = document.createElement("aside");
101
- e.className = "rte-comments-panel", e.setAttribute("role", "complementary"), e.setAttribute("aria-label", "Comments"), e.setAttribute("aria-hidden", "true"), window.getComputedStyle(t.root).position === "static" && (t.root.style.position = "relative"), t.root.appendChild(e), t.panelElement = e;
114
+ function _(e) {
115
+ if (e.panelElement) return;
116
+ const t = document.createElement("aside");
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 z(t) {
104
- t.selectionChangeListener || (t.selectionChangeListener = () => {
105
- const e = window.getSelection();
106
- if (!e || e.rangeCount === 0 || e.isCollapsed) return;
107
- const r = e.getRangeAt(0);
108
- w(r, t.root) && (t.savedSelection = r.cloneRange(), x = t.root);
109
- }, document.addEventListener("selectionchange", t.selectionChangeListener));
119
+ function j(e) {
120
+ e.selectionChangeListener || (e.selectionChangeListener = () => {
121
+ const t = window.getSelection();
122
+ if (!t || t.rangeCount === 0 || t.isCollapsed) return;
123
+ const r = t.getRangeAt(0);
124
+ k(r, e.root) && (e.savedSelection = r.cloneRange(), x = e.root);
125
+ }, document.addEventListener("selectionchange", e.selectionChangeListener));
110
126
  }
111
- function V(t) {
112
- t.selectionChangeListener && (document.removeEventListener("selectionchange", t.selectionChangeListener), t.selectionChangeListener = null);
127
+ function F(e) {
128
+ e.selectionChangeListener && (document.removeEventListener("selectionchange", e.selectionChangeListener), e.selectionChangeListener = null);
113
129
  }
114
- function M(t) {
115
- return Array.from(t.comments.values()).sort(
116
- (e, r) => r.createdAt.localeCompare(e.createdAt)
117
- );
130
+ function Z(e) {
131
+ return O(e).sort((t, r) => r.createdAt.localeCompare(t.createdAt));
118
132
  }
119
- function L(t) {
120
- return new Date(t).toLocaleString();
133
+ function B(e) {
134
+ return new Date(e).toLocaleString();
121
135
  }
122
- function D(t, e) {
123
- const r = t.expandedComments.has(e.id), o = document.createElement("article");
124
- o.className = `rte-comment-item${e.resolved ? " resolved" : ""}`, o.innerHTML = `
136
+ function K(e, t) {
137
+ const r = e.expandedComments.has(t.id), o = document.createElement("article");
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">${e.author}</strong>
128
- <time class="rte-comment-date">${L(e.createdAt)}</time>
141
+ <strong class="rte-comment-author"></strong>
142
+ <time class="rte-comment-date">${B(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
- ${e.selectedText ? `<blockquote class="rte-comment-selection">${e.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 = e.text), o.querySelector(".rte-comment-expand")?.addEventListener("click", () => {
140
- t.expandedComments.has(e.id) ? t.expandedComments.delete(e.id) : t.expandedComments.add(e.id), m(t);
152
+ const n = o.querySelector(".rte-comment-author");
153
+ n && (n.textContent = t.author);
154
+ const c = o.querySelector(".rte-comment-text");
155
+ c && (c.textContent = t.text);
156
+ const f = o.querySelector(".rte-comment-selection");
157
+ f && (f.textContent = t.selectedText), o.querySelector(".rte-comment-expand")?.addEventListener("click", () => {
158
+ e.expandedComments.has(t.id) ? e.expandedComments.delete(t.id) : e.expandedComments.add(t.id), d(e);
141
159
  });
142
- const p = o.querySelector(".rte-comment-expanded");
143
- if (p && r) {
144
- if (e.replies.length > 0) {
145
- const n = document.createElement("div");
146
- n.className = "rte-comment-replies", e.replies.forEach((s) => {
147
- const l = document.createElement("div");
148
- l.className = "rte-comment-reply", l.innerHTML = `
160
+ const l = o.querySelector(".rte-comment-expanded");
161
+ if (l && r) {
162
+ if (t.replies.length > 0) {
163
+ const a = document.createElement("div");
164
+ a.className = "rte-comment-replies", t.replies.forEach((i) => {
165
+ const m = document.createElement("div");
166
+ m.className = "rte-comment-reply", m.innerHTML = `
149
167
  <div class="rte-comment-reply-header">
150
- <strong>${s.author}</strong>
151
- <time>${L(s.createdAt)}</time>
168
+ <strong class="rte-comment-reply-author"></strong>
169
+ <time>${B(i.createdAt)}</time>
152
170
  </div>
153
171
  <div class="rte-comment-reply-text"></div>
154
172
  `;
155
- const f = l.querySelector(".rte-comment-reply-text");
156
- f && (f.textContent = s.text), n.appendChild(l);
157
- }), p.appendChild(n);
158
- }
159
- if (!e.resolved) {
160
- const n = document.createElement("div");
161
- n.className = "rte-comment-reply-composer", n.innerHTML = `
173
+ const v = m.querySelector(".rte-comment-reply-author");
174
+ v && (v.textContent = i.author);
175
+ const g = m.querySelector(".rte-comment-reply-text");
176
+ g && (g.textContent = i.text), a.appendChild(m);
177
+ }), l.appendChild(a);
178
+ }
179
+ if (!t.resolved) {
180
+ const a = document.createElement("div");
181
+ a.className = "rte-comment-reply-composer", a.innerHTML = `
162
182
  <textarea class="rte-comment-reply-textarea" rows="2" placeholder="Reply..."></textarea>
163
183
  <button type="button" class="rte-comment-btn primary">Reply</button>
164
184
  `;
165
- const s = n.querySelector(
185
+ const i = a.querySelector(
166
186
  ".rte-comment-reply-textarea"
167
- ), l = n.querySelector(
187
+ ), m = a.querySelector(
168
188
  ".rte-comment-btn.primary"
169
189
  );
170
- if (s && l) {
171
- s.value = t.replyTexts[e.id] || "";
172
- const f = () => {
173
- const b = !!s.value.trim();
174
- l.disabled = !b;
190
+ if (i && m) {
191
+ i.value = e.replyTexts[t.id] || "";
192
+ const v = () => {
193
+ const g = !!i.value.trim();
194
+ m.disabled = !g;
175
195
  };
176
- f(), s.addEventListener("input", () => {
177
- t.replyTexts[e.id] = s.value, f();
178
- }), l.addEventListener("click", () => {
179
- const b = s.value.trim();
180
- b && (F(e.id, E, b), t.replyTexts[e.id] = "", m(t));
196
+ v(), i.addEventListener("input", () => {
197
+ e.replyTexts[t.id] = i.value, v();
198
+ }), m.addEventListener("click", () => {
199
+ const g = i.value.trim();
200
+ g && (Q(t.id, T, g), e.replyTexts[t.id] = "", d(e));
181
201
  });
182
202
  }
183
- p.appendChild(n);
184
- }
185
- const c = document.createElement("div");
186
- if (c.className = "rte-comment-actions", e.anchorId) {
187
- const n = document.createElement("button");
188
- n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Jump to text", n.onclick = () => {
189
- const s = t.root.querySelector(`#${e.anchorId}`);
190
- s && (s.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), h(t, e.id, !0), window.setTimeout(() => h(t, e.id, !1), 1200));
191
- }, c.appendChild(n);
192
- }
193
- if (e.resolved) {
194
- const n = document.createElement("button");
195
- n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => _(e.id), c.appendChild(n);
203
+ l.appendChild(a);
204
+ }
205
+ const s = document.createElement("div");
206
+ if (s.className = "rte-comment-actions", t.anchorId) {
207
+ const a = document.createElement("button");
208
+ a.type = "button", a.className = "rte-comment-btn ghost", a.textContent = "Jump to text", a.onclick = () => {
209
+ const i = C(e, t);
210
+ i && (i.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), E(e, t.id, !0), window.setTimeout(() => E(e, t.id, !1), 1200));
211
+ }, s.appendChild(a);
212
+ }
213
+ if (t.resolved) {
214
+ const a = document.createElement("button");
215
+ a.type = "button", a.className = "rte-comment-btn ghost", a.textContent = "Reopen", a.onclick = () => G(t.id), s.appendChild(a);
196
216
  } else {
197
- const n = document.createElement("button");
198
- n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => P(e.id, E), c.appendChild(n);
217
+ const a = document.createElement("button");
218
+ a.type = "button", a.className = "rte-comment-btn success", a.textContent = "Resolve", a.onclick = () => X(t.id, T), s.appendChild(a);
199
219
  }
200
- const i = document.createElement("button");
201
- i.type = "button", i.className = "rte-comment-btn danger", i.textContent = "Delete", i.onclick = () => j(e.id), c.appendChild(i), p.appendChild(c);
220
+ const b = document.createElement("button");
221
+ b.type = "button", b.className = "rte-comment-btn danger", b.textContent = "Delete", b.onclick = () => J(t.id), s.appendChild(b), l.appendChild(s);
202
222
  }
203
- return o.addEventListener("mouseenter", () => h(t, e.id, !0)), o.addEventListener("mouseleave", () => h(t, e.id, !1)), o;
223
+ return o.addEventListener("mouseenter", () => E(e, t.id, !0)), o.addEventListener("mouseleave", () => E(e, t.id, !1)), o;
204
224
  }
205
- function m(t) {
206
- const e = t || u();
207
- if (!e?.panelElement) return;
208
- const r = M(e);
209
- e.panelElement.innerHTML = `
225
+ function d(e) {
226
+ const t = e || u();
227
+ if (!t?.panelElement) return;
228
+ const r = Z(t);
229
+ t.panelElement.innerHTML = `
210
230
  <div class="rte-comments-header">
211
231
  <div>
212
232
  <h3>Comments (${r.length})</h3>
@@ -221,141 +241,160 @@ function m(t) {
221
241
  </div>
222
242
  </div>
223
243
  ${r.length === 0 ? '<div class="rte-comments-empty">No comments yet.</div>' : '<div class="rte-comments-list"></div>'}
224
- `, e.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
225
- g(e, !1);
244
+ `, t.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
245
+ w(t, !1);
226
246
  });
227
- const a = e.panelElement.querySelector(
247
+ const n = t.panelElement.querySelector(
228
248
  ".new-comment-textarea"
229
- ), d = e.panelElement.querySelector(
249
+ ), c = t.panelElement.querySelector(
230
250
  ".add-comment-btn"
231
251
  );
232
- if (a && d) {
233
- a.value = e.newCommentText;
234
- const c = () => {
235
- const i = !!a.value.trim();
236
- d.disabled = !i;
252
+ if (n && c) {
253
+ n.value = t.newCommentText;
254
+ const p = () => {
255
+ const l = !!n.value.trim();
256
+ c.disabled = !l;
237
257
  };
238
- c(), a.addEventListener("input", () => {
239
- e.newCommentText = a.value, c();
240
- }), a.addEventListener("keydown", (i) => {
241
- (i.ctrlKey || i.metaKey) && i.key === "Enter" && (i.preventDefault(), d.click());
242
- }), d.addEventListener("click", () => {
243
- const i = a.value.trim();
244
- if (!i) return;
245
- const n = !!e.savedSelection;
246
- O(E, i, !n), e.newCommentText = "", m(e);
258
+ p(), n.addEventListener("input", () => {
259
+ t.newCommentText = n.value, p();
260
+ }), n.addEventListener("keydown", (l) => {
261
+ (l.ctrlKey || l.metaKey) && l.key === "Enter" && (l.preventDefault(), c.click());
262
+ }), c.addEventListener("click", () => {
263
+ const l = n.value.trim();
264
+ if (!l) return;
265
+ const s = !!t.savedSelection;
266
+ W(T, l, !s), t.newCommentText = "", d(t);
247
267
  });
248
268
  }
249
- const p = e.panelElement.querySelector(".rte-comments-list");
250
- p && r.forEach((c) => {
251
- p.appendChild(D(e, c));
269
+ const f = t.panelElement.querySelector(".rte-comments-list");
270
+ f && r.forEach((p) => {
271
+ f.appendChild(K(t, p));
252
272
  });
253
273
  }
254
- function T() {
255
- S || (S = !0, document.addEventListener("focusin", (t) => {
256
- const e = y(t.target);
257
- e && (x = e);
274
+ const L = /* @__PURE__ */ new WeakMap();
275
+ function U(e) {
276
+ L.has(e) || L.set(
277
+ e,
278
+ window.setTimeout(() => {
279
+ L.delete(e), e.panelVisible && d(e);
280
+ }, 120)
281
+ );
282
+ }
283
+ function V() {
284
+ R || (R = !0, document.addEventListener("focusin", (e) => {
285
+ const t = h(e.target);
286
+ t && (x = t);
287
+ }), document.addEventListener("click", (e) => {
288
+ const r = (e.target instanceof Element ? e.target : null)?.closest(".rte-comment-anchor");
289
+ if (!r) return;
290
+ const o = h(r), n = o ? y.get(o) : null, c = r.getAttribute("data-comment-id");
291
+ !n || !c || !n.comments.has(c) || (e.preventDefault(), e.stopPropagation(), x = n.root, n.expandedComments.add(c), w(n, !0), d(n));
292
+ }), document.addEventListener("input", (e) => {
293
+ const t = e.target instanceof Element ? e.target : null;
294
+ if (!t || t.closest(".rte-comments-panel")) return;
295
+ const r = h(t), o = r ? y.get(r) : null;
296
+ o?.panelVisible && U(o);
258
297
  }), document.addEventListener("selectionchange", () => {
259
- const t = window.getSelection();
260
- if (!t || t.rangeCount === 0) return;
261
- const e = t.getRangeAt(0), r = y(e.commonAncestorContainer);
298
+ const e = window.getSelection();
299
+ if (!e || e.rangeCount === 0) return;
300
+ const t = e.getRangeAt(0), r = h(t.commonAncestorContainer);
262
301
  if (!r) return;
263
302
  x = r;
264
- const o = C.get(r);
265
- !o || t.isCollapsed || w(e, r) && (o.savedSelection = e.cloneRange());
303
+ const o = y.get(r);
304
+ !o || e.isCollapsed || k(t, r) && (o.savedSelection = t.cloneRange());
266
305
  }), document.addEventListener(
267
306
  "keydown",
268
- (t) => {
269
- if (t.key !== "Escape") return;
270
- const e = u();
271
- !e || !e.panelVisible || (t.preventDefault(), t.stopPropagation(), g(e, !1));
307
+ (e) => {
308
+ if (e.key !== "Escape") return;
309
+ const t = u();
310
+ !t || !t.panelVisible || (e.preventDefault(), e.stopPropagation(), w(t, !1));
272
311
  },
273
312
  !0
274
313
  ));
275
314
  }
276
- function O(t, e, r = !1) {
315
+ function W(e, t, r = !1) {
277
316
  const o = u();
278
317
  if (!o) return "";
279
- const a = e.trim();
280
- if (!a) return "";
318
+ const n = t.trim();
319
+ if (!n) return "";
281
320
  if (r) {
282
- const l = v("comment");
283
- return o.comments.set(l, {
284
- id: l,
321
+ const i = S("comment");
322
+ return o.comments.set(i, {
323
+ id: i,
285
324
  anchorId: "",
286
325
  selectedText: "",
287
- author: t,
288
- text: a,
326
+ author: e,
327
+ text: n,
289
328
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
290
329
  resolved: !1,
291
330
  replies: []
292
- }), m(o), l;
293
- }
294
- const d = o.savedSelection || R(o.root);
295
- if (!d || !w(d, o.root)) return "";
296
- const p = d.toString().trim();
297
- if (!p) return "";
298
- const c = v("comment"), i = v("comment-anchor"), n = document.createElement("span");
299
- n.id = i, n.className = "rte-comment-anchor", n.setAttribute("data-comment-id", c), n.setAttribute("title", "Commented text");
300
- try {
301
- const l = d.cloneRange(), f = l.extractContents();
302
- if (!f.textContent?.trim()) return "";
303
- n.appendChild(f), l.insertNode(n);
304
- } catch {
305
- return "";
331
+ }), d(o), i;
306
332
  }
307
- return $(o, n, c), o.comments.set(c, {
308
- id: c,
309
- anchorId: i,
310
- selectedText: p,
311
- author: t,
312
- text: a,
333
+ const c = o.savedSelection || I(o.root);
334
+ if (!c || !k(c, o.root)) return "";
335
+ const f = c.toString().trim();
336
+ if (!f) return "";
337
+ const p = S("comment"), l = S("comment-anchor"), s = document.createElement("span");
338
+ return s.id = l, s.className = "rte-comment-anchor", s.setAttribute("data-comment-id", p), s.setAttribute("title", "Commented text"), A(o, () => {
339
+ try {
340
+ const i = c.cloneRange(), m = i.extractContents();
341
+ return m.textContent?.trim() ? (s.appendChild(m), i.insertNode(s), !0) : !1;
342
+ } catch {
343
+ return !1;
344
+ }
345
+ }) ? (o.comments.set(p, {
346
+ id: p,
347
+ anchorId: l,
348
+ selectedText: f,
349
+ author: e,
350
+ text: n,
313
351
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
314
352
  resolved: !1,
315
353
  replies: []
316
- }), o.savedSelection = null, window.getSelection()?.removeAllRanges(), m(o), c;
354
+ }), o.savedSelection = null, window.getSelection()?.removeAllRanges(), d(o), p) : "";
317
355
  }
318
- function P(t, e) {
356
+ function X(e, t) {
319
357
  const r = u();
320
358
  if (!r) return;
321
- const o = r.comments.get(t);
322
- o && (o.resolved = !0, o.resolvedBy = e, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), I(r, o), m(r));
359
+ const o = r.comments.get(e);
360
+ o && (o.resolved = !0, o.resolvedBy = t, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), A(r, () => M(r, o)), d(r));
323
361
  }
324
- function _(t) {
325
- const e = u();
326
- if (!e) return;
327
- const r = e.comments.get(t);
328
- r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, I(e, r), m(e));
362
+ function G(e) {
363
+ const t = u();
364
+ if (!t) return;
365
+ const r = t.comments.get(e);
366
+ r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, A(t, () => M(t, r)), d(t));
329
367
  }
330
- function j(t) {
331
- const e = u();
332
- if (!e) return;
333
- const r = e.comments.get(t);
368
+ function J(e) {
369
+ const t = u();
370
+ if (!t) return;
371
+ const r = t.comments.get(e);
334
372
  if (r) {
335
373
  if (r.anchorId) {
336
- const o = e.root.querySelector(`#${r.anchorId}`);
337
- o && q(o);
338
- }
339
- e.comments.delete(t), e.expandedComments.delete(t), delete e.replyTexts[t], m(e);
374
+ const o = C(t, r);
375
+ o && A(t, () => P(o));
376
+ } else
377
+ t.comments.delete(e), t.expandedComments.delete(e), delete t.replyTexts[e];
378
+ d(t);
340
379
  }
341
380
  }
342
- function F(t, e, r) {
381
+ function Q(e, t, r) {
343
382
  const o = u();
344
383
  if (!o) return;
345
- const a = o.comments.get(t);
346
- if (!a) return;
347
- const d = r.trim();
348
- d && (a.replies.push({
349
- id: v("reply"),
350
- author: e,
351
- text: d,
384
+ const n = o.comments.get(e);
385
+ if (!n) return;
386
+ const c = r.trim();
387
+ c && (n.replies.push({
388
+ id: S("reply"),
389
+ author: t,
390
+ text: c,
352
391
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
353
- }), m(o));
392
+ }), d(o));
354
393
  }
355
- function Z() {
394
+ function Y() {
356
395
  if (document.getElementById("rte-comments-panel-styles")) return;
357
- const t = document.createElement("style");
358
- t.id = "rte-comments-panel-styles", t.textContent = `
396
+ const e = document.createElement("style");
397
+ e.id = "rte-comments-panel-styles", e.textContent = `
359
398
  .rte-comments-panel {
360
399
  --rte-comments-panel-width: min(360px, 42vw);
361
400
  position: absolute;
@@ -671,16 +710,24 @@ function Z() {
671
710
  margin-right: 0;
672
711
  }
673
712
  }
674
- `, document.head.appendChild(t);
713
+ `, document.head.appendChild(e);
675
714
  }
676
- const K = () => ({
715
+ const te = () => ({
677
716
  name: "comments",
678
717
  toolbar: [
679
718
  {
680
719
  label: "Add Comment",
681
720
  command: "addComment",
682
721
  type: "button",
683
- 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>'
722
+ // The upstream SVGRepo export used a class-based <style> block for the
723
+ // transparent bounding rect (`.cls-1{fill:none}`). That's fine when an
724
+ // icon is scoped (shadow DOM, or one icon per page) but this markup is
725
+ // inserted via raw innerHTML into plain light-DOM content alongside
726
+ // every other plugin's icons, so the <style> tag applies document-wide
727
+ // - any other icon reusing the same auto-generated class name would
728
+ // collide with it. Inlined the one declaration it held (fill="none")
729
+ // directly on the rect instead, so there's nothing to leak.
730
+ 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>'
684
731
  },
685
732
  {
686
733
  label: "Show / Hide Comments",
@@ -690,21 +737,21 @@ const K = () => ({
690
737
  }
691
738
  ],
692
739
  commands: {
693
- addComment: (t, e) => {
694
- A(e), T();
740
+ addComment: (e, t) => {
741
+ q(t), V();
695
742
  const r = u();
696
- return r ? (r.savedSelection = R(r.root), r.savedSelection && window.getSelection()?.removeAllRanges(), g(r, !0), m(r), r.panelElement?.querySelector(
743
+ return r ? (r.savedSelection = I(r.root), r.savedSelection && window.getSelection()?.removeAllRanges(), w(r, !0), d(r), r.panelElement?.querySelector(
697
744
  ".new-comment-textarea"
698
745
  )?.focus({ preventScroll: !0 }), !0) : !1;
699
746
  },
700
- toggleComments: (t, e) => {
701
- A(e), T();
747
+ toggleComments: (e, t) => {
748
+ q(t), V();
702
749
  const r = u();
703
- return r ? (g(r, !r.panelVisible), r.panelVisible && m(r), !0) : !1;
750
+ return r ? (w(r, !r.panelVisible), r.panelVisible && d(r), !0) : !1;
704
751
  }
705
752
  },
706
753
  keymap: {}
707
754
  });
708
755
  export {
709
- K as CommentsPlugin
756
+ te as CommentsPlugin
710
757
  };