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