@editora/plugins 1.0.8 → 1.0.10

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