@editora/plugins 1.0.22 → 1.1.0

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 (103) hide show
  1. package/README.md +1 -1
  2. package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-BwhZsI5v.js} +11 -11
  3. package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-CojLCp6C.mjs} +61 -53
  4. package/dist/MediaManagerPlugin.native-CycfjOi4.js +1841 -0
  5. package/dist/MediaManagerPlugin.native-DZrmcmnm.mjs +4688 -0
  6. package/dist/a11y-checker.cjs.js +3 -3
  7. package/dist/a11y-checker.esm.js +6 -4
  8. package/dist/anchor.cjs.js +4 -4
  9. package/dist/anchor.esm.js +19 -18
  10. package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
  11. package/dist/anchoredPopover-Cygmit_o.js +1 -0
  12. package/dist/approval-workflow.cjs.js +7 -7
  13. package/dist/approval-workflow.esm.js +55 -54
  14. package/dist/background-color.cjs.js +2 -2
  15. package/dist/background-color.esm.js +72 -67
  16. package/dist/blocks-library.cjs.js +18 -19
  17. package/dist/blocks-library.esm.js +41 -42
  18. package/dist/citations.cjs.js +4 -4
  19. package/dist/citations.esm.js +50 -50
  20. package/dist/code-sample.cjs.js +10 -10
  21. package/dist/code-sample.esm.js +4 -4
  22. package/dist/code.cjs.js +1 -1
  23. package/dist/code.esm.js +1 -1
  24. package/dist/comments.cjs.js +23 -11
  25. package/dist/comments.esm.js +167 -149
  26. package/dist/conditional-content.cjs.js +2 -2
  27. package/dist/conditional-content.esm.js +2 -2
  28. package/dist/confirmDialog-D3S8BhIM.js +42 -0
  29. package/dist/confirmDialog-DR4c8j6S.mjs +87 -0
  30. package/dist/content-rules.cjs.js +6 -6
  31. package/dist/content-rules.esm.js +51 -51
  32. package/dist/data-binding.cjs.js +2 -2
  33. package/dist/data-binding.esm.js +2 -2
  34. package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
  35. package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
  36. package/dist/document-manager.cjs.js +1 -1
  37. package/dist/document-manager.esm.js +1 -1
  38. package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
  39. package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
  40. package/dist/embed-iframe.cjs.js +6 -6
  41. package/dist/embed-iframe.esm.js +6 -6
  42. package/dist/emojis.cjs.js +5 -5
  43. package/dist/emojis.esm.js +3 -3
  44. package/dist/enterprise.cjs.js +1 -1
  45. package/dist/enterprise.esm.js +12 -12
  46. package/dist/format-painter.cjs.js +1 -1
  47. package/dist/format-painter.esm.js +172 -151
  48. package/dist/heading.cjs.js +1 -1
  49. package/dist/heading.esm.js +96 -83
  50. package/dist/history.cjs.js +1 -1
  51. package/dist/history.esm.js +176 -97
  52. package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
  53. package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/index.esm.js +90 -83
  56. package/dist/katex-Cc3-mvOY.js +257 -0
  57. package/dist/katex-DoRnZ_sp.mjs +11682 -0
  58. package/dist/katex.min--Ws3c9be.mjs +5 -0
  59. package/dist/katex.min-Dk2VscxB.js +2 -0
  60. package/dist/link.cjs.js +3 -3
  61. package/dist/link.esm.js +3 -3
  62. package/dist/list.cjs.js +1 -1
  63. package/dist/list.esm.js +140 -52
  64. package/dist/math.cjs.js +14 -14
  65. package/dist/math.esm.js +149 -136
  66. package/dist/media-manager.cjs.js +1 -619
  67. package/dist/media-manager.esm.js +30 -1017
  68. package/dist/mentions.cjs.js +12 -12
  69. package/dist/mentions.esm.js +149 -143
  70. package/dist/merge-tag.cjs.js +5 -3
  71. package/dist/merge-tag.esm.js +5 -3
  72. package/dist/notify-BkbzMopb.js +32 -0
  73. package/dist/notify-zOp-mUOJ.mjs +59 -0
  74. package/dist/pii-redaction.cjs.js +1 -1
  75. package/dist/pii-redaction.esm.js +1 -1
  76. package/dist/preview.cjs.js +1 -1
  77. package/dist/preview.esm.js +1 -1
  78. package/dist/shared-config.cjs.js +1 -1
  79. package/dist/shared-config.esm.js +14 -14
  80. package/dist/slash-commands.cjs.js +5 -5
  81. package/dist/slash-commands.esm.js +259 -236
  82. package/dist/smart-paste.cjs.js +1 -1
  83. package/dist/smart-paste.esm.js +1 -1
  84. package/dist/special-characters.cjs.js +3 -3
  85. package/dist/special-characters.esm.js +3 -3
  86. package/dist/spell-check.cjs.js +9 -9
  87. package/dist/spell-check.esm.js +288 -251
  88. package/dist/table.cjs.js +14 -14
  89. package/dist/table.esm.js +175 -154
  90. package/dist/template.cjs.js +5 -3
  91. package/dist/template.esm.js +15 -13
  92. package/dist/text-color.cjs.js +4 -4
  93. package/dist/text-color.esm.js +38 -34
  94. package/dist/translation-workflow.cjs.js +9 -9
  95. package/dist/translation-workflow.esm.js +98 -95
  96. package/dist/version-diff.cjs.js +4 -4
  97. package/dist/version-diff.esm.js +36 -36
  98. package/index.d.ts +183 -2
  99. package/package.json +6 -5
  100. package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
  101. package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
  102. package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
  103. package/dist/dialogHelpers-zU6zpMIA.js +0 -12
