@editora/core 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/LICENSE +21 -0
  2. package/dist/ApprovalWorkflowPlugin.native-C3jtAYjG.mjs +1076 -0
  3. package/dist/BlocksLibraryPlugin.native-HMWKxWNs.mjs +1327 -0
  4. package/dist/CitationsPlugin.native-BnU0qCwR.mjs +1464 -0
  5. package/dist/ConditionalContentPlugin.native-CfhY46rU.mjs +1367 -0
  6. package/dist/ContentRulesPlugin.native-nBLQ8QFZ.mjs +1099 -0
  7. package/dist/DataBindingPlugin.native-jQ1JPRTp.mjs +917 -0
  8. package/dist/DocSchemaPlugin.native-CHOge18O.mjs +1325 -0
  9. package/dist/MentionPlugin.native-BMDlOqur.mjs +734 -0
  10. package/dist/PIIRedactionPlugin.native-DcsjmtV1.mjs +1396 -0
  11. package/dist/{PageBreakPlugin.native-CXdX5fAv.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +37 -37
  12. package/dist/{PreviewPlugin.native-DBvfpmIv.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +30 -30
  13. package/dist/SlashCommandsPlugin.native-CmxvMEaE.mjs +755 -0
  14. package/dist/SmartPastePlugin.native-BOKKtF07.mjs +1398 -0
  15. package/dist/TrackChangesPlugin.native-Bghu2q4a.mjs +761 -0
  16. package/dist/TranslationWorkflowPlugin.native-Bz6jDGvj.mjs +1728 -0
  17. package/dist/VersionDiffPlugin.native-Bvxgy--t.mjs +776 -0
  18. package/dist/editora.min.js +13 -13
  19. package/dist/editora.umd.js +13 -13
  20. package/dist/index-D1LOqg5C.js +10 -0
  21. package/dist/{index-yzU4NdPT.mjs → index-DqC57IEH.mjs} +424 -331
  22. package/dist/index.cjs.js +1 -1
  23. package/dist/index.esm.js +2 -2
  24. package/dist/plugin-loader.js +77 -40
  25. package/dist/webcomponent-core.js +479 -386
  26. package/dist/webcomponent-core.min.css +1 -1
  27. package/dist/webcomponent-core.min.js +39 -39
  28. package/dist/webcomponent.cjs.js +1 -1
  29. package/dist/webcomponent.esm.js +1 -1
  30. package/dist/webcomponent.js +417 -287
  31. package/dist/webcomponent.min.css +1 -1
  32. package/dist/webcomponent.min.js +5664 -394
  33. package/package.json +2 -2
  34. package/dist/index-BpE6GFbz.js +0 -10
@@ -0,0 +1,1325 @@
1
+ const E = ".rte-content, .editora-content", ie = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", fe = "__editoraCommandEditorRoot", he = "rte-doc-schema-styles", m = "rte-doc-schema-panel", v = "document-schema", T = "doc-schema", R = "docSchema", w = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', Me = {
2
+ panelTitle: "Document Schema",
3
+ panelAriaLabel: "Document schema panel",
4
+ schemaLabel: "Schema",
5
+ schemaDescriptionPrefix: "Description",
6
+ validateText: "Run Validation",
7
+ insertMissingText: "Insert Missing Sections",
8
+ realtimeOnText: "Realtime On",
9
+ realtimeOffText: "Realtime Off",
10
+ closeText: "Close",
11
+ noIssuesText: "No schema violations detected.",
12
+ summaryPrefix: "Schema",
13
+ issueListLabel: "Schema issues",
14
+ shortcutText: "Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",
15
+ helperText: "Choose a schema, validate structure, then insert missing sections safely.",
16
+ readonlyMessage: "Editor is read-only. Missing sections cannot be inserted.",
17
+ defaultPlaceholderText: "Add section content.",
18
+ missingSectionMessage: "Missing required section",
19
+ duplicateSectionMessage: "Section appears too many times",
20
+ outOfOrderMessage: "Section appears out of required order",
21
+ unknownHeadingMessage: "Heading is not part of selected schema",
22
+ insertedSummaryPrefix: "Inserted missing sections"
23
+ }, u = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), ne = /* @__PURE__ */ new Set();
24
+ let W = 0, Ae = 0, ge = 0, k = null, y = null, q = null, z = null, B = null, H = null, K = null;
25
+ function M(e) {
26
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
27
+ }
28
+ function Le(e) {
29
+ return e.replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
30
+ }
31
+ function P(e, t, n) {
32
+ return Number.isFinite(e) ? Math.max(t, Math.min(n, e)) : t;
33
+ }
34
+ function ye(e) {
35
+ return e.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
36
+ }
37
+ function ce(e, t) {
38
+ return t(e).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/, "").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i, "").replace(/[::]+$/g, "").replace(/\s+/g, " ").trim();
39
+ }
40
+ function pe() {
41
+ return [
42
+ {
43
+ id: "contract",
44
+ label: "Contract",
45
+ description: "Template for legal/commercial agreements with strict section ordering.",
46
+ strictOrder: !0,
47
+ allowUnknownHeadings: !1,
48
+ sections: [
49
+ { id: "summary", title: "Executive Summary", aliases: ["Overview"] },
50
+ { id: "scope", title: "Scope" },
51
+ { id: "terms", title: "Terms and Conditions", aliases: ["Terms"] },
52
+ { id: "responsibilities", title: "Responsibilities" },
53
+ { id: "sla", title: "Service Levels", aliases: ["SLA", "Service Level Agreement"] },
54
+ { id: "termination", title: "Termination" }
55
+ ]
56
+ },
57
+ {
58
+ id: "sop",
59
+ label: "SOP",
60
+ description: "Standard operating procedure with clear implementation and governance sections.",
61
+ strictOrder: !0,
62
+ allowUnknownHeadings: !0,
63
+ sections: [
64
+ { id: "purpose", title: "Purpose" },
65
+ { id: "scope", title: "Scope" },
66
+ { id: "procedure", title: "Procedure", maxOccurrences: 10 },
67
+ { id: "roles", title: "Roles and Responsibilities", aliases: ["Responsibilities"] },
68
+ { id: "validation", title: "Validation" },
69
+ { id: "revision-history", title: "Revision History", aliases: ["Change History"] }
70
+ ]
71
+ },
72
+ {
73
+ id: "policy",
74
+ label: "Policy",
75
+ description: "Policy document with control ownership, exception handling, and enforcement.",
76
+ strictOrder: !0,
77
+ allowUnknownHeadings: !0,
78
+ sections: [
79
+ { id: "statement", title: "Policy Statement" },
80
+ { id: "applicability", title: "Applicability", aliases: ["Scope"] },
81
+ { id: "controls", title: "Controls" },
82
+ { id: "exceptions", title: "Exceptions" },
83
+ { id: "enforcement", title: "Enforcement" }
84
+ ]
85
+ }
86
+ ];
87
+ }
88
+ function Oe(e, t, n) {
89
+ var f, h;
90
+ const r = n(e.title || "");
91
+ if (!r) return null;
92
+ const s = ye(n(e.id || r)) || `section-${t + 1}`, o = P(Number((f = e.minOccurrences) != null ? f : 1), 0, 20), a = Math.max(1, o), c = P(Number((h = e.maxOccurrences) != null ? h : a), o, 40), i = n(e.placeholder || ""), l = Array.isArray(e.aliases) ? e.aliases.map((b) => n(b)).filter(Boolean) : [], d = [r, ...l].map((b) => ce(b, n)).filter(Boolean);
93
+ return {
94
+ id: s,
95
+ title: r,
96
+ minOccurrences: o,
97
+ maxOccurrences: c,
98
+ placeholder: i,
99
+ matchKeys: Array.from(new Set(d))
100
+ };
101
+ }
102
+ function Se(e, t) {
103
+ const n = Array.isArray(e) && e.length > 0 ? e : pe(), r = [], s = /* @__PURE__ */ new Set();
104
+ return n.forEach((o, a) => {
105
+ const c = t(o.label || "");
106
+ if (!c) return;
107
+ const i = ye(t(o.id || c)) || `schema-${a + 1}`;
108
+ let l = i, d = 1;
109
+ for (; s.has(l); )
110
+ l = `${i}-${d++}`;
111
+ s.add(l);
112
+ const f = Array.isArray(o.sections) ? o.sections : [], h = [], b = /* @__PURE__ */ new Set();
113
+ if (f.forEach(($, g) => {
114
+ const x = Oe($, g, t);
115
+ if (!x) return;
116
+ let N = x.id, Ie = 1;
117
+ for (; b.has(N); )
118
+ N = `${x.id}-${Ie++}`;
119
+ b.add(N), h.push({
120
+ ...x,
121
+ id: N
122
+ });
123
+ }), h.length === 0) return;
124
+ const O = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
125
+ h.forEach(($, g) => {
126
+ A.set($.id, g), $.matchKeys.forEach((x) => {
127
+ O.has(x) || O.set(x, $);
128
+ });
129
+ }), r.push({
130
+ id: l,
131
+ label: c,
132
+ description: t(o.description || ""),
133
+ strictOrder: o.strictOrder !== !1,
134
+ allowUnknownHeadings: !!o.allowUnknownHeadings,
135
+ sections: h,
136
+ matchKeyToSection: O,
137
+ orderBySectionId: A
138
+ });
139
+ }), r.length > 0 ? r : Se(pe(), t);
140
+ }
141
+ function Z(e = {}) {
142
+ var o, a, c;
143
+ const t = e.normalizeText || Le, n = Se(e.schemas, t), r = t(e.defaultSchemaId || ""), s = n.some((i) => i.id === r) ? r : ((o = n[0]) == null ? void 0 : o.id) || null;
144
+ return {
145
+ schemas: n,
146
+ defaultSchemaId: s,
147
+ enableRealtime: e.enableRealtime !== !1,
148
+ debounceMs: P(Number((a = e.debounceMs) != null ? a : 260), 60, 2e3),
149
+ maxIssues: P(Number((c = e.maxIssues) != null ? c : 80), 5, 500),
150
+ labels: {
151
+ ...Me,
152
+ ...e.labels || {}
153
+ },
154
+ normalizeText: t
155
+ };
156
+ }
157
+ function Re(e) {
158
+ return {
159
+ schemas: e.schemas.map((t) => ({
160
+ id: t.id,
161
+ label: t.label,
162
+ description: t.description || void 0,
163
+ strictOrder: t.strictOrder,
164
+ allowUnknownHeadings: t.allowUnknownHeadings,
165
+ sections: t.sections.map((n) => ({
166
+ id: n.id,
167
+ title: n.title,
168
+ minOccurrences: n.minOccurrences,
169
+ maxOccurrences: n.maxOccurrences,
170
+ placeholder: n.placeholder || void 0
171
+ }))
172
+ })),
173
+ defaultSchemaId: e.defaultSchemaId || void 0,
174
+ enableRealtime: e.enableRealtime,
175
+ debounceMs: e.debounceMs,
176
+ maxIssues: e.maxIssues,
177
+ labels: { ...e.labels },
178
+ normalizeText: e.normalizeText
179
+ };
180
+ }
181
+ function le(e) {
182
+ return e.closest(ie) || e;
183
+ }
184
+ function U(e) {
185
+ if (!e) return null;
186
+ if (e.matches(E)) return e;
187
+ const t = e.querySelector(E);
188
+ return t instanceof HTMLElement ? t : null;
189
+ }
190
+ function He() {
191
+ if (typeof window == "undefined") return null;
192
+ const e = window[fe];
193
+ if (!(e instanceof HTMLElement)) return null;
194
+ window[fe] = null;
195
+ const t = U(e);
196
+ if (t) return t;
197
+ const n = e.closest(ie);
198
+ if (n) {
199
+ const s = U(n);
200
+ if (s) return s;
201
+ }
202
+ const r = e.closest(E);
203
+ return r instanceof HTMLElement ? r : null;
204
+ }
205
+ function De(e) {
206
+ const t = e.closest("[data-editora-editor]");
207
+ if (t && U(t) === e)
208
+ return t;
209
+ let n = e;
210
+ for (; n; ) {
211
+ if (n.matches(ie) && (n === e || U(n) === e))
212
+ return n;
213
+ n = n.parentElement;
214
+ }
215
+ return le(e);
216
+ }
217
+ function xe(e) {
218
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
219
+ }
220
+ function Y(e) {
221
+ 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;
222
+ }
223
+ function Ne(e) {
224
+ const t = le(e);
225
+ if (Y(t)) return !0;
226
+ const n = t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
227
+ return Y(n) ? !0 : Y(document.documentElement) || Y(document.body);
228
+ }
229
+ function oe(e, t) {
230
+ e.classList.remove("rte-doc-schema-theme-dark"), Ne(t) && e.classList.add("rte-doc-schema-theme-dark");
231
+ }
232
+ function Pe(e) {
233
+ var t, n, r, s;
234
+ for (let o = 0; o < e.length; o += 1) {
235
+ const a = e[o];
236
+ if (!(a.type !== "childList" || a.removedNodes.length === 0))
237
+ for (let c = 0; c < a.removedNodes.length; c += 1) {
238
+ const i = a.removedNodes[c];
239
+ if (i.nodeType !== Node.ELEMENT_NODE) continue;
240
+ const l = i;
241
+ if ((t = l.matches) != null && t.call(l, E) || (n = l.matches) != null && n.call(l, `.${m}`) || (r = l.querySelector) != null && r.call(l, E) || (s = l.querySelector) != null && s.call(l, `.${m}`))
242
+ return !0;
243
+ }
244
+ }
245
+ return !1;
246
+ }
247
+ function Q() {
248
+ Array.from(ne).forEach((t) => {
249
+ t.isConnected || ue(t);
250
+ });
251
+ }
252
+ function I(e, t = !0, n = !0) {
253
+ var c;
254
+ if (Q(), (e == null ? void 0 : e.contentElement) instanceof HTMLElement) return e.contentElement;
255
+ if ((e == null ? void 0 : e.editorElement) instanceof HTMLElement) {
256
+ const i = U(e.editorElement);
257
+ if (i) return i;
258
+ }
259
+ const r = He();
260
+ if (r) return r;
261
+ const s = window.getSelection();
262
+ if (s && s.rangeCount > 0) {
263
+ const i = (c = xe(s.getRangeAt(0).startContainer)) == null ? void 0 : c.closest(
264
+ E
265
+ );
266
+ if (i) return i;
267
+ }
268
+ const o = document.activeElement;
269
+ if (o) {
270
+ if (o.matches(E)) return o;
271
+ const i = o.closest(E);
272
+ if (i) return i;
273
+ }
274
+ if (n && y && y.isConnected)
275
+ return y;
276
+ if (!t) return null;
277
+ const a = document.querySelector(E);
278
+ return a instanceof HTMLElement ? a : null;
279
+ }
280
+ function _e(e) {
281
+ const t = e.target;
282
+ if (t) {
283
+ const r = t.closest(`.${m}`);
284
+ if (r) {
285
+ const o = Array.from(S.entries()).find(([, a]) => a === r);
286
+ if (o) return o[0];
287
+ }
288
+ const s = t.closest(E);
289
+ if (s) return s;
290
+ }
291
+ const n = document.activeElement;
292
+ if (n) {
293
+ const r = n.closest(`.${m}`);
294
+ if (r) {
295
+ const o = Array.from(S.entries()).find(([, a]) => a === r);
296
+ if (o) return o[0];
297
+ }
298
+ const s = n.closest(E);
299
+ if (s) return s;
300
+ }
301
+ return null;
302
+ }
303
+ function be(e, t, n) {
304
+ const r = De(e);
305
+ Array.from(
306
+ r.querySelectorAll(
307
+ `.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`
308
+ )
309
+ ).forEach((o) => {
310
+ o.classList.toggle("active", n), o.setAttribute("data-active", n ? "true" : "false"), o.setAttribute("aria-pressed", n ? "true" : "false");
311
+ });
312
+ }
313
+ function de(e) {
314
+ const t = te.get(e);
315
+ typeof t == "number" && (window.clearTimeout(t), te.delete(e));
316
+ }
317
+ function L(e, t) {
318
+ return t && e.schemas.find((n) => n.id === t) || null;
319
+ }
320
+ function re(e) {
321
+ var t;
322
+ return e.defaultSchemaId || ((t = e.schemas[0]) == null ? void 0 : t.id) || null;
323
+ }
324
+ function p(e, t) {
325
+ u.has(e) || u.set(e, t);
326
+ let n = j.get(e);
327
+ return n || (n = {
328
+ activeSchemaId: re(t),
329
+ realtimeEnabled: t.enableRealtime,
330
+ issues: [],
331
+ headingCount: 0,
332
+ recognizedHeadingCount: 0,
333
+ missingCount: 0,
334
+ lastRunAt: null,
335
+ snapshot: ""
336
+ }, j.set(e, n)), (!n.activeSchemaId || !L(t, n.activeSchemaId)) && (n.activeSchemaId = re(t)), ne.add(e), n;
337
+ }
338
+ function ue(e) {
339
+ var t;
340
+ de(e), (t = S.get(e)) == null || t.remove(), S.delete(e), F.delete(e), u.delete(e), X.delete(e), j.delete(e), ne.delete(e), y === e && (y = null);
341
+ }
342
+ function me(e) {
343
+ return F.get(e) === !0;
344
+ }
345
+ function Ee(e) {
346
+ return e.getAttribute("contenteditable") === "false" || e.getAttribute("data-readonly") === "true";
347
+ }
348
+ function se(e, t) {
349
+ if (!t.classList.contains("show")) return;
350
+ const n = le(e).getBoundingClientRect(), r = Math.min(window.innerWidth - 20, 440), s = Math.max(10, window.innerWidth - r - 10), o = Math.min(Math.max(10, n.right - r), s), a = Math.max(10, Math.min(window.innerHeight - 10, n.top + 12));
351
+ t.style.width = `${r}px`, t.style.left = `${o}px`, t.style.top = `${a}px`, t.style.maxHeight = `${Math.max(260, window.innerHeight - 20)}px`;
352
+ }
353
+ function ee(e, t) {
354
+ const n = e.querySelector(".rte-doc-schema-live");
355
+ n && (n.textContent = t);
356
+ }
357
+ function qe(e, t) {
358
+ const n = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), r = [];
359
+ return n.forEach((s, o) => {
360
+ const a = t(s.textContent || "");
361
+ if (!a) return;
362
+ const c = Number(s.tagName.slice(1)) || 0, i = ce(a, t);
363
+ r.push({
364
+ text: a,
365
+ key: i,
366
+ index: o,
367
+ level: c
368
+ });
369
+ }), r;
370
+ }
371
+ function ve(e, t, n) {
372
+ const r = Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")), s = [];
373
+ return r.forEach((o) => {
374
+ var f;
375
+ const a = n(o.textContent || "");
376
+ if (!a) return;
377
+ const c = ce(a, n), i = c && t.matchKeyToSection.get(c) || null, l = i && (f = t.orderBySectionId.get(i.id)) != null ? f : null, d = P(Number(o.tagName.slice(1)) || 0, 1, 6);
378
+ s.push({
379
+ element: o,
380
+ level: d,
381
+ section: i,
382
+ order: l
383
+ });
384
+ }), s;
385
+ }
386
+ function ze(e, t = 2) {
387
+ const n = e.filter((i) => i.section).map((i) => i.level), r = n.length > 0 ? n : e.map((i) => i.level);
388
+ if (r.length === 0) return t;
389
+ const s = /* @__PURE__ */ new Map();
390
+ r.forEach((i, l) => {
391
+ s.has(i) || s.set(i, { count: 0, firstIndex: l });
392
+ const d = s.get(i);
393
+ d.count += 1;
394
+ });
395
+ let o = t, a = -1, c = Number.MAX_SAFE_INTEGER;
396
+ return s.forEach((i, l) => {
397
+ (i.count > a || i.count === a && i.firstIndex < c || i.count === a && i.firstIndex === c && l < o) && (o = l, a = i.count, c = i.firstIndex);
398
+ }), P(o, 1, 6);
399
+ }
400
+ function Be(e) {
401
+ var o;
402
+ const t = window.getSelection();
403
+ if (!t || t.rangeCount === 0) return null;
404
+ const n = t.getRangeAt(0);
405
+ if (((o = xe(n.startContainer)) == null ? void 0 : o.closest(E)) !== e) return null;
406
+ if (n.startContainer.nodeType === Node.ELEMENT_NODE) {
407
+ const a = n.startContainer, c = a.childNodes[n.startOffset] || null;
408
+ return { parent: a, referenceNode: c };
409
+ }
410
+ const s = n.startContainer.parentNode;
411
+ return s ? {
412
+ parent: s,
413
+ referenceNode: n.startContainer.nextSibling || null
414
+ } : null;
415
+ }
416
+ function Ke(e, t, n, r) {
417
+ var i;
418
+ const s = ve(e, n, r), o = n.orderBySectionId.get(t.id);
419
+ if (typeof o != "number" || s.length === 0)
420
+ return { parent: e, referenceNode: null };
421
+ const a = s.find((l) => typeof l.order == "number" && l.order > o);
422
+ if (a && a.element.parentNode)
423
+ return {
424
+ parent: a.element.parentNode,
425
+ referenceNode: a.element
426
+ };
427
+ let c = -1;
428
+ for (let l = 0; l < s.length; l += 1) {
429
+ const d = s[l];
430
+ typeof d.order == "number" && d.order < o && (c = l);
431
+ }
432
+ if (c >= 0) {
433
+ const l = ((i = s[c + 1]) == null ? void 0 : i.element) || null;
434
+ return {
435
+ parent: (l == null ? void 0 : l.parentNode) || s[c].element.parentNode || e,
436
+ referenceNode: l
437
+ };
438
+ }
439
+ return { parent: e, referenceNode: null };
440
+ }
441
+ function Ve(e, t, n, r) {
442
+ const s = e.ownerDocument || document, o = `h${P(r, 1, 6)}`, a = s.createElement(o);
443
+ a.setAttribute("data-doc-schema-section", t.id), a.textContent = t.title;
444
+ const c = s.createElement("p");
445
+ return c.textContent = t.placeholder || n.labels.defaultPlaceholderText, [a, c];
446
+ }
447
+ function V(e, t, n, r = {}) {
448
+ return ge += 1, {
449
+ id: `doc-schema-issue-${ge}`,
450
+ type: e,
451
+ severity: t,
452
+ message: n,
453
+ ...r
454
+ };
455
+ }
456
+ function J(e, t, n) {
457
+ return e.replace(/\{section\}/g, t || "").replace(/\{heading\}/g, n || "").trim();
458
+ }
459
+ function je(e, t, n) {
460
+ var i;
461
+ const r = qe(e, n.normalizeText), s = [], o = /* @__PURE__ */ new Map(), a = [];
462
+ for (let l = 0; l < r.length && !(s.length >= n.maxIssues); l += 1) {
463
+ const d = r[l];
464
+ if (!d.key) continue;
465
+ const f = t.matchKeyToSection.get(d.key);
466
+ if (f) {
467
+ o.set(f.id, (o.get(f.id) || 0) + 1), a.push({ section: f, heading: d });
468
+ continue;
469
+ }
470
+ t.allowUnknownHeadings || s.push(
471
+ V(
472
+ "unknown-heading",
473
+ "warning",
474
+ J(n.labels.unknownHeadingMessage, null, d.text),
475
+ {
476
+ headingText: d.text,
477
+ suggestion: "Map this heading to a schema alias or remove it from strict structure mode."
478
+ }
479
+ )
480
+ );
481
+ }
482
+ let c = 0;
483
+ for (let l = 0; l < t.sections.length && !(s.length >= n.maxIssues); l += 1) {
484
+ const d = t.sections[l], f = o.get(d.id) || 0;
485
+ f < d.minOccurrences && (c += 1, s.push(
486
+ V(
487
+ "missing-section",
488
+ "error",
489
+ J(n.labels.missingSectionMessage, d.title, null),
490
+ {
491
+ sectionId: d.id,
492
+ sectionTitle: d.title,
493
+ suggestion: `Add heading "${d.title}" to satisfy schema requirements.`
494
+ }
495
+ )
496
+ )), f > d.maxOccurrences && s.length < n.maxIssues && s.push(
497
+ V(
498
+ "duplicate-section",
499
+ "warning",
500
+ J(n.labels.duplicateSectionMessage, d.title, null),
501
+ {
502
+ sectionId: d.id,
503
+ sectionTitle: d.title,
504
+ suggestion: `Keep at most ${d.maxOccurrences} instance(s) of "${d.title}".`
505
+ }
506
+ )
507
+ );
508
+ }
509
+ if (t.strictOrder && s.length < n.maxIssues) {
510
+ let l = -1;
511
+ for (let d = 0; d < a.length && !(s.length >= n.maxIssues); d += 1) {
512
+ const f = a[d], h = (i = t.orderBySectionId.get(f.section.id)) != null ? i : d;
513
+ h < l ? s.push(
514
+ V(
515
+ "out-of-order",
516
+ "warning",
517
+ J(n.labels.outOfOrderMessage, f.section.title, f.heading.text),
518
+ {
519
+ sectionId: f.section.id,
520
+ sectionTitle: f.section.title,
521
+ headingText: f.heading.text,
522
+ suggestion: `Move "${f.section.title}" after earlier required sections.`
523
+ }
524
+ )
525
+ ) : l = h;
526
+ }
527
+ }
528
+ return {
529
+ issues: s,
530
+ headingCount: r.length,
531
+ recognizedHeadingCount: a.length,
532
+ missingCount: c
533
+ };
534
+ }
535
+ function we(e) {
536
+ const t = u.get(e) || k, n = j.get(e), r = t ? L(t, (n == null ? void 0 : n.activeSchemaId) || null) : null;
537
+ return {
538
+ activeSchemaId: (n == null ? void 0 : n.activeSchemaId) || null,
539
+ activeSchemaLabel: (r == null ? void 0 : r.label) || null,
540
+ realtimeEnabled: (n == null ? void 0 : n.realtimeEnabled) === !0,
541
+ issues: n != null && n.issues ? n.issues.map((s) => ({ ...s })) : [],
542
+ headingCount: (n == null ? void 0 : n.headingCount) || 0,
543
+ recognizedHeadingCount: (n == null ? void 0 : n.recognizedHeadingCount) || 0,
544
+ missingCount: (n == null ? void 0 : n.missingCount) || 0,
545
+ lastRunAt: (n == null ? void 0 : n.lastRunAt) || null
546
+ };
547
+ }
548
+ function D(e) {
549
+ const t = j.get(e);
550
+ be(e, "toggleDocSchemaPanel", me(e)), be(e, "toggleDocSchemaRealtime", (t == null ? void 0 : t.realtimeEnabled) === !0);
551
+ }
552
+ function _(e) {
553
+ const t = S.get(e);
554
+ if (!t) return;
555
+ const n = u.get(e) || k;
556
+ if (!n) return;
557
+ const r = p(e, n), s = L(n, r.activeSchemaId), o = t.querySelector(".rte-doc-schema-label");
558
+ o && (o.textContent = n.labels.schemaLabel);
559
+ const a = t.querySelector('[data-field="schema"]');
560
+ a && (a.innerHTML = n.schemas.map((g) => `<option value="${M(g.id)}">${M(g.label)}</option>`).join(""), a.value = r.activeSchemaId || "");
561
+ const c = t.querySelector(".rte-doc-schema-description");
562
+ if (c) {
563
+ const g = (s == null ? void 0 : s.description) || "";
564
+ c.textContent = g ? `${n.labels.schemaDescriptionPrefix}: ${g}` : "", c.hidden = !g;
565
+ }
566
+ const i = t.querySelector(".rte-doc-schema-summary");
567
+ if (i) {
568
+ const g = (s == null ? void 0 : s.label) || "N/A", x = r.issues.length;
569
+ i.textContent = `${n.labels.summaryPrefix}: ${g} • ${x} issue${x === 1 ? "" : "s"}`;
570
+ }
571
+ const l = t.querySelector(".rte-doc-schema-helper");
572
+ l && (l.textContent = n.labels.helperText);
573
+ const d = t.querySelector(".rte-doc-schema-shortcut");
574
+ d && (d.textContent = n.labels.shortcutText);
575
+ const f = t.querySelector('[data-action="run-validation"]');
576
+ f && (f.textContent = n.labels.validateText);
577
+ const h = t.querySelector('[data-action="insert-missing"]');
578
+ if (h) {
579
+ h.textContent = n.labels.insertMissingText;
580
+ const g = r.issues.some((x) => x.type === "missing-section");
581
+ h.disabled = !g || Ee(e);
582
+ }
583
+ const b = t.querySelector('[data-action="toggle-realtime"]');
584
+ b && (b.textContent = r.realtimeEnabled ? n.labels.realtimeOnText : n.labels.realtimeOffText, b.setAttribute("aria-pressed", r.realtimeEnabled ? "true" : "false"));
585
+ const O = t.querySelector('[data-action="close"]');
586
+ O && O.setAttribute("aria-label", n.labels.closeText);
587
+ const A = t.querySelector(".rte-doc-schema-issues"), $ = t.querySelector(".rte-doc-schema-empty");
588
+ A && (A.setAttribute("aria-label", n.labels.issueListLabel), r.issues.length === 0 ? (A.innerHTML = "", $ && ($.hidden = !1, $.textContent = n.labels.noIssuesText)) : ($ && ($.hidden = !0), A.innerHTML = r.issues.map((g) => {
589
+ const x = g.severity === "error" ? "error" : g.severity === "warning" ? "warning" : "info", N = g.sectionTitle || g.headingText || "";
590
+ return `
591
+ <li class="rte-doc-schema-issue ${x}" role="listitem">
592
+ <p class="rte-doc-schema-issue-message">${M(g.message)}${N ? `: <strong>${M(N)}</strong>` : ""}</p>
593
+ ${g.suggestion ? `<p class="rte-doc-schema-issue-suggestion">${M(g.suggestion)}</p>` : ""}
594
+ </li>
595
+ `;
596
+ }).join(""))), t.setAttribute("aria-label", n.labels.panelAriaLabel);
597
+ }
598
+ function G(e, t = !1) {
599
+ const n = S.get(e);
600
+ n && (n.classList.remove("show"), F.set(e, !1), D(e), t && e.focus({ preventScroll: !0 }));
601
+ }
602
+ function ae(e) {
603
+ const t = Fe(e);
604
+ S.forEach((r, s) => {
605
+ s !== e && G(s, !1);
606
+ }), t.classList.add("show"), F.set(e, !0), _(e), se(e, t), D(e);
607
+ const n = t.querySelector('[data-field="schema"]');
608
+ n == null || n.focus(), C(e, "panel-open", !1);
609
+ }
610
+ function ke(e, t) {
611
+ const n = me(e);
612
+ return (typeof t == "boolean" ? t : !n) ? ae(e) : G(e, !1), !0;
613
+ }
614
+ function Ue(e, t) {
615
+ if (t === e.innerHTML) return;
616
+ const n = window.execEditorCommand || window.executeEditorCommand;
617
+ if (typeof n == "function")
618
+ try {
619
+ n("recordDomTransaction", e, t, e.innerHTML);
620
+ } catch (r) {
621
+ }
622
+ }
623
+ function Ge(e) {
624
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
625
+ }
626
+ function C(e, t, n) {
627
+ const r = u.get(e) || k;
628
+ if (!r) return [];
629
+ const s = p(e, r), o = S.get(e), a = e.innerHTML;
630
+ if (!n && s.snapshot === a)
631
+ return s.issues;
632
+ const c = L(r, s.activeSchemaId);
633
+ if (!c)
634
+ return s.issues = [
635
+ V("missing-section", "error", "No active schema is configured for this editor.", {
636
+ suggestion: "Set `defaultSchemaId` or update schema options."
637
+ })
638
+ ], s.headingCount = 0, s.recognizedHeadingCount = 0, s.missingCount = 1, s.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), s.snapshot = a, _(e), D(e), s.issues;
639
+ const i = je(e, c, r);
640
+ return s.issues = i.issues, s.headingCount = i.headingCount, s.recognizedHeadingCount = i.recognizedHeadingCount, s.missingCount = i.missingCount, s.lastRunAt = (/* @__PURE__ */ new Date()).toISOString(), s.snapshot = a, _(e), D(e), e.dispatchEvent(
641
+ new CustomEvent("editora:doc-schema-validation", {
642
+ bubbles: !0,
643
+ detail: {
644
+ reason: t,
645
+ state: we(e)
646
+ }
647
+ })
648
+ ), o && ee(
649
+ o,
650
+ i.issues.length === 0 ? r.labels.noIssuesText : `${i.issues.length} issue${i.issues.length === 1 ? "" : "s"} detected.`
651
+ ), s.issues;
652
+ }
653
+ function $e(e) {
654
+ const t = u.get(e) || k;
655
+ if (!t) return;
656
+ de(e);
657
+ const n = window.setTimeout(() => {
658
+ te.delete(e), C(e, "realtime", !1);
659
+ }, t.debounceMs);
660
+ te.set(e, n);
661
+ }
662
+ function Ce(e, t) {
663
+ const n = u.get(e) || k;
664
+ if (!n) return !1;
665
+ const r = p(e, n), s = typeof t == "boolean" ? t : !r.realtimeEnabled;
666
+ return r.realtimeEnabled = s, s ? $e(e) : de(e), _(e), D(e), !0;
667
+ }
668
+ function Te(e) {
669
+ const t = u.get(e) || k;
670
+ if (!t) return !1;
671
+ const n = p(e, t), r = S.get(e);
672
+ if (Ee(e))
673
+ return r && ee(r, t.labels.readonlyMessage), !1;
674
+ const s = L(t, n.activeSchemaId);
675
+ if (!s) return !1;
676
+ C(e, "insert-missing-pre", !0);
677
+ const o = Array.from(
678
+ new Set(
679
+ n.issues.filter((h) => h.type === "missing-section" && h.sectionId).map((h) => h.sectionId)
680
+ )
681
+ ), a = s.sections.filter((h) => o.includes(h.id));
682
+ if (a.length === 0)
683
+ return r && ee(r, t.labels.noIssuesText), !1;
684
+ const c = e.innerHTML, i = ve(e, s, t.normalizeText), l = ze(i, 2), d = Be(e);
685
+ a.forEach((h) => {
686
+ const b = s.strictOrder ? Ke(e, h, s, t.normalizeText) : d || { parent: e, referenceNode: null }, [O, A] = Ve(e, h, t, l);
687
+ b.parent.insertBefore(O, b.referenceNode), b.parent.insertBefore(A, b.referenceNode);
688
+ }), Ue(e, c), Ge(e), C(e, "insert-missing-post", !0);
689
+ const f = a.map((h) => h.title).join(", ");
690
+ return e.dispatchEvent(
691
+ new CustomEvent("editora:doc-schema-insert-missing", {
692
+ bubbles: !0,
693
+ detail: {
694
+ schemaId: s.id,
695
+ sectionIds: a.map((h) => h.id)
696
+ }
697
+ })
698
+ ), r && ee(r, `${t.labels.insertedSummaryPrefix}: ${f}`), !0;
699
+ }
700
+ function Fe(e) {
701
+ const t = S.get(e);
702
+ if (t) return t;
703
+ const n = u.get(e) || k || Z();
704
+ p(e, n);
705
+ const r = `rte-doc-schema-panel-${Ae++}`, s = `${r}-schema`, o = document.createElement("section");
706
+ return o.className = m, o.id = r, o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false"), o.setAttribute("aria-label", n.labels.panelAriaLabel), o.innerHTML = `
707
+ <header class="rte-doc-schema-header">
708
+ <h2 class="rte-doc-schema-title">${M(n.labels.panelTitle)}</h2>
709
+ <button type="button" class="rte-doc-schema-icon-btn" data-action="close" aria-label="${M(
710
+ n.labels.closeText
711
+ )}">✕</button>
712
+ </header>
713
+ <div class="rte-doc-schema-body">
714
+ <label class="rte-doc-schema-label" for="${M(s)}"></label>
715
+ <select id="${M(s)}" class="rte-doc-schema-select" data-field="schema"></select>
716
+ <p class="rte-doc-schema-description" hidden></p>
717
+ <p class="rte-doc-schema-summary"></p>
718
+ <div class="rte-doc-schema-actions">
719
+ <button type="button" class="rte-doc-schema-btn rte-doc-schema-btn-primary" data-action="run-validation"></button>
720
+ <button type="button" class="rte-doc-schema-btn" data-action="insert-missing"></button>
721
+ <button type="button" class="rte-doc-schema-btn" data-action="toggle-realtime" aria-pressed="false"></button>
722
+ </div>
723
+ <p class="rte-doc-schema-helper"></p>
724
+ <p class="rte-doc-schema-shortcut"></p>
725
+ <div class="rte-doc-schema-issues-wrap">
726
+ <ul class="rte-doc-schema-issues" role="list" aria-label="${M(n.labels.issueListLabel)}"></ul>
727
+ <p class="rte-doc-schema-empty" hidden></p>
728
+ </div>
729
+ </div>
730
+ <div class="rte-doc-schema-live" aria-live="polite" aria-atomic="true"></div>
731
+ `, o.addEventListener("click", (a) => {
732
+ const c = a.target, i = c == null ? void 0 : c.closest("[data-action]");
733
+ if (!i) return;
734
+ const l = i.getAttribute("data-action");
735
+ if (l === "close") {
736
+ G(e, !0);
737
+ return;
738
+ }
739
+ if (l === "run-validation") {
740
+ C(e, "panel-button", !0);
741
+ return;
742
+ }
743
+ if (l === "insert-missing") {
744
+ Te(e);
745
+ return;
746
+ }
747
+ l === "toggle-realtime" && Ce(e);
748
+ }), o.addEventListener("change", (a) => {
749
+ const c = a.target;
750
+ if (!(c instanceof HTMLSelectElement) || c.getAttribute("data-field") !== "schema") return;
751
+ const i = u.get(e) || k;
752
+ if (!i) return;
753
+ const l = p(e, i), d = c.value;
754
+ L(i, d) && (l.activeSchemaId = d, l.snapshot = "", C(e, "schema-change", !0));
755
+ }), o.addEventListener("keydown", (a) => {
756
+ a.key === "Escape" && (a.preventDefault(), G(e, !0));
757
+ }), oe(o, e), document.body.appendChild(o), S.set(e, o), F.set(e, !1), _(e), o;
758
+ }
759
+ function We(e) {
760
+ const t = e.key.toLowerCase();
761
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "g";
762
+ }
763
+ function Ye(e) {
764
+ const t = e.key.toLowerCase();
765
+ return (e.metaKey || e.ctrlKey) && e.altKey && e.shiftKey && t === "j";
766
+ }
767
+ function Je(e) {
768
+ k = e, q || (q = (t) => {
769
+ Q();
770
+ const n = t.target, r = n == null ? void 0 : n.closest(E);
771
+ if (!r) return;
772
+ const s = u.get(r) || e;
773
+ p(r, s), u.set(r, s), y = r, D(r);
774
+ const o = S.get(r);
775
+ o && (oe(o, r), se(r, o), _(r));
776
+ }, document.addEventListener("focusin", q, !0)), z || (z = (t) => {
777
+ const n = t.target, r = n == null ? void 0 : n.closest(E);
778
+ if (!r) return;
779
+ const s = u.get(r) || k;
780
+ !s || !p(r, s).realtimeEnabled || $e(r);
781
+ }, document.addEventListener("input", z, !0)), B || (B = (t) => {
782
+ if (t.defaultPrevented) return;
783
+ const n = t.target;
784
+ if (n != null && n.closest(`.${m}`) && t.key !== "Escape") return;
785
+ const r = _e(t);
786
+ if (!r) return;
787
+ const s = u.get(r) || k || e;
788
+ if (p(r, s), u.set(r, s), y = r, t.key === "Escape" && me(r)) {
789
+ t.preventDefault(), G(r, !0);
790
+ return;
791
+ }
792
+ if (We(t)) {
793
+ t.preventDefault(), t.stopPropagation(), ke(r);
794
+ return;
795
+ }
796
+ Ye(t) && (t.preventDefault(), t.stopPropagation(), C(r, "shortcut", !0));
797
+ }, document.addEventListener("keydown", B, !0)), H || (H = () => {
798
+ Q(), S.forEach((t, n) => {
799
+ !n.isConnected || !t.isConnected || (oe(t, n), se(n, t));
800
+ });
801
+ }, window.addEventListener("scroll", H, !0), window.addEventListener("resize", H)), !K && typeof MutationObserver != "undefined" && document.body && (K = new MutationObserver((t) => {
802
+ Pe(t) && Q();
803
+ }), K.observe(document.body, {
804
+ childList: !0,
805
+ subtree: !0
806
+ }));
807
+ }
808
+ function Xe() {
809
+ q && (document.removeEventListener("focusin", q, !0), q = null), z && (document.removeEventListener("input", z, !0), z = null), B && (document.removeEventListener("keydown", B, !0), B = null), H && (window.removeEventListener("scroll", H, !0), window.removeEventListener("resize", H), H = null), K && (K.disconnect(), K = null), S.forEach((t) => t.remove()), S.clear(), Array.from(ne).forEach((t) => ue(t)), k = null, y = null;
810
+ }
811
+ function Ze() {
812
+ if (typeof document == "undefined" || document.getElementById(he)) return;
813
+ const e = document.createElement("style");
814
+ e.id = he, e.textContent = `
815
+ .rte-toolbar-group-items.${v},
816
+ .editora-toolbar-group-items.${v},
817
+ .rte-toolbar-group-items.${T},
818
+ .editora-toolbar-group-items.${T},
819
+ .rte-toolbar-group-items.${R},
820
+ .editora-toolbar-group-items.${R} {
821
+ display: flex;
822
+ border: 1px solid #cbd5e1;
823
+ border-radius: 4px;
824
+ background: #ffffff;
825
+ }
826
+
827
+ .rte-toolbar-group-items.${v} .rte-toolbar-button,
828
+ .editora-toolbar-group-items.${v} .editora-toolbar-button,
829
+ .rte-toolbar-group-items.${T} .rte-toolbar-button,
830
+ .editora-toolbar-group-items.${T} .editora-toolbar-button,
831
+ .rte-toolbar-group-items.${R} .rte-toolbar-button,
832
+ .editora-toolbar-group-items.${R} .editora-toolbar-button {
833
+ border: none;
834
+ border-right: 1px solid #cbd5e1;
835
+ border-radius: 0;
836
+ }
837
+
838
+ .rte-toolbar-group-items.${v} .rte-toolbar-item:last-child .rte-toolbar-button,
839
+ .editora-toolbar-group-items.${v} .editora-toolbar-item:last-child .editora-toolbar-button,
840
+ .rte-toolbar-group-items.${T} .rte-toolbar-item:last-child .rte-toolbar-button,
841
+ .editora-toolbar-group-items.${T} .editora-toolbar-item:last-child .editora-toolbar-button,
842
+ .rte-toolbar-group-items.${R} .rte-toolbar-item:last-child .rte-toolbar-button,
843
+ .editora-toolbar-group-items.${R} .editora-toolbar-item:last-child .editora-toolbar-button {
844
+ border-right: none;
845
+ }
846
+
847
+ ${w} .rte-toolbar-group-items.${v},
848
+ ${w} .editora-toolbar-group-items.${v},
849
+ ${w} .rte-toolbar-group-items.${T},
850
+ ${w} .editora-toolbar-group-items.${T},
851
+ ${w} .rte-toolbar-group-items.${R},
852
+ ${w} .editora-toolbar-group-items.${R} {
853
+ border-color: #566275;
854
+ }
855
+ .rte-toolbar-button[data-command="toggleDocSchemaRealtime"].active,
856
+ .editora-toolbar-button[data-command="toggleDocSchemaRealtime"].active {
857
+ background-color: #ccc;
858
+ }
859
+ ${w} .rte-toolbar-group-items.${v} .rte-toolbar-button svg,
860
+ ${w} .editora-toolbar-group-items.${v} .editora-toolbar-button svg,
861
+ ${w} .rte-toolbar-group-items.${T} .rte-toolbar-button svg,
862
+ ${w} .editora-toolbar-group-items.${T} .editora-toolbar-button svg
863
+ {
864
+ fill: none;
865
+ }
866
+ ${w} .rte-toolbar-group-items.${v} .rte-toolbar-button,
867
+ ${w} .editora-toolbar-group-items.${v} .editora-toolbar-button
868
+ {
869
+ border-color: #566275;
870
+ }
871
+ .${m} {
872
+ position: fixed;
873
+ z-index: 12000;
874
+ display: none;
875
+ width: min(440px, calc(100vw - 20px));
876
+ max-height: calc(100vh - 20px);
877
+ border: 1px solid #d1d5db;
878
+ border-radius: 14px;
879
+ background: #ffffff;
880
+ color: #0f172a;
881
+ box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
882
+ overflow: hidden;
883
+ }
884
+
885
+ .${m}.show {
886
+ display: flex;
887
+ flex-direction: column;
888
+ }
889
+
890
+ .${m}.rte-doc-schema-theme-dark {
891
+ border-color: #334155;
892
+ background: #0f172a;
893
+ color: #e2e8f0;
894
+ box-shadow: 0 24px 52px rgba(2, 6, 23, 0.68);
895
+ }
896
+
897
+ .rte-doc-schema-header {
898
+ display: flex;
899
+ align-items: center;
900
+ justify-content: space-between;
901
+ gap: 8px;
902
+ padding: 12px 14px;
903
+ border-bottom: 1px solid #e2e8f0;
904
+ background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
905
+ }
906
+
907
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-header {
908
+ border-color: #1e293b;
909
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
910
+ }
911
+
912
+ .rte-doc-schema-title {
913
+ margin: 0;
914
+ font-size: 15px;
915
+ line-height: 1.2;
916
+ font-weight: 700;
917
+ }
918
+
919
+ .rte-doc-schema-icon-btn {
920
+ border: 1px solid #cbd5e1;
921
+ border-radius: 6px;
922
+ min-height: 34px;
923
+ width: 34px;
924
+ background: #ffffff;
925
+ color: #0f172a;
926
+ font-size: 16px;
927
+ line-height: 1;
928
+ font-weight: 600;
929
+ padding: 0;
930
+ display: inline-flex;
931
+ align-items: center;
932
+ justify-content: center;
933
+ cursor: pointer;
934
+ }
935
+
936
+ .rte-doc-schema-icon-btn:hover,
937
+ .rte-doc-schema-icon-btn:focus-visible {
938
+ outline: none;
939
+ border-color: #3b82f6;
940
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
941
+ }
942
+
943
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-icon-btn {
944
+ border-color: #475569;
945
+ background: #0f172a;
946
+ color: #e2e8f0;
947
+ }
948
+
949
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-icon-btn:hover,
950
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-icon-btn:focus-visible {
951
+ border-color: #60a5fa;
952
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
953
+ }
954
+
955
+ .rte-doc-schema-body {
956
+ display: flex;
957
+ flex-direction: column;
958
+ gap: 8px;
959
+ padding: 12px;
960
+ overflow: auto;
961
+ }
962
+
963
+ .rte-doc-schema-label {
964
+ font-size: 12px;
965
+ line-height: 1.3;
966
+ font-weight: 700;
967
+ color: #334155;
968
+ }
969
+
970
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-label {
971
+ color: #cbd5e1;
972
+ }
973
+
974
+ .rte-doc-schema-select {
975
+ border: 1px solid #cbd5e1;
976
+ border-radius: 8px;
977
+ min-height: 34px;
978
+ padding: 0 10px;
979
+ font-size: 13px;
980
+ background: #ffffff;
981
+ color: inherit;
982
+ }
983
+
984
+ .rte-doc-schema-select:focus-visible {
985
+ border-color: #0f766e;
986
+ box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
987
+ outline: none;
988
+ }
989
+
990
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-select {
991
+ border-color: #334155;
992
+ background: #0b1220;
993
+ color: #e2e8f0;
994
+ }
995
+
996
+ .rte-doc-schema-description,
997
+ .rte-doc-schema-summary,
998
+ .rte-doc-schema-helper,
999
+ .rte-doc-schema-shortcut {
1000
+ margin: 0;
1001
+ font-size: 12px;
1002
+ line-height: 1.35;
1003
+ color: #475569;
1004
+ }
1005
+
1006
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-description,
1007
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-summary,
1008
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-helper,
1009
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-shortcut {
1010
+ color: #94a3b8;
1011
+ }
1012
+
1013
+ .rte-doc-schema-actions {
1014
+ display: grid;
1015
+ grid-template-columns: repeat(3, minmax(0, 1fr));
1016
+ gap: 8px;
1017
+ }
1018
+
1019
+ .rte-doc-schema-btn {
1020
+ border: 1px solid #cbd5e1;
1021
+ border-radius: 8px;
1022
+ min-height: 34px;
1023
+ padding: 0 8px;
1024
+ background: #ffffff;
1025
+ color: inherit;
1026
+ font-size: 12px;
1027
+ font-weight: 700;
1028
+ cursor: pointer;
1029
+ }
1030
+
1031
+ .rte-doc-schema-btn:disabled {
1032
+ opacity: 0.6;
1033
+ cursor: not-allowed;
1034
+ }
1035
+
1036
+ .rte-doc-schema-btn-primary {
1037
+ border-color: #0f766e;
1038
+ background: #0f766e;
1039
+ color: #f8fafc;
1040
+ }
1041
+
1042
+ .rte-doc-schema-btn:hover,
1043
+ .rte-doc-schema-btn:focus-visible {
1044
+ border-color: #94a3b8;
1045
+ outline: none;
1046
+ }
1047
+
1048
+ .rte-doc-schema-btn-primary:hover,
1049
+ .rte-doc-schema-btn-primary:focus-visible {
1050
+ border-color: #115e59;
1051
+ background: #115e59;
1052
+ }
1053
+
1054
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-btn {
1055
+ border-color: #334155;
1056
+ background: #111827;
1057
+ color: #e2e8f0;
1058
+ }
1059
+
1060
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-btn-primary {
1061
+ border-color: #14b8a6;
1062
+ background: #0f766e;
1063
+ color: #f0fdfa;
1064
+ }
1065
+
1066
+ .rte-doc-schema-issues-wrap {
1067
+ border: 1px solid #e2e8f0;
1068
+ border-radius: 10px;
1069
+ padding: 6px;
1070
+ background: #f8fafc;
1071
+ max-height: min(40vh, 320px);
1072
+ overflow: auto;
1073
+ }
1074
+
1075
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issues-wrap {
1076
+ border-color: #334155;
1077
+ background: #0b1220;
1078
+ }
1079
+
1080
+ .rte-doc-schema-issues {
1081
+ margin: 0;
1082
+ padding: 0;
1083
+ list-style: none;
1084
+ display: grid;
1085
+ gap: 6px;
1086
+ }
1087
+
1088
+ .rte-doc-schema-issue {
1089
+ border: 1px solid #cbd5e1;
1090
+ border-radius: 8px;
1091
+ background: #ffffff;
1092
+ padding: 8px;
1093
+ display: grid;
1094
+ gap: 4px;
1095
+ }
1096
+
1097
+ .rte-doc-schema-issue.error {
1098
+ border-color: #ef4444;
1099
+ background: #fef2f2;
1100
+ }
1101
+
1102
+ .rte-doc-schema-issue.warning {
1103
+ border-color: #f59e0b;
1104
+ background: #fffbeb;
1105
+ }
1106
+
1107
+ .rte-doc-schema-issue.info {
1108
+ border-color: #0ea5e9;
1109
+ background: #f0f9ff;
1110
+ }
1111
+
1112
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue {
1113
+ border-color: #334155;
1114
+ background: #111827;
1115
+ color: #e2e8f0;
1116
+ }
1117
+
1118
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue.error {
1119
+ border-color: rgba(239, 68, 68, 0.7);
1120
+ background: rgba(127, 29, 29, 0.28);
1121
+ }
1122
+
1123
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue.warning {
1124
+ border-color: rgba(245, 158, 11, 0.72);
1125
+ background: rgba(120, 53, 15, 0.28);
1126
+ }
1127
+
1128
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue.info {
1129
+ border-color: rgba(14, 165, 233, 0.7);
1130
+ background: rgba(7, 89, 133, 0.28);
1131
+ }
1132
+
1133
+ .rte-doc-schema-issue-message,
1134
+ .rte-doc-schema-issue-suggestion {
1135
+ margin: 0;
1136
+ font-size: 12px;
1137
+ line-height: 1.35;
1138
+ color: #1f2937;
1139
+ }
1140
+
1141
+ .rte-doc-schema-issue-suggestion {
1142
+ color: #475569;
1143
+ }
1144
+
1145
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue-message {
1146
+ color: #e2e8f0;
1147
+ }
1148
+
1149
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue-suggestion {
1150
+ color: #cbd5e1;
1151
+ }
1152
+
1153
+ .rte-doc-schema-empty {
1154
+ margin: 8px;
1155
+ font-size: 12px;
1156
+ color: #64748b;
1157
+ }
1158
+
1159
+ .rte-doc-schema-live {
1160
+ position: absolute;
1161
+ width: 1px;
1162
+ height: 1px;
1163
+ margin: -1px;
1164
+ padding: 0;
1165
+ overflow: hidden;
1166
+ clip: rect(0 0 0 0);
1167
+ border: 0;
1168
+ }
1169
+
1170
+ @media (max-width: 768px) {
1171
+ .${m} {
1172
+ left: 10px !important;
1173
+ right: 10px;
1174
+ top: 10px !important;
1175
+ width: auto !important;
1176
+ max-height: calc(100vh - 20px);
1177
+ }
1178
+
1179
+ .rte-doc-schema-actions {
1180
+ grid-template-columns: 1fr;
1181
+ }
1182
+ }
1183
+ `, document.head.appendChild(e);
1184
+ }
1185
+ const Qe = (e = {}) => {
1186
+ const t = Z(e), n = /* @__PURE__ */ new Set();
1187
+ return Ze(), {
1188
+ name: "docSchema",
1189
+ toolbar: [
1190
+ {
1191
+ id: "docSchemaGroup",
1192
+ label: "Document Schema",
1193
+ type: "group",
1194
+ command: "docSchema",
1195
+ items: [
1196
+ {
1197
+ id: "toggleDocSchemaPanel",
1198
+ label: "Document Schema",
1199
+ command: "toggleDocSchemaPanel",
1200
+ shortcut: "Mod-Alt-Shift-g",
1201
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 4.5h12A1.5 1.5 0 0 1 19.5 6v12A1.5 1.5 0 0 1 18 19.5H6A1.5 1.5 0 0 1 4.5 18V6A1.5 1.5 0 0 1 6 4.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'
1202
+ },
1203
+ {
1204
+ id: "runDocSchemaValidation",
1205
+ label: "Run Schema Validation",
1206
+ command: "runDocSchemaValidation",
1207
+ shortcut: "Mod-Alt-Shift-j",
1208
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3.5 4.5 6.5v5c0 4.8 3.1 8.9 7.5 10 4.4-1.1 7.5-5.2 7.5-10v-5L12 3.5Z" stroke="currentColor" stroke-width="1.6"/><path d="m9 12.5 2 2 4-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>'
1209
+ },
1210
+ {
1211
+ id: "toggleDocSchemaRealtime",
1212
+ label: "Toggle Schema Realtime",
1213
+ command: "toggleDocSchemaRealtime",
1214
+ icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 12a7.5 7.5 0 1 1 7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M9.5 19.5H5.5v-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><circle cx="12" cy="12" r="2" fill="currentColor"/></svg>'
1215
+ }
1216
+ ]
1217
+ }
1218
+ ],
1219
+ commands: {
1220
+ docSchema: (r, s) => {
1221
+ const o = I(s, !1, !1);
1222
+ if (!o) return !1;
1223
+ const a = u.get(o) || t;
1224
+ return p(o, a), u.set(o, a), y = o, ae(o), !0;
1225
+ },
1226
+ openDocSchemaPanel: (r, s) => {
1227
+ const o = I(s, !1, !1);
1228
+ if (!o) return !1;
1229
+ const a = u.get(o) || t;
1230
+ return p(o, a), u.set(o, a), y = o, ae(o), !0;
1231
+ },
1232
+ toggleDocSchemaPanel: (r, s) => {
1233
+ const o = I(s, !1, !1);
1234
+ if (!o) return !1;
1235
+ const a = u.get(o) || t;
1236
+ return p(o, a), u.set(o, a), y = o, ke(o, typeof r == "boolean" ? r : void 0);
1237
+ },
1238
+ runDocSchemaValidation: (r, s) => {
1239
+ const o = I(s, !1, !1);
1240
+ if (!o) return !1;
1241
+ const a = u.get(o) || t;
1242
+ return p(o, a), u.set(o, a), y = o, C(o, "command", !0), !0;
1243
+ },
1244
+ insertMissingDocSchemaSections: (r, s) => {
1245
+ const o = I(s, !1, !1);
1246
+ if (!o) return !1;
1247
+ const a = u.get(o) || t;
1248
+ return p(o, a), u.set(o, a), y = o, Te(o);
1249
+ },
1250
+ toggleDocSchemaRealtime: (r, s) => {
1251
+ const o = I(s, !1, !1);
1252
+ if (!o) return !1;
1253
+ const a = u.get(o) || t;
1254
+ return p(o, a), u.set(o, a), y = o, Ce(o, typeof r == "boolean" ? r : void 0);
1255
+ },
1256
+ setDocSchemaMode: (r, s) => {
1257
+ const o = I(s, !1, !1);
1258
+ if (!o) return !1;
1259
+ const a = u.get(o) || t, c = p(o, a);
1260
+ u.set(o, a);
1261
+ const i = typeof r == "string" ? r : (r == null ? void 0 : r.schemaId) || (r == null ? void 0 : r.id);
1262
+ return !i || !L(a, i) ? !1 : (c.activeSchemaId = i, c.snapshot = "", C(o, "set-mode", !0), !0);
1263
+ },
1264
+ setDocSchemaOptions: (r, s) => {
1265
+ const o = I(s, !1, !1);
1266
+ if (!o || !r || typeof r != "object") return !1;
1267
+ const a = u.get(o) || t, c = X.get(o) || Re(a), i = {
1268
+ ...c,
1269
+ ...r,
1270
+ labels: {
1271
+ ...c.labels || {},
1272
+ ...r.labels || {}
1273
+ },
1274
+ schemas: Array.isArray(r.schemas) ? r.schemas : c.schemas,
1275
+ normalizeText: r.normalizeText || a.normalizeText
1276
+ }, l = Z(i);
1277
+ u.set(o, l), X.set(o, i);
1278
+ const d = p(o, l);
1279
+ return typeof r.enableRealtime == "boolean" && (d.realtimeEnabled = r.enableRealtime), (!d.activeSchemaId || !L(l, d.activeSchemaId)) && (d.activeSchemaId = re(l)), typeof r.defaultSchemaId == "string" && L(l, r.defaultSchemaId) && (d.activeSchemaId = r.defaultSchemaId), d.snapshot = "", C(o, "set-options", !0), _(o), D(o), !0;
1280
+ },
1281
+ getDocSchemaState: (r, s) => {
1282
+ const o = I(s, !1, !1);
1283
+ if (!o) return !1;
1284
+ const a = u.get(o) || t;
1285
+ p(o, a);
1286
+ const c = we(o);
1287
+ if (typeof r == "function")
1288
+ try {
1289
+ r(c);
1290
+ } catch (i) {
1291
+ }
1292
+ return o.__docSchemaState = c, o.dispatchEvent(
1293
+ new CustomEvent("editora:doc-schema-state", {
1294
+ bubbles: !0,
1295
+ detail: c
1296
+ })
1297
+ ), !0;
1298
+ }
1299
+ },
1300
+ keymap: {
1301
+ "Mod-Alt-Shift-g": "toggleDocSchemaPanel",
1302
+ "Mod-Alt-Shift-G": "toggleDocSchemaPanel",
1303
+ "Mod-Alt-Shift-j": "runDocSchemaValidation",
1304
+ "Mod-Alt-Shift-J": "runDocSchemaValidation"
1305
+ },
1306
+ init: function(s) {
1307
+ W += 1;
1308
+ const o = this && typeof this.__pluginConfig == "object" ? { ...e, ...this.__pluginConfig } : e, a = Z(o);
1309
+ Je(a);
1310
+ const c = I(
1311
+ s != null && s.editorElement ? { editorElement: s.editorElement } : void 0,
1312
+ !1,
1313
+ !1
1314
+ );
1315
+ c && (y = c, n.add(c), p(c, a), u.set(c, a), X.set(c, o), D(c), C(c, "init", !0));
1316
+ },
1317
+ destroy: () => {
1318
+ n.forEach((r) => ue(r)), n.clear(), W = Math.max(0, W - 1), !(W > 0) && Xe();
1319
+ }
1320
+ };
1321
+ };
1322
+ export {
1323
+ Qe as DocSchemaPlugin
1324
+ };
1325
+ //# sourceMappingURL=DocSchemaPlugin.native-CHOge18O.mjs.map