@editora/plugins 1.0.8 → 1.0.10

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 (141) hide show
  1. package/README.md +27 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +447 -0
  11. package/dist/approval-workflow.esm.js +1111 -0
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +442 -0
  16. package/dist/blocks-library.esm.js +1384 -0
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +548 -0
  21. package/dist/citations.esm.js +1530 -0
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +626 -0
  31. package/dist/conditional-content.esm.js +1421 -0
  32. package/dist/content-rules.cjs.js +408 -0
  33. package/dist/content-rules.esm.js +1147 -0
  34. package/dist/data-binding.cjs.js +321 -0
  35. package/dist/data-binding.esm.js +953 -0
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +398 -0
  38. package/dist/doc-schema.esm.js +1378 -0
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -0
  49. package/dist/enterprise.esm.js +58 -0
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +124 -93
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +105 -0
  87. package/dist/mentions.esm.js +774 -0
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +67 -51
  92. package/dist/pii-redaction.cjs.js +436 -0
  93. package/dist/pii-redaction.esm.js +1447 -0
  94. package/dist/preview.cjs.js +3 -3
  95. package/dist/preview.esm.js +37 -32
  96. package/dist/print.cjs.js +4 -4
  97. package/dist/print.esm.js +20 -17
  98. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  99. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  100. package/dist/slash-commands.cjs.js +90 -0
  101. package/dist/slash-commands.esm.js +788 -0
  102. package/dist/smart-paste.cjs.js +398 -0
  103. package/dist/smart-paste.esm.js +1444 -0
  104. package/dist/special-characters.cjs.js +7 -7
  105. package/dist/special-characters.esm.js +69 -61
  106. package/dist/spell-check.cjs.js +5 -5
  107. package/dist/spell-check.esm.js +123 -97
  108. package/dist/strikethrough.cjs.js +1 -1
  109. package/dist/strikethrough.esm.js +19 -14
  110. package/dist/style.css +1 -0
  111. package/dist/table.cjs.js +4 -4
  112. package/dist/table.esm.js +225 -191
  113. package/dist/template.cjs.js +11 -11
  114. package/dist/template.esm.js +153 -124
  115. package/dist/text-alignment.cjs.js +1 -1
  116. package/dist/text-alignment.esm.js +27 -21
  117. package/dist/text-color.cjs.js +3 -3
  118. package/dist/text-color.esm.js +87 -70
  119. package/dist/track-changes.cjs.js +77 -0
  120. package/dist/track-changes.esm.js +817 -0
  121. package/dist/translation-workflow.cjs.js +626 -0
  122. package/dist/translation-workflow.esm.js +1794 -0
  123. package/dist/version-diff.cjs.js +362 -0
  124. package/dist/version-diff.esm.js +797 -0
  125. package/index.d.ts +798 -0
  126. package/package.json +114 -9
  127. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  128. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  129. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  130. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  131. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  132. package/dist/documentManager-Jf0RbSks.js +0 -17
  133. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  134. package/dist/index-CvJk4DKa.js +0 -221
  135. package/dist/index-D3CycEFU.mjs +0 -16543
  136. package/dist/index-tqLTHcO6.js +0 -1
  137. package/dist/index.es-CE_A4QSm.js +0 -5
  138. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  139. package/dist/jspdf.es.min-BoS80556.js +0 -77
  140. package/dist/plugins.css +0 -1
  141. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -0,0 +1,1147 @@
