@editora/core 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/{ApprovalWorkflowPlugin.native-C3jtAYjG.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +136 -133
- package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
- package/dist/{BlocksLibraryPlugin.native-HMWKxWNs.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +90 -87
- package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
- package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
- package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
- package/dist/{CitationsPlugin.native-BnU0qCwR.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +132 -129
- package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
- package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
- package/dist/{ContentRulesPlugin.native-nBLQ8QFZ.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +105 -102
- package/dist/{DataBindingPlugin.native-jQ1JPRTp.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +49 -46
- package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
- package/dist/{DocSchemaPlugin.native-CHOge18O.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +55 -52
- package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-BF_-LjTq.mjs} +287 -115
- package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
- package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-D2wl32jV.mjs} +88 -103
- package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
- package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
- package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +204 -202
- package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
- package/dist/{PIIRedactionPlugin.native-DcsjmtV1.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +158 -155
- package/dist/{SlashCommandsPlugin.native-CmxvMEaE.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +2 -2
- package/dist/{SmartPastePlugin.native-BOKKtF07.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +127 -124
- package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +100 -76
- package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -26
- package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
- package/dist/{TranslationWorkflowPlugin.native-Bz6jDGvj.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +104 -101
- package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
- package/dist/editora.min.js +1 -1
- package/dist/editora.umd.js +1 -1
- package/dist/index-CPMGUZfB.js +10 -0
- package/dist/{index-DqC57IEH.mjs → index-DBoj6QfW.mjs} +17 -15
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
- package/dist/plugin-loader.js +37 -37
- package/dist/webcomponent-core.js +18 -16
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +139 -62
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +50 -48
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +1174 -1071
- package/package.json +11 -5
- package/LICENSE +0 -21
- package/dist/BlockquotePlugin.native-JFmOLsxN.mjs +0 -48
- package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs +0 -79
- package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +0 -309
- package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +0 -140
- package/dist/CodePlugin.native-DlpTPdkd.mjs +0 -2691
- package/dist/DirectionPlugin.native-CDnbdNyl.mjs +0 -130
- package/dist/HeadingPlugin.native-DrLYwQnQ.mjs +0 -64
- package/dist/MathPlugin.native-f_mDp8VL.mjs +0 -292
- package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +0 -559
- package/dist/TemplatePlugin.native-CrpfKRJ8.mjs +0 -602
- package/dist/index-D1LOqg5C.js +0 -10
package/dist/{ContentRulesPlugin.native-nBLQ8QFZ.mjs → ContentRulesPlugin.native-vPx5nC73.mjs}
RENAMED
|
@@ -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, m = 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) => {
|
|
@@ -37,15 +37,15 @@ function ae(e) {
|
|
|
37
37
|
function j(e = {}) {
|
|
38
38
|
var t, n, o, r;
|
|
39
39
|
return {
|
|
40
|
-
bannedWords:
|
|
41
|
-
requiredHeadings:
|
|
40
|
+
bannedWords: ie(e.bannedWords),
|
|
41
|
+
requiredHeadings: ie(e.requiredHeadings),
|
|
42
42
|
maxSentenceWords: Math.max(8, Number((t = e.maxSentenceWords) != null ? t : 32)),
|
|
43
43
|
minReadabilityScore: Math.max(0, Math.min(120, Number((n = e.minReadabilityScore) != null ? n : 55))),
|
|
44
44
|
maxIssues: Math.max(1, Number((o = e.maxIssues) != null ? o : 100)),
|
|
45
45
|
debounceMs: Math.max(50, Number((r = e.debounceMs) != null ? r : 220)),
|
|
46
46
|
enableRealtime: e.enableRealtime !== !1,
|
|
47
|
-
labels:
|
|
48
|
-
normalizeText: e.normalizeText ||
|
|
47
|
+
labels: ye(e.labels),
|
|
48
|
+
normalizeText: e.normalizeText || we,
|
|
49
49
|
customRules: Array.isArray(e.customRules) ? e.customRules : []
|
|
50
50
|
};
|
|
51
51
|
}
|
|
@@ -58,11 +58,11 @@ function F(e) {
|
|
|
58
58
|
const t = e.querySelector(R);
|
|
59
59
|
return t instanceof HTMLElement ? t : null;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function ke() {
|
|
62
62
|
if (typeof window == "undefined") return null;
|
|
63
|
-
const e = window[
|
|
63
|
+
const e = window[se];
|
|
64
64
|
if (!(e instanceof HTMLElement)) return null;
|
|
65
|
-
window[
|
|
65
|
+
window[se] = null;
|
|
66
66
|
const t = F(e);
|
|
67
67
|
if (t) return t;
|
|
68
68
|
const n = e.closest(ee);
|
|
@@ -72,7 +72,7 @@ function we() {
|
|
|
72
72
|
}
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function Re(e) {
|
|
76
76
|
const t = e.closest("[data-editora-editor]");
|
|
77
77
|
if (t && F(t) === e)
|
|
78
78
|
return t;
|
|
@@ -87,16 +87,16 @@ function ke(e) {
|
|
|
87
87
|
function K(e) {
|
|
88
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
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function Ee(e) {
|
|
91
91
|
const t = X(e);
|
|
92
92
|
if (K(t)) return !0;
|
|
93
93
|
const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
|
|
94
94
|
return K(n) ? !0 : K(document.documentElement) || K(document.body);
|
|
95
95
|
}
|
|
96
96
|
function G(e, t) {
|
|
97
|
-
e.classList.remove("rte-content-rules-theme-dark"),
|
|
97
|
+
e.classList.remove("rte-content-rules-theme-dark"), Ee(t) && e.classList.add("rte-content-rules-theme-dark");
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function ve(e) {
|
|
100
100
|
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
101
101
|
}
|
|
102
102
|
function M(e, t = !0) {
|
|
@@ -107,11 +107,11 @@ function M(e, t = !0) {
|
|
|
107
107
|
const a = s.querySelector(R);
|
|
108
108
|
if (a instanceof HTMLElement) return a;
|
|
109
109
|
}
|
|
110
|
-
const n =
|
|
110
|
+
const n = ke();
|
|
111
111
|
if (n) return n;
|
|
112
112
|
const o = window.getSelection();
|
|
113
113
|
if (o && o.rangeCount > 0) {
|
|
114
|
-
const s = o.getRangeAt(0).startContainer, a =
|
|
114
|
+
const s = o.getRangeAt(0).startContainer, a = ve(s), l = a == null ? void 0 : a.closest(R);
|
|
115
115
|
if (l) return l;
|
|
116
116
|
}
|
|
117
117
|
const r = document.activeElement;
|
|
@@ -129,24 +129,24 @@ function Ce(e, t) {
|
|
|
129
129
|
const n = e.innerText || e.textContent || "";
|
|
130
130
|
return t(n);
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function $e(e) {
|
|
133
133
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function ce(e) {
|
|
136
136
|
let t = 2166136261;
|
|
137
137
|
for (let n = 0; n < e.length; n += 1)
|
|
138
138
|
t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
139
139
|
return t >>> 0;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function ue(e) {
|
|
142
142
|
const t = e.match(/\b[\w'-]+\b/g);
|
|
143
143
|
return t ? t.length : 0;
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function ge(e) {
|
|
146
146
|
const t = e.match(/[^.!?]+[.!?]*/g);
|
|
147
147
|
return t ? t.map((n) => n.trim()).filter(Boolean).length : 0;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function Me(e) {
|
|
150
150
|
const t = e.toLowerCase().replace(/[^a-z]/g, "");
|
|
151
151
|
if (!t) return 0;
|
|
152
152
|
if (t.length <= 3) return 1;
|
|
@@ -154,10 +154,10 @@ function $e(e) {
|
|
|
154
154
|
let o = n ? n.length : 1;
|
|
155
155
|
return t.endsWith("e") && (o -= 1), Math.max(1, o);
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Se(e) {
|
|
158
158
|
const t = e.match(/\b[\w'-]+\b/g) || [], n = t.length;
|
|
159
159
|
if (n === 0) return 100;
|
|
160
|
-
const o = Math.max(1,
|
|
160
|
+
const o = Math.max(1, ge(e)), r = t.reduce((a, l) => a + Me(l), 0), s = 206.835 - 1.015 * (n / o) - 84.6 * (r / Math.max(1, n));
|
|
161
161
|
return Number.isFinite(s) ? Math.max(0, Math.min(120, s)) : 0;
|
|
162
162
|
}
|
|
163
163
|
function z(e, t) {
|
|
@@ -169,54 +169,54 @@ function x(e, t) {
|
|
|
169
169
|
function P(e, t, n) {
|
|
170
170
|
x(e, n) || e.push(t);
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function me(e, t = 140) {
|
|
173
173
|
return e.length <= t ? e : `${e.slice(0, t - 1).trimEnd()}...`;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Te(e, t, n, o) {
|
|
176
176
|
return {
|
|
177
177
|
id: e.id || z(t, o),
|
|
178
178
|
ruleId: e.ruleId || t,
|
|
179
179
|
severity: e.severity || n,
|
|
180
180
|
message: e.message || t,
|
|
181
|
-
excerpt: e.excerpt ?
|
|
181
|
+
excerpt: e.excerpt ? me(e.excerpt, 220) : void 0,
|
|
182
182
|
suggestion: e.suggestion,
|
|
183
183
|
locateText: e.locateText,
|
|
184
184
|
selector: e.selector
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
function
|
|
187
|
+
function Ae(e, t) {
|
|
188
188
|
const n = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), o = /* @__PURE__ */ new Set();
|
|
189
189
|
return n.forEach((r) => {
|
|
190
190
|
const s = t(r.textContent || "").toLowerCase();
|
|
191
191
|
s && o.add(s);
|
|
192
192
|
}), o;
|
|
193
193
|
}
|
|
194
|
-
function
|
|
194
|
+
function Le(e) {
|
|
195
195
|
const t = e.match(/[^.!?\n]+[.!?]?/g);
|
|
196
196
|
return t ? t.map((n) => n.trim()).filter(Boolean) : [];
|
|
197
197
|
}
|
|
198
|
-
async function
|
|
199
|
-
const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${
|
|
200
|
-
if (!n &&
|
|
201
|
-
return
|
|
198
|
+
async function v(e, t, n = !1) {
|
|
199
|
+
const o = Ce(e, t.normalizeText), r = e.innerHTML, s = `${o.length}:${ce(o)}:${r.length}:${ce(r)}`;
|
|
200
|
+
if (!n && ae.get(e) === s)
|
|
201
|
+
return C.get(e) || [];
|
|
202
202
|
const a = (Y.get(e) || 0) + 1;
|
|
203
203
|
Y.set(e, a);
|
|
204
|
-
const l =
|
|
204
|
+
const l = ue(o), c = ge(o), u = Se(o), i = [], y = t.labels;
|
|
205
205
|
if (t.bannedWords.length > 0) {
|
|
206
206
|
let w = 0;
|
|
207
207
|
for (const p of t.bannedWords) {
|
|
208
|
-
const g = new RegExp(`\\b${
|
|
208
|
+
const g = new RegExp(`\\b${$e(p)}\\b`, "gi");
|
|
209
209
|
let b = g.exec(o);
|
|
210
210
|
for (; b && !x(i, t.maxIssues); ) {
|
|
211
|
-
const
|
|
211
|
+
const oe = b[0];
|
|
212
212
|
P(
|
|
213
213
|
i,
|
|
214
214
|
{
|
|
215
215
|
id: z("banned-word", w),
|
|
216
216
|
ruleId: "banned-word",
|
|
217
217
|
severity: "error",
|
|
218
|
-
message: `${y.bannedWordMessage}: "${
|
|
219
|
-
locateText:
|
|
218
|
+
message: `${y.bannedWordMessage}: "${oe}"`,
|
|
219
|
+
locateText: oe,
|
|
220
220
|
suggestion: "Replace or remove banned terms."
|
|
221
221
|
},
|
|
222
222
|
t.maxIssues
|
|
@@ -226,7 +226,7 @@ async function C(e, t, n = !1) {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
if (!x(i, t.maxIssues) && t.requiredHeadings.length > 0) {
|
|
229
|
-
const w =
|
|
229
|
+
const w = Ae(e, t.normalizeText);
|
|
230
230
|
let p = 0;
|
|
231
231
|
t.requiredHeadings.forEach((g) => {
|
|
232
232
|
if (x(i, t.maxIssues)) return;
|
|
@@ -245,11 +245,11 @@ async function C(e, t, n = !1) {
|
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
if (!x(i, t.maxIssues)) {
|
|
248
|
-
const w =
|
|
248
|
+
const w = Le(o);
|
|
249
249
|
let p = 0;
|
|
250
250
|
for (const g of w) {
|
|
251
251
|
if (x(i, t.maxIssues)) break;
|
|
252
|
-
const b =
|
|
252
|
+
const b = ue(g);
|
|
253
253
|
b <= t.maxSentenceWords || (P(
|
|
254
254
|
i,
|
|
255
255
|
{
|
|
@@ -257,7 +257,7 @@ async function C(e, t, n = !1) {
|
|
|
257
257
|
ruleId: "sentence-length",
|
|
258
258
|
severity: "warning",
|
|
259
259
|
message: `${y.sentenceLengthMessage} (${b}/${t.maxSentenceWords} words)`,
|
|
260
|
-
excerpt:
|
|
260
|
+
excerpt: me(g, 200),
|
|
261
261
|
locateText: g.slice(0, 64),
|
|
262
262
|
suggestion: "Split into shorter sentences for readability."
|
|
263
263
|
},
|
|
@@ -293,7 +293,7 @@ async function C(e, t, n = !1) {
|
|
|
293
293
|
for (let b = 0; b < g.length && !x(i, t.maxIssues); b += 1)
|
|
294
294
|
P(
|
|
295
295
|
i,
|
|
296
|
-
|
|
296
|
+
Te(g[b], p.id, p.severity || "warning", b),
|
|
297
297
|
t.maxIssues
|
|
298
298
|
);
|
|
299
299
|
} catch (g) {
|
|
@@ -301,13 +301,13 @@ async function C(e, t, n = !1) {
|
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
303
|
if (Y.get(e) !== a)
|
|
304
|
-
return
|
|
304
|
+
return C.get(e) || [];
|
|
305
305
|
const D = {
|
|
306
306
|
readabilityScore: u,
|
|
307
307
|
wordCount: l,
|
|
308
308
|
sentenceCount: c
|
|
309
309
|
};
|
|
310
|
-
return
|
|
310
|
+
return ae.set(e, s), C.set(e, i), fe.set(e, D), te(e), e.dispatchEvent(
|
|
311
311
|
new CustomEvent("editora:content-rules-audit", {
|
|
312
312
|
bubbles: !0,
|
|
313
313
|
detail: {
|
|
@@ -317,17 +317,17 @@ async function C(e, t, n = !1) {
|
|
|
317
317
|
})
|
|
318
318
|
), i;
|
|
319
319
|
}
|
|
320
|
-
function
|
|
320
|
+
function Ie(e) {
|
|
321
321
|
return e.reduce(
|
|
322
322
|
(t, n) => (t[n.severity] += 1, t),
|
|
323
323
|
{ error: 0, warning: 0, info: 0 }
|
|
324
324
|
);
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function He(e) {
|
|
327
327
|
return e === "error" ? "Error" : e === "warning" ? "Warning" : "Info";
|
|
328
328
|
}
|
|
329
329
|
function $(e, t, n) {
|
|
330
|
-
const o =
|
|
330
|
+
const o = Re(e);
|
|
331
331
|
Array.from(
|
|
332
332
|
o.querySelectorAll(
|
|
333
333
|
`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
|
|
@@ -346,7 +346,7 @@ function J(e, t) {
|
|
|
346
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
347
|
t.style.left = `${l}px`, t.style.top = `${c}px`;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function de(e, t) {
|
|
350
350
|
const n = t.trim().toLowerCase();
|
|
351
351
|
if (!n) return !1;
|
|
352
352
|
const o = window.getSelection();
|
|
@@ -365,16 +365,16 @@ function ue(e, t) {
|
|
|
365
365
|
}
|
|
366
366
|
return !1;
|
|
367
367
|
}
|
|
368
|
-
function
|
|
368
|
+
function We(e, t) {
|
|
369
369
|
if (t.selector) {
|
|
370
370
|
const n = e.querySelector(t.selector);
|
|
371
371
|
if (n)
|
|
372
372
|
return n.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), n.focus({ preventScroll: !0 }), !0;
|
|
373
373
|
}
|
|
374
|
-
return !!(t.locateText &&
|
|
374
|
+
return !!(t.locateText && de(e, t.locateText) || t.excerpt && de(e, t.excerpt.slice(0, 64)));
|
|
375
375
|
}
|
|
376
|
-
function
|
|
377
|
-
return (
|
|
376
|
+
function Oe(e, t) {
|
|
377
|
+
return (C.get(e) || []).find((o) => o.id === t);
|
|
378
378
|
}
|
|
379
379
|
function A(e, t) {
|
|
380
380
|
const n = T.get(e);
|
|
@@ -391,11 +391,11 @@ function te(e) {
|
|
|
391
391
|
if (!t) return;
|
|
392
392
|
const n = d.get(e) || E;
|
|
393
393
|
if (!n) return;
|
|
394
|
-
const o =
|
|
394
|
+
const o = C.get(e) || [], r = fe.get(e) || {
|
|
395
395
|
readabilityScore: 100
|
|
396
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
397
|
if (!s || !a || !l || !c) return;
|
|
398
|
-
const u =
|
|
398
|
+
const u = Ie(o);
|
|
399
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
400
|
l.innerHTML = `<li class="rte-content-rules-empty">${k(n.labels.noIssuesText)}</li>`;
|
|
401
401
|
return;
|
|
@@ -412,7 +412,7 @@ function te(e) {
|
|
|
412
412
|
data-role="issue-button"
|
|
413
413
|
aria-label="${k(w)}"
|
|
414
414
|
>
|
|
415
|
-
<span class="rte-content-rules-badge">${k(
|
|
415
|
+
<span class="rte-content-rules-badge">${k(He(i.severity))}</span>
|
|
416
416
|
<span class="rte-content-rules-message">${k(i.message)}</span>
|
|
417
417
|
</button>
|
|
418
418
|
${y}
|
|
@@ -425,15 +425,15 @@ function W(e, t = !1) {
|
|
|
425
425
|
const n = h.get(e);
|
|
426
426
|
n && (n.classList.remove("show"), B.set(e, !1), $(e, "toggleContentRulesPanel", !1), t && e.focus({ preventScroll: !0 }));
|
|
427
427
|
}
|
|
428
|
-
function
|
|
428
|
+
function qe(e) {
|
|
429
429
|
h.forEach((t, n) => {
|
|
430
430
|
n !== e && W(n, !1);
|
|
431
431
|
});
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function Pe(e) {
|
|
434
434
|
const t = h.get(e);
|
|
435
435
|
if (t) return t;
|
|
436
|
-
const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${
|
|
436
|
+
const n = d.get(e) || E || j(), o = `rte-content-rules-panel-${xe++}`, r = document.createElement("section");
|
|
437
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
438
|
<header class="rte-content-rules-header">
|
|
439
439
|
<h2 class="rte-content-rules-title">${k(n.labels.panelTitle)}</h2>
|
|
@@ -463,21 +463,21 @@ function qe(e) {
|
|
|
463
463
|
}
|
|
464
464
|
if (c === "run-audit") {
|
|
465
465
|
const u = d.get(e) || E || n;
|
|
466
|
-
|
|
466
|
+
v(e, u, !0);
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
469
|
if (c === "toggle-realtime") {
|
|
470
470
|
const i = !A(e, d.get(e) || E || n);
|
|
471
471
|
if (T.set(e, i), O(e, r, d.get(e) || E || n), i) {
|
|
472
472
|
const y = d.get(e) || E || n;
|
|
473
|
-
|
|
473
|
+
v(e, y, !0);
|
|
474
474
|
}
|
|
475
475
|
return;
|
|
476
476
|
}
|
|
477
477
|
if (c === "focus-issue") {
|
|
478
|
-
const u = l.getAttribute("data-issue-id") || "", i =
|
|
478
|
+
const u = l.getAttribute("data-issue-id") || "", i = Oe(e, u);
|
|
479
479
|
if (!i) return;
|
|
480
|
-
|
|
480
|
+
We(e, i), W(e, !1);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
}), r.addEventListener("keydown", (s) => {
|
|
@@ -496,8 +496,8 @@ function qe(e) {
|
|
|
496
496
|
}), G(r, e), document.body.appendChild(r), h.set(e, r), B.set(e, !1), O(e, r, n), r;
|
|
497
497
|
}
|
|
498
498
|
function ne(e) {
|
|
499
|
-
const t =
|
|
500
|
-
|
|
499
|
+
const t = Pe(e);
|
|
500
|
+
qe(e), t.classList.add("show"), B.set(e, !0), G(t, e), J(e, t), te(e), $(e, "toggleContentRulesPanel", !0);
|
|
501
501
|
const n = t.querySelector('[data-action="run-audit"]');
|
|
502
502
|
n == null || n.focus();
|
|
503
503
|
}
|
|
@@ -505,35 +505,38 @@ function Q(e, t) {
|
|
|
505
505
|
const n = U(e);
|
|
506
506
|
return (typeof t == "boolean" ? t : !n) ? ne(e) : W(e, !1), !0;
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function be(e) {
|
|
509
509
|
const t = V.get(e);
|
|
510
510
|
typeof t == "number" && (window.clearTimeout(t), _.delete(t), V.delete(e));
|
|
511
511
|
}
|
|
512
|
-
function
|
|
512
|
+
function he(e) {
|
|
513
513
|
const t = d.get(e) || E;
|
|
514
514
|
if (!t || !A(e, t)) return;
|
|
515
|
-
|
|
515
|
+
be(e);
|
|
516
516
|
const n = window.setTimeout(() => {
|
|
517
|
-
_.delete(n), V.delete(e),
|
|
517
|
+
_.delete(n), V.delete(e), v(e, t, !1);
|
|
518
518
|
}, t.debounceMs);
|
|
519
519
|
_.add(n), V.set(e, n);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
522
|
-
|
|
523
|
-
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
|
|
521
|
+
function re(e) {
|
|
522
|
+
return typeof e.key == "string" ? e.key.toLowerCase() : "";
|
|
524
523
|
}
|
|
525
524
|
function ze(e) {
|
|
526
|
-
const t = e
|
|
527
|
-
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "
|
|
525
|
+
const t = re(e);
|
|
526
|
+
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "r";
|
|
528
527
|
}
|
|
529
528
|
function _e(e) {
|
|
530
|
-
const t = e
|
|
529
|
+
const t = re(e);
|
|
530
|
+
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "l";
|
|
531
|
+
}
|
|
532
|
+
function Be(e) {
|
|
533
|
+
const t = re(e);
|
|
531
534
|
return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "t";
|
|
532
535
|
}
|
|
533
|
-
function
|
|
534
|
-
if (typeof document == "undefined" || document.getElementById(
|
|
536
|
+
function De() {
|
|
537
|
+
if (typeof document == "undefined" || document.getElementById(le)) return;
|
|
535
538
|
const e = document.createElement("style");
|
|
536
|
-
e.id =
|
|
539
|
+
e.id = le, e.textContent = `
|
|
537
540
|
.rte-toolbar-group-items.content-rules,
|
|
538
541
|
.editora-toolbar-group-items.content-rules {
|
|
539
542
|
display: flex;
|
|
@@ -908,21 +911,21 @@ function Be() {
|
|
|
908
911
|
}
|
|
909
912
|
`, document.head.appendChild(e);
|
|
910
913
|
}
|
|
911
|
-
function
|
|
914
|
+
function Ne(e) {
|
|
912
915
|
E = e, L || (L = (t) => {
|
|
913
916
|
const n = t.target, o = n == null ? void 0 : n.closest(R);
|
|
914
917
|
if (!o) return;
|
|
915
|
-
m = o, d.has(o) || d.set(o, e),
|
|
918
|
+
m = o, d.has(o) || d.set(o, e), C.has(o) || C.set(o, []), T.has(o) || T.set(o, e.enableRealtime);
|
|
916
919
|
const r = h.get(o);
|
|
917
920
|
r && (G(r, o), J(o, r), O(o, r, d.get(o) || e)), $(o, "toggleContentRulesPanel", U(o)), $(o, "toggleContentRulesRealtime", A(o, e));
|
|
918
921
|
}, document.addEventListener("focusin", L, !0)), I || (I = (t) => {
|
|
919
922
|
const n = t.target, o = n == null ? void 0 : n.closest(R);
|
|
920
|
-
o && (m = o,
|
|
923
|
+
o && (m = o, he(o));
|
|
921
924
|
}, document.addEventListener("input", I, !0)), H || (H = (t) => {
|
|
922
925
|
if (t.defaultPrevented) return;
|
|
923
926
|
const n = t.target;
|
|
924
927
|
if (n != null && n.closest("input, textarea, select")) return;
|
|
925
|
-
const o = t.key === "Escape", r =
|
|
928
|
+
const o = t.key === "Escape", r = ze(t), s = _e(t), a = Be(t);
|
|
926
929
|
if (!o && !r && !s && !a)
|
|
927
930
|
return;
|
|
928
931
|
const l = M(void 0, !1);
|
|
@@ -937,7 +940,7 @@ function De(e) {
|
|
|
937
940
|
return;
|
|
938
941
|
}
|
|
939
942
|
if (s) {
|
|
940
|
-
t.preventDefault(), t.stopPropagation(),
|
|
943
|
+
t.preventDefault(), t.stopPropagation(), v(l, c, !0), ne(l);
|
|
941
944
|
return;
|
|
942
945
|
}
|
|
943
946
|
if (a) {
|
|
@@ -945,26 +948,26 @@ function De(e) {
|
|
|
945
948
|
const u = !A(l, c);
|
|
946
949
|
T.set(l, u);
|
|
947
950
|
const i = h.get(l);
|
|
948
|
-
i && O(l, i, c), $(l, "toggleContentRulesRealtime", u), u &&
|
|
951
|
+
i && O(l, i, c), $(l, "toggleContentRulesRealtime", u), u && v(l, c, !0);
|
|
949
952
|
}
|
|
950
953
|
}, document.addEventListener("keydown", H, !0)), S || (S = () => {
|
|
951
954
|
h.forEach((t, n) => {
|
|
952
955
|
if (!n.isConnected || !t.isConnected) {
|
|
953
|
-
|
|
956
|
+
be(n), t.remove(), h.delete(n), B.delete(n);
|
|
954
957
|
return;
|
|
955
958
|
}
|
|
956
959
|
G(t, n), J(n, t);
|
|
957
960
|
});
|
|
958
961
|
}, window.addEventListener("scroll", S, !0), window.addEventListener("resize", S));
|
|
959
962
|
}
|
|
960
|
-
function
|
|
963
|
+
function Ke() {
|
|
961
964
|
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
965
|
e.remove();
|
|
963
966
|
}), h.clear(), E = null, m = null;
|
|
964
967
|
}
|
|
965
|
-
const
|
|
968
|
+
const je = (e = {}) => {
|
|
966
969
|
const t = j(e);
|
|
967
|
-
return
|
|
970
|
+
return De(), {
|
|
968
971
|
name: "contentRules",
|
|
969
972
|
toolbar: [
|
|
970
973
|
{
|
|
@@ -1002,7 +1005,7 @@ const Ke = (e = {}) => {
|
|
|
1002
1005
|
const r = M(o);
|
|
1003
1006
|
if (!r || Z(r)) return !1;
|
|
1004
1007
|
const s = d.get(r) || t;
|
|
1005
|
-
return d.set(r, s), m = r, Q(r, !0),
|
|
1008
|
+
return d.set(r, s), m = r, Q(r, !0), v(r, s, !1), !0;
|
|
1006
1009
|
},
|
|
1007
1010
|
toggleContentRulesPanel: (n, o) => {
|
|
1008
1011
|
const r = M(o);
|
|
@@ -1011,14 +1014,14 @@ const Ke = (e = {}) => {
|
|
|
1011
1014
|
const s = d.get(r) || t;
|
|
1012
1015
|
d.set(r, s);
|
|
1013
1016
|
const a = Q(r, typeof n == "boolean" ? n : void 0);
|
|
1014
|
-
return U(r) &&
|
|
1017
|
+
return U(r) && v(r, s, !1), a;
|
|
1015
1018
|
},
|
|
1016
1019
|
runContentRulesAudit: async (n, o) => {
|
|
1017
1020
|
const r = M(o);
|
|
1018
1021
|
if (!r) return !1;
|
|
1019
1022
|
m = r;
|
|
1020
1023
|
const s = d.get(r) || t;
|
|
1021
|
-
return d.set(r, s), await
|
|
1024
|
+
return d.set(r, s), await v(r, s, !0), ne(r), !0;
|
|
1022
1025
|
},
|
|
1023
1026
|
toggleContentRulesRealtime: (n, o) => {
|
|
1024
1027
|
const r = M(o);
|
|
@@ -1029,12 +1032,12 @@ const Ke = (e = {}) => {
|
|
|
1029
1032
|
const a = typeof n == "boolean" ? n : !A(r, s);
|
|
1030
1033
|
T.set(r, a);
|
|
1031
1034
|
const l = h.get(r);
|
|
1032
|
-
return l && O(r, l, s), $(r, "toggleContentRulesRealtime", a), a &&
|
|
1035
|
+
return l && O(r, l, s), $(r, "toggleContentRulesRealtime", a), a && v(r, s, !0), !0;
|
|
1033
1036
|
},
|
|
1034
1037
|
getContentRulesIssues: (n, o) => {
|
|
1035
1038
|
const r = M(o);
|
|
1036
1039
|
if (!r) return !1;
|
|
1037
|
-
const s =
|
|
1040
|
+
const s = C.get(r) || [];
|
|
1038
1041
|
if (typeof n == "function")
|
|
1039
1042
|
try {
|
|
1040
1043
|
n(s);
|
|
@@ -1058,7 +1061,7 @@ const Ke = (e = {}) => {
|
|
|
1058
1061
|
...n.labels || {}
|
|
1059
1062
|
}
|
|
1060
1063
|
});
|
|
1061
|
-
d.set(r, a), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, a) &&
|
|
1064
|
+
d.set(r, a), typeof n.enableRealtime == "boolean" && T.set(r, n.enableRealtime), A(r, a) && v(r, a, !0);
|
|
1062
1065
|
const l = h.get(r);
|
|
1063
1066
|
if (l) {
|
|
1064
1067
|
l.setAttribute("aria-label", a.labels.panelAriaLabel);
|
|
@@ -1079,21 +1082,21 @@ const Ke = (e = {}) => {
|
|
|
1079
1082
|
init: function(o) {
|
|
1080
1083
|
N += 1;
|
|
1081
1084
|
const r = this && typeof this.__pluginConfig == "object" ? j({ ...t, ...this.__pluginConfig }) : t;
|
|
1082
|
-
|
|
1085
|
+
Ne(r);
|
|
1083
1086
|
const s = M(
|
|
1084
1087
|
o && o.editorElement ? { editorElement: o.editorElement } : void 0,
|
|
1085
1088
|
!1
|
|
1086
1089
|
);
|
|
1087
|
-
s && (m = s, d.set(s, r), T.set(s, r.enableRealtime),
|
|
1090
|
+
s && (m = s, d.set(s, r), T.set(s, r.enableRealtime), C.set(s, []), $(s, "toggleContentRulesPanel", !1), $(s, "toggleContentRulesRealtime", r.enableRealtime), r.enableRealtime && he(s));
|
|
1088
1091
|
},
|
|
1089
1092
|
destroy: () => {
|
|
1090
1093
|
N = Math.max(0, N - 1), !(N > 0) && (_.forEach((n) => {
|
|
1091
1094
|
window.clearTimeout(n);
|
|
1092
|
-
}), _.clear(),
|
|
1095
|
+
}), _.clear(), Ke());
|
|
1093
1096
|
}
|
|
1094
1097
|
};
|
|
1095
1098
|
};
|
|
1096
1099
|
export {
|
|
1097
|
-
|
|
1100
|
+
je as ContentRulesPlugin
|
|
1098
1101
|
};
|
|
1099
|
-
//# sourceMappingURL=ContentRulesPlugin.native-
|
|
1102
|
+
//# sourceMappingURL=ContentRulesPlugin.native-vPx5nC73.mjs.map
|