@editora/plugins 1.0.7 → 1.0.9

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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -4
  3. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  4. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  5. package/dist/anchor.cjs.js +11 -11
  6. package/dist/anchor.esm.js +130 -107
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +447 -0
  10. package/dist/approval-workflow.esm.js +1070 -0
  11. package/dist/background-color.cjs.js +3 -3
  12. package/dist/background-color.esm.js +116 -119
  13. package/dist/blocks-library.cjs.js +442 -0
  14. package/dist/blocks-library.esm.js +1317 -0
  15. package/dist/citations.cjs.js +548 -0
  16. package/dist/citations.esm.js +1457 -0
  17. package/dist/code.cjs.js +82 -102
  18. package/dist/code.esm.js +1172 -662
  19. package/dist/comments.cjs.js +10 -10
  20. package/dist/comments.esm.js +195 -177
  21. package/dist/conditional-content.cjs.js +626 -0
  22. package/dist/conditional-content.esm.js +1360 -0
  23. package/dist/content-rules.cjs.js +408 -0
  24. package/dist/content-rules.esm.js +1093 -0
  25. package/dist/data-binding.cjs.js +321 -0
  26. package/dist/data-binding.esm.js +913 -0
  27. package/dist/doc-schema.cjs.js +398 -0
  28. package/dist/doc-schema.esm.js +1310 -0
  29. package/dist/document-manager.cjs.js +1 -1
  30. package/dist/document-manager.esm.js +1 -1
  31. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  32. package/dist/documentManager-Jf0RbSks.js +17 -0
  33. package/dist/embed-iframe.cjs.js +2 -2
  34. package/dist/embed-iframe.esm.js +8 -5
  35. package/dist/emojis.cjs.js +64 -39
  36. package/dist/emojis.esm.js +133 -104
  37. package/dist/enterprise.cjs.js +1 -0
  38. package/dist/enterprise.esm.js +56 -0
  39. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  40. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  41. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  42. package/dist/index-CvJk4DKa.js +221 -0
  43. package/dist/index-D3CycEFU.mjs +16543 -0
  44. package/dist/index-tqLTHcO6.js +1 -0
  45. package/dist/index.cjs.js +1 -1
  46. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  47. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  48. package/dist/index.esm.js +111 -75
  49. package/dist/jspdf.es.min-BoS80556.js +77 -0
  50. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  51. package/dist/link.cjs.js +6 -6
  52. package/dist/link.esm.js +41 -39
  53. package/dist/math.cjs.js +21 -21
  54. package/dist/math.esm.js +151 -112
  55. package/dist/media-manager.cjs.js +15 -15
  56. package/dist/media-manager.esm.js +227 -206
  57. package/dist/mentions.cjs.js +105 -0
  58. package/dist/mentions.esm.js +726 -0
  59. package/dist/merge-tag.cjs.js +44 -12
  60. package/dist/merge-tag.esm.js +368 -241
  61. package/dist/page-break.cjs.js +2 -2
  62. package/dist/page-break.esm.js +85 -77
  63. package/dist/pii-redaction.cjs.js +436 -0
  64. package/dist/pii-redaction.esm.js +1377 -0
  65. package/dist/preview.cjs.js +3 -3
  66. package/dist/preview.esm.js +29 -29
  67. package/dist/slash-commands.cjs.js +90 -0
  68. package/dist/slash-commands.esm.js +752 -0
  69. package/dist/smart-paste.cjs.js +398 -0
  70. package/dist/smart-paste.esm.js +1388 -0
  71. package/dist/special-characters.cjs.js +83 -45
  72. package/dist/special-characters.esm.js +149 -100
  73. package/dist/spell-check.cjs.js +9 -9
  74. package/dist/spell-check.esm.js +235 -216
  75. package/dist/template.cjs.js +14 -14
  76. package/dist/template.esm.js +157 -131
  77. package/dist/text-color.cjs.js +9 -9
  78. package/dist/text-color.esm.js +131 -115
  79. package/dist/track-changes.cjs.js +77 -0
  80. package/dist/track-changes.esm.js +755 -0
  81. package/dist/translation-workflow.cjs.js +626 -0
  82. package/dist/translation-workflow.esm.js +1718 -0
  83. package/dist/version-diff.cjs.js +362 -0
  84. package/dist/version-diff.esm.js +768 -0
  85. package/index.d.ts +849 -1
  86. package/package.json +105 -6
  87. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  88. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  89. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  90. package/dist/documentManager-_tQQfQi9.js +0 -317
  91. package/dist/index-D3pJyAsj.js +0 -1
