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