1
+ const R = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", oe = "__editoraCommandEditorRoot", se = "rte-content-rules-styles", f = "rte-content-rules-panel", q = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', he = {
2
+ panelTitle: "Content Rules",
3
+ panelAriaLabel: "Content rules panel",
4
+ runAuditText: "Run Audit",
5
+ realtimeOnText: "Realtime On",
6
+ realtimeOffText: "Realtime Off",
7
+ closeText: "Close",
8
+ noIssuesText: "No rule violations detected.",
9
+ summaryPrefix: "Issues",
10
+ locateText: "Locate",
11
+ bannedWordMessage: "Banned word found",
12
+ requiredHeadingMessage: "Missing required heading",
13
+ sentenceLengthMessage: "Sentence is too long",
14
+ readabilityMessage: "Readability score is below threshold"
15
+ }, d = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
16
+ let N = 0, pe = 0, E = null, g = null, L = null, I = null, H = null, S = null;
17
+ function k(e) {
18
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
19
+ }
20
+ function xe(e) {
21
+ return {
22
+ ...he,
23
+ ...e || {}
24
+ };
25
+ }
26
+ function ye(e) {
27
+ return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
28
+ }
29
+ function ae(e) {
30
+ if (!e)
31
+ return [];
32
+ const t = /* @__PURE__ */ new Set();
33
+ return e.forEach((n) => {
34
+ const o = n.trim();
35
+ o && t.add(o);
36
+ }), Array.from(t);
37
+ }
38
+ function j(e = {}) {
39
+ return {
40
+ bannedWords: ae(e.bannedWords),
41
+ requiredHeadings: ae(e.requiredHeadings),
42
+ maxSentenceWords: Math.max(8, Number(e.maxSentenceWords ?? 32)),
43
+ minReadabilityScore: Math.max(0, Math.min(120, Number(e.minReadabilityScore ?? 55))),
44
+ maxIssues: Math.max(1, Number(e.maxIssues ?? 100)),
45
+ debounceMs: Math.max(50, Number(e.debounceMs ?? 220)),
46
+ enableRealtime: e.enableRealtime !== !1,
47
+ labels: xe(e.labels),
48
+ normalizeText: e.normalizeText || ye,
49
+ customRules: Array.isArray(e.customRules) ? e.customRules : []
50
+ };
51
+ }
52
+ function X(e) {
53
+ return e.closest(ee) || e;
54
+ }
55
+ function F(e) {
56
+ if (!e)
57
+ return null;
58
+ if (e.matches(R))
59
+ return e;
60
+ const t = e.querySelector(R);
61
+ return t instanceof HTMLElement ? t : null;
62
+ }
63
+ function we() {
64
+ if (typeof window > "u")
65
+ return null;
66
+ const e = window[oe];
67
+ if (!(e instanceof HTMLElement))
68
+ return null;
69
+ window[oe] = null;
70
+ const t = F(e);
71
+ if (t)
72
+ return t;
73
+ const n = e.closest(ee);
74
+ if (n) {
75
+ const o = F(n);
76
+ if (o)
77
+ return o;
78
+ }
79
+ return null;
80
+ }
81
+ function ke(e) {
82
+ const t = e.closest("[data-editora-editor]");
83
+ if (t && F(t) === e)
84
+ return t;
85
+ let n = e;
86
+ for (; n; ) {
87
+ if (n.matches(ee) && (n === e || F(n) === e))
88
+ return n;
89
+ n = n.parentElement;
90
+ }
91
+ return X(e);
92
+ }
93
+ function K(e) {
94
+ 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;
95
+ }
96
+ function Re(e) {
97
+ const t = X(e);
98
+ if (K(t))
99
+ return !0;
100
+ const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
101
+ return K(n) ? !0 : K(document.documentElement) || K(document.body);
102
+ }
103
+ function G(e, t) {
104
+ e.classList.remove("rte-content-rules-theme-dark"), Re(t) && e.classList.add("rte-content-rules-theme-dark");
105
+ }
106
+ function Ee(e) {
107
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
108
+ }
109
+ function M(e, t = !0) {
110
+ if ((e == null ? void 0 : e.contentElement) instanceof HTMLElement)
111
+ return e.contentElement;
112
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
113
+ const s = e.editorElement;
114
+ if (s.matches(R))
115
+ return s;
116
+ const a = s.querySelector(R);
117
+ if (a instanceof HTMLElement)
118
+ return a;
119
+ }
120
+ const n = we();
121
+ if (n)
122
+ return n;
123
+ const o = window.getSelection();
124
+ if (o && o.rangeCount > 0) {
125
+ const s = o.getRangeAt(0).startContainer, a = Ee(s), l = a == null ? void 0 : a.closest(R);
126
+ if (l)
127
+ return l;
128
+ }
129
+ const r = document.activeElement;
130
+ if (r) {
131
+ if (r.matches(R))
132
+ return r;
133
+ const s = r.closest(R);
134
+ if (s)
135
+ return s;
136
+ }
137
+ return g && g.isConnected ? g : (g && !g.isConnected && (g = null), t ? document.querySelector(R) : null);
138
+ }
139
+ function Z(e) {
140
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
141
+ }
142
+ function Ce(e, t) {
143
+ const n = e.innerText || e.textContent || "";
144
+ return t(n);
145
+ }
146
+ function ve(e) {
147
+ return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
148
+ }
149
+ function ie(e) {
150
+ let t = 2166136261;
151
+ for (let n = 0; n < e.length; n += 1)
152
+ t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
153
+ return t >>> 0;
154
+ }
155
+ function ce(e) {
156
+ const t = e.match(/\b[\w'-]+\b/g);
157
+ return t ? t.length : 0;
158
+ }
159
+ function fe(e) {
160
+ const t = e.match(/[^.!?]+[.!?]*/g);
161
+ return t ? t.map((n) => n.trim()).filter(Boolean).length : 0;
162
+ }
163
+ function $e(e) {
164
+ const t = e.toLowerCase().replace(/[^a-z]/g, "");
165
+ if (!t)
166
+ return 0;
167
+ if (t.length <= 3)
168
+ return 1;
169
+ const n = t.match(/[aeiouy]+/g);
170
+ let o = n ? n.length : 1;
171
+ return t.endsWith("e") && (o -= 1), Math.max(1, o);
172
+ }
173
+ function Me(e) {
174
+ const t = e.match(/\b[\w'-]+\b/g) || [], n = t.length;
175
+ if (n === 0)
176
+ return 100;
177
+ const o = Math.max(1, fe(e)), r = t.reduce((a, l) => a + $e(l), 0), s = 206.835 - 1.015 * (n / o) - 84.6 * (r / Math.max(1, n));
178
+ return Number.isFinite(s) ? Math.max(0, Math.min(120, s)) : 0;
179
+ }
180
+ function z(e, t) {
181
+ return `${e}-${t}`;
182
+ }
183
+ function x(e, t) {
184
+ return e.length >= t;
185
+ }
186
+ function P(e, t, n) {
187
+ x(e, n) || e.push(t);
188
+ }
189
+ function ge(e, t = 140) {
190
+ return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
191
+ }
192
+ function Se(e, t, n, o) {
193
+ return {
194
+ id: e.id || z(t, o),
195
+ ruleId: e.ruleId || t,
196
+ severity: e.severity || n,
197
+ message: e.message || t,
198
+ excerpt: e.excerpt ? ge(e.excerpt, 220) : void 0,
199
+ suggestion: e.suggestion,
200
+ locateText: e.locateText,
201
+ selector: e.selector
202
+ };
203
+ }
204
+ function Te(e, t) {
205
+ const n = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), o = /* @__PURE__ */ new Set();
206
+ return n.forEach((r) => {
207
+ const s = t(r.textContent || "").toLowerCase();
208
+ s && o.add(s);
209
+ }), o;
210
+ }
211
+ function Ae(e) {
212
+ const t = e.match(/[^.!?\n]+[.!?]?/g);
213
+ return t ? t.map((n) => n.trim()).filter(Boolean) : [];
214
+ }
215
+ async function C(e, t, n = !1) {
216
+ const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${ie(o)}:${r.length}:${ie(r)}`;
217
+ if (!n && le.get(e) === s)
218
+ return v.get(e) || [];
219
+ const a = (Y.get(e) || 0) + 1;
220
+ Y.set(e, a);
221
+ const l = ce(o), c = fe(o), u = Me(o), i = [], y = t.labels;
222
+ if (t.bannedWords.length > 0) {
223
+ let w = 0;
224
+ for (const p of t.bannedWords) {
225
+ const m = new RegExp(`\\b${ve(p)}\\b`, "gi");
226
+ let b = m.exec(o);
227
+ for (; b && !x(i, t.maxIssues); ) {
228
+ const re = b[0];
229
+ P(
230
+ i,
231
+ {
232
+ id: z("banned-word", w),
233
+ ruleId: "banned-word",
234
+ severity: "error",
235
+ message: `${y.bannedWordMessage}: "${re}"`,
236
+ locateText: re,
237
+ suggestion: "Replace or remove banned terms."
238
+ },
239
+ t.maxIssues
240
+ ), w += 1, b = m.exec(o);
241
+ }
242
+ if (x(i, t.maxIssues))
243
+ break;
244
+ }
245
+ }
246
+ if (!x(i, t.maxIssues) && t.requiredHeadings.length > 0) {
247
+ const w = Te(e, t.normalizeText);
248
+ let p = 0;
249
+ t.requiredHeadings.forEach((m) => {
250
+ if (x(i, t.maxIssues))
251
+ return;
252
+ const b = t.normalizeText(m).toLowerCase();
253
+ !b || w.has(b) || (P(
254
+ i,
255
+ {
256
+ id: z("required-heading", p),
257
+ ruleId: "required-heading",
258
+ severity: "warning",
259
+ message: `${y.requiredHeadingMessage}: "${m}"`,
260
+ suggestion: `Add a heading named "${m}".`
261
+ },
262
+ t.maxIssues
263
+ ), p += 1);
264
+ });
265
+ }
266
+ if (!x(i, t.maxIssues)) {
267
+ const w = Ae(o);
268
+ let p = 0;
269
+ for (const m of w) {
270
+ if (x(i, t.maxIssues))
271
+ break;
272
+ const b = ce(m);
273
+ b <= t.maxSentenceWords || (P(
274
+ i,
275
+ {
276
+ id: z("sentence-length", p),
277
+ ruleId: "sentence-length",
278
+ severity: "warning",
279
+ message: `${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,
280
+ excerpt: ge(m, 200),
281
+ locateText: m.slice(0, 64),
282
+ suggestion: "Split into shorter sentences for readability."
283
+ },
284
+ t.maxIssues
285
+ ), p += 1);
286
+ }
287
+ }
288
+ if (!x(i, t.maxIssues) && l > 0 && u < t.minReadabilityScore && P(
289
+ i,
290
+ {
291
+ id: z("readability", 0),
292
+ ruleId: "readability",
293
+ severity: "info",
294
+ message: `${y.readabilityMessage}: ${u.toFixed(1)} < ${t.minReadabilityScore}`,
295
+ suggestion: "Use shorter sentences and simpler wording."
296
+ },
297
+ t.maxIssues
298
+ ), !x(i, t.maxIssues) && t.customRules.length > 0) {
299
+ const w = {
300
+ editor: e,
301
+ editorRoot: X(e),
302
+ text: o,
303
+ html: r,
304
+ wordCount: l,
305
+ sentenceCount: c,
306
+ readabilityScore: u
307
+ };
308
+ for (const p of t.customRules) {
309
+ if (x(i, t.maxIssues))
310
+ break;
311
+ try {
312
+ const m = await p.evaluate(w);
313
+ if (!Array.isArray(m))
314
+ continue;
315
+ for (let b = 0; b < m.length && !x(i, t.maxIssues); b += 1)
316
+ P(
317
+ i,
318
+ Se(m[b], p.id, p.severity || "warning", b),
319
+ t.maxIssues
320
+ );
321
+ } catch {
322
+ }
323
+ }
324
+ }
325
+ if (Y.get(e) !== a)
326
+ return v.get(e) || [];
327
+ const D = {
328
+ readabilityScore: u,
329
+ wordCount: l,
330
+ sentenceCount: c
331
+ };
332
+ return le.set(e, s), v.set(e, i), de.set(e, D), te(e), e.dispatchEvent(
333
+ new CustomEvent("editora:content-rules-audit", {
334
+ bubbles: !0,
335
+ detail: {
336
+ issues: i,
337
+ metrics: D
338
+ }
339
+ })
340
+ ), i;
341
+ }
342
+ function Le(e) {
343
+ return e.reduce(
344
+ (t, n) => (t[n.severity] += 1, t),
345
+ { error: 0, warning: 0, info: 0 }
346
+ );
347
+ }
348
+ function Ie(e) {
349
+ return e === "error" ? "Error" : e === "warning" ? "Warning" : "Info";
350
+ }
351
+ function $(e, t, n) {
352
+ const o = ke(e);
353
+ Array.from(
354
+ o.querySelectorAll(
355
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
356
+ )
357
+ ).forEach((s) => {
358
+ s.classList.toggle("active", n), s.setAttribute("data-active", n ? "true" : "false"), s.setAttribute("aria-pressed", n ? "true" : "false");
359
+ });
360
+ }
361
+ function U(e) {
362
+ return B.get(e) === !0;
363
+ }
364
+ function J(e, t) {
365
+ if (!t.classList.contains("show"))
366
+ return;
367
+ const o = X(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 360);
368
+ t.style.width = `${r}px`, t.style.maxHeight = `${Math.max(220, window.innerHeight - 24)}px`;
369
+ const s = Math.max(10, o.right - r), a = Math.max(10, window.innerWidth - r - 10), l = Math.min(s, a), c = Math.max(10, Math.min(window.innerHeight - 10 - 240, o.top + 10));
370
+ t.style.left = `${l}px`, t.style.top = `${c}px`;
371
+ }
372
+ function ue(e, t) {
373
+ const n = t.trim().toLowerCase();
374
+ if (!n)
375
+ return !1;
376
+ const o = window.getSelection();
377
+ if (!o)
378
+ return !1;
379
+ const r = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, null);
380
+ let s = r.nextNode();
381
+ for (; s; ) {
382
+ const l = s.data.toLowerCase().indexOf(n);
383
+ if (l !== -1) {
384
+ const c = document.createRange();
385
+ c.setStart(s, l), c.setEnd(s, Math.min(s.length, l + n.length)), o.removeAllRanges(), o.addRange(c);
386
+ const u = s.parentElement;
387
+ return u && u.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), e.focus({ preventScroll: !0 }), !0;
388
+ }
389
+ s = r.nextNode();
390
+ }
391
+ return !1;
392
+ }
393
+ function He(e, t) {
394
+ if (t.selector) {
395
+ const n = e.querySelector(t.selector);
396
+ if (n)
397
+ return n.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), n.focus({ preventScroll: !0 }), !0;
398
+ }
399
+ return !!(t.locateText && ue(e, t.locateText) || t.excerpt && ue(e, t.excerpt.slice(0, 64)));
400
+ }
401
+ function We(e, t) {
402
+ return (v.get(e) || []).find((o) => o.id === t);
403
+ }
404
+ function A(e, t) {
405
+ const n = T.get(e);
406
+ return typeof n == "boolean" ? n : t ? t.enableRealtime : !0;
407
+ }
408
+ function O(e, t, n) {
409
+ const o = t.querySelector('[data-action="toggle-realtime"]');
410
+ if (!o)
411
+ return;
412
+ const r = A(e, n);
413
+ o.textContent = r ? n.labels.realtimeOnText : n.labels.realtimeOffText, o.setAttribute("aria-pressed", r ? "true" : "false"), $(e, "toggleContentRulesRealtime", r);
414
+ }
415
+ function te(e) {
416
+ const t = h.get(e);
417
+ if (!t)
418
+ return;
419
+ const n = d.get(e) || E;
420
+ if (!n)
421
+ return;
422
+ const o = v.get(e) || [], r = de.get(e) || {
423
+ readabilityScore: 100,
424
+ wordCount: 0,
425
+ sentenceCount: 0
426
+ }, s = t.querySelector(".rte-content-rules-count"), a = t.querySelector(".rte-content-rules-summary"), l = t.querySelector(".rte-content-rules-list"), c = t.querySelector(".rte-content-rules-live");
427
+ if (!s || !a || !l || !c)
428
+ return;
429
+ const u = Le(o);
430
+ if (s.textContent = String(o.length), a.textContent = `${n.labels.summaryPrefix}: ${o.length} | Error ${u.error} | Warning ${u.warning} | Info ${u.info} | Readability ${r.readabilityScore.toFixed(1)}`, c.textContent = `${o.length} issues. ${u.error} errors, ${u.warning} warnings, ${u.info} info.`, o.length === 0) {
431
+ l.innerHTML = `<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;
432
+ return;
433
+ }
434
+ l.innerHTML = o.map((i) => {
435
+ const y = i.excerpt ? `<p class="rte-content-rules-excerpt">${k(i.excerpt)}</p>` : "", D = i.suggestion ? `<p class="rte-content-rules-suggestion">${k(i.suggestion)}</p>` : "", w = `${n.labels.locateText}: ${i.message}`;
436
+ return `
437
+ <li class="rte-content-rules-item rte-content-rules-item-${i.severity}">
438
+ <button
439
+ type="button"
440
+ class="rte-content-rules-item-btn"
441
+ data-action="focus-issue"
442
+ data-issue-id="${k(i.id)}"
443
+ data-role="issue-button"
444
+ aria-label="${k(w)}"
445
+ >
446
+ <span class="rte-content-rules-badge">${k(Ie(i.severity))}</span>
447
+ <span class="rte-content-rules-message">${k(i.message)}</span>
448
+ </button>
449
+ ${y}
450
+ ${D}
451
+ </li>
452
+ `;
453
+ }).join("");
454
+ }
455
+ function W(e, t = !1) {
456
+ const n = h.get(e);
457
+ n && (n.classList.remove("show"), B.set(e, !1), $(e, "toggleContentRulesPanel", !1), t && e.focus({ preventScroll: !0 }));
458
+ }
459
+ function Oe(e) {
460
+ h.forEach((t, n) => {
461
+ n !== e && W(n, !1);
462
+ });
463
+ }
464
+ function qe(e) {
465
+ const t = h.get(e);
466
+ if (t)
467
+ return t;
468
+ const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${pe++}`, r = document.createElement("section");
469
+ return r.className = f, r.id = o, r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "false"), r.setAttribute("aria-label", n.labels.panelAriaLabel), r.innerHTML = `
470
+ <header class="rte-content-rules-header">
471
+ <h2 class="rte-content-rules-title">${k(n.labels.panelTitle)}</h2>
472
+ <button type="button" class="rte-content-rules-icon-btn" data-action="close" aria-label="${k(n.labels.closeText)}">✕</button>
473
+ </header>
474
+ <div class="rte-content-rules-body">
475
+ <div class="rte-content-rules-topline">
476
+ <p class="rte-content-rules-summary" aria-live="polite"></p>
477
+ <span class="rte-content-rules-count" aria-hidden="true">0</span>
478
+ </div>
479
+ <div class="rte-content-rules-controls" role="toolbar" aria-label="Content rules controls">
480
+ <button type="button" class="rte-content-rules-btn rte-content-rules-btn-primary" data-action="run-audit">${k(n.labels.runAuditText)}</button>
481
+ <button type="button" class="rte-content-rules-btn" data-action="toggle-realtime" aria-pressed="false"></button>
482
+ </div>
483
+ <ul class="rte-content-rules-list" role="list" aria-label="Detected content rule issues"></ul>
484
+ <p class="rte-content-rules-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + R</p>
485
+ <span class="rte-content-rules-live" aria-live="polite"></span>
486
+ </div>
487
+ `, r.addEventListener("click", (s) => {
488
+ const a = s.target, l = a == null ? void 0 : a.closest("[data-action]");
489
+ if (!l)
490
+ return;
491
+ const c = l.getAttribute("data-action");
492
+ if (c) {
493
+ if (c === "close") {
494
+ W(e, !0);
495
+ return;
496
+ }
497
+ if (c === "run-audit") {
498
+ const u = d.get(e) || E || n;
499
+ C(e, u, !0);
500
+ return;
501
+ }
502
+ if (c === "toggle-realtime") {
503
+ const i = !A(e, d.get(e) || E || n);
504
+ if (T.set(e, i), O(e, r, d.get(e) || E || n), i) {
505
+ const y = d.get(e) || E || n;
506
+ C(e, y, !0);
507
+ }
508
+ return;
509
+ }
510
+ if (c === "focus-issue") {
511
+ const u = l.getAttribute("data-issue-id") || "", i = We(e, u);
512
+ if (!i)
513
+ return;
514
+ He(e, i), W(e, !1);
515
+ }
516
+ }
517
+ }), r.addEventListener("keydown", (s) => {
518
+ if (s.key === "Escape") {
519
+ s.preventDefault(), W(e, !0);
520
+ return;
521
+ }
522
+ if (s.key !== "ArrowDown" && s.key !== "ArrowUp")
523
+ return;
524
+ const a = Array.from(r.querySelectorAll('[data-role="issue-button"]'));
525
+ if (a.length === 0)
526
+ return;
527
+ const l = document.activeElement, c = a.findIndex((y) => y === l);
528
+ if (c === -1)
529
+ return;
530
+ s.preventDefault();
531
+ const u = s.key === "ArrowDown" ? 1 : -1, i = (c + u + a.length) % a.length;
532
+ a[i].focus();
533
+ }), G(r, e), document.body.appendChild(r), h.set(e, r), B.set(e, !1), O(e, r, n), r;
534
+ }
535
+ function ne(e) {
536
+ const t = qe(e);
537
+ Oe(e), t.classList.add("show"), B.set(e, !0), G(t, e), J(e, t), te(e), $(e, "toggleContentRulesPanel", !0);
538
+ const n = t.querySelector('[data-action="run-audit"]');
539
+ n == null || n.focus();
540
+ }
541
+ function Q(e, t) {
542
+ const n = U(e);
543
+ return (typeof t == "boolean" ? t : !n) ? ne(e) : W(e, !1), !0;
544
+ }
545
+ function me(e) {
546
+ const t = V.get(e);
547
+ typeof t == "number" && (window.clearTimeout(t), _.delete(t), V.delete(e));
548
+ }
549
+ function be(e) {
550
+ const t = d.get(e) || E;
551
+ if (!t || !A(e, t))
552
+ return;
553
+ me(e);
554
+ const n = window.setTimeout(() => {
555
+ _.delete(n), V.delete(e), C(e, t, !1);
556
+ }, t.debounceMs);
557
+ _.add(n), V.set(e, n);
558
+ }
559
+ function Pe(e) {
560
+ const t = e.key.toLowerCase();
561
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
562
+ }
563
+ function ze(e) {
564
+ const t = e.key.toLowerCase();
565
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
566
+ }
567
+ function _e(e) {
568
+ const t = e.key.toLowerCase();
569
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "t";
570
+ }
571
+ function Be() {
572
+ if (typeof document > "u" || document.getElementById(se))
573
+ return;
574
+ const e = document.createElement("style");
575
+ e.id = se, e.textContent = `
576
+ .rte-toolbar-group-items.content-rules,
577
+ .editora-toolbar-group-items.content-rules {
578
+ display: flex;
579
+ border: 1px solid #ccc;
580
+ border-radius: 3px;
581
+ background: #fff;
582
+ }
583
+
584
+ .rte-toolbar-group-items.content-rules .rte-toolbar-button,
585
+ .editora-toolbar-group-items.content-rules .editora-toolbar-button {
586
+ border: none;
587
+ border-radius: 0px;
588
+ }
589
+
590
+ .rte-toolbar-group-items.content-rules .rte-toolbar-button,
591
+ .editora-toolbar-group-items.content-rules .editora-toolbar-button {
592
+ border-right: 1px solid #ccc;
593
+ }
594
+ .rte-toolbar-group-items.content-rules .rte-toolbar-item:last-child .rte-toolbar-button,
595
+ .editora-toolbar-group-items.content-rules .editora-toolbar-item:last-child .editora-toolbar-button {
596
+ border-right: none;
597
+ }
598
+ .rte-toolbar-button[data-command="toggleContentRulesRealtime"].active,
599
+ .editora-toolbar-button[data-command="toggleContentRulesRealtime"].active {
600
+ background-color: #ccc;
601
+ }
602
+
603
+ ${q} .rte-toolbar-group-items.content-rules,
604
+ ${q} .editora-toolbar-group-items.content-rules {
605
+ border-color: #566275;
606
+ }
607
+ ${q} .rte-toolbar-group-items.content-rules .rte-toolbar-button,
608
+ ${q} .editora-toolbar-group-items.content-rules .editora-toolbar-button
609
+ {
610
+ border-color: #566275;
611
+ }
612
+ ${q} .rte-toolbar-group-items.content-rules .rte-toolbar-button svg{
613
+ fill: none;
614
+ }
615
+ .${f} {
616
+ position: fixed;
617
+ z-index: 12000;
618
+ display: none;
619
+ width: min(360px, calc(100vw - 20px));
620
+ max-height: calc(100vh - 20px);
621
+ border: 1px solid #d1d5db;
622
+ border-radius: 14px;
623
+ background: #ffffff;
624
+ color: #111827;
625
+ box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
626
+ overflow: hidden;
627
+ }
628
+
629
+ .${f}.show {
630
+ display: flex;
631
+ flex-direction: column;
632
+ }
633
+
634
+ .${f}.rte-content-rules-theme-dark {
635
+ border-color: #334155;
636
+ background: #0f172a;
637
+ color: #e2e8f0;
638
+ box-shadow: 0 20px 46px rgba(2, 6, 23, 0.68);
639
+ }
640
+
641
+ .rte-content-rules-header {
642
+ display: flex;
643
+ align-items: center;
644
+ justify-content: space-between;
645
+ gap: 8px;
646
+ padding: 12px 14px;
647
+ border-bottom: 1px solid #e5e7eb;
648
+ background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
649
+ }
650
+
651
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-header {
652
+ border-color: #1e293b;
653
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
654
+ }
655
+
656
+ .rte-content-rules-title {
657
+ margin: 0;
658
+ font-size: 15px;
659
+ line-height: 1.2;
660
+ font-weight: 700;
661
+ }
662
+
663
+ .rte-content-rules-icon-btn {
664
+ width: 34px;
665
+ height: 34px;
666
+ border: 1px solid #cbd5e1;
667
+ border-radius: 6px;
668
+ background: #ffffff;
669
+ color: #0f172a;
670
+ font-size: 16px;
671
+ line-height: 1;
672
+ font-weight: 600;
673
+ padding: 0;
674
+ display: inline-flex;
675
+ align-items: center;
676
+ justify-content: center;
677
+ cursor: pointer;
678
+ }
679
+
680
+ .rte-content-rules-icon-btn:hover,
681
+ .rte-content-rules-icon-btn:focus-visible {
682
+ outline: none;
683
+ border-color: #3b82f6;
684
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
685
+ }
686
+
687
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-icon-btn {
688
+ background: #0f172a;
689
+ border-color: #475569;
690
+ color: #e2e8f0;
691
+ }
692
+
693
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-icon-btn:hover,
694
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-icon-btn:focus-visible {
695
+ border-color: #60a5fa;
696
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
697
+ }
698
+
699
+ .rte-content-rules-body {
700
+ display: flex;
701
+ flex-direction: column;
702
+ gap: 10px;
703
+ padding: 12px;
704
+ overflow: auto;
705
+ }
706
+
707
+ .rte-content-rules-topline {
708
+ display: flex;
709
+ align-items: center;
710
+ justify-content: space-between;
711
+ gap: 8px;
712
+ }
713
+
714
+ .rte-content-rules-summary {
715
+ margin: 0;
716
+ font-size: 12px;
717
+ line-height: 1.35;
718
+ color: #475569;
719
+ flex: 1;
720
+ }
721
+
722
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-summary {
723
+ color: #94a3b8;
724
+ }
725
+
726
+ .rte-content-rules-count {
727
+ min-width: 32px;
728
+ height: 32px;
729
+ border-radius: 999px;
730
+ display: inline-flex;
731
+ align-items: center;
732
+ justify-content: center;
733
+ font-weight: 700;
734
+ font-size: 13px;
735
+ border: 1px solid #cbd5e1;
736
+ background: #f8fafc;
737
+ }
738
+
739
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-count {
740
+ border-color: #334155;
741
+ background: #111827;
742
+ color: #cbd5e1;
743
+ }
744
+
745
+ .rte-content-rules-controls {
746
+ display: flex;
747
+ gap: 8px;
748
+ flex-wrap: wrap;
749
+ }
750
+
751
+ .rte-content-rules-btn {
752
+ border: 1px solid #cbd5e1;
753
+ border-radius: 8px;
754
+ height: 34px;
755
+ padding: 0 10px;
756
+ background: #ffffff;
757
+ color: inherit;
758
+ font-size: 12px;
759
+ font-weight: 600;
760
+ cursor: pointer;
761
+ }
762
+
763
+ .rte-content-rules-btn:hover,
764
+ .rte-content-rules-btn:focus-visible {
765
+ border-color: #94a3b8;
766
+ background: #f8fafc;
767
+ outline: none;
768
+ }
769
+
770
+ .rte-content-rules-btn-primary {
771
+ border-color: #0284c7;
772
+ background: #0ea5e9;
773
+ color: #f8fafc;
774
+ }
775
+
776
+ .rte-content-rules-btn-primary:hover,
777
+ .rte-content-rules-btn-primary:focus-visible {
778
+ border-color: #0369a1;
779
+ background: #0284c7;
780
+ color: #ffffff;
781
+ }
782
+
783
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-btn {
784
+ border-color: #334155;
785
+ background: #111827;
786
+ color: #e2e8f0;
787
+ }
788
+
789
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-btn:hover,
790
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-btn:focus-visible {
791
+ border-color: #475569;
792
+ background: #1e293b;
793
+ }
794
+
795
+ .rte-content-rules-list {
796
+ list-style: none;
797
+ margin: 0;
798
+ padding: 0;
799
+ display: flex;
800
+ flex-direction: column;
801
+ gap: 8px;
802
+ max-height: min(55vh, 420px);
803
+ overflow: auto;
804
+ }
805
+
806
+ .rte-content-rules-item {
807
+ border: 1px solid #e2e8f0;
808
+ border-radius: 10px;
809
+ padding: 8px;
810
+ background: #ffffff;
811
+ }
812
+
813
+ .rte-content-rules-item-error {
814
+ border-color: #fca5a5;
815
+ background: #fef2f2;
816
+ }
817
+
818
+ .rte-content-rules-item-warning {
819
+ border-color: #fcd34d;
820
+ background: #fffbeb;
821
+ }
822
+
823
+ .rte-content-rules-item-info {
824
+ border-color: #93c5fd;
825
+ background: #eff6ff;
826
+ }
827
+
828
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item {
829
+ border-color: #334155;
830
+ background: #0b1220;
831
+ }
832
+
833
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item-error {
834
+ border-color: #7f1d1d;
835
+ background: #2b0b11;
836
+ }
837
+
838
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item-warning {
839
+ border-color: #78350f;
840
+ background: #2b1907;
841
+ }
842
+
843
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-item-info {
844
+ border-color: #1d4ed8;
845
+ background: #0a162f;
846
+ }
847
+
848
+ .rte-content-rules-item-btn {
849
+ width: 100%;
850
+ border: none;
851
+ background: transparent;
852
+ display: flex;
853
+ align-items: flex-start;
854
+ gap: 8px;
855
+ text-align: left;
856
+ padding: 0;
857
+ color: inherit;
858
+ cursor: pointer;
859
+ }
860
+
861
+ .rte-content-rules-item-btn:focus-visible {
862
+ outline: 2px solid #0284c7;
863
+ outline-offset: 3px;
864
+ border-radius: 6px;
865
+ }
866
+
867
+ .rte-content-rules-badge {
868
+ flex: 0 0 auto;
869
+ margin-top: 1px;
870
+ border-radius: 999px;
871
+ border: 1px solid currentColor;
872
+ padding: 1px 8px;
873
+ font-size: 10px;
874
+ font-weight: 700;
875
+ line-height: 1.3;
876
+ text-transform: uppercase;
877
+ opacity: 0.86;
878
+ }
879
+
880
+ .rte-content-rules-message {
881
+ font-size: 13px;
882
+ line-height: 1.35;
883
+ font-weight: 600;
884
+ }
885
+
886
+ .rte-content-rules-excerpt,
887
+ .rte-content-rules-suggestion {
888
+ margin: 8px 0 0;
889
+ font-size: 12px;
890
+ line-height: 1.35;
891
+ color: #334155;
892
+ }
893
+
894
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-excerpt,
895
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-suggestion {
896
+ color: #94a3b8;
897
+ }
898
+
899
+ .rte-content-rules-empty {
900
+ border: 1px dashed #cbd5e1;
901
+ border-radius: 10px;
902
+ padding: 10px;
903
+ font-size: 13px;
904
+ color: #475569;
905
+ background: #f8fafc;
906
+ }
907
+
908
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-empty {
909
+ border-color: #334155;
910
+ background: #0b1220;
911
+ color: #94a3b8;
912
+ }
913
+
914
+ .rte-content-rules-shortcut {
915
+ margin: 2px 0 0;
916
+ font-size: 11px;
917
+ color: #64748b;
918
+ }
919
+
920
+ .${f}.rte-content-rules-theme-dark .rte-content-rules-shortcut {
921
+ color: #94a3b8;
922
+ }
923
+
924
+ .rte-content-rules-live {
925
+ position: absolute;
926
+ width: 1px;
927
+ height: 1px;
928
+ margin: -1px;
929
+ padding: 0;
930
+ overflow: hidden;
931
+ clip: rect(0 0 0 0);
932
+ border: 0;
933
+ }
934
+
935
+ @media (max-width: 768px) {
936
+ .${f} {
937
+ left: 10px !important;
938
+ right: 10px;
939
+ top: 10px !important;
940
+ width: auto !important;
941
+ max-height: calc(100vh - 20px);
942
+ }
943
+
944
+ .rte-content-rules-list {
945
+ max-height: 45vh;
946
+ }
947
+ }
948
+ `, document.head.appendChild(e);
949
+ }
950
+ function De(e) {
951
+ E = e, L || (L = (t) => {
952
+ const n = t.target, o = n == null ? void 0 : n.closest(R);
953
+ if (!o)
954
+ return;
955
+ g = o, d.has(o) || d.set(o, e), v.has(o) || v.set(o, []), T.has(o) || T.set(o, e.enableRealtime);
956
+ const r = h.get(o);
957
+ r && (G(r, o), J(o, r), O(o, r, d.get(o) || e)), $(o, "toggleContentRulesPanel", U(o)), $(o, "toggleContentRulesRealtime", A(o, e));
958
+ }, document.addEventListener("focusin", L, !0)), I || (I = (t) => {
959
+ const n = t.target, o = n == null ? void 0 : n.closest(R);
960
+ o && (g = o, be(o));
961
+ }, document.addEventListener("input", I, !0)), H || (H = (t) => {
962
+ if (t.defaultPrevented)
963
+ return;
964
+ const n = t.target;
965
+ if (n != null && n.closest("input, textarea, select"))
966
+ return;
967
+ const o = t.key === "Escape", r = Pe(t), s = ze(t), a = _e(t);
968
+ if (!o && !r && !s && !a)
969
+ return;
970
+ const l = M(void 0, !1);
971
+ if (!l || Z(l))
972
+ return;
973
+ const c = d.get(l) || E || e;
974
+ if (d.set(l, c), g = l, o && U(l)) {
975
+ t.preventDefault(), W(l, !0);
976
+ return;
977
+ }
978
+ if (r) {
979
+ t.preventDefault(), t.stopPropagation(), Q(l);
980
+ return;
981
+ }
982
+ if (s) {
983
+ t.preventDefault(), t.stopPropagation(), C(l, c, !0), ne(l);
984
+ return;
985
+ }
986
+ if (a) {
987
+ t.preventDefault(), t.stopPropagation();
988
+ const u = !A(l, c);
989
+ T.set(l, u);
990
+ const i = h.get(l);
991
+ i && O(l, i, c), $(l, "toggleContentRulesRealtime", u), u && C(l, c, !0);
992
+ }
993
+ }, document.addEventListener("keydown", H, !0)), S || (S = () => {
994
+ h.forEach((t, n) => {
995
+ if (!n.isConnected || !t.isConnected) {
996
+ me(n), t.remove(), h.delete(n), B.delete(n);
997
+ return;
998
+ }
999
+ G(t, n), J(n, t);
1000
+ });
1001
+ }, window.addEventListener("scroll", S, !0), window.addEventListener("resize", S));
1002
+ }
1003
+ function Ne() {
1004
+ L && (document.removeEventListener("focusin", L, !0), L = null), I && (document.removeEventListener("input", I, !0), I = null), H && (document.removeEventListener("keydown", H, !0), H = null), S && (window.removeEventListener("scroll", S, !0), window.removeEventListener("resize", S), S = null), h.forEach((e) => {
1005
+ e.remove();
1006
+ }), h.clear(), E = null, g = null;
1007
+ }
1008
+ const Ke = (e = {}) => {
1009
+ const t = j(e);
1010
+ return Be(), {
1011
+ name: "contentRules",
1012
+ toolbar: [
1013
+ {
1014
+ id: "contentRulesGroup",
1015
+ label: "Content Rules",
1016
+ type: "group",
1017
+ command: "contentRules",
1018
+ items: [
1019
+ {
1020
+ id: "contentRules",
1021
+ label: "Content Rules",
1022
+ command: "toggleContentRulesPanel",
1023
+ shortcut: "Mod-Alt-Shift-r",
1024
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 3h9l5 5v11a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm8 2v4h4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 11h8M8 15h8M8 19h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'
1025
+ },
1026
+ {
1027
+ id: "contentRulesAudit",
1028
+ label: "Run Rules Audit",
1029
+ command: "runContentRulesAudit",
1030
+ shortcut: "Mod-Alt-Shift-l",
1031
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4 12h4l2 5 4-10 2 5h4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.6"/></svg>'
1032
+ },
1033
+ {
1034
+ id: "contentRulesRealtime",
1035
+ label: "Toggle Realtime Rules",
1036
+ command: "toggleContentRulesRealtime",
1037
+ shortcut: "Mod-Alt-Shift-t",
1038
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3v4M12 17v4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M3 12h4M17 12h4M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12" cy="12" r="4" stroke="currentColor" stroke-width="1.6"/></svg>'
1039
+ }
1040
+ ]
1041
+ }
1042
+ ],
1043
+ commands: {
1044
+ contentRules: (n, o) => {
1045
+ const r = M(o);
1046
+ if (!r || Z(r))
1047
+ return !1;
1048
+ const s = d.get(r) || t;
1049
+ return d.set(r, s), g = r, Q(r, !0), C(r, s, !1), !0;
1050
+ },
1051
+ toggleContentRulesPanel: (n, o) => {
1052
+ const r = M(o);
1053
+ if (!r || Z(r))
1054
+ return !1;
1055
+ g = r;
1056
+ const s = d.get(r) || t;
1057
+ d.set(r, s);
1058
+ const a = Q(r, typeof n == "boolean" ? n : void 0);
1059
+ return U(r) && C(r, s, !1), a;
1060
+ },
1061
+ runContentRulesAudit: async (n, o) => {
1062
+ const r = M(o);
1063
+ if (!r)
1064
+ return !1;
1065
+ g = r;
1066
+ const s = d.get(r) || t;
1067
+ return d.set(r, s), await C(r, s, !0), ne(r), !0;
1068
+ },
1069
+ toggleContentRulesRealtime: (n, o) => {
1070
+ const r = M(o);
1071
+ if (!r)
1072
+ return !1;
1073
+ g = r;
1074
+ const s = d.get(r) || t;
1075
+ d.set(r, s);
1076
+ const a = typeof n == "boolean" ? n : !A(r, s);
1077
+ T.set(r, a);
1078
+ const l = h.get(r);
1079
+ return l && O(r, l, s), $(r, "toggleContentRulesRealtime", a), a && C(r, s, !0), !0;
1080
+ },
1081
+ getContentRulesIssues: (n, o) => {
1082
+ const r = M(o);
1083
+ if (!r)
1084
+ return !1;
1085
+ const s = v.get(r) || [];
1086
+ if (typeof n == "function")
1087
+ try {
1088
+ n(s);
1089
+ } catch {
1090
+ }
1091
+ return r.__contentRulesIssues = s, r.dispatchEvent(
1092
+ new CustomEvent("editora:content-rules-issues", {
1093
+ bubbles: !0,
1094
+ detail: { issues: s }
1095
+ })
1096
+ ), !0;
1097
+ },
1098
+ setContentRulesOptions: (n, o) => {
1099
+ const r = M(o);
1100
+ if (!r || !n || typeof n != "object")
1101
+ return !1;
1102
+ const s = d.get(r) || t, a = j({
1103
+ ...s,
1104
+ ...n,
1105
+ labels: {
1106
+ ...s.labels,
1107
+ ...n.labels || {}
1108
+ }
1109
+ });
1110
+ d.set(r, a), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, a) && C(r, a, !0);
1111
+ const l = h.get(r);
1112
+ if (l) {
1113
+ l.setAttribute("aria-label", a.labels.panelAriaLabel);
1114
+ const c = l.querySelector(".rte-content-rules-title");
1115
+ c && (c.textContent = a.labels.panelTitle), O(r, l, a), te(r);
1116
+ }
1117
+ return !0;
1118
+ }
1119
+ },
1120
+ keymap: {
1121
+ "Mod-Alt-Shift-r": "toggleContentRulesPanel",
1122
+ "Mod-Alt-Shift-R": "toggleContentRulesPanel",
1123
+ "Mod-Alt-Shift-l": "runContentRulesAudit",
1124
+ "Mod-Alt-Shift-L": "runContentRulesAudit",
1125
+ "Mod-Alt-Shift-t": "toggleContentRulesRealtime",
1126
+ "Mod-Alt-Shift-T": "toggleContentRulesRealtime"
1127
+ },
1128
+ init: function(o) {
1129
+ N += 1;
1130
+ const r = this && typeof this.__pluginConfig == "object" ? j({ ...t, ...this.__pluginConfig }) : t;
1131
+ De(r);
1132
+ const s = M(
1133
+ o && o.editorElement ? { editorElement: o.editorElement } : void 0,
1134
+ !1
1135
+ );
1136
+ s && (g = s, d.set(s, r), T.set(s, r.enableRealtime), v.set(s, []), $(s, "toggleContentRulesPanel", !1), $(s, "toggleContentRulesRealtime", r.enableRealtime), r.enableRealtime && be(s));
1137
+ },
1138
+ destroy: () => {
1139
+ N = Math.max(0, N - 1), !(N > 0) && (_.forEach((n) => {
1140
+ window.clearTimeout(n);
1141
+ }), _.clear(), Ne());
1142
+ }
1143
+ };
1144
+ };
1145
+ export {
1146
+ Ke as ContentRulesPlugin
1147
+ };