@@ -1,11 +1,12 @@
1
- import { r as N } from "./historyHelpers-BEKwNOtA.mjs";
1
+ import { f as M, p as N, k as D } from "./dialogHelpers-BbwpIXD9.mjs";
2
+ import { r as $ } from "./historyHelpers-BEKwNOtA.mjs";
2
3
  const y = /* @__PURE__ */ new WeakMap();
3
- let x = null, R = !1, H = 0;
4
+ let h = null, R = !1, H = 0;
4
5
  const T = "User";
5
6
  function S(e) {
6
7
  return H += 1, `${e}-${Date.now()}-${H}`;
7
8
  }
8
- function h(e) {
9
+ function g(e) {
9
10
  if (!e) return null;
10
11
  const t = e instanceof Element ? e : e.parentElement;
11
12
  return t ? t.closest("[data-editora-editor]") || t.closest(".rte-editor") || t.closest(".editora-editor") : null;
@@ -14,32 +15,32 @@ function q(e) {
14
15
  const t = e?.editorElement || e?.contentElement || null;
15
16
  if (!(t instanceof HTMLElement)) return;
16
17
  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);
17
- r && (x = r);
18
+ r && (h = r);
18
19
  }
19
20
  function k(e, t) {
20
21
  return t.contains(e.commonAncestorContainer);
21
22
  }
22
- function z() {
23
+ function P() {
23
24
  if (typeof window < "u") {
24
25
  const o = window.__editoraCommandEditorRoot;
25
26
  if (o instanceof HTMLElement) {
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;
27
+ 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);
28
+ if (a)
29
+ return h = a, window.__editoraCommandEditorRoot = null, a;
29
30
  }
30
31
  }
31
- const e = document.activeElement, t = e ? h(e) : null;
32
+ const e = document.activeElement, t = e ? g(e) : null;
32
33
  if (t) return t;
33
34
  const r = window.getSelection();
34
35
  if (r && r.rangeCount > 0) {
35
- const o = h(
36
+ const o = g(
36
37
  r.getRangeAt(0).commonAncestorContainer
37
38
  );
38
39
  if (o) return o;
39
40
  }
40
- return x;
41
+ return h;
41
42
  }
42
- function D(e) {
43
+ function O(e) {
43
44
  const t = y.get(e);
44
45
  if (t) return t;
45
46
  const r = {
@@ -56,22 +57,22 @@ function D(e) {
56
57
  return y.set(e, r), r;
57
58
  }
58
59
  function u() {
59
- const e = z();
60
- return e ? (x = e, D(e)) : null;
60
+ const e = P();
61
+ return e ? (h = e, O(e)) : null;
61
62
  }
62
- function I(e) {
63
+ function V(e) {
63
64
  const t = window.getSelection();
64
65
  if (!t || t.rangeCount === 0 || t.isCollapsed) return null;
65
66
  const r = t.getRangeAt(0);
66
67
  return k(r, e) ? r.cloneRange() : null;
67
68
  }
68
- function $(e) {
69
+ function F(e) {
69
70
  return e.root.querySelector(".rte-content") || e.root.querySelector("[contenteditable]");
70
71
  }
71
72
  function C(e, t) {
72
73
  return t.anchorId ? e.root.querySelector(`[id="${t.anchorId}"]`) : null;
73
74
  }
74
- function O(e) {
75
+ function _(e) {
75
76
  const t = [];
76
77
  return e.comments.forEach((r) => {
77
78
  if (r.anchorId) {
@@ -83,20 +84,20 @@ function O(e) {
83
84
  }), t;
84
85
  }
85
86
  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;
87
+ const r = F(e), o = r ? r.innerHTML : "", a = t();
88
+ return r && r.innerHTML !== o && ($(r, o), r.dispatchEvent(new Event("input", { bubbles: !0 }))), a;
88
89
  }
89
- function M(e, t) {
90
+ function I(e, t) {
90
91
  const r = C(e, t);
91
92
  r && r.classList.toggle("rte-comment-anchor-resolved", t.resolved);
92
93
  }
93
94
  function E(e, t, r) {
94
95
  const o = e.comments.get(t);
95
96
  if (!o) return;
96
- const n = C(e, o);
97
- n && n.classList.toggle("highlighted", r);
97
+ const a = C(e, o);
98
+ a && a.classList.toggle("highlighted", r);
98
99
  }
99
- function P(e) {
100
+ function j(e) {
100
101
  const t = e.parentNode;
101
102
  if (t) {
102
103
  for (; e.firstChild; )
@@ -106,34 +107,37 @@ function P(e) {
106
107
  }
107
108
  function w(e, t) {
108
109
  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);
110
+ re(), Z(e), e.root.setAttribute("data-rte-comments-open", "true"), e.panelElement && (e.panelElement.classList.add("is-open"), e.panelElement.setAttribute("aria-hidden", "false")), K(e), M(e.panelElement);
110
111
  return;
111
112
  }
112
- e.root.removeAttribute("data-rte-comments-open"), F(e), e.panelElement && (e.panelElement.remove(), e.panelElement = null);
113
+ if (e.root.removeAttribute("data-rte-comments-open"), U(e), e.panelElement) {
114
+ const r = N(e.panelElement);
115
+ e.panelElement.remove(), e.panelElement = null, r && e.root.querySelector('[contenteditable="true"]')?.focus({ preventScroll: !0 });
116
+ }
113
117
  }
114
- function _(e) {
118
+ function Z(e) {
115
119
  if (e.panelElement) return;
116
120
  const t = document.createElement("aside");
117
121
  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;
118
122
  }
119
- function j(e) {
123
+ function K(e) {
120
124
  e.selectionChangeListener || (e.selectionChangeListener = () => {
121
125
  const t = window.getSelection();
122
126
  if (!t || t.rangeCount === 0 || t.isCollapsed) return;
123
127
  const r = t.getRangeAt(0);
124
- k(r, e.root) && (e.savedSelection = r.cloneRange(), x = e.root);
128
+ k(r, e.root) && (e.savedSelection = r.cloneRange(), h = e.root);
125
129
  }, document.addEventListener("selectionchange", e.selectionChangeListener));
126
130
  }
127
- function F(e) {
131
+ function U(e) {
128
132
  e.selectionChangeListener && (document.removeEventListener("selectionchange", e.selectionChangeListener), e.selectionChangeListener = null);
129
133
  }
130
- function Z(e) {
131
- return O(e).sort((t, r) => r.createdAt.localeCompare(t.createdAt));
134
+ function W(e) {
135
+ return _(e).sort((t, r) => r.createdAt.localeCompare(t.createdAt));
132
136
  }
133
137
  function B(e) {
134
138
  return new Date(e).toLocaleString();
135
139
  }
136
- function K(e, t) {
140
+ function X(e, t) {
137
141
  const r = e.expandedComments.has(t.id), o = document.createElement("article");
138
142
  o.className = `rte-comment-item${t.resolved ? " resolved" : ""}`, o.innerHTML = `
139
143
  <header class="rte-comment-header">
@@ -149,84 +153,85 @@ function K(e, t) {
149
153
  ${t.selectedText ? '<blockquote class="rte-comment-selection"></blockquote>' : ""}
150
154
  <section class="rte-comment-expanded${r ? " show" : ""}"></section>
151
155
  `;
152
- const n = o.querySelector(".rte-comment-author");
153
- n && (n.textContent = t.author);
156
+ const a = o.querySelector(".rte-comment-author");
157
+ a && (a.textContent = t.author);
154
158
  const c = o.querySelector(".rte-comment-text");
155
159
  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);
160
+ const p = o.querySelector(".rte-comment-selection");
161
+ p && (p.textContent = t.selectedText), o.querySelector(".rte-comment-expand")?.addEventListener("click", () => {
162
+ e.expandedComments.has(t.id) ? e.expandedComments.delete(t.id) : e.expandedComments.add(t.id), s(e);
159
163
  });
160
- const l = o.querySelector(".rte-comment-expanded");
161
- if (l && r) {
164
+ const d = o.querySelector(".rte-comment-expanded");
165
+ if (d && r) {
162
166
  if (t.replies.length > 0) {
163
- const a = document.createElement("div");
164
- a.className = "rte-comment-replies", t.replies.forEach((i) => {
167
+ const n = document.createElement("div");
168
+ n.className = "rte-comment-replies", t.replies.forEach((l) => {
165
169
  const m = document.createElement("div");
166
170
  m.className = "rte-comment-reply", m.innerHTML = `
167
171
  <div class="rte-comment-reply-header">
168
172
  <strong class="rte-comment-reply-author"></strong>
169
- <time>${B(i.createdAt)}</time>
173
+ <time>${B(l.createdAt)}</time>
170
174
  </div>
171
175
  <div class="rte-comment-reply-text"></div>
172
176
  `;
173
177
  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
+ v && (v.textContent = l.author);
179
+ const b = m.querySelector(".rte-comment-reply-text");
180
+ b && (b.textContent = l.text), n.appendChild(m);
181
+ }), d.appendChild(n);
178
182
  }
179
183
  if (!t.resolved) {
180
- const a = document.createElement("div");
181
- a.className = "rte-comment-reply-composer", a.innerHTML = `
184
+ const n = document.createElement("div");
185
+ n.className = "rte-comment-reply-composer", n.innerHTML = `
182
186
  <textarea class="rte-comment-reply-textarea" rows="2" placeholder="Reply..."></textarea>
183
187
  <button type="button" class="rte-comment-btn primary">Reply</button>
184
188
  `;
185
- const i = a.querySelector(
189
+ const l = n.querySelector(
186
190
  ".rte-comment-reply-textarea"
187
- ), m = a.querySelector(
191
+ ), m = n.querySelector(
188
192
  ".rte-comment-btn.primary"
189
193
  );
190
- if (i && m) {
191
- i.value = e.replyTexts[t.id] || "";
194
+ if (l && m) {
195
+ l.value = e.replyTexts[t.id] || "";
192
196
  const v = () => {
193
- const g = !!i.value.trim();
194
- m.disabled = !g;
197
+ const b = !!l.value.trim();
198
+ m.disabled = !b;
195
199
  };
196
- v(), i.addEventListener("input", () => {
197
- e.replyTexts[t.id] = i.value, v();
200
+ v(), l.addEventListener("input", () => {
201
+ e.replyTexts[t.id] = l.value, v();
198
202
  }), m.addEventListener("click", () => {
199
- const g = i.value.trim();
200
- g && (Q(t.id, T, g), e.replyTexts[t.id] = "", d(e));
203
+ const b = l.value.trim();
204
+ b && (te(t.id, T, b), e.replyTexts[t.id] = "", s(e));
201
205
  });
202
206
  }
203
- l.appendChild(a);
207
+ d.appendChild(n);
204
208
  }
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);
209
+ const i = document.createElement("div");
210
+ if (i.className = "rte-comment-actions", t.anchorId) {
211
+ const n = document.createElement("button");
212
+ n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Jump to text", n.onclick = () => {
213
+ const l = C(e, t);
214
+ l && (l.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), E(e, t.id, !0), window.setTimeout(() => E(e, t.id, !1), 1200));
215
+ }, i.appendChild(n);
212
216
  }
213
217
  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);
218
+ const n = document.createElement("button");
219
+ n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => Y(t.id), i.appendChild(n);
216
220
  } else {
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);
221
+ const n = document.createElement("button");
222
+ n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => Q(t.id, T), i.appendChild(n);
219
223
  }
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);
224
+ const x = document.createElement("button");
225
+ x.type = "button", x.className = "rte-comment-btn danger", x.textContent = "Delete", x.onclick = () => ee(t.id), i.appendChild(x), d.appendChild(i);
222
226
  }
223
227
  return o.addEventListener("mouseenter", () => E(e, t.id, !0)), o.addEventListener("mouseleave", () => E(e, t.id, !1)), o;
224
228
  }
225
- function d(e) {
229
+ function s(e) {
226
230
  const t = e || u();
227
231
  if (!t?.panelElement) return;
228
- const r = Z(t);
229
- t.panelElement.innerHTML = `
232
+ const r = W(t), o = t.panelElement;
233
+ D(o, () => {
234
+ o.innerHTML = `
230
235
  <div class="rte-comments-header">
231
236
  <div>
232
237
  <h3>Comments (${r.length})</h3>
@@ -241,65 +246,66 @@ function d(e) {
241
246
  </div>
242
247
  </div>
243
248
  ${r.length === 0 ? '<div class="rte-comments-empty">No comments yet.</div>' : '<div class="rte-comments-list"></div>'}
244
- `, t.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
245
- w(t, !1);
249
+ `;
250
+ }), t.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
251
+ w(t, !1), (!t.root.contains(document.activeElement) || document.activeElement === document.body) && t.root.querySelector('[contenteditable="true"]')?.focus({ preventScroll: !0 });
246
252
  });
247
- const n = t.panelElement.querySelector(
253
+ const c = t.panelElement.querySelector(
248
254
  ".new-comment-textarea"
249
- ), c = t.panelElement.querySelector(
255
+ ), p = t.panelElement.querySelector(
250
256
  ".add-comment-btn"
251
257
  );
252
- if (n && c) {
253
- n.value = t.newCommentText;
254
- const p = () => {
255
- const l = !!n.value.trim();
256
- c.disabled = !l;
258
+ if (c && p) {
259
+ c.value = t.newCommentText;
260
+ const d = () => {
261
+ const i = !!c.value.trim();
262
+ p.disabled = !i;
257
263
  };
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);
264
+ d(), c.addEventListener("input", () => {
265
+ t.newCommentText = c.value, d();
266
+ }), c.addEventListener("keydown", (i) => {
267
+ (i.ctrlKey || i.metaKey) && i.key === "Enter" && (i.preventDefault(), p.click());
268
+ }), p.addEventListener("click", () => {
269
+ const i = c.value.trim();
270
+ if (!i) return;
271
+ const x = !!t.savedSelection;
272
+ J(T, i, !x), t.newCommentText = "", s(t);
267
273
  });
268
274
  }
269
275
  const f = t.panelElement.querySelector(".rte-comments-list");
270
- f && r.forEach((p) => {
271
- f.appendChild(K(t, p));
276
+ f && r.forEach((d) => {
277
+ f.appendChild(X(t, d));
272
278
  });
273
279
  }
274
280
  const L = /* @__PURE__ */ new WeakMap();
275
- function U(e) {
281
+ function G(e) {
276
282
  L.has(e) || L.set(
277
283
  e,
278
284
  window.setTimeout(() => {
279
- L.delete(e), e.panelVisible && d(e);
285
+ L.delete(e), e.panelVisible && s(e);
280
286
  }, 120)
281
287
  );
282
288
  }
283
- function V() {
289
+ function z() {
284
290
  R || (R = !0, document.addEventListener("focusin", (e) => {
285
- const t = h(e.target);
286
- t && (x = t);
291
+ const t = g(e.target);
292
+ t && (h = t);
287
293
  }), document.addEventListener("click", (e) => {
288
294
  const r = (e.target instanceof Element ? e.target : null)?.closest(".rte-comment-anchor");
289
295
  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));
296
+ const o = g(r), a = o ? y.get(o) : null, c = r.getAttribute("data-comment-id");
297
+ !a || !c || !a.comments.has(c) || (e.preventDefault(), e.stopPropagation(), h = a.root, a.expandedComments.add(c), w(a, !0), s(a));
292
298
  }), document.addEventListener("input", (e) => {
293
299
  const t = e.target instanceof Element ? e.target : null;
294
300
  if (!t || t.closest(".rte-comments-panel")) return;
295
- const r = h(t), o = r ? y.get(r) : null;
296
- o?.panelVisible && U(o);
301
+ const r = g(t), o = r ? y.get(r) : null;
302
+ o?.panelVisible && G(o);
297
303
  }), document.addEventListener("selectionchange", () => {
298
304
  const e = window.getSelection();
299
305
  if (!e || e.rangeCount === 0) return;
300
- const t = e.getRangeAt(0), r = h(t.commonAncestorContainer);
306
+ const t = e.getRangeAt(0), r = g(t.commonAncestorContainer);
301
307
  if (!r) return;
302
- x = r;
308
+ h = r;
303
309
  const o = y.get(r);
304
310
  !o || e.isCollapsed || k(t, r) && (o.savedSelection = t.cloneRange());
305
311
  }), document.addEventListener(
@@ -312,86 +318,86 @@ function V() {
312
318
  !0
313
319
  ));
314
320
  }
315
- function W(e, t, r = !1) {
321
+ function J(e, t, r = !1) {
316
322
  const o = u();
317
323
  if (!o) return "";
318
- const n = t.trim();
319
- if (!n) return "";
324
+ const a = t.trim();
325
+ if (!a) return "";
320
326
  if (r) {
321
- const i = S("comment");
322
- return o.comments.set(i, {
323
- id: i,
327
+ const l = S("comment");
328
+ return o.comments.set(l, {
329
+ id: l,
324
330
  anchorId: "",
325
331
  selectedText: "",
326
332
  author: e,
327
- text: n,
333
+ text: a,
328
334
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
329
335
  resolved: !1,
330
336
  replies: []
331
- }), d(o), i;
337
+ }), s(o), l;
332
338
  }
333
- const c = o.savedSelection || I(o.root);
339
+ const c = o.savedSelection || V(o.root);
334
340
  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, () => {
341
+ const p = c.toString().trim();
342
+ if (!p) return "";
343
+ const f = S("comment"), d = S("comment-anchor"), i = document.createElement("span");
344
+ return i.id = d, i.className = "rte-comment-anchor", i.setAttribute("data-comment-id", f), i.setAttribute("title", "Commented text"), A(o, () => {
339
345
  try {
340
- const i = c.cloneRange(), m = i.extractContents();
341
- return m.textContent?.trim() ? (s.appendChild(m), i.insertNode(s), !0) : !1;
346
+ const l = c.cloneRange(), m = l.extractContents();
347
+ return m.textContent?.trim() ? (i.appendChild(m), l.insertNode(i), !0) : !1;
342
348
  } catch {
343
349
  return !1;
344
350
  }
345
- }) ? (o.comments.set(p, {
346
- id: p,
347
- anchorId: l,
348
- selectedText: f,
351
+ }) ? (o.comments.set(f, {
352
+ id: f,
353
+ anchorId: d,
354
+ selectedText: p,
349
355
  author: e,
350
- text: n,
356
+ text: a,
351
357
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
352
358
  resolved: !1,
353
359
  replies: []
354
- }), o.savedSelection = null, window.getSelection()?.removeAllRanges(), d(o), p) : "";
360
+ }), o.savedSelection = null, window.getSelection()?.removeAllRanges(), s(o), f) : "";
355
361
  }
356
- function X(e, t) {
362
+ function Q(e, t) {
357
363
  const r = u();
358
364
  if (!r) return;
359
365
  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));
366
+ o && (o.resolved = !0, o.resolvedBy = t, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), A(r, () => I(r, o)), s(r));
361
367
  }
362
- function G(e) {
368
+ function Y(e) {
363
369
  const t = u();
364
370
  if (!t) return;
365
371
  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));
372
+ r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, A(t, () => I(t, r)), s(t));
367
373
  }
368
- function J(e) {
374
+ function ee(e) {
369
375
  const t = u();
370
376
  if (!t) return;
371
377
  const r = t.comments.get(e);
372
378
  if (r) {
373
379
  if (r.anchorId) {
374
380
  const o = C(t, r);
375
- o && A(t, () => P(o));
381
+ o && A(t, () => j(o));
376
382
  } else
377
383
  t.comments.delete(e), t.expandedComments.delete(e), delete t.replyTexts[e];
378
- d(t);
384
+ s(t);
379
385
  }
380
386
  }
381
- function Q(e, t, r) {
387
+ function te(e, t, r) {
382
388
  const o = u();
383
389
  if (!o) return;
384
- const n = o.comments.get(e);
385
- if (!n) return;
390
+ const a = o.comments.get(e);
391
+ if (!a) return;
386
392
  const c = r.trim();
387
- c && (n.replies.push({
393
+ c && (a.replies.push({
388
394
  id: S("reply"),
389
395
  author: t,
390
396
  text: c,
391
397
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
392
- }), d(o));
398
+ }), s(o));
393
399
  }
394
- function Y() {
400
+ function re() {
395
401
  if (document.getElementById("rte-comments-panel-styles")) return;
396
402
  const e = document.createElement("style");
397
403
  e.id = "rte-comments-panel-styles", e.textContent = `
@@ -412,7 +418,9 @@ function Y() {
412
418
  opacity: 0;
413
419
  pointer-events: none;
414
420
  transition: transform 180ms ease, opacity 180ms ease;
415
- z-index: 55;
421
+ /* Above the editor's sticky toolbar (z-index 100): on a narrow screen the panel lies over the editor, and
422
+ under the toolbar its header, and the button that closes it, could not be clicked. */
423
+ z-index: 110;
416
424
  }
417
425
 
418
426
  .rte-comments-panel.is-open {
@@ -421,7 +429,16 @@ function Y() {
421
429
  pointer-events: auto;
422
430
  }
423
431
 
424
- [data-rte-comments-open="true"] :is(.rte-toolbar, .editora-toolbar, .rte-content, .editora-content, .editora-statusbar, .editora-statusbar-container) {
432
+ /* The panel's width is set on the editor itself, not only on the panel: the toolbar and the text make room for the
433
+ panel with a margin of that width, and a variable set on the panel is not visible to them (the margin was
434
+ silently 0, so the panel lay over the toolbar and the text and its header could not be reached). */
435
+ [data-rte-comments-open="true"] {
436
+ --rte-comments-panel-width: min(360px, 42vw);
437
+ }
438
+
439
+ /* The toolbar's wrapper is the element that is as wide as the editor, and it sits above the panel (it is sticky,
440
+ z-index 100): it has to give up the panel's width too, or its empty right-hand end covers the panel's header. */
441
+ [data-rte-comments-open="true"] :is(.rte-toolbar-wrapper, .rte-toolbar:not(.rte-toolbar-wrapper .rte-toolbar), .editora-toolbar, .rte-content, .editora-content, .editora-statusbar, .editora-statusbar-container) {
425
442
  margin-right: var(--rte-comments-panel-width);
426
443
  transition: margin-right 180ms ease;
427
444
  }
@@ -702,17 +719,18 @@ function Y() {
702
719
  }
703
720
 
704
721
  @media (max-width: 900px) {
722
+ [data-rte-comments-open="true"],
705
723
  .rte-comments-panel {
706
724
  --rte-comments-panel-width: min(420px, 100%);
707
725
  }
708
726
 
709
- [data-rte-comments-open="true"] :is(.rte-toolbar, .editora-toolbar, .rte-content, .editora-content, .editora-statusbar, .editora-statusbar-container) {
727
+ [data-rte-comments-open="true"] :is(.rte-toolbar-wrapper, .rte-toolbar:not(.rte-toolbar-wrapper .rte-toolbar), .editora-toolbar, .rte-content, .editora-content, .editora-statusbar, .editora-statusbar-container) {
710
728
  margin-right: 0;
711
729
  }
712
730
  }
713
731
  `, document.head.appendChild(e);
714
732
  }
715
- const te = () => ({
733
+ const ae = () => ({
716
734
  name: "comments",
717
735
  toolbar: [
718
736
  {
@@ -738,20 +756,20 @@ const te = () => ({
738
756
  ],
739
757
  commands: {
740
758
  addComment: (e, t) => {
741
- q(t), V();
759
+ q(t), z();
742
760
  const r = u();
743
- return r ? (r.savedSelection = I(r.root), r.savedSelection && window.getSelection()?.removeAllRanges(), w(r, !0), d(r), r.panelElement?.querySelector(
761
+ return r ? (r.savedSelection = V(r.root), r.savedSelection && window.getSelection()?.removeAllRanges(), w(r, !0), s(r), r.panelElement?.querySelector(
744
762
  ".new-comment-textarea"
745
763
  )?.focus({ preventScroll: !0 }), !0) : !1;
746
764
  },
747
765
  toggleComments: (e, t) => {
748
- q(t), V();
766
+ q(t), z();
749
767
  const r = u();
750
- return r ? (w(r, !r.panelVisible), r.panelVisible && d(r), !0) : !1;
768
+ return r ? (w(r, !r.panelVisible), r.panelVisible && s(r), !0) : !1;
751
769
  }
752
770
  },
753
771
  keymap: {}
754
772
  });
755
773
  export {
756
- te as CommentsPlugin
774
+ ae as CommentsPlugin
757
775
  };