@editora/core 1.0.6 → 1.0.8

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