@editora/plugins 1.0.11 → 1.0.13

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/approval-workflow.cjs.js +14 -14
  3. package/dist/approval-workflow.esm.js +265 -262
  4. package/dist/blockquote.cjs.js +1 -1
  5. package/dist/blockquote.esm.js +177 -15
  6. package/dist/blocks-library.cjs.js +6 -6
  7. package/dist/blocks-library.esm.js +95 -92
  8. package/dist/bold.cjs.js +1 -1
  9. package/dist/bold.esm.js +10 -6
  10. package/dist/capitalization.cjs.js +1 -1
  11. package/dist/capitalization.esm.js +124 -44
  12. package/dist/checklist.cjs.js +1 -1
  13. package/dist/checklist.esm.js +251 -191
  14. package/dist/citations.cjs.js +4 -4
  15. package/dist/citations.esm.js +131 -128
  16. package/dist/clear-formatting.cjs.js +1 -1
  17. package/dist/clear-formatting.esm.js +68 -36
  18. package/dist/code.cjs.js +121 -44
  19. package/dist/code.esm.js +2694 -889
  20. package/dist/content-rules.cjs.js +5 -5
  21. package/dist/content-rules.esm.js +104 -101
  22. package/dist/data-binding.cjs.js +3 -3
  23. package/dist/data-binding.esm.js +51 -48
  24. package/dist/direction.cjs.js +1 -1
  25. package/dist/direction.esm.js +97 -74
  26. package/dist/doc-schema.cjs.js +4 -4
  27. package/dist/doc-schema.esm.js +104 -101
  28. package/dist/embed-iframe.cjs.js +21 -4
  29. package/dist/embed-iframe.esm.js +279 -116
  30. package/dist/heading.cjs.js +1 -1
  31. package/dist/heading.esm.js +239 -56
  32. package/dist/history.cjs.js +1 -1
  33. package/dist/history.esm.js +74 -89
  34. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  35. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  36. package/dist/italic.cjs.js +1 -1
  37. package/dist/italic.esm.js +12 -8
  38. package/dist/math.cjs.js +27 -21
  39. package/dist/math.esm.js +218 -146
  40. package/dist/merge-tag.cjs.js +8 -2
  41. package/dist/merge-tag.esm.js +130 -111
  42. package/dist/pii-redaction.cjs.js +6 -6
  43. package/dist/pii-redaction.esm.js +169 -166
  44. package/dist/smart-paste.cjs.js +5 -5
  45. package/dist/smart-paste.esm.js +120 -117
  46. package/dist/special-characters.cjs.js +6 -10
  47. package/dist/special-characters.esm.js +97 -75
  48. package/dist/strikethrough.cjs.js +1 -1
  49. package/dist/strikethrough.esm.js +11 -25
  50. package/dist/translation-workflow.cjs.js +7 -7
  51. package/dist/translation-workflow.esm.js +103 -100
  52. package/dist/underline.cjs.js +1 -1
  53. package/dist/underline.esm.js +7 -3
  54. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- const g = /* @__PURE__ */ new Set([
1
+ const l = '.rte-content, .editora-content, [contenteditable="true"]', T = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", C = /* @__PURE__ */ new Set([
2
2
  "P",
3
3
  "DIV",
4
4
  "H1",
@@ -9,85 +9,108 @@ const g = /* @__PURE__ */ new Set([
9
9
  "H6",
10
10
  "LI",
11
11
  "BLOCKQUOTE",
12
- "PRE"
13
- ]), l = (e) => g.has(e.tagName) && e.getAttribute("contenteditable") !== "true", h = () => {
14
- const e = window.getSelection();
15
- if (e && e.rangeCount > 0) {
16
- let t = e.getRangeAt(0).startContainer;
17
- for (; t && t !== document.body; ) {
18
- if (t.nodeType === Node.ELEMENT_NODE) {
19
- const r = t;
20
- if (r.getAttribute("contenteditable") === "true")
21
- return r;
22
- }
23
- t = t.parentNode;
24
- }
12
+ "PRE",
13
+ "TABLE",
14
+ "FIGURE",
15
+ "UL",
16
+ "OL"
17
+ ]), d = (e) => C.has(e.tagName) && e.getAttribute("contenteditable") !== "true", m = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, g = (e) => {
18
+ const n = e?.contentElement;
19
+ if (n instanceof HTMLElement) return n;
20
+ const t = e?.editorElement;
21
+ if (t instanceof HTMLElement) {
22
+ const o = t.querySelector(l);
23
+ if (o instanceof HTMLElement) return o;
24
+ if (t.getAttribute("contenteditable") === "true") return t;
25
25
  }
26
- const n = document.activeElement;
27
- if (n) {
28
- if (n.getAttribute("contenteditable") === "true")
29
- return n;
30
- const t = n.closest('[contenteditable="true"]');
31
- if (t) return t;
26
+ const r = window.__editoraCommandEditorRoot;
27
+ if (r instanceof HTMLElement) {
28
+ const o = r.querySelector(l);
29
+ if (o instanceof HTMLElement) return o;
30
+ if (r.getAttribute("contenteditable") === "true") return r;
32
31
  }
33
- return document.querySelector('[contenteditable="true"]');
34
- }, u = (e) => {
35
- let n = e;
36
- for (; n && n !== document.body; ) {
37
- if (n.nodeType === Node.ELEMENT_NODE) {
38
- const t = n;
39
- if (l(t)) return t;
40
- if (t.getAttribute("contenteditable") === "true") break;
41
- }
42
- n = n.parentNode;
32
+ const i = window.getSelection();
33
+ if (i && i.rangeCount > 0) {
34
+ const o = m(i.getRangeAt(0).startContainer), c = o?.closest(l);
35
+ if (c instanceof HTMLElement) return c;
36
+ const f = o?.closest(T)?.querySelector(l);
37
+ if (f instanceof HTMLElement) return f;
43
38
  }
44
- return null;
45
- }, C = (e, n) => {
39
+ const a = document.activeElement, s = a instanceof HTMLElement ? a.closest(l) : null;
40
+ return s instanceof HTMLElement ? s : document.querySelector(l);
41
+ }, L = (e) => {
42
+ const n = window.getSelection();
43
+ if (!n || n.rangeCount === 0) return null;
44
+ const t = n.getRangeAt(0);
45
+ return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
46
+ }, R = (e, n) => {
47
+ let t = m(n);
48
+ for (; t && t !== e && e.contains(t); ) {
49
+ if (d(t)) return t;
50
+ t = t.parentElement;
51
+ }
52
+ return d(e) ? e : null;
53
+ }, u = (e, n) => {
54
+ const t = R(e, n);
55
+ if (!t || t === e) return null;
56
+ const r = t.closest("li");
57
+ return r instanceof HTMLElement && e.contains(r) ? r : t;
58
+ }, h = (e, n) => {
59
+ if (typeof e.intersectsNode == "function")
60
+ try {
61
+ return e.intersectsNode(n);
62
+ } catch {
63
+ return !1;
64
+ }
65
+ const t = document.createRange();
66
+ return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
67
+ }, w = (e, n) => {
46
68
  const t = [], r = /* @__PURE__ */ new Set(), i = (o) => {
47
- !o || r.has(o) || n.contains(o) && l(o) && (r.add(o), t.push(o));
69
+ !o || r.has(o) || o === n || !n.contains(o) || d(o) && (r.add(o), t.push(o));
48
70
  };
49
71
  if (e.collapsed)
50
- return i(u(e.startContainer)), t;
51
- const s = document.createTreeWalker(
72
+ return i(u(n, e.startContainer)), t;
73
+ i(u(n, e.startContainer)), i(u(n, e.endContainer));
74
+ const a = document.createTreeWalker(
52
75
  n,
53
76
  NodeFilter.SHOW_ELEMENT,
54
77
  {
55
78
  acceptNode: (o) => {
56
- const d = o;
57
- if (!l(d)) return NodeFilter.FILTER_SKIP;
58
- if (typeof e.intersectsNode == "function")
59
- return e.intersectsNode(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
60
- const a = document.createRange();
61
- return a.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, a) > 0 && e.compareBoundaryPoints(Range.START_TO_END, a) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
79
+ const c = o;
80
+ return !d(c) || c.closest("li") && c.tagName !== "LI" ? NodeFilter.FILTER_SKIP : h(e, c) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
62
81
  }
63
82
  }
64
83
  );
65
- let c = s.nextNode();
66
- for (; c; )
67
- i(c), c = s.nextNode();
68
- return t.length === 0 && i(u(e.commonAncestorContainer)), t;
69
- }, T = (e, n) => {
70
- if (n === e.innerHTML) return;
71
- const t = window.execEditorCommand || window.executeEditorCommand;
72
- if (typeof t == "function")
73
- try {
74
- t("recordDomTransaction", e, n, e.innerHTML);
75
- } catch {
84
+ let s = a.nextNode();
85
+ for (; s; )
86
+ i(s), s = a.nextNode();
87
+ return t.length === 0 && i(u(n, e.commonAncestorContainer)), t.filter((o) => !t.some((c) => c !== o && o.contains(c)));
88
+ }, p = (e, n, t) => {
89
+ if (n !== t) {
90
+ if (typeof window.execEditorCommand == "function") {
91
+ window.execEditorCommand("recordDomTransaction", e, n, t);
92
+ return;
76
93
  }
77
- }, f = (e) => {
78
- const n = h();
79
- if (!n) return !1;
80
- const t = window.getSelection();
81
- if (!t || t.rangeCount === 0) return !1;
82
- const r = t.getRangeAt(0);
83
- if (!n.contains(r.commonAncestorContainer)) return !1;
84
- const i = C(r, n);
94
+ if (typeof window.executeEditorCommand == "function")
95
+ try {
96
+ window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
97
+ } catch {
98
+ }
99
+ }
100
+ }, E = (e, n) => {
101
+ const t = g(n);
102
+ if (!t) return !1;
103
+ const r = L(t);
104
+ if (!r) return !1;
105
+ const i = w(r, t);
85
106
  if (i.length === 0) return !1;
86
- const s = n.innerHTML;
87
- return i.forEach((c) => {
88
- e === "rtl" ? c.setAttribute("dir", "rtl") : c.removeAttribute("dir");
89
- }), T(n, s), n.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
90
- }, E = () => ({
107
+ const a = t.innerHTML;
108
+ i.forEach((o) => {
109
+ o.setAttribute("dir", e);
110
+ });
111
+ const s = t.innerHTML;
112
+ return a === s ? !1 : (p(t, a, s), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), !0);
113
+ }, M = () => ({
91
114
  name: "direction",
92
115
  toolbar: [
93
116
  {
@@ -104,18 +127,18 @@ const g = /* @__PURE__ */ new Set([
104
127
  }
105
128
  ],
106
129
  commands: {
107
- setDirectionLTR: () => {
130
+ setDirectionLTR: (e, n) => {
108
131
  try {
109
- return f(null);
110
- } catch (e) {
111
- return console.error("Failed to set LTR direction:", e), !1;
132
+ return E("ltr", n);
133
+ } catch (t) {
134
+ return console.error("Failed to set LTR direction:", t), !1;
112
135
  }
113
136
  },
114
- setDirectionRTL: () => {
137
+ setDirectionRTL: (e, n) => {
115
138
  try {
116
- return f("rtl");
117
- } catch (e) {
118
- return console.error("Failed to set RTL direction:", e), !1;
139
+ return E("rtl", n);
140
+ } catch (t) {
141
+ return console.error("Failed to set RTL direction:", t), !1;
119
142
  }
120
143
  }
121
144
  },
@@ -125,5 +148,5 @@ const g = /* @__PURE__ */ new Set([
125
148
  }
126
149
  });
127
150
  export {
128
- E as DirectionPlugin
151
+ M as DirectionPlugin
129
152
  };
@@ -1,9 +1,9 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",fe="__editoraCommandEditorRoot",he="rte-doc-schema-styles",m="rte-doc-schema-panel",v="document-schema",M="doc-schema",H="docSchema",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ie={panelTitle:"Document Schema",panelAriaLabel:"Document schema panel",schemaLabel:"Schema",schemaDescriptionPrefix:"Description",validateText:"Run Validation",insertMissingText:"Insert Missing Sections",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No schema violations detected.",summaryPrefix:"Schema",issueListLabel:"Schema issues",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",helperText:"Choose a schema, validate structure, then insert missing sections safely.",readonlyMessage:"Editor is read-only. Missing sections cannot be inserted.",defaultPlaceholderText:"Add section content.",missingSectionMessage:"Missing required section",duplicateSectionMessage:"Section appears too many times",outOfOrderMessage:"Section appears out of required order",unknownHeadingMessage:"Heading is not part of selected schema",insertedSummaryPrefix:"Inserted missing sections"},u=new WeakMap,X=new WeakMap,j=new WeakMap,p=new Map,F=new WeakMap,te=new WeakMap,ne=new Set;let W=0,Ae=0,ge=0,w=null,b=null,q=null,z=null,B=null,R=null,K=null;function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Le(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function P(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function xe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e,t){return t(e).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/,"").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i,"").replace(/[::]+$/g,"").replace(/\s+/g," ").trim()}function be(){return[{id:"contract",label:"Contract",description:"Template for legal/commercial agreements with strict section ordering.",strictOrder:!0,allowUnknownHeadings:!1,sections:[{id:"summary",title:"Executive Summary",aliases:["Overview"]},{id:"scope",title:"Scope"},{id:"terms",title:"Terms and Conditions",aliases:["Terms"]},{id:"responsibilities",title:"Responsibilities"},{id:"sla",title:"Service Levels",aliases:["SLA","Service Level Agreement"]},{id:"termination",title:"Termination"}]},{id:"sop",label:"SOP",description:"Standard operating procedure with clear implementation and governance sections.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"purpose",title:"Purpose"},{id:"scope",title:"Scope"},{id:"procedure",title:"Procedure",maxOccurrences:10},{id:"roles",title:"Roles and Responsibilities",aliases:["Responsibilities"]},{id:"validation",title:"Validation"},{id:"revision-history",title:"Revision History",aliases:["Change History"]}]},{id:"policy",label:"Policy",description:"Policy document with control ownership, exception handling, and enforcement.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"statement",title:"Policy Statement"},{id:"applicability",title:"Applicability",aliases:["Scope"]},{id:"controls",title:"Controls"},{id:"exceptions",title:"Exceptions"},{id:"enforcement",title:"Enforcement"}]}]}function Oe(e,t,n){const r=n(e.title||"");if(!r)return null;const s=xe(n(e.id||r))||`section-${t+1}`,o=P(Number(e.minOccurrences??1),0,20),a=Math.max(1,o),c=P(Number(e.maxOccurrences??a),o,40),i=n(e.placeholder||""),l=Array.isArray(e.aliases)?e.aliases.map(y=>n(y)).filter(Boolean):[],d=[r,...l].map(y=>ce(y,n)).filter(Boolean);return{id:s,title:r,minOccurrences:o,maxOccurrences:c,placeholder:i,matchKeys:Array.from(new Set(d))}}function Se(e,t){const n=Array.isArray(e)&&e.length>0?e:be(),r=[],s=new Set;return n.forEach((o,a)=>{const c=t(o.label||"");if(!c)return;const i=xe(t(o.id||c))||`schema-${a+1}`;let l=i,d=1;for(;s.has(l);)l=`${i}-${d++}`;s.add(l);const y=Array.isArray(o.sections)?o.sections:[],f=[],k=new Set;if(y.forEach(($,h)=>{const x=Oe($,h,t);if(!x)return;let N=x.id,Te=1;for(;k.has(N);)N=`${x.id}-${Te++}`;k.add(N),f.push({...x,id:N})}),f.length===0)return;const O=new Map,A=new Map;f.forEach(($,h)=>{A.set($.id,h),$.matchKeys.forEach(x=>{O.has(x)||O.set(x,$)})}),r.push({id:l,label:c,description:t(o.description||""),strictOrder:o.strictOrder!==!1,allowUnknownHeadings:!!o.allowUnknownHeadings,sections:f,matchKeyToSection:O,orderBySectionId:A})}),r.length>0?r:Se(be(),t)}function Z(e={}){const t=e.normalizeText||Le,n=Se(e.schemas,t),r=t(e.defaultSchemaId||""),s=n.some(o=>o.id===r)?r:n[0]?.id||null;return{schemas:n,defaultSchemaId:s,enableRealtime:e.enableRealtime!==!1,debounceMs:P(Number(e.debounceMs??260),60,2e3),maxIssues:P(Number(e.maxIssues??80),5,500),labels:{...Ie,...e.labels||{}},normalizeText:t}}function He(e){return{schemas:e.schemas.map(t=>({id:t.id,label:t.label,description:t.description||void 0,strictOrder:t.strictOrder,allowUnknownHeadings:t.allowUnknownHeadings,sections:t.sections.map(n=>({id:n.id,title:n.title,minOccurrences:n.minOccurrences,maxOccurrences:n.maxOccurrences,placeholder:n.placeholder||void 0}))})),defaultSchemaId:e.defaultSchemaId||void 0,enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,labels:{...e.labels},normalizeText:e.normalizeText}}function le(e){return e.closest(ie)||e}function U(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[fe];if(!(e instanceof HTMLElement))return null;window[fe]=null;const t=U(e);if(t)return t;const n=e.closest(ie);if(n){const s=U(n);if(s)return s}const r=e.closest(S);return r instanceof HTMLElement?r:null}function De(e){const t=e.closest("[data-editora-editor]");if(t&&U(t)===e)return t;let n=e;for(;n;){if(n.matches(ie)&&(n===e||U(n)===e))return n;n=n.parentElement}return le(e)}function ye(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function Y(e){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}function Ne(e){const t=le(e);if(Y(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Y(n)?!0:Y(document.documentElement)||Y(document.body)}function oe(e,t){e.classList.remove("rte-doc-schema-theme-dark"),Ne(t)&&e.classList.add("rte-doc-schema-theme-dark")}function Pe(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const s=n.removedNodes[r];if(s.nodeType!==Node.ELEMENT_NODE)continue;const o=s;if(o.matches?.(S)||o.matches?.(`.${m}`)||o.querySelector?.(S)||o.querySelector?.(`.${m}`))return!0}}return!1}function Q(){Array.from(ne).forEach(t=>{t.isConnected||ue(t)})}function T(e,t=!0,n=!0){if(Q(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const c=U(e.editorElement);if(c)return c}const r=Re();if(r)return r;const s=window.getSelection();if(s&&s.rangeCount>0){const c=ye(s.getRangeAt(0).startContainer)?.closest(S);if(c)return c}const o=document.activeElement;if(o){if(o.matches(S))return o;const c=o.closest(S);if(c)return c}if(n&&b&&b.isConnected)return b;if(!t)return null;const a=document.querySelector(S);return a instanceof HTMLElement?a:null}function _e(e){const t=e.target;if(t){const r=t.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=t.closest(S);if(s)return s}const n=document.activeElement;if(n){const r=n.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=n.closest(S);if(s)return s}return null}function pe(e,t,n){const r=De(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function de(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),te.delete(e))}function L(e,t){return t&&e.schemas.find(n=>n.id===t)||null}function re(e){return e.defaultSchemaId||e.schemas[0]?.id||null}function g(e,t){u.has(e)||u.set(e,t);let n=j.get(e);return n||(n={activeSchemaId:re(t),realtimeEnabled:t.enableRealtime,issues:[],headingCount:0,recognizedHeadingCount:0,missingCount:0,lastRunAt:null,snapshot:""},j.set(e,n)),(!n.activeSchemaId||!L(t,n.activeSchemaId))&&(n.activeSchemaId=re(t)),ne.add(e),n}function ue(e){de(e),p.get(e)?.remove(),p.delete(e),F.delete(e),u.delete(e),X.delete(e),j.delete(e),ne.delete(e),b===e&&(b=null)}function me(e){return F.get(e)===!0}function ve(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function se(e,t){if(!t.classList.contains("show"))return;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));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`}function ee(e,t){const n=e.querySelector(".rte-doc-schema-live");n&&(n.textContent=t)}function qe(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=[];return n.forEach((s,o)=>{const a=t(s.textContent||"");if(!a)return;const c=Number(s.tagName.slice(1))||0,i=ce(a,t);r.push({text:a,key:i,index:o,level:c})}),r}function Ee(e,t,n){const r=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),s=[];return r.forEach(o=>{const a=n(o.textContent||"");if(!a)return;const c=ce(a,n),i=c&&t.matchKeyToSection.get(c)||null,l=i?t.orderBySectionId.get(i.id)??null:null,d=P(Number(o.tagName.slice(1))||0,1,6);s.push({element:o,level:d,section:i,order:l})}),s}function ze(e,t=2){const n=e.filter(i=>i.section).map(i=>i.level),r=n.length>0?n:e.map(i=>i.level);if(r.length===0)return t;const s=new Map;r.forEach((i,l)=>{s.has(i)||s.set(i,{count:0,firstIndex:l});const d=s.get(i);d.count+=1});let o=t,a=-1,c=Number.MAX_SAFE_INTEGER;return s.forEach((i,l)=>{(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)}),P(o,1,6)}function Be(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(ye(n.startContainer)?.closest(S)!==e)return null;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const o=n.startContainer,a=o.childNodes[n.startOffset]||null;return{parent:o,referenceNode:a}}const s=n.startContainer.parentNode;return s?{parent:s,referenceNode:n.startContainer.nextSibling||null}:null}function Ke(e,t,n,r){const s=Ee(e,n,r),o=n.orderBySectionId.get(t.id);if(typeof o!="number"||s.length===0)return{parent:e,referenceNode:null};const a=s.find(i=>typeof i.order=="number"&&i.order>o);if(a&&a.element.parentNode)return{parent:a.element.parentNode,referenceNode:a.element};let c=-1;for(let i=0;i<s.length;i+=1){const l=s[i];typeof l.order=="number"&&l.order<o&&(c=i)}if(c>=0){const i=s[c+1]?.element||null;return{parent:i?.parentNode||s[c].element.parentNode||e,referenceNode:i}}return{parent:e,referenceNode:null}}function Ve(e,t,n,r){const s=e.ownerDocument||document,o=`h${P(r,1,6)}`,a=s.createElement(o);a.setAttribute("data-doc-schema-section",t.id),a.textContent=t.title;const c=s.createElement("p");return c.textContent=t.placeholder||n.labels.defaultPlaceholderText,[a,c]}function V(e,t,n,r={}){return ge+=1,{id:`doc-schema-issue-${ge}`,type:e,severity:t,message:n,...r}}function J(e,t,n){return e.replace(/\{section\}/g,t||"").replace(/\{heading\}/g,n||"").trim()}function je(e,t,n){const r=qe(e,n.normalizeText),s=[],o=new Map,a=[];for(let i=0;i<r.length&&!(s.length>=n.maxIssues);i+=1){const l=r[i];if(!l.key)continue;const d=t.matchKeyToSection.get(l.key);if(d){o.set(d.id,(o.get(d.id)||0)+1),a.push({section:d,heading:l});continue}t.allowUnknownHeadings||s.push(V("unknown-heading","warning",J(n.labels.unknownHeadingMessage,null,l.text),{headingText:l.text,suggestion:"Map this heading to a schema alias or remove it from strict structure mode."}))}let c=0;for(let i=0;i<t.sections.length&&!(s.length>=n.maxIssues);i+=1){const l=t.sections[i],d=o.get(l.id)||0;d<l.minOccurrences&&(c+=1,s.push(V("missing-section","error",J(n.labels.missingSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Add heading "${l.title}" to satisfy schema requirements.`}))),d>l.maxOccurrences&&s.length<n.maxIssues&&s.push(V("duplicate-section","warning",J(n.labels.duplicateSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Keep at most ${l.maxOccurrences} instance(s) of "${l.title}".`}))}if(t.strictOrder&&s.length<n.maxIssues){let i=-1;for(let l=0;l<a.length&&!(s.length>=n.maxIssues);l+=1){const d=a[l],y=t.orderBySectionId.get(d.section.id)??l;y<i?s.push(V("out-of-order","warning",J(n.labels.outOfOrderMessage,d.section.title,d.heading.text),{sectionId:d.section.id,sectionTitle:d.section.title,headingText:d.heading.text,suggestion:`Move "${d.section.title}" after earlier required sections.`})):i=y}}return{issues:s,headingCount:r.length,recognizedHeadingCount:a.length,missingCount:c}}function we(e){const t=u.get(e)||w,n=j.get(e),r=t?L(t,n?.activeSchemaId||null):null;return{activeSchemaId:n?.activeSchemaId||null,activeSchemaLabel:r?.label||null,realtimeEnabled:n?.realtimeEnabled===!0,issues:n?.issues?n.issues.map(s=>({...s})):[],headingCount:n?.headingCount||0,recognizedHeadingCount:n?.recognizedHeadingCount||0,missingCount:n?.missingCount||0,lastRunAt:n?.lastRunAt||null}}function D(e){const t=j.get(e);pe(e,"toggleDocSchemaPanel",me(e)),pe(e,"toggleDocSchemaRealtime",t?.realtimeEnabled===!0)}function _(e){const t=p.get(e);if(!t)return;const n=u.get(e)||w;if(!n)return;const r=g(e,n),s=L(n,r.activeSchemaId),o=t.querySelector(".rte-doc-schema-label");o&&(o.textContent=n.labels.schemaLabel);const a=t.querySelector('[data-field="schema"]');a&&(a.innerHTML=n.schemas.map(h=>`<option value="${I(h.id)}">${I(h.label)}</option>`).join(""),a.value=r.activeSchemaId||"");const c=t.querySelector(".rte-doc-schema-description");if(c){const h=s?.description||"";c.textContent=h?`${n.labels.schemaDescriptionPrefix}: ${h}`:"",c.hidden=!h}const i=t.querySelector(".rte-doc-schema-summary");if(i){const h=s?.label||"N/A",x=r.issues.length;i.textContent=`${n.labels.summaryPrefix}: ${h} • ${x} issue${x===1?"":"s"}`}const l=t.querySelector(".rte-doc-schema-helper");l&&(l.textContent=n.labels.helperText);const d=t.querySelector(".rte-doc-schema-shortcut");d&&(d.textContent=n.labels.shortcutText);const y=t.querySelector('[data-action="run-validation"]');y&&(y.textContent=n.labels.validateText);const f=t.querySelector('[data-action="insert-missing"]');if(f){f.textContent=n.labels.insertMissingText;const h=r.issues.some(x=>x.type==="missing-section");f.disabled=!h||ve(e)}const k=t.querySelector('[data-action="toggle-realtime"]');k&&(k.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,k.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const O=t.querySelector('[data-action="close"]');O&&O.setAttribute("aria-label",n.labels.closeText);const A=t.querySelector(".rte-doc-schema-issues"),$=t.querySelector(".rte-doc-schema-empty");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=>{const x=h.severity==="error"?"error":h.severity==="warning"?"warning":"info",N=h.sectionTitle||h.headingText||"";return`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",ie="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",fe="__editoraCommandEditorRoot",he="rte-doc-schema-styles",m="rte-doc-schema-panel",v="document-schema",M="doc-schema",H="docSchema",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Ae={panelTitle:"Document Schema",panelAriaLabel:"Document schema panel",schemaLabel:"Schema",schemaDescriptionPrefix:"Description",validateText:"Run Validation",insertMissingText:"Insert Missing Sections",realtimeOnText:"Realtime On",realtimeOffText:"Realtime Off",closeText:"Close",noIssuesText:"No schema violations detected.",summaryPrefix:"Schema",issueListLabel:"Schema issues",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+G (panel), Ctrl/Cmd+Alt+Shift+J (validate)",helperText:"Choose a schema, validate structure, then insert missing sections safely.",readonlyMessage:"Editor is read-only. Missing sections cannot be inserted.",defaultPlaceholderText:"Add section content.",missingSectionMessage:"Missing required section",duplicateSectionMessage:"Section appears too many times",outOfOrderMessage:"Section appears out of required order",unknownHeadingMessage:"Heading is not part of selected schema",insertedSummaryPrefix:"Inserted missing sections"},u=new WeakMap,X=new WeakMap,j=new WeakMap,p=new Map,F=new WeakMap,te=new WeakMap,ne=new Set;let W=0,Le=0,ge=0,w=null,b=null,q=null,z=null,B=null,R=null,K=null;function I(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Oe(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function P(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function xe(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e,t){return t(e).toLowerCase().replace(/^[\s\-\u2022]*(?:[0-9]+(?:\.[0-9]+)*)[\)\.\-:\s]+/,"").replace(/^[\s\-\u2022]*(?:[ivxlcdm]+)[\)\.\-:\s]+/i,"").replace(/[::]+$/g,"").replace(/\s+/g," ").trim()}function be(){return[{id:"contract",label:"Contract",description:"Template for legal/commercial agreements with strict section ordering.",strictOrder:!0,allowUnknownHeadings:!1,sections:[{id:"summary",title:"Executive Summary",aliases:["Overview"]},{id:"scope",title:"Scope"},{id:"terms",title:"Terms and Conditions",aliases:["Terms"]},{id:"responsibilities",title:"Responsibilities"},{id:"sla",title:"Service Levels",aliases:["SLA","Service Level Agreement"]},{id:"termination",title:"Termination"}]},{id:"sop",label:"SOP",description:"Standard operating procedure with clear implementation and governance sections.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"purpose",title:"Purpose"},{id:"scope",title:"Scope"},{id:"procedure",title:"Procedure",maxOccurrences:10},{id:"roles",title:"Roles and Responsibilities",aliases:["Responsibilities"]},{id:"validation",title:"Validation"},{id:"revision-history",title:"Revision History",aliases:["Change History"]}]},{id:"policy",label:"Policy",description:"Policy document with control ownership, exception handling, and enforcement.",strictOrder:!0,allowUnknownHeadings:!0,sections:[{id:"statement",title:"Policy Statement"},{id:"applicability",title:"Applicability",aliases:["Scope"]},{id:"controls",title:"Controls"},{id:"exceptions",title:"Exceptions"},{id:"enforcement",title:"Enforcement"}]}]}function He(e,t,n){const r=n(e.title||"");if(!r)return null;const s=xe(n(e.id||r))||`section-${t+1}`,o=P(Number(e.minOccurrences??1),0,20),a=Math.max(1,o),c=P(Number(e.maxOccurrences??a),o,40),i=n(e.placeholder||""),l=Array.isArray(e.aliases)?e.aliases.map(y=>n(y)).filter(Boolean):[],d=[r,...l].map(y=>ce(y,n)).filter(Boolean);return{id:s,title:r,minOccurrences:o,maxOccurrences:c,placeholder:i,matchKeys:Array.from(new Set(d))}}function Se(e,t){const n=Array.isArray(e)&&e.length>0?e:be(),r=[],s=new Set;return n.forEach((o,a)=>{const c=t(o.label||"");if(!c)return;const i=xe(t(o.id||c))||`schema-${a+1}`;let l=i,d=1;for(;s.has(l);)l=`${i}-${d++}`;s.add(l);const y=Array.isArray(o.sections)?o.sections:[],f=[],k=new Set;if(y.forEach(($,h)=>{const x=He($,h,t);if(!x)return;let N=x.id,Ie=1;for(;k.has(N);)N=`${x.id}-${Ie++}`;k.add(N),f.push({...x,id:N})}),f.length===0)return;const O=new Map,A=new Map;f.forEach(($,h)=>{A.set($.id,h),$.matchKeys.forEach(x=>{O.has(x)||O.set(x,$)})}),r.push({id:l,label:c,description:t(o.description||""),strictOrder:o.strictOrder!==!1,allowUnknownHeadings:!!o.allowUnknownHeadings,sections:f,matchKeyToSection:O,orderBySectionId:A})}),r.length>0?r:Se(be(),t)}function Z(e={}){const t=e.normalizeText||Oe,n=Se(e.schemas,t),r=t(e.defaultSchemaId||""),s=n.some(o=>o.id===r)?r:n[0]?.id||null;return{schemas:n,defaultSchemaId:s,enableRealtime:e.enableRealtime!==!1,debounceMs:P(Number(e.debounceMs??260),60,2e3),maxIssues:P(Number(e.maxIssues??80),5,500),labels:{...Ae,...e.labels||{}},normalizeText:t}}function Re(e){return{schemas:e.schemas.map(t=>({id:t.id,label:t.label,description:t.description||void 0,strictOrder:t.strictOrder,allowUnknownHeadings:t.allowUnknownHeadings,sections:t.sections.map(n=>({id:n.id,title:n.title,minOccurrences:n.minOccurrences,maxOccurrences:n.maxOccurrences,placeholder:n.placeholder||void 0}))})),defaultSchemaId:e.defaultSchemaId||void 0,enableRealtime:e.enableRealtime,debounceMs:e.debounceMs,maxIssues:e.maxIssues,labels:{...e.labels},normalizeText:e.normalizeText}}function le(e){return e.closest(ie)||e}function U(e){if(!e)return null;if(e.matches(S))return e;const t=e.querySelector(S);return t instanceof HTMLElement?t:null}function De(){if(typeof window>"u")return null;const e=window[fe];if(!(e instanceof HTMLElement))return null;window[fe]=null;const t=U(e);if(t)return t;const n=e.closest(ie);if(n){const s=U(n);if(s)return s}const r=e.closest(S);return r instanceof HTMLElement?r:null}function Ne(e){const t=e.closest("[data-editora-editor]");if(t&&U(t)===e)return t;let n=e;for(;n;){if(n.matches(ie)&&(n===e||U(n)===e))return n;n=n.parentElement}return le(e)}function ye(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function Y(e){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}function Pe(e){const t=le(e);if(Y(t))return!0;const n=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Y(n)?!0:Y(document.documentElement)||Y(document.body)}function oe(e,t){e.classList.remove("rte-doc-schema-theme-dark"),Pe(t)&&e.classList.add("rte-doc-schema-theme-dark")}function _e(e){for(let t=0;t<e.length;t+=1){const n=e[t];if(!(n.type!=="childList"||n.removedNodes.length===0))for(let r=0;r<n.removedNodes.length;r+=1){const s=n.removedNodes[r];if(s.nodeType!==Node.ELEMENT_NODE)continue;const o=s;if(o.matches?.(S)||o.matches?.(`.${m}`)||o.querySelector?.(S)||o.querySelector?.(`.${m}`))return!0}}return!1}function Q(){Array.from(ne).forEach(t=>{t.isConnected||ue(t)})}function T(e,t=!0,n=!0){if(Q(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const c=U(e.editorElement);if(c)return c}const r=De();if(r)return r;const s=window.getSelection();if(s&&s.rangeCount>0){const c=ye(s.getRangeAt(0).startContainer)?.closest(S);if(c)return c}const o=document.activeElement;if(o){if(o.matches(S))return o;const c=o.closest(S);if(c)return c}if(n&&b&&b.isConnected)return b;if(!t)return null;const a=document.querySelector(S);return a instanceof HTMLElement?a:null}function qe(e){const t=e.target;if(t){const r=t.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=t.closest(S);if(s)return s}const n=document.activeElement;if(n){const r=n.closest(`.${m}`);if(r){const o=Array.from(p.entries()).find(([,a])=>a===r);if(o)return o[0]}const s=n.closest(S);if(s)return s}return null}function pe(e,t,n){const r=Ne(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",n),o.setAttribute("data-active",n?"true":"false"),o.setAttribute("aria-pressed",n?"true":"false")})}function de(e){const t=te.get(e);typeof t=="number"&&(window.clearTimeout(t),te.delete(e))}function L(e,t){return t&&e.schemas.find(n=>n.id===t)||null}function re(e){return e.defaultSchemaId||e.schemas[0]?.id||null}function g(e,t){u.has(e)||u.set(e,t);let n=j.get(e);return n||(n={activeSchemaId:re(t),realtimeEnabled:t.enableRealtime,issues:[],headingCount:0,recognizedHeadingCount:0,missingCount:0,lastRunAt:null,snapshot:""},j.set(e,n)),(!n.activeSchemaId||!L(t,n.activeSchemaId))&&(n.activeSchemaId=re(t)),ne.add(e),n}function ue(e){de(e),p.get(e)?.remove(),p.delete(e),F.delete(e),u.delete(e),X.delete(e),j.delete(e),ne.delete(e),b===e&&(b=null)}function me(e){return F.get(e)===!0}function ve(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function se(e,t){if(!t.classList.contains("show"))return;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));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`}function ee(e,t){const n=e.querySelector(".rte-doc-schema-live");n&&(n.textContent=t)}function ze(e,t){const n=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),r=[];return n.forEach((s,o)=>{const a=t(s.textContent||"");if(!a)return;const c=Number(s.tagName.slice(1))||0,i=ce(a,t);r.push({text:a,key:i,index:o,level:c})}),r}function Ee(e,t,n){const r=Array.from(e.querySelectorAll("h1, h2, h3, h4, h5, h6")),s=[];return r.forEach(o=>{const a=n(o.textContent||"");if(!a)return;const c=ce(a,n),i=c&&t.matchKeyToSection.get(c)||null,l=i?t.orderBySectionId.get(i.id)??null:null,d=P(Number(o.tagName.slice(1))||0,1,6);s.push({element:o,level:d,section:i,order:l})}),s}function Be(e,t=2){const n=e.filter(i=>i.section).map(i=>i.level),r=n.length>0?n:e.map(i=>i.level);if(r.length===0)return t;const s=new Map;r.forEach((i,l)=>{s.has(i)||s.set(i,{count:0,firstIndex:l});const d=s.get(i);d.count+=1});let o=t,a=-1,c=Number.MAX_SAFE_INTEGER;return s.forEach((i,l)=>{(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)}),P(o,1,6)}function Ke(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(ye(n.startContainer)?.closest(S)!==e)return null;if(n.startContainer.nodeType===Node.ELEMENT_NODE){const o=n.startContainer,a=o.childNodes[n.startOffset]||null;return{parent:o,referenceNode:a}}const s=n.startContainer.parentNode;return s?{parent:s,referenceNode:n.startContainer.nextSibling||null}:null}function Ve(e,t,n,r){const s=Ee(e,n,r),o=n.orderBySectionId.get(t.id);if(typeof o!="number"||s.length===0)return{parent:e,referenceNode:null};const a=s.find(i=>typeof i.order=="number"&&i.order>o);if(a&&a.element.parentNode)return{parent:a.element.parentNode,referenceNode:a.element};let c=-1;for(let i=0;i<s.length;i+=1){const l=s[i];typeof l.order=="number"&&l.order<o&&(c=i)}if(c>=0){const i=s[c+1]?.element||null;return{parent:i?.parentNode||s[c].element.parentNode||e,referenceNode:i}}return{parent:e,referenceNode:null}}function je(e,t,n,r){const s=e.ownerDocument||document,o=`h${P(r,1,6)}`,a=s.createElement(o);a.setAttribute("data-doc-schema-section",t.id),a.textContent=t.title;const c=s.createElement("p");return c.textContent=t.placeholder||n.labels.defaultPlaceholderText,[a,c]}function V(e,t,n,r={}){return ge+=1,{id:`doc-schema-issue-${ge}`,type:e,severity:t,message:n,...r}}function J(e,t,n){return e.replace(/\{section\}/g,t||"").replace(/\{heading\}/g,n||"").trim()}function Ue(e,t,n){const r=ze(e,n.normalizeText),s=[],o=new Map,a=[];for(let i=0;i<r.length&&!(s.length>=n.maxIssues);i+=1){const l=r[i];if(!l.key)continue;const d=t.matchKeyToSection.get(l.key);if(d){o.set(d.id,(o.get(d.id)||0)+1),a.push({section:d,heading:l});continue}t.allowUnknownHeadings||s.push(V("unknown-heading","warning",J(n.labels.unknownHeadingMessage,null,l.text),{headingText:l.text,suggestion:"Map this heading to a schema alias or remove it from strict structure mode."}))}let c=0;for(let i=0;i<t.sections.length&&!(s.length>=n.maxIssues);i+=1){const l=t.sections[i],d=o.get(l.id)||0;d<l.minOccurrences&&(c+=1,s.push(V("missing-section","error",J(n.labels.missingSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Add heading "${l.title}" to satisfy schema requirements.`}))),d>l.maxOccurrences&&s.length<n.maxIssues&&s.push(V("duplicate-section","warning",J(n.labels.duplicateSectionMessage,l.title,null),{sectionId:l.id,sectionTitle:l.title,suggestion:`Keep at most ${l.maxOccurrences} instance(s) of "${l.title}".`}))}if(t.strictOrder&&s.length<n.maxIssues){let i=-1;for(let l=0;l<a.length&&!(s.length>=n.maxIssues);l+=1){const d=a[l],y=t.orderBySectionId.get(d.section.id)??l;y<i?s.push(V("out-of-order","warning",J(n.labels.outOfOrderMessage,d.section.title,d.heading.text),{sectionId:d.section.id,sectionTitle:d.section.title,headingText:d.heading.text,suggestion:`Move "${d.section.title}" after earlier required sections.`})):i=y}}return{issues:s,headingCount:r.length,recognizedHeadingCount:a.length,missingCount:c}}function we(e){const t=u.get(e)||w,n=j.get(e),r=t?L(t,n?.activeSchemaId||null):null;return{activeSchemaId:n?.activeSchemaId||null,activeSchemaLabel:r?.label||null,realtimeEnabled:n?.realtimeEnabled===!0,issues:n?.issues?n.issues.map(s=>({...s})):[],headingCount:n?.headingCount||0,recognizedHeadingCount:n?.recognizedHeadingCount||0,missingCount:n?.missingCount||0,lastRunAt:n?.lastRunAt||null}}function D(e){const t=j.get(e);pe(e,"toggleDocSchemaPanel",me(e)),pe(e,"toggleDocSchemaRealtime",t?.realtimeEnabled===!0)}function _(e){const t=p.get(e);if(!t)return;const n=u.get(e)||w;if(!n)return;const r=g(e,n),s=L(n,r.activeSchemaId),o=t.querySelector(".rte-doc-schema-label");o&&(o.textContent=n.labels.schemaLabel);const a=t.querySelector('[data-field="schema"]');a&&(a.innerHTML=n.schemas.map(h=>`<option value="${I(h.id)}">${I(h.label)}</option>`).join(""),a.value=r.activeSchemaId||"");const c=t.querySelector(".rte-doc-schema-description");if(c){const h=s?.description||"";c.textContent=h?`${n.labels.schemaDescriptionPrefix}: ${h}`:"",c.hidden=!h}const i=t.querySelector(".rte-doc-schema-summary");if(i){const h=s?.label||"N/A",x=r.issues.length;i.textContent=`${n.labels.summaryPrefix}: ${h} • ${x} issue${x===1?"":"s"}`}const l=t.querySelector(".rte-doc-schema-helper");l&&(l.textContent=n.labels.helperText);const d=t.querySelector(".rte-doc-schema-shortcut");d&&(d.textContent=n.labels.shortcutText);const y=t.querySelector('[data-action="run-validation"]');y&&(y.textContent=n.labels.validateText);const f=t.querySelector('[data-action="insert-missing"]');if(f){f.textContent=n.labels.insertMissingText;const h=r.issues.some(x=>x.type==="missing-section");f.disabled=!h||ve(e)}const k=t.querySelector('[data-action="toggle-realtime"]');k&&(k.textContent=r.realtimeEnabled?n.labels.realtimeOnText:n.labels.realtimeOffText,k.setAttribute("aria-pressed",r.realtimeEnabled?"true":"false"));const O=t.querySelector('[data-action="close"]');O&&O.setAttribute("aria-label",n.labels.closeText);const A=t.querySelector(".rte-doc-schema-issues"),$=t.querySelector(".rte-doc-schema-empty");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=>{const x=h.severity==="error"?"error":h.severity==="warning"?"warning":"info",N=h.sectionTitle||h.headingText||"";return`
2
2
  <li class="rte-doc-schema-issue ${x}" role="listitem">
3
3
  <p class="rte-doc-schema-issue-message">${I(h.message)}${N?`: <strong>${I(N)}</strong>`:""}</p>
4
4
  ${h.suggestion?`<p class="rte-doc-schema-issue-suggestion">${I(h.suggestion)}</p>`:""}
5
5
  </li>
6
- `}).join(""))),t.setAttribute("aria-label",n.labels.panelAriaLabel)}function G(e,t=!1){const n=p.get(e);n&&(n.classList.remove("show"),F.set(e,!1),D(e),t&&e.focus({preventScroll:!0}))}function ae(e){const t=Fe(e);p.forEach((r,s)=>{s!==e&&G(s,!1)}),t.classList.add("show"),F.set(e,!0),_(e),se(e,t),D(e),t.querySelector('[data-field="schema"]')?.focus(),C(e,"panel-open",!1)}function ke(e,t){const n=me(e);return(typeof t=="boolean"?t:!n)?ae(e):G(e,!1),!0}function Ue(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ge(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function C(e,t,n){const r=u.get(e)||w;if(!r)return[];const s=g(e,r),o=p.get(e),a=e.innerHTML;if(!n&&s.snapshot===a)return s.issues;const c=L(r,s.activeSchemaId);if(!c)return s.issues=[V("missing-section","error","No active schema is configured for this editor.",{suggestion:"Set `defaultSchemaId` or update schema options."})],s.headingCount=0,s.recognizedHeadingCount=0,s.missingCount=1,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),s.issues;const i=je(e,c,r);return s.issues=i.issues,s.headingCount=i.headingCount,s.recognizedHeadingCount=i.recognizedHeadingCount,s.missingCount=i.missingCount,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),e.dispatchEvent(new CustomEvent("editora:doc-schema-validation",{bubbles:!0,detail:{reason:t,state:we(e)}})),o&&ee(o,i.issues.length===0?r.labels.noIssuesText:`${i.issues.length} issue${i.issues.length===1?"":"s"} detected.`),s.issues}function $e(e){const t=u.get(e)||w;if(!t)return;de(e);const n=window.setTimeout(()=>{te.delete(e),C(e,"realtime",!1)},t.debounceMs);te.set(e,n)}function Ce(e,t){const n=u.get(e)||w;if(!n)return!1;const r=g(e,n),s=typeof t=="boolean"?t:!r.realtimeEnabled;return r.realtimeEnabled=s,s?$e(e):de(e),_(e),D(e),!0}function Me(e){const t=u.get(e)||w;if(!t)return!1;const n=g(e,t),r=p.get(e);if(ve(e))return r&&ee(r,t.labels.readonlyMessage),!1;const s=L(t,n.activeSchemaId);if(!s)return!1;C(e,"insert-missing-pre",!0);const o=Array.from(new Set(n.issues.filter(f=>f.type==="missing-section"&&f.sectionId).map(f=>f.sectionId))),a=s.sections.filter(f=>o.includes(f.id));if(a.length===0)return r&&ee(r,t.labels.noIssuesText),!1;const c=e.innerHTML,i=Ee(e,s,t.normalizeText),l=ze(i,2),d=Be(e);a.forEach(f=>{const k=s.strictOrder?Ke(e,f,s,t.normalizeText):d||{parent:e,referenceNode:null},[O,A]=Ve(e,f,t,l);k.parent.insertBefore(O,k.referenceNode),k.parent.insertBefore(A,k.referenceNode)}),Ue(e,c),Ge(e),C(e,"insert-missing-post",!0);const y=a.map(f=>f.title).join(", ");return e.dispatchEvent(new CustomEvent("editora:doc-schema-insert-missing",{bubbles:!0,detail:{schemaId:s.id,sectionIds:a.map(f=>f.id)}})),r&&ee(r,`${t.labels.insertedSummaryPrefix}: ${y}`),!0}function Fe(e){const t=p.get(e);if(t)return t;const n=u.get(e)||w||Z();g(e,n);const r=`rte-doc-schema-panel-${Ae++}`,s=`${r}-schema`,o=document.createElement("section");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=`
6
+ `}).join(""))),t.setAttribute("aria-label",n.labels.panelAriaLabel)}function G(e,t=!1){const n=p.get(e);n&&(n.classList.remove("show"),F.set(e,!1),D(e),t&&e.focus({preventScroll:!0}))}function ae(e){const t=We(e);p.forEach((r,s)=>{s!==e&&G(s,!1)}),t.classList.add("show"),F.set(e,!0),_(e),se(e,t),D(e),t.querySelector('[data-field="schema"]')?.focus(),C(e,"panel-open",!1)}function ke(e,t){const n=me(e);return(typeof t=="boolean"?t:!n)?ae(e):G(e,!1),!0}function Ge(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Fe(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function C(e,t,n){const r=u.get(e)||w;if(!r)return[];const s=g(e,r),o=p.get(e),a=e.innerHTML;if(!n&&s.snapshot===a)return s.issues;const c=L(r,s.activeSchemaId);if(!c)return s.issues=[V("missing-section","error","No active schema is configured for this editor.",{suggestion:"Set `defaultSchemaId` or update schema options."})],s.headingCount=0,s.recognizedHeadingCount=0,s.missingCount=1,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),s.issues;const i=Ue(e,c,r);return s.issues=i.issues,s.headingCount=i.headingCount,s.recognizedHeadingCount=i.recognizedHeadingCount,s.missingCount=i.missingCount,s.lastRunAt=new Date().toISOString(),s.snapshot=a,_(e),D(e),e.dispatchEvent(new CustomEvent("editora:doc-schema-validation",{bubbles:!0,detail:{reason:t,state:we(e)}})),o&&ee(o,i.issues.length===0?r.labels.noIssuesText:`${i.issues.length} issue${i.issues.length===1?"":"s"} detected.`),s.issues}function $e(e){const t=u.get(e)||w;if(!t)return;de(e);const n=window.setTimeout(()=>{te.delete(e),C(e,"realtime",!1)},t.debounceMs);te.set(e,n)}function Ce(e,t){const n=u.get(e)||w;if(!n)return!1;const r=g(e,n),s=typeof t=="boolean"?t:!r.realtimeEnabled;return r.realtimeEnabled=s,s?$e(e):de(e),_(e),D(e),!0}function Me(e){const t=u.get(e)||w;if(!t)return!1;const n=g(e,t),r=p.get(e);if(ve(e))return r&&ee(r,t.labels.readonlyMessage),!1;const s=L(t,n.activeSchemaId);if(!s)return!1;C(e,"insert-missing-pre",!0);const o=Array.from(new Set(n.issues.filter(f=>f.type==="missing-section"&&f.sectionId).map(f=>f.sectionId))),a=s.sections.filter(f=>o.includes(f.id));if(a.length===0)return r&&ee(r,t.labels.noIssuesText),!1;const c=e.innerHTML,i=Ee(e,s,t.normalizeText),l=Be(i,2),d=Ke(e);a.forEach(f=>{const k=s.strictOrder?Ve(e,f,s,t.normalizeText):d||{parent:e,referenceNode:null},[O,A]=je(e,f,t,l);k.parent.insertBefore(O,k.referenceNode),k.parent.insertBefore(A,k.referenceNode)}),Ge(e,c),Fe(e),C(e,"insert-missing-post",!0);const y=a.map(f=>f.title).join(", ");return e.dispatchEvent(new CustomEvent("editora:doc-schema-insert-missing",{bubbles:!0,detail:{schemaId:s.id,sectionIds:a.map(f=>f.id)}})),r&&ee(r,`${t.labels.insertedSummaryPrefix}: ${y}`),!0}function We(e){const t=p.get(e);if(t)return t;const n=u.get(e)||w||Z();g(e,n);const r=`rte-doc-schema-panel-${Le++}`,s=`${r}-schema`,o=document.createElement("section");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=`
7
7
  <header class="rte-doc-schema-header">
8
8
  <h2 class="rte-doc-schema-title">${I(n.labels.panelTitle)}</h2>
9
9
  <button type="button" class="rte-doc-schema-icon-btn" data-action="close" aria-label="${I(n.labels.closeText)}">✕</button>
@@ -26,7 +26,7 @@
26
26
  </div>
27
27
  </div>
28
28
  <div class="rte-doc-schema-live" aria-live="polite" aria-atomic="true"></div>
29
- `,o.addEventListener("click",a=>{const i=a.target?.closest("[data-action]");if(!i)return;const l=i.getAttribute("data-action");if(l==="close"){G(e,!0);return}if(l==="run-validation"){C(e,"panel-button",!0);return}if(l==="insert-missing"){Me(e);return}l==="toggle-realtime"&&Ce(e)}),o.addEventListener("change",a=>{const c=a.target;if(!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="schema")return;const i=u.get(e)||w;if(!i)return;const l=g(e,i),d=c.value;L(i,d)&&(l.activeSchemaId=d,l.snapshot="",C(e,"schema-change",!0))}),o.addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),G(e,!0))}),oe(o,e),document.body.appendChild(o),p.set(e,o),F.set(e,!1),_(e),o}function We(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function Ye(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="j"}function Je(e){w=e,q||(q=t=>{Q();const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||e;g(r,s),u.set(r,s),b=r,D(r);const o=p.get(r);o&&(oe(o,r),se(r,o),_(r))},document.addEventListener("focusin",q,!0)),z||(z=t=>{const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||w;!s||!g(r,s).realtimeEnabled||$e(r)},document.addEventListener("input",z,!0)),B||(B=t=>{if(t.defaultPrevented||t.target?.closest(`.${m}`)&&t.key!=="Escape")return;const r=_e(t);if(!r)return;const s=u.get(r)||w||e;if(g(r,s),u.set(r,s),b=r,t.key==="Escape"&&me(r)){t.preventDefault(),G(r,!0);return}if(We(t)){t.preventDefault(),t.stopPropagation(),ke(r);return}Ye(t)&&(t.preventDefault(),t.stopPropagation(),C(r,"shortcut",!0))},document.addEventListener("keydown",B,!0)),R||(R=()=>{Q(),p.forEach((t,n)=>{!n.isConnected||!t.isConnected||(oe(t,n),se(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!K&&typeof MutationObserver<"u"&&document.body&&(K=new MutationObserver(t=>{Pe(t)&&Q()}),K.observe(document.body,{childList:!0,subtree:!0}))}function Xe(){q&&(document.removeEventListener("focusin",q,!0),q=null),z&&(document.removeEventListener("input",z,!0),z=null),B&&(document.removeEventListener("keydown",B,!0),B=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),K&&(K.disconnect(),K=null),p.forEach(t=>t.remove()),p.clear(),Array.from(ne).forEach(t=>ue(t)),w=null,b=null}function Ze(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
29
+ `,o.addEventListener("click",a=>{const i=a.target?.closest("[data-action]");if(!i)return;const l=i.getAttribute("data-action");if(l==="close"){G(e,!0);return}if(l==="run-validation"){C(e,"panel-button",!0);return}if(l==="insert-missing"){Me(e);return}l==="toggle-realtime"&&Ce(e)}),o.addEventListener("change",a=>{const c=a.target;if(!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="schema")return;const i=u.get(e)||w;if(!i)return;const l=g(e,i),d=c.value;L(i,d)&&(l.activeSchemaId=d,l.snapshot="",C(e,"schema-change",!0))}),o.addEventListener("keydown",a=>{a.key==="Escape"&&(a.preventDefault(),G(e,!0))}),oe(o,e),document.body.appendChild(o),p.set(e,o),F.set(e,!1),_(e),o}function Te(e){return typeof e.key=="string"?e.key.toLowerCase():""}function Ye(e){const t=Te(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function Je(e){const t=Te(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="j"}function Xe(e){w=e,q||(q=t=>{Q();const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||e;g(r,s),u.set(r,s),b=r,D(r);const o=p.get(r);o&&(oe(o,r),se(r,o),_(r))},document.addEventListener("focusin",q,!0)),z||(z=t=>{const r=t.target?.closest(S);if(!r)return;const s=u.get(r)||w;!s||!g(r,s).realtimeEnabled||$e(r)},document.addEventListener("input",z,!0)),B||(B=t=>{if(t.defaultPrevented||t.target?.closest(`.${m}`)&&t.key!=="Escape")return;const r=qe(t);if(!r)return;const s=u.get(r)||w||e;if(g(r,s),u.set(r,s),b=r,t.key==="Escape"&&me(r)){t.preventDefault(),G(r,!0);return}if(Ye(t)){t.preventDefault(),t.stopPropagation(),ke(r);return}Je(t)&&(t.preventDefault(),t.stopPropagation(),C(r,"shortcut",!0))},document.addEventListener("keydown",B,!0)),R||(R=()=>{Q(),p.forEach((t,n)=>{!n.isConnected||!t.isConnected||(oe(t,n),se(n,t))})},window.addEventListener("scroll",R,!0),window.addEventListener("resize",R)),!K&&typeof MutationObserver<"u"&&document.body&&(K=new MutationObserver(t=>{_e(t)&&Q()}),K.observe(document.body,{childList:!0,subtree:!0}))}function Ze(){q&&(document.removeEventListener("focusin",q,!0),q=null),z&&(document.removeEventListener("input",z,!0),z=null),B&&(document.removeEventListener("keydown",B,!0),B=null),R&&(window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),R=null),K&&(K.disconnect(),K=null),p.forEach(t=>t.remove()),p.clear(),Array.from(ne).forEach(t=>ue(t)),w=null,b=null}function Qe(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
30
30
  .rte-toolbar-group-items.${v},
31
31
  .editora-toolbar-group-items.${v},
32
32
  .rte-toolbar-group-items.${M},
@@ -395,4 +395,4 @@
395
395
  grid-template-columns: 1fr;
396
396
  }
397
397
  }
398
- `,document.head.appendChild(e)}const Qe=(e={})=>{const t=Z(e),n=new Set;return Ze(),{name:"docSchema",toolbar:[{id:"docSchemaGroup",label:"Document Schema",type:"group",command:"docSchema",items:[{id:"toggleDocSchemaPanel",label:"Document Schema",command:"toggleDocSchemaPanel",shortcut:"Mod-Alt-Shift-g",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>'},{id:"runDocSchemaValidation",label:"Run Schema Validation",command:"runDocSchemaValidation",shortcut:"Mod-Alt-Shift-j",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>'},{id:"toggleDocSchemaRealtime",label:"Toggle Schema Realtime",command:"toggleDocSchemaRealtime",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>'}]}],commands:{docSchema:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},openDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},toggleDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ke(o,typeof r=="boolean"?r:void 0)},runDocSchemaValidation:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,C(o,"command",!0),!0},insertMissingDocSchemaSections:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Me(o)},toggleDocSchemaRealtime:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Ce(o,typeof r=="boolean"?r:void 0)},setDocSchemaMode:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t,c=g(o,a);u.set(o,a);const i=typeof r=="string"?r:r?.schemaId||r?.id;return!i||!L(a,i)?!1:(c.activeSchemaId=i,c.snapshot="",C(o,"set-mode",!0),!0)},setDocSchemaOptions:(r,s)=>{const o=T(s,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=u.get(o)||t,c=X.get(o)||He(a),i={...c,...r,labels:{...c.labels||{},...r.labels||{}},schemas:Array.isArray(r.schemas)?r.schemas:c.schemas,normalizeText:r.normalizeText||a.normalizeText},l=Z(i);u.set(o,l),X.set(o,i);const d=g(o,l);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},getDocSchemaState:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;g(o,a);const c=we(o);if(typeof r=="function")try{r(c)}catch{}return o.__docSchemaState=c,o.dispatchEvent(new CustomEvent("editora:doc-schema-state",{bubbles:!0,detail:c})),!0}},keymap:{"Mod-Alt-Shift-g":"toggleDocSchemaPanel","Mod-Alt-Shift-G":"toggleDocSchemaPanel","Mod-Alt-Shift-j":"runDocSchemaValidation","Mod-Alt-Shift-J":"runDocSchemaValidation"},init:function(s){W+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Z(o);Je(a);const c=T(s?.editorElement?{editorElement:s.editorElement}:void 0,!1,!1);c&&(b=c,n.add(c),g(c,a),u.set(c,a),X.set(c,o),D(c),C(c,"init",!0))},destroy:()=>{n.forEach(r=>ue(r)),n.clear(),W=Math.max(0,W-1),!(W>0)&&Xe()}}};exports.DocSchemaPlugin=Qe;
398
+ `,document.head.appendChild(e)}const et=(e={})=>{const t=Z(e),n=new Set;return Qe(),{name:"docSchema",toolbar:[{id:"docSchemaGroup",label:"Document Schema",type:"group",command:"docSchema",items:[{id:"toggleDocSchemaPanel",label:"Document Schema",command:"toggleDocSchemaPanel",shortcut:"Mod-Alt-Shift-g",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>'},{id:"runDocSchemaValidation",label:"Run Schema Validation",command:"runDocSchemaValidation",shortcut:"Mod-Alt-Shift-j",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>'},{id:"toggleDocSchemaRealtime",label:"Toggle Schema Realtime",command:"toggleDocSchemaRealtime",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>'}]}],commands:{docSchema:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},openDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ae(o),!0},toggleDocSchemaPanel:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,ke(o,typeof r=="boolean"?r:void 0)},runDocSchemaValidation:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,C(o,"command",!0),!0},insertMissingDocSchemaSections:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Me(o)},toggleDocSchemaRealtime:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;return g(o,a),u.set(o,a),b=o,Ce(o,typeof r=="boolean"?r:void 0)},setDocSchemaMode:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t,c=g(o,a);u.set(o,a);const i=typeof r=="string"?r:r?.schemaId||r?.id;return!i||!L(a,i)?!1:(c.activeSchemaId=i,c.snapshot="",C(o,"set-mode",!0),!0)},setDocSchemaOptions:(r,s)=>{const o=T(s,!1,!1);if(!o||!r||typeof r!="object")return!1;const a=u.get(o)||t,c=X.get(o)||Re(a),i={...c,...r,labels:{...c.labels||{},...r.labels||{}},schemas:Array.isArray(r.schemas)?r.schemas:c.schemas,normalizeText:r.normalizeText||a.normalizeText},l=Z(i);u.set(o,l),X.set(o,i);const d=g(o,l);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},getDocSchemaState:(r,s)=>{const o=T(s,!1,!1);if(!o)return!1;const a=u.get(o)||t;g(o,a);const c=we(o);if(typeof r=="function")try{r(c)}catch{}return o.__docSchemaState=c,o.dispatchEvent(new CustomEvent("editora:doc-schema-state",{bubbles:!0,detail:c})),!0}},keymap:{"Mod-Alt-Shift-g":"toggleDocSchemaPanel","Mod-Alt-Shift-G":"toggleDocSchemaPanel","Mod-Alt-Shift-j":"runDocSchemaValidation","Mod-Alt-Shift-J":"runDocSchemaValidation"},init:function(s){W+=1;const o=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Z(o);Xe(a);const c=T(s?.editorElement?{editorElement:s.editorElement}:void 0,!1,!1);c&&(b=c,n.add(c),g(c,a),u.set(c,a),X.set(c,o),D(c),C(c,"init",!0))},destroy:()=>{n.forEach(r=>ue(r)),n.clear(),W=Math.max(0,W-1),!(W>0)&&Ze()}}};exports.DocSchemaPlugin=et;