@@ -0,0 +1,1377 @@
1
+ const x = ".rte-content, .editora-content", ae = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", ke = "__editoraCommandEditorRoot", we = "rte-pii-redaction-styles", u = "rte-pii-redaction-panel", k = "pii-redaction", v = "piiRedaction", $ = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pe = typeof NodeFilter < "u" ? NodeFilter.SHOW_TEXT : 4, Ne = [
2
+ "email",
3
+ "phone",
4
+ "ssn",
5
+ "credit-card",
6
+ "ipv4",
7
+ "api-key",
8
+ "jwt"
9
+ ], Oe = {
10
+ panelTitle: "PII Redaction",
11
+ panelAriaLabel: "PII redaction panel",
12
+ scanText: "Scan PII",
13
+ redactAllText: "Redact All",
14
+ redactText: "Redact",
15
+ locateText: "Locate",
16
+ realtimeOnText: "Realtime On",
17
+ realtimeOffText: "Realtime Off",
18
+ closeText: "Close",
19
+ noFindingsText: "No PII detected in the document.",
20
+ summaryPrefix: "Findings",
21
+ shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+I/U/M/Y",
22
+ readonlyRedactionText: "Editor is read-only. Reopen editable mode to redact.",
23
+ matchLabel: "Detected",
24
+ maskedLabel: "Masked",
25
+ excerptLabel: "Context"
26
+ }, ze = {
27
+ email: {
28
+ label: "Email",
29
+ severity: "medium",
30
+ pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi
31
+ },
32
+ phone: {
33
+ label: "Phone",
34
+ severity: "medium",
35
+ pattern: /\b(?:\+?\d{1,3}[\s.-]?)?(?:\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4})\b/g
36
+ },
37
+ ssn: {
38
+ label: "SSN",
39
+ severity: "high",
40
+ pattern: /\b\d{3}-\d{2}-\d{4}\b/g
41
+ },
42
+ "credit-card": {
43
+ label: "Credit Card",
44
+ severity: "high",
45
+ pattern: /\b(?:\d[ -]*?){13,19}\b/g,
46
+ validator: (e) => qe(e)
47
+ },
48
+ ipv4: {
49
+ label: "IPv4",
50
+ severity: "low",
51
+ pattern: /\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g
52
+ },
53
+ "api-key": {
54
+ label: "API Key",
55
+ severity: "high",
56
+ pattern: /\b(?:sk-[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z\-_]{35}|ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,})\b/g
57
+ },
58
+ jwt: {
59
+ label: "JWT",
60
+ severity: "high",
61
+ pattern: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g
62
+ }
63
+ }, f = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new Set(), W = /* @__PURE__ */ new Set();
64
+ let G = 0, Fe = 0, Ee = 0, A = null, g = null, P = null, L = null, D = null, R = null, _ = null;
65
+ function p(e) {
66
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
67
+ }
68
+ function He(e) {
69
+ return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
70
+ }
71
+ function Y(e) {
72
+ const t = e.flags.includes("g") ? e.flags : `${e.flags}g`;
73
+ return new RegExp(e.source, t);
74
+ }
75
+ function be(e) {
76
+ return new RegExp(e.source, e.flags);
77
+ }
78
+ function X(e, t, n) {
79
+ return Math.max(t, Math.min(n, e));
80
+ }
81
+ function Be(e, t) {
82
+ return e === "high" || e === "medium" || e === "low" ? e : t;
83
+ }
84
+ function Ke(e) {
85
+ const t = (e || "*").slice(0, 1) || "*";
86
+ return /[A-Za-z0-9._%+\-\s]/.test(t) ? "*" : t;
87
+ }
88
+ function ve(e) {
89
+ let t = 2166136261;
90
+ for (let n = 0; n < e.length; n += 1)
91
+ t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
92
+ return t >>> 0;
93
+ }
94
+ function qe(e) {
95
+ const t = e.replace(/\D/g, "");
96
+ if (t.length < 13 || t.length > 19) return !1;
97
+ let n = 0, r = !1;
98
+ for (let i = t.length - 1; i >= 0; i -= 1) {
99
+ let o = Number(t[i]);
100
+ r && (o *= 2, o > 9 && (o -= 9)), n += o, r = !r;
101
+ }
102
+ return n % 10 === 0;
103
+ }
104
+ function We(e, t) {
105
+ const n = ze[e];
106
+ if (typeof t == "boolean")
107
+ return {
108
+ type: e,
109
+ label: n.label,
110
+ severity: n.severity,
111
+ enabled: t,
112
+ pattern: Y(n.pattern),
113
+ validator: n.validator
114
+ };
115
+ if (!t)
116
+ return {
117
+ type: e,
118
+ label: n.label,
119
+ severity: n.severity,
120
+ enabled: !0,
121
+ pattern: Y(n.pattern),
122
+ validator: n.validator
123
+ };
124
+ const r = t.pattern instanceof RegExp ? Y(t.pattern) : Y(n.pattern);
125
+ return {
126
+ type: e,
127
+ label: n.label,
128
+ severity: Be(t.severity, n.severity),
129
+ enabled: t.enabled !== !1,
130
+ pattern: r,
131
+ validator: n.validator
132
+ };
133
+ }
134
+ function ee(e = {}) {
135
+ const t = Ne.map((r) => We(r, e.detectors?.[r])), n = t.map((r) => `${r.type}:${r.enabled ? "1" : "0"}:${r.severity}:${r.pattern.source}:${r.pattern.flags}`).join("|");
136
+ return {
137
+ enableRealtime: e.enableRealtime !== !1,
138
+ debounceMs: X(Number(e.debounceMs ?? 220), 60, 3e3),
139
+ maxFindings: X(Number(e.maxFindings ?? 140), 1, 500),
140
+ maskChar: Ke(e.maskChar),
141
+ revealStart: X(Number(e.revealStart ?? 2), 0, 12),
142
+ revealEnd: X(Number(e.revealEnd ?? 2), 0, 12),
143
+ redactionMode: e.redactionMode === "mask" ? "mask" : "token",
144
+ redactionToken: (e.redactionToken || "REDACTED").trim() || "REDACTED",
145
+ skipInCodeBlocks: e.skipInCodeBlocks !== !1,
146
+ labels: {
147
+ ...Oe,
148
+ ...e.labels || {}
149
+ },
150
+ normalizeText: e.normalizeText || He,
151
+ detectors: t,
152
+ detectorSignature: n
153
+ };
154
+ }
155
+ function ce(e) {
156
+ const t = {};
157
+ return e.detectors.forEach((n) => {
158
+ t[n.type] = {
159
+ enabled: n.enabled,
160
+ severity: n.severity,
161
+ pattern: n.pattern
162
+ };
163
+ }), {
164
+ enableRealtime: e.enableRealtime,
165
+ debounceMs: e.debounceMs,
166
+ maxFindings: e.maxFindings,
167
+ maskChar: e.maskChar,
168
+ revealStart: e.revealStart,
169
+ revealEnd: e.revealEnd,
170
+ redactionMode: e.redactionMode,
171
+ redactionToken: e.redactionToken,
172
+ skipInCodeBlocks: e.skipInCodeBlocks,
173
+ labels: { ...e.labels },
174
+ normalizeText: e.normalizeText,
175
+ detectors: t
176
+ };
177
+ }
178
+ function ge(e) {
179
+ return e.closest(ae) || e;
180
+ }
181
+ function je(e) {
182
+ const t = e.closest("[data-editora-editor]");
183
+ if (t && O(t) === e)
184
+ return t;
185
+ let n = e;
186
+ for (; n; ) {
187
+ if (n.matches(ae) && (n === e || O(n) === e))
188
+ return n;
189
+ n = n.parentElement;
190
+ }
191
+ return ge(e);
192
+ }
193
+ function O(e) {
194
+ if (!e) return null;
195
+ if (e.matches(x)) return e;
196
+ const t = e.querySelector(x);
197
+ return t instanceof HTMLElement ? t : null;
198
+ }
199
+ function Ze() {
200
+ if (typeof window > "u") return null;
201
+ const e = window[ke];
202
+ if (!(e instanceof HTMLElement)) return null;
203
+ window[ke] = null;
204
+ const t = O(e);
205
+ if (t) return t;
206
+ const n = e.closest(ae);
207
+ if (n) {
208
+ const i = O(n);
209
+ if (i) return i;
210
+ }
211
+ const r = e.closest(x);
212
+ return r instanceof HTMLElement ? r : null;
213
+ }
214
+ function J(e) {
215
+ 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;
216
+ }
217
+ function Ve(e) {
218
+ const t = ge(e);
219
+ if (J(t)) return !0;
220
+ const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
221
+ return J(n) ? !0 : J(document.documentElement) || J(document.body);
222
+ }
223
+ function ne(e, t) {
224
+ e.classList.remove("rte-pii-redaction-theme-dark"), Ve(t) && e.classList.add("rte-pii-redaction-theme-dark");
225
+ }
226
+ function re(e) {
227
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
228
+ }
229
+ function me(e) {
230
+ const t = te.get(e);
231
+ typeof t == "number" && (window.clearTimeout(t), W.delete(t), te.delete(e));
232
+ }
233
+ function V(e) {
234
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
235
+ }
236
+ function le(e = 0) {
237
+ return {
238
+ total: 0,
239
+ high: 0,
240
+ medium: 0,
241
+ low: 0,
242
+ redactedCount: e,
243
+ byType: {
244
+ email: 0,
245
+ phone: 0,
246
+ ssn: 0,
247
+ "credit-card": 0,
248
+ ipv4: 0,
249
+ "api-key": 0,
250
+ jwt: 0
251
+ }
252
+ };
253
+ }
254
+ function K() {
255
+ Array.from(q).forEach((t) => {
256
+ t.isConnected || Ie(t);
257
+ });
258
+ }
259
+ function Ue(e) {
260
+ for (let t = 0; t < e.length; t += 1) {
261
+ const n = e[t];
262
+ if (!(n.type !== "childList" || n.removedNodes.length === 0))
263
+ for (let r = 0; r < n.removedNodes.length; r += 1) {
264
+ const i = n.removedNodes[r];
265
+ if (i.nodeType !== Node.ELEMENT_NODE) continue;
266
+ const o = i;
267
+ if (o.matches?.(x) || o.matches?.(`.${u}`) || o.querySelector?.(x) || o.querySelector?.(`.${u}`))
268
+ return !0;
269
+ }
270
+ }
271
+ return !1;
272
+ }
273
+ function T(e, t = !0) {
274
+ if (K(), e?.contentElement instanceof HTMLElement) return e.contentElement;
275
+ if (e?.editorElement instanceof HTMLElement) {
276
+ const o = e.editorElement, a = O(o);
277
+ if (a) return a;
278
+ }
279
+ const n = Ze();
280
+ if (n) return n;
281
+ const r = window.getSelection();
282
+ if (r && r.rangeCount > 0) {
283
+ const a = re(r.getRangeAt(0).startContainer)?.closest(x);
284
+ if (a) return a;
285
+ }
286
+ const i = document.activeElement;
287
+ if (i) {
288
+ if (i.matches(x)) return i;
289
+ const o = i.closest(x);
290
+ if (o) return o;
291
+ }
292
+ return g && g.isConnected ? g : (g && !g.isConnected && (g = null), t ? document.querySelector(x) : null);
293
+ }
294
+ function Ie(e) {
295
+ me(e), m.get(e)?.remove(), m.delete(e), Z.delete(e), f.delete(e), I.delete(e), E.delete(e), S.delete(e), de.delete(e), Q.delete(e), q.delete(e), g === e && (g = null);
296
+ }
297
+ function C(e, t, n) {
298
+ const r = je(e);
299
+ Array.from(
300
+ r.querySelectorAll(
301
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
302
+ )
303
+ ).forEach((o) => {
304
+ o.classList.toggle("active", n), o.setAttribute("data-active", n ? "true" : "false"), o.setAttribute("aria-pressed", n ? "true" : "false");
305
+ });
306
+ }
307
+ function w(e, t) {
308
+ f.has(e) || f.set(e, t), I.has(e) || I.set(e, []), E.has(e) || E.set(e, le(0)), S.has(e) || S.set(e, t.enableRealtime), q.add(e);
309
+ }
310
+ function oe(e) {
311
+ return Z.get(e) === !0;
312
+ }
313
+ function $e(e, t, n, r) {
314
+ if (!e) return e;
315
+ if (e.length <= n + r)
316
+ return t.repeat(e.length);
317
+ const i = e.slice(0, n), o = r > 0 ? e.slice(e.length - r) : "";
318
+ return `${i}${t.repeat(Math.max(1, e.length - n - r))}${o}`;
319
+ }
320
+ function se(e, t, n) {
321
+ const r = e.replace(/\D/g, "");
322
+ if (r.length === 0) return e;
323
+ let i = 0;
324
+ const o = Math.max(0, r.length - n);
325
+ return e.split("").map((a) => /\d/.test(a) ? (i += 1, i <= o ? t : a) : a).join("");
326
+ }
327
+ function Ge(e, t) {
328
+ const n = e.indexOf("@");
329
+ if (n <= 0) return e;
330
+ const r = e.slice(0, n), i = e.slice(n + 1);
331
+ return r.length <= 2 ? `${r[0] || ""}${t}[at]${i}` : `${r[0]}${t.repeat(Math.max(1, r.length - 2))}${r[r.length - 1]}[at]${i}`;
332
+ }
333
+ function Ye(e, t) {
334
+ const n = e.split(".");
335
+ return n.length !== 4 ? e : `${n[0]}.${n[1]}.${n[2]}.${t.repeat(Math.max(1, n[3].length))}`;
336
+ }
337
+ function Te(e, t, n) {
338
+ return e && (t === "email" ? Ge(e, n.maskChar) : t === "phone" || t === "ssn" || t === "credit-card" ? se(e, n.maskChar, 4) : t === "ipv4" ? Ye(e, n.maskChar) : t === "api-key" || t === "jwt" ? $e(e, n.maskChar, 0, 0) : $e(e, n.maskChar, n.revealStart, n.revealEnd));
339
+ }
340
+ function Ce(e, t, n) {
341
+ return n.redactionMode === "mask" ? Te(e, t, n) : `[${n.redactionToken}:${t.toUpperCase()}]`;
342
+ }
343
+ function Xe(e) {
344
+ return Ee += 1, `pii-${e}-${Date.now().toString(36)}-${Ee.toString(36)}`;
345
+ }
346
+ function he(e, t) {
347
+ return t.skipInCodeBlocks ? !!e.parentElement?.closest("code, pre, kbd, samp") : !1;
348
+ }
349
+ function Je(e, t) {
350
+ return t.some((n) => e.start < n.end && n.start < e.end);
351
+ }
352
+ function Qe(e, t, n) {
353
+ const r = [];
354
+ t.filter((a) => a.enabled).forEach((a) => {
355
+ const l = be(a.pattern);
356
+ let c = l.exec(e);
357
+ for (; c && r.length < n * 5; ) {
358
+ const d = c[0] || "", s = c.index, b = s + d.length;
359
+ d && b > s && (!a.validator || a.validator(d)) && r.push({
360
+ type: a.type,
361
+ severity: a.severity,
362
+ value: d,
363
+ start: s,
364
+ end: b
365
+ }), l.lastIndex === c.index && (l.lastIndex += 1), c = l.exec(e);
366
+ }
367
+ }), r.sort((a, l) => a.start !== l.start ? a.start - l.start : l.end - a.end);
368
+ const o = [];
369
+ for (let a = 0; a < r.length && !(o.length >= n); a += 1) {
370
+ const l = r[a];
371
+ Je({ start: l.start, end: l.end }, o) || o.push(l);
372
+ }
373
+ return o;
374
+ }
375
+ function ue(e, t = 120) {
376
+ return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
377
+ }
378
+ function et(e, t, n) {
379
+ const r = Math.max(0, t - 28), i = Math.min(e.length, n + 28);
380
+ return ue(e.slice(r, i).trim(), 180);
381
+ }
382
+ function tt(e, t) {
383
+ const n = le(t);
384
+ return n.total = e.length, e.forEach((r) => {
385
+ n.byType[r.type] += 1, r.severity === "high" ? n.high += 1 : r.severity === "medium" ? n.medium += 1 : n.low += 1;
386
+ }), n;
387
+ }
388
+ function ie(e, t) {
389
+ const n = e.querySelector(".rte-pii-redaction-live");
390
+ n && (n.textContent = t);
391
+ }
392
+ function z(e, t, n) {
393
+ const r = t.querySelector('[data-action="toggle-realtime"]');
394
+ if (!r) return;
395
+ const i = F(e, n);
396
+ r.textContent = i ? n.labels.realtimeOnText : n.labels.realtimeOffText, r.setAttribute("aria-pressed", i ? "true" : "false"), C(e, "togglePIIRealtime", i);
397
+ }
398
+ function nt(e, t) {
399
+ e.setAttribute("aria-label", t.labels.panelAriaLabel);
400
+ const n = e.querySelector(".rte-pii-redaction-title");
401
+ n && (n.textContent = t.labels.panelTitle);
402
+ const r = e.querySelector('[data-action="close"]');
403
+ r && r.setAttribute("aria-label", t.labels.closeText);
404
+ const i = e.querySelector('[data-action="run-scan"]');
405
+ i && (i.textContent = t.labels.scanText);
406
+ const o = e.querySelector('[data-action="redact-all"]');
407
+ o && (o.textContent = t.labels.redactAllText);
408
+ const a = e.querySelector(".rte-pii-redaction-shortcut");
409
+ a && (a.textContent = t.labels.shortcutText);
410
+ }
411
+ function H(e) {
412
+ const t = m.get(e);
413
+ if (!t) return;
414
+ const n = f.get(e) || A;
415
+ if (!n) return;
416
+ const r = I.get(e) || [], i = E.get(e) || le(0), o = V(e), a = t.querySelector(".rte-pii-redaction-count"), l = t.querySelector(".rte-pii-redaction-summary"), c = t.querySelector(".rte-pii-redaction-list"), d = t.querySelector('[data-action="redact-all"]');
417
+ if (!(!a || !l || !c || !d)) {
418
+ if (a.textContent = String(i.total), l.textContent = `${n.labels.summaryPrefix}: ${i.total} | High ${i.high} | Medium ${i.medium} | Low ${i.low} | Redacted ${i.redactedCount}`, d.disabled = o || r.length === 0, o ? ie(t, n.labels.readonlyRedactionText) : ie(t, `${i.total} PII findings detected.`), z(e, t, n), r.length === 0) {
419
+ c.innerHTML = `<li class="rte-pii-redaction-empty">${p(n.labels.noFindingsText)}</li>`;
420
+ return;
421
+ }
422
+ c.innerHTML = r.map((s) => {
423
+ const b = s.type.toUpperCase(), M = s.suggestion || "Redact this finding before export/share.", B = `${n.labels.locateText}: ${s.match}`, y = `${n.labels.redactText}: ${s.match}`, U = o ? 'disabled aria-disabled="true"' : "";
424
+ return `
425
+ <li class="rte-pii-redaction-item rte-pii-redaction-item-${s.severity}">
426
+ <button
427
+ type="button"
428
+ class="rte-pii-redaction-item-btn"
429
+ data-action="locate-finding"
430
+ data-finding-id="${p(s.id)}"
431
+ data-role="finding-button"
432
+ aria-label="${p(B)}"
433
+ >
434
+ <span class="rte-pii-redaction-badge">${p(s.severity.toUpperCase())}</span>
435
+ <span class="rte-pii-redaction-type">${p(b)}</span>
436
+ </button>
437
+ <p class="rte-pii-redaction-line"><strong>${p(n.labels.matchLabel)}:</strong> ${p(ue(s.match, 80))}</p>
438
+ <p class="rte-pii-redaction-line"><strong>${p(n.labels.maskedLabel)}:</strong> ${p(ue(s.masked, 80))}</p>
439
+ ${s.excerpt ? `<p class="rte-pii-redaction-line"><strong>${p(n.labels.excerptLabel)}:</strong> ${p(s.excerpt)}</p>` : ""}
440
+ <p class="rte-pii-redaction-help">${p(M)}</p>
441
+ <div class="rte-pii-redaction-item-actions">
442
+ <button type="button" class="rte-pii-redaction-btn" data-action="redact-finding" data-finding-id="${p(
443
+ s.id
444
+ )}" aria-label="${p(y)}" ${U}>${p(n.labels.redactText)}</button>
445
+ </div>
446
+ </li>
447
+ `;
448
+ }).join("");
449
+ }
450
+ }
451
+ function fe(e, t) {
452
+ if (!t.classList.contains("show")) return;
453
+ const r = ge(e).getBoundingClientRect(), i = Math.min(window.innerWidth - 20, 390), o = Math.max(10, window.innerWidth - i - 10), a = Math.min(Math.max(10, r.right - i), o), l = Math.max(10, Math.min(window.innerHeight - 10 - 280, r.top + 10));
454
+ t.style.width = `${i}px`, t.style.left = `${a}px`, t.style.top = `${l}px`, t.style.maxHeight = `${Math.max(260, window.innerHeight - 20)}px`;
455
+ }
456
+ function F(e, t) {
457
+ const n = S.get(e);
458
+ return typeof n == "boolean" ? n : t ? t.enableRealtime : !0;
459
+ }
460
+ function Re(e, t) {
461
+ if (t === e.innerHTML) return;
462
+ const n = window.execEditorCommand || window.executeEditorCommand;
463
+ if (typeof n == "function")
464
+ try {
465
+ n("recordDomTransaction", e, t, e.innerHTML);
466
+ } catch {
467
+ }
468
+ }
469
+ function Se(e) {
470
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
471
+ }
472
+ function Ae(e, t) {
473
+ e.dispatchEvent(
474
+ new CustomEvent("editora:pii-redacted", {
475
+ bubbles: !0,
476
+ detail: {
477
+ redactedCount: t
478
+ }
479
+ })
480
+ );
481
+ }
482
+ function Me(e, t) {
483
+ return (I.get(e) || []).find((r) => r.id === t);
484
+ }
485
+ function rt(e) {
486
+ const t = m.get(e);
487
+ if (t) return t;
488
+ const n = f.get(e) || A || ee(), r = `rte-pii-redaction-panel-${Fe++}`, i = document.createElement("section");
489
+ return i.className = u, i.id = r, i.setAttribute("role", "dialog"), i.setAttribute("aria-modal", "false"), i.setAttribute("aria-label", n.labels.panelAriaLabel), i.innerHTML = `
490
+ <header class="rte-pii-redaction-header">
491
+ <h2 class="rte-pii-redaction-title">${p(n.labels.panelTitle)}</h2>
492
+ <button type="button" class="rte-pii-redaction-icon-btn" data-action="close" aria-label="${p(
493
+ n.labels.closeText
494
+ )}">✕</button>
495
+ </header>
496
+ <div class="rte-pii-redaction-body">
497
+ <div class="rte-pii-redaction-topline">
498
+ <p class="rte-pii-redaction-summary" aria-live="polite"></p>
499
+ <span class="rte-pii-redaction-count" aria-hidden="true">0</span>
500
+ </div>
501
+ <div class="rte-pii-redaction-controls" role="toolbar" aria-label="PII redaction controls">
502
+ <button type="button" class="rte-pii-redaction-btn rte-pii-redaction-btn-primary" data-action="run-scan">${p(
503
+ n.labels.scanText
504
+ )}</button>
505
+ <button type="button" class="rte-pii-redaction-btn" data-action="redact-all">${p(
506
+ n.labels.redactAllText
507
+ )}</button>
508
+ <button type="button" class="rte-pii-redaction-btn" data-action="toggle-realtime" aria-pressed="false"></button>
509
+ </div>
510
+ <ul class="rte-pii-redaction-list" role="list" aria-label="Detected PII findings"></ul>
511
+ <p class="rte-pii-redaction-shortcut">${p(n.labels.shortcutText)}</p>
512
+ <span class="rte-pii-redaction-live" aria-live="polite"></span>
513
+ </div>
514
+ `, i.addEventListener("click", (o) => {
515
+ const l = o.target?.closest("[data-action]");
516
+ if (!l) return;
517
+ const c = l.getAttribute("data-action") || "", d = f.get(e) || A || n;
518
+ if (f.set(e, d), w(e, d), c === "close") {
519
+ j(e, !0);
520
+ return;
521
+ }
522
+ if (c === "run-scan") {
523
+ h(e, d, !0);
524
+ return;
525
+ }
526
+ if (c === "toggle-realtime") {
527
+ const s = !F(e, d);
528
+ S.set(e, s), z(e, i, d), s && h(e, d, !0);
529
+ return;
530
+ }
531
+ if (c === "redact-all") {
532
+ xe(e, d);
533
+ return;
534
+ }
535
+ if (c === "locate-finding") {
536
+ const s = l.getAttribute("data-finding-id") || "", b = Me(e, s);
537
+ if (!b) return;
538
+ at(e, b, d);
539
+ return;
540
+ }
541
+ if (c === "redact-finding") {
542
+ const s = l.getAttribute("data-finding-id") || "";
543
+ De(e, s, d);
544
+ }
545
+ }), i.addEventListener("keydown", (o) => {
546
+ if (o.key === "Escape") {
547
+ o.preventDefault(), j(e, !0);
548
+ return;
549
+ }
550
+ if (o.key !== "ArrowDown" && o.key !== "ArrowUp") return;
551
+ const a = Array.from(i.querySelectorAll('[data-role="finding-button"]'));
552
+ if (a.length === 0) return;
553
+ const l = document.activeElement, c = a.findIndex((b) => b === l);
554
+ if (c === -1) return;
555
+ o.preventDefault();
556
+ const d = o.key === "ArrowDown" ? 1 : -1, s = (c + d + a.length) % a.length;
557
+ a[s].focus();
558
+ }), ne(i, e), document.body.appendChild(i), m.set(e, i), Z.set(e, !1), H(e), i;
559
+ }
560
+ function j(e, t = !1) {
561
+ const n = m.get(e);
562
+ n && (n.classList.remove("show"), Z.set(e, !1), C(e, "togglePIIRedactionPanel", !1), t && e.focus({ preventScroll: !0 }));
563
+ }
564
+ function N(e) {
565
+ K();
566
+ const t = rt(e);
567
+ m.forEach((r, i) => {
568
+ i !== e && j(i, !1);
569
+ }), t.classList.add("show"), Z.set(e, !0), C(e, "togglePIIRedactionPanel", !0), ne(t, e), fe(e, t), H(e), t.querySelector('[data-action="run-scan"]')?.focus();
570
+ }
571
+ function Pe(e, t) {
572
+ const n = oe(e);
573
+ return (typeof t == "boolean" ? t : !n) ? N(e) : j(e), !0;
574
+ }
575
+ function ot(e, t) {
576
+ const n = t.normalizeText(e.innerText || e.textContent || ""), r = e.innerHTML;
577
+ return `${n.length}:${ve(n)}:${r.length}:${ve(r)}:${t.detectorSignature}`;
578
+ }
579
+ function it(e, t) {
580
+ const n = [], r = be(e.pattern);
581
+ let i = r.exec(t);
582
+ for (; i; ) {
583
+ const o = i[0] || "", a = i.index, l = a + o.length;
584
+ o && l > a && (!e.validator || e.validator(o)) && n.push({ value: o, start: a, end: l }), r.lastIndex === i.index && (r.lastIndex += 1), i = r.exec(t);
585
+ }
586
+ return n;
587
+ }
588
+ function Le(e, t, n) {
589
+ const r = n.detectors.find((c) => c.type === t.type && c.enabled);
590
+ if (!r) return null;
591
+ const i = t.match.toLowerCase();
592
+ let o = 0;
593
+ const a = document.createTreeWalker(e, pe, null);
594
+ let l = a.nextNode();
595
+ for (; l; ) {
596
+ if (!he(l, n)) {
597
+ const c = it(r, l.data);
598
+ for (let d = 0; d < c.length; d += 1) {
599
+ const s = c[d];
600
+ if (s.value.toLowerCase() === i && (o += 1, o === t.occurrence)) {
601
+ const b = document.createRange();
602
+ return b.setStart(l, s.start), b.setEnd(l, s.end), b;
603
+ }
604
+ }
605
+ }
606
+ l = a.nextNode();
607
+ }
608
+ return null;
609
+ }
610
+ function at(e, t, n) {
611
+ const r = Le(e, t, n);
612
+ if (!r) return !1;
613
+ const i = window.getSelection();
614
+ return i ? (i.removeAllRanges(), i.addRange(r), re(r.startContainer)?.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 }), !0) : !1;
615
+ }
616
+ async function h(e, t, n = !1) {
617
+ w(e, t);
618
+ const r = ot(e, t);
619
+ if (!n && de.get(e) === r)
620
+ return I.get(e) || [];
621
+ const i = (Q.get(e) || 0) + 1;
622
+ Q.set(e, i);
623
+ const o = [], a = /* @__PURE__ */ new Map(), l = document.createTreeWalker(e, pe, null);
624
+ let c = l.nextNode();
625
+ for (; c && o.length < t.maxFindings; ) {
626
+ const b = c.data || "";
627
+ if (b.trim() && !he(c, t)) {
628
+ const M = Qe(b, t.detectors, t.maxFindings - o.length);
629
+ for (let B = 0; B < M.length && !(o.length >= t.maxFindings); B += 1) {
630
+ const y = M[B], U = `${y.type}:${y.value.toLowerCase()}`, ye = (a.get(U) || 0) + 1;
631
+ a.set(U, ye), o.push({
632
+ id: Xe(y.type),
633
+ type: y.type,
634
+ severity: y.severity,
635
+ match: y.value,
636
+ masked: Te(y.value, y.type, t),
637
+ occurrence: ye,
638
+ excerpt: et(b, y.start, y.end),
639
+ suggestion: "Review and redact this value before external sharing."
640
+ });
641
+ }
642
+ }
643
+ c = l.nextNode();
644
+ }
645
+ if (Q.get(e) !== i)
646
+ return I.get(e) || [];
647
+ const d = E.get(e)?.redactedCount || 0, s = tt(o, d);
648
+ return de.set(e, r), I.set(e, o), E.set(e, s), H(e), e.dispatchEvent(
649
+ new CustomEvent("editora:pii-scan", {
650
+ bubbles: !0,
651
+ detail: {
652
+ findings: o,
653
+ stats: s
654
+ }
655
+ })
656
+ ), o;
657
+ }
658
+ function lt(e, t) {
659
+ let n = e, r = 0;
660
+ return t.detectors.filter((o) => o.enabled).forEach((o) => {
661
+ const a = be(o.pattern);
662
+ n = n.replace(a, (l) => o.validator && !o.validator(l) ? l : (r += 1, Ce(l, o.type, t)));
663
+ }), { nextValue: n, count: r };
664
+ }
665
+ async function De(e, t, n) {
666
+ if (V(e)) {
667
+ const d = m.get(e);
668
+ return d && ie(d, n.labels.readonlyRedactionText), !1;
669
+ }
670
+ const r = Me(e, t);
671
+ if (!r) return !1;
672
+ const i = Le(e, r, n);
673
+ if (!i) return !1;
674
+ const o = e.innerHTML, a = Ce(r.match, r.type, n);
675
+ if (i.startContainer === i.endContainer && i.startContainer.nodeType === Node.TEXT_NODE) {
676
+ const d = i.startContainer, s = d.data, b = i.startOffset, M = i.endOffset;
677
+ d.data = `${s.slice(0, b)}${a}${s.slice(M)}`;
678
+ } else
679
+ i.deleteContents(), i.insertNode(document.createTextNode(a));
680
+ Se(e), Re(e, o);
681
+ const l = E.get(e)?.redactedCount || 0;
682
+ await h(e, n, !0);
683
+ const c = E.get(e);
684
+ return c && (c.redactedCount = l + 1, H(e)), Ae(e, 1), !0;
685
+ }
686
+ async function xe(e, t) {
687
+ if (V(e)) {
688
+ const d = m.get(e);
689
+ return d && ie(d, t.labels.readonlyRedactionText), 0;
690
+ }
691
+ (I.get(e) || []).length === 0 && await h(e, t, !0);
692
+ const r = e.innerHTML;
693
+ let i = 0;
694
+ const o = document.createTreeWalker(e, pe, null);
695
+ let a = o.nextNode();
696
+ for (; a; ) {
697
+ if (he(a, t)) {
698
+ a = o.nextNode();
699
+ continue;
700
+ }
701
+ const d = a.data || "";
702
+ if (!d) {
703
+ a = o.nextNode();
704
+ continue;
705
+ }
706
+ const s = lt(d, t);
707
+ s.count > 0 && s.nextValue !== d && (a.data = s.nextValue, i += s.count), a = o.nextNode();
708
+ }
709
+ if (i === 0) return 0;
710
+ Se(e), Re(e, r);
711
+ const l = E.get(e)?.redactedCount || 0;
712
+ await h(e, t, !0);
713
+ const c = E.get(e);
714
+ return c && (c.redactedCount = l + i, H(e)), Ae(e, i), i;
715
+ }
716
+ function _e(e) {
717
+ const t = f.get(e) || A;
718
+ if (!t || !F(e, t) || V(e)) return;
719
+ me(e);
720
+ const n = window.setTimeout(() => {
721
+ W.delete(n), te.delete(e), h(e, t, !1);
722
+ }, t.debounceMs);
723
+ W.add(n), te.set(e, n);
724
+ }
725
+ function ct(e) {
726
+ const t = e.key.toLowerCase();
727
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "i";
728
+ }
729
+ function st(e) {
730
+ const t = e.key.toLowerCase();
731
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "u";
732
+ }
733
+ function dt(e) {
734
+ const t = e.key.toLowerCase();
735
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "m";
736
+ }
737
+ function ut(e) {
738
+ const t = e.key.toLowerCase();
739
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "y";
740
+ }
741
+ function ft(e) {
742
+ const t = re(e.target);
743
+ if (t) {
744
+ const r = t.closest(x);
745
+ if (r) return r;
746
+ const i = t.closest(ae);
747
+ if (i) {
748
+ const a = O(i);
749
+ if (a) return a;
750
+ }
751
+ const o = t.closest(`.${u}`);
752
+ if (o) {
753
+ const a = Array.from(m.entries()).find(([, l]) => l === o);
754
+ if (a) return a[0];
755
+ }
756
+ }
757
+ const n = window.getSelection();
758
+ if (n && n.rangeCount > 0) {
759
+ const r = re(n.getRangeAt(0).startContainer)?.closest(
760
+ x
761
+ );
762
+ if (r) return r;
763
+ }
764
+ return null;
765
+ }
766
+ function pt() {
767
+ if (typeof document > "u" || document.getElementById(we)) return;
768
+ const e = document.createElement("style");
769
+ e.id = we, e.textContent = `
770
+ .rte-toolbar-group-items.${k},
771
+ .editora-toolbar-group-items.${k},
772
+ .rte-toolbar-group-items.${v},
773
+ .editora-toolbar-group-items.${v} {
774
+ display: flex;
775
+ border: 1px solid #ccc;
776
+ border-radius: 3px;
777
+ background: #fff;
778
+ }
779
+
780
+ .rte-toolbar-group-items.${k} .rte-toolbar-button,
781
+ .editora-toolbar-group-items.${k} .editora-toolbar-button,
782
+ .rte-toolbar-group-items.${v} .rte-toolbar-button,
783
+ .editora-toolbar-group-items.${v} .editora-toolbar-button {
784
+ border: none;
785
+ border-radius: 0;
786
+ border-right: 1px solid #ccc;
787
+ }
788
+
789
+ .rte-toolbar-group-items.${k} .rte-toolbar-item:last-child .rte-toolbar-button,
790
+ .editora-toolbar-group-items.${k} .editora-toolbar-item:last-child .editora-toolbar-button,
791
+ .rte-toolbar-group-items.${v} .rte-toolbar-item:last-child .rte-toolbar-button,
792
+ .editora-toolbar-group-items.${v} .editora-toolbar-item:last-child .editora-toolbar-button {
793
+ border-right: none;
794
+ }
795
+
796
+ .rte-toolbar-button[data-command="togglePIIRealtime"].active,
797
+ .editora-toolbar-button[data-command="togglePIIRealtime"].active {
798
+ background-color: #ccc;
799
+ }
800
+
801
+ ${$} .rte-toolbar-group-items.${k},
802
+ ${$} .editora-toolbar-group-items.${k},
803
+ ${$} .rte-toolbar-group-items.${v},
804
+ ${$} .editora-toolbar-group-items.${v},
805
+ .${u}.rte-pii-redaction-theme-dark {
806
+ border-color: #566275;
807
+ }
808
+ ${$} .rte-toolbar-group-items.${k} .rte-toolbar-button svg,
809
+ ${$} .editora-toolbar-group-items.${k} .editora-toolbar-button svg,
810
+ ${$} .rte-toolbar-group-items.${v} .rte-toolbar-button svg,
811
+ ${$} .editora-toolbar-group-items.${v} .editora-toolbar-button svg
812
+ {
813
+ fill: none;
814
+ }
815
+ ${$} .rte-toolbar-group-items.${k} .rte-toolbar-button,
816
+ ${$} .editora-toolbar-group-items.${k} .editora-toolbar-button
817
+ {
818
+ border-color: #566275;
819
+ }
820
+ .${u} {
821
+ position: fixed;
822
+ z-index: 12000;
823
+ display: none;
824
+ width: min(390px, calc(100vw - 20px));
825
+ max-height: calc(100vh - 20px);
826
+ border: 1px solid #d1d5db;
827
+ border-radius: 14px;
828
+ background: #ffffff;
829
+ color: #111827;
830
+ box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
831
+ overflow: hidden;
832
+ }
833
+
834
+ .${u}.show {
835
+ display: flex;
836
+ flex-direction: column;
837
+ }
838
+
839
+ .${u}.rte-pii-redaction-theme-dark {
840
+ border-color: #334155;
841
+ background: #0f172a;
842
+ color: #e2e8f0;
843
+ box-shadow: 0 20px 46px rgba(2, 6, 23, 0.68);
844
+ }
845
+
846
+ .rte-pii-redaction-header {
847
+ display: flex;
848
+ align-items: center;
849
+ justify-content: space-between;
850
+ gap: 8px;
851
+ padding: 12px 14px;
852
+ border-bottom: 1px solid #e5e7eb;
853
+ background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
854
+ }
855
+
856
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-header {
857
+ border-color: #1e293b;
858
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
859
+ }
860
+
861
+ .rte-pii-redaction-title {
862
+ margin: 0;
863
+ font-size: 15px;
864
+ line-height: 1.2;
865
+ font-weight: 700;
866
+ }
867
+
868
+ .rte-pii-redaction-icon-btn {
869
+ width: 34px;
870
+ height: 34px;
871
+ border: 1px solid #cbd5e1;
872
+ border-radius: 6px;
873
+ background: #ffffff;
874
+ color: #0f172a;
875
+ font-size: 16px;
876
+ line-height: 1;
877
+ font-weight: 600;
878
+ padding: 0;
879
+ display: inline-flex;
880
+ align-items: center;
881
+ justify-content: center;
882
+ cursor: pointer;
883
+ }
884
+
885
+ .rte-pii-redaction-icon-btn:hover,
886
+ .rte-pii-redaction-icon-btn:focus-visible {
887
+ outline: none;
888
+ border-color: #3b82f6;
889
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
890
+ }
891
+
892
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-icon-btn {
893
+ background: #0f172a;
894
+ border-color: #475569;
895
+ color: #e2e8f0;
896
+ }
897
+
898
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-icon-btn:hover,
899
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-icon-btn:focus-visible {
900
+ border-color: #60a5fa;
901
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
902
+ }
903
+
904
+ .rte-pii-redaction-body {
905
+ display: flex;
906
+ flex-direction: column;
907
+ gap: 10px;
908
+ padding: 12px;
909
+ overflow: auto;
910
+ }
911
+
912
+ .rte-pii-redaction-topline {
913
+ display: flex;
914
+ align-items: center;
915
+ justify-content: space-between;
916
+ gap: 8px;
917
+ }
918
+
919
+ .rte-pii-redaction-summary {
920
+ margin: 0;
921
+ font-size: 12px;
922
+ line-height: 1.35;
923
+ color: #475569;
924
+ flex: 1;
925
+ }
926
+
927
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-summary {
928
+ color: #94a3b8;
929
+ }
930
+
931
+ .rte-pii-redaction-count {
932
+ min-width: 32px;
933
+ height: 32px;
934
+ border-radius: 999px;
935
+ display: inline-flex;
936
+ align-items: center;
937
+ justify-content: center;
938
+ font-weight: 700;
939
+ font-size: 13px;
940
+ border: 1px solid #cbd5e1;
941
+ background: #f8fafc;
942
+ }
943
+
944
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-count {
945
+ border-color: #334155;
946
+ background: #111827;
947
+ color: #cbd5e1;
948
+ }
949
+
950
+ .rte-pii-redaction-controls {
951
+ display: flex;
952
+ gap: 8px;
953
+ flex-wrap: wrap;
954
+ }
955
+
956
+ .rte-pii-redaction-btn {
957
+ border: 1px solid #cbd5e1;
958
+ border-radius: 8px;
959
+ height: 34px;
960
+ padding: 0 10px;
961
+ background: #ffffff;
962
+ color: inherit;
963
+ font-size: 12px;
964
+ font-weight: 600;
965
+ cursor: pointer;
966
+ }
967
+
968
+ .rte-pii-redaction-btn:hover,
969
+ .rte-pii-redaction-btn:focus-visible {
970
+ border-color: #94a3b8;
971
+ background: #f8fafc;
972
+ outline: none;
973
+ }
974
+
975
+ .rte-pii-redaction-btn:disabled {
976
+ opacity: 0.56;
977
+ cursor: not-allowed;
978
+ }
979
+
980
+ .rte-pii-redaction-btn-primary {
981
+ border-color: #0284c7;
982
+ background: #0ea5e9;
983
+ color: #f8fafc;
984
+ }
985
+
986
+ .rte-pii-redaction-btn-primary:hover,
987
+ .rte-pii-redaction-btn-primary:focus-visible {
988
+ border-color: #0369a1;
989
+ background: #0284c7;
990
+ color: #ffffff;
991
+ }
992
+
993
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-btn {
994
+ border-color: #334155;
995
+ background: #111827;
996
+ color: #e2e8f0;
997
+ }
998
+
999
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-btn:hover,
1000
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-btn:focus-visible {
1001
+ border-color: #475569;
1002
+ background: #1e293b;
1003
+ }
1004
+
1005
+ .rte-pii-redaction-list {
1006
+ list-style: none;
1007
+ margin: 0;
1008
+ padding: 0;
1009
+ display: flex;
1010
+ flex-direction: column;
1011
+ gap: 8px;
1012
+ max-height: min(55vh, 420px);
1013
+ overflow: auto;
1014
+ }
1015
+
1016
+ .rte-pii-redaction-item {
1017
+ border: 1px solid #e2e8f0;
1018
+ border-radius: 10px;
1019
+ padding: 8px;
1020
+ background: #ffffff;
1021
+ display: grid;
1022
+ gap: 6px;
1023
+ }
1024
+
1025
+ .rte-pii-redaction-item-high {
1026
+ border-color: #fca5a5;
1027
+ background: #fef2f2;
1028
+ }
1029
+
1030
+ .rte-pii-redaction-item-medium {
1031
+ border-color: #fcd34d;
1032
+ background: #fffbeb;
1033
+ }
1034
+
1035
+ .rte-pii-redaction-item-low {
1036
+ border-color: #93c5fd;
1037
+ background: #eff6ff;
1038
+ }
1039
+
1040
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item {
1041
+ border-color: #334155;
1042
+ background: #0b1220;
1043
+ }
1044
+
1045
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item-high {
1046
+ border-color: #7f1d1d;
1047
+ background: #2b0b11;
1048
+ }
1049
+
1050
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item-medium {
1051
+ border-color: #78350f;
1052
+ background: #2b1907;
1053
+ }
1054
+
1055
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-item-low {
1056
+ border-color: #1d4ed8;
1057
+ background: #0a162f;
1058
+ }
1059
+
1060
+ .rte-pii-redaction-item-btn {
1061
+ border: none;
1062
+ background: transparent;
1063
+ width: 100%;
1064
+ display: flex;
1065
+ align-items: center;
1066
+ gap: 8px;
1067
+ text-align: left;
1068
+ padding: 0;
1069
+ color: inherit;
1070
+ cursor: pointer;
1071
+ }
1072
+
1073
+ .rte-pii-redaction-item-btn:focus-visible {
1074
+ outline: 2px solid #0284c7;
1075
+ outline-offset: 3px;
1076
+ border-radius: 6px;
1077
+ }
1078
+
1079
+ .rte-pii-redaction-badge {
1080
+ border-radius: 999px;
1081
+ border: 1px solid currentColor;
1082
+ padding: 1px 8px;
1083
+ font-size: 10px;
1084
+ font-weight: 700;
1085
+ line-height: 1.3;
1086
+ text-transform: uppercase;
1087
+ opacity: 0.86;
1088
+ }
1089
+
1090
+ .rte-pii-redaction-type {
1091
+ font-size: 12px;
1092
+ font-weight: 700;
1093
+ letter-spacing: 0.03em;
1094
+ }
1095
+
1096
+ .rte-pii-redaction-line,
1097
+ .rte-pii-redaction-help {
1098
+ margin: 0;
1099
+ font-size: 12px;
1100
+ line-height: 1.35;
1101
+ color: #334155;
1102
+ word-break: break-word;
1103
+ }
1104
+
1105
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-line,
1106
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-help {
1107
+ color: #94a3b8;
1108
+ }
1109
+
1110
+ .rte-pii-redaction-item-actions {
1111
+ display: flex;
1112
+ justify-content: flex-end;
1113
+ }
1114
+
1115
+ .rte-pii-redaction-empty {
1116
+ border: 1px dashed #cbd5e1;
1117
+ border-radius: 10px;
1118
+ padding: 10px;
1119
+ font-size: 13px;
1120
+ color: #475569;
1121
+ background: #f8fafc;
1122
+ }
1123
+
1124
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-empty {
1125
+ border-color: #334155;
1126
+ background: #0b1220;
1127
+ color: #94a3b8;
1128
+ }
1129
+
1130
+ .rte-pii-redaction-shortcut {
1131
+ margin: 2px 0 0;
1132
+ font-size: 11px;
1133
+ color: #64748b;
1134
+ }
1135
+
1136
+ .${u}.rte-pii-redaction-theme-dark .rte-pii-redaction-shortcut {
1137
+ color: #94a3b8;
1138
+ }
1139
+
1140
+ .rte-pii-redaction-live {
1141
+ position: absolute;
1142
+ width: 1px;
1143
+ height: 1px;
1144
+ margin: -1px;
1145
+ padding: 0;
1146
+ overflow: hidden;
1147
+ clip: rect(0 0 0 0);
1148
+ border: 0;
1149
+ }
1150
+
1151
+ @media (max-width: 768px) {
1152
+ .${u} {
1153
+ left: 10px !important;
1154
+ right: 10px;
1155
+ top: 10px !important;
1156
+ width: auto !important;
1157
+ max-height: calc(100vh - 20px);
1158
+ }
1159
+
1160
+ .rte-pii-redaction-list {
1161
+ max-height: 45vh;
1162
+ }
1163
+ }
1164
+ `, document.head.appendChild(e);
1165
+ }
1166
+ function bt(e) {
1167
+ A = e, P || (P = (t) => {
1168
+ K();
1169
+ const r = t.target?.closest(x);
1170
+ if (!r) return;
1171
+ g = r;
1172
+ const i = f.get(r) || e;
1173
+ w(r, i), f.set(r, i), C(r, "togglePIIRedactionPanel", oe(r)), C(r, "togglePIIRealtime", F(r, i));
1174
+ const o = m.get(r);
1175
+ o && (ne(o, r), fe(r, o), z(r, o, i));
1176
+ }, document.addEventListener("focusin", P, !0)), L || (L = (t) => {
1177
+ const r = t.target?.closest(x);
1178
+ r && (g = r, _e(r));
1179
+ }, document.addEventListener("input", L, !0)), D || (D = (t) => {
1180
+ if (t.defaultPrevented || t.target?.closest(`.${u} input, .${u} textarea, .${u} select`)) return;
1181
+ const r = ft(t);
1182
+ if (!r) return;
1183
+ const i = f.get(r) || A || e;
1184
+ if (w(r, i), f.set(r, i), g = r, t.key === "Escape" && oe(r)) {
1185
+ t.preventDefault(), j(r, !0);
1186
+ return;
1187
+ }
1188
+ if (ct(t)) {
1189
+ t.preventDefault(), t.stopPropagation(), Pe(r);
1190
+ return;
1191
+ }
1192
+ if (st(t)) {
1193
+ t.preventDefault(), t.stopPropagation(), h(r, i, !0), N(r);
1194
+ return;
1195
+ }
1196
+ if (dt(t)) {
1197
+ t.preventDefault(), t.stopPropagation(), V(r) || (xe(r, i), N(r));
1198
+ return;
1199
+ }
1200
+ if (ut(t)) {
1201
+ t.preventDefault(), t.stopPropagation();
1202
+ const o = !F(r, i);
1203
+ S.set(r, o);
1204
+ const a = m.get(r);
1205
+ a && z(r, a, i), C(r, "togglePIIRealtime", o), o && h(r, i, !0);
1206
+ }
1207
+ }, document.addEventListener("keydown", D, !0)), R || (R = () => {
1208
+ K(), m.forEach((t, n) => {
1209
+ !n.isConnected || !t.isConnected || (ne(t, n), fe(n, t));
1210
+ });
1211
+ }, window.addEventListener("scroll", R, !0), window.addEventListener("resize", R)), !_ && typeof MutationObserver < "u" && document.body && (_ = new MutationObserver((t) => {
1212
+ Ue(t) && K();
1213
+ }), _.observe(document.body, {
1214
+ childList: !0,
1215
+ subtree: !0
1216
+ }));
1217
+ }
1218
+ function gt() {
1219
+ P && (document.removeEventListener("focusin", P, !0), P = null), L && (document.removeEventListener("input", L, !0), L = null), D && (document.removeEventListener("keydown", D, !0), D = null), R && (window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R), R = null), _ && (_.disconnect(), _ = null), m.forEach((e) => e.remove()), m.clear(), q.forEach((e) => me(e)), q.clear(), A = null, g = null;
1220
+ }
1221
+ const mt = (e = {}) => {
1222
+ const t = ee(e), n = /* @__PURE__ */ new Set();
1223
+ return pt(), {
1224
+ name: "piiRedaction",
1225
+ toolbar: [
1226
+ {
1227
+ id: "piiRedactionGroup",
1228
+ label: "PII Redaction",
1229
+ type: "group",
1230
+ command: "piiRedaction",
1231
+ items: [
1232
+ {
1233
+ id: "piiRedaction",
1234
+ label: "PII Redaction",
1235
+ command: "togglePIIRedactionPanel",
1236
+ shortcut: "Mod-Alt-Shift-i",
1237
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 19 6.5v4.8c0 4.4-2.7 8.1-7 9.2-4.3-1.1-7-4.8-7-9.2V6.5l7-3Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M8.8 11.6h6.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="11.6" r="1.2" fill="currentColor"/></svg>'
1238
+ },
1239
+ {
1240
+ id: "piiScan",
1241
+ label: "Scan PII",
1242
+ command: "runPIIScan",
1243
+ shortcut: "Mod-Alt-Shift-u",
1244
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4.5" y="3.5" width="11" height="15" rx="2" stroke="currentColor" stroke-width="1.6"/><path d="M7.5 8.2h5M7.5 11.2h5M7.5 14.2h3.2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="16.8" cy="16.8" r="2.8" stroke="currentColor" stroke-width="1.6"/><path d="m18.8 18.8 2 2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'
1245
+ },
1246
+ {
1247
+ id: "piiRedactAll",
1248
+ label: "Redact All PII",
1249
+ command: "redactAllPII",
1250
+ shortcut: "Mod-Alt-Shift-m",
1251
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 18h14" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M7 6h10l-1 8H8L7 6Z" stroke="currentColor" stroke-width="1.7"/><path d="m9 9 6 4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>'
1252
+ },
1253
+ {
1254
+ id: "piiRealtime",
1255
+ label: "Toggle Realtime PII Scan",
1256
+ command: "togglePIIRealtime",
1257
+ shortcut: "Mod-Alt-Shift-y",
1258
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4 12h4M16 12h4" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.7"/></svg>'
1259
+ }
1260
+ ]
1261
+ }
1262
+ ],
1263
+ commands: {
1264
+ piiRedaction: (r, i) => {
1265
+ const o = T(i);
1266
+ if (!o) return !1;
1267
+ const a = f.get(o) || t;
1268
+ return w(o, a), f.set(o, a), g = o, N(o), h(o, a, !1), !0;
1269
+ },
1270
+ togglePIIRedactionPanel: (r, i) => {
1271
+ const o = T(i);
1272
+ if (!o) return !1;
1273
+ const a = f.get(o) || t;
1274
+ w(o, a), f.set(o, a), g = o;
1275
+ const l = Pe(o, typeof r == "boolean" ? r : void 0);
1276
+ return oe(o) && h(o, a, !1), l;
1277
+ },
1278
+ runPIIScan: async (r, i) => {
1279
+ const o = T(i);
1280
+ if (!o) return !1;
1281
+ const a = f.get(o) || t;
1282
+ return w(o, a), f.set(o, a), g = o, await h(o, a, !0), N(o), !0;
1283
+ },
1284
+ redactAllPII: async (r, i) => {
1285
+ const o = T(i);
1286
+ if (!o) return !1;
1287
+ const a = f.get(o) || t;
1288
+ w(o, a), f.set(o, a), g = o;
1289
+ const l = await xe(o, a);
1290
+ return l > 0 && N(o), l > 0;
1291
+ },
1292
+ redactPIIFinding: async (r, i) => {
1293
+ const o = T(i);
1294
+ if (!o || typeof r != "string" || !r) return !1;
1295
+ const a = f.get(o) || t;
1296
+ return w(o, a), f.set(o, a), g = o, De(o, r, a);
1297
+ },
1298
+ togglePIIRealtime: (r, i) => {
1299
+ const o = T(i);
1300
+ if (!o) return !1;
1301
+ const a = f.get(o) || t;
1302
+ w(o, a), f.set(o, a);
1303
+ const l = typeof r == "boolean" ? r : !F(o, a);
1304
+ S.set(o, l);
1305
+ const c = m.get(o);
1306
+ return c && z(o, c, a), C(o, "togglePIIRealtime", l), l && h(o, a, !0), !0;
1307
+ },
1308
+ getPIIRedactionFindings: (r, i) => {
1309
+ const o = T(i);
1310
+ if (!o) return !1;
1311
+ const a = I.get(o) || [], l = E.get(o) || le(0), c = a.map((s) => ({ ...s })), d = {
1312
+ ...l,
1313
+ byType: { ...l.byType }
1314
+ };
1315
+ if (typeof r == "function")
1316
+ try {
1317
+ r(c, d);
1318
+ } catch {
1319
+ }
1320
+ return o.__piiRedactionFindings = c, o.dispatchEvent(
1321
+ new CustomEvent("editora:pii-findings", {
1322
+ bubbles: !0,
1323
+ detail: { findings: c, stats: d }
1324
+ })
1325
+ ), !0;
1326
+ },
1327
+ setPIIRedactionOptions: (r, i) => {
1328
+ const o = T(i);
1329
+ if (!o || !r || typeof r != "object") return !1;
1330
+ const a = f.get(o) || t, l = ee({
1331
+ ...ce(a),
1332
+ ...r,
1333
+ labels: {
1334
+ ...a.labels,
1335
+ ...r.labels || {}
1336
+ },
1337
+ detectors: {
1338
+ ...ce(a).detectors || {},
1339
+ ...r.detectors || {}
1340
+ },
1341
+ normalizeText: r.normalizeText || a.normalizeText
1342
+ });
1343
+ f.set(o, l), typeof r.enableRealtime == "boolean" && S.set(o, r.enableRealtime);
1344
+ const c = m.get(o);
1345
+ return c && (nt(c, l), H(o), z(o, c, l)), h(o, l, !0), !0;
1346
+ }
1347
+ },
1348
+ keymap: {
1349
+ "Mod-Alt-Shift-i": "togglePIIRedactionPanel",
1350
+ "Mod-Alt-Shift-I": "togglePIIRedactionPanel",
1351
+ "Mod-Alt-Shift-u": "runPIIScan",
1352
+ "Mod-Alt-Shift-U": "runPIIScan",
1353
+ "Mod-Alt-Shift-m": "redactAllPII",
1354
+ "Mod-Alt-Shift-M": "redactAllPII",
1355
+ "Mod-Alt-Shift-y": "togglePIIRealtime",
1356
+ "Mod-Alt-Shift-Y": "togglePIIRealtime"
1357
+ },
1358
+ init: function(i) {
1359
+ G += 1;
1360
+ const o = this && typeof this.__pluginConfig == "object" ? ee({ ...ce(t), ...this.__pluginConfig }) : t;
1361
+ bt(o);
1362
+ const a = T(
1363
+ i?.editorElement ? { editorElement: i.editorElement } : void 0,
1364
+ !1
1365
+ );
1366
+ a && (g = a, n.add(a), w(a, o), f.set(a, o), C(a, "togglePIIRedactionPanel", !1), C(a, "togglePIIRealtime", o.enableRealtime), o.enableRealtime && _e(a));
1367
+ },
1368
+ destroy: () => {
1369
+ n.forEach((r) => Ie(r)), n.clear(), G = Math.max(0, G - 1), !(G > 0) && (W.forEach((r) => {
1370
+ window.clearTimeout(r);
1371
+ }), W.clear(), gt());
1372
+ }
1373
+ };
1374
+ };
1375
+ export {
1376
+ mt as PIIRedactionPlugin
1377
+ };