@editora/core 1.0.0 → 1.0.1

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.
package/dist/index.cjs.js CHANGED
@@ -1,7 +1,520 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class c{constructor(e,t,i){this.doc=e,this.selection=t,this.schema=i}static create(e,t){const i=t||e.node("doc",{},[e.node("paragraph")]);return new c(i,{anchor:0,head:0},e)}apply(e,t){return new c(e,t||this.selection,this.schema)}}class f{constructor(e){this.listeners=[],this.pluginManager=e;const t=e.buildSchema();this.state=c.create(t),this.commands=e.getCommands()}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}execCommand(e){const t=this.commands[e];if(!t)return!1;const i=t(this.state);return i?(this.setState(i),!0):!1}setContent(e){this.setState(this.state.apply(e))}getContent(){return this.state.doc}}class p{constructor(e,t){this.nodes=new Map(Object.entries(e)),this.marks=new Map(Object.entries(t))}node(e,t,i){return{type:e,attrs:t,content:i}}text(e,t){return{type:"text",text:e,marks:t}}}class y{constructor(){this.plugins=[]}register(e){this.plugins.push(e)}buildSchema(){const e={},t={};return this.plugins.forEach(i=>{i.nodes&&Object.assign(e,i.nodes),i.marks&&Object.assign(t,i.marks)}),new p(e,t)}getCommands(){const e={};return this.plugins.forEach(t=>{t.commands&&Object.assign(e,t.commands)}),e}getToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}}class g{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,this.plugin.context?.initialize&&this.plugin.context.initialize(),this.plugin.context?.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(t){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,t),!1}}destroy(){if(!this.initialized)return!1;try{return this.plugin.context?.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(e){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,e),!1}}executeCommand(e,...t){if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const i=this.plugin.commands?.[e];return i?i(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(i){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,i),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function S(n){return new g(n)}class k{constructor(e){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator<"u"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,e?.enabled===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),e?.shortcuts&&e.shortcuts.forEach(t=>this.registerShortcut(t)),e?.customShortcuts&&Object.values(e.customShortcuts).forEach(t=>{this.registerShortcut(t)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let e=1;e<=6;e++)this.registerShortcut({key:String(e),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${e}`,description:`Heading ${e}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.set(t,e)}unregisterShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.delete(t)}getShortcutKey(e){const t=[];return e.ctrl&&t.push("ctrl"),e.alt&&t.push("alt"),e.shift&&t.push("shift"),e.meta&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}getEventKey(e){const t=[];return e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.metaKey&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}handleKeyDown(e,t){if(!this.enabled)return!1;const i=this.getEventKey(e),r=this.shortcuts.get(i);return r?(r.preventDefault!==!1&&(e.preventDefault(),e.stopPropagation()),t(r.command,r.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(e){return Array.from(this.shortcuts.values()).find(t=>t.command===e)}getShortcutDescription(e){const t=[];this.isMac?(e.meta&&t.push("⌘"),e.ctrl&&t.push("⌃"),e.alt&&t.push("⌥"),e.shift&&t.push("⇧")):(e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));const i=e.key.length===1?e.key.toUpperCase():e.key;return t.push(i),t.join("+")}getShortcutsHelp(){const e=this.getAllShortcuts(),t=new Map;e.forEach(r=>{const a=this.getShortcutCategory(r.command);t.has(a)||t.set(a,[]),t.get(a).push(r)});let i=`# Keyboard Shortcuts
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-BK2lHfHK.js");class v{constructor(e){if(this.listeners=[],e instanceof l.PluginManager)this.pluginManager=e;else{const i=e;this.pluginManager=new l.PluginManager,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(n=>{this.pluginManager.register(n)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const t=this.pluginManager.buildSchema();this.state=l.EditorState.create(t),this.commands=this.pluginManager.getCommands()}setupDOMElement(e){this.domElement&&(e.enableToolbar!==!1&&e.toolbarElement?this.toolbarElement=e.toolbarElement:e.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",e.content&&(this.contentElement.innerHTML=e.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(t=>t(this.state))}))}setupKeyboardShortcuts(e){const t={};e.forEach(i=>{i.shortcut&&(t[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const n=[];(i.ctrlKey||i.metaKey)&&n.push("ctrl"),i.shiftKey&&n.push("shift"),i.altKey&&n.push("alt");const s=i.key.toLowerCase(),o=n.length>0?`${n.join("+")}+${s}`:s,r=t[o];r&&(i.preventDefault(),this.execCommand(r))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(s=>s.id&&s.id===e||s.command===e);n&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.command))}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}on(e,t){return e==="change"||e==="input"?this.onChange(t):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(e,t){const i=this.commands[e];if(!i)return console.warn(`Command not found: ${e}`),!1;let n;return t!==void 0?n=i(this.state,t):n=i(this.state),n?(this.setState(n),!0):!1}setContent(e){typeof e=="string"?this.contentElement&&(this.contentElement.innerHTML=e):this.setState(this.state.apply(e))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class f{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){var t,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,(t=this.plugin.context)!=null&&t.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!1}}destroy(){var e;if(!this.initialized)return!1;try{return(e=this.plugin.context)!=null&&e.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(t){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,t),!1}}executeCommand(e,...t){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const n=(i=this.plugin.commands)==null?void 0:i[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,n),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function E(a){return new f(a)}class S{constructor(e){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(e==null?void 0:e.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),e!=null&&e.shortcuts&&e.shortcuts.forEach(t=>this.registerShortcut(t)),e!=null&&e.customShortcuts&&Object.values(e.customShortcuts).forEach(t=>{this.registerShortcut(t)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let e=1;e<=6;e++)this.registerShortcut({key:String(e),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${e}`,description:`Heading ${e}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.set(t,e)}unregisterShortcut(e){const t=this.getShortcutKey(e);this.shortcuts.delete(t)}getShortcutKey(e){const t=[];return e.ctrl&&t.push("ctrl"),e.alt&&t.push("alt"),e.shift&&t.push("shift"),e.meta&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}getEventKey(e){const t=[];return e.ctrlKey&&t.push("ctrl"),e.altKey&&t.push("alt"),e.shiftKey&&t.push("shift"),e.metaKey&&t.push("meta"),t.push(e.key.toLowerCase()),t.join("+")}handleKeyDown(e,t){if(!this.enabled)return!1;const i=this.getEventKey(e),n=this.shortcuts.get(i);return n?(n.preventDefault!==!1&&(e.preventDefault(),e.stopPropagation()),t(n.command,n.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(e){return Array.from(this.shortcuts.values()).find(t=>t.command===e)}getShortcutDescription(e){const t=[];this.isMac?(e.meta&&t.push("⌘"),e.ctrl&&t.push("⌃"),e.alt&&t.push("⌥"),e.shift&&t.push("⇧")):(e.ctrl&&t.push("Ctrl"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift"));const i=e.key.length===1?e.key.toUpperCase():e.key;return t.push(i),t.join("+")}getShortcutsHelp(){const e=this.getAllShortcuts(),t=new Map;e.forEach(n=>{const s=this.getShortcutCategory(n.command);t.has(s)||t.set(s,[]),t.get(s).push(n)});let i=`# Keyboard Shortcuts
2
2
 
3
- `;return t.forEach((r,a)=>{i+=`## ${a}
3
+ `;return t.forEach((n,s)=>{i+=`## ${s}
4
4
 
5
- `,r.forEach(l=>{const o=this.getShortcutDescription(l);i+=`- **${o}**: ${l.description||l.command}
5
+ `,n.forEach(o=>{const r=this.getShortcutDescription(o);i+=`- **${r}**: ${o.description||o.command}
6
6
  `}),i+=`
7
- `}),i}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"}}function M(n={}){const{enabled:e=!1,provider:t="browser",apiUrl:i="",apiHeaders:r={},language:a="en",customDictionary:l=[],ignoreAllCaps:o=!0,ignoreNumbers:m=!0}=n;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:a}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":i?console.log("[Spellcheck] Using API:",i):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:u=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:u=>(console.log("[Spellcheck] Add to dictionary:",u),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function b(n={}){const{uploadUrl:e="",libraryUrl:t="",maxFileSize:i=10*1024*1024,allowedTypes:r=["image/jpeg","image/png","image/gif","image/webp"],headers:a={},withCredentials:l=!1,chunkSize:o=1024*1024,enableChunking:m=!0,onProgress:u,onError:d,onSuccess:v}=n;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:i,allowedTypes:r}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:s=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async s=>{if(console.log("[Media] Insert image command (not implemented)",s),!s)return console.log("[Media] No file provided - should open picker"),null;if(!r.includes(s.type)){const h=new Error(`File type ${s.type} not allowed`);return d?.(h),null}if(s.size>i){const h=new Error(`File size ${s.size} exceeds max ${i}`);return d?.(h),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async s=>(console.log("[Media] Upload media (not implemented)",{name:s.name,size:s.size,type:s.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}exports.Editor=f;exports.EditorState=c;exports.KeyboardShortcutManager=k;exports.PluginManager=y;exports.PluginRuntime=g;exports.Schema=p;exports.createMediaPlugin=b;exports.createPluginRuntime=S;exports.createSpellcheckPlugin=M;
7
+ `}),i}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"}}function w(a={}){const{enabled:e=!1,provider:t="browser",apiUrl:i="",apiHeaders:n={},language:s="en",customDictionary:o=[],ignoreAllCaps:r=!0,ignoreNumbers:c=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:s}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":i?console.log("[Spellcheck] Using API:",i):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:h=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:h=>(console.log("[Spellcheck] Add to dictionary:",h),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function x(a={}){const{uploadUrl:e="",libraryUrl:t="",maxFileSize:i=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:s={},withCredentials:o=!1,chunkSize:r=1024*1024,enableChunking:c=!0,onProgress:h,onError:u,onSuccess:A}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:i,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:d=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async d=>{if(console.log("[Media] Insert image command (not implemented)",d),!d)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(d.type)){const g=new Error(`File type ${d.type} not allowed`);return u==null||u(g),null}if(d.size>i){const g=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(g),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async d=>(console.log("[Media] Upload media (not implemented)",{name:d.name,size:d.size,type:d.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class p{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new p(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new p(this.doc,e)}update(e,t){return new p(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class m{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");if(e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height),e.innerHTML=`
8
+ <div class="editora-dialog-container">
9
+ <div class="editora-dialog-header">
10
+ <h3>${this.config.title}</h3>
11
+ <button class="editora-dialog-close" aria-label="Close">&times;</button>
12
+ </div>
13
+ <div class="editora-dialog-body">
14
+ ${typeof this.config.content=="string"?this.config.content:""}
15
+ </div>
16
+ <div class="editora-dialog-footer">
17
+ <button type="button" class="editora-btn editora-btn-cancel">Cancel</button>
18
+ <button type="button" class="editora-btn editora-btn-primary">OK</button>
19
+ </div>
20
+ </div>
21
+ `,typeof this.config.content!="string"){const t=e.querySelector(".editora-dialog-body");t&&(t.innerHTML="",t.appendChild(this.config.content))}return e}attachEventListeners(){const e=this.element.querySelector(".editora-dialog-close");e==null||e.addEventListener("click",()=>this.close());const t=this.element.querySelector(".editora-btn-cancel");t==null||t.addEventListener("click",()=>{var n,s;(s=(n=this.config).onCancel)==null||s.call(n),this.close()});const i=this.element.querySelector(".editora-btn-primary");i==null||i.addEventListener("click",()=>this.handleSubmit()),this.config.closeOnEscape&&this.element.addEventListener("cancel",n=>{n.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",n=>{const s=this.element.getBoundingClientRect();(n.clientX<s.left||n.clientX>s.right||n.clientY<s.top||n.clientY>s.bottom)&&this.close()})}handleSubmit(){var t,i,n,s;const e=this.element.querySelector("form");if(e){const o=new FormData(e);(i=(t=this.config).onSubmit)==null||i.call(t,o)}else{const o=this.element.querySelectorAll("input, select, textarea"),r=new FormData;o.forEach(c=>{c.name&&r.append(c.name,c.value)}),(s=(n=this.config).onSubmit)==null||s.call(n,r)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class C{constructor(e){this.isOpen=!1,this.config=e,this.selectedValue=e.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("div");e.className="editora-dropdown",this.config.width&&(e.style.width=this.config.width);const t=this.config.options.find(n=>n.value===this.selectedValue),i=(t==null?void 0:t.label)||this.config.placeholder||"Select...";return e.innerHTML=`
22
+ <button class="editora-dropdown-toggle" type="button">
23
+ <span class="editora-dropdown-label">${i}</span>
24
+ <span class="editora-dropdown-arrow">▼</span>
25
+ </button>
26
+ <div class="editora-dropdown-menu" style="display: none;">
27
+ ${this.config.options.map(n=>`
28
+ <div class="editora-dropdown-item" data-value="${n.value}">
29
+ ${n.icon?`<span class="editora-dropdown-icon">${n.icon}</span>`:""}
30
+ <span>${n.label}</span>
31
+ </div>
32
+ `).join("")}
33
+ </div>
34
+ `,e}attachEventListeners(){const e=this.element.querySelector(".editora-dropdown-toggle"),t=this.element.querySelector(".editora-dropdown-menu");e.addEventListener("click",n=>{n.stopPropagation(),this.isOpen=!this.isOpen,t.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(n=>{n.addEventListener("click",()=>{var o,r;const s=n.getAttribute("data-value");s&&(this.setValue(s),(r=(o=this.config).onChange)==null||r.call(o,s),this.close())})}),document.addEventListener("click",n=>{this.element.contains(n.target)||this.close()})}setValue(e){this.selectedValue=e;const t=this.config.options.find(n=>n.value===e),i=this.element.querySelector(".editora-dropdown-label");i&&t&&(i.textContent=t.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const e=this.element.querySelector(".editora-dropdown-menu");e&&(e.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class k{constructor(e){this.defaultPresets=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC"],this.config={presetColors:this.defaultPresets,...e},this.selectedColor=e.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){var t;const e=document.createElement("div");return e.className="editora-color-picker",e.innerHTML=`
35
+ <div class="editora-color-picker-input">
36
+ <input type="color" value="${this.selectedColor||"#000000"}" />
37
+ <input type="text" value="${this.selectedColor||"#000000"}" placeholder="#000000" />
38
+ </div>
39
+ <div class="editora-color-picker-presets">
40
+ ${(t=this.config.presetColors)==null?void 0:t.map(i=>`
41
+ <button
42
+ class="editora-color-preset"
43
+ style="background-color: ${i};"
44
+ data-color="${i}"
45
+ title="${i}"
46
+ ></button>
47
+ `).join("")}
48
+ </div>
49
+ `,e}attachEventListeners(){const e=this.element.querySelector('input[type="color"]'),t=this.element.querySelector('input[type="text"]');e.addEventListener("input",n=>{var o,r;const s=n.target.value;t.value=s,this.selectedColor=s,(r=(o=this.config).onChange)==null||r.call(o,s)}),t.addEventListener("input",n=>{var o,r;const s=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(s)&&(e.value=s,this.selectedColor=s,(r=(o=this.config).onChange)==null||r.call(o,s))}),this.element.querySelectorAll(".editora-color-preset").forEach(n=>{n.addEventListener("click",()=>{var o,r;const s=n.getAttribute("data-color");s&&(e.value=s,t.value=s,this.selectedColor=s,(r=(o=this.config).onChange)==null||r.call(o,s))})})}getValue(){return this.selectedColor}setValue(e){this.selectedColor=e;const t=this.element.querySelector('input[type="color"]'),i=this.element.querySelector('input[type="text"]');t&&(t.value=e),i&&(i.value=e)}getElement(){return this.element}destroy(){this.element.remove()}}class M{constructor(e){const{initialUrl:t="",initialText:i="",onSubmit:n,onCancel:s}=e;this.dialog=new m({title:"Insert/Edit Link",content:this.createFormHTML(t,i),onSubmit:o=>{const r=(o.get("url")||"").trim(),c=(o.get("text")||"").trim(),h=o.get("openInNewTab")==="on";if(!r){alert("Please enter a URL");return}n({url:r,text:c,openInNewTab:h}),this.dialog.close()},onCancel:()=>{s==null||s(),this.dialog.close()},width:"500px"})}createFormHTML(e,t){return`
50
+ <form class="link-dialog-form">
51
+ <div class="form-group">
52
+ <label for="link-url">URL</label>
53
+ <input
54
+ type="url"
55
+ id="link-url"
56
+ name="url"
57
+ placeholder="https://example.com"
58
+ value="${this.escapeHtml(e)}"
59
+ required
60
+ autofocus
61
+ />
62
+ <small>Enter the web address (URL) for the link</small>
63
+ </div>
64
+
65
+ <div class="form-group">
66
+ <label for="link-text">Link Text</label>
67
+ <input
68
+ type="text"
69
+ id="link-text"
70
+ name="text"
71
+ placeholder="Click here"
72
+ value="${this.escapeHtml(t)}"
73
+ />
74
+ <small>Text to display for the link (leave empty to use URL)</small>
75
+ </div>
76
+
77
+ <div class="form-group">
78
+ <label class="checkbox-label">
79
+ <input
80
+ type="checkbox"
81
+ name="openInNewTab"
82
+ id="link-new-tab"
83
+ />
84
+ <span>Open link in new tab</span>
85
+ </label>
86
+ </div>
87
+
88
+ <div class="form-actions">
89
+ <button type="button" class="btn btn-secondary" data-action="cancel">
90
+ Cancel
91
+ </button>
92
+ <button type="submit" class="btn btn-primary">
93
+ Insert Link
94
+ </button>
95
+ </div>
96
+ </form>
97
+ `}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class L{constructor(e){const{onSubmit:t,onCancel:i}=e;this.dialog=new m({title:"Insert Table",content:this.createFormHTML(),onSubmit:n=>{const s=parseInt(n.get("rows"),10),o=parseInt(n.get("cols"),10),r=n.get("headerRow")==="on";if(s<1||s>100){alert("Please enter a valid number of rows (1-100)");return}if(o<1||o>20){alert("Please enter a valid number of columns (1-20)");return}t({rows:s,cols:o,headerRow:r}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"400px"})}createFormHTML(){return`
98
+ <form class="table-dialog-form">
99
+ <div class="form-group">
100
+ <label for="table-rows">Rows</label>
101
+ <input
102
+ type="number"
103
+ id="table-rows"
104
+ name="rows"
105
+ min="1"
106
+ max="100"
107
+ value="3"
108
+ required
109
+ autofocus
110
+ />
111
+ <small>Number of rows (1-100)</small>
112
+ </div>
113
+
114
+ <div class="form-group">
115
+ <label for="table-cols">Columns</label>
116
+ <input
117
+ type="number"
118
+ id="table-cols"
119
+ name="cols"
120
+ min="1"
121
+ max="20"
122
+ value="3"
123
+ required
124
+ />
125
+ <small>Number of columns (1-20)</small>
126
+ </div>
127
+
128
+ <div class="form-group">
129
+ <label class="checkbox-label">
130
+ <input
131
+ type="checkbox"
132
+ name="headerRow"
133
+ id="table-header"
134
+ checked
135
+ />
136
+ <span>Include header row</span>
137
+ </label>
138
+ </div>
139
+
140
+ <div class="table-preview">
141
+ <strong>Preview:</strong>
142
+ <div id="table-preview-content" style="margin-top: 8px; font-size: 12px; color: #666;">
143
+ 3 rows × 3 columns with header
144
+ </div>
145
+ </div>
146
+
147
+ <div class="form-actions">
148
+ <button type="button" class="btn btn-secondary" data-action="cancel">
149
+ Cancel
150
+ </button>
151
+ <button type="submit" class="btn btn-primary">
152
+ Insert Table
153
+ </button>
154
+ </div>
155
+ </form>
156
+ `}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const e=document.querySelector(".table-dialog-form");if(!e)return;const t=e.querySelector("#table-rows"),i=e.querySelector("#table-cols"),n=e.querySelector("#table-header"),s=e.querySelector("#table-preview-content"),o=()=>{const r=parseInt((t==null?void 0:t.value)||"3",10),c=parseInt((i==null?void 0:i.value)||"3",10),h=n==null?void 0:n.checked;s&&(s.textContent=`${r} rows × ${c} columns${h?" with header":""}`)};t==null||t.addEventListener("input",o),i==null||i.addEventListener("input",o),n==null||n.addEventListener("change",o)}}class T{constructor(e){this.config=e;const{onSubmit:t,onCancel:i}=e;this.dialog=new m({title:"Insert Image",content:this.createFormHTML(),onSubmit:n=>{const s=(n.get("src")||"").trim(),o=(n.get("alt")||"").trim(),r=(n.get("width")||"").trim(),c=(n.get("height")||"").trim();if(!s){alert("Please enter an image URL or upload an image");return}t({src:s,alt:o,width:r||void 0,height:c||void 0}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"500px"})}createFormHTML(){return`
157
+ <form class="image-dialog-form">
158
+ ${this.config.allowUpload?`
159
+ <div class="form-group">
160
+ <label for="image-upload">Upload Image</label>
161
+ <input
162
+ type="file"
163
+ id="image-upload"
164
+ accept="image/*"
165
+ />
166
+ <small>Or upload an image from your computer</small>
167
+ </div>
168
+ <div class="form-divider">OR</div>
169
+ `:""}
170
+
171
+ <div class="form-group">
172
+ <label for="image-src">Image URL</label>
173
+ <input
174
+ type="url"
175
+ id="image-src"
176
+ name="src"
177
+ placeholder="https://example.com/image.jpg"
178
+ ${this.config.allowUpload?"":"required autofocus"}
179
+ />
180
+ <small>Enter the web address (URL) of the image</small>
181
+ </div>
182
+
183
+ <div class="form-group">
184
+ <label for="image-alt">Alt Text</label>
185
+ <input
186
+ type="text"
187
+ id="image-alt"
188
+ name="alt"
189
+ placeholder="Description of the image"
190
+ />
191
+ <small>Alternative text for accessibility (recommended)</small>
192
+ </div>
193
+
194
+ <div class="form-row">
195
+ <div class="form-group">
196
+ <label for="image-width">Width</label>
197
+ <input
198
+ type="text"
199
+ id="image-width"
200
+ name="width"
201
+ placeholder="auto"
202
+ />
203
+ </div>
204
+
205
+ <div class="form-group">
206
+ <label for="image-height">Height</label>
207
+ <input
208
+ type="text"
209
+ id="image-height"
210
+ name="height"
211
+ placeholder="auto"
212
+ />
213
+ </div>
214
+ </div>
215
+
216
+ <div class="image-preview" id="image-preview" style="display: none;">
217
+ <strong>Preview:</strong>
218
+ <img id="preview-img" style="max-width: 100%; max-height: 200px; margin-top: 8px;" />
219
+ </div>
220
+
221
+ <div class="form-actions">
222
+ <button type="button" class="btn btn-secondary" data-action="cancel">
223
+ Cancel
224
+ </button>
225
+ <button type="submit" class="btn btn-primary">
226
+ Insert Image
227
+ </button>
228
+ </div>
229
+ </form>
230
+ `}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-src"),i=e.querySelector("#image-preview"),n=e.querySelector("#preview-img");t==null||t.addEventListener("input",()=>{const s=t.value.trim();s&&this.isValidImageUrl(s)?(n.src=s,i.style.display="block",n.onerror=()=>{i.style.display="none"}):i.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-upload"),i=e.querySelector("#image-src");t==null||t.addEventListener("change",async n=>{var r;const s=(r=n.target.files)==null?void 0:r[0];if(!s)return;const o=new FileReader;o.onload=c=>{var u;const h=(u=c.target)==null?void 0:u.result;i.value=h,i.dispatchEvent(new Event("input"))},o.readAsDataURL(s)})}isValidImageUrl(e){try{return new URL(e),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(e)||e.startsWith("data:image/")}catch(t){return!1}}}class D{constructor(e){this.onSubmit=e.onSubmit;const t=this.createContent();this.dialog=new m({title:"Insert Math Equation",content:t,buttons:[{label:"Cancel",onClick:()=>this.dialog.close()},{label:"Insert",onClick:()=>this.handleSubmit(),primary:!0}]}),this.latexInput=t.querySelector("#math-latex"),this.previewDiv=t.querySelector("#math-preview"),this.displayTypeSelect=t.querySelector("#math-display-type"),this.latexInput.addEventListener("input",()=>this.updatePreview())}createContent(){const e=document.createElement("div");return e.className="math-dialog-content",e.style.minWidth="500px",e.innerHTML=`
231
+ <style>
232
+ .math-dialog-content {
233
+ display: flex;
234
+ flex-direction: column;
235
+ gap: 1rem;
236
+ }
237
+ .math-form-group {
238
+ display: flex;
239
+ flex-direction: column;
240
+ gap: 0.5rem;
241
+ }
242
+ .math-form-group label {
243
+ font-weight: 500;
244
+ color: #333;
245
+ }
246
+ .math-latex-input {
247
+ width: 100%;
248
+ min-height: 80px;
249
+ padding: 0.5rem;
250
+ border: 1px solid #ddd;
251
+ border-radius: 4px;
252
+ font-family: 'Courier New', monospace;
253
+ font-size: 14px;
254
+ resize: vertical;
255
+ }
256
+ .math-preview {
257
+ padding: 1rem;
258
+ background: #f9f9f9;
259
+ border: 1px solid #ddd;
260
+ border-radius: 4px;
261
+ min-height: 60px;
262
+ font-size: 18px;
263
+ text-align: center;
264
+ }
265
+ .math-preview:empty::before {
266
+ content: 'Preview will appear here...';
267
+ color: #999;
268
+ font-style: italic;
269
+ }
270
+ .math-symbols {
271
+ display: grid;
272
+ grid-template-columns: repeat(8, 1fr);
273
+ gap: 0.5rem;
274
+ padding: 0.5rem;
275
+ background: #f5f5f5;
276
+ border-radius: 4px;
277
+ }
278
+ .math-symbol-btn {
279
+ padding: 0.5rem;
280
+ border: 1px solid #ddd;
281
+ background: white;
282
+ border-radius: 4px;
283
+ cursor: pointer;
284
+ font-size: 18px;
285
+ transition: all 0.2s;
286
+ }
287
+ .math-symbol-btn:hover {
288
+ background: #e3f2fd;
289
+ border-color: #2196f3;
290
+ }
291
+ .math-display-select {
292
+ padding: 0.5rem;
293
+ border: 1px solid #ddd;
294
+ border-radius: 4px;
295
+ font-size: 14px;
296
+ }
297
+ </style>
298
+
299
+ <div class="math-form-group">
300
+ <label for="math-latex">LaTeX Expression:</label>
301
+ <textarea
302
+ id="math-latex"
303
+ class="math-latex-input"
304
+ placeholder="Enter LaTeX (e.g., x^2 + y^2 = r^2)"
305
+ ></textarea>
306
+ </div>
307
+
308
+ <div class="math-form-group">
309
+ <label>Common Symbols:</label>
310
+ <div class="math-symbols">
311
+ <button class="math-symbol-btn" data-symbol="\\frac{a}{b}" title="Fraction">a/b</button>
312
+ <button class="math-symbol-btn" data-symbol="x^{2}" title="Superscript">x²</button>
313
+ <button class="math-symbol-btn" data-symbol="x_{i}" title="Subscript">xᵢ</button>
314
+ <button class="math-symbol-btn" data-symbol="\\sqrt{x}" title="Square root">√x</button>
315
+ <button class="math-symbol-btn" data-symbol="\\sum" title="Sum">∑</button>
316
+ <button class="math-symbol-btn" data-symbol="\\int" title="Integral">∫</button>
317
+ <button class="math-symbol-btn" data-symbol="\\pi" title="Pi">π</button>
318
+ <button class="math-symbol-btn" data-symbol="\\alpha" title="Alpha">α</button>
319
+ <button class="math-symbol-btn" data-symbol="\\beta" title="Beta">β</button>
320
+ <button class="math-symbol-btn" data-symbol="\\gamma" title="Gamma">γ</button>
321
+ <button class="math-symbol-btn" data-symbol="\\theta" title="Theta">θ</button>
322
+ <button class="math-symbol-btn" data-symbol="\\lambda" title="Lambda">λ</button>
323
+ <button class="math-symbol-btn" data-symbol="\\infty" title="Infinity">∞</button>
324
+ <button class="math-symbol-btn" data-symbol="\\leq" title="Less or equal">≤</button>
325
+ <button class="math-symbol-btn" data-symbol="\\geq" title="Greater or equal">≥</button>
326
+ <button class="math-symbol-btn" data-symbol="\\neq" title="Not equal">≠</button>
327
+ </div>
328
+ </div>
329
+
330
+ <div class="math-form-group">
331
+ <label for="math-preview">Preview:</label>
332
+ <div id="math-preview" class="math-preview"></div>
333
+ </div>
334
+
335
+ <div class="math-form-group">
336
+ <label for="math-display-type">Display Type:</label>
337
+ <select id="math-display-type" class="math-display-select">
338
+ <option value="inline">Inline (within text)</option>
339
+ <option value="block">Block (centered, new line)</option>
340
+ </select>
341
+ </div>
342
+ `,e.querySelectorAll(".math-symbol-btn").forEach(i=>{i.addEventListener("click",n=>{n.preventDefault();const s=i.getAttribute("data-symbol");if(s&&this.latexInput){const o=this.latexInput.selectionStart,r=this.latexInput.selectionEnd,c=this.latexInput.value;this.latexInput.value=c.substring(0,o)+s+c.substring(r),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=o+s.length,this.updatePreview()}})}),e}updatePreview(){const e=this.latexInput.value.trim();if(!e){this.previewDiv.textContent="";return}let t=e.replace(/\\frac\{([^}]+)\}\{([^}]+)\}/g,"($1)/($2)").replace(/\^\{([^}]+)\}/g,"^$1").replace(/\_\{([^}]+)\}/g,"_$1").replace(/\\sqrt\{([^}]+)\}/g,"√($1)").replace(/\\sum/g,"∑").replace(/\\int/g,"∫").replace(/\\pi/g,"π").replace(/\\alpha/g,"α").replace(/\\beta/g,"β").replace(/\\gamma/g,"γ").replace(/\\theta/g,"θ").replace(/\\lambda/g,"λ").replace(/\\infty/g,"∞").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠");this.previewDiv.textContent=t}handleSubmit(){const e=this.latexInput.value.trim();if(!e){alert("Please enter a LaTeX expression.");return}const t=this.displayTypeSelect.value;this.onSubmit({latex:e,display:t}),this.dialog.close()}show(){this.dialog.show(),this.latexInput.value="",this.previewDiv.textContent="",this.displayTypeSelect.value="inline",setTimeout(()=>this.latexInput.focus(),100)}close(){this.dialog.close()}}class I{constructor(e){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new m({title:"Insert Special Character",content:t,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=t.querySelector("#char-search"),this.categorySelect=t.querySelector("#char-category"),this.charactersGrid=t.querySelector("#char-grid"),this.searchInput.addEventListener("input",()=>this.filterCharacters()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const e=document.createElement("div");return e.className="character-dialog-content",e.style.minWidth="500px",e.innerHTML=`
343
+ <style>
344
+ .character-dialog-content {
345
+ display: flex;
346
+ flex-direction: column;
347
+ gap: 1rem;
348
+ }
349
+ .char-controls {
350
+ display: flex;
351
+ gap: 0.5rem;
352
+ }
353
+ .char-search, .char-category {
354
+ padding: 0.5rem;
355
+ border: 1px solid #ddd;
356
+ border-radius: 4px;
357
+ font-size: 14px;
358
+ }
359
+ .char-search {
360
+ flex: 1;
361
+ }
362
+ .char-category {
363
+ min-width: 150px;
364
+ }
365
+ .char-grid {
366
+ display: grid;
367
+ grid-template-columns: repeat(10, 1fr);
368
+ gap: 0.5rem;
369
+ max-height: 300px;
370
+ overflow-y: auto;
371
+ padding: 1rem;
372
+ background: #f9f9f9;
373
+ border: 1px solid #ddd;
374
+ border-radius: 4px;
375
+ }
376
+ .char-button {
377
+ aspect-ratio: 1;
378
+ display: flex;
379
+ align-items: center;
380
+ justify-content: center;
381
+ padding: 0.5rem;
382
+ border: 1px solid #ddd;
383
+ background: white;
384
+ border-radius: 4px;
385
+ cursor: pointer;
386
+ font-size: 20px;
387
+ transition: all 0.2s;
388
+ }
389
+ .char-button:hover {
390
+ background: #e3f2fd;
391
+ border-color: #2196f3;
392
+ transform: scale(1.1);
393
+ }
394
+ .char-info {
395
+ padding: 0.5rem;
396
+ background: #f5f5f5;
397
+ border-radius: 4px;
398
+ font-size: 12px;
399
+ color: #666;
400
+ text-align: center;
401
+ }
402
+ </style>
403
+
404
+ <div class="char-controls">
405
+ <input
406
+ type="text"
407
+ id="char-search"
408
+ class="char-search"
409
+ placeholder="Search characters..."
410
+ />
411
+ <select id="char-category" class="char-category">
412
+ <option value="all">All Categories</option>
413
+ <option value="common">Common Symbols</option>
414
+ <option value="arrows">Arrows</option>
415
+ <option value="currency">Currency</option>
416
+ <option value="math">Mathematics</option>
417
+ <option value="greek">Greek Letters</option>
418
+ <option value="punctuation">Punctuation</option>
419
+ <option value="superscript">Superscript</option>
420
+ <option value="subscript">Subscript</option>
421
+ </select>
422
+ </div>
423
+
424
+ <div id="char-grid" class="char-grid"></div>
425
+
426
+ <div class="char-info">
427
+ Click any character to insert it into your document.
428
+ </div>
429
+ `,e}updateGrid(){const e=this.categorySelect.value;this.charactersGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.characters).flat():t=this.characters[e]||[],t.forEach(i=>{const n=document.createElement("button");n.className="char-button",n.textContent=i,n.title=`Insert ${i} (U+${i.charCodeAt(0).toString(16).toUpperCase()})`,n.addEventListener("click",s=>{s.preventDefault(),this.handleSelect(i)}),this.charactersGrid.appendChild(n)})}filterCharacters(){const e=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(i=>{const n=i.textContent||"",s=`u+${n.charCodeAt(0).toString(16)}`,o=!e||n.includes(e)||s.includes(e);i.style.display=o?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="all",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class F{constructor(e){this.emojis={popular:["😀","😃","😄","😁","😊","😍","🤩","😘","😗","😚","😙","🙂","🤗","🤔","🤨","😐","😑","😶","🙄","😏","👍","👎","👌","✌️","🤞","🤝","👏","🙌","👋","🤚","✋","🖐️","🖖","👊","✊","🤛","🤜","💪"],smileys:["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔"],emotions:["😳","😞","😟","😠","😡","🤬","😔","😕","🙁","😬","🥺","😣","😖","😫","😩","🥱","😤","😮","😱","😨","😰","😥","😢","😭","😪","😓","🤤","😴","😷","🤒"],gestures:["👍","👎","👌","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝️","👋","🤚","✋","🖐️","🖖","👏","🙌","👐","🤲","🤝","🙏","✍️","💅","🤳","💪","🦾","🦿"],people:["👶","👧","🧒","👦","👩","🧑","👨","👵","🧓","👴","👲","👳","🧕","👮","👷","💂","🕵️","👩‍⚕️","👨‍⚕️","👩‍🎓","👨‍🎓","👩‍🏫","👨‍🏫","👩‍⚖️","👨‍⚖️","👩‍🌾","👨‍🌾","👩‍🍳","👨‍🍳","👩‍🔧"],animals:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🙈","🙉","🙊","🐔","🐧","🐦","🐤","🐣","🐥","🦆","🦅","🦉","🦇","🐺","🐗"],nature:["🌵","🎄","🌲","🌳","🌴","🌱","🌿","☘️","🍀","🎍","🎋","🍃","🍂","🍁","🍄","🌾","💐","🌷","🌹","🥀","🌺","🌸","🌼","🌻","🌞","🌝","🌛","🌜","⭐","🌟"],food:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🌽","🥕","🧄","🧅","🥔","🍠","🥐"],objects:["⌚","📱","💻","⌨️","🖥️","🖨️","🖱️","🕹️","💾","💿","📀","📷","📹","🎥","📞","☎️","📟","📠","📺","📻","🎙️","🎚️","🎛️","🧭","⏱️","⏰","📡","🔋","🔌","💡"],symbols:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","✨","💫","⭐","🌟","✔️","✅","❌","❎","➕","➖","✖️","➗"],activities:["⚽","🏀","🏈","⚾","🥎","🎾","🏐","🏉","🥏","🎱","🪀","🏓","🏸","🏒","🏑","🥍","🏏","🪃","🥅","⛳","🪁","🏹","🎣","🤿","🥊","🥋","🎽","🛹","🛼","🛷"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new m({title:"Insert Emoji",content:t,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=t.querySelector("#emoji-search"),this.categorySelect=t.querySelector("#emoji-category"),this.emojisGrid=t.querySelector("#emoji-grid"),this.searchInput.addEventListener("input",()=>this.filterEmojis()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const e=document.createElement("div");return e.className="emoji-dialog-content",e.style.minWidth="500px",e.innerHTML=`
430
+ <style>
431
+ .emoji-dialog-content {
432
+ display: flex;
433
+ flex-direction: column;
434
+ gap: 1rem;
435
+ }
436
+ .emoji-controls {
437
+ display: flex;
438
+ gap: 0.5rem;
439
+ }
440
+ .emoji-search, .emoji-category {
441
+ padding: 0.5rem;
442
+ border: 1px solid #ddd;
443
+ border-radius: 4px;
444
+ font-size: 14px;
445
+ }
446
+ .emoji-search {
447
+ flex: 1;
448
+ }
449
+ .emoji-category {
450
+ min-width: 150px;
451
+ }
452
+ .emoji-grid {
453
+ display: grid;
454
+ grid-template-columns: repeat(10, 1fr);
455
+ gap: 0.5rem;
456
+ max-height: 350px;
457
+ overflow-y: auto;
458
+ padding: 1rem;
459
+ background: #f9f9f9;
460
+ border: 1px solid #ddd;
461
+ border-radius: 4px;
462
+ }
463
+ .emoji-button {
464
+ aspect-ratio: 1;
465
+ display: flex;
466
+ align-items: center;
467
+ justify-content: center;
468
+ padding: 0.5rem;
469
+ border: 1px solid #ddd;
470
+ background: white;
471
+ border-radius: 4px;
472
+ cursor: pointer;
473
+ font-size: 24px;
474
+ transition: all 0.2s;
475
+ }
476
+ .emoji-button:hover {
477
+ background: #fff3e0;
478
+ border-color: #ff9800;
479
+ transform: scale(1.15);
480
+ }
481
+ .emoji-info {
482
+ padding: 0.5rem;
483
+ background: #f5f5f5;
484
+ border-radius: 4px;
485
+ font-size: 12px;
486
+ color: #666;
487
+ text-align: center;
488
+ }
489
+ </style>
490
+
491
+ <div class="emoji-controls">
492
+ <input
493
+ type="text"
494
+ id="emoji-search"
495
+ class="emoji-search"
496
+ placeholder="Search emojis..."
497
+ />
498
+ <select id="emoji-category" class="emoji-category">
499
+ <option value="all">All Emojis</option>
500
+ <option value="popular">Popular</option>
501
+ <option value="smileys">Smileys & Faces</option>
502
+ <option value="emotions">Emotions</option>
503
+ <option value="gestures">Gestures & Hands</option>
504
+ <option value="people">People</option>
505
+ <option value="animals">Animals</option>
506
+ <option value="nature">Nature</option>
507
+ <option value="food">Food & Drink</option>
508
+ <option value="objects">Objects</option>
509
+ <option value="symbols">Symbols</option>
510
+ <option value="activities">Activities & Sports</option>
511
+ </select>
512
+ </div>
513
+
514
+ <div id="emoji-grid" class="emoji-grid"></div>
515
+
516
+ <div class="emoji-info">
517
+ Click any emoji to insert it into your document.
518
+ </div>
519
+ `,e}updateGrid(){const e=this.categorySelect.value;this.emojisGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.emojis).flat():t=this.emojis[e]||[],t.forEach(i=>{const n=document.createElement("button");n.className="emoji-button",n.textContent=i,n.title=`Insert ${i}`,n.addEventListener("click",s=>{s.preventDefault(),this.handleSelect(i)}),this.emojisGrid.appendChild(n)})}filterEmojis(){const e=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(i=>{const n=i.textContent||"",s=!e||n.includes(e);i.style.display=s?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="popular",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class b{constructor(e={}){this.changeListeners=[],this.options=e,this.engine=new l.EditorEngine({content:e.content,plugins:e.plugins||[],readonly:e.readonly}),e.onChange&&this.onChange(e.onChange),this.engine.on("change",()=>{const t=this.getHTML();this.changeListeners.forEach(i=>i(t))})}mount(e,t){this.contentElement=e,this.toolbarElement=t,this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.className="rte-content",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.options.toolbar!==!1&&this.toolbarElement&&(this.toolbar=new l.ToolbarRenderer({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((i,n)=>{this.execCommand(i,n)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const i=this.getHTML();this.changeListeners.forEach(n=>n(i))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setHTML(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,t){const i=this.engine.execCommand(e,t);return this.toolbar,i}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}onChange(e){return this.changeListeners.push(e),()=>{const t=this.changeListeners.indexOf(e);t>-1&&this.changeListeners.splice(t,1)}}registerCommand(e,t){if(typeof window!="undefined"){const i=window.__editorCommands||new Map;i.set(e,t),window.__editorCommands=i}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var e;return{getHTML:()=>this.getHTML(),setHTML:t=>this.setHTML(t),execCommand:(t,i)=>this.execCommand(t,i),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(t,i)=>this.registerCommand(t,i),onChange:t=>this.onChange(t),getState:()=>this.getState(),toolbar:{items:((e=this.options.plugins)==null?void 0:e.flatMap(t=>t.toolbar||[]))||[]}}}destroy(){var e;this.engine.destroy(),(e=this.toolbar)==null||e.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function P(a){return new b(a)}class y{constructor(e){this.options=e,this.containerElement=e.element;const t=this.resolvePlugins(e.plugins);this.engine=new l.EditorEngine({content:e.content,plugins:t,readonly:e.readonly}),this.initializeDOM()}resolvePlugins(e){return e?typeof e=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):e:[]}initializeDOM(){this.containerElement.innerHTML="",this.containerElement.classList.add("editora-editor"),this.options.enableToolbar!==!1&&this.options.toolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.containerElement.appendChild(this.toolbarElement),this.toolbar=new l.ToolbarRenderer({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((e,t)=>{this.execCommand(e,t)}),this.toolbar.render(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content",this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.containerElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.containerElement.dispatchEvent(new CustomEvent("change",{detail:{html:this.getContent()}}))})}getContent(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setContent(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,t){return this.engine.execCommand(e,t)}focus(){var e;(e=this.contentElement)==null||e.focus()}on(e,t){const i=n=>{t(n.detail)};return this.containerElement.addEventListener(e,i),()=>{this.containerElement.removeEventListener(e,i)}}destroy(){var e;this.engine.destroy(),(e=this.toolbar)==null||e.destroy(),this.containerElement.innerHTML=""}}function j(a){return new y(a)}function q(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",l.RichTextEditorElement)}exports.CommandRegistry=l.CommandRegistry;exports.ConfigResolver=l.ConfigResolver;exports.EditorEngine=l.EditorEngine;exports.EditorState=l.EditorState;exports.FloatingToolbar=l.FloatingToolbar;exports.PluginLoader=l.PluginLoader;exports.PluginManager=l.PluginManager;exports.RichTextEditorElement=l.RichTextEditorElement;exports.Schema=l.Schema;exports.StatusBar=l.StatusBar;exports.ToolbarRenderer=l.ToolbarRenderer;exports.CharacterDialog=I;exports.ColorPicker=k;exports.Dialog=m;exports.DocumentModel=p;exports.Dropdown=C;exports.Editor=v;exports.EmojiDialog=F;exports.ImageDialog=T;exports.KeyboardShortcutManager=S;exports.LinkDialog=M;exports.MathDialog=D;exports.PluginRuntime=f;exports.ReactAdapter=b;exports.TableDialog=L;exports.VanillaAdapter=y;exports.createEditor=j;exports.createMediaPlugin=x;exports.createPluginRuntime=E;exports.createReactAdapter=P;exports.createSpellcheckPlugin=w;exports.initWebComponent=q;
520
+ //# sourceMappingURL=index.cjs.js.map