@editora/plugins 1.0.12 → 1.0.13

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 (51) hide show
  1. package/dist/approval-workflow.cjs.js +14 -14
  2. package/dist/approval-workflow.esm.js +265 -262
  3. package/dist/blockquote.cjs.js +1 -1
  4. package/dist/blockquote.esm.js +177 -15
  5. package/dist/blocks-library.cjs.js +6 -6
  6. package/dist/blocks-library.esm.js +95 -92
  7. package/dist/bold.cjs.js +1 -1
  8. package/dist/bold.esm.js +10 -6
  9. package/dist/capitalization.cjs.js +1 -1
  10. package/dist/capitalization.esm.js +124 -44
  11. package/dist/checklist.cjs.js +1 -1
  12. package/dist/checklist.esm.js +251 -191
  13. package/dist/citations.cjs.js +4 -4
  14. package/dist/citations.esm.js +131 -128
  15. package/dist/clear-formatting.cjs.js +1 -1
  16. package/dist/clear-formatting.esm.js +68 -36
  17. package/dist/content-rules.cjs.js +5 -5
  18. package/dist/content-rules.esm.js +104 -101
  19. package/dist/data-binding.cjs.js +3 -3
  20. package/dist/data-binding.esm.js +51 -48
  21. package/dist/direction.cjs.js +1 -1
  22. package/dist/direction.esm.js +97 -74
  23. package/dist/doc-schema.cjs.js +4 -4
  24. package/dist/doc-schema.esm.js +104 -101
  25. package/dist/embed-iframe.cjs.js +21 -4
  26. package/dist/embed-iframe.esm.js +279 -116
  27. package/dist/heading.cjs.js +1 -1
  28. package/dist/heading.esm.js +239 -56
  29. package/dist/history.cjs.js +1 -1
  30. package/dist/history.esm.js +74 -89
  31. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  32. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  33. package/dist/italic.cjs.js +1 -1
  34. package/dist/italic.esm.js +12 -8
  35. package/dist/math.cjs.js +27 -21
  36. package/dist/math.esm.js +218 -146
  37. package/dist/merge-tag.cjs.js +8 -2
  38. package/dist/merge-tag.esm.js +130 -111
  39. package/dist/pii-redaction.cjs.js +6 -6
  40. package/dist/pii-redaction.esm.js +169 -166
  41. package/dist/smart-paste.cjs.js +5 -5
  42. package/dist/smart-paste.esm.js +120 -117
  43. package/dist/special-characters.cjs.js +6 -10
  44. package/dist/special-characters.esm.js +97 -75
  45. package/dist/strikethrough.cjs.js +1 -1
  46. package/dist/strikethrough.esm.js +11 -25
  47. package/dist/translation-workflow.cjs.js +7 -7
  48. package/dist/translation-workflow.esm.js +103 -100
  49. package/dist/underline.cjs.js +1 -1
  50. package/dist/underline.esm.js +7 -3
  51. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- const w = ".rte-content, .editora-content", F = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ee = "__editoraCommandEditorRoot", te = "rte-approval-workflow-styles", d = "rte-approval-panel", h = "approval", y = "approvalWorkflow", g = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', ue = {
1
+ 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)', ft = {
2
2
  panelTitle: "Approval Workflow",
3
3
  panelAriaLabel: "Approval workflow panel",
4
4
  statusLabel: "Status",
@@ -22,98 +22,98 @@ const w = ".rte-content, .editora-content", F = "[data-editora-editor], .rte-edi
22
22
  lockedSuffix: "Locked",
23
23
  shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+A/R/P/D",
24
24
  approveCommentRequiredText: "Approval comment is required."
25
- }, fe = {
25
+ }, mt = {
26
26
  draft: "statusDraftText",
27
27
  review: "statusReviewText",
28
28
  approved: "statusApprovedText"
29
- }, s = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new Set();
30
- let _ = 0, me = 0, oe = 0, re = 0, R = null, v = null, T = null, L = null, S = null;
31
- function p(e) {
32
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
29
+ }, s = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new Set();
30
+ let _ = 0, bt = 0, rt = 0, at = 0, R = null, v = null, T = null, L = null, S = null;
31
+ function p(t) {
32
+ return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
33
33
  }
