@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.
- package/dist/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
- package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
- package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +17 -15
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +12 -5
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-CJ90EVWy.mjs +0 -145
- package/dist/index-DTkvH8gX.js +0 -1
package/dist/comments.esm.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
8
|
-
if (!
|
|
9
|
-
const
|
|
10
|
-
return
|
|
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
|
|
13
|
-
const
|
|
14
|
-
if (!(
|
|
15
|
-
const r =
|
|
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
|
|
19
|
-
return
|
|
19
|
+
function k(e, t) {
|
|
20
|
+
return t.contains(e.commonAncestorContainer);
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
+
function z() {
|
|
22
23
|
if (typeof window < "u") {
|
|
23
24
|
const o = window.__editoraCommandEditorRoot;
|
|
24
25
|
if (o instanceof HTMLElement) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return x =
|
|
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
|
|
31
|
-
if (
|
|
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 =
|
|
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
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
42
|
+
function D(e) {
|
|
43
|
+
const t = y.get(e);
|
|
44
|
+
if (t) return t;
|
|
44
45
|
const r = {
|
|
45
|
-
root:
|
|
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
|
|
56
|
+
return y.set(e, r), r;
|
|
56
57
|
}
|
|
57
58
|
function u() {
|
|
58
|
-
const
|
|
59
|
-
return
|
|
59
|
+
const e = z();
|
|
60
|
+
return e ? (x = e, D(e)) : null;
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
64
|
-
const r =
|
|
65
|
-
return
|
|
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
|
|
68
|
-
|
|
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
|
|
73
|
-
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
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
|
|
84
|
-
const e = t
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
|
92
|
-
if (
|
|
93
|
-
|
|
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
|
-
|
|
112
|
+
e.root.removeAttribute("data-rte-comments-open"), F(e), e.panelElement && (e.panelElement.remove(), e.panelElement = null);
|
|
97
113
|
}
|
|
98
|
-
function
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
|
|
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
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
107
|
-
const r =
|
|
108
|
-
|
|
109
|
-
}, document.addEventListener("selectionchange",
|
|
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
|
|
112
|
-
|
|
127
|
+
function F(e) {
|
|
128
|
+
e.selectionChangeListener && (document.removeEventListener("selectionchange", e.selectionChangeListener), e.selectionChangeListener = null);
|
|
113
129
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
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
|
|
120
|
-
return new Date(
|
|
133
|
+
function B(e) {
|
|
134
|
+
return new Date(e).toLocaleString();
|
|
121
135
|
}
|
|
122
|
-
function
|
|
123
|
-
const r =
|
|
124
|
-
o.className = `rte-comment-item${
|
|
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"
|
|
128
|
-
<time class="rte-comment-date">${
|
|
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
|
-
${
|
|
149
|
+
${t.selectedText ? '<blockquote class="rte-comment-selection"></blockquote>' : ""}
|
|
136
150
|
<section class="rte-comment-expanded${r ? " show" : ""}"></section>
|
|
137
151
|
`;
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
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
|
|
143
|
-
if (
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
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
|
|
151
|
-
<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
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
|
185
|
+
const i = a.querySelector(
|
|
166
186
|
".rte-comment-reply-textarea"
|
|
167
|
-
),
|
|
187
|
+
), m = a.querySelector(
|
|
168
188
|
".rte-comment-btn.primary"
|
|
169
189
|
);
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
const
|
|
174
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
}),
|
|
179
|
-
const
|
|
180
|
-
|
|
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
|
-
|
|
184
|
-
}
|
|
185
|
-
const
|
|
186
|
-
if (
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
},
|
|
192
|
-
}
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
|
|
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
|
|
198
|
-
|
|
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
|
|
201
|
-
|
|
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", () =>
|
|
223
|
+
return o.addEventListener("mouseenter", () => E(e, t.id, !0)), o.addEventListener("mouseleave", () => E(e, t.id, !1)), o;
|
|
204
224
|
}
|
|
205
|
-
function
|
|
206
|
-
const
|
|
207
|
-
if (!
|
|
208
|
-
const r =
|
|
209
|
-
|
|
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
|
-
`,
|
|
225
|
-
|
|
244
|
+
`, t.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
|
|
245
|
+
w(t, !1);
|
|
226
246
|
});
|
|
227
|
-
const
|
|
247
|
+
const n = t.panelElement.querySelector(
|
|
228
248
|
".new-comment-textarea"
|
|
229
|
-
),
|
|
249
|
+
), c = t.panelElement.querySelector(
|
|
230
250
|
".add-comment-btn"
|
|
231
251
|
);
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
}),
|
|
241
|
-
(
|
|
242
|
-
}),
|
|
243
|
-
const
|
|
244
|
-
if (!
|
|
245
|
-
const
|
|
246
|
-
|
|
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
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
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
|
|
260
|
-
if (!
|
|
261
|
-
const
|
|
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 =
|
|
265
|
-
!o ||
|
|
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
|
-
(
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
!
|
|
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
|
|
315
|
+
function W(e, t, r = !1) {
|
|
277
316
|
const o = u();
|
|
278
317
|
if (!o) return "";
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
318
|
+
const n = t.trim();
|
|
319
|
+
if (!n) return "";
|
|
281
320
|
if (r) {
|
|
282
|
-
const
|
|
283
|
-
return o.comments.set(
|
|
284
|
-
id:
|
|
321
|
+
const i = S("comment");
|
|
322
|
+
return o.comments.set(i, {
|
|
323
|
+
id: i,
|
|
285
324
|
anchorId: "",
|
|
286
325
|
selectedText: "",
|
|
287
|
-
author:
|
|
288
|
-
text:
|
|
326
|
+
author: e,
|
|
327
|
+
text: n,
|
|
289
328
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
290
329
|
resolved: !1,
|
|
291
330
|
replies: []
|
|
292
|
-
}),
|
|
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
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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(),
|
|
354
|
+
}), o.savedSelection = null, window.getSelection()?.removeAllRanges(), d(o), p) : "";
|
|
317
355
|
}
|
|
318
|
-
function
|
|
356
|
+
function X(e, t) {
|
|
319
357
|
const r = u();
|
|
320
358
|
if (!r) return;
|
|
321
|
-
const o = r.comments.get(
|
|
322
|
-
o && (o.resolved = !0, o.resolvedBy =
|
|
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
|
|
325
|
-
const
|
|
326
|
-
if (!
|
|
327
|
-
const r =
|
|
328
|
-
r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0,
|
|
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
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
333
|
-
const r =
|
|
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 =
|
|
337
|
-
o &&
|
|
338
|
-
}
|
|
339
|
-
|
|
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
|
|
381
|
+
function Q(e, t, r) {
|
|
343
382
|
const o = u();
|
|
344
383
|
if (!o) return;
|
|
345
|
-
const
|
|
346
|
-
if (!
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
id:
|
|
350
|
-
author:
|
|
351
|
-
text:
|
|
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
|
-
}),
|
|
392
|
+
}), d(o));
|
|
354
393
|
}
|
|
355
|
-
function
|
|
394
|
+
function Y() {
|
|
356
395
|
if (document.getElementById("rte-comments-panel-styles")) return;
|
|
357
|
-
const
|
|
358
|
-
|
|
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(
|
|
713
|
+
`, document.head.appendChild(e);
|
|
675
714
|
}
|
|
676
|
-
const
|
|
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
|
-
|
|
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: (
|
|
694
|
-
|
|
740
|
+
addComment: (e, t) => {
|
|
741
|
+
q(t), V();
|
|
695
742
|
const r = u();
|
|
696
|
-
return r ? (r.savedSelection =
|
|
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: (
|
|
701
|
-
|
|
747
|
+
toggleComments: (e, t) => {
|
|
748
|
+
q(t), V();
|
|
702
749
|
const r = u();
|
|
703
|
-
return r ? (
|
|
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
|
-
|
|
756
|
+
te as CommentsPlugin
|
|
710
757
|
};
|