@editora/plugins 1.0.21 → 1.0.23
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/README.md +259 -645
- package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-DESvGCrJ.mjs} +61 -53
- package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-DJqwsRPZ.js} +11 -11
- package/dist/a11y-checker.cjs.js +3 -3
- package/dist/a11y-checker.esm.js +6 -4
- package/dist/anchor.cjs.js +4 -4
- package/dist/anchor.esm.js +19 -18
- package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
- package/dist/anchoredPopover-Cygmit_o.js +1 -0
- package/dist/approval-workflow.cjs.js +7 -7
- package/dist/approval-workflow.esm.js +55 -54
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +72 -67
- package/dist/blocks-library.cjs.js +18 -19
- package/dist/blocks-library.esm.js +41 -42
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +50 -50
- package/dist/code-sample.cjs.js +10 -10
- package/dist/code-sample.esm.js +4 -4
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/comments.cjs.js +23 -11
- package/dist/comments.esm.js +167 -149
- package/dist/conditional-content.cjs.js +2 -2
- package/dist/conditional-content.esm.js +2 -2
- package/dist/confirmDialog-6BPaNPis.mjs +106 -0
- package/dist/confirmDialog-C4UWENes.js +46 -0
- package/dist/content-rules.cjs.js +6 -6
- package/dist/content-rules.esm.js +51 -51
- package/dist/data-binding.cjs.js +2 -2
- package/dist/data-binding.esm.js +2 -2
- package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
- package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
- package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
- package/dist/embed-iframe.cjs.js +6 -6
- package/dist/embed-iframe.esm.js +6 -6
- package/dist/emojis.cjs.js +5 -5
- package/dist/emojis.esm.js +3 -3
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +1 -1
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +172 -151
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +96 -83
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +176 -97
- package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
- package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/katex-Cc3-mvOY.js +257 -0
- package/dist/katex-DoRnZ_sp.mjs +11682 -0
- package/dist/katex.min--Ws3c9be.mjs +5 -0
- package/dist/katex.min-Dk2VscxB.js +2 -0
- package/dist/link.cjs.js +3 -3
- package/dist/link.esm.js +3 -3
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +140 -52
- package/dist/math.cjs.js +14 -14
- package/dist/math.esm.js +149 -136
- package/dist/media-manager.cjs.js +46 -46
- package/dist/media-manager.esm.js +320 -264
- package/dist/mentions.cjs.js +12 -12
- package/dist/mentions.esm.js +149 -143
- package/dist/merge-tag.cjs.js +5 -3
- package/dist/merge-tag.esm.js +5 -3
- package/dist/notify-BkbzMopb.js +32 -0
- package/dist/notify-zOp-mUOJ.mjs +59 -0
- package/dist/pii-redaction.cjs.js +1 -1
- package/dist/pii-redaction.esm.js +1 -1
- package/dist/preview.cjs.js +1 -1
- package/dist/preview.esm.js +1 -1
- package/dist/shared-config.cjs.js +1 -1
- package/dist/shared-config.esm.js +14 -14
- package/dist/slash-commands.cjs.js +5 -5
- package/dist/slash-commands.esm.js +259 -236
- package/dist/smart-paste.cjs.js +1 -1
- package/dist/smart-paste.esm.js +1 -1
- package/dist/special-characters.cjs.js +3 -3
- package/dist/special-characters.esm.js +3 -3
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +288 -251
- package/dist/table.cjs.js +14 -14
- package/dist/table.esm.js +175 -154
- package/dist/template.cjs.js +5 -3
- package/dist/template.esm.js +15 -13
- package/dist/text-color.cjs.js +4 -4
- package/dist/text-color.esm.js +38 -34
- package/dist/translation-workflow.cjs.js +9 -9
- package/dist/translation-workflow.esm.js +98 -95
- package/dist/version-diff.cjs.js +4 -4
- package/dist/version-diff.esm.js +36 -36
- package/package.json +6 -5
- package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
- package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
- package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
- package/dist/dialogHelpers-zU6zpMIA.js +0 -12
package/dist/anchor.esm.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { i as z } from "./dialogHelpers-
|
|
1
|
+
import { i as z } from "./dialogHelpers-BbwpIXD9.mjs";
|
|
2
|
+
import { n as M } from "./notify-zOp-mUOJ.mjs";
|
|
2
3
|
import { f as D, g as S } from "./editorContainerHelpers-C7kdWnS0.mjs";
|
|
3
4
|
const b = /* @__PURE__ */ new Set(), x = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
4
|
-
function
|
|
5
|
+
function H(t, c) {
|
|
5
6
|
if (c === t.innerHTML) return;
|
|
6
7
|
const s = window.execEditorCommand || window.executeEditorCommand;
|
|
7
8
|
if (typeof s == "function")
|
|
@@ -10,7 +11,7 @@ function M(t, c) {
|
|
|
10
11
|
} catch {
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function R() {
|
|
14
15
|
if (typeof window > "u" || window.__anchorObserverInitialized) return;
|
|
15
16
|
window.__anchorObserverInitialized = !0, new MutationObserver((c) => {
|
|
16
17
|
c.forEach((s) => {
|
|
@@ -36,7 +37,7 @@ function H() {
|
|
|
36
37
|
function A(t) {
|
|
37
38
|
return !t || t.trim().length === 0 ? { valid: !1, error: "Anchor ID cannot be empty" } : t.length > 256 ? { valid: !1, error: "Anchor ID must be less than 256 characters" } : /^[A-Za-z_]/.test(t) ? /^[A-Za-z0-9\-_]+$/.test(t) ? { valid: !0, error: "" } : { valid: !1, error: "Anchor ID can only contain letters, numbers, hyphens, and underscores" } : { valid: !1, error: "Anchor ID must start with a letter or underscore" };
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function I() {
|
|
40
41
|
const t = D();
|
|
41
42
|
if (!t) return;
|
|
42
43
|
const c = S(t);
|
|
@@ -47,7 +48,7 @@ function R() {
|
|
|
47
48
|
e && a.add(e);
|
|
48
49
|
}), b.clear(), a.forEach((l) => b.add(l));
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function _(t) {
|
|
51
52
|
if (t) {
|
|
52
53
|
const a = t.startContainer;
|
|
53
54
|
if ((a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement)?.closest(x)) return !0;
|
|
@@ -59,9 +60,9 @@ function I(t) {
|
|
|
59
60
|
}
|
|
60
61
|
return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
document.querySelectorAll(".rte-anchor-dialog-overlay").forEach((r) => r.remove()),
|
|
64
|
-
const l =
|
|
63
|
+
function L(t, c, s, a) {
|
|
64
|
+
document.querySelectorAll(".rte-anchor-dialog-overlay").forEach((r) => r.remove()), I();
|
|
65
|
+
const l = _(a), e = l ? {
|
|
65
66
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
66
67
|
dialogBg: "#1f2937",
|
|
67
68
|
panelBg: "#222d3a",
|
|
@@ -78,7 +79,7 @@ function _(t, c, s, a) {
|
|
|
78
79
|
cancelBg: "#334155",
|
|
79
80
|
cancelHover: "#475569",
|
|
80
81
|
cancelText: "#e2e8f0",
|
|
81
|
-
saveBg: "#
|
|
82
|
+
saveBg: "#2563eb",
|
|
82
83
|
saveHover: "#2563eb",
|
|
83
84
|
saveDisabledBg: "#374151",
|
|
84
85
|
saveDisabledText: "#7f8ca1",
|
|
@@ -91,7 +92,7 @@ function _(t, c, s, a) {
|
|
|
91
92
|
panelBg: "#f9f9f9",
|
|
92
93
|
border: "#e0e0e0",
|
|
93
94
|
text: "#333333",
|
|
94
|
-
muted: "#
|
|
95
|
+
muted: "#6b6b6b",
|
|
95
96
|
closeHoverBg: "#e0e0e0",
|
|
96
97
|
fieldBg: "#ffffff",
|
|
97
98
|
fieldFocusBg: "#f9f9ff",
|
|
@@ -106,7 +107,7 @@ function _(t, c, s, a) {
|
|
|
106
107
|
saveHover: "#0052a3",
|
|
107
108
|
saveDisabledBg: "#d0d0d0",
|
|
108
109
|
saveDisabledText: "#999999",
|
|
109
|
-
help: "#
|
|
110
|
+
help: "#6b6b6b",
|
|
110
111
|
focusRing: "rgba(0, 102, 204, 0.1)",
|
|
111
112
|
errorRing: "rgba(211, 47, 47, 0.1)"
|
|
112
113
|
}, n = document.createElement("div");
|
|
@@ -269,7 +270,7 @@ function _(t, c, s, a) {
|
|
|
269
270
|
r.target === n && E();
|
|
270
271
|
}, u.appendChild(h), u.appendChild(C), u.appendChild(v), n.appendChild(u), document.body.appendChild(n), setTimeout(() => o.focus(), 100);
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function O(t, c) {
|
|
273
274
|
let s;
|
|
274
275
|
if (c)
|
|
275
276
|
s = c;
|
|
@@ -297,7 +298,7 @@ function L(t, c) {
|
|
|
297
298
|
`, s.insertNode(n), b.add(t), s.setStart(n.nextSibling || n.parentNode, 0), s.collapse(!0);
|
|
298
299
|
const u = window.getSelection();
|
|
299
300
|
if (u && (u.removeAllRanges(), u.addRange(s)), a)
|
|
300
|
-
|
|
301
|
+
H(a, e), a.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
301
302
|
else {
|
|
302
303
|
const d = D();
|
|
303
304
|
if (d) {
|
|
@@ -390,7 +391,7 @@ function N() {
|
|
|
390
391
|
}
|
|
391
392
|
`, document.head.appendChild(t);
|
|
392
393
|
}
|
|
393
|
-
const
|
|
394
|
+
const P = () => (typeof window < "u" && (R(), N()), {
|
|
394
395
|
name: "anchor",
|
|
395
396
|
toolbar: [
|
|
396
397
|
{
|
|
@@ -405,10 +406,10 @@ const j = () => (typeof window < "u" && (H(), N()), {
|
|
|
405
406
|
try {
|
|
406
407
|
const t = window.getSelection();
|
|
407
408
|
if (!t || t.rangeCount === 0)
|
|
408
|
-
return
|
|
409
|
+
return M("Please place your cursor where you want to insert the anchor."), !1;
|
|
409
410
|
const c = t.getRangeAt(0).cloneRange();
|
|
410
|
-
return
|
|
411
|
-
|
|
411
|
+
return L("add", "", (s) => {
|
|
412
|
+
O(s, c);
|
|
412
413
|
}, c), !0;
|
|
413
414
|
} catch (t) {
|
|
414
415
|
return console.error("Failed to insert anchor:", t), !1;
|
|
@@ -420,5 +421,5 @@ const j = () => (typeof window < "u" && (H(), N()), {
|
|
|
420
421
|
}
|
|
421
422
|
});
|
|
422
423
|
export {
|
|
423
|
-
|
|
424
|
+
P as AnchorPlugin
|
|
424
425
|
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { r as k } from "./historyHelpers-BEKwNOtA.mjs";
|
|
2
|
+
const N = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
|
|
3
|
+
function M(e) {
|
|
4
|
+
return !!e.cloneContents().querySelector(N);
|
|
5
|
+
}
|
|
6
|
+
function E(e, t) {
|
|
7
|
+
return (e?.nodeType === Node.ELEMENT_NODE ? e : e?.parentElement ?? null)?.closest('[contenteditable="true"]') || t()?.querySelector('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
|
|
8
|
+
}
|
|
9
|
+
function x(e, t) {
|
|
10
|
+
const n = E(e, t);
|
|
11
|
+
n && n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
12
|
+
}
|
|
13
|
+
function O(e, t) {
|
|
14
|
+
let r = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
|
|
15
|
+
for (; r && r !== document.body; ) {
|
|
16
|
+
if (r.classList.contains(t)) {
|
|
17
|
+
const s = document.createRange();
|
|
18
|
+
if (s.selectNodeContents(r), s.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && s.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
r = r.parentElement;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function _(e) {
|
|
26
|
+
const t = window.getSelection(), n = e.savedRange?.commonAncestorContainer ?? (t && t.rangeCount > 0 ? t.getRangeAt(0).commonAncestorContainer : null), r = E(n, e.getActiveEditorRoot), s = r ? r.innerHTML : null, l = q(e);
|
|
27
|
+
return l && r && s !== null && k(r, s), l;
|
|
28
|
+
}
|
|
29
|
+
function q(e) {
|
|
30
|
+
try {
|
|
31
|
+
if (e.savedRange) {
|
|
32
|
+
const i = window.getSelection();
|
|
33
|
+
i && (i.removeAllRanges(), i.addRange(e.savedRange.cloneRange()));
|
|
34
|
+
}
|
|
35
|
+
const t = window.getSelection();
|
|
36
|
+
if (!t || t.rangeCount === 0 || t.isCollapsed)
|
|
37
|
+
return !1;
|
|
38
|
+
const n = t.getRangeAt(0);
|
|
39
|
+
if (n.collapsed)
|
|
40
|
+
return !1;
|
|
41
|
+
const r = O(n, e.className);
|
|
42
|
+
if (r)
|
|
43
|
+
return e.styleProperty === "backgroundColor" ? r.style.backgroundColor = e.color : r.style.color = e.color, x(r, e.getActiveEditorRoot), !0;
|
|
44
|
+
E(
|
|
45
|
+
n.commonAncestorContainer,
|
|
46
|
+
e.getActiveEditorRoot
|
|
47
|
+
)?.focus({ preventScroll: !0 });
|
|
48
|
+
try {
|
|
49
|
+
document.execCommand("styleWithCSS", !1, "true");
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
let l = !1;
|
|
53
|
+
if (e.commands.forEach((i) => {
|
|
54
|
+
l || (l = document.execCommand(i, !1, e.color));
|
|
55
|
+
}), !l && !M(n)) {
|
|
56
|
+
const i = document.createElement("span");
|
|
57
|
+
e.styleProperty === "backgroundColor" ? i.style.backgroundColor = e.color : i.style.color = e.color, i.className = e.className;
|
|
58
|
+
const a = n.extractContents();
|
|
59
|
+
i.appendChild(a), n.insertNode(i), n.setStartAfter(i), n.collapse(!0), t.removeAllRanges(), t.addRange(n), l = !0;
|
|
60
|
+
}
|
|
61
|
+
return l ? (x(n.commonAncestorContainer, e.getActiveEditorRoot), !0) : (e.warnMessage && console.warn(e.warnMessage), !1);
|
|
62
|
+
} catch (t) {
|
|
63
|
+
return e.warnMessage ? console.error(e.warnMessage, t) : console.error("[ColorApply] Failed to apply color", t), !1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function B({
|
|
67
|
+
popover: e,
|
|
68
|
+
anchor: t,
|
|
69
|
+
onClose: n,
|
|
70
|
+
gap: r = 6,
|
|
71
|
+
margin: s = 8,
|
|
72
|
+
zIndex: l = 1e4,
|
|
73
|
+
label: i,
|
|
74
|
+
initialFocus: a
|
|
75
|
+
}) {
|
|
76
|
+
e.style.position = "fixed", e.style.zIndex = `${l}`, e.style.visibility = "hidden";
|
|
77
|
+
const w = () => {
|
|
78
|
+
if (!e.isConnected || !t.isConnected) {
|
|
79
|
+
n();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const o = t.getBoundingClientRect();
|
|
83
|
+
if (o.width === 0 && o.height === 0) {
|
|
84
|
+
n();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const c = e.getBoundingClientRect(), u = c.width || e.offsetWidth || 220, f = c.height || e.offsetHeight || 260, h = window.innerWidth, T = window.innerHeight;
|
|
88
|
+
let m = o.left, d = o.bottom + r;
|
|
89
|
+
if (m + u > h - s && (m = h - u - s), m = Math.max(s, m), d + f > T - s) {
|
|
90
|
+
const S = o.top - f - r;
|
|
91
|
+
S >= s ? d = S : d = Math.max(s, T - f - s);
|
|
92
|
+
}
|
|
93
|
+
d < s && (d = s), e.style.left = `${Math.round(m)}px`, e.style.top = `${Math.round(d)}px`, e.style.visibility = "visible";
|
|
94
|
+
}, g = () => {
|
|
95
|
+
w();
|
|
96
|
+
}, C = (o) => {
|
|
97
|
+
const c = o.target;
|
|
98
|
+
c && (e.contains(c) || t.contains(c) || n());
|
|
99
|
+
}, b = (o) => {
|
|
100
|
+
o.key === "Escape" && n();
|
|
101
|
+
}, R = () => Array.from(e.querySelectorAll("button, input, select, textarea, [tabindex]")).filter(
|
|
102
|
+
(o) => !o.disabled && o.tabIndex >= 0 && o.getClientRects().length > 0
|
|
103
|
+
), A = (o) => {
|
|
104
|
+
if (o.key !== "Tab" || o.defaultPrevented) return;
|
|
105
|
+
const c = R();
|
|
106
|
+
if (c.length === 0) return;
|
|
107
|
+
const u = c.indexOf(document.activeElement), f = o.shiftKey ? -1 : 1, h = u === -1 ? o.shiftKey ? c[c.length - 1] : c[0] : c[(u + f + c.length) % c.length];
|
|
108
|
+
o.preventDefault(), h.focus();
|
|
109
|
+
};
|
|
110
|
+
(a !== void 0 || i) && (i && (e.getAttribute("role") || e.setAttribute("role", "dialog"), e.getAttribute("aria-label") || e.setAttribute("aria-label", i)), e.addEventListener("keydown", A)), window.addEventListener("resize", g), window.addEventListener("scroll", g, !0), document.addEventListener("keydown", b);
|
|
111
|
+
const L = window.requestAnimationFrame(() => {
|
|
112
|
+
document.addEventListener("mousedown", C, !0);
|
|
113
|
+
});
|
|
114
|
+
w();
|
|
115
|
+
let y;
|
|
116
|
+
const v = (o) => {
|
|
117
|
+
if (!e.isConnected) return;
|
|
118
|
+
const c = (a ? e.querySelector(a) : null) ?? R()[0];
|
|
119
|
+
c?.focus({ preventScroll: !0 }), c && !e.contains(document.activeElement) && o < 4 && (y = window.setTimeout(() => v(o + 1), 40));
|
|
120
|
+
};
|
|
121
|
+
return a !== void 0 && (y = window.setTimeout(() => v(0), 0)), { reposition: w, destroy: () => {
|
|
122
|
+
window.clearTimeout(y), e.removeEventListener("keydown", A), window.cancelAnimationFrame(L), window.removeEventListener("resize", g), window.removeEventListener("scroll", g, !0), document.removeEventListener("keydown", b), document.removeEventListener("mousedown", C, !0);
|
|
123
|
+
} };
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
_ as a,
|
|
127
|
+
B as b
|
|
128
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const k=require("./historyHelpers-Cu8Pk7m1.js"),N="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function M(e){return!!e.cloneContents().querySelector(N)}function E(e,t){return(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest('[contenteditable="true"]')||t()?.querySelector('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function L(e,t){const n=E(e,t);n&&n.dispatchEvent(new Event("input",{bubbles:!0}))}function q(e,t){let r=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentElement:e.startContainer;for(;r&&r!==document.body;){if(r.classList.contains(t)){const l=document.createRange();if(l.selectNodeContents(r),l.compareBoundaryPoints(Range.START_TO_START,e)<=0&&l.compareBoundaryPoints(Range.END_TO_END,e)>=0)return r}r=r.parentElement}return null}function H(e){const t=window.getSelection(),n=e.savedRange?.commonAncestorContainer??(t&&t.rangeCount>0?t.getRangeAt(0).commonAncestorContainer:null),r=E(n,e.getActiveEditorRoot),l=r?r.innerHTML:null,i=O(e);return i&&r&&l!==null&&k.recordDomHistory(r,l),i}function O(e){try{if(e.savedRange){const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(e.savedRange.cloneRange()))}const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0);if(n.collapsed)return!1;const r=q(n,e.className);if(r)return e.styleProperty==="backgroundColor"?r.style.backgroundColor=e.color:r.style.color=e.color,L(r,e.getActiveEditorRoot),!0;E(n.commonAncestorContainer,e.getActiveEditorRoot)?.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let i=!1;if(e.commands.forEach(s=>{i||(i=document.execCommand(s,!1,e.color))}),!i&&!M(n)){const s=document.createElement("span");e.styleProperty==="backgroundColor"?s.style.backgroundColor=e.color:s.style.color=e.color,s.className=e.className;const a=n.extractContents();s.appendChild(a),n.insertNode(s),n.setStartAfter(s),n.collapse(!0),t.removeAllRanges(),t.addRange(n),i=!0}return i?(L(n.commonAncestorContainer,e.getActiveEditorRoot),!0):(e.warnMessage&&console.warn(e.warnMessage),!1)}catch(t){return e.warnMessage?console.error(e.warnMessage,t):console.error("[ColorApply] Failed to apply color",t),!1}}function P({popover:e,anchor:t,onClose:n,gap:r=6,margin:l=8,zIndex:i=1e4,label:s,initialFocus:a}){e.style.position="fixed",e.style.zIndex=`${i}`,e.style.visibility="hidden";const g=()=>{if(!e.isConnected||!t.isConnected){n();return}const o=t.getBoundingClientRect();if(o.width===0&&o.height===0){n();return}const c=e.getBoundingClientRect(),u=c.width||e.offsetWidth||220,f=c.height||e.offsetHeight||260,y=window.innerWidth,T=window.innerHeight;let m=o.left,d=o.bottom+r;if(m+u>y-l&&(m=y-u-l),m=Math.max(l,m),d+f>T-l){const S=o.top-f-r;S>=l?d=S:d=Math.max(l,T-f-l)}d<l&&(d=l),e.style.left=`${Math.round(m)}px`,e.style.top=`${Math.round(d)}px`,e.style.visibility="visible"},h=()=>{g()},C=o=>{const c=o.target;c&&(e.contains(c)||t.contains(c)||n())},b=o=>{o.key==="Escape"&&n()},A=()=>Array.from(e.querySelectorAll("button, input, select, textarea, [tabindex]")).filter(o=>!o.disabled&&o.tabIndex>=0&&o.getClientRects().length>0),R=o=>{if(o.key!=="Tab"||o.defaultPrevented)return;const c=A();if(c.length===0)return;const u=c.indexOf(document.activeElement),f=o.shiftKey?-1:1,y=u===-1?o.shiftKey?c[c.length-1]:c[0]:c[(u+f+c.length)%c.length];o.preventDefault(),y.focus()};(a!==void 0||s)&&(s&&(e.getAttribute("role")||e.setAttribute("role","dialog"),e.getAttribute("aria-label")||e.setAttribute("aria-label",s)),e.addEventListener("keydown",R)),window.addEventListener("resize",h),window.addEventListener("scroll",h,!0),document.addEventListener("keydown",b);const x=window.requestAnimationFrame(()=>{document.addEventListener("mousedown",C,!0)});g();let w;const v=o=>{if(!e.isConnected)return;const c=(a?e.querySelector(a):null)??A()[0];c?.focus({preventScroll:!0}),c&&!e.contains(document.activeElement)&&o<4&&(w=window.setTimeout(()=>v(o+1),40))};return a!==void 0&&(w=window.setTimeout(()=>v(0),0)),{reposition:g,destroy:()=>{window.clearTimeout(w),e.removeEventListener("keydown",R),window.cancelAnimationFrame(x),window.removeEventListener("resize",h),window.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",b),document.removeEventListener("mousedown",C,!0)}}}exports.applyColorToSelection=H;exports.attachAnchoredPopover=P;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=".rte-content, .editora-content",F="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",et="__editoraCommandEditorRoot",ot="rte-approval-workflow-styles",d="rte-approval-panel",h="approval",k="approvalWorkflow",g=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const ft=require("./dialogHelpers-BxSQ7A6M.js"),w=".rte-content, .editora-content",F="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",et="__editoraCommandEditorRoot",ot="rte-approval-workflow-styles",d="rte-approval-panel",h="approval",k="approvalWorkflow",g=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',mt={panelTitle:"Approval Workflow",panelAriaLabel:"Approval workflow panel",statusLabel:"Status",statusDraftText:"Draft",statusReviewText:"In Review",statusApprovedText:"Approved",requestReviewText:"Request Review",approveText:"Approve",reopenDraftText:"Reopen Draft",addCommentText:"Add Comment",actorLabel:"Actor",actorPlaceholder:"Reviewer name",commentLabel:"Comment",commentPlaceholder:"Add review note or sign-off context",closeText:"Close",commentsHeading:"Comments",signoffsHeading:"Sign-offs",noCommentsText:"No comments yet.",noSignoffsText:"No sign-offs yet.",summaryPrefix:"Workflow",lockedSuffix:"Locked",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+A/R/P/D",approveCommentRequiredText:"Approval comment is required."},bt={draft:"statusDraftText",review:"statusReviewText",approved:"statusApprovedText"},s=new WeakMap,I=new WeakMap,y=new Map,O=new WeakMap,H=new Set;let _=0,gt=0,rt=0,at=0,R=null,v=null,T=null,L=null,S=null;function p(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vt(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function lt(t){return t==="review"||t==="approved"?t:"draft"}function z(t={}){return{defaultStatus:lt(t.defaultStatus),lockOnApproval:t.lockOnApproval!==!1,maxHistoryEntries:Math.max(10,Math.min(500,Number(t.maxHistoryEntries??120))),requireCommentOnApprove:!!t.requireCommentOnApprove,defaultActor:(t.defaultActor||"system").trim()||"system",labels:{...mt,...t.labels||{}},normalizeText:t.normalizeText||vt}}function Y(t){return t.closest(F)||t}function K(t){if(!t)return null;if(t.matches(w))return t;const e=t.querySelector(w);return e instanceof HTMLElement?e:null}function ht(){if(typeof window>"u")return null;const t=window[et];if(!(t instanceof HTMLElement))return null;window[et]=null;const e=K(t);if(e)return e;const o=t.closest(F);if(o){const a=K(o);if(a)return a}return null}function xt(t){const e=t.closest("[data-editora-editor]");if(e&&K(e)===t)return e;let o=t;for(;o;){if(o.matches(F)&&(o===t||K(o)===t))return o;o=o.parentElement}return Y(t)}function W(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function wt(t){const e=Y(t);if(W(e))return!0;const o=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return W(o)?!0:W(document.documentElement)||W(document.body)}function B(t,e){t.classList.remove("rte-approval-theme-dark"),wt(e)&&t.classList.add("rte-approval-theme-dark")}function it(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function x(t,e=!0){if(D(),t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const n=t.editorElement;if(n.matches(w))return n;const l=n.querySelector(w);if(l instanceof HTMLElement)return l}const o=ht();if(o)return o;const a=window.getSelection();if(a&&a.rangeCount>0){const l=it(a.getRangeAt(0).startContainer)?.closest(w);if(l)return l}const r=document.activeElement;if(r){if(r.matches(w))return r;const n=r.closest(w);if(n)return n}return v&&v.isConnected?v:(v&&!v.isConnected&&(v=null),e?document.querySelector(w):null)}function D(){Array.from(H).forEach(e=>{e.isConnected||(y.get(e)?.remove(),y.delete(e),O.delete(e),s.delete(e),I.delete(e),H.delete(e),v===e&&(v=null))})}function yt(t){return t?!!(t.closest(`.${d}`)||t.closest(w)||t.closest(F)):!1}function kt(){const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const e=t.getRangeAt(0).startContainer;return!!it(e)?.closest(w)}function C(t,e,o){const a=xt(t);Array.from(a.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(n=>{n.classList.toggle("active",o),n.setAttribute("aria-pressed",o?"true":"false"),n.setAttribute("data-active",o?"true":"false")})}function st(t,e,o){e!==null?t.setAttribute("contenteditable",e):t.setAttribute("contenteditable","true"),o!==null?t.setAttribute("data-readonly",o):t.removeAttribute("data-readonly")}function X(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function J(t,e){if(e===t.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",t,e,t.innerHTML)}catch{}}function Q(){return rt+=1,`approval-comment-${Date.now().toString(36)}-${rt.toString(36)}`}function At(){return at+=1,`approval-signoff-${Date.now().toString(36)}-${at.toString(36)}`}function ct(t){return{status:t.status,locked:t.locked,comments:t.comments.map(e=>({...e})),signoffs:t.signoffs.map(e=>({...e})),updatedAt:t.updatedAt}}function St(t,e){const o=bt[t];return e.labels[o]||t}function pt(t,e,o){const a=e.locked,r=e.status==="approved"&&o.lockOnApproval;if(t.setAttribute("data-approval-status",e.status),t.setAttribute("data-approval-locked",r?"true":"false"),t.classList.toggle("rte-approval-locked-editor",r),C(t,"toggleApprovalWorkflowPanel",tt(t)),C(t,"requestApprovalReview",e.status==="review"),C(t,"approveDocument",e.status==="approved"),C(t,"reopenDraft",e.status==="draft"),r){a||(e.preApprovalContentEditable=t.getAttribute("contenteditable"),e.preApprovalReadonly=t.getAttribute("data-readonly")),t.setAttribute("contenteditable","false"),t.setAttribute("data-readonly","true"),e.locked=!0;return}e.locked=!1,st(t,e.preApprovalContentEditable??e.originalContentEditable,e.preApprovalReadonly??e.originalReadonly),e.preApprovalContentEditable=null,e.preApprovalReadonly=null}function f(t,e){let o=I.get(t);return o||(o={status:e.defaultStatus,locked:!1,comments:[],signoffs:[],updatedAt:new Date().toISOString(),originalContentEditable:t.getAttribute("contenteditable"),originalReadonly:t.getAttribute("data-readonly"),preApprovalContentEditable:null,preApprovalReadonly:null},I.set(t,o),H.add(t),pt(t,o,e),o)}function j(t,e){return t.length<=e?t:t.slice(t.length-e)}function M(t,e){const o=t.querySelector(".rte-approval-live");o&&(o.textContent=e)}function Et(t,e){const o=ct(e);t.__approvalWorkflowState=o,t.dispatchEvent(new CustomEvent("editora:approval-state-changed",{bubbles:!0,detail:{state:o}}))}function P(t){const e=y.get(t);if(!e)return;const o=s.get(t)||R;if(!o)return;const a=f(t,o),r=e.querySelector(".rte-approval-summary"),n=e.querySelector('[data-action="request-review"]'),l=e.querySelector('[data-action="approve"]'),c=e.querySelector('[data-action="reopen-draft"]'),u=e.querySelector(".rte-approval-comments-list"),m=e.querySelector(".rte-approval-signoffs-list");if(r){const i=St(a.status,o);r.textContent=`${o.labels.summaryPrefix}: ${i} | Comments: ${a.comments.length} | Sign-offs: ${a.signoffs.length}${a.locked?` | ${o.labels.lockedSuffix}`:""}`}n&&(n.disabled=a.status!=="draft"),l&&(l.disabled=a.status==="approved"),c&&(c.disabled=a.status==="draft"),u&&(a.comments.length===0?u.innerHTML=`<li class="rte-approval-empty">${p(o.labels.noCommentsText)}</li>`:u.innerHTML=a.comments.slice().reverse().map(i=>`
|
|
2
2
|
<li class="rte-approval-item rte-approval-item-${i.kind}" role="listitem">
|
|
3
3
|
<div class="rte-approval-item-head">
|
|
4
4
|
<span class="rte-approval-item-author">${p(i.author)}</span>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
</div>
|
|
15
15
|
<p class="rte-approval-item-message">${p(i.comment||"Approved")}</p>
|
|
16
16
|
</li>
|
|
17
|
-
`).join(""))}function G(t,e,o){e.updatedAt=new Date().toISOString(),pt(t,e,o),P(t),
|
|
17
|
+
`).join(""))}function G(t,e,o){e.updatedAt=new Date().toISOString(),pt(t,e,o),P(t),Et(t,e)}function nt(t,e,o,a){t.comments.push({id:Q(),author:o||e.defaultActor,message:a,kind:"system",createdAt:new Date().toISOString()}),t.comments=j(t.comments,e.maxHistoryEntries)}function $(t,e,o,a){const r=f(t,o);if(r.status===e)return!1;const n=t.innerHTML;return r.status=e,e==="review"?nt(r,o,a,"Review requested."):e==="draft"&&nt(r,o,a,"Returned to draft."),G(t,r,o),X(t),J(t,n),!0}function dt(t,e,o,a){const r=a.normalizeText(e);if(!r)return!1;const n=a.normalizeText(o)||a.defaultActor,l=f(t,a),c=t.innerHTML;return l.comments.push({id:Q(),author:n,message:r,kind:"comment",createdAt:new Date().toISOString()}),l.comments=j(l.comments,a.maxHistoryEntries),G(t,l,a),X(t),J(t,c),!0}function Z(t,e,o,a){const r=e.normalizeText(o)||e.defaultActor,n=e.normalizeText(a);if(e.requireCommentOnApprove&&!n)return!1;const l=f(t,e),c=t.innerHTML;return l.status="approved",l.signoffs.push({id:At(),author:r,comment:n||void 0,createdAt:new Date().toISOString()}),l.signoffs=j(l.signoffs,e.maxHistoryEntries),n&&(l.comments.push({id:Q(),author:r,message:n,kind:"system",createdAt:new Date().toISOString()}),l.comments=j(l.comments,e.maxHistoryEntries)),G(t,l,e),X(t),J(t,c),!0}function N(t,e){return t.querySelector(`[data-field="${e}"]`)}function $t(t){const e=N(t,"actor")?.value||"",o=N(t,"comment")?.value||"";return{actor:e,comment:o}}function U(t,e){if(!e.classList.contains("show"))return;const a=Y(t).getBoundingClientRect(),r=Math.min(window.innerWidth-20,420),n=Math.max(10,window.innerWidth-r-10),l=Math.min(Math.max(10,a.right-r),n),c=Math.max(10,Math.min(window.innerHeight-10-280,a.top+12));e.style.width=`${r}px`,e.style.left=`${l}px`,e.style.top=`${c}px`,e.style.maxHeight=`${Math.max(280,window.innerHeight-24)}px`}function Ct(t){const e=y.get(t);if(e)return e;const o=s.get(t)||R||z(),a=`rte-approval-panel-${gt++}`,r=document.createElement("section");return r.className=d,r.id=a,r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false"),r.setAttribute("aria-label",o.labels.panelAriaLabel),r.setAttribute("tabindex","-1"),r.innerHTML=`
|
|
18
18
|
<header class="rte-approval-header">
|
|
19
19
|
<h2 class="rte-approval-title">${p(o.labels.panelTitle)}</h2>
|
|
20
20
|
<button type="button" class="rte-approval-icon-btn" data-action="close" aria-label="${p(o.labels.closeText)}">✕</button>
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
<p class="rte-approval-shortcut">${p(o.labels.shortcutText)}</p>
|
|
54
54
|
<span class="rte-approval-live" aria-live="polite"></span>
|
|
55
55
|
</div>
|
|
56
|
-
`,r.addEventListener("click",n=>{const l=n.target;if(!l)return;const c=l.closest("[data-action]");if(!c)return;const u=c.getAttribute("data-action")||"",m=s.get(t)||R||o;if(s.set(t,m),f(t,m),u==="close"){q(t,!0);return}const i
|
|
56
|
+
`,r.addEventListener("click",n=>{const l=n.target;if(!l)return;const c=l.closest("[data-action]");if(!c)return;const u=c.getAttribute("data-action")||"",m=s.get(t)||R||o;if(s.set(t,m),f(t,m),u==="close"){q(t,!0);return}const i=$t(r);if(u==="request-review"){$(t,"review",m,i.actor||m.defaultActor)&&M(r,"Status changed to review.");return}if(u==="reopen-draft"){$(t,"draft",m,i.actor||m.defaultActor)&&M(r,"Status changed to draft.");return}if(u==="approve"){const b=Z(t,m,i.actor,i.comment);if(!b&&m.requireCommentOnApprove){M(r,m.labels.approveCommentRequiredText);return}if(b){const E=N(r,"comment");E&&(E.value=""),M(r,"Document approved and signed off.")}return}if(u==="add-comment"){if(!dt(t,i.comment,i.actor,m))return;const E=N(r,"comment");E&&(E.value=""),M(r,"Comment added.");return}}),r.addEventListener("keydown",n=>{n.key==="Escape"&&(n.preventDefault(),q(t,!0))}),B(r,t),document.body.appendChild(r),y.set(t,r),O.set(t,!1),P(t),r}function tt(t){return O.get(t)===!0}function A(t){D();const e=Ct(t);y.forEach((o,a)=>{a!==t&&q(a,!1)}),e.classList.add("show"),O.set(t,!0),C(t,"toggleApprovalWorkflowPanel",!0),B(e,t),U(t,e),P(t),ft.focusPanel(e)}function q(t,e=!1){const o=y.get(t);o&&(o.classList.remove("show"),O.set(t,!1),C(t,"toggleApprovalWorkflowPanel",!1),e&&t.focus({preventScroll:!0}))}function ut(t,e){const o=tt(t);return(typeof e=="boolean"?e:!o)?A(t):q(t),!0}function V(t){return typeof t.key=="string"?t.key.toLowerCase():""}function Tt(t){const e=V(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="a"}function Lt(t){const e=V(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="r"}function Rt(t){const e=V(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="p"}function Mt(t){const e=V(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="d"}function Dt(t){R=t,T||(T=e=>{D();const a=e.target?.closest(w);if(!a)return;v=a;const r=s.get(a)||t;s.set(a,r),f(a,r);const n=y.get(a);n&&(B(n,a),U(a,n))},document.addEventListener("focusin",T,!0)),L||(L=e=>{if(e.defaultPrevented)return;const o=Tt(e),a=Lt(e),r=Rt(e),n=Mt(e),l=e.key==="Escape";if(!l&&!o&&!a&&!r&&!n)return;D();const c=e.target,u=!!c?.closest(`.${d} input, .${d} textarea, .${d} select`);if(!yt(c)&&!kt())return;const i=x(void 0,!1);if(!i)return;const b=s.get(i)||R||t;s.set(i,b);const E=f(i,b);if(v=i,l&&tt(i)){e.preventDefault(),q(i,!0);return}if(!u){if(o){e.preventDefault(),e.stopPropagation(),ut(i);return}if(a){e.preventDefault(),e.stopPropagation(),$(i,"review",b,b.defaultActor)&&A(i);return}if(r){e.preventDefault(),e.stopPropagation(),Z(i,b,b.defaultActor,"Approved via keyboard shortcut.")&&A(i);return}n&&(e.preventDefault(),e.stopPropagation(),E.status!=="draft"&&$(i,"draft",b,b.defaultActor)&&A(i))}},document.addEventListener("keydown",L,!0)),S||(S=()=>{D(),y.forEach((e,o)=>{!o.isConnected||!e.isConnected||(B(e,o),U(o,e))})},window.addEventListener("scroll",S,!0),window.addEventListener("resize",S))}function Ht(t){const e=I.get(t);e&&(t.classList.remove("rte-approval-locked-editor"),t.removeAttribute("data-approval-status"),t.removeAttribute("data-approval-locked"),st(t,e.preApprovalContentEditable??e.originalContentEditable,e.preApprovalReadonly??e.originalReadonly))}function Pt(){T&&(document.removeEventListener("focusin",T,!0),T=null),L&&(document.removeEventListener("keydown",L,!0),L=null),S&&(window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),S=null),y.forEach(t=>t.remove()),y.clear(),H.forEach(t=>Ht(t)),H.clear(),R=null,v=null}function qt(){if(typeof document>"u"||document.getElementById(ot))return;const t=document.createElement("style");t.id=ot,t.textContent=`
|
|
57
57
|
.rte-toolbar-group-items.${h},
|
|
58
58
|
.editora-toolbar-group-items.${h},
|
|
59
59
|
.rte-toolbar-group-items.${k},
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
|
|
388
388
|
.rte-approval-item-time {
|
|
389
389
|
font-size: 11px;
|
|
390
|
-
color: #
|
|
390
|
+
color: #475569;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
.${d}.rte-approval-theme-dark .rte-approval-item-time {
|
|
@@ -406,7 +406,7 @@
|
|
|
406
406
|
border-radius: 8px;
|
|
407
407
|
padding: 8px;
|
|
408
408
|
font-size: 12px;
|
|
409
|
-
color: #
|
|
409
|
+
color: #475569;
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
.${d}.rte-approval-theme-dark .rte-approval-empty {
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
.rte-approval-shortcut {
|
|
418
418
|
margin: 0;
|
|
419
419
|
font-size: 11px;
|
|
420
|
-
color: #
|
|
420
|
+
color: #475569;
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
.${d}.rte-approval-theme-dark .rte-approval-shortcut {
|
|
@@ -444,4 +444,4 @@
|
|
|
444
444
|
max-height: calc(100vh - 20px);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
`,document.head.appendChild(t)}const
|
|
447
|
+
`,document.head.appendChild(t)}const Ot=(t={})=>{const e=z(t);return qt(),{name:"approvalWorkflow",toolbar:[{id:"approvalWorkflowGroup",label:"Approval",type:"group",command:"approvalWorkflow",items:[{id:"approvalWorkflow",label:"Approval Workflow",command:"toggleApprovalWorkflowPanel",shortcut:"Mod-Alt-Shift-a",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="16" height="14" rx="2.5" stroke="currentColor" stroke-width="1.7"/><path d="M8 10h8M8 14h5" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="m16.5 16 1.8 1.8 3.2-3.2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"approvalRequestReview",label:"Request Review",command:"requestApprovalReview",shortcut:"Mod-Alt-Shift-r",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><circle cx="11" cy="11" r="6.5" stroke="currentColor" stroke-width="1.7"/><path d="M11 8v3l2 2" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17.5 17.5 20 20" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'},{id:"approvalApprove",label:"Approve",command:"approveDocument",shortcut:"Mod-Alt-Shift-p",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 12.5 9.5 17 19 7.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><rect x="3.8" y="3.8" width="16.4" height="16.4" rx="3" stroke="currentColor" stroke-width="1.4"/></svg>'},{id:"approvalReopen",label:"Reopen Draft",command:"reopenDraft",shortcut:"Mod-Alt-Shift-d",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8 8H4v4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M5 12a7 7 0 1 0 2-4.95" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'}]}],commands:{approvalWorkflow:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;return s.set(r,n),f(r,n),v=r,A(r),P(r),!0},toggleApprovalWorkflowPanel:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;return s.set(r,n),f(r,n),v=r,ut(r,typeof o=="boolean"?o:void 0)},requestApprovalReview:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;s.set(r,n),f(r,n);const l=$(r,"review",n,n.defaultActor);return A(r),l},approveDocument:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;s.set(r,n),f(r,n);const l=typeof o=="object"&&o?String(o.author||""):n.defaultActor,c=typeof o=="object"&&o?String(o.comment||""):typeof o=="string"?o:"",u=Z(r,n,l,c);return u&&A(r),u},reopenDraft:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;s.set(r,n),f(r,n);const l=$(r,"draft",n,n.defaultActor);return l&&A(r),l},addApprovalComment:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;s.set(r,n),f(r,n);const l=typeof o=="object"&&o?String(o.author||""):n.defaultActor,c=typeof o=="object"&&o?String(o.message||""):typeof o=="string"?o:"",u=dt(r,c,l,n);return u&&A(r),u},setApprovalStatus:(o,a)=>{const r=x(a);if(!r||!o)return!1;const n=lt(o),l=s.get(r)||e;s.set(r,l),f(r,l);const c=$(r,n,l,l.defaultActor);return c&&A(r),c},setApprovalWorkflowOptions:(o,a)=>{const r=x(a);if(!r||!o||typeof o!="object")return!1;const n=s.get(r)||e,l=z({...n,...o,labels:{...n.labels,...o.labels||{}},normalizeText:o.normalizeText||n.normalizeText});s.set(r,l);const c=f(r,l);return G(r,c,l),!0},getApprovalWorkflowState:(o,a)=>{const r=x(a);if(!r)return!1;const n=s.get(r)||e;s.set(r,n);const l=f(r,n),c=ct(l);if(typeof o=="function")try{o(c)}catch{}return r.__approvalWorkflowState=c,r.dispatchEvent(new CustomEvent("editora:approval-state",{bubbles:!0,detail:{state:c}})),!0}},keymap:{"Mod-Alt-Shift-a":"toggleApprovalWorkflowPanel","Mod-Alt-Shift-A":"toggleApprovalWorkflowPanel","Mod-Alt-Shift-r":"requestApprovalReview","Mod-Alt-Shift-R":"requestApprovalReview","Mod-Alt-Shift-p":"approveDocument","Mod-Alt-Shift-P":"approveDocument","Mod-Alt-Shift-d":"reopenDraft","Mod-Alt-Shift-D":"reopenDraft"},init:function(a){_+=1;const r=this&&typeof this.__pluginConfig=="object"?z({...e,...this.__pluginConfig}):e;Dt(r);const n=x(a?.editorElement?{editorElement:a.editorElement}:void 0,!1);n&&(s.set(n,r),f(n,r),v=n,P(n))},destroy:()=>{_=Math.max(0,_-1),!(_>0)&&Pt()}}};exports.ApprovalWorkflowPlugin=Ot;
|