@editora/plugins 1.0.12 → 1.0.14
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/dist/approval-workflow.cjs.js +14 -14
- package/dist/approval-workflow.esm.js +265 -262
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +177 -15
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +95 -92
- package/dist/bold.cjs.js +1 -1
- package/dist/bold.esm.js +10 -6
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +124 -44
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +251 -191
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +131 -128
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +68 -36
- package/dist/code.cjs.js +27 -21
- package/dist/code.esm.js +72 -43
- package/dist/content-rules.cjs.js +5 -5
- package/dist/content-rules.esm.js +104 -101
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +51 -48
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +97 -74
- package/dist/doc-schema.cjs.js +4 -4
- package/dist/doc-schema.esm.js +104 -101
- package/dist/embed-iframe.cjs.js +21 -4
- package/dist/embed-iframe.esm.js +279 -116
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +239 -56
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +74 -89
- package/dist/inlineFormatting-DOYOJdnD.js +1 -0
- package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +12 -8
- package/dist/math.cjs.js +27 -21
- package/dist/math.esm.js +218 -146
- package/dist/merge-tag.cjs.js +8 -2
- package/dist/merge-tag.esm.js +130 -111
- package/dist/pii-redaction.cjs.js +6 -6
- package/dist/pii-redaction.esm.js +169 -166
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +120 -117
- package/dist/special-characters.cjs.js +6 -10
- package/dist/special-characters.esm.js +97 -75
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +11 -25
- package/dist/translation-workflow.cjs.js +7 -7
- package/dist/translation-workflow.esm.js +103 -100
- package/dist/underline.cjs.js +1 -1
- package/dist/underline.esm.js +7 -3
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const R = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor",
|
|
1
|
+
const R = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", se = "__editoraCommandEditorRoot", le = "rte-content-rules-styles", f = "rte-content-rules-panel", q = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', pe = {
|
|
2
2
|
panelTitle: "Content Rules",
|
|
3
3
|
panelAriaLabel: "Content rules panel",
|
|
4
4
|
runAuditText: "Run Audit",
|
|
@@ -12,21 +12,21 @@ const R = ".rte-content, .editora-content", ee = "[data-editora-editor], .rte-ed
|
|
|
12
12
|
requiredHeadingMessage: "Missing required heading",
|
|
13
13
|
sentenceLengthMessage: "Sentence is too long",
|
|
14
14
|
readabilityMessage: "Readability score is below threshold"
|
|
15
|
-
}, d = /* @__PURE__ */ new WeakMap(),
|
|
16
|
-
let N = 0,
|
|
15
|
+
}, d = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), fe = /* @__PURE__ */ new WeakMap(), T = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
|
|
16
|
+
let N = 0, xe = 0, E = null, g = null, L = null, I = null, H = null, S = null;
|
|
17
17
|
function k(e) {
|
|
18
18
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function ye(e) {
|
|
21
21
|
return {
|
|
22
|
-
...
|
|
22
|
+
...pe,
|
|
23
23
|
...e || {}
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function we(e) {
|
|
27
27
|
return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function ie(e) {
|
|
30
30
|
if (!e) return [];
|
|
31
31
|
const t = /* @__PURE__ */ new Set();
|
|
32
32
|
return e.forEach((n) => {
|
|
@@ -36,15 +36,15 @@ function ae(e) {
|
|
|
36
36
|
}
|
|
37
37
|
function j(e = {}) {
|
|
38
38
|
return {
|
|
39
|
-
bannedWords:
|
|
40
|
-
requiredHeadings:
|
|
39
|
+
bannedWords: ie(e.bannedWords),
|
|
40
|
+
requiredHeadings: ie(e.requiredHeadings),
|
|
41
41
|
maxSentenceWords: Math.max(8, Number(e.maxSentenceWords ?? 32)),
|
|
42
42
|
minReadabilityScore: Math.max(0, Math.min(120, Number(e.minReadabilityScore ?? 55))),
|
|
43
43
|
maxIssues: Math.max(1, Number(e.maxIssues ?? 100)),
|
|
44
44
|
debounceMs: Math.max(50, Number(e.debounceMs ?? 220)),
|
|
45
45
|
enableRealtime: e.enableRealtime !== !1,
|
|
46
|
-
labels:
|
|
47
|
-
normalizeText: e.normalizeText ||
|
|
46
|
+
labels: ye(e.labels),
|
|
47
|
+
normalizeText: e.normalizeText || we,
|
|
48
48
|
customRules: Array.isArray(e.customRules) ? e.customRules : []
|
|
49
49
|
};
|
|
50
50
|
}
|
|
@@ -57,11 +57,11 @@ function F(e) {
|
|
|
57
57
|
const t = e.querySelector(R);
|
|
58
58
|
return t instanceof HTMLElement ? t : null;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function ke() {
|
|
61
61
|
if (typeof window > "u") return null;
|
|
62
|
-
const e = window[
|
|
62
|
+
const e = window[se];
|
|
63
63
|
if (!(e instanceof HTMLElement)) return null;
|
|
64
|
-
window[
|
|
64
|
+
window[se] = null;
|
|
65
65
|
const t = F(e);
|
|
66
66
|
if (t) return t;
|
|
67
67
|
const n = e.closest(ee);
|
|
@@ -71,7 +71,7 @@ function we() {
|
|
|
71
71
|
}
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Re(e) {
|
|
75
75
|
const t = e.closest("[data-editora-editor]");
|
|
76
76
|
if (t && F(t) === e)
|
|
77
77
|
return t;
|
|
@@ -86,16 +86,16 @@ function ke(e) {
|
|
|
86
86
|
function K(e) {
|
|
87
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
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function Ee(e) {
|
|
90
90
|
const t = X(e);
|
|
91
91
|
if (K(t)) return !0;
|
|
92
92
|
const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
|
|
93
93
|
return K(n) ? !0 : K(document.documentElement) || K(document.body);
|
|
94
94
|
}
|
|
95
95
|
function G(e, t) {
|
|
96
|
-
e.classList.remove("rte-content-rules-theme-dark"),
|
|
96
|
+
e.classList.remove("rte-content-rules-theme-dark"), Ee(t) && e.classList.add("rte-content-rules-theme-dark");
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function ve(e) {
|
|
99
99
|
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
100
100
|
}
|
|
101
101
|
function M(e, t = !0) {
|
|
@@ -106,11 +106,11 @@ function M(e, t = !0) {
|
|
|
106
106
|
const i = s.querySelector(R);
|
|
107
107
|
if (i instanceof HTMLElement) return i;
|
|
108
108
|
}
|
|
109
|
-
const n =
|
|
109
|
+
const n = ke();
|
|
110
110
|
if (n) return n;
|
|
111
111
|
const o = window.getSelection();
|
|
112
112
|
if (o && o.rangeCount > 0) {
|
|
113
|
-
const s = o.getRangeAt(0).startContainer, l =
|
|
113
|
+
const s = o.getRangeAt(0).startContainer, l = ve(s)?.closest(R);
|
|
114
114
|
if (l) return l;
|
|
115
115
|
}
|
|
116
116
|
const r = document.activeElement;
|
|
@@ -128,24 +128,24 @@ function Ce(e, t) {
|
|
|
128
128
|
const n = e.innerText || e.textContent || "";
|
|
129
129
|
return t(n);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function $e(e) {
|
|
132
132
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function ce(e) {
|
|
135
135
|
let t = 2166136261;
|
|
136
136
|
for (let n = 0; n < e.length; n += 1)
|
|
137
137
|
t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
138
138
|
return t >>> 0;
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function ue(e) {
|
|
141
141
|
const t = e.match(/\b[\w'-]+\b/g);
|
|
142
142
|
return t ? t.length : 0;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function ge(e) {
|
|
145
145
|
const t = e.match(/[^.!?]+[.!?]*/g);
|
|
146
146
|
return t ? t.map((n) => n.trim()).filter(Boolean).length : 0;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function Me(e) {
|
|
149
149
|
const t = e.toLowerCase().replace(/[^a-z]/g, "");
|
|
150
150
|
if (!t) return 0;
|
|
151
151
|
if (t.length <= 3) return 1;
|
|
@@ -153,10 +153,10 @@ function $e(e) {
|
|
|
153
153
|
let o = n ? n.length : 1;
|
|
154
154
|
return t.endsWith("e") && (o -= 1), Math.max(1, o);
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function Se(e) {
|
|
157
157
|
const t = e.match(/\b[\w'-]+\b/g) || [], n = t.length;
|
|
158
158
|
if (n === 0) return 100;
|
|
159
|
-
const o = Math.max(1,
|
|
159
|
+
const o = Math.max(1, ge(e)), r = t.reduce((i, l) => i + Me(l), 0), s = 206.835 - 1.015 * (n / o) - 84.6 * (r / Math.max(1, n));
|
|
160
160
|
return Number.isFinite(s) ? Math.max(0, Math.min(120, s)) : 0;
|
|
161
161
|
}
|
|
162
162
|
function z(e, t) {
|
|
@@ -168,54 +168,54 @@ function x(e, t) {
|
|
|
168
168
|
function P(e, t, n) {
|
|
169
169
|
x(e, n) || e.push(t);
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function me(e, t = 140) {
|
|
172
172
|
return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function Te(e, t, n, o) {
|
|
175
175
|
return {
|
|
176
176
|
id: e.id || z(t, o),
|
|
177
177
|
ruleId: e.ruleId || t,
|
|
178
178
|
severity: e.severity || n,
|
|
179
179
|
message: e.message || t,
|
|
180
|
-
excerpt: e.excerpt ?
|
|
180
|
+
excerpt: e.excerpt ? me(e.excerpt, 220) : void 0,
|
|
181
181
|
suggestion: e.suggestion,
|
|
182
182
|
locateText: e.locateText,
|
|
183
183
|
selector: e.selector
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Ae(e, t) {
|
|
187
187
|
const n = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), o = /* @__PURE__ */ new Set();
|
|
188
188
|
return n.forEach((r) => {
|
|
189
189
|
const s = t(r.textContent || "").toLowerCase();
|
|
190
190
|
s && o.add(s);
|
|
191
191
|
}), o;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function Le(e) {
|
|
194
194
|
const t = e.match(/[^.!?\n]+[.!?]?/g);
|
|
195
195
|
return t ? t.map((n) => n.trim()).filter(Boolean) : [];
|
|
196
196
|
}
|
|
197
|
-
async function
|
|
198
|
-
const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${
|
|
199
|
-
if (!n &&
|
|
200
|
-
return
|
|
197
|
+
async function v(e, t, n = !1) {
|
|
198
|
+
const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${ce(o)}:${r.length}:${ce(r)}`;
|
|
199
|
+
if (!n && ae.get(e) === s)
|
|
200
|
+
return C.get(e) || [];
|
|
201
201
|
const i = (Y.get(e) || 0) + 1;
|
|
202
202
|
Y.set(e, i);
|
|
203
|
-
const l =
|
|
203
|
+
const l = ue(o), c = ge(o), u = Se(o), a = [], y = t.labels;
|
|
204
204
|
if (t.bannedWords.length > 0) {
|
|
205
205
|
let w = 0;
|
|
206
206
|
for (const p of t.bannedWords) {
|
|
207
|
-
const m = new RegExp(`\\b${
|
|
207
|
+
const m = new RegExp(`\\b${$e(p)}\\b`, "gi");
|
|
208
208
|
let b = m.exec(o);
|
|
209
209
|
for (; b && !x(a, t.maxIssues); ) {
|
|
210
|
-
const
|
|
210
|
+
const oe = b[0];
|
|
211
211
|
P(
|
|
212
212
|
a,
|
|
213
213
|
{
|
|
214
214
|
id: z("banned-word", w),
|
|
215
215
|
ruleId: "banned-word",
|
|
216
216
|
severity: "error",
|
|
217
|
-
message: `${y.bannedWordMessage}: "${
|
|
218
|
-
locateText:
|
|
217
|
+
message: `${y.bannedWordMessage}: "${oe}"`,
|
|
218
|
+
locateText: oe,
|
|
219
219
|
suggestion: "Replace or remove banned terms."
|
|
220
220
|
},
|
|
221
221
|
t.maxIssues
|
|
@@ -225,7 +225,7 @@ async function C(e, t, n = !1) {
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
if (!x(a, t.maxIssues) && t.requiredHeadings.length > 0) {
|
|
228
|
-
const w =
|
|
228
|
+
const w = Ae(e, t.normalizeText);
|
|
229
229
|
let p = 0;
|
|
230
230
|
t.requiredHeadings.forEach((m) => {
|
|
231
231
|
if (x(a, t.maxIssues)) return;
|
|
@@ -244,11 +244,11 @@ async function C(e, t, n = !1) {
|
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
if (!x(a, t.maxIssues)) {
|
|
247
|
-
const w =
|
|
247
|
+
const w = Le(o);
|
|
248
248
|
let p = 0;
|
|
249
249
|
for (const m of w) {
|
|
250
250
|
if (x(a, t.maxIssues)) break;
|
|
251
|
-
const b =
|
|
251
|
+
const b = ue(m);
|
|
252
252
|
b <= t.maxSentenceWords || (P(
|
|
253
253
|
a,
|
|
254
254
|
{
|
|
@@ -256,7 +256,7 @@ async function C(e, t, n = !1) {
|
|
|
256
256
|
ruleId: "sentence-length",
|
|
257
257
|
severity: "warning",
|
|
258
258
|
message: `${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,
|
|
259
|
-
excerpt:
|
|
259
|
+
excerpt: me(m, 200),
|
|
260
260
|
locateText: m.slice(0, 64),
|
|
261
261
|
suggestion: "Split into shorter sentences for readability."
|
|
262
262
|
},
|
|
@@ -292,7 +292,7 @@ async function C(e, t, n = !1) {
|
|
|
292
292
|
for (let b = 0; b < m.length && !x(a, t.maxIssues); b += 1)
|
|
293
293
|
P(
|
|
294
294
|
a,
|
|
295
|
-
|
|
295
|
+
Te(m[b], p.id, p.severity || "warning", b),
|
|
296
296
|
t.maxIssues
|
|
297
297
|
);
|
|
298
298
|
} catch {
|
|
@@ -300,13 +300,13 @@ async function C(e, t, n = !1) {
|
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
302
|
if (Y.get(e) !== i)
|
|
303
|
-
return
|
|
303
|
+
return C.get(e) || [];
|
|
304
304
|
const D = {
|
|
305
305
|
readabilityScore: u,
|
|
306
306
|
wordCount: l,
|
|
307
307
|
sentenceCount: c
|
|
308
308
|
};
|
|
309
|
-
return
|
|
309
|
+
return ae.set(e, s), C.set(e, a), fe.set(e, D), te(e), e.dispatchEvent(
|
|
310
310
|
new CustomEvent("editora:content-rules-audit", {
|
|
311
311
|
bubbles: !0,
|
|
312
312
|
detail: {
|
|
@@ -316,17 +316,17 @@ async function C(e, t, n = !1) {
|
|
|
316
316
|
})
|
|
317
317
|
), a;
|
|
318
318
|
}
|
|
319
|
-
function
|
|
319
|
+
function Ie(e) {
|
|
320
320
|
return e.reduce(
|
|
321
321
|
(t, n) => (t[n.severity] += 1, t),
|
|
322
322
|
{ error: 0, warning: 0, info: 0 }
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function He(e) {
|
|
326
326
|
return e === "error" ? "Error" : e === "warning" ? "Warning" : "Info";
|
|
327
327
|
}
|
|
328
328
|
function $(e, t, n) {
|
|
329
|
-
const o =
|
|
329
|
+
const o = Re(e);
|
|
330
330
|
Array.from(
|
|
331
331
|
o.querySelectorAll(
|
|
332
332
|
`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
|
|
@@ -345,7 +345,7 @@ function J(e, t) {
|
|
|
345
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
346
|
t.style.left = `${l}px`, t.style.top = `${c}px`;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function de(e, t) {
|
|
349
349
|
const n = t.trim().toLowerCase();
|
|
350
350
|
if (!n) return !1;
|
|
351
351
|
const o = window.getSelection();
|
|
@@ -364,16 +364,16 @@ function ue(e, t) {
|
|
|
364
364
|
}
|
|
365
365
|
return !1;
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function We(e, t) {
|
|
368
368
|
if (t.selector) {
|
|
369
369
|
const n = e.querySelector(t.selector);
|
|
370
370
|
if (n)
|
|
371
371
|
return n.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), n.focus({ preventScroll: !0 }), !0;
|
|
372
372
|
}
|
|
373
|
-
return !!(t.locateText &&
|
|
373
|
+
return !!(t.locateText && de(e, t.locateText) || t.excerpt && de(e, t.excerpt.slice(0, 64)));
|
|
374
374
|
}
|
|
375
|
-
function
|
|
376
|
-
return (
|
|
375
|
+
function Oe(e, t) {
|
|
376
|
+
return (C.get(e) || []).find((o) => o.id === t);
|
|
377
377
|
}
|
|
378
378
|
function A(e, t) {
|
|
379
379
|
const n = T.get(e);
|
|
@@ -390,11 +390,11 @@ function te(e) {
|
|
|
390
390
|
if (!t) return;
|
|
391
391
|
const n = d.get(e) || E;
|
|
392
392
|
if (!n) return;
|
|
393
|
-
const o =
|
|
393
|
+
const o = C.get(e) || [], r = fe.get(e) || {
|
|
394
394
|
readabilityScore: 100
|
|
395
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
396
|
if (!s || !i || !l || !c) return;
|
|
397
|
-
const u =
|
|
397
|
+
const u = Ie(o);
|
|
398
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
399
|
l.innerHTML = `<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;
|
|
400
400
|
return;
|
|
@@ -411,7 +411,7 @@ function te(e) {
|
|
|
411
411
|
data-role="issue-button"
|
|
412
412
|
aria-label="${k(w)}"
|
|
413
413
|
>
|
|
414
|
-
<span class="rte-content-rules-badge">${k(
|
|
414
|
+
<span class="rte-content-rules-badge">${k(He(a.severity))}</span>
|
|
415
415
|
<span class="rte-content-rules-message">${k(a.message)}</span>
|
|
416
416
|
</button>
|
|
417
417
|
${y}
|
|
@@ -424,15 +424,15 @@ function W(e, t = !1) {
|
|
|
424
424
|
const n = h.get(e);
|
|
425
425
|
n && (n.classList.remove("show"), B.set(e, !1), $(e, "toggleContentRulesPanel", !1), t && e.focus({ preventScroll: !0 }));
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function qe(e) {
|
|
428
428
|
h.forEach((t, n) => {
|
|
429
429
|
n !== e && W(n, !1);
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function Pe(e) {
|
|
433
433
|
const t = h.get(e);
|
|
434
434
|
if (t) return t;
|
|
435
|
-
const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${
|
|
435
|
+
const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${xe++}`, r = document.createElement("section");
|
|
436
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
437
|
<header class="rte-content-rules-header">
|
|
438
438
|
<h2 class="rte-content-rules-title">${k(n.labels.panelTitle)}</h2>
|
|
@@ -462,21 +462,21 @@ function qe(e) {
|
|
|
462
462
|
}
|
|
463
463
|
if (c === "run-audit") {
|
|
464
464
|
const u = d.get(e) || E || n;
|
|
465
|
-
|
|
465
|
+
v(e, u, !0);
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
468
|
if (c === "toggle-realtime") {
|
|
469
469
|
const a = !A(e, d.get(e) || E || n);
|
|
470
470
|
if (T.set(e, a), O(e, r, d.get(e) || E || n), a) {
|
|
471
471
|
const y = d.get(e) || E || n;
|
|
472
|
-
|
|
472
|
+
v(e, y, !0);
|
|
473
473
|
}
|
|
474
474
|
return;
|
|
475
475
|
}
|
|
476
476
|
if (c === "focus-issue") {
|
|
477
|
-
const u = l.getAttribute("data-issue-id") || "", a =
|
|
477
|
+
const u = l.getAttribute("data-issue-id") || "", a = Oe(e, u);
|
|
478
478
|
if (!a) return;
|
|
479
|
-
|
|
479
|
+
We(e, a), W(e, !1);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
}), r.addEventListener("keydown", (s) => {
|
|
@@ -495,42 +495,45 @@ function qe(e) {
|
|
|
495
495
|
}), G(r, e), document.body.appendChild(r), h.set(e, r), B.set(e, !1), O(e, r, n), r;
|
|
496
496
|
}
|
|
497
497
|
function ne(e) {
|
|
498
|
-
const t =
|
|
499
|
-
|
|
498
|
+
const t = Pe(e);
|
|
499
|
+
qe(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
500
|
}
|
|
501
501
|
function Q(e, t) {
|
|
502
502
|
const n = U(e);
|
|
503
503
|
return (typeof t == "boolean" ? t : !n) ? ne(e) : W(e, !1), !0;
|
|
504
504
|
}
|
|
505
|
-
function
|
|
505
|
+
function be(e) {
|
|
506
506
|
const t = V.get(e);
|
|
507
507
|
typeof t == "number" && (window.clearTimeout(t), _.delete(t), V.delete(e));
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function he(e) {
|
|
510
510
|
const t = d.get(e) || E;
|
|
511
511
|
if (!t || !A(e, t)) return;
|
|
512
|
-
|
|
512
|
+
be(e);
|
|
513
513
|
const n = window.setTimeout(() => {
|
|
514
|
-
_.delete(n), V.delete(e),
|
|
514
|
+
_.delete(n), V.delete(e), v(e, t, !1);
|
|
515
515
|
}, t.debounceMs);
|
|
516
516
|
_.add(n), V.set(e, n);
|
|
517
517
|
}
|
|
518
|
-
function
|
|
519
|
-
|
|
520
|
-
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
|
|
518
|
+
function re(e) {
|
|
519
|
+
return typeof e.key == "string" ? e.key.toLowerCase() : "";
|
|
521
520
|
}
|
|
522
521
|
function ze(e) {
|
|
523
|
-
const t = e
|
|
524
|
-
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "
|
|
522
|
+
const t = re(e);
|
|
523
|
+
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
|
|
525
524
|
}
|
|
526
525
|
function _e(e) {
|
|
527
|
-
const t = e
|
|
526
|
+
const t = re(e);
|
|
527
|
+
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
|
|
528
|
+
}
|
|
529
|
+
function Be(e) {
|
|
530
|
+
const t = re(e);
|
|
528
531
|
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "t";
|
|
529
532
|
}
|
|
530
|
-
function
|
|
531
|
-
if (typeof document > "u" || document.getElementById(
|
|
533
|
+
function De() {
|
|
534
|
+
if (typeof document > "u" || document.getElementById(le)) return;
|
|
532
535
|
const e = document.createElement("style");
|
|
533
|
-
e.id =
|
|
536
|
+
e.id = le, e.textContent = `
|
|
534
537
|
.rte-toolbar-group-items.content-rules,
|
|
535
538
|
.editora-toolbar-group-items.content-rules {
|
|
536
539
|
display: flex;
|
|
@@ -905,19 +908,19 @@ function Be() {
|
|
|
905
908
|
}
|
|
906
909
|
`, document.head.appendChild(e);
|
|
907
910
|
}
|
|
908
|
-
function
|
|
911
|
+
function Ne(e) {
|
|
909
912
|
E = e, L || (L = (t) => {
|
|
910
913
|
const o = t.target?.closest(R);
|
|
911
914
|
if (!o) return;
|
|
912
|
-
g = o, d.has(o) || d.set(o, e),
|
|
915
|
+
g = o, d.has(o) || d.set(o, e), C.has(o) || C.set(o, []), T.has(o) || T.set(o, e.enableRealtime);
|
|
913
916
|
const r = h.get(o);
|
|
914
917
|
r && (G(r, o), J(o, r), O(o, r, d.get(o) || e)), $(o, "toggleContentRulesPanel", U(o)), $(o, "toggleContentRulesRealtime", A(o, e));
|
|
915
918
|
}, document.addEventListener("focusin", L, !0)), I || (I = (t) => {
|
|
916
919
|
const o = t.target?.closest(R);
|
|
917
|
-
o && (g = o,
|
|
920
|
+
o && (g = o, he(o));
|
|
918
921
|
}, document.addEventListener("input", I, !0)), H || (H = (t) => {
|
|
919
922
|
if (t.defaultPrevented || t.target?.closest("input, textarea, select")) return;
|
|
920
|
-
const o = t.key === "Escape", r =
|
|
923
|
+
const o = t.key === "Escape", r = ze(t), s = _e(t), i = Be(t);
|
|
921
924
|
if (!o && !r && !s && !i)
|
|
922
925
|
return;
|
|
923
926
|
const l = M(void 0, !1);
|
|
@@ -932,7 +935,7 @@ function De(e) {
|
|
|
932
935
|
return;
|
|
933
936
|
}
|
|
934
937
|
if (s) {
|
|
935
|
-
t.preventDefault(), t.stopPropagation(),
|
|
938
|
+
t.preventDefault(), t.stopPropagation(), v(l, c, !0), ne(l);
|
|
936
939
|
return;
|
|
937
940
|
}
|
|
938
941
|
if (i) {
|
|
@@ -940,26 +943,26 @@ function De(e) {
|
|
|
940
943
|
const u = !A(l, c);
|
|
941
944
|
T.set(l, u);
|
|
942
945
|
const a = h.get(l);
|
|
943
|
-
a && O(l, a, c), $(l, "toggleContentRulesRealtime", u), u &&
|
|
946
|
+
a && O(l, a, c), $(l, "toggleContentRulesRealtime", u), u && v(l, c, !0);
|
|
944
947
|
}
|
|
945
948
|
}, document.addEventListener("keydown", H, !0)), S || (S = () => {
|
|
946
949
|
h.forEach((t, n) => {
|
|
947
950
|
if (!n.isConnected || !t.isConnected) {
|
|
948
|
-
|
|
951
|
+
be(n), t.remove(), h.delete(n), B.delete(n);
|
|
949
952
|
return;
|
|
950
953
|
}
|
|
951
954
|
G(t, n), J(n, t);
|
|
952
955
|
});
|
|
953
956
|
}, window.addEventListener("scroll", S, !0), window.addEventListener("resize", S));
|
|
954
957
|
}
|
|
955
|
-
function
|
|
958
|
+
function Ke() {
|
|
956
959
|
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
960
|
e.remove();
|
|
958
961
|
}), h.clear(), E = null, g = null;
|
|
959
962
|
}
|
|
960
|
-
const
|
|
963
|
+
const je = (e = {}) => {
|
|
961
964
|
const t = j(e);
|
|
962
|
-
return
|
|
965
|
+
return De(), {
|
|
963
966
|
name: "contentRules",
|
|
964
967
|
toolbar: [
|
|
965
968
|
{
|
|
@@ -997,7 +1000,7 @@ const Ke = (e = {}) => {
|
|
|
997
1000
|
const r = M(o);
|
|
998
1001
|
if (!r || Z(r)) return !1;
|
|
999
1002
|
const s = d.get(r) || t;
|
|
1000
|
-
return d.set(r, s), g = r, Q(r, !0),
|
|
1003
|
+
return d.set(r, s), g = r, Q(r, !0), v(r, s, !1), !0;
|
|
1001
1004
|
},
|
|
1002
1005
|
toggleContentRulesPanel: (n, o) => {
|
|
1003
1006
|
const r = M(o);
|
|
@@ -1006,14 +1009,14 @@ const Ke = (e = {}) => {
|
|
|
1006
1009
|
const s = d.get(r) || t;
|
|
1007
1010
|
d.set(r, s);
|
|
1008
1011
|
const i = Q(r, typeof n == "boolean" ? n : void 0);
|
|
1009
|
-
return U(r) &&
|
|
1012
|
+
return U(r) && v(r, s, !1), i;
|
|
1010
1013
|
},
|
|
1011
1014
|
runContentRulesAudit: async (n, o) => {
|
|
1012
1015
|
const r = M(o);
|
|
1013
1016
|
if (!r) return !1;
|
|
1014
1017
|
g = r;
|
|
1015
1018
|
const s = d.get(r) || t;
|
|
1016
|
-
return d.set(r, s), await
|
|
1019
|
+
return d.set(r, s), await v(r, s, !0), ne(r), !0;
|
|
1017
1020
|
},
|
|
1018
1021
|
toggleContentRulesRealtime: (n, o) => {
|
|
1019
1022
|
const r = M(o);
|
|
@@ -1024,12 +1027,12 @@ const Ke = (e = {}) => {
|
|
|
1024
1027
|
const i = typeof n == "boolean" ? n : !A(r, s);
|
|
1025
1028
|
T.set(r, i);
|
|
1026
1029
|
const l = h.get(r);
|
|
1027
|
-
return l && O(r, l, s), $(r, "toggleContentRulesRealtime", i), i &&
|
|
1030
|
+
return l && O(r, l, s), $(r, "toggleContentRulesRealtime", i), i && v(r, s, !0), !0;
|
|
1028
1031
|
},
|
|
1029
1032
|
getContentRulesIssues: (n, o) => {
|
|
1030
1033
|
const r = M(o);
|
|
1031
1034
|
if (!r) return !1;
|
|
1032
|
-
const s =
|
|
1035
|
+
const s = C.get(r) || [];
|
|
1033
1036
|
if (typeof n == "function")
|
|
1034
1037
|
try {
|
|
1035
1038
|
n(s);
|
|
@@ -1053,7 +1056,7 @@ const Ke = (e = {}) => {
|
|
|
1053
1056
|
...n.labels || {}
|
|
1054
1057
|
}
|
|
1055
1058
|
});
|
|
1056
|
-
d.set(r, i), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, i) &&
|
|
1059
|
+
d.set(r, i), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, i) && v(r, i, !0);
|
|
1057
1060
|
const l = h.get(r);
|
|
1058
1061
|
if (l) {
|
|
1059
1062
|
l.setAttribute("aria-label", i.labels.panelAriaLabel);
|
|
@@ -1074,20 +1077,20 @@ const Ke = (e = {}) => {
|
|
|
1074
1077
|
init: function(o) {
|
|
1075
1078
|
N += 1;
|
|
1076
1079
|
const r = this && typeof this.__pluginConfig == "object" ? j({ ...t, ...this.__pluginConfig }) : t;
|
|
1077
|
-
|
|
1080
|
+
Ne(r);
|
|
1078
1081
|
const s = M(
|
|
1079
1082
|
o && o.editorElement ? { editorElement: o.editorElement } : void 0,
|
|
1080
1083
|
!1
|
|
1081
1084
|
);
|
|
1082
|
-
s && (g = s, d.set(s, r), T.set(s, r.enableRealtime),
|
|
1085
|
+
s && (g = s, d.set(s, r), T.set(s, r.enableRealtime), C.set(s, []), $(s, "toggleContentRulesPanel", !1), $(s, "toggleContentRulesRealtime", r.enableRealtime), r.enableRealtime && he(s));
|
|
1083
1086
|
},
|
|
1084
1087
|
destroy: () => {
|
|
1085
1088
|
N = Math.max(0, N - 1), !(N > 0) && (_.forEach((n) => {
|
|
1086
1089
|
window.clearTimeout(n);
|
|
1087
|
-
}), _.clear(),
|
|
1090
|
+
}), _.clear(), Ke());
|
|
1088
1091
|
}
|
|
1089
1092
|
};
|
|
1090
1093
|
};
|
|
1091
1094
|
export {
|
|
1092
|
-
|
|
1095
|
+
je as ContentRulesPlugin
|
|
1093
1096
|
};
|