@editora/plugins 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -4
  3. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  4. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  5. package/dist/anchor.cjs.js +11 -11
  6. package/dist/anchor.esm.js +130 -107
  7. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  8. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  9. package/dist/approval-workflow.cjs.js +447 -0
  10. package/dist/approval-workflow.esm.js +1070 -0
  11. package/dist/background-color.cjs.js +3 -3
  12. package/dist/background-color.esm.js +116 -119
  13. package/dist/blocks-library.cjs.js +442 -0
  14. package/dist/blocks-library.esm.js +1317 -0
  15. package/dist/citations.cjs.js +548 -0
  16. package/dist/citations.esm.js +1457 -0
  17. package/dist/code.cjs.js +82 -102
  18. package/dist/code.esm.js +1172 -662
  19. package/dist/comments.cjs.js +10 -10
  20. package/dist/comments.esm.js +195 -177
  21. package/dist/conditional-content.cjs.js +626 -0
  22. package/dist/conditional-content.esm.js +1360 -0
  23. package/dist/content-rules.cjs.js +408 -0
  24. package/dist/content-rules.esm.js +1093 -0
  25. package/dist/data-binding.cjs.js +321 -0
  26. package/dist/data-binding.esm.js +913 -0
  27. package/dist/doc-schema.cjs.js +398 -0
  28. package/dist/doc-schema.esm.js +1310 -0
  29. package/dist/document-manager.cjs.js +1 -1
  30. package/dist/document-manager.esm.js +1 -1
  31. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  32. package/dist/documentManager-Jf0RbSks.js +17 -0
  33. package/dist/embed-iframe.cjs.js +2 -2
  34. package/dist/embed-iframe.esm.js +8 -5
  35. package/dist/emojis.cjs.js +64 -39
  36. package/dist/emojis.esm.js +133 -104
  37. package/dist/enterprise.cjs.js +1 -0
  38. package/dist/enterprise.esm.js +56 -0
  39. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  40. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  41. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  42. package/dist/index-CvJk4DKa.js +221 -0
  43. package/dist/index-D3CycEFU.mjs +16543 -0
  44. package/dist/index-tqLTHcO6.js +1 -0
  45. package/dist/index.cjs.js +1 -1
  46. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  47. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  48. package/dist/index.esm.js +111 -75
  49. package/dist/jspdf.es.min-BoS80556.js +77 -0
  50. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  51. package/dist/link.cjs.js +6 -6
  52. package/dist/link.esm.js +41 -39
  53. package/dist/math.cjs.js +21 -21
  54. package/dist/math.esm.js +151 -112
  55. package/dist/media-manager.cjs.js +15 -15
  56. package/dist/media-manager.esm.js +227 -206
  57. package/dist/mentions.cjs.js +105 -0
  58. package/dist/mentions.esm.js +726 -0
  59. package/dist/merge-tag.cjs.js +44 -12
  60. package/dist/merge-tag.esm.js +368 -241
  61. package/dist/page-break.cjs.js +2 -2
  62. package/dist/page-break.esm.js +85 -77
  63. package/dist/pii-redaction.cjs.js +436 -0
  64. package/dist/pii-redaction.esm.js +1377 -0
  65. package/dist/preview.cjs.js +3 -3
  66. package/dist/preview.esm.js +29 -29
  67. package/dist/slash-commands.cjs.js +90 -0
  68. package/dist/slash-commands.esm.js +752 -0
  69. package/dist/smart-paste.cjs.js +398 -0
  70. package/dist/smart-paste.esm.js +1388 -0
  71. package/dist/special-characters.cjs.js +83 -45
  72. package/dist/special-characters.esm.js +149 -100
  73. package/dist/spell-check.cjs.js +9 -9
  74. package/dist/spell-check.esm.js +235 -216
  75. package/dist/template.cjs.js +14 -14
  76. package/dist/template.esm.js +157 -131
  77. package/dist/text-color.cjs.js +9 -9
  78. package/dist/text-color.esm.js +131 -115
  79. package/dist/track-changes.cjs.js +77 -0
  80. package/dist/track-changes.esm.js +755 -0
  81. package/dist/translation-workflow.cjs.js +626 -0
  82. package/dist/translation-workflow.esm.js +1718 -0
  83. package/dist/version-diff.cjs.js +362 -0
  84. package/dist/version-diff.esm.js +768 -0
  85. package/index.d.ts +849 -1
  86. package/package.json +105 -6
  87. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  88. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  89. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  90. package/dist/documentManager-_tQQfQi9.js +0 -317
  91. package/dist/index-D3pJyAsj.js +0 -1
