@editora/plugins 1.0.7 → 1.0.9

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