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