@@ -0,0 +1,398 @@
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`
2
+ <li class="rte-doc-schema-issue ${x}" role="listitem">
3
+ <p class="rte-doc-schema-issue-message">${I(h.message)}${N?`: <strong>${I(N)}</strong>`:""}</p>
4
+ ${h.suggestion?`<p class="rte-doc-schema-issue-suggestion">${I(h.suggestion)}</p>`:""}
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=`
7
+ <header class="rte-doc-schema-header">
8
+ <h2 class="rte-doc-schema-title">${I(n.labels.panelTitle)}</h2>
9
+ <button type="button" class="rte-doc-schema-icon-btn" data-action="close" aria-label="${I(n.labels.closeText)}">✕</button>
10
+ </header>
11
+ <div class="rte-doc-schema-body">
12
+ <label class="rte-doc-schema-label" for="${I(s)}"></label>
13
+ <select id="${I(s)}" class="rte-doc-schema-select" data-field="schema"></select>
14
+ <p class="rte-doc-schema-description" hidden></p>
15
+ <p class="rte-doc-schema-summary"></p>
16
+ <div class="rte-doc-schema-actions">
17
+ <button type="button" class="rte-doc-schema-btn rte-doc-schema-btn-primary" data-action="run-validation"></button>
18
+ <button type="button" class="rte-doc-schema-btn" data-action="insert-missing"></button>
19
+ <button type="button" class="rte-doc-schema-btn" data-action="toggle-realtime" aria-pressed="false"></button>
20
+ </div>
21
+ <p class="rte-doc-schema-helper"></p>
22
+ <p class="rte-doc-schema-shortcut"></p>
23
+ <div class="rte-doc-schema-issues-wrap">
24
+ <ul class="rte-doc-schema-issues" role="list" aria-label="${I(n.labels.issueListLabel)}"></ul>
25
+ <p class="rte-doc-schema-empty" hidden></p>
26
+ </div>
27
+ </div>
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=`
30
+ .rte-toolbar-group-items.${v},
31
+ .editora-toolbar-group-items.${v},
32
+ .rte-toolbar-group-items.${M},
33
+ .editora-toolbar-group-items.${M},
34
+ .rte-toolbar-group-items.${H},
35
+ .editora-toolbar-group-items.${H} {
36
+ display: flex;
37
+ border: 1px solid #cbd5e1;
38
+ border-radius: 4px;
39
+ background: #ffffff;
40
+ }
41
+
42
+ .rte-toolbar-group-items.${v} .rte-toolbar-button,
43
+ .editora-toolbar-group-items.${v} .editora-toolbar-button,
44
+ .rte-toolbar-group-items.${M} .rte-toolbar-button,
45
+ .editora-toolbar-group-items.${M} .editora-toolbar-button,
46
+ .rte-toolbar-group-items.${H} .rte-toolbar-button,
47
+ .editora-toolbar-group-items.${H} .editora-toolbar-button {
48
+ border: none;
49
+ border-right: 1px solid #cbd5e1;
50
+ border-radius: 0;
51
+ }
52
+
53
+ .rte-toolbar-group-items.${v} .rte-toolbar-item:last-child .rte-toolbar-button,
54
+ .editora-toolbar-group-items.${v} .editora-toolbar-item:last-child .editora-toolbar-button,
55
+ .rte-toolbar-group-items.${M} .rte-toolbar-item:last-child .rte-toolbar-button,
56
+ .editora-toolbar-group-items.${M} .editora-toolbar-item:last-child .editora-toolbar-button,
57
+ .rte-toolbar-group-items.${H} .rte-toolbar-item:last-child .rte-toolbar-button,
58
+ .editora-toolbar-group-items.${H} .editora-toolbar-item:last-child .editora-toolbar-button {
59
+ border-right: none;
60
+ }
61
+
62
+ ${E} .rte-toolbar-group-items.${v},
63
+ ${E} .editora-toolbar-group-items.${v},
64
+ ${E} .rte-toolbar-group-items.${M},
65
+ ${E} .editora-toolbar-group-items.${M},
66
+ ${E} .rte-toolbar-group-items.${H},
67
+ ${E} .editora-toolbar-group-items.${H} {
68
+ border-color: #566275;
69
+ }
70
+ .rte-toolbar-button[data-command="toggleDocSchemaRealtime"].active,
71
+ .editora-toolbar-button[data-command="toggleDocSchemaRealtime"].active {
72
+ background-color: #ccc;
73
+ }
74
+ ${E} .rte-toolbar-group-items.${v} .rte-toolbar-button svg,
75
+ ${E} .editora-toolbar-group-items.${v} .editora-toolbar-button svg,
76
+ ${E} .rte-toolbar-group-items.${M} .rte-toolbar-button svg,
77
+ ${E} .editora-toolbar-group-items.${M} .editora-toolbar-button svg
78
+ {
79
+ fill: none;
80
+ }
81
+ ${E} .rte-toolbar-group-items.${v} .rte-toolbar-button,
82
+ ${E} .editora-toolbar-group-items.${v} .editora-toolbar-button
83
+ {
84
+ border-color: #566275;
85
+ }
86
+ .${m} {
87
+ position: fixed;
88
+ z-index: 12000;
89
+ display: none;
90
+ width: min(440px, calc(100vw - 20px));
91
+ max-height: calc(100vh - 20px);
92
+ border: 1px solid #d1d5db;
93
+ border-radius: 14px;
94
+ background: #ffffff;
95
+ color: #0f172a;
96
+ box-shadow: 0 24px 48px rgba(15, 23, 42, 0.24);
97
+ overflow: hidden;
98
+ }
99
+
100
+ .${m}.show {
101
+ display: flex;
102
+ flex-direction: column;
103
+ }
104
+
105
+ .${m}.rte-doc-schema-theme-dark {
106
+ border-color: #334155;
107
+ background: #0f172a;
108
+ color: #e2e8f0;
109
+ box-shadow: 0 24px 52px rgba(2, 6, 23, 0.68);
110
+ }
111
+
112
+ .rte-doc-schema-header {
113
+ display: flex;
114
+ align-items: center;
115
+ justify-content: space-between;
116
+ gap: 8px;
117
+ padding: 12px 14px;
118
+ border-bottom: 1px solid #e2e8f0;
119
+ background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
120
+ }
121
+
122
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-header {
123
+ border-color: #1e293b;
124
+ background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
125
+ }
126
+
127
+ .rte-doc-schema-title {
128
+ margin: 0;
129
+ font-size: 15px;
130
+ line-height: 1.2;
131
+ font-weight: 700;
132
+ }
133
+
134
+ .rte-doc-schema-icon-btn {
135
+ border: 1px solid #cbd5e1;
136
+ border-radius: 6px;
137
+ min-height: 34px;
138
+ width: 34px;
139
+ background: #ffffff;
140
+ color: #0f172a;
141
+ font-size: 16px;
142
+ line-height: 1;
143
+ font-weight: 600;
144
+ padding: 0;
145
+ display: inline-flex;
146
+ align-items: center;
147
+ justify-content: center;
148
+ cursor: pointer;
149
+ }
150
+
151
+ .rte-doc-schema-icon-btn:hover,
152
+ .rte-doc-schema-icon-btn:focus-visible {
153
+ outline: none;
154
+ border-color: #3b82f6;
155
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
156
+ }
157
+
158
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-icon-btn {
159
+ border-color: #475569;
160
+ background: #0f172a;
161
+ color: #e2e8f0;
162
+ }
163
+
164
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-icon-btn:hover,
165
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-icon-btn:focus-visible {
166
+ border-color: #60a5fa;
167
+ box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
168
+ }
169
+
170
+ .rte-doc-schema-body {
171
+ display: flex;
172
+ flex-direction: column;
173
+ gap: 8px;
174
+ padding: 12px;
175
+ overflow: auto;
176
+ }
177
+
178
+ .rte-doc-schema-label {
179
+ font-size: 12px;
180
+ line-height: 1.3;
181
+ font-weight: 700;
182
+ color: #334155;
183
+ }
184
+
185
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-label {
186
+ color: #cbd5e1;
187
+ }
188
+
189
+ .rte-doc-schema-select {
190
+ border: 1px solid #cbd5e1;
191
+ border-radius: 8px;
192
+ min-height: 34px;
193
+ padding: 0 10px;
194
+ font-size: 13px;
195
+ background: #ffffff;
196
+ color: inherit;
197
+ }
198
+
199
+ .rte-doc-schema-select:focus-visible {
200
+ border-color: #0f766e;
201
+ box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
202
+ outline: none;
203
+ }
204
+
205
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-select {
206
+ border-color: #334155;
207
+ background: #0b1220;
208
+ color: #e2e8f0;
209
+ }
210
+
211
+ .rte-doc-schema-description,
212
+ .rte-doc-schema-summary,
213
+ .rte-doc-schema-helper,
214
+ .rte-doc-schema-shortcut {
215
+ margin: 0;
216
+ font-size: 12px;
217
+ line-height: 1.35;
218
+ color: #475569;
219
+ }
220
+
221
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-description,
222
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-summary,
223
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-helper,
224
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-shortcut {
225
+ color: #94a3b8;
226
+ }
227
+
228
+ .rte-doc-schema-actions {
229
+ display: grid;
230
+ grid-template-columns: repeat(3, minmax(0, 1fr));
231
+ gap: 8px;
232
+ }
233
+
234
+ .rte-doc-schema-btn {
235
+ border: 1px solid #cbd5e1;
236
+ border-radius: 8px;
237
+ min-height: 34px;
238
+ padding: 0 8px;
239
+ background: #ffffff;
240
+ color: inherit;
241
+ font-size: 12px;
242
+ font-weight: 700;
243
+ cursor: pointer;
244
+ }
245
+
246
+ .rte-doc-schema-btn:disabled {
247
+ opacity: 0.6;
248
+ cursor: not-allowed;
249
+ }
250
+
251
+ .rte-doc-schema-btn-primary {
252
+ border-color: #0f766e;
253
+ background: #0f766e;
254
+ color: #f8fafc;
255
+ }
256
+
257
+ .rte-doc-schema-btn:hover,
258
+ .rte-doc-schema-btn:focus-visible {
259
+ border-color: #94a3b8;
260
+ outline: none;
261
+ }
262
+
263
+ .rte-doc-schema-btn-primary:hover,
264
+ .rte-doc-schema-btn-primary:focus-visible {
265
+ border-color: #115e59;
266
+ background: #115e59;
267
+ }
268
+
269
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-btn {
270
+ border-color: #334155;
271
+ background: #111827;
272
+ color: #e2e8f0;
273
+ }
274
+
275
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-btn-primary {
276
+ border-color: #14b8a6;
277
+ background: #0f766e;
278
+ color: #f0fdfa;
279
+ }
280
+
281
+ .rte-doc-schema-issues-wrap {
282
+ border: 1px solid #e2e8f0;
283
+ border-radius: 10px;
284
+ padding: 6px;
285
+ background: #f8fafc;
286
+ max-height: min(40vh, 320px);
287
+ overflow: auto;
288
+ }
289
+
290
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issues-wrap {
291
+ border-color: #334155;
292
+ background: #0b1220;
293
+ }
294
+
295
+ .rte-doc-schema-issues {
296
+ margin: 0;
297
+ padding: 0;
298
+ list-style: none;
299
+ display: grid;
300
+ gap: 6px;
301
+ }
302
+
303
+ .rte-doc-schema-issue {
304
+ border: 1px solid #cbd5e1;
305
+ border-radius: 8px;
306
+ background: #ffffff;
307
+ padding: 8px;
308
+ display: grid;
309
+ gap: 4px;
310
+ }
311
+
312
+ .rte-doc-schema-issue.error {
313
+ border-color: #ef4444;
314
+ background: #fef2f2;
315
+ }
316
+
317
+ .rte-doc-schema-issue.warning {
318
+ border-color: #f59e0b;
319
+ background: #fffbeb;
320
+ }
321
+
322
+ .rte-doc-schema-issue.info {
323
+ border-color: #0ea5e9;
324
+ background: #f0f9ff;
325
+ }
326
+
327
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue {
328
+ border-color: #334155;
329
+ background: #111827;
330
+ color: #e2e8f0;
331
+ }
332
+
333
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue.error {
334
+ border-color: rgba(239, 68, 68, 0.7);
335
+ background: rgba(127, 29, 29, 0.28);
336
+ }
337
+
338
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue.warning {
339
+ border-color: rgba(245, 158, 11, 0.72);
340
+ background: rgba(120, 53, 15, 0.28);
341
+ }
342
+
343
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue.info {
344
+ border-color: rgba(14, 165, 233, 0.7);
345
+ background: rgba(7, 89, 133, 0.28);
346
+ }
347
+
348
+ .rte-doc-schema-issue-message,
349
+ .rte-doc-schema-issue-suggestion {
350
+ margin: 0;
351
+ font-size: 12px;
352
+ line-height: 1.35;
353
+ color: #1f2937;
354
+ }
355
+
356
+ .rte-doc-schema-issue-suggestion {
357
+ color: #475569;
358
+ }
359
+
360
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue-message {
361
+ color: #e2e8f0;
362
+ }
363
+
364
+ .${m}.rte-doc-schema-theme-dark .rte-doc-schema-issue-suggestion {
365
+ color: #cbd5e1;
366
+ }
367
+
368
+ .rte-doc-schema-empty {
369
+ margin: 8px;
370
+ font-size: 12px;
371
+ color: #64748b;
372
+ }
373
+
374
+ .rte-doc-schema-live {
375
+ position: absolute;
376
+ width: 1px;
377
+ height: 1px;
378
+ margin: -1px;
379
+ padding: 0;
380
+ overflow: hidden;
381
+ clip: rect(0 0 0 0);
382
+ border: 0;
383
+ }
384
+
385
+ @media (max-width: 768px) {
386
+ .${m} {
387
+ left: 10px !important;
388
+ right: 10px;
389
+ top: 10px !important;
390
+ width: auto !important;
391
+ max-height: calc(100vh - 20px);
392
+ }
393
+
394
+ .rte-doc-schema-actions {
395
+ grid-template-columns: 1fr;
396
+ }
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;