34
- function be(e) {
35
- return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
34
+ function gt(t) {
35
+ return t.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
36
36
  }
37
- function ne(e) {
38
- return e === "review" || e === "approved" ? e : "draft";
37
+ function lt(t) {
38
+ return t === "review" || t === "approved" ? t : "draft";
39
39
  }
40
- function z(e = {}) {
40
+ function z(t = {}) {
41
41
  return {
42
- defaultStatus: ne(e.defaultStatus),
43
- lockOnApproval: e.lockOnApproval !== !1,
44
- maxHistoryEntries: Math.max(10, Math.min(500, Number(e.maxHistoryEntries ?? 120))),
45
- requireCommentOnApprove: !!e.requireCommentOnApprove,
46
- defaultActor: (e.defaultActor || "system").trim() || "system",
42
+ defaultStatus: lt(t.defaultStatus),
43
+ lockOnApproval: t.lockOnApproval !== !1,
44
+ maxHistoryEntries: Math.max(10, Math.min(500, Number(t.maxHistoryEntries ?? 120))),
45
+ requireCommentOnApprove: !!t.requireCommentOnApprove,
46
+ defaultActor: (t.defaultActor || "system").trim() || "system",
47
47
  labels: {
48
- ...ue,
49
- ...e.labels || {}
48
+ ...ft,
49
+ ...t.labels || {}
50
50
  },
51
- normalizeText: e.normalizeText || be
51
+ normalizeText: t.normalizeText || gt
52
52
  };
53
53
  }
54
- function U(e) {
55
- return e.closest(F) || e;
54
+ function Y(t) {
55
+ return t.closest(F) || t;
56
56
  }
57
- function B(e) {
58
- if (!e) return null;
59
- if (e.matches(w)) return e;
60
- const t = e.querySelector(w);
61
- return t instanceof HTMLElement ? t : null;
57
+ function K(t) {
58
+ if (!t) return null;
59
+ if (t.matches(w)) return t;
60
+ const e = t.querySelector(w);
61
+ return e instanceof HTMLElement ? e : null;
62
62
  }
63
- function ge() {
63
+ function vt() {
64
64
  if (typeof window > "u") return null;
65
- const e = window[ee];
66
- if (!(e instanceof HTMLElement)) return null;
67
- window[ee] = null;
68
- const t = B(e);
69
- if (t) return t;
70
- const o = e.closest(F);
65
+ const t = window[et];
66
+ if (!(t instanceof HTMLElement)) return null;
67
+ window[et] = null;
68
+ const e = K(t);
69
+ if (e) return e;
70
+ const o = t.closest(F);
71
71
  if (o) {
72
- const n = B(o);
72
+ const n = K(o);
73
73
  if (n) return n;
74
74
  }
75
75
  return null;
76
76
  }
77
- function ve(e) {
78
- const t = e.closest("[data-editora-editor]");
79
- if (t && B(t) === e)
80
- return t;
81
- let o = e;
77
+ function ht(t) {
78
+ const e = t.closest("[data-editora-editor]");
79
+ if (e && K(e) === t)
80
+ return e;
81
+ let o = t;
82
82
  for (; o; ) {
83
- if (o.matches(F) && (o === e || B(o) === e))
83
+ if (o.matches(F) && (o === t || K(o) === t))
84
84
  return o;
85
85
  o = o.parentElement;
86
86
  }
87
- return U(e);
87
+ return Y(t);
88
88
  }
89
- function W(e) {
90
- return e ? (e.getAttribute("data-theme") || e.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : e.classList.contains("dark") || e.classList.contains("editora-theme-dark") || e.classList.contains("rte-theme-dark") : !1;
89
+ function W(t) {
90
+ 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;
91
91
  }
92
- function he(e) {
93
- const t = U(e);
94
- if (W(t)) return !0;
95
- const o = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
92
+ function xt(t) {
93
+ const e = Y(t);
94
+ if (W(e)) return !0;
95
+ const o = e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
96
96
  return W(o) ? !0 : W(document.documentElement) || W(document.body);
97
97
  }
98
- function K(e, t) {
99
- e.classList.remove("rte-approval-theme-dark"), he(t) && e.classList.add("rte-approval-theme-dark");
98
+ function B(t, e) {
99
+ t.classList.remove("rte-approval-theme-dark"), xt(e) && t.classList.add("rte-approval-theme-dark");
100
100
  }
101
- function le(e) {
102
- return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
101
+ function it(t) {
102
+ return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
103
103
  }
104
- function x(e, t = !0) {
105
- if (D(), e?.contentElement instanceof HTMLElement) return e.contentElement;
106
- if (e?.editorElement instanceof HTMLElement) {
107
- const a = e.editorElement;
104
+ function x(t, e = !0) {
105
+ if (D(), t?.contentElement instanceof HTMLElement) return t.contentElement;
106
+ if (t?.editorElement instanceof HTMLElement) {
107
+ const a = t.editorElement;
108
108
  if (a.matches(w)) return a;
109
109
  const l = a.querySelector(w);
110
110
  if (l instanceof HTMLElement) return l;
111
111
  }
112
- const o = ge();
112
+ const o = vt();
113
113
  if (o) return o;
114
114
  const n = window.getSelection();
115
115
  if (n && n.rangeCount > 0) {
116
- const l = le(n.getRangeAt(0).startContainer)?.closest(w);
116
+ const l = it(n.getRangeAt(0).startContainer)?.closest(w);
117
117
  if (l) return l;
118
118
  }
119
119
  const r = document.activeElement;
@@ -122,101 +122,101 @@ function x(e, t = !0) {
122
122
  const a = r.closest(w);
123
123
  if (a) return a;
124
124
  }
125
- return v && v.isConnected ? v : (v && !v.isConnected && (v = null), t ? document.querySelector(w) : null);
125
+ return v && v.isConnected ? v : (v && !v.isConnected && (v = null), e ? document.querySelector(w) : null);
126
126
  }
127
127
  function D() {
128
- Array.from(H).forEach((t) => {
129
- t.isConnected || (k.get(t)?.remove(), k.delete(t), O.delete(t), s.delete(t), I.delete(t), H.delete(t), v === t && (v = null));
128
+ Array.from(H).forEach((e) => {
129
+ 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));
130
130
  });
131
131
  }
132
- function xe(e) {
133
- return e ? !!(e.closest(`.${d}`) || e.closest(w) || e.closest(F)) : !1;
132
+ function wt(t) {
133
+ return t ? !!(t.closest(`.${d}`) || t.closest(w) || t.closest(F)) : !1;
134
134
  }
135
- function we() {
136
- const e = window.getSelection();
137
- if (!e || e.rangeCount === 0) return !1;
138
- const t = e.getRangeAt(0).startContainer;
139
- return !!le(t)?.closest(w);
135
+ function yt() {
136
+ const t = window.getSelection();
137
+ if (!t || t.rangeCount === 0) return !1;
138
+ const e = t.getRangeAt(0).startContainer;
139
+ return !!it(e)?.closest(w);
140
140
  }
141
- function C(e, t, o) {
142
- const n = ve(e);
141
+ function C(t, e, o) {
142
+ const n = ht(t);
143
143
  Array.from(
144
144
  n.querySelectorAll(
145
- `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
145
+ `.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`
146
146
  )
147
147
  ).forEach((a) => {
148
148
  a.classList.toggle("active", o), a.setAttribute("aria-pressed", o ? "true" : "false"), a.setAttribute("data-active", o ? "true" : "false");
149
149
  });
150
150
  }
151
- function ie(e, t, o) {
152
- t !== null ? e.setAttribute("contenteditable", t) : e.setAttribute("contenteditable", "true"), o !== null ? e.setAttribute("data-readonly", o) : e.removeAttribute("data-readonly");
151
+ function st(t, e, o) {
152
+ e !== null ? t.setAttribute("contenteditable", e) : t.setAttribute("contenteditable", "true"), o !== null ? t.setAttribute("data-readonly", o) : t.removeAttribute("data-readonly");
153
153
  }
154
- function Y(e) {
155
- e.dispatchEvent(new Event("input", { bubbles: !0 }));
154
+ function X(t) {
155
+ t.dispatchEvent(new Event("input", { bubbles: !0 }));
156
156
  }
157
- function X(e, t) {
158
- if (t === e.innerHTML) return;
157
+ function J(t, e) {
158
+ if (e === t.innerHTML) return;
159
159
  const o = window.execEditorCommand || window.executeEditorCommand;
160
160
  if (typeof o == "function")
161
161
  try {
162
- o("recordDomTransaction", e, t, e.innerHTML);
162
+ o("recordDomTransaction", t, e, t.innerHTML);
163
163
  } catch {
164
164
  }
165
165
  }
166
- function J() {
167
- return oe += 1, `approval-comment-${Date.now().toString(36)}-${oe.toString(36)}`;
166
+ function Q() {
167
+ return rt += 1, `approval-comment-${Date.now().toString(36)}-${rt.toString(36)}`;
168
168
  }
169
- function ke() {
170
- return re += 1, `approval-signoff-${Date.now().toString(36)}-${re.toString(36)}`;
169
+ function kt() {
170
+ return at += 1, `approval-signoff-${Date.now().toString(36)}-${at.toString(36)}`;
171
171
  }
172
- function se(e) {
172
+ function ct(t) {
173
173
  return {
174
- status: e.status,
175
- locked: e.locked,
176
- comments: e.comments.map((t) => ({ ...t })),
177
- signoffs: e.signoffs.map((t) => ({ ...t })),
178
- updatedAt: e.updatedAt
174
+ status: t.status,
175
+ locked: t.locked,
176
+ comments: t.comments.map((e) => ({ ...e })),
177
+ signoffs: t.signoffs.map((e) => ({ ...e })),
178
+ updatedAt: t.updatedAt
179
179
  };
180
180
  }
181
- function ye(e, t) {
182
- const o = fe[e];
183
- return t.labels[o] || e;
181
+ function At(t, e) {
182
+ const o = mt[t];
183
+ return e.labels[o] || t;
184
184
  }
185
- function ce(e, t, o) {
186
- if (e.setAttribute("data-approval-status", t.status), e.setAttribute("data-approval-locked", t.locked ? "true" : "false"), e.classList.toggle("rte-approval-locked-editor", t.locked), C(e, "toggleApprovalWorkflowPanel", Z(e)), C(e, "requestApprovalReview", t.status === "review"), C(e, "approveDocument", t.status === "approved"), C(e, "reopenDraft", t.status === "draft"), t.status === "approved" && o.lockOnApproval) {
187
- t.locked || (t.preApprovalContentEditable = e.getAttribute("contenteditable"), t.preApprovalReadonly = e.getAttribute("data-readonly")), e.setAttribute("contenteditable", "false"), e.setAttribute("data-readonly", "true"), t.locked = !0;
185
+ function pt(t, e, o) {
186
+ if (t.setAttribute("data-approval-status", e.status), t.setAttribute("data-approval-locked", e.locked ? "true" : "false"), t.classList.toggle("rte-approval-locked-editor", e.locked), C(t, "toggleApprovalWorkflowPanel", tt(t)), C(t, "requestApprovalReview", e.status === "review"), C(t, "approveDocument", e.status === "approved"), C(t, "reopenDraft", e.status === "draft"), e.status === "approved" && o.lockOnApproval) {
187
+ e.locked || (e.preApprovalContentEditable = t.getAttribute("contenteditable"), e.preApprovalReadonly = t.getAttribute("data-readonly")), t.setAttribute("contenteditable", "false"), t.setAttribute("data-readonly", "true"), e.locked = !0;
188
188
  return;
189
189
  }
190
- t.locked = !1, ie(
191
- e,
192
- t.preApprovalContentEditable ?? t.originalContentEditable,
193
- t.preApprovalReadonly ?? t.originalReadonly
194
- ), t.preApprovalContentEditable = null, t.preApprovalReadonly = null;
190
+ e.locked = !1, st(
191
+ t,
192
+ e.preApprovalContentEditable ?? e.originalContentEditable,
193
+ e.preApprovalReadonly ?? e.originalReadonly
194
+ ), e.preApprovalContentEditable = null, e.preApprovalReadonly = null;
195
195
  }
196
- function f(e, t) {
197
- let o = I.get(e);
196
+ function f(t, e) {
197
+ let o = I.get(t);
198
198
  return o || (o = {
199
- status: t.defaultStatus,
199
+ status: e.defaultStatus,
200
200
  locked: !1,
201
201
  comments: [],
202
202
  signoffs: [],
203
203
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
204
- originalContentEditable: e.getAttribute("contenteditable"),
205
- originalReadonly: e.getAttribute("data-readonly"),
204
+ originalContentEditable: t.getAttribute("contenteditable"),
205
+ originalReadonly: t.getAttribute("data-readonly"),
206
206
  preApprovalContentEditable: null,
207
207
  preApprovalReadonly: null
208
- }, I.set(e, o), H.add(e), ce(e, o, t), o);
208
+ }, I.set(t, o), H.add(t), pt(t, o, e), o);
209
209
  }
210
- function j(e, t) {
211
- return e.length <= t ? e : e.slice(e.length - t);
210
+ function j(t, e) {
211
+ return t.length <= e ? t : t.slice(t.length - e);
212
212
  }
213
- function M(e, t) {
214
- const o = e.querySelector(".rte-approval-live");
215
- o && (o.textContent = t);
213
+ function M(t, e) {
214
+ const o = t.querySelector(".rte-approval-live");
215
+ o && (o.textContent = e);
216
216
  }
217
- function Ae(e, t) {
218
- const o = se(t);
219
- e.__approvalWorkflowState = o, e.dispatchEvent(
217
+ function St(t, e) {
218
+ const o = ct(e);
219
+ t.__approvalWorkflowState = o, t.dispatchEvent(
220
220
  new CustomEvent("editora:approval-state-changed", {
221
221
  bubbles: !0,
222
222
  detail: {
@@ -225,14 +225,14 @@ function Ae(e, t) {
225
225
  })
226
226
  );
227
227
  }
228
- function q(e) {
229
- const t = k.get(e);
230
- if (!t) return;
231
- const o = s.get(e) || R;
228
+ function q(t) {
229
+ const e = y.get(t);
230
+ if (!e) return;
231
+ const o = s.get(t) || R;
232
232
  if (!o) return;
233
- const n = f(e, o), r = t.querySelector(".rte-approval-summary"), a = t.querySelector('[data-action="request-review"]'), l = t.querySelector('[data-action="approve"]'), c = t.querySelector('[data-action="reopen-draft"]'), u = t.querySelector(".rte-approval-comments-list"), m = t.querySelector(".rte-approval-signoffs-list");
233
+ const n = f(t, o), r = e.querySelector(".rte-approval-summary"), a = 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");
234
234
  if (r) {
235
- const i = ye(n.status, o);
235
+ const i = At(n.status, o);
236
236
  r.textContent = `${o.labels.summaryPrefix}: ${i} | Comments: ${n.comments.length} | Sign-offs: ${n.signoffs.length}${n.locked ? ` | ${o.labels.lockedSuffix}` : ""}`;
237
237
  }
238
238
  a && (a.disabled = n.status !== "draft"), l && (l.disabled = n.status === "approved"), c && (c.disabled = n.status === "draft"), u && (n.comments.length === 0 ? u.innerHTML = `<li class="rte-approval-empty">${p(o.labels.noCommentsText)}</li>` : u.innerHTML = n.comments.slice().reverse().map(
@@ -261,69 +261,69 @@ function q(e) {
261
261
  `
262
262
  ).join(""));
263
263
  }
264
- function G(e, t, o) {
265
- t.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), ce(e, t, o), q(e), Ae(e, t);
264
+ function G(t, e, o) {
265
+ e.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), pt(t, e, o), q(t), St(t, e);
266
266
  }
267
- function ae(e, t, o, n) {
268
- e.comments.push({
269
- id: J(),
270
- author: o || t.defaultActor,
267
+ function nt(t, e, o, n) {
268
+ t.comments.push({
269
+ id: Q(),
270
+ author: o || e.defaultActor,
271
271
  message: n,
272
272
  kind: "system",
273
273
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
274
- }), e.comments = j(e.comments, t.maxHistoryEntries);
274
+ }), t.comments = j(t.comments, e.maxHistoryEntries);
275
275
  }
276
- function E(e, t, o, n) {
277
- const r = f(e, o);
278
- if (r.status === t) return !1;
279
- const a = e.innerHTML;
280
- return r.status = t, t === "review" ? ae(r, o, n, "Review requested.") : t === "draft" && ae(r, o, n, "Returned to draft."), G(e, r, o), Y(e), X(e, a), !0;
276
+ function $(t, e, o, n) {
277
+ const r = f(t, o);
278
+ if (r.status === e) return !1;
279
+ const a = t.innerHTML;
280
+ return r.status = e, e === "review" ? nt(r, o, n, "Review requested.") : e === "draft" && nt(r, o, n, "Returned to draft."), G(t, r, o), X(t), J(t, a), !0;
281
281
  }
282
- function pe(e, t, o, n) {
283
- const r = n.normalizeText(t);
282
+ function dt(t, e, o, n) {
283
+ const r = n.normalizeText(e);
284
284
  if (!r) return !1;
285
- const a = n.normalizeText(o) || n.defaultActor, l = f(e, n), c = e.innerHTML;
285
+ const a = n.normalizeText(o) || n.defaultActor, l = f(t, n), c = t.innerHTML;
286
286
  return l.comments.push({
287
- id: J(),
287
+ id: Q(),
288
288
  author: a,
289
289
  message: r,
290
290
  kind: "comment",
291
291
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
292
- }), l.comments = j(l.comments, n.maxHistoryEntries), G(e, l, n), Y(e), X(e, c), !0;
292
+ }), l.comments = j(l.comments, n.maxHistoryEntries), G(t, l, n), X(t), J(t, c), !0;
293
293
  }
294
- function Q(e, t, o, n) {
295
- const r = t.normalizeText(o) || t.defaultActor, a = t.normalizeText(n);
296
- if (t.requireCommentOnApprove && !a) return !1;
297
- const l = f(e, t), c = e.innerHTML;
294
+ function Z(t, e, o, n) {
295
+ const r = e.normalizeText(o) || e.defaultActor, a = e.normalizeText(n);
296
+ if (e.requireCommentOnApprove && !a) return !1;
297
+ const l = f(t, e), c = t.innerHTML;
298
298
  return l.status = "approved", l.signoffs.push({
299
- id: ke(),
299
+ id: kt(),
300
300
  author: r,
301
301
  comment: a || void 0,
302
302
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
303
- }), l.signoffs = j(l.signoffs, t.maxHistoryEntries), a && (l.comments.push({
304
- id: J(),
303
+ }), l.signoffs = j(l.signoffs, e.maxHistoryEntries), a && (l.comments.push({
304
+ id: Q(),
305
305
  author: r,
306
306
  message: a,
307
307
  kind: "system",
308
308
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
309
- }), l.comments = j(l.comments, t.maxHistoryEntries)), G(e, l, t), Y(e), X(e, c), !0;
309
+ }), l.comments = j(l.comments, e.maxHistoryEntries)), G(t, l, e), X(t), J(t, c), !0;
310
310
  }
311
- function N(e, t) {
312
- return e.querySelector(`[data-field="${t}"]`);
311
+ function N(t, e) {
312
+ return t.querySelector(`[data-field="${e}"]`);
313
313
  }
314
- function Se(e) {
315
- const t = N(e, "actor")?.value || "", o = N(e, "comment")?.value || "";
316
- return { actor: t, comment: o };
314
+ function Et(t) {
315
+ const e = N(t, "actor")?.value || "", o = N(t, "comment")?.value || "";
316
+ return { actor: e, comment: o };
317
317
  }
318
- function V(e, t) {
319
- if (!t.classList.contains("show")) return;
320
- const n = U(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 420), a = Math.max(10, window.innerWidth - r - 10), l = Math.min(Math.max(10, n.right - r), a), c = Math.max(10, Math.min(window.innerHeight - 10 - 280, n.top + 12));
321
- t.style.width = `${r}px`, t.style.left = `${l}px`, t.style.top = `${c}px`, t.style.maxHeight = `${Math.max(280, window.innerHeight - 24)}px`;
318
+ function U(t, e) {
319
+ if (!e.classList.contains("show")) return;
320
+ const n = Y(t).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 420), a = Math.max(10, window.innerWidth - r - 10), l = Math.min(Math.max(10, n.right - r), a), c = Math.max(10, Math.min(window.innerHeight - 10 - 280, n.top + 12));
321
+ 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`;
322
322
  }
323
- function $e(e) {
324
- const t = k.get(e);
325
- if (t) return t;
326
- const o = s.get(e) || R || z(), n = `rte-approval-panel-${me++}`, r = document.createElement("section");
323
+ function $t(t) {
324
+ const e = y.get(t);
325
+ if (e) return e;
326
+ const o = s.get(t) || R || z(), n = `rte-approval-panel-${bt++}`, r = document.createElement("section");
327
327
  return r.className = d, r.id = n, r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false"), r.setAttribute("aria-label", o.labels.panelAriaLabel), r.setAttribute("tabindex", "-1"), r.innerHTML = `
328
328
  <header class="rte-approval-header">
329
329
  <h2 class="rte-approval-title">${p(o.labels.panelTitle)}</h2>
@@ -382,144 +382,147 @@ function $e(e) {
382
382
  if (!l) return;
383
383
  const c = l.closest("[data-action]");
384
384
  if (!c) return;
385
- const u = c.getAttribute("data-action") || "", m = s.get(e) || R || o;
386
- if (s.set(e, m), f(e, m), u === "close") {
387
- P(e, !0);
385
+ const u = c.getAttribute("data-action") || "", m = s.get(t) || R || o;
386
+ if (s.set(t, m), f(t, m), u === "close") {
387
+ P(t, !0);
388
388
  return;
389
389
  }
390
- const i = Se(r);
390
+ const i = Et(r);
391
391
  if (u === "request-review") {
392
- E(e, "review", m, i.actor || m.defaultActor) && M(r, "Status changed to review.");
392
+ $(t, "review", m, i.actor || m.defaultActor) && M(r, "Status changed to review.");
393
393
  return;
394
394
  }
395
395
  if (u === "reopen-draft") {
396
- E(e, "draft", m, i.actor || m.defaultActor) && M(r, "Status changed to draft.");
396
+ $(t, "draft", m, i.actor || m.defaultActor) && M(r, "Status changed to draft.");
397
397
  return;
398
398
  }
399
399
  if (u === "approve") {
400
- const b = Q(e, m, i.actor, i.comment);
400
+ const b = Z(t, m, i.actor, i.comment);
401
401
  if (!b && m.requireCommentOnApprove) {
402
402
  M(r, m.labels.approveCommentRequiredText);
403
403
  return;
404
404
  }
405
405
  if (b) {
406
- const $ = N(r, "comment");
407
- $ && ($.value = ""), M(r, "Document approved and signed off.");
406
+ const E = N(r, "comment");
407
+ E && (E.value = ""), M(r, "Document approved and signed off.");
408
408
  }
409
409
  return;
410
410
  }
411
411
  if (u === "add-comment") {
412
- if (!pe(e, i.comment, i.actor, m)) return;
413
- const $ = N(r, "comment");
414
- $ && ($.value = ""), M(r, "Comment added.");
412
+ if (!dt(t, i.comment, i.actor, m)) return;
413
+ const E = N(r, "comment");
414
+ E && (E.value = ""), M(r, "Comment added.");
415
415
  return;
416
416
  }
417
417
  }), r.addEventListener("keydown", (a) => {
418
- a.key === "Escape" && (a.preventDefault(), P(e, !0));
419
- }), K(r, e), document.body.appendChild(r), k.set(e, r), O.set(e, !1), q(e), r;
418
+ a.key === "Escape" && (a.preventDefault(), P(t, !0));
419
+ }), B(r, t), document.body.appendChild(r), y.set(t, r), O.set(t, !1), q(t), r;
420
420
  }
421
- function Z(e) {
422
- return O.get(e) === !0;
421
+ function tt(t) {
422
+ return O.get(t) === !0;
423
423
  }
424
- function A(e) {
424
+ function A(t) {
425
425
  D();
426
- const t = $e(e);
427
- k.forEach((o, n) => {
428
- n !== e && P(n, !1);
429
- }), t.classList.add("show"), O.set(e, !0), C(e, "toggleApprovalWorkflowPanel", !0), K(t, e), V(e, t), q(e);
426
+ const e = $t(t);
427
+ y.forEach((o, n) => {
428
+ n !== t && P(n, !1);
429
+ }), e.classList.add("show"), O.set(t, !0), C(t, "toggleApprovalWorkflowPanel", !0), B(e, t), U(t, e), q(t);
430
430
  }
431
- function P(e, t = !1) {
432
- const o = k.get(e);
433
- o && (o.classList.remove("show"), O.set(e, !1), C(e, "toggleApprovalWorkflowPanel", !1), t && e.focus({ preventScroll: !0 }));
431
+ function P(t, e = !1) {
432
+ const o = y.get(t);
433
+ o && (o.classList.remove("show"), O.set(t, !1), C(t, "toggleApprovalWorkflowPanel", !1), e && t.focus({ preventScroll: !0 }));
434
434
  }
435
- function de(e, t) {
436
- const o = Z(e);
437
- return (typeof t == "boolean" ? t : !o) ? A(e) : P(e), !0;
435
+ function ut(t, e) {
436
+ const o = tt(t);
437
+ return (typeof e == "boolean" ? e : !o) ? A(t) : P(t), !0;
438
438
  }
439
- function Ee(e) {
440
- const t = e.key.toLowerCase();
441
- return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "a";
439
+ function V(t) {
440
+ return typeof t.key == "string" ? t.key.toLowerCase() : "";
442
441
  }
443
- function Ce(e) {
444
- const t = e.key.toLowerCase();
445
- return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
442
+ function Ct(t) {
443
+ const e = V(t);
444
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "a";
446
445
  }
447
- function Te(e) {
448
- const t = e.key.toLowerCase();
449
- return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "p";
446
+ function Tt(t) {
447
+ const e = V(t);
448
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "r";
450
449
  }
451
- function Le(e) {
452
- const t = e.key.toLowerCase();
453
- return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "d";
450
+ function Lt(t) {
451
+ const e = V(t);
452
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "p";
454
453
  }
455
- function Re(e) {
456
- R = e, T || (T = (t) => {
454
+ function Rt(t) {
455
+ const e = V(t);
456
+ return (t.metaKey || t.ctrlKey) && t.altKey && t.shiftKey && e === "d";
457
+ }
458
+ function Mt(t) {
459
+ R = t, T || (T = (e) => {
457
460
  D();
458
- const n = t.target?.closest(w);
461
+ const n = e.target?.closest(w);
459
462
  if (!n) return;
460
463
  v = n;
461
- const r = s.get(n) || e;
464
+ const r = s.get(n) || t;
462
465
  s.set(n, r), f(n, r);
463
- const a = k.get(n);
464
- a && (K(a, n), V(n, a));
465
- }, document.addEventListener("focusin", T, !0)), L || (L = (t) => {
466
- if (t.defaultPrevented) return;
467
- const o = Ee(t), n = Ce(t), r = Te(t), a = Le(t), l = t.key === "Escape";
466
+ const a = y.get(n);
467
+ a && (B(a, n), U(n, a));
468
+ }, document.addEventListener("focusin", T, !0)), L || (L = (e) => {
469
+ if (e.defaultPrevented) return;
470
+ const o = Ct(e), n = Tt(e), r = Lt(e), a = Rt(e), l = e.key === "Escape";
468
471
  if (!l && !o && !n && !r && !a)
469
472
  return;
470
473
  D();
471
- const c = t.target, u = !!c?.closest(`.${d} input, .${d} textarea, .${d} select`);
472
- if (!xe(c) && !we())
474
+ const c = e.target, u = !!c?.closest(`.${d} input, .${d} textarea, .${d} select`);
475
+ if (!wt(c) && !yt())
473
476
  return;
474
477
  const i = x(void 0, !1);
475
478
  if (!i) return;
476
- const b = s.get(i) || R || e;
479
+ const b = s.get(i) || R || t;
477
480
  s.set(i, b);
478
- const $ = f(i, b);
479
- if (v = i, l && Z(i)) {
480
- t.preventDefault(), P(i, !0);
481
+ const E = f(i, b);
482
+ if (v = i, l && tt(i)) {
483
+ e.preventDefault(), P(i, !0);
481
484
  return;
482
485
  }
483
486
  if (!u) {
484
487
  if (o) {
485
- t.preventDefault(), t.stopPropagation(), de(i);
488
+ e.preventDefault(), e.stopPropagation(), ut(i);
486
489
  return;
487
490
  }
488
491
  if (n) {
489
- t.preventDefault(), t.stopPropagation(), E(i, "review", b, b.defaultActor) && A(i);
492
+ e.preventDefault(), e.stopPropagation(), $(i, "review", b, b.defaultActor) && A(i);
490
493
  return;
491
494
  }
492
495
  if (r) {
493
- t.preventDefault(), t.stopPropagation(), Q(i, b, b.defaultActor, "Approved via keyboard shortcut.") && A(i);
496
+ e.preventDefault(), e.stopPropagation(), Z(i, b, b.defaultActor, "Approved via keyboard shortcut.") && A(i);
494
497
  return;
495
498
  }
496
- a && (t.preventDefault(), t.stopPropagation(), $.status !== "draft" && E(i, "draft", b, b.defaultActor) && A(i));
499
+ a && (e.preventDefault(), e.stopPropagation(), E.status !== "draft" && $(i, "draft", b, b.defaultActor) && A(i));
497
500
  }
498
501
  }, document.addEventListener("keydown", L, !0)), S || (S = () => {
499
- D(), k.forEach((t, o) => {
500
- !o.isConnected || !t.isConnected || (K(t, o), V(o, t));
502
+ D(), y.forEach((e, o) => {
503
+ !o.isConnected || !e.isConnected || (B(e, o), U(o, e));
501
504
  });
502
505
  }, window.addEventListener("scroll", S, !0), window.addEventListener("resize", S));
503
506
  }
504
- function Me(e) {
505
- const t = I.get(e);
506
- t && (e.classList.remove("rte-approval-locked-editor"), e.removeAttribute("data-approval-status"), e.removeAttribute("data-approval-locked"), ie(
507
- e,
508
- t.preApprovalContentEditable ?? t.originalContentEditable,
509
- t.preApprovalReadonly ?? t.originalReadonly
507
+ function Dt(t) {
508
+ const e = I.get(t);
509
+ e && (t.classList.remove("rte-approval-locked-editor"), t.removeAttribute("data-approval-status"), t.removeAttribute("data-approval-locked"), st(
510
+ t,
511
+ e.preApprovalContentEditable ?? e.originalContentEditable,
512
+ e.preApprovalReadonly ?? e.originalReadonly
510
513
  ));
511
514
  }
512
- function De() {
513
- 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), k.forEach((e) => e.remove()), k.clear(), H.forEach((e) => Me(e)), H.clear(), R = null, v = null;
515
+ function Ht() {
516
+ 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) => Dt(t)), H.clear(), R = null, v = null;
514
517
  }
515
- function He() {
516
- if (typeof document > "u" || document.getElementById(te)) return;
517
- const e = document.createElement("style");
518
- e.id = te, e.textContent = `
518
+ function qt() {
519
+ if (typeof document > "u" || document.getElementById(ot)) return;
520
+ const t = document.createElement("style");
521
+ t.id = ot, t.textContent = `
519
522
  .rte-toolbar-group-items.${h},
520
523
  .editora-toolbar-group-items.${h},
521
- .rte-toolbar-group-items.${y},
522
- .editora-toolbar-group-items.${y} {
524
+ .rte-toolbar-group-items.${k},
525
+ .editora-toolbar-group-items.${k} {
523
526
  display: flex;
524
527
  border: 1px solid #ccc;
525
528
  border-radius: 3px;
@@ -528,8 +531,8 @@ function He() {
528
531
 
529
532
  .rte-toolbar-group-items.${h} .rte-toolbar-button,
530
533
  .editora-toolbar-group-items.${h} .editora-toolbar-button,
531
- .rte-toolbar-group-items.${y} .rte-toolbar-button,
532
- .editora-toolbar-group-items.${y} .editora-toolbar-button {
534
+ .rte-toolbar-group-items.${k} .rte-toolbar-button,
535
+ .editora-toolbar-group-items.${k} .editora-toolbar-button {
533
536
  border: none;
534
537
  border-radius: 0;
535
538
  border-right: 1px solid #ccc;
@@ -551,22 +554,22 @@ function He() {
551
554
 
552
555
  .rte-toolbar-group-items.${h} .rte-toolbar-item:last-child .rte-toolbar-button,
553
556
  .editora-toolbar-group-items.${h} .editora-toolbar-item:last-child .editora-toolbar-button,
554
- .rte-toolbar-group-items.${y} .rte-toolbar-item:last-child .rte-toolbar-button,
555
- .editora-toolbar-group-items.${y} .editora-toolbar-item:last-child .editora-toolbar-button {
557
+ .rte-toolbar-group-items.${k} .rte-toolbar-item:last-child .rte-toolbar-button,
558
+ .editora-toolbar-group-items.${k} .editora-toolbar-item:last-child .editora-toolbar-button {
556
559
  border-right: none;
557
560
  }
558
561
 
559
562
  ${g} .rte-toolbar-group-items.${h},
560
563
  ${g} .editora-toolbar-group-items.${h},
561
- ${g} .rte-toolbar-group-items.${y},
562
- ${g} .editora-toolbar-group-items.${y},
564
+ ${g} .rte-toolbar-group-items.${k},
565
+ ${g} .editora-toolbar-group-items.${k},
563
566
  .${d}.rte-approval-theme-dark {
564
567
  border-color: #566275;
565
568
  }
566
569
  ${g} .rte-toolbar-group-items.${h} .rte-toolbar-button svg,
567
570
  ${g} .editora-toolbar-group-items.${h} .editora-toolbar-button svg,
568
- ${g} .rte-toolbar-group-items.${y} .rte-toolbar-button svg,
569
- ${g} .editora-toolbar-group-items.${y} .editora-toolbar-button svg
571
+ ${g} .rte-toolbar-group-items.${k} .rte-toolbar-button svg,
572
+ ${g} .editora-toolbar-group-items.${k} .editora-toolbar-button svg
570
573
  {
571
574
  fill: none;
572
575
  }
@@ -906,11 +909,11 @@ function He() {
906
909
  max-height: calc(100vh - 20px);
907
910
  }
908
911
  }
909
- `, document.head.appendChild(e);
912
+ `, document.head.appendChild(t);
910
913
  }
911
- const qe = (e = {}) => {
912
- const t = z(e);
913
- return He(), {
914
+ const Pt = (t = {}) => {
915
+ const e = z(t);
916
+ return qt(), {
914
917
  name: "approvalWorkflow",
915
918
  toolbar: [
916
919
  {
@@ -954,59 +957,59 @@ const qe = (e = {}) => {
954
957
  approvalWorkflow: (o, n) => {
955
958
  const r = x(n);
956
959
  if (!r) return !1;
957
- const a = s.get(r) || t;
960
+ const a = s.get(r) || e;
958
961
  return s.set(r, a), f(r, a), v = r, A(r), q(r), !0;
959
962
  },
960
963
  toggleApprovalWorkflowPanel: (o, n) => {
961
964
  const r = x(n);
962
965
  if (!r) return !1;
963
- const a = s.get(r) || t;
964
- return s.set(r, a), f(r, a), v = r, de(r, typeof o == "boolean" ? o : void 0);
966
+ const a = s.get(r) || e;
967
+ return s.set(r, a), f(r, a), v = r, ut(r, typeof o == "boolean" ? o : void 0);
965
968
  },
966
969
  requestApprovalReview: (o, n) => {
967
970
  const r = x(n);
968
971
  if (!r) return !1;
969
- const a = s.get(r) || t;
972
+ const a = s.get(r) || e;
970
973
  s.set(r, a), f(r, a);
971
- const l = E(r, "review", a, a.defaultActor);
974
+ const l = $(r, "review", a, a.defaultActor);
972
975
  return A(r), l;
973
976
  },
974
977
  approveDocument: (o, n) => {
975
978
  const r = x(n);
976
979
  if (!r) return !1;
977
- const a = s.get(r) || t;
980
+ const a = s.get(r) || e;
978
981
  s.set(r, a), f(r, a);
979
- const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.comment || "") : typeof o == "string" ? o : "", u = Q(r, a, l, c);
982
+ const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.comment || "") : typeof o == "string" ? o : "", u = Z(r, a, l, c);
980
983
  return u && A(r), u;
981
984
  },
982
985
  reopenDraft: (o, n) => {
983
986
  const r = x(n);
984
987
  if (!r) return !1;
985
- const a = s.get(r) || t;
988
+ const a = s.get(r) || e;
986
989
  s.set(r, a), f(r, a);
987
- const l = E(r, "draft", a, a.defaultActor);
990
+ const l = $(r, "draft", a, a.defaultActor);
988
991
  return l && A(r), l;
989
992
  },
990
993
  addApprovalComment: (o, n) => {
991
994
  const r = x(n);
992
995
  if (!r) return !1;
993
- const a = s.get(r) || t;
996
+ const a = s.get(r) || e;
994
997
  s.set(r, a), f(r, a);
995
- const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.message || "") : typeof o == "string" ? o : "", u = pe(r, c, l, a);
998
+ const l = typeof o == "object" && o ? String(o.author || "") : a.defaultActor, c = typeof o == "object" && o ? String(o.message || "") : typeof o == "string" ? o : "", u = dt(r, c, l, a);
996
999
  return u && A(r), u;
997
1000
  },
998
1001
  setApprovalStatus: (o, n) => {
999
1002
  const r = x(n);
1000
1003
  if (!r || !o) return !1;
1001
- const a = ne(o), l = s.get(r) || t;
1004
+ const a = lt(o), l = s.get(r) || e;
1002
1005
  s.set(r, l), f(r, l);
1003
- const c = E(r, a, l, l.defaultActor);
1006
+ const c = $(r, a, l, l.defaultActor);
1004
1007
  return c && A(r), c;
1005
1008
  },
1006
1009
  setApprovalWorkflowOptions: (o, n) => {
1007
1010
  const r = x(n);
1008
1011
  if (!r || !o || typeof o != "object") return !1;
1009
- const a = s.get(r) || t, l = z({
1012
+ const a = s.get(r) || e, l = z({
1010
1013
  ...a,
1011
1014
  ...o,
1012
1015
  labels: {
@@ -1022,9 +1025,9 @@ const qe = (e = {}) => {
1022
1025
  getApprovalWorkflowState: (o, n) => {
1023
1026
  const r = x(n);
1024
1027
  if (!r) return !1;
1025
- const a = s.get(r) || t;
1028
+ const a = s.get(r) || e;
1026
1029
  s.set(r, a);
1027
- const l = f(r, a), c = se(l);
1030
+ const l = f(r, a), c = ct(l);
1028
1031
  if (typeof o == "function")
1029
1032
  try {
1030
1033
  o(c);
@@ -1052,8 +1055,8 @@ const qe = (e = {}) => {
1052
1055
  },
1053
1056
  init: function(n) {
1054
1057
  _ += 1;
1055
- const r = this && typeof this.__pluginConfig == "object" ? z({ ...t, ...this.__pluginConfig }) : t;
1056
- Re(r);
1058
+ const r = this && typeof this.__pluginConfig == "object" ? z({ ...e, ...this.__pluginConfig }) : e;
1059
+ Mt(r);
1057
1060
  const a = x(
1058
1061
  n?.editorElement ? { editorElement: n.editorElement } : void 0,
1059
1062
  !1
@@ -1061,10 +1064,10 @@ const qe = (e = {}) => {
1061
1064
  a && (s.set(a, r), f(a, r), v = a, q(a));
1062
1065
  },
1063
1066
  destroy: () => {
1064
- _ = Math.max(0, _ - 1), !(_ > 0) && De();
1067
+ _ = Math.max(0, _ - 1), !(_ > 0) && Ht();
1065
1068
  }
1066
1069
  };
1067
1070
  };
1068
1071
  export {
1069
- qe as ApprovalWorkflowPlugin
1072
+ Pt as ApprovalWorkflowPlugin
1070
1073
  };