@editora/core 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +9 -0
  2. package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs +475 -0
  3. package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +1 -0
  4. package/dist/AnchorPlugin.native-7es9PVZ9.mjs +340 -0
  5. package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +1 -0
  6. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +449 -0
  7. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +1 -0
  8. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs +48 -0
  9. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +1 -0
  10. package/dist/BoldPlugin.native-BAzzoqU5.mjs +45 -0
  11. package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +1 -0
  12. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs +79 -0
  13. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +1 -0
  14. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +153 -0
  15. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +1 -0
  16. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +27 -0
  17. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +1 -0
  18. package/dist/CodePlugin.native-DD9xFIid.mjs +1679 -0
  19. package/dist/CodePlugin.native-DD9xFIid.mjs.map +1 -0
  20. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +326 -0
  21. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +1 -0
  22. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +473 -0
  23. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +1 -0
  24. package/dist/DirectionPlugin.native-Be7wCzkI.mjs +59 -0
  25. package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +1 -0
  26. package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs +116 -0
  27. package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +1 -0
  28. package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs +461 -0
  29. package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +1 -0
  30. package/dist/EmojisPlugin.native-D6mJSnSR.mjs +1033 -0
  31. package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +1 -0
  32. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +106 -0
  33. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +1 -0
  34. package/dist/FontSizePlugin.native-DkLMLPue.mjs +186 -0
  35. package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +1 -0
  36. package/dist/FootnotePlugin.native-BciVc9W6.mjs +128 -0
  37. package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +1 -0
  38. package/dist/FullscreenPlugin.native-ChXyxeNw.mjs +77 -0
  39. package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +1 -0
  40. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs +64 -0
  41. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +1 -0
  42. package/dist/HistoryPlugin.native-DoDRifCf.mjs +89 -0
  43. package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +1 -0
  44. package/dist/IndentPlugin.native-CbFugPoi.mjs +133 -0
  45. package/dist/IndentPlugin.native-CbFugPoi.mjs.map +1 -0
  46. package/dist/ItalicPlugin.native-CQjjDyUL.mjs +43 -0
  47. package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +1 -0
  48. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +73 -0
  49. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +1 -0
  50. package/dist/LinkPlugin.native-BdAOV-iu.mjs +206 -0
  51. package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +1 -0
  52. package/dist/ListPlugin.native-CLFU5AUQ.mjs +59 -0
  53. package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +1 -0
  54. package/dist/MathPlugin.native-DE_ii-LA.mjs +182 -0
  55. package/dist/MathPlugin.native-DE_ii-LA.mjs.map +1 -0
  56. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +533 -0
  57. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +1 -0
  58. package/dist/MergeTagPlugin.native-CrxyThyn.mjs +178 -0
  59. package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +1 -0
  60. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +172 -0
  61. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +1 -0
  62. package/dist/PreviewPlugin.native-DBvfpmIv.mjs +322 -0
  63. package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +1 -0
  64. package/dist/PrintPlugin.native-BUpm52VJ.mjs +311 -0
  65. package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +1 -0
  66. package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs +731 -0
  67. package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +1 -0
  68. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +465 -0
  69. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +1 -0
  70. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +43 -0
  71. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +1 -0
  72. package/dist/TablePlugin.native-EEWXn1-s.mjs +491 -0
  73. package/dist/TablePlugin.native-EEWXn1-s.mjs.map +1 -0
  74. package/dist/TemplatePlugin.native-BlSn1c9h.mjs +564 -0
  75. package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +1 -0
  76. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +97 -0
  77. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +1 -0
  78. package/dist/TextColorPlugin.native-D6SmTglm.mjs +432 -0
  79. package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +1 -0
  80. package/dist/UnderlinePlugin.native-QpIcK4L2.mjs +35 -0
  81. package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +1 -0
  82. package/dist/documentManager-irzj9n3V.mjs +37627 -0
  83. package/dist/documentManager-irzj9n3V.mjs.map +1 -0
  84. package/dist/editorContainerHelpers-C7kdWnS0.mjs +27 -0
  85. package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +1 -0
  86. package/dist/editora.min.js +14 -12
  87. package/dist/editora.min.js.map +1 -1
  88. package/dist/editora.umd.js +14 -12
  89. package/dist/editora.umd.js.map +1 -1
  90. package/dist/index-BF5RBhL9.js +4 -0
  91. package/dist/index-BF5RBhL9.js.map +1 -0
  92. package/dist/{index-BS4zT-KN.mjs → index-BPsf460l.mjs} +286 -162
  93. package/dist/index-BPsf460l.mjs.map +1 -0
  94. package/dist/index.cjs.js +3 -3
  95. package/dist/index.cjs.js.map +1 -1
  96. package/dist/index.es-CuicffkQ.mjs +6665 -0
  97. package/dist/index.es-CuicffkQ.mjs.map +1 -0
  98. package/dist/index.esm.js +117 -112
  99. package/dist/index.esm.js.map +1 -1
  100. package/dist/plugin-loader.js +55 -0
  101. package/dist/plugin-loader.js.map +1 -0
  102. package/dist/purify.es-CKpwg8Tk.mjs +471 -0
  103. package/dist/purify.es-CKpwg8Tk.mjs.map +1 -0
  104. package/dist/webcomponent-core.js +1243 -0
  105. package/dist/webcomponent-core.js.map +1 -0
  106. package/dist/webcomponent-core.min.css +1 -0
  107. package/dist/webcomponent-core.min.js +597 -0
  108. package/dist/webcomponent-core.min.js.map +1 -0
  109. package/dist/webcomponent.cjs.js +1 -1
  110. package/dist/webcomponent.esm.js +3 -3
  111. package/dist/webcomponent.js +1286 -0
  112. package/dist/webcomponent.js.map +1 -0
  113. package/dist/webcomponent.min.css +1 -0
  114. package/dist/webcomponent.min.js +337 -334
  115. package/dist/webcomponent.min.js.map +1 -1
  116. package/package.json +16 -4
  117. package/dist/index-BK2lHfHK.js +0 -2
  118. package/dist/index-BK2lHfHK.js.map +0 -1
  119. package/dist/index-BS4zT-KN.mjs.map +0 -1
  120. package/dist/webcomponent.umd.js +0 -4073
  121. package/dist/webcomponent.umd.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ function i() {
2
+ const t = window.getSelection();
3
+ if (!t || !t.rangeCount)
4
+ return null;
5
+ const e = t.getRangeAt(0).startContainer, r = e.nodeType === Node.TEXT_NODE ? e.parentElement : e;
6
+ return o(r);
7
+ }
8
+ function o(t) {
9
+ if (!t) return null;
10
+ if (t.hasAttribute("data-editora-editor"))
11
+ return t;
12
+ let n = t.parentElement;
13
+ for (; n; ) {
14
+ if (n.hasAttribute("data-editora-editor"))
15
+ return n;
16
+ n = n.parentElement;
17
+ }
18
+ return null;
19
+ }
20
+ function a(t) {
21
+ return t ? t.querySelector(".rte-content") : (console.warn("[Editora] Editor container not found"), null);
22
+ }
23
+ export {
24
+ i as f,
25
+ a as g
26
+ };
27
+ //# sourceMappingURL=editorContainerHelpers-C7kdWnS0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorContainerHelpers-C7kdWnS0.mjs","sources":["../../plugins/shared/editorContainerHelpers.ts"],"sourcesContent":["/**\n * Utility functions for plugins to access the editor container in a multi-instance safe way\n * \n * These functions help plugins find their parent editor container and perform scoped DOM queries\n * instead of using global selectors that only work with the first editor instance on a page.\n */\n\n/**\n * Find the editor container from the current selection\n * This is the most reliable way to find the active editor when executing commands\n * \n * @returns The editor container div or null if no selection or editor not found\n */\nexport function findEditorContainerFromSelection(): HTMLDivElement | null {\n const selection = window.getSelection();\n if (!selection || !selection.rangeCount) {\n return null;\n }\n \n const range = selection.getRangeAt(0);\n const node = range.startContainer;\n \n // Get the element (text nodes need their parent)\n const element = node.nodeType === Node.TEXT_NODE \n ? node.parentElement \n : node as HTMLElement;\n \n return findEditorContainer(element);\n}\n\n/**\n * Find the parent editor container for a given element\n * Walks up the DOM tree looking for [data-editora-editor] attribute\n * \n * @param element - Starting element to search from (usually a toolbar, plugin element, etc)\n * @returns The editor container div or null if not found\n */\nexport function findEditorContainer(element: HTMLElement | null): HTMLDivElement | null {\n if (!element) return null;\n \n // If element itself is the editor container, return it\n if (element.hasAttribute('data-editora-editor')) {\n return element as HTMLDivElement;\n }\n \n // Walk up the DOM tree looking for editor container\n let current = element.parentElement;\n while (current) {\n if (current.hasAttribute('data-editora-editor')) {\n return current as HTMLDivElement;\n }\n current = current.parentElement;\n }\n \n return null;\n}\n\n/**\n * Get the content element (.rte-content) for a given editor container\n * Uses scoped selector instead of global document.querySelector\n * \n * @param editorContainer - The editor container element\n * @returns The content element or null if not found\n */\nexport function getContentElement(editorContainer: HTMLDivElement | null): HTMLElement | null {\n if (!editorContainer) {\n console.warn('[Editora] Editor container not found');\n return null;\n }\n return editorContainer.querySelector('.rte-content') as HTMLElement | null;\n}\n\n/**\n * Get the content element by first finding the parent editor container from a given element\n * This is the most common usage pattern in plugins\n * \n * @param fromElement - Element to start searching from (e.g., this in event handler)\n * @returns The content element or null if not found\n */\nexport function findContentElement(fromElement: HTMLElement | null): HTMLElement | null {\n const container = findEditorContainer(fromElement);\n return getContentElement(container);\n}\n\n/**\n * Query elements within the editor container scope\n * Useful for finding specific elements like footnotes, merge tags, anchors, etc.\n * \n * @param editorContainer - The editor container element\n * @param selector - CSS selector to find within the container\n * @returns NodeList of matching elements\n */\nexport function queryScopedElements(\n editorContainer: HTMLDivElement | null,\n selector: string\n): NodeListOf<Element> {\n if (!editorContainer) {\n // Fallback to global selector for backward compatibility, but warn\n console.warn(`[Editora] Editor container not found, using global selector fallback for \"${selector}\"`);\n return document.querySelectorAll(selector);\n }\n return editorContainer.querySelectorAll(selector);\n}\n\n/**\n * Get a single scoped element\n * \n * @param editorContainer - The editor container element\n * @param selector - CSS selector to find within the container\n * @returns First matching element or null\n */\nexport function queryScopedElement(\n editorContainer: HTMLDivElement | null,\n selector: string\n): Element | null {\n if (!editorContainer) {\n // Fallback to global selector for backward compatibility, but warn\n console.warn(`[Editora] Editor container not found, using global selector fallback for \"${selector}\"`);\n return document.querySelector(selector);\n }\n return editorContainer.querySelector(selector);\n}\n\n/**\n * Get an element by ID within editor container scope\n * IDs like footnote IDs, anchor IDs, merge tag IDs should be scoped to the editor\n * \n * @param editorContainer - The editor container element\n * @param id - Element ID to find\n * @returns Element with that ID or null\n */\nexport function getScopedElementById(\n editorContainer: HTMLDivElement | null,\n id: string\n): HTMLElement | null {\n if (!editorContainer) {\n // Fallback for backward compatibility\n return document.getElementById(id);\n }\n \n // Use querySelector with ID selector within container scope\n return editorContainer.querySelector(`#${id}`) as HTMLElement | null;\n}\n\n/**\n * Event handler helper - Extract editor container from event and get content element\n * Common pattern: In event handlers, get the target element and find the editor container\n * \n * @param event - DOM event\n * @returns Object with editorContainer and contentElement\n */\nexport function getEditorElementsFromEvent(event: Event): {\n editorContainer: HTMLDivElement | null;\n contentElement: HTMLElement | null;\n} {\n const target = event.target as HTMLElement;\n const editorContainer = findEditorContainer(target);\n const contentElement = getContentElement(editorContainer);\n return { editorContainer, contentElement };\n}\n\n/**\n * Check if an element is within an editor instance\n * \n * @param element - Element to check\n * @returns True if element is inside an editor container\n */\nexport function isInEditor(element: HTMLElement | null): boolean {\n return findEditorContainer(element) !== null;\n}\n\n/**\n * Helper for getting selection from a specific editor\n * Ensures selection is within the correct editor instance\n * \n * @param editorContainer - The editor container element\n * @returns Selection if it's within this editor, or null otherwise\n */\nexport function getEditorSelection(editorContainer: HTMLDivElement | null): Selection | null {\n const selection = window.getSelection();\n if (!selection || !editorContainer) return null;\n \n const contentElement = getContentElement(editorContainer);\n if (!contentElement) return null;\n \n // Check if selection is within this editor's content\n if (selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n if (contentElement.contains(range.startContainer) && contentElement.contains(range.endContainer)) {\n return selection;\n }\n }\n \n return null;\n}\n\n/**\n * Helper for commands that need to know which editor they're being executed on\n * Extract editor context from toolbar button or command origin\n * \n * @param element - Button or element that triggered the command\n * @returns Editor container or null\n */\nexport function getEditorContextFromCommand(element: HTMLElement | null): HTMLDivElement | null {\n // First, try to find the editor container directly\n const fromElement = findEditorContainer(element);\n if (fromElement) return fromElement;\n \n // If element is a toolbar button, it might be outside editor container\n // Try to find it through document.activeElement (the focused editor)\n const activeElement = document.activeElement as HTMLElement;\n if (activeElement && activeElement.classList?.contains('rte-content')) {\n return findEditorContainer(activeElement);\n }\n \n return null;\n}\n"],"names":["findEditorContainerFromSelection","selection","node","element","findEditorContainer","current","getContentElement","editorContainer"],"mappings":"AAaO,SAASA,IAA0D;AACxE,QAAMC,IAAY,OAAO,aAAA;AACzB,MAAI,CAACA,KAAa,CAACA,EAAU;AAC3B,WAAO;AAIT,QAAMC,IADQD,EAAU,WAAW,CAAC,EACjB,gBAGbE,IAAUD,EAAK,aAAa,KAAK,YACnCA,EAAK,gBACLA;AAEJ,SAAOE,EAAoBD,CAAO;AACpC;AASO,SAASC,EAAoBD,GAAoD;AACtF,MAAI,CAACA,EAAS,QAAO;AAGrB,MAAIA,EAAQ,aAAa,qBAAqB;AAC5C,WAAOA;AAIT,MAAIE,IAAUF,EAAQ;AACtB,SAAOE,KAAS;AACd,QAAIA,EAAQ,aAAa,qBAAqB;AAC5C,aAAOA;AAET,IAAAA,IAAUA,EAAQ;AAAA,EACpB;AAEA,SAAO;AACT;AASO,SAASC,EAAkBC,GAA4D;AAC5F,SAAKA,IAIEA,EAAgB,cAAc,cAAc,KAHjD,QAAQ,KAAK,sCAAsC,GAC5C;AAGX;"}
@@ -1,10 +1,10 @@
1
- var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this.selection=e,this.schema=i}static create(t,e){const i=e||t.node("doc",{},[t.node("paragraph")]);return new b(i,{anchor:0,head:0},t)}apply(t,e){return new b(t,e||this.selection,this.schema)}}class L{constructor(t,e){this.nodes=new Map(Object.entries(t)),this.marks=new Map(Object.entries(e))}node(t,e,i){return{type:t,attrs:e,content:i}}text(t,e){return{type:"text",text:t,marks:e}}}class v{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(t,e){if(this.plugins.push(t),e&&this.pluginConfigs.set(t.name,e),t.initialize){const i=this.pluginConfigs.get(t.name)||t.config;t.initialize(i)}}unregister(t){const e=this.plugins.findIndex(i=>i.name===t);if(e>-1){const i=this.plugins[e];i.destroy&&i.destroy(),this.plugins.splice(e,1),this.pluginConfigs.delete(t)}}getPlugin(t){return this.plugins.find(e=>e.name===t)}getPluginConfig(t){return this.pluginConfigs.get(t)}buildSchema(){const t={},e={};return this.plugins.forEach(i=>{i.nodes&&Object.assign(t,i.nodes),i.marks&&Object.assign(e,i.marks)}),new L(t,e)}getCommands(){const t={};return this.plugins.forEach(e=>{e.commands&&Object.assign(t,e.commands)}),t}getToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}async executePluginCommand(t,e,...i){const o=this.getPlugin(t);if(!o)throw new Error(`Plugin not found: ${t}`);const n=this.getPluginConfig(t)||o.config||{},s=n.mode||"local";try{switch(s){case"local":return o.executeLocal?o.executeLocal(e,...i):null;case"api":if(!o.executeAPI)throw new Error(`Plugin ${t} does not support API mode`);return await o.executeAPI(e,...i);case"hybrid":if(o.executeHybrid)return await o.executeHybrid(e,...i);try{if(o.executeAPI)return await o.executeAPI(e,...i)}catch(r){if(console.warn(`API execution failed for ${t}, falling back to local`,r),o.executeLocal&&n.fallbackToLocal!==!1)return o.executeLocal(e,...i);throw r}break;default:throw new Error(`Unknown plugin mode: ${s}`)}}catch(r){throw console.error(`Error executing command ${e} on plugin ${t}:`,r),r}}async destroyAll(){const t=this.plugins.filter(e=>e.destroy).map(e=>e.destroy());await Promise.all(t),this.plugins=[],this.pluginConfigs.clear()}}class F{constructor(t){if(this.listeners=[],t instanceof v)this.pluginManager=t;else{const i=t;this.pluginManager=new v,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(o=>{this.pluginManager.register(o)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const e=this.pluginManager.buildSchema();this.state=b.create(e),this.commands=this.pluginManager.getCommands()}setupDOMElement(t){this.domElement&&(t.enableToolbar!==!1&&t.toolbarElement?this.toolbarElement=t.toolbarElement:t.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",t.content&&(this.contentElement.innerHTML=t.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(e=>e(this.state))}))}setupKeyboardShortcuts(t){const e={};t.forEach(i=>{i.shortcut&&(e[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const o=[];(i.ctrlKey||i.metaKey)&&o.push("ctrl"),i.shiftKey&&o.push("shift"),i.altKey&&o.push("alt");const n=i.key.toLowerCase(),s=o.length>0?`${o.join("+")}+${n}`:n,r=e[s];r&&(i.preventDefault(),this.execCommand(r))})}handleToolbarCommand(t,e){const o=this.pluginManager.getToolbarItems().find(n=>n.id&&n.id===t||n.command===t);o&&(e!==void 0?this.execCommand(o.command,e):this.execCommand(o.command))}setState(t){this.state=t,this.listeners.forEach(e=>e(t))}onChange(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}on(t,e){return t==="change"||t==="input"?this.onChange(e):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(t,e){const i=this.commands[t];if(!i)return console.warn(`Command not found: ${t}`),!1;let o;return e!==void 0?o=i(this.state,e):o=i(this.state),o?(this.setState(o),!0):!1}setContent(t){typeof t=="string"?this.contentElement&&(this.contentElement.innerHTML=t):this.setState(this.state.apply(t))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class M{constructor(t){this.initialized=!1,this.plugin=t}initialize(t){var e,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=t,(e=this.plugin.context)!=null&&e.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&t.provider&&this.plugin.context.onEditorReady(t),this.initialized=!0,!0}catch(o){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,o),!1}}destroy(){var t;if(!this.initialized)return!1;try{return(t=this.plugin.context)!=null&&t.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(t,...e){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${t}"`),null;try{const o=(i=this.plugin.commands)==null?void 0:i[t];return o?o(...e):(console.warn(`Command "${t}" not found in plugin "${this.plugin.name}"`),null)}catch(o){return console.error(`Error executing command "${t}" in plugin "${this.plugin.name}":`,o),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function j(a){return new M(a)}class ${constructor(t){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(t==null?void 0:t.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),t!=null&&t.shortcuts&&t.shortcuts.forEach(e=>this.registerShortcut(e)),t!=null&&t.customShortcuts&&Object.values(t.customShortcuts).forEach(e=>{this.registerShortcut(e)})}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 t=1;t<=6;t++)this.registerShortcut({key:String(t),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${t}`,description:`Heading ${t}`,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(t){const e=this.getShortcutKey(t);this.shortcuts.set(e,t)}unregisterShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.delete(e)}getShortcutKey(t){const e=[];return t.ctrl&&e.push("ctrl"),t.alt&&e.push("alt"),t.shift&&e.push("shift"),t.meta&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}getEventKey(t){const e=[];return t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}handleKeyDown(t,e){if(!this.enabled)return!1;const i=this.getEventKey(t),o=this.shortcuts.get(i);return o?(o.preventDefault!==!1&&(t.preventDefault(),t.stopPropagation()),e(o.command,o.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(t){return Array.from(this.shortcuts.values()).find(e=>e.command===t)}getShortcutDescription(t){const e=[];this.isMac?(t.meta&&e.push("⌘"),t.ctrl&&e.push("⌃"),t.alt&&e.push("⌥"),t.shift&&e.push("⇧")):(t.ctrl&&e.push("Ctrl"),t.alt&&e.push("Alt"),t.shift&&e.push("Shift"));const i=t.key.length===1?t.key.toUpperCase():t.key;return e.push(i),e.join("+")}getShortcutsHelp(){const t=this.getAllShortcuts(),e=new Map;t.forEach(o=>{const n=this.getShortcutCategory(o.command);e.has(n)||e.set(n,[]),e.get(n).push(o)});let i=`# Keyboard Shortcuts
1
+ var Editora=(function(c){"use strict";class y{constructor(t,e,i){this.doc=t,this.selection=e,this.schema=i}static create(t,e){const i=e||t.node("doc",{},[t.node("paragraph")]);return new y(i,{anchor:0,head:0},t)}apply(t,e){return new y(t,e||this.selection,this.schema)}}class S{constructor(t,e){this.nodes=new Map(Object.entries(t)),this.marks=new Map(Object.entries(e))}node(t,e,i){return{type:t,attrs:e,content:i}}text(t,e){return{type:"text",text:t,marks:e}}}class v{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(t,e){if(this.plugins.push(t),e&&this.pluginConfigs.set(t.name,e),t.initialize){const i=this.pluginConfigs.get(t.name)||t.config;t.initialize(i)}}unregister(t){const e=this.plugins.findIndex(i=>i.name===t);if(e>-1){const i=this.plugins[e];i.destroy&&i.destroy(),this.plugins.splice(e,1),this.pluginConfigs.delete(t)}}getPlugin(t){return this.plugins.find(e=>e.name===t)}getPluginConfig(t){return this.pluginConfigs.get(t)}buildSchema(){const t={},e={};return this.plugins.forEach(i=>{i.nodes&&Object.assign(t,i.nodes),i.marks&&Object.assign(e,i.marks)}),new S(t,e)}getCommands(){const t={};return this.plugins.forEach(e=>{e.commands&&Object.assign(t,e.commands)}),t}getToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}async executePluginCommand(t,e,...i){const o=this.getPlugin(t);if(!o)throw new Error(`Plugin not found: ${t}`);const n=this.getPluginConfig(t)||o.config||{},r=n.mode||"local";try{switch(r){case"local":return o.executeLocal?o.executeLocal(e,...i):null;case"api":if(!o.executeAPI)throw new Error(`Plugin ${t} does not support API mode`);return await o.executeAPI(e,...i);case"hybrid":if(o.executeHybrid)return await o.executeHybrid(e,...i);try{if(o.executeAPI)return await o.executeAPI(e,...i)}catch(s){if(console.warn(`API execution failed for ${t}, falling back to local`,s),o.executeLocal&&n.fallbackToLocal!==!1)return o.executeLocal(e,...i);throw s}break;default:throw new Error(`Unknown plugin mode: ${r}`)}}catch(s){throw console.error(`Error executing command ${e} on plugin ${t}:`,s),s}}async destroyAll(){const t=this.plugins.filter(e=>e.destroy).map(e=>e.destroy());await Promise.all(t),this.plugins=[],this.pluginConfigs.clear()}}class z{constructor(t){if(this.listeners=[],t instanceof v)this.pluginManager=t;else{const i=t;this.pluginManager=new v,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(o=>{this.pluginManager.register(o)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const e=this.pluginManager.buildSchema();this.state=y.create(e),this.commands=this.pluginManager.getCommands()}setupDOMElement(t){this.domElement&&(t.enableToolbar!==!1&&t.toolbarElement?this.toolbarElement=t.toolbarElement:t.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",t.content&&(this.contentElement.innerHTML=t.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(e=>e(this.state))}))}setupKeyboardShortcuts(t){const e={};t.forEach(i=>{i.shortcut&&(e[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const o=[];(i.ctrlKey||i.metaKey)&&o.push("ctrl"),i.shiftKey&&o.push("shift"),i.altKey&&o.push("alt");const n=i.key.toLowerCase(),r=o.length>0?`${o.join("+")}+${n}`:n,s=e[r];s&&(i.preventDefault(),this.execCommand(s))})}handleToolbarCommand(t,e){const o=this.pluginManager.getToolbarItems().find(n=>n.id&&n.id===t||n.command===t);o&&(e!==void 0?this.execCommand(o.command,e):this.execCommand(o.command))}setState(t){this.state=t,this.listeners.forEach(e=>e(t))}onChange(t){return this.listeners.push(t),()=>{this.listeners=this.listeners.filter(e=>e!==t)}}on(t,e){return t==="change"||t==="input"?this.onChange(e):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(t,e){const i=this.commands[t];if(!i)return console.warn(`Command not found: ${t}`),!1;let o;return e!==void 0?o=i(this.state,e):o=i(this.state),o?(this.setState(o),!0):!1}setContent(t){typeof t=="string"?this.contentElement&&(this.contentElement.innerHTML=t):this.setState(this.state.apply(t))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class L{constructor(t){this.initialized=!1,this.plugin=t}initialize(t){var e,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=t,(e=this.plugin.context)!=null&&e.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&t.provider&&this.plugin.context.onEditorReady(t),this.initialized=!0,!0}catch(o){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,o),!1}}destroy(){var t;if(!this.initialized)return!1;try{return(t=this.plugin.context)!=null&&t.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(t,...e){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${t}"`),null;try{const o=(i=this.plugin.commands)==null?void 0:i[t];return o?o(...e):(console.warn(`Command "${t}" not found in plugin "${this.plugin.name}"`),null)}catch(o){return console.error(`Error executing command "${t}" in plugin "${this.plugin.name}":`,o),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function N(a){return new L(a)}class q{constructor(t){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(t==null?void 0:t.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),t!=null&&t.shortcuts&&t.shortcuts.forEach(e=>this.registerShortcut(e)),t!=null&&t.customShortcuts&&Object.values(t.customShortcuts).forEach(e=>{this.registerShortcut(e)})}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 t=1;t<=6;t++)this.registerShortcut({key:String(t),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${t}`,description:`Heading ${t}`,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(t){const e=this.getShortcutKey(t);this.shortcuts.set(e,t)}unregisterShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.delete(e)}getShortcutKey(t){const e=[];return t.ctrl&&e.push("ctrl"),t.alt&&e.push("alt"),t.shift&&e.push("shift"),t.meta&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}getEventKey(t){const e=[];return t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}handleKeyDown(t,e){if(!this.enabled)return!1;const i=this.getEventKey(t),o=this.shortcuts.get(i);return o?(o.preventDefault!==!1&&(t.preventDefault(),t.stopPropagation()),e(o.command,o.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(t){return Array.from(this.shortcuts.values()).find(e=>e.command===t)}getShortcutDescription(t){const e=[];this.isMac?(t.meta&&e.push("⌘"),t.ctrl&&e.push("⌃"),t.alt&&e.push("⌥"),t.shift&&e.push("⇧")):(t.ctrl&&e.push("Ctrl"),t.alt&&e.push("Alt"),t.shift&&e.push("Shift"));const i=t.key.length===1?t.key.toUpperCase():t.key;return e.push(i),e.join("+")}getShortcutsHelp(){const t=this.getAllShortcuts(),e=new Map;t.forEach(o=>{const n=this.getShortcutCategory(o.command);e.has(n)||e.set(n,[]),e.get(n).push(o)});let i=`# Keyboard Shortcuts
2
2
 
3
3
  `;return e.forEach((o,n)=>{i+=`## ${n}
4
4
 
5
- `,o.forEach(s=>{const r=this.getShortcutDescription(s);i+=`- **${r}**: ${s.description||s.command}
5
+ `,o.forEach(r=>{const s=this.getShortcutDescription(r);i+=`- **${s}**: ${r.description||r.command}
6
6
  `}),i+=`
7
- `}),i}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"}}function N(a={}){const{enabled:t=!1,provider:e="browser",apiUrl:i="",apiHeaders:o={},language:n="en",customDictionary:s=[],ignoreAllCaps:r=!0,ignoreNumbers:l=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:n}),e){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:p=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:p=>(console.log("[Spellcheck] Add to dictionary:",p),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function R(a={}){const{uploadUrl:t="",libraryUrl:e="",maxFileSize:i=10485760,allowedTypes:o=["image/jpeg","image/png","image/gif","image/webp"],headers:n={},withCredentials:s=!1,chunkSize:r=1048576,enableChunking:l=!0,onProgress:p,onError:u,onSuccess:m}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:i,allowedTypes:o}),t||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(!o.includes(d.type)){const h=new Error(`File type ${d.type} not allowed`);return u==null||u(h),null}if(d.size>i){const h=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(h),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||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 T{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,i])=>{this.register(e,i)})}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 E{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new v,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(i=>this.pluginManager.register(i));const e=this.pluginManager.buildSchema();this.state=b.create(e),this.commandRegistry=new T(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 i=this.commandRegistry.get(t);if(!i)return console.warn(`Command not found: ${t}`),!1;let o;return e!==void 0?o=i(this.state,e):o=i(this.state),o?(this.setState(o),this.emit("change",this.state),!0):!1}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 i=this.listeners.get(t);if(i){const o=i.indexOf(e);o>-1&&i.splice(o,1)}}}emit(t,...e){const i=this.listeners.get(t);i&&i.forEach(o=>{try{o(...e)}catch(n){console.error(`Error in ${t} handler:`,n)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class y{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new y(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new y(this.doc,t)}update(t,e){return new y(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class x{constructor(t,e,i){this.config=t,this.plugins=e,this.pluginLoader=i}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],i=t.split("|").map(r=>r.trim()),o=this.getAvailableToolbarItems(),n=new Map;o.forEach(r=>{r.command&&n.set(r.command,r),r.type==="group"&&r.label&&n.set(r.label,r)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",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",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return i.forEach(r=>{const l=[];r.split(/\s+/).filter(Boolean).forEach(u=>{if(u==="direction"){const h=n.get("setDirectionLTR"),g=n.get("setDirectionRTL");h&&l.push({id:"directionLTR",label:h.label,command:h.command,icon:h.icon,type:h.type||"button",options:h.options}),g&&l.push({id:"directionRTL",label:g.label,command:g.command,icon:g.icon,type:g.type||"button",options:g.options});return}if(u==="comments"){const h=n.get("addComment"),g=n.get("toggleComments");h&&l.push({id:"addComment",label:h.label,command:h.command,icon:h.icon,type:h.type||"button",options:h.options}),g&&l.push({id:"toggleComments",label:g.label,command:g.command,icon:g.icon,type:g.type||"button",options:g.options});return}const m=s[u]||u;let d=n.get(m);d||(d=n.get(u)),d&&l.push({id:u,label:d.label,command:d.command,icon:d.icon,type:d.type==="separator"?"separator":d.type||"button",options:d.options,items:d.items})}),l.length>0&&e.push(l)}),e}getAvailableToolbarItems(){let t=this.plugins;return this.pluginLoader&&(t=this.pluginLoader.getRegisteredPluginNames().map(n=>this.pluginLoader.load(n)).filter(n=>n!==null)),t.flatMap(i=>i.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=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(e);i.forEach((o,n)=>{const s=document.createElement("div");if(s.className="editora-toolbar-group",o.forEach(r=>{this.appendToolbarButton(s,r)}),t.appendChild(s),n<i.length-1){const r=document.createElement("div");r.className="editora-toolbar-separator",t.appendChild(r)}})}appendToolbarButton(t,e){if(e.type==="separator"){const i=document.createElement("div");i.className="editora-toolbar-separator",t.appendChild(i)}else if(e.type==="dropdown"){const i=this.createDropdown(e);t.appendChild(i)}else if(e.type==="inline-menu"){const i=this.createInlineMenu(e);t.appendChild(i)}else if(e.type==="group"&&e.items&&e.items.length){const i=this.createGroupButton(e);t.appendChild(i)}else if(e.type==="input"){const i=this.createInput(e);t.appendChild(i)}else{const i=this.createButton(e);t.appendChild(i)}}createGroupButton(t){const e=document.createElement("div");if(e.className="editora-toolbar-group-button",e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const i=document.createElement("div");i.className="editora-toolbar-group-items",t.items.forEach(o=>{this.appendToolbarButton(i,o)}),e.appendChild(i)}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||"",e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",i=>{i.preventDefault(),this.commandHandler&&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,e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}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",i=>{i.preventDefault(),this.commandHandler&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const i=document.createElement("button");i.className="editora-toolbar-button editora-toolbar-dropdown-trigger",i.type="button",i.textContent=t.label;const o=document.createElement("div");o.className="editora-toolbar-dropdown-menu",o.style.display="none",t.options&&t.options.forEach(s=>{const r=document.createElement("button");r.className="editora-toolbar-dropdown-item",r.type="button",r.textContent=s.label,r.setAttribute("data-value",s.value),r.addEventListener("click",l=>{l.preventDefault(),this.commandHandler&&this.commandHandler(t.command,s.value),o.style.display="none"}),o.appendChild(r)}),i.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation();const r=o.style.display==="block";o.style.display=r?"none":"block"});const n=s=>{e.contains(s.target)||(o.style.display="none")};return document.addEventListener("click",n),e._cleanupDropdown=()=>{document.removeEventListener("click",n)},e.appendChild(i),e.appendChild(o),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const i=document.createElement("button");if(i.className="editora-toolbar-button",i.type="button",i.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,i.appendChild(n)}else i.innerHTML=t.icon;else i.textContent=t.label;const o=document.createElement("div");return o.className="editora-toolbar-dropdown-menu",o.style.display="none",t.options&&t.options.forEach(n=>{const s=document.createElement("button");s.className="editora-toolbar-dropdown-item",s.type="button",s.textContent=n.label,s.setAttribute("data-value",n.value),s.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation(),this.commandHandler&&this.commandHandler(t.command,n.value),o.style.display="none"}),o.appendChild(s)}),i.addEventListener("click",n=>{var r;n.preventDefault(),n.stopPropagation();const s=(r=this.container)==null?void 0:r.querySelectorAll(".editora-toolbar-dropdown-menu");s==null||s.forEach(l=>{l!==o&&(l.style.display="none")}),o.style.display=o.style.display==="none"?"block":"none"}),document.addEventListener("click",n=>{e.contains(n.target)||(o.style.display="none")}),e.appendChild(i),e.appendChild(o),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const i=this.container.querySelector(`[data-command="${t}"]`);i&&(e.active!==void 0&&i.classList.toggle("active",e.active),e.disabled!==void 0&&(i.disabled=e.disabled))}destroy(){this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(e=>{const i=e._cleanupDropdown;i&&i()}),this.container.innerHTML=""),this.commandHandler=void 0}}class I{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 D{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=[];this.statusInfo.wordCount!==void 0&&t.push(`Words: ${this.statusInfo.wordCount}`),this.statusInfo.charCount!==void 0&&t.push(`Characters: ${this.statusInfo.charCount}`),this.statusInfo.lineCount!==void 0&&t.push(`Lines: ${this.statusInfo.lineCount}`),this.statusInfo.language&&t.push(`Language: ${this.statusInfo.language}`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([e,i])=>{t.push(`${e}: ${i}`)}),t.forEach((e,i)=>{const o=document.createElement("span");if(o.className="editora-statusbar-item",o.textContent=e,this.container.appendChild(o),i<t.length-1){const n=document.createElement("span");n.className="editora-statusbar-separator",n.textContent="|",this.container.appendChild(n)}})}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class f{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");if(t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height),t.innerHTML=`
7
+ `}),i}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"}}function R(a={}){const{enabled:t=!1,provider:e="browser",apiUrl:i="",apiHeaders:o={},language:n="en",customDictionary:r=[],ignoreAllCaps:s=!0,ignoreNumbers:l=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:n}),e){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:m=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:m=>(console.log("[Spellcheck] Add to dictionary:",m),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function B(a={}){const{uploadUrl:t="",libraryUrl:e="",maxFileSize:i=10485760,allowedTypes:o=["image/jpeg","image/png","image/gif","image/webp"],headers:n={},withCredentials:r=!1,chunkSize:s=1048576,enableChunking:l=!0,onProgress:m,onError:u,onSuccess:p}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:i,allowedTypes:o}),t||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(!o.includes(d.type)){const h=new Error(`File type ${d.type} not allowed`);return u==null||u(h),null}if(d.size>i){const h=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(h),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||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 M{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,i])=>{this.register(e,i)})}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 w{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new v,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(i=>this.pluginManager.register(i));const e=this.pluginManager.buildSchema();this.state=y.create(e),this.commandRegistry=new M(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 i=this.commandRegistry.get(t);if(!i)return console.warn(`Command not found: ${t}`),!1;let o;return e!==void 0?o=i(this.state,e):o=i(this.state),o?(this.setState(o),this.emit("change",this.state),!0):!1}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 i=this.listeners.get(t);if(i){const o=i.indexOf(e);o>-1&&i.splice(o,1)}}}emit(t,...e){const i=this.listeners.get(t);i&&i.forEach(o=>{try{o(...e)}catch(n){console.error(`Error in ${t} handler:`,n)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class x{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new x(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new x(this.doc,t)}update(t,e){return new x(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class E{constructor(t,e,i){this.config=t,this.plugins=e,this.pluginLoader=i}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],i=t.split("|").map(s=>s.trim()),o=this.getAvailableToolbarItems(),n=new Map;o.forEach(s=>{s.command&&n.set(s.command,s),s.type==="group"&&s.label&&n.set(s.label,s)});const r={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",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",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return i.forEach(s=>{const l=[];s.split(/\s+/).filter(Boolean).forEach(u=>{if(u==="direction"){const h=n.get("setDirectionLTR"),g=n.get("setDirectionRTL");h&&l.push({id:"directionLTR",label:h.label,command:h.command,icon:h.icon,type:h.type||"button",options:h.options}),g&&l.push({id:"directionRTL",label:g.label,command:g.command,icon:g.icon,type:g.type||"button",options:g.options});return}if(u==="comments"){const h=n.get("addComment"),g=n.get("toggleComments");h&&l.push({id:"addComment",label:h.label,command:h.command,icon:h.icon,type:h.type||"button",options:h.options}),g&&l.push({id:"toggleComments",label:g.label,command:g.command,icon:g.icon,type:g.type||"button",options:g.options});return}const p=r[u]||u;let d=n.get(p);d||(d=n.get(u)),d&&l.push({id:u,label:d.label,command:d.command,icon:d.icon,type:d.type==="separator"?"separator":d.type||"button",options:d.options,items:d.items})}),l.length>0&&e.push(l)}),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=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(e);i.forEach((o,n)=>{const r=document.createElement("div");if(r.className="editora-toolbar-group",o.forEach(s=>{this.appendToolbarButton(r,s)}),t.appendChild(r),n<i.length-1){const s=document.createElement("div");s.className="editora-toolbar-separator",t.appendChild(s)}})}appendToolbarButton(t,e){if(e.type==="separator"){const i=document.createElement("div");i.className="editora-toolbar-separator",t.appendChild(i)}else if(e.type==="dropdown"){const i=this.createDropdown(e);t.appendChild(i)}else if(e.type==="inline-menu"){const i=this.createInlineMenu(e);t.appendChild(i)}else if(e.type==="group"&&e.items&&e.items.length){const i=this.createGroupButton(e);t.appendChild(i)}else if(e.type==="input"){const i=this.createInput(e);t.appendChild(i)}else{const i=this.createButton(e);t.appendChild(i)}}createGroupButton(t){const e=document.createElement("div");if(e.className="editora-toolbar-group-button",e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const i=document.createElement("div");i.className="editora-toolbar-group-items",t.items.forEach(o=>{this.appendToolbarButton(i,o)}),e.appendChild(i)}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||"",e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",i=>{i.preventDefault(),this.commandHandler&&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,e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}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",i=>{i.preventDefault(),this.commandHandler&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const i=document.createElement("button");i.className="editora-toolbar-button editora-toolbar-dropdown-trigger",i.type="button",i.textContent=t.label;const o=document.createElement("div");o.className="editora-toolbar-dropdown-menu",o.style.display="none",t.options&&t.options.forEach(r=>{const s=document.createElement("button");s.className="editora-toolbar-dropdown-item",s.type="button",s.textContent=r.label,s.setAttribute("data-value",r.value),s.addEventListener("click",l=>{l.preventDefault(),this.commandHandler&&this.commandHandler(t.command,r.value),o.style.display="none"}),o.appendChild(s)}),i.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();const s=o.style.display==="block";o.style.display=s?"none":"block"});const n=r=>{e.contains(r.target)||(o.style.display="none")};return document.addEventListener("click",n),e._cleanupDropdown=()=>{document.removeEventListener("click",n)},e.appendChild(i),e.appendChild(o),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const i=document.createElement("button");if(i.className="editora-toolbar-button",i.type="button",i.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,i.appendChild(n)}else i.innerHTML=t.icon;else i.textContent=t.label;const o=document.createElement("div");return o.className="editora-toolbar-dropdown-menu",o.style.display="none",t.options&&t.options.forEach(n=>{const r=document.createElement("button");r.className="editora-toolbar-dropdown-item",r.type="button",r.textContent=n.label,r.setAttribute("data-value",n.value),r.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation(),this.commandHandler&&this.commandHandler(t.command,n.value),o.style.display="none"}),o.appendChild(r)}),i.addEventListener("click",n=>{var s;n.preventDefault(),n.stopPropagation();const r=(s=this.container)==null?void 0:s.querySelectorAll(".editora-toolbar-dropdown-menu");r==null||r.forEach(l=>{l!==o&&(l.style.display="none")}),o.style.display=o.style.display==="none"?"block":"none"}),document.addEventListener("click",n=>{e.contains(n.target)||(o.style.display="none")}),e.appendChild(i),e.appendChild(o),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const i=this.container.querySelector(`[data-command="${t}"]`);i&&(e.active!==void 0&&i.classList.toggle("active",e.active),e.disabled!==void 0&&(i.disabled=e.disabled))}destroy(){this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(e=>{const i=e._cleanupDropdown;i&&i()}),this.container.innerHTML=""),this.commandHandler=void 0}}class T{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 I{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 i=[];if(this.statusInfo.selectionInfo){const n=this.statusInfo.selectionInfo;n.startLine===n.endLine&&n.startColumn===n.endColumn?i.push(`Ln ${n.startLine}, Col ${n.startColumn}`):(n.startLine===n.endLine?i.push(`Ln ${n.startLine}, Col ${n.startColumn}-${n.endColumn}`):i.push(`Ln ${n.startLine}:${n.startColumn} - ${n.endLine}:${n.endColumn}`),i.push(`${n.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const n=this.statusInfo.cursorPosition;i.push(`Ln ${n.line}, Col ${n.column}`)}this.statusInfo.language&&i.push(this.statusInfo.language);const o=[];this.statusInfo.wordCount!==void 0&&o.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&o.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&o.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([n,r])=>{o.push(`${n}: ${r}`)}),i.forEach((n,r)=>{const s=document.createElement("span");if(s.className="editora-statusbar-item",s.textContent=n,t.appendChild(s),r<i.length-1){const l=document.createElement("span");l.className="editora-statusbar-separator",l.textContent="|",t.appendChild(l)}}),o.forEach((n,r)=>{const s=document.createElement("span");if(s.className="editora-statusbar-item",s.textContent=n,e.appendChild(s),r<o.length-1){const l=document.createElement("span");l.className="editora-statusbar-separator",l.textContent="|",e.appendChild(l)}}),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 f{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");if(t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height),t.innerHTML=`
8
8
  <div class="editora-dialog-container">
9
9
  <div class="editora-dialog-header">
10
10
  <h3>${this.config.title}</h3>
@@ -18,7 +18,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
18
18
  <button type="button" class="editora-btn editora-btn-primary">OK</button>
19
19
  </div>
20
20
  </div>
21
- `,typeof this.config.content!="string"){const e=t.querySelector(".editora-dialog-body");e&&(e.innerHTML="",e.appendChild(this.config.content))}return t}attachEventListeners(){const t=this.element.querySelector(".editora-dialog-close");t==null||t.addEventListener("click",()=>this.close());const e=this.element.querySelector(".editora-btn-cancel");e==null||e.addEventListener("click",()=>{var o,n;(n=(o=this.config).onCancel)==null||n.call(o),this.close()});const i=this.element.querySelector(".editora-btn-primary");i==null||i.addEventListener("click",()=>this.handleSubmit()),this.config.closeOnEscape&&this.element.addEventListener("cancel",o=>{o.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",o=>{const n=this.element.getBoundingClientRect();(o.clientX<n.left||o.clientX>n.right||o.clientY<n.top||o.clientY>n.bottom)&&this.close()})}handleSubmit(){var e,i,o,n;const t=this.element.querySelector("form");if(t){const s=new FormData(t);(i=(e=this.config).onSubmit)==null||i.call(e,s)}else{const s=this.element.querySelectorAll("input, select, textarea"),r=new FormData;s.forEach(l=>{l.name&&r.append(l.name,l.value)}),(n=(o=this.config).onSubmit)==null||n.call(o,r)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class z{constructor(t){this.isOpen=!1,this.config=t,this.selectedValue=t.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("div");t.className="editora-dropdown",this.config.width&&(t.style.width=this.config.width);const e=this.config.options.find(o=>o.value===this.selectedValue),i=(e==null?void 0:e.label)||this.config.placeholder||"Select...";return t.innerHTML=`
21
+ `,typeof this.config.content!="string"){const e=t.querySelector(".editora-dialog-body");e&&(e.innerHTML="",e.appendChild(this.config.content))}return t}attachEventListeners(){const t=this.element.querySelector(".editora-dialog-close");t==null||t.addEventListener("click",()=>this.close());const e=this.element.querySelector(".editora-btn-cancel");e==null||e.addEventListener("click",()=>{var o,n;(n=(o=this.config).onCancel)==null||n.call(o),this.close()});const i=this.element.querySelector(".editora-btn-primary");i==null||i.addEventListener("click",()=>this.handleSubmit()),this.config.closeOnEscape&&this.element.addEventListener("cancel",o=>{o.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",o=>{const n=this.element.getBoundingClientRect();(o.clientX<n.left||o.clientX>n.right||o.clientY<n.top||o.clientY>n.bottom)&&this.close()})}handleSubmit(){var e,i,o,n;const t=this.element.querySelector("form");if(t){const r=new FormData(t);(i=(e=this.config).onSubmit)==null||i.call(e,r)}else{const r=this.element.querySelectorAll("input, select, textarea"),s=new FormData;r.forEach(l=>{l.name&&s.append(l.name,l.value)}),(n=(o=this.config).onSubmit)==null||n.call(o,s)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class O{constructor(t){this.isOpen=!1,this.config=t,this.selectedValue=t.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("div");t.className="editora-dropdown",this.config.width&&(t.style.width=this.config.width);const e=this.config.options.find(o=>o.value===this.selectedValue),i=(e==null?void 0:e.label)||this.config.placeholder||"Select...";return t.innerHTML=`
22
22
  <button class="editora-dropdown-toggle" type="button">
23
23
  <span class="editora-dropdown-label">${i}</span>
24
24
  <span class="editora-dropdown-arrow">▼</span>
@@ -31,7 +31,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
31
31
  </div>
32
32
  `).join("")}
33
33
  </div>
34
- `,t}attachEventListeners(){const t=this.element.querySelector(".editora-dropdown-toggle"),e=this.element.querySelector(".editora-dropdown-menu");t.addEventListener("click",o=>{o.stopPropagation(),this.isOpen=!this.isOpen,e.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(o=>{o.addEventListener("click",()=>{var s,r;const n=o.getAttribute("data-value");n&&(this.setValue(n),(r=(s=this.config).onChange)==null||r.call(s,n),this.close())})}),document.addEventListener("click",o=>{this.element.contains(o.target)||this.close()})}setValue(t){this.selectedValue=t;const e=this.config.options.find(o=>o.value===t),i=this.element.querySelector(".editora-dropdown-label");i&&e&&(i.textContent=e.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const t=this.element.querySelector(".editora-dropdown-menu");t&&(t.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class q{constructor(t){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,...t},this.selectedColor=t.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){var e;const t=document.createElement("div");return t.className="editora-color-picker",t.innerHTML=`
34
+ `,t}attachEventListeners(){const t=this.element.querySelector(".editora-dropdown-toggle"),e=this.element.querySelector(".editora-dropdown-menu");t.addEventListener("click",o=>{o.stopPropagation(),this.isOpen=!this.isOpen,e.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(o=>{o.addEventListener("click",()=>{var r,s;const n=o.getAttribute("data-value");n&&(this.setValue(n),(s=(r=this.config).onChange)==null||s.call(r,n),this.close())})}),document.addEventListener("click",o=>{this.element.contains(o.target)||this.close()})}setValue(t){this.selectedValue=t;const e=this.config.options.find(o=>o.value===t),i=this.element.querySelector(".editora-dropdown-label");i&&e&&(i.textContent=e.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const t=this.element.querySelector(".editora-dropdown-menu");t&&(t.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class U{constructor(t){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,...t},this.selectedColor=t.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){var e;const t=document.createElement("div");return t.className="editora-color-picker",t.innerHTML=`
35
35
  <div class="editora-color-picker-input">
36
36
  <input type="color" value="${this.selectedColor||"#000000"}" />
37
37
  <input type="text" value="${this.selectedColor||"#000000"}" placeholder="#000000" />
@@ -46,7 +46,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
46
46
  ></button>
47
47
  `).join("")}
48
48
  </div>
49
- `,t}attachEventListeners(){const t=this.element.querySelector('input[type="color"]'),e=this.element.querySelector('input[type="text"]');t.addEventListener("input",o=>{var s,r;const n=o.target.value;e.value=n,this.selectedColor=n,(r=(s=this.config).onChange)==null||r.call(s,n)}),e.addEventListener("input",o=>{var s,r;const n=o.target.value;/^#[0-9A-Fa-f]{6}$/.test(n)&&(t.value=n,this.selectedColor=n,(r=(s=this.config).onChange)==null||r.call(s,n))}),this.element.querySelectorAll(".editora-color-preset").forEach(o=>{o.addEventListener("click",()=>{var s,r;const n=o.getAttribute("data-color");n&&(t.value=n,e.value=n,this.selectedColor=n,(r=(s=this.config).onChange)==null||r.call(s,n))})})}getValue(){return this.selectedColor}setValue(t){this.selectedColor=t;const e=this.element.querySelector('input[type="color"]'),i=this.element.querySelector('input[type="text"]');e&&(e.value=t),i&&(i.value=t)}getElement(){return this.element}destroy(){this.element.remove()}}class B{constructor(t){const{initialUrl:e="",initialText:i="",onSubmit:o,onCancel:n}=t;this.dialog=new f({title:"Insert/Edit Link",content:this.createFormHTML(e,i),onSubmit:s=>{const r=(s.get("url")||"").trim(),l=(s.get("text")||"").trim(),p=s.get("openInNewTab")==="on";if(!r){alert("Please enter a URL");return}o({url:r,text:l,openInNewTab:p}),this.dialog.close()},onCancel:()=>{n==null||n(),this.dialog.close()},width:"500px"})}createFormHTML(t,e){return`
49
+ `,t}attachEventListeners(){const t=this.element.querySelector('input[type="color"]'),e=this.element.querySelector('input[type="text"]');t.addEventListener("input",o=>{var r,s;const n=o.target.value;e.value=n,this.selectedColor=n,(s=(r=this.config).onChange)==null||s.call(r,n)}),e.addEventListener("input",o=>{var r,s;const n=o.target.value;/^#[0-9A-Fa-f]{6}$/.test(n)&&(t.value=n,this.selectedColor=n,(s=(r=this.config).onChange)==null||s.call(r,n))}),this.element.querySelectorAll(".editora-color-preset").forEach(o=>{o.addEventListener("click",()=>{var r,s;const n=o.getAttribute("data-color");n&&(t.value=n,e.value=n,this.selectedColor=n,(s=(r=this.config).onChange)==null||s.call(r,n))})})}getValue(){return this.selectedColor}setValue(t){this.selectedColor=t;const e=this.element.querySelector('input[type="color"]'),i=this.element.querySelector('input[type="text"]');e&&(e.value=t),i&&(i.value=t)}getElement(){return this.element}destroy(){this.element.remove()}}class W{constructor(t){const{initialUrl:e="",initialText:i="",onSubmit:o,onCancel:n}=t;this.dialog=new f({title:"Insert/Edit Link",content:this.createFormHTML(e,i),onSubmit:r=>{const s=(r.get("url")||"").trim(),l=(r.get("text")||"").trim(),m=r.get("openInNewTab")==="on";if(!s){alert("Please enter a URL");return}o({url:s,text:l,openInNewTab:m}),this.dialog.close()},onCancel:()=>{n==null||n(),this.dialog.close()},width:"500px"})}createFormHTML(t,e){return`
50
50
  <form class="link-dialog-form">
51
51
  <div class="form-group">
52
52
  <label for="link-url">URL</label>
@@ -94,7 +94,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
94
94
  </button>
95
95
  </div>
96
96
  </form>
97
- `}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class O{constructor(t){const{onSubmit:e,onCancel:i}=t;this.dialog=new f({title:"Insert Table",content:this.createFormHTML(),onSubmit:o=>{const n=parseInt(o.get("rows"),10),s=parseInt(o.get("cols"),10),r=o.get("headerRow")==="on";if(n<1||n>100){alert("Please enter a valid number of rows (1-100)");return}if(s<1||s>20){alert("Please enter a valid number of columns (1-20)");return}e({rows:n,cols:s,headerRow:r}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"400px"})}createFormHTML(){return`
97
+ `}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class G{constructor(t){const{onSubmit:e,onCancel:i}=t;this.dialog=new f({title:"Insert Table",content:this.createFormHTML(),onSubmit:o=>{const n=parseInt(o.get("rows"),10),r=parseInt(o.get("cols"),10),s=o.get("headerRow")==="on";if(n<1||n>100){alert("Please enter a valid number of rows (1-100)");return}if(r<1||r>20){alert("Please enter a valid number of columns (1-20)");return}e({rows:n,cols:r,headerRow:s}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"400px"})}createFormHTML(){return`
98
98
  <form class="table-dialog-form">
99
99
  <div class="form-group">
100
100
  <label for="table-rows">Rows</label>
@@ -153,7 +153,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
153
153
  </button>
154
154
  </div>
155
155
  </form>
156
- `}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const t=document.querySelector(".table-dialog-form");if(!t)return;const e=t.querySelector("#table-rows"),i=t.querySelector("#table-cols"),o=t.querySelector("#table-header"),n=t.querySelector("#table-preview-content"),s=()=>{const r=parseInt((e==null?void 0:e.value)||"3",10),l=parseInt((i==null?void 0:i.value)||"3",10),p=o==null?void 0:o.checked;n&&(n.textContent=`${r} rows × ${l} columns${p?" with header":""}`)};e==null||e.addEventListener("input",s),i==null||i.addEventListener("input",s),o==null||o.addEventListener("change",s)}}class U{constructor(t){this.config=t;const{onSubmit:e,onCancel:i}=t;this.dialog=new f({title:"Insert Image",content:this.createFormHTML(),onSubmit:o=>{const n=(o.get("src")||"").trim(),s=(o.get("alt")||"").trim(),r=(o.get("width")||"").trim(),l=(o.get("height")||"").trim();if(!n){alert("Please enter an image URL or upload an image");return}e({src:n,alt:s,width:r||void 0,height:l||void 0}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"500px"})}createFormHTML(){return`
156
+ `}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const t=document.querySelector(".table-dialog-form");if(!t)return;const e=t.querySelector("#table-rows"),i=t.querySelector("#table-cols"),o=t.querySelector("#table-header"),n=t.querySelector("#table-preview-content"),r=()=>{const s=parseInt((e==null?void 0:e.value)||"3",10),l=parseInt((i==null?void 0:i.value)||"3",10),m=o==null?void 0:o.checked;n&&(n.textContent=`${s} rows × ${l} columns${m?" with header":""}`)};e==null||e.addEventListener("input",r),i==null||i.addEventListener("input",r),o==null||o.addEventListener("change",r)}}class K{constructor(t){this.config=t;const{onSubmit:e,onCancel:i}=t;this.dialog=new f({title:"Insert Image",content:this.createFormHTML(),onSubmit:o=>{const n=(o.get("src")||"").trim(),r=(o.get("alt")||"").trim(),s=(o.get("width")||"").trim(),l=(o.get("height")||"").trim();if(!n){alert("Please enter an image URL or upload an image");return}e({src:n,alt:r,width:s||void 0,height:l||void 0}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"500px"})}createFormHTML(){return`
157
157
  <form class="image-dialog-form">
158
158
  ${this.config.allowUpload?`
159
159
  <div class="form-group">
@@ -227,7 +227,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
227
227
  </button>
228
228
  </div>
229
229
  </form>
230
- `}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const t=document.querySelector(".image-dialog-form");if(!t)return;const e=t.querySelector("#image-src"),i=t.querySelector("#image-preview"),o=t.querySelector("#preview-img");e==null||e.addEventListener("input",()=>{const n=e.value.trim();n&&this.isValidImageUrl(n)?(o.src=n,i.style.display="block",o.onerror=()=>{i.style.display="none"}):i.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const t=document.querySelector(".image-dialog-form");if(!t)return;const e=t.querySelector("#image-upload"),i=t.querySelector("#image-src");e==null||e.addEventListener("change",async o=>{var r;const n=(r=o.target.files)==null?void 0:r[0];if(!n)return;const s=new FileReader;s.onload=l=>{var u;const p=(u=l.target)==null?void 0:u.result;i.value=p,i.dispatchEvent(new Event("input"))},s.readAsDataURL(n)})}isValidImageUrl(t){try{return new URL(t),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(t)||t.startsWith("data:image/")}catch(e){return!1}}}class G{constructor(t){this.onSubmit=t.onSubmit;const e=this.createContent();this.dialog=new f({title:"Insert Math Equation",content:e,buttons:[{label:"Cancel",onClick:()=>this.dialog.close()},{label:"Insert",onClick:()=>this.handleSubmit(),primary:!0}]}),this.latexInput=e.querySelector("#math-latex"),this.previewDiv=e.querySelector("#math-preview"),this.displayTypeSelect=e.querySelector("#math-display-type"),this.latexInput.addEventListener("input",()=>this.updatePreview())}createContent(){const t=document.createElement("div");return t.className="math-dialog-content",t.style.minWidth="500px",t.innerHTML=`
230
+ `}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const t=document.querySelector(".image-dialog-form");if(!t)return;const e=t.querySelector("#image-src"),i=t.querySelector("#image-preview"),o=t.querySelector("#preview-img");e==null||e.addEventListener("input",()=>{const n=e.value.trim();n&&this.isValidImageUrl(n)?(o.src=n,i.style.display="block",o.onerror=()=>{i.style.display="none"}):i.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const t=document.querySelector(".image-dialog-form");if(!t)return;const e=t.querySelector("#image-upload"),i=t.querySelector("#image-src");e==null||e.addEventListener("change",async o=>{var s;const n=(s=o.target.files)==null?void 0:s[0];if(!n)return;const r=new FileReader;r.onload=l=>{var u;const m=(u=l.target)==null?void 0:u.result;i.value=m,i.dispatchEvent(new Event("input"))},r.readAsDataURL(n)})}isValidImageUrl(t){try{return new URL(t),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(t)||t.startsWith("data:image/")}catch(e){return!1}}}class V{constructor(t){this.onSubmit=t.onSubmit;const e=this.createContent();this.dialog=new f({title:"Insert Math Equation",content:e,buttons:[{label:"Cancel",onClick:()=>this.dialog.close()},{label:"Insert",onClick:()=>this.handleSubmit(),primary:!0}]}),this.latexInput=e.querySelector("#math-latex"),this.previewDiv=e.querySelector("#math-preview"),this.displayTypeSelect=e.querySelector("#math-display-type"),this.latexInput.addEventListener("input",()=>this.updatePreview())}createContent(){const t=document.createElement("div");return t.className="math-dialog-content",t.style.minWidth="500px",t.innerHTML=`
231
231
  <style>
232
232
  .math-dialog-content {
233
233
  display: flex;
@@ -339,7 +339,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
339
339
  <option value="block">Block (centered, new line)</option>
340
340
  </select>
341
341
  </div>
342
- `,t.querySelectorAll(".math-symbol-btn").forEach(i=>{i.addEventListener("click",o=>{o.preventDefault();const n=i.getAttribute("data-symbol");if(n&&this.latexInput){const s=this.latexInput.selectionStart,r=this.latexInput.selectionEnd,l=this.latexInput.value;this.latexInput.value=l.substring(0,s)+n+l.substring(r),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=s+n.length,this.updatePreview()}})}),t}updatePreview(){const t=this.latexInput.value.trim();if(!t){this.previewDiv.textContent="";return}let e=t.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=e}handleSubmit(){const t=this.latexInput.value.trim();if(!t){alert("Please enter a LaTeX expression.");return}const e=this.displayTypeSelect.value;this.onSubmit({latex:t,display:e}),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 W{constructor(t){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=t.onSelect;const e=this.createContent();this.dialog=new f({title:"Insert Special Character",content:e,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=e.querySelector("#char-search"),this.categorySelect=e.querySelector("#char-category"),this.charactersGrid=e.querySelector("#char-grid"),this.searchInput.addEventListener("input",()=>this.filterCharacters()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const t=document.createElement("div");return t.className="character-dialog-content",t.style.minWidth="500px",t.innerHTML=`
342
+ `,t.querySelectorAll(".math-symbol-btn").forEach(i=>{i.addEventListener("click",o=>{o.preventDefault();const n=i.getAttribute("data-symbol");if(n&&this.latexInput){const r=this.latexInput.selectionStart,s=this.latexInput.selectionEnd,l=this.latexInput.value;this.latexInput.value=l.substring(0,r)+n+l.substring(s),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=r+n.length,this.updatePreview()}})}),t}updatePreview(){const t=this.latexInput.value.trim();if(!t){this.previewDiv.textContent="";return}let e=t.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=e}handleSubmit(){const t=this.latexInput.value.trim();if(!t){alert("Please enter a LaTeX expression.");return}const e=this.displayTypeSelect.value;this.onSubmit({latex:t,display:e}),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 _{constructor(t){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=t.onSelect;const e=this.createContent();this.dialog=new f({title:"Insert Special Character",content:e,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=e.querySelector("#char-search"),this.categorySelect=e.querySelector("#char-category"),this.charactersGrid=e.querySelector("#char-grid"),this.searchInput.addEventListener("input",()=>this.filterCharacters()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const t=document.createElement("div");return t.className="character-dialog-content",t.style.minWidth="500px",t.innerHTML=`
343
343
  <style>
344
344
  .character-dialog-content {
345
345
  display: flex;
@@ -426,7 +426,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
426
426
  <div class="char-info">
427
427
  Click any character to insert it into your document.
428
428
  </div>
429
- `,t}updateGrid(){const t=this.categorySelect.value;this.charactersGrid.innerHTML="";let e=[];t==="all"?e=Object.values(this.characters).flat():e=this.characters[t]||[],e.forEach(i=>{const o=document.createElement("button");o.className="char-button",o.textContent=i,o.title=`Insert ${i} (U+${i.charCodeAt(0).toString(16).toUpperCase()})`,o.addEventListener("click",n=>{n.preventDefault(),this.handleSelect(i)}),this.charactersGrid.appendChild(o)})}filterCharacters(){const t=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(i=>{const o=i.textContent||"",n=`u+${o.charCodeAt(0).toString(16)}`,s=!t||o.includes(t)||n.includes(t);i.style.display=s?"flex":"none"})}handleSelect(t){this.onSelect(t),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 K{constructor(t){this.emojis={popular:["😀","😃","😄","😁","😊","😍","🤩","😘","😗","😚","😙","🙂","🤗","🤔","🤨","😐","😑","😶","🙄","😏","👍","👎","👌","✌️","🤞","🤝","👏","🙌","👋","🤚","✋","🖐️","🖖","👊","✊","🤛","🤜","💪"],smileys:["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔"],emotions:["😳","😞","😟","😠","😡","🤬","😔","😕","🙁","😬","🥺","😣","😖","😫","😩","🥱","😤","😮","😱","😨","😰","😥","😢","😭","😪","😓","🤤","😴","😷","🤒"],gestures:["👍","👎","👌","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝️","👋","🤚","✋","🖐️","🖖","👏","🙌","👐","🤲","🤝","🙏","✍️","💅","🤳","💪","🦾","🦿"],people:["👶","👧","🧒","👦","👩","🧑","👨","👵","🧓","👴","👲","👳","🧕","👮","👷","💂","🕵️","👩‍⚕️","👨‍⚕️","👩‍🎓","👨‍🎓","👩‍🏫","👨‍🏫","👩‍⚖️","👨‍⚖️","👩‍🌾","👨‍🌾","👩‍🍳","👨‍🍳","👩‍🔧"],animals:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🙈","🙉","🙊","🐔","🐧","🐦","🐤","🐣","🐥","🦆","🦅","🦉","🦇","🐺","🐗"],nature:["🌵","🎄","🌲","🌳","🌴","🌱","🌿","☘️","🍀","🎍","🎋","🍃","🍂","🍁","🍄","🌾","💐","🌷","🌹","🥀","🌺","🌸","🌼","🌻","🌞","🌝","🌛","🌜","⭐","🌟"],food:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🌽","🥕","🧄","🧅","🥔","🍠","🥐"],objects:["⌚","📱","💻","⌨️","🖥️","🖨️","🖱️","🕹️","💾","💿","📀","📷","📹","🎥","📞","☎️","📟","📠","📺","📻","🎙️","🎚️","🎛️","🧭","⏱️","⏰","📡","🔋","🔌","💡"],symbols:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","✨","💫","⭐","🌟","✔️","✅","❌","❎","➕","➖","✖️","➗"],activities:["⚽","🏀","🏈","⚾","🥎","🎾","🏐","🏉","🥏","🎱","🪀","🏓","🏸","🏒","🏑","🥍","🏏","🪃","🥅","⛳","🪁","🏹","🎣","🤿","🥊","🥋","🎽","🛹","🛼","🛷"]},this.onSelect=t.onSelect;const e=this.createContent();this.dialog=new f({title:"Insert Emoji",content:e,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=e.querySelector("#emoji-search"),this.categorySelect=e.querySelector("#emoji-category"),this.emojisGrid=e.querySelector("#emoji-grid"),this.searchInput.addEventListener("input",()=>this.filterEmojis()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const t=document.createElement("div");return t.className="emoji-dialog-content",t.style.minWidth="500px",t.innerHTML=`
429
+ `,t}updateGrid(){const t=this.categorySelect.value;this.charactersGrid.innerHTML="";let e=[];t==="all"?e=Object.values(this.characters).flat():e=this.characters[t]||[],e.forEach(i=>{const o=document.createElement("button");o.className="char-button",o.textContent=i,o.title=`Insert ${i} (U+${i.charCodeAt(0).toString(16).toUpperCase()})`,o.addEventListener("click",n=>{n.preventDefault(),this.handleSelect(i)}),this.charactersGrid.appendChild(o)})}filterCharacters(){const t=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(i=>{const o=i.textContent||"",n=`u+${o.charCodeAt(0).toString(16)}`,r=!t||o.includes(t)||n.includes(t);i.style.display=r?"flex":"none"})}handleSelect(t){this.onSelect(t),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 X{constructor(t){this.emojis={popular:["😀","😃","😄","😁","😊","😍","🤩","😘","😗","😚","😙","🙂","🤗","🤔","🤨","😐","😑","😶","🙄","😏","👍","👎","👌","✌️","🤞","🤝","👏","🙌","👋","🤚","✋","🖐️","🖖","👊","✊","🤛","🤜","💪"],smileys:["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔"],emotions:["😳","😞","😟","😠","😡","🤬","😔","😕","🙁","😬","🥺","😣","😖","😫","😩","🥱","😤","😮","😱","😨","😰","😥","😢","😭","😪","😓","🤤","😴","😷","🤒"],gestures:["👍","👎","👌","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝️","👋","🤚","✋","🖐️","🖖","👏","🙌","👐","🤲","🤝","🙏","✍️","💅","🤳","💪","🦾","🦿"],people:["👶","👧","🧒","👦","👩","🧑","👨","👵","🧓","👴","👲","👳","🧕","👮","👷","💂","🕵️","👩‍⚕️","👨‍⚕️","👩‍🎓","👨‍🎓","👩‍🏫","👨‍🏫","👩‍⚖️","👨‍⚖️","👩‍🌾","👨‍🌾","👩‍🍳","👨‍🍳","👩‍🔧"],animals:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🙈","🙉","🙊","🐔","🐧","🐦","🐤","🐣","🐥","🦆","🦅","🦉","🦇","🐺","🐗"],nature:["🌵","🎄","🌲","🌳","🌴","🌱","🌿","☘️","🍀","🎍","🎋","🍃","🍂","🍁","🍄","🌾","💐","🌷","🌹","🥀","🌺","🌸","🌼","🌻","🌞","🌝","🌛","🌜","⭐","🌟"],food:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🌽","🥕","🧄","🧅","🥔","🍠","🥐"],objects:["⌚","📱","💻","⌨️","🖥️","🖨️","🖱️","🕹️","💾","💿","📀","📷","📹","🎥","📞","☎️","📟","📠","📺","📻","🎙️","🎚️","🎛️","🧭","⏱️","⏰","📡","🔋","🔌","💡"],symbols:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","✨","💫","⭐","🌟","✔️","✅","❌","❎","➕","➖","✖️","➗"],activities:["⚽","🏀","🏈","⚾","🥎","🎾","🏐","🏉","🥏","🎱","🪀","🏓","🏸","🏒","🏑","🥍","🏏","🪃","🥅","⛳","🪁","🏹","🎣","🤿","🥊","🥋","🎽","🛹","🛼","🛷"]},this.onSelect=t.onSelect;const e=this.createContent();this.dialog=new f({title:"Insert Emoji",content:e,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=e.querySelector("#emoji-search"),this.categorySelect=e.querySelector("#emoji-category"),this.emojisGrid=e.querySelector("#emoji-grid"),this.searchInput.addEventListener("input",()=>this.filterEmojis()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const t=document.createElement("div");return t.className="emoji-dialog-content",t.style.minWidth="500px",t.innerHTML=`
430
430
  <style>
431
431
  .emoji-dialog-content {
432
432
  display: flex;
@@ -516,5 +516,7 @@ var Editora=(function(c){"use strict";class b{constructor(t,e,i){this.doc=t,this
516
516
  <div class="emoji-info">
517
517
  Click any emoji to insert it into your document.
518
518
  </div>
519
- `,t}updateGrid(){const t=this.categorySelect.value;this.emojisGrid.innerHTML="";let e=[];t==="all"?e=Object.values(this.emojis).flat():e=this.emojis[t]||[],e.forEach(i=>{const o=document.createElement("button");o.className="emoji-button",o.textContent=i,o.title=`Insert ${i}`,o.addEventListener("click",n=>{n.preventDefault(),this.handleSelect(i)}),this.emojisGrid.appendChild(o)})}filterEmojis(){const t=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(i=>{const o=i.textContent||"",n=!t||o.includes(t);i.style.display=n?"flex":"none"})}handleSelect(t){this.onSelect(t),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()}}const S=class S{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const i=this.parseAttributes(t.attributes);Object.assign(e,i)}return t.jsConfig&&Object.assign(e,t.jsConfig),e}static parseAttributes(t){const e={};for(const[i,o]of Object.entries(t)){const n=this.kebabToCamel(i);e[n]=this.parseAttributeValue(o)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const i of t)for(const[o,n]of Object.entries(i))n!=null&&(typeof n=="object"&&!Array.isArray(n)&&e[o]?e[o]=this.merge(e[o],n):e[o]=n);return e}};S.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,spellcheck:!1,language:"en"};let w=S;class P{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const i=this.pluginRegistry.get(t);if(!i)return console.warn(`Plugin not found: ${t}`),null;const o=i();return e&&this.applyPluginConfig(o,e),this.loadedPlugins.set(t,o),o}loadMultiple(t,e){return t.map(i=>this.load(i,e)).filter(i=>i!==null)}parsePluginString(t,e){const i=t.split(/\s+/).filter(Boolean);return this.loadMultiple(i,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPluginNames(){return Array.from(this.loadedPlugins.keys())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}class A{constructor(t={}){this.changeListeners=[],this.options=t,this.engine=new E({content:t.content,plugins:t.plugins||[],readonly:t.readonly}),t.onChange&&this.onChange(t.onChange),this.engine.on("change",()=>{const e=this.getHTML();this.changeListeners.forEach(i=>i(e))})}mount(t,e){this.contentElement=t,this.toolbarElement=e,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 x({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((i,o)=>{this.execCommand(i,o)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const i=this.getHTML();this.changeListeners.forEach(o=>o(i))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setHTML(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){const i=this.engine.execCommand(t,e);return this.toolbar,i}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}onChange(t){return this.changeListeners.push(t),()=>{const e=this.changeListeners.indexOf(t);e>-1&&this.changeListeners.splice(e,1)}}registerCommand(t,e){if(typeof window!="undefined"){const i=window.__editorCommands||new Map;i.set(t,e),window.__editorCommands=i}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var t;return{getHTML:()=>this.getHTML(),setHTML:e=>this.setHTML(e),execCommand:(e,i)=>this.execCommand(e,i),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(e,i)=>this.registerCommand(e,i),onChange:e=>this.onChange(e),getState:()=>this.getState(),toolbar:{items:((t=this.options.plugins)==null?void 0:t.flatMap(e=>e.toolbar||[]))||[]}}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function V(a){return new A(a)}class H{constructor(t){this.options=t,this.containerElement=t.element;const e=this.resolvePlugins(t.plugins);this.engine=new E({content:t.content,plugins:e,readonly:t.readonly}),this.initializeDOM()}resolvePlugins(t){return t?typeof t=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):t:[]}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 x({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((t,e)=>{this.execCommand(t,e)}),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 t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){return this.engine.execCommand(t,e)}focus(){var t;(t=this.contentElement)==null||t.focus()}on(t,e){const i=o=>{e(o.detail)};return this.containerElement.addEventListener(t,i),()=>{this.containerElement.removeEventListener(t,i)}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.containerElement.innerHTML=""}}const _='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{background:#1e1e1e;color:#d4d4d4;border-color:#3c3c3c}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:#252526;border-bottom-color:#3c3c3c}.editora-toolbar-sticky{position:sticky;top:0;z-index:100}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border-left:1px solid #ccc;border-top-right-radius:3px;border-bottom-right-radius:3px}}}.editora-theme-dark .editora-toolbar-button{color:#d4d4d4}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:#37373d;border-color:#555}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:#2a2d2e;border-color:#666}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:24px;height:24px;display:block}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#3c3c3c}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#252526;border-color:#3c3c3c;box-shadow:0 2px 8px #00000080}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d4d4d4}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#37373d}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#6a6a6a}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#4db8ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#9a9a9a}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#252526;border-color:#3c3c3c;box-shadow:0 2px 8px #00000080}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:#252526;border-top-color:#3c3c3c;color:#9a9a9a}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#3c3c3c}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}';let C;function X(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const t=document.createElement("style");t.id=a,t.textContent=_,document.head.appendChild(t)}}function J(){if(!C){const a=k.__globalPluginLoader;a?C=a:C=new P}return C}class k extends HTMLElement{constructor(){if(super(),this.config={},this.isInitialized=!1,this.pluginLoader=J(),X(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","readonly","disabled","theme","placeholder","autofocus","language","spellcheck"]}connectedCallback(){this.config=this.resolveConfig(),setTimeout(()=>{this.initialize()},0)}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,i){e!==i&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,i))}setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),this.initialize())}initialize(){if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const t=this.loadPlugins();t.forEach(i=>{if(i.init&&typeof i.init=="function")try{i.init()}catch(o){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,o)}});const e=this.getAttribute("data-initial-content")||"";this.engine=new E({content:e,plugins:t,readonly:this.config.readonly}),this.createUI(t,e),this.setupEventListeners(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(i=>i.nodeType===Node.TEXT_NODE?i.textContent:i.nodeType===Node.ELEMENT_NODE?i.outerHTML:"").join("").trim():""}loadPlugins(){const t=[];if(this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0))if(typeof this.config.plugins=="string"){const i=this.pluginLoader.parsePluginString(this.config.plugins);t.push(...i)}else Array.isArray(this.config.plugins)&&this.config.plugins.forEach(i=>{if(typeof i=="string"){const o=this.pluginLoader.load(i);o&&t.push(o)}else t.push(i)});else{const i=this.pluginLoader.getRegisteredPluginNames(),o=this.pluginLoader.loadMultiple(i);t.push(...o)}return t}createUI(t,e){const i=this.querySelector('[slot="toolbar"]'),o=this.querySelector('[slot="statusbar"]');if(this.innerHTML="",this.config.toolbar!==!1&&!i){this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement);const n=this.config.toolbarItems||this.config.toolbar;this.toolbar=new x({items:typeof n=="string"?n:void 0,sticky:this.config.toolbar&&typeof this.config.toolbar=="object"?this.config.toolbar.sticky:!1,position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((s,r)=>{var p,u;if(this.contentElement){this.contentElement.focus();const m=window.getSelection();if(!m||m.rangeCount===0||!this.contentElement.contains(m.anchorNode)){const d=document.createRange(),h=this.contentElement.lastChild||this.contentElement;h.nodeType===Node.TEXT_NODE?d.setStart(h,((p=h.textContent)==null?void 0:p.length)||0):h.nodeType===Node.ELEMENT_NODE?(d.selectNodeContents(h),d.collapse(!1)):d.setStart(this.contentElement,0),d.collapse(!0),m==null||m.removeAllRanges(),m==null||m.addRange(d)}}const l=t.find(m=>m.commands&&m.commands[s]);if(l&&l.commands){const m=l.commands[s];if(typeof m=="function")try{return m(s==="toggleFullscreen"?this:r)}catch(d){return console.error(`[RichTextEditor] Error executing native command ${s}:`,d),!1}}return((u=this.engine)==null?void 0:u.execCommand(s,r))||!1}),this.toolbar.render(this.toolbarElement)}else i&&this.appendChild(i);this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(n){console.warn("defaultParagraphSeparator not supported:",n)}if(e){const n=document.createElement("div");n.innerHTML=e.trim(),!Array.from(n.childNodes).some(r=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(l)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.config.toolbar&&typeof this.config.toolbar=="object"&&this.config.toolbar.floating&&(this.floatingToolbar=new I({enabled:!0}),this.floatingToolbar.create(this)),o?this.appendChild(o):this.config.statusbar&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new D({position:"bottom"}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var n;return(n=this.contentElement)==null?void 0:n.focus()},0)}setupEventListeners(){!this.contentElement||!this.engine||(this.contentElement.addEventListener("input",()=>{const t=this.contentElement.innerHTML;if(this.dispatchEvent(new CustomEvent("content-change",{detail:{html:t},bubbles:!0})),this.statusBar){const e=this.contentElement.textContent||"",i=e.trim().split(/\s+/).filter(Boolean).length,o=e.length;this.statusBar.update({wordCount:i,charCount:o})}}),this.contentElement.addEventListener("focus",()=>{this.dispatchEvent(new Event("editor-focus",{bubbles:!0}))}),this.contentElement.addEventListener("blur",()=>{this.dispatchEvent(new Event("editor-blur",{bubbles:!0}))}),this.floatingToolbar&&document.addEventListener("selectionchange",()=>{this.updateFloatingToolbar()}))}updateFloatingToolbar(){if(!this.floatingToolbar)return;const t=window.getSelection();if(!t||t.rangeCount===0){this.floatingToolbar.hide();return}const e=t.getRangeAt(0);if(e.collapsed){this.floatingToolbar.hide();return}const i=e.getBoundingClientRect();this.floatingToolbar.show(i.left,i.top-40)}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=e==="true"?"false":"true"),this.engine&&this.engine.setReadonly(e==="true");break;case"theme":this.classList.forEach(i=>{i.startsWith("editora-theme-")&&this.classList.remove(i)}),e&&this.classList.add(`editora-theme-${e}`);break;case"placeholder":this.contentElement&&this.contentElement.setAttribute("data-placeholder",e);break;case"toolbar":case"plugins":this.isConnected&&(this.destroy(),this.initialize());break}}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const i=this.attributes[e];t[i.name]=i.value}return w.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>{var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""},setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=t)},execCommand:(t,e)=>{var i;return((i=this.engine)==null?void 0:i.execCommand(t,e))||!1},focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,i,o;(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(i=this.floatingToolbar)==null||i.destroy(),(o=this.statusBar)==null||o.destroy(),this.innerHTML="",this.isInitialized=!1,this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){var i;return((i=this.engine)==null?void 0:i.execCommand(t,e))||!1}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}function Y(a){return new H(a)}function Q(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",k)}return c.CharacterDialog=W,c.ColorPicker=q,c.CommandRegistry=T,c.ConfigResolver=w,c.Dialog=f,c.DocumentModel=y,c.Dropdown=z,c.Editor=F,c.EditorEngine=E,c.EditorState=b,c.EmojiDialog=K,c.FloatingToolbar=I,c.ImageDialog=U,c.KeyboardShortcutManager=$,c.LinkDialog=B,c.MathDialog=G,c.PluginLoader=P,c.PluginManager=v,c.PluginRuntime=M,c.ReactAdapter=A,c.RichTextEditorElement=k,c.Schema=L,c.StatusBar=D,c.TableDialog=O,c.ToolbarRenderer=x,c.VanillaAdapter=H,c.createEditor=Y,c.createMediaPlugin=R,c.createPluginRuntime=j,c.createReactAdapter=V,c.createSpellcheckPlugin=N,c.initWebComponent=Q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c})({});
519
+ `,t}updateGrid(){const t=this.categorySelect.value;this.emojisGrid.innerHTML="";let e=[];t==="all"?e=Object.values(this.emojis).flat():e=this.emojis[t]||[],e.forEach(i=>{const o=document.createElement("button");o.className="emoji-button",o.textContent=i,o.title=`Insert ${i}`,o.addEventListener("click",n=>{n.preventDefault(),this.handleSelect(i)}),this.emojisGrid.appendChild(o)})}filterEmojis(){const t=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(i=>{const o=i.textContent||"",n=!t||o.includes(t);i.style.display=n?"flex":"none"})}handleSelect(t){this.onSelect(t),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()}}function D(a,t){const e=a.textContent||"",i=P(a,t.startContainer,t.startOffset),n=e.substring(0,i).split(`
520
+ `),r=n.length,s=n[n.length-1].length+1;return{line:r,column:s}}function P(a,t,e){var r;let i=0;const o=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let n=o.firstChild();for(;n;){if(n===t){i+=e;break}else n.nodeType===Node.TEXT_NODE&&(i+=((r=n.textContent)==null?void 0:r.length)||0);n=o.nextNode()}return i}function A(a){var i,o;const t=a.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let e=1;if(t.length>0){e=t.length;const n=t[t.length-1];(n.tagName==="BR"||((i=n.innerHTML)==null?void 0:i.trim())===""||((o=n.textContent)==null?void 0:o.trim())==="")&&e++}else{const r=(a.textContent||"").split(`
521
+ `).length;e=Math.max(1,r)}return e}function H(a){const t=a.trim()?a.trim().split(/\s+/).length:0,e=a.length;return{words:t,chars:e}}function F(a,t){const e=a.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}const k=class k{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const i=this.parseAttributes(t.attributes);Object.assign(e,i)}return t.jsConfig&&Object.assign(e,t.jsConfig),e}static parseAttributes(t){const e={};for(const[i,o]of Object.entries(t)){const n=this.kebabToCamel(i);e[n]=this.parseAttributeValue(o)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,i)=>i.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const i of t)for(const[o,n]of Object.entries(i))n!=null&&(typeof n=="object"&&!Array.isArray(n)&&e[o]?e[o]=this.merge(e[o],n):e[o]=n);return e}};k.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,spellcheck:!1,language:"en"};let C=k;class Y{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}async load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const i=this.pluginRegistry.get(t);if(!i)return console.warn(`Plugin not found: ${t}`),null;const o=await i();return e&&this.applyPluginConfig(o,e),this.loadedPlugins.set(t,o),o}async loadMultiple(t,e){return(await Promise.all(t.map(o=>this.load(o,e)))).filter(o=>o!==null)}async parsePluginString(t,e){const i=t.split(/\s+/).filter(Boolean);return this.loadMultiple(i,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}class ${constructor(t={}){this.changeListeners=[],this.options=t,this.engine=new w({content:t.content,plugins:t.plugins||[],readonly:t.readonly}),t.onChange&&this.onChange(t.onChange),this.engine.on("change",()=>{const e=this.getHTML();this.changeListeners.forEach(i=>i(e))})}mount(t,e){this.contentElement=t,this.toolbarElement=e,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 E({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((i,o)=>{this.execCommand(i,o)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const i=this.getHTML();this.changeListeners.forEach(o=>o(i))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setHTML(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){const i=this.engine.execCommand(t,e);return this.toolbar,i}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}onChange(t){return this.changeListeners.push(t),()=>{const e=this.changeListeners.indexOf(t);e>-1&&this.changeListeners.splice(e,1)}}registerCommand(t,e){if(typeof window!="undefined"){const i=window.__editorCommands||new Map;i.set(t,e),window.__editorCommands=i}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var t;return{getHTML:()=>this.getHTML(),setHTML:e=>this.setHTML(e),execCommand:(e,i)=>this.execCommand(e,i),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(e,i)=>this.registerCommand(e,i),onChange:e=>this.onChange(e),getState:()=>this.getState(),toolbar:{items:((t=this.options.plugins)==null?void 0:t.flatMap(e=>e.toolbar||[]))||[]}}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function J(a){return new $(a)}class j{constructor(t){this.options=t,this.containerElement=t.element;const e=this.resolvePlugins(t.plugins);this.engine=new w({content:t.content,plugins:e,readonly:t.readonly}),this.initializeDOM()}resolvePlugins(t){return t?typeof t=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):t:[]}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 E({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((t,e)=>{this.execCommand(t,e)}),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 t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){return this.engine.execCommand(t,e)}focus(){var t;(t=this.contentElement)==null||t.focus()}on(t,e){const i=o=>{e(o.detail)};return this.containerElement.addEventListener(t,i),()=>{this.containerElement.removeEventListener(t,i)}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.containerElement.innerHTML=""}}const Q='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{background:#1e1e1e;color:#d4d4d4;border-color:#3c3c3c}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:#252526;border-bottom-color:#3c3c3c}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border-left:1px solid #ccc;border-top-right-radius:3px;border-bottom-right-radius:3px}}}.editora-theme-dark .editora-toolbar-button{color:#d4d4d4}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:#37373d;border-color:#555}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:#2a2d2e;border-color:#666}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:24px;height:24px;display:block}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#3c3c3c}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#252526;border-color:#3c3c3c;box-shadow:0 2px 8px #00000080}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d4d4d4}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#37373d}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#6a6a6a}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#4db8ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#9a9a9a}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#252526;border-color:#3c3c3c;box-shadow:0 2px 8px #00000080}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:#252526;border-top-color:#3c3c3c;color:#9a9a9a}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#3c3c3c}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';function Z(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const t=document.createElement("style");t.id=a,t.textContent=Q,document.head.appendChild(t)}}class b extends HTMLElement{constructor(){if(super(),this.config={},this.isInitialized=!1,Z(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","readonly","disabled","theme","placeholder","autofocus","language","spellcheck","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(b.__globalPluginLoader){this.pluginLoader=b.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{b.__globalPluginLoader?(this.pluginLoader=b.__globalPluginLoader,t()):setTimeout(e,0)};e()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,i){e!==i&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,i))}async setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const t=await this.loadPlugins();t.forEach(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(o){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,o)}});const e=this.getAttribute("data-initial-content")||"";this.engine=new w({content:e,plugins:t,readonly:this.config.readonly}),this.createUI(t,e),this.setupEventListeners(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(i=>i.nodeType===Node.TEXT_NODE?i.textContent:i.nodeType===Node.ELEMENT_NODE?i.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const t=[];if(this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0)){if(typeof this.config.plugins=="string"){const i=await this.pluginLoader.parsePluginString(this.config.plugins);t.push(...i)}else if(Array.isArray(this.config.plugins))for(const i of this.config.plugins)if(typeof i=="string"){const o=await this.pluginLoader.load(i);o&&t.push(o)}else t.push(i)}else{const i=this.pluginLoader.getRegisteredPluginNames(),o=await this.pluginLoader.loadMultiple(i);t.push(...o)}return t}createUI(t,e){const i=this.querySelector('[slot="toolbar"]'),o=this.querySelector('[slot="statusbar"]');if(this.innerHTML="",this.config.toolbar!==!1&&!i){this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement);const n=this.config.toolbarItems||this.config.toolbar;this.toolbar=new E({items:typeof n=="string"?n:void 0,sticky:this.config.toolbar&&typeof this.config.toolbar=="object"?this.config.toolbar.sticky:!1,position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((r,s)=>{var m,u;if(this.contentElement){this.contentElement.focus();const p=window.getSelection();if(!p||p.rangeCount===0||!this.contentElement.contains(p.anchorNode)){const d=document.createRange(),h=this.contentElement.lastChild||this.contentElement;h.nodeType===Node.TEXT_NODE?d.setStart(h,((m=h.textContent)==null?void 0:m.length)||0):h.nodeType===Node.ELEMENT_NODE?(d.selectNodeContents(h),d.collapse(!1)):d.setStart(this.contentElement,0),d.collapse(!0),p==null||p.removeAllRanges(),p==null||p.addRange(d)}}const l=t.find(p=>p.commands&&p.commands[r]);if(l&&l.commands){const p=l.commands[r];if(typeof p=="function")try{return p(r==="toggleFullscreen"?this:s)}catch(d){return console.error(`[RichTextEditor] Error executing native command ${r}:`,d),!1}}return((u=this.engine)==null?void 0:u.execCommand(r,s))||!1}),this.toolbar.render(this.toolbarElement)}else i&&this.appendChild(i);this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(n){console.warn("defaultParagraphSeparator not supported:",n)}if(e){const n=document.createElement("div");n.innerHTML=e.trim(),!Array.from(n.childNodes).some(s=>{if(s.nodeType===Node.ELEMENT_NODE){const l=s.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(l)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.config.toolbar&&typeof this.config.toolbar=="object"&&this.config.toolbar.floating&&(this.floatingToolbar=new T({enabled:!0}),this.floatingToolbar.create(this)),o?this.appendChild(o):this.config.statusbar&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new I({position:"bottom"}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var n;return(n=this.contentElement)==null?void 0:n.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;this.contentElement.addEventListener("input",()=>{const e=this.contentElement.innerHTML;this.dispatchEvent(new CustomEvent("content-change",{detail:{html:e},bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("focus",()=>{this.dispatchEvent(new Event("editor-focus",{bubbles:!0}))}),this.contentElement.addEventListener("blur",()=>{this.dispatchEvent(new Event("editor-blur",{bubbles:!0}))});const t=()=>{this.updateFloatingToolbar(),this.updateStatusBar()};document.addEventListener("selectionchange",t)}updateFloatingToolbar(){if(!this.floatingToolbar)return;const t=window.getSelection();if(!t||t.rangeCount===0){this.floatingToolbar.hide();return}const e=t.getRangeAt(0);if(e.collapsed){this.floatingToolbar.hide();return}const i=e.getBoundingClientRect();this.floatingToolbar.show(i.left,i.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const t=this.contentElement.textContent||"",{words:e,chars:i}=H(t),o=A(this.contentElement),n=window.getSelection();let r,s;if(n&&n.rangeCount>0){const l=n.getRangeAt(0);r=D(this.contentElement,l),l.collapsed||(s=F(l,r),r=void 0)}this.statusBar.update({wordCount:e,charCount:i,lineCount:o,cursorPosition:r,selectionInfo:s})}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=e==="true"?"false":"true"),this.engine&&this.engine.setReadonly(e==="true");break;case"theme":this.classList.forEach(i=>{i.startsWith("editora-theme-")&&this.classList.remove(i)}),e&&this.classList.add(`editora-theme-${e}`);break;case"placeholder":this.contentElement&&this.contentElement.setAttribute("data-placeholder",e);break;case"toolbar":case"plugins":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(i=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",i)})}));break}}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const i=this.attributes[e];t[i.name]=i.value}return C.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>{var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""},setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=t)},execCommand:(t,e)=>{var i;return((i=this.engine)==null?void 0:i.execCommand(t,e))||!1},focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,i,o;(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(i=this.floatingToolbar)==null||i.destroy(),(o=this.statusBar)==null||o.destroy(),this.innerHTML="",this.isInitialized=!1,this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){var i;return((i=this.engine)==null?void 0:i.execCommand(t,e))||!1}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}function tt(a){return new j(a)}function et(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",b)}return c.CharacterDialog=_,c.ColorPicker=U,c.CommandRegistry=M,c.ConfigResolver=C,c.Dialog=f,c.DocumentModel=x,c.Dropdown=O,c.Editor=z,c.EditorEngine=w,c.EditorState=y,c.EmojiDialog=X,c.FloatingToolbar=T,c.ImageDialog=K,c.KeyboardShortcutManager=q,c.LinkDialog=W,c.MathDialog=V,c.MediaPlugin=B,c.PluginLoader=Y,c.PluginManager=v,c.PluginRuntime=L,c.ReactAdapter=$,c.RichTextEditorElement=b,c.Schema=S,c.SpellcheckPlugin=R,c.StatusBar=I,c.TableDialog=G,c.ToolbarRenderer=E,c.VanillaAdapter=j,c.calculateTextStats=H,c.countLines=A,c.createEditor=tt,c.createPluginRuntime=N,c.createReactAdapter=J,c.getCursorPosition=D,c.getSelectionInfo=F,c.getTextOffset=P,c.initWebComponent=et,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c})({});
520
522
  //# sourceMappingURL=editora.min.js.map