@editora/core 1.0.20 → 1.0.21

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.
@@ -101,7 +101,7 @@ class W {
101
101
  }
102
102
  class X {
103
103
  constructor(e) {
104
- this.gutterWidth = 50, this.gutterFoldColumnWidth = 20, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
104
+ this.gutterWidth = 50, this.gutterFoldColumnWidth = 24, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 24, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
105
105
  }
106
106
  createDOM() {
107
107
  this.container.innerHTML = "";
@@ -2831,7 +2831,7 @@ class oe {
2831
2831
  }
2832
2832
  class le {
2833
2833
  constructor() {
2834
- this.name = "code-folding", this.lineHeight = 21, this.voidMarkupTags = /* @__PURE__ */ new Set([
2834
+ this.name = "code-folding", this.lineHeight = 24, this.voidMarkupTags = /* @__PURE__ */ new Set([
2835
2835
  "area",
2836
2836
  "base",
2837
2837
  "br",
@@ -2909,7 +2909,7 @@ class le {
2909
2909
  right: 0;
2910
2910
  top: 0;
2911
2911
  bottom: 0;
2912
- width: 20px;
2912
+ width: 24px;
2913
2913
  pointer-events: none;
2914
2914
  z-index: 3;
2915
2915
  `, e.appendChild(this.foldingUI));
@@ -3137,7 +3137,7 @@ class le {
3137
3137
  position: absolute;
3138
3138
  left: 0;
3139
3139
  top: ${t * this.lineHeight}px;
3140
- width: 20px;
3140
+ width: 24px;
3141
3141
  height: ${this.lineHeight}px;
3142
3142
  display: flex;
3143
3143
  align-items: center;
@@ -4728,4 +4728,4 @@ const P = '[data-theme="dark"], .dark, .editora-theme-dark', ce = `/* Source Edi
4728
4728
  export {
4729
4729
  ge as CodePlugin
4730
4730
  };
4731
- //# sourceMappingURL=CodePlugin.native-BcVqm5MS.mjs.map
4731
+ //# sourceMappingURL=CodePlugin.native-AoJ_idGz.mjs.map
@@ -135,7 +135,7 @@ class Ot {
135
135
  }
136
136
  class Qn {
137
137
  constructor(e) {
138
- this.gutterWidth = 50, this.gutterFoldColumnWidth = 20, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 21, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
138
+ this.gutterWidth = 50, this.gutterFoldColumnWidth = 24, this.gutterFoldColumnGap = 4, this.gutterLineNumberPaddingLeft = 8, this.gutterLineNumberPaddingRight = 4, this.gutterDigitWidth = 9, this.lineHeight = 24, this.trailingNewlineMarkerAttr = "data-lce-trailing-newline-marker", this.foldPlaceholderAttr = "data-lce-fold-placeholder", this.virtualMarkerRegex = /[\u200B\uE000]/, this.virtualMarkerGlobalRegex = /[\u200B\uE000]/g, this.lastLineCount = 0, this.lastHighlightHTML = "", this.highlightOverlayActive = !1, this.lastLineDecorationSnapshot = "", this.lastGutterDecorationSnapshot = "", this.container = e, this.createDOM();
139
139
  }
140
140
  createDOM() {
141
141
  this.container.innerHTML = "";
@@ -2865,7 +2865,7 @@ class oi {
2865
2865
  }
2866
2866
  class ai {
2867
2867
  constructor() {
2868
- this.name = "code-folding", this.lineHeight = 21, this.voidMarkupTags = /* @__PURE__ */ new Set([
2868
+ this.name = "code-folding", this.lineHeight = 24, this.voidMarkupTags = /* @__PURE__ */ new Set([
2869
2869
  "area",
2870
2870
  "base",
2871
2871
  "br",
@@ -2943,7 +2943,7 @@ class ai {
2943
2943
  right: 0;
2944
2944
  top: 0;
2945
2945
  bottom: 0;
2946
- width: 20px;
2946
+ width: 24px;
2947
2947
  pointer-events: none;
2948
2948
  z-index: 3;
2949
2949
  `, e.appendChild(this.foldingUI));
@@ -3171,7 +3171,7 @@ class ai {
3171
3171
  position: absolute;
3172
3172
  left: 0;
3173
3173
  top: ${t * this.lineHeight}px;
3174
- width: 20px;
3174
+ width: 24px;
3175
3175
  height: ${this.lineHeight}px;
3176
3176
  display: flex;
3177
3177
  align-items: center;
@@ -6247,4 +6247,4 @@ const Et = '[data-theme="dark"], .dark, .editora-theme-dark', ji = `/* Source Ed
6247
6247
  export {
6248
6248
  Gi as CodePlugin
6249
6249
  };
6250
- //# sourceMappingURL=CodePlugin.native-Rgxx2Igx.mjs.map
6250
+ //# sourceMappingURL=CodePlugin.native-CEgR1DWC.mjs.map
@@ -4,7 +4,7 @@ var Editora=(function(g){"use strict";class lt{constructor(t,e,o){this.doc=t,thi
4
4
 
5
5
  `,n.forEach(s=>{const c=this.getShortcutDescription(s);o+=`- **${c}**: ${s.description||s.command}
6
6
  `}),o+=`
7
- `}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}const Ne=new Set;function ze(a,t){Ne.has(a)||(Ne.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${t} instead.`))}function rn(a={}){ze("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:t=!1,provider:e="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:i}),e){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:f=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:f=>(console.log("[Spellcheck] Add to dictionary:",f),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){ze("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:t="",libraryUrl:e="",maxFileSize:o=10485760,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1048576,enableChunking:u=!0,onProgress:f,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:o,allowedTypes:n}),t||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Fe{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Rt{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new xt,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=lt.create(e),this.commandRegistry=new Fe(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let n;return e.length===0?n=o(this.state):e.length===1?n=o(this.state,e[0]):n=o(this.state,...e),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${t}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const n=o.indexOf(e);n>-1&&o.splice(n,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(n=>{try{n(...e)}catch(i){console.error(`Error in ${t} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class kt{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new kt(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new kt(this.doc,t)}update(t,e){return new kt(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pt{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&e.push(u)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const f=c.lastElementChild;f instanceof HTMLElement&&(this.overflowUnits.push(f),this.overflowUnitHomes.set(f,c))}),e.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",e.appendChild(u)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,t.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=t.clientWidth,f=16,b=40,T=4,v=Math.max(0,u-f-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const Z=k<c.length;o.style.display=Z?"":"none",o.classList.toggle("active",Z&&this.expandedOpen),!Z&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(t),s()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=t.icon,e.appendChild(n)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,t.items.forEach(i=>{this.appendToolbarButton(n,i)}),e.appendChild(n)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var f;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=(f=this.container)==null?void 0:f.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class He{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Ue{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class et{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height);const e=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
7
+ `}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}const Ne=new Set;function ze(a,t){Ne.has(a)||(Ne.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${t} instead.`))}function rn(a={}){ze("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:t=!1,provider:e="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:i}),e){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:f=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:f=>(console.log("[Spellcheck] Add to dictionary:",f),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){ze("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:t="",libraryUrl:e="",maxFileSize:o=10485760,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1048576,enableChunking:u=!0,onProgress:f,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:o,allowedTypes:n}),t||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Fe{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Rt{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new xt,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=lt.create(e),this.commandRegistry=new Fe(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let n;return e.length===0?n=o(this.state):e.length===1?n=o(this.state,e[0]):n=o(this.state,...e),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${t}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const n=o.indexOf(e);n>-1&&o.splice(n,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(n=>{try{n(...e)}catch(i){console.error(`Error in ${t} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class kt{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new kt(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new kt(this.doc,t)}update(t,e){return new kt(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pt{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&e.push(u)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const f=c.lastElementChild;f instanceof HTMLElement&&(this.overflowUnits.push(f),this.overflowUnitHomes.set(f,c))}),e.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",e.appendChild(u)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,t.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=t.clientWidth,f=16,b=40,T=4,v=Math.max(0,u-f-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const Z=k<c.length;o.style.display=Z?"":"none",o.classList.toggle("active",Z&&this.expandedOpen),!Z&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(t),s()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=t.icon,e.appendChild(n)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,t.items.forEach(i=>{this.appendToolbarButton(n,i)}),e.appendChild(n)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.setAttribute("aria-label",t.label),e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var f;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=(f=this.container)==null?void 0:f.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class He{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Ue{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class et{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height);const e=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
8
8
  <button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
9
9
  <button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
10
10
  `;if(t.innerHTML=`
@@ -4,7 +4,7 @@
4
4
 
5
5
  `,n.forEach(s=>{const c=this.getShortcutDescription(s);o+=`- **${c}**: ${s.description||s.command}
6
6
  `}),o+=`
7
- `}),o}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}const Nt=new Set;function zt(a,e){Nt.has(a)||(Nt.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${e} instead.`))}function rn(a={}){zt("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:e=!1,provider:t="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:i}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:g=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:g=>(console.log("[Spellcheck] Add to dictionary:",g),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){zt("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:e="",libraryUrl:t="",maxFileSize:o=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1024*1024,enableChunking:u=!0,onProgress:g,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:o,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Ft{constructor(e={}){this.commands=new Map,Object.entries(e).forEach(([t,o])=>{this.register(t,o)})}register(e,t){this.commands.has(e)&&console.warn(`Command ${e} is being overwritten`),this.commands.set(e,t)}unregister(e){this.commands.delete(e)}get(e){return this.commands.get(e)}has(e){return this.commands.has(e)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Re{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new xe,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(o=>this.pluginManager.register(o));const t=this.pluginManager.buildSchema();this.state=W.create(t),this.commandRegistry=new Ft(this.pluginManager.getCommands())}execCommand(e,...t){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(e);if(!o)return console.warn(`Command not found: ${e}`),!1;let n;return t.length===0?n=o(this.state):t.length===1?n=o(this.state,t[0]):n=o(this.state,...t),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${e}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(e){this.isDestroyed||(this.state=e,this.emit("stateChange",e))}getState(){return this.state}setReadonly(e){this.isReadonly=e,this.emit("readonlyChange",e)}isReadOnly(){return this.isReadonly}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const o=this.listeners.get(e);if(o){const n=o.indexOf(t);n>-1&&o.splice(n,1)}}}emit(e,...t){const o=this.listeners.get(e);o&&o.forEach(n=>{try{n(...t)}catch(i){console.error(`Error in ${e} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class ke{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new ke(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new ke(this.doc,e)}update(e,t){return new ke(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pe{constructor(e,t,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=e,this.plugins=t,this.pluginLoader=o}setLastCommandTrigger(e,t){if(typeof window=="undefined"||!e)return;const o=t||e.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=e,window.__editoraLastCommand=o)}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],o=e.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&t.push(u)}),t}getAvailableToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}render(e){this.container=e,e.innerHTML="",e.className="editora-toolbar",this.config.sticky&&e.classList.add("editora-toolbar-sticky"),this.config.position&&e.classList.add(`editora-toolbar-${this.config.position}`);const t=document.createElement("div");t.className="editora-toolbar-items-container",this.itemsContainer=t,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const g=c.lastElementChild;g instanceof HTMLElement&&(this.overflowUnits.push(g),this.overflowUnitHomes.set(g,c))}),t.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",t.appendChild(u)}}),e.appendChild(t),this.setupOverflow(e)}setupOverflow(e){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,e.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,e.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=e.clientWidth,g=16,b=40,T=4,v=Math.max(0,u-g-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const J=k<c.length;o.style.display=J?"":"none",o.classList.toggle("active",J&&this.expandedOpen),!J&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(e),s()}setExpandedOpen(e){var t,o;this.expandedOpen=e,(t=this.expandedRow)==null||t.classList.toggle("show",e),(o=this.moreButton)==null||o.classList.toggle("active",e)}appendToolbarButton(e,t){if(t.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",e.appendChild(o)}else if(t.type==="dropdown"){const o=this.createDropdown(t);e.appendChild(o)}else if(t.type==="inline-menu"){const o=this.createInlineMenu(t);e.appendChild(o)}else if(t.type==="group"&&t.items&&t.items.length){const o=this.createGroupButton(t);e.appendChild(o)}else if(t.type==="input"){const o=this.createInput(t);e.appendChild(o)}else{const o=this.createButton(t);e.appendChild(o)}}createGroupButton(e){const t=document.createElement("div"),o=e.label.toLowerCase().replace(/\s+/g,"-");if(t.className=`editora-toolbar-group-button ${o}`,t.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=e.icon,t.appendChild(n)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,e.items.forEach(i=>{this.appendToolbarButton(n,i)}),t.appendChild(n)}return t}createInput(e){const t=document.createElement("input");return t.className=`editora-toolbar-input ${e.label.toLowerCase().replace(/\s+/g,"-")}`,t.type="text",t.title=e.label,t.placeholder=e.placeholder||"",e.command&&t.setAttribute("data-command",e.command),e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(t,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createButton(e){const t=document.createElement("button");if(t.className="editora-toolbar-button",t.type="button",t.title=e.label,e.command&&t.setAttribute("data-command",e.command),e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=e.icon,t.appendChild(o)}else t.innerHTML=e.icon;else t.textContent=e.label;return e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createDropdown(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=e.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",g=>{g.preventDefault(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),t}createInlineMenu(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=e.icon,o.appendChild(c)}else o.innerHTML=e.icon;else o.textContent=e.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var g;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const u=(g=this.container)==null?void 0:g.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),t}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(t=>t.command).join(" ")}updateButtonState(e,t){if(!this.container)return;const o=this.container.querySelector(`[data-command="${e}"]`);o&&(t.active!==void 0&&o.classList.toggle("active",t.active),t.disabled!==void 0&&(o.disabled=t.disabled))}destroy(){var e;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Ht{constructor(e){this.visible=!1,this.config=e}create(e){const t=document.createElement("div");return t.className="editora-floating-toolbar",t.style.display="none",t.style.position="absolute",t.style.zIndex="1000",this.container=t,e.appendChild(t),t}show(e,t){this.container&&(this.container.style.display="block",this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(e,t){!this.container||!this.visible||(this.container.style.left=`${e}px`,this.container.style.top=`${t}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Ut{constructor(e={}){this.statusInfo={},this.config=e}create(e){const t=document.createElement("div");return t.className="editora-statusbar",this.config.position&&t.classList.add(`editora-statusbar-${this.config.position}`),this.container=t,e.appendChild(t),t}update(e){this.statusInfo={...this.statusInfo,...e},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="editora-statusbar-left";const t=document.createElement("div");t.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),this.container.appendChild(e),this.container.appendChild(t)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class oe{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
7
+ `}),o}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}const Nt=new Set;function zt(a,e){Nt.has(a)||(Nt.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${e} instead.`))}function rn(a={}){zt("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:e=!1,provider:t="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:i}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:g=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:g=>(console.log("[Spellcheck] Add to dictionary:",g),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){zt("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:e="",libraryUrl:t="",maxFileSize:o=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1024*1024,enableChunking:u=!0,onProgress:g,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:o,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Ft{constructor(e={}){this.commands=new Map,Object.entries(e).forEach(([t,o])=>{this.register(t,o)})}register(e,t){this.commands.has(e)&&console.warn(`Command ${e} is being overwritten`),this.commands.set(e,t)}unregister(e){this.commands.delete(e)}get(e){return this.commands.get(e)}has(e){return this.commands.has(e)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Re{constructor(e={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=e.readonly||!1,this.pluginManager=new xe,e.plugins&&Array.isArray(e.plugins)&&e.plugins.forEach(o=>this.pluginManager.register(o));const t=this.pluginManager.buildSchema();this.state=W.create(t),this.commandRegistry=new Ft(this.pluginManager.getCommands())}execCommand(e,...t){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(e);if(!o)return console.warn(`Command not found: ${e}`),!1;let n;return t.length===0?n=o(this.state):t.length===1?n=o(this.state,t[0]):n=o(this.state,...t),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${e}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(e){this.isDestroyed||(this.state=e,this.emit("stateChange",e))}getState(){return this.state}setReadonly(e){this.isReadonly=e,this.emit("readonlyChange",e)}isReadOnly(){return this.isReadonly}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{const o=this.listeners.get(e);if(o){const n=o.indexOf(t);n>-1&&o.splice(n,1)}}}emit(e,...t){const o=this.listeners.get(e);o&&o.forEach(n=>{try{n(...t)}catch(i){console.error(`Error in ${e} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class ke{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new ke(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new ke(this.doc,e)}update(e,t){return new ke(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pe{constructor(e,t,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=e,this.plugins=t,this.pluginLoader=o}setLastCommandTrigger(e,t){if(typeof window=="undefined"||!e)return;const o=t||e.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=e,window.__editoraLastCommand=o)}setCommandHandler(e){this.commandHandler=e}parseToolbarString(e){const t=[],o=e.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&t.push(u)}),t}getAvailableToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}render(e){this.container=e,e.innerHTML="",e.className="editora-toolbar",this.config.sticky&&e.classList.add("editora-toolbar-sticky"),this.config.position&&e.classList.add(`editora-toolbar-${this.config.position}`);const t=document.createElement("div");t.className="editora-toolbar-items-container",this.itemsContainer=t,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const g=c.lastElementChild;g instanceof HTMLElement&&(this.overflowUnits.push(g),this.overflowUnitHomes.set(g,c))}),t.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",t.appendChild(u)}}),e.appendChild(t),this.setupOverflow(e)}setupOverflow(e){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,e.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,e.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=e.clientWidth,g=16,b=40,T=4,v=Math.max(0,u-g-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const J=k<c.length;o.style.display=J?"":"none",o.classList.toggle("active",J&&this.expandedOpen),!J&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(e),s()}setExpandedOpen(e){var t,o;this.expandedOpen=e,(t=this.expandedRow)==null||t.classList.toggle("show",e),(o=this.moreButton)==null||o.classList.toggle("active",e)}appendToolbarButton(e,t){if(t.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",e.appendChild(o)}else if(t.type==="dropdown"){const o=this.createDropdown(t);e.appendChild(o)}else if(t.type==="inline-menu"){const o=this.createInlineMenu(t);e.appendChild(o)}else if(t.type==="group"&&t.items&&t.items.length){const o=this.createGroupButton(t);e.appendChild(o)}else if(t.type==="input"){const o=this.createInput(t);e.appendChild(o)}else{const o=this.createButton(t);e.appendChild(o)}}createGroupButton(e){const t=document.createElement("div"),o=e.label.toLowerCase().replace(/\s+/g,"-");if(t.className=`editora-toolbar-group-button ${o}`,t.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=e.icon,t.appendChild(n)}else t.innerHTML=e.icon;if(e.items&&e.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,e.items.forEach(i=>{this.appendToolbarButton(n,i)}),t.appendChild(n)}return t}createInput(e){const t=document.createElement("input");return t.className=`editora-toolbar-input ${e.label.toLowerCase().replace(/\s+/g,"-")}`,t.type="text",t.title=e.label,t.setAttribute("aria-label",e.label),t.placeholder=e.placeholder||"",e.command&&t.setAttribute("data-command",e.command),e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(t,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createButton(e){const t=document.createElement("button");if(t.className="editora-toolbar-button",t.type="button",t.title=e.label,e.command&&t.setAttribute("data-command",e.command),e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=e.icon,t.appendChild(o)}else t.innerHTML=e.icon;else t.textContent=e.label;return e.active&&t.classList.add("active"),e.disabled&&(t.disabled=!0),t.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&e.command&&this.commandHandler(e.command)}),t}createDropdown(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=e.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",g=>{g.preventDefault(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),t}createInlineMenu(e){const t=document.createElement("div");t.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=e.label,e.icon)if(e.icon.startsWith("<svg")&&e.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=e.icon,o.appendChild(c)}else o.innerHTML=e.icon;else o.textContent=e.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",e.options&&e.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.setLastCommandTrigger(o,e.command),this.commandHandler&&e.command&&this.commandHandler(e.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var g;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,e.command);const u=(g=this.container)==null?void 0:g.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{t.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),t._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},t.appendChild(o),t.appendChild(n),t}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(t=>t.command).join(" ")}updateButtonState(e,t){if(!this.container)return;const o=this.container.querySelector(`[data-command="${e}"]`);o&&(t.active!==void 0&&o.classList.toggle("active",t.active),t.disabled!==void 0&&(o.disabled=t.disabled))}destroy(){var e;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Ht{constructor(e){this.visible=!1,this.config=e}create(e){const t=document.createElement("div");return t.className="editora-floating-toolbar",t.style.display="none",t.style.position="absolute",t.style.zIndex="1000",this.container=t,e.appendChild(t),t}show(e,t){this.container&&(this.container.style.display="block",this.container.style.left=`${e}px`,this.container.style.top=`${t}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(e,t){!this.container||!this.visible||(this.container.style.left=`${e}px`,this.container.style.top=`${t}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Ut{constructor(e={}){this.statusInfo={},this.config=e}create(e){const t=document.createElement("div");return t.className="editora-statusbar",this.config.position&&t.classList.add(`editora-statusbar-${this.config.position}`),this.container=t,e.appendChild(t),t}update(e){this.statusInfo={...this.statusInfo,...e},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const e=document.createElement("div");e.className="editora-statusbar-left";const t=document.createElement("div");t.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),this.container.appendChild(e),this.container.appendChild(t)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class oe{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
8
8
  <button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
9
9
  <button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
10
10
  `;if(e.innerHTML=`
@@ -838,7 +838,7 @@ class fn {
838
838
  */
839
839
  createInput(t) {
840
840
  const e = document.createElement("input");
841
- return e.className = `editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g, "-")}`, e.type = "text", e.title = t.label, e.placeholder = t.placeholder || "", t.command && e.setAttribute("data-command", t.command), t.active && e.classList.add("active"), t.disabled && (e.disabled = !0), e.addEventListener("click", (o) => {
841
+ return e.className = `editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g, "-")}`, e.type = "text", e.title = t.label, e.setAttribute("aria-label", t.label), e.placeholder = t.placeholder || "", t.command && e.setAttribute("data-command", t.command), t.active && e.classList.add("active"), t.disabled && (e.disabled = !0), e.addEventListener("click", (o) => {
842
842
  o.preventDefault(), this.setLastCommandTrigger(e, t.command), this.commandHandler && t.command && this.commandHandler(t.command);
843
843
  }), e;
844
844
  }
@@ -3943,4 +3943,4 @@ export {
3943
3943
  yi as o,
3944
3944
  ii as s
3945
3945
  };
3946
- //# sourceMappingURL=index-BxlbmLsp.mjs.map
3946
+ //# sourceMappingURL=index-6i4_TH66.mjs.map