@editora/plugins 1.0.2 → 1.0.5

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 (105) hide show
  1. package/README.md +30 -5
  2. package/dist/a11y-checker.cjs.js +109 -0
  3. package/dist/a11y-checker.esm.js +509 -0
  4. package/dist/anchor.cjs.js +176 -0
  5. package/dist/anchor.esm.js +400 -0
  6. package/dist/background-color.cjs.js +218 -0
  7. package/dist/background-color.esm.js +482 -0
  8. package/dist/blockquote.cjs.js +1 -0
  9. package/dist/blockquote.esm.js +47 -0
  10. package/dist/bold.cjs.js +1 -0
  11. package/dist/bold.esm.js +44 -0
  12. package/dist/capitalization.cjs.js +1 -0
  13. package/dist/capitalization.esm.js +78 -0
  14. package/dist/checklist.cjs.js +1 -0
  15. package/dist/checklist.esm.js +305 -0
  16. package/dist/clear-formatting.cjs.js +1 -0
  17. package/dist/clear-formatting.esm.js +138 -0
  18. package/dist/code-sample.cjs.js +161 -0
  19. package/dist/code-sample.esm.js +381 -0
  20. package/dist/code.cjs.js +606 -0
  21. package/dist/code.esm.js +2164 -0
  22. package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
  23. package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
  24. package/dist/comments.cjs.js +354 -0
  25. package/dist/comments.esm.js +692 -0
  26. package/dist/direction.cjs.js +1 -0
  27. package/dist/direction.esm.js +129 -0
  28. package/dist/document-manager.cjs.js +1 -0
  29. package/dist/document-manager.esm.js +6 -0
  30. package/dist/{documentManager-CYC9totK.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
  31. package/dist/{documentManager-BGlu3WRB.js → documentManager-_tQQfQi9.js} +3 -3
  32. package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
  33. package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
  34. package/dist/embed-iframe.cjs.js +361 -0
  35. package/dist/embed-iframe.esm.js +556 -0
  36. package/dist/emojis.cjs.js +284 -0
  37. package/dist/emojis.esm.js +1080 -0
  38. package/dist/font-family.cjs.js +1 -0
  39. package/dist/font-family.esm.js +152 -0
  40. package/dist/font-size.cjs.js +1 -0
  41. package/dist/font-size.esm.js +278 -0
  42. package/dist/footnote.cjs.js +85 -0
  43. package/dist/footnote.esm.js +397 -0
  44. package/dist/fullscreen.cjs.js +1 -0
  45. package/dist/fullscreen.esm.js +73 -0
  46. package/dist/heading.cjs.js +1 -0
  47. package/dist/heading.esm.js +63 -0
  48. package/dist/history.cjs.js +1 -0
  49. package/dist/history.esm.js +246 -0
  50. package/dist/indent.cjs.js +1 -0
  51. package/dist/indent.esm.js +146 -0
  52. package/dist/index-Bskk414V.mjs +145 -0
  53. package/dist/index-D3pJyAsj.js +1 -0
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/{index.es-B-to-4j4.js → index.es-Cz1qItab.js} +1 -1
  56. package/dist/{index.es-BbXJ7tyO.mjs → index.es-DEcRmSTY.mjs} +1 -1
  57. package/dist/index.esm.js +89 -49
  58. package/dist/italic.cjs.js +1 -0
  59. package/dist/italic.esm.js +40 -0
  60. package/dist/line-height.cjs.js +1 -0
  61. package/dist/line-height.esm.js +145 -0
  62. package/dist/link.cjs.js +138 -0
  63. package/dist/link.esm.js +276 -0
  64. package/dist/list.cjs.js +1 -0
  65. package/dist/list.esm.js +102 -0
  66. package/dist/lite.cjs.js +1 -0
  67. package/dist/lite.esm.js +61 -0
  68. package/dist/math.cjs.js +45 -0
  69. package/dist/math.esm.js +249 -0
  70. package/dist/media-manager.cjs.js +619 -0
  71. package/dist/media-manager.esm.js +994 -0
  72. package/dist/merge-tag.cjs.js +93 -0
  73. package/dist/merge-tag.esm.js +412 -0
  74. package/dist/page-break.cjs.js +72 -0
  75. package/dist/page-break.esm.js +295 -0
  76. package/dist/plugins.css +1 -1
  77. package/dist/preview.cjs.js +230 -0
  78. package/dist/preview.esm.js +321 -0
  79. package/dist/print.cjs.js +254 -0
  80. package/dist/print.esm.js +309 -0
  81. package/dist/purify.es-DHhaBdbu.mjs +470 -0
  82. package/dist/purify.es-T2a3nLiC.js +3 -0
  83. package/dist/shared-config.cjs.js +1 -0
  84. package/dist/shared-config.esm.js +30 -0
  85. package/dist/special-characters.cjs.js +257 -0
  86. package/dist/special-characters.esm.js +772 -0
  87. package/dist/spell-check.cjs.js +512 -0
  88. package/dist/spell-check.esm.js +1013 -0
  89. package/dist/strikethrough.cjs.js +1 -0
  90. package/dist/strikethrough.esm.js +71 -0
  91. package/dist/table.cjs.js +35 -0
  92. package/dist/table.esm.js +477 -0
  93. package/dist/template.cjs.js +356 -0
  94. package/dist/template.esm.js +560 -0
  95. package/dist/text-alignment.cjs.js +1 -0
  96. package/dist/text-alignment.esm.js +105 -0
  97. package/dist/text-color.cjs.js +300 -0
  98. package/dist/text-color.esm.js +507 -0
  99. package/dist/underline.cjs.js +1 -0
  100. package/dist/underline.esm.js +34 -0
  101. package/index.d.ts +62 -0
  102. package/package.json +220 -7
  103. package/LICENSE +0 -21
  104. package/dist/index-BbORIHoM.mjs +0 -11763
  105. package/dist/index-C-OCBS_6.js +0 -3753
@@ -1,3753 +0,0 @@
1
- "use strict";const Di=()=>{const n=e=>{try{return document.execCommand("formatBlock",!1,e),!0}catch(t){return console.error(`Failed to set block type to ${e}:`,t),!1}};return{name:"heading",toolbar:[{label:"Heading",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:e=>e?n(e):!1,setHeading1:()=>n("h1"),setHeading2:()=>n("h2"),setHeading3:()=>n("h3"),setParagraph:()=>n("p")},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}}},_i=()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:n=>{const e=typeof n=="string"?n:n.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:()=>(document.execCommand("bold",!1),!0)},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}}),Mr=()=>(document.execCommand("italic",!1),!0),Hi=(n,e)=>{typeof window<"u"&&window.registerEditorCommand?.(n,e)},Do=()=>{Hi("toggleItalic",Mr)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Do):Do());const Pi=()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:Mr},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}}),Oi=()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:()=>(document.execCommand("underline",!1),!0)},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}}),$i=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:n=>(typeof n=="string"?n:n.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:()=>(document.execCommand("strikeThrough",!1),!0)},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}}),Nr=()=>(document.execCommand("insertUnorderedList",!1),!0),Rr=()=>(document.execCommand("insertOrderedList",!1),!0),_o=(n,e)=>{typeof window<"u"&&window.registerEditorCommand?.(n,e)},Ho=()=>{_o("toggleBulletList",Nr),_o("toggleOrderedList",Rr)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ho):Ho());const Bi=()=>({name:"list",nodes:{bulletList:{content:"listItem+",group:"block",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},orderedList:{content:"listItem+",group:"block",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",0]},listItem:{content:"paragraph",parseDOM:[{tag:"li"}],toDOM:()=>["li",0]}},toolbar:[{label:"Bullet List",command:"toggleBulletList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M11 5h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2ZM4.5 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-8"},{label:"Numbered List",command:"toggleOrderedList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M10 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 1 1 0-2ZM6 4v3.5c0 .3-.2.5-.5.5a.5.5 0 0 1-.5-.5V5h-.5a.5.5 0 0 1 0-1H6Zm-1 8.8l.2.2h1.3c.3 0 .5.2.5.5s-.2.5-.5.5H4.9a1 1 0 0 1-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 0 0 0-.2l-.7.3a.5.5 0 0 1-.7-.3.5.5 0 0 1 .3-.6l.7-.4c.5-.2 1.1 0 1.4.4.3.5.3 1.1-.1 1.5l-1.2.7Zm0 3.7v.5c0 .3.2.5.5.5h1c.3 0 .5.2.5.5s-.2.5-.5.5h-1a1.5 1.5 0 0 1-1.5-1.5v-.5c0-.3.1-.6.3-.8l1.3-1.4c.3-.4.1-.9-.2-1-.1 0-.2 0-.3.2l-.4.5a.5.5 0 0 1-.7.1.5.5 0 0 1-.1-.7l.4-.5c.5-.5 1.2-.6 1.8-.4.6.3 1 .9 1 1.6 0 .4-.2.8-.5 1.1l-1.3 1.4-.3.4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-7"}],commands:{toggleBulletList:Nr,toggleOrderedList:Rr},keymap:{"Mod-Shift-8":"toggleBulletList","Mod-Shift-7":"toggleOrderedList"}}),Fi=()=>{const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},qi=()=>({name:"checklist",init:()=>{if(typeof document<"u"&&typeof window<"u"){const n=e=>{const o=e.target.closest('li[data-type="checklist-item"]');if(o){const r=o.getBoundingClientRect();if(e.clientX-r.left<32){e.preventDefault(),e.stopPropagation();const l=o.getAttribute("data-checked")==="true";o.setAttribute("data-checked",(!l).toString())}}};document.addEventListener("click",n)}},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:n=>({checked:n.getAttribute("data-checked")==="true"})}],toDOM:n=>["li",{"data-type":"checklist-item","data-checked":n?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const n=Fi();if(!n)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);if(!n.contains(t.commonAncestorContainer))return!1;const o=t.commonAncestorContainer.nodeType===Node.TEXT_NODE?t.commonAncestorContainer.parentElement:t.commonAncestorContainer,r=o?.closest("li")?.closest("ul, ol");if(r){const l=r.hasAttribute("data-type")&&r.getAttribute("data-type")==="checklist",c=r.tagName.toLowerCase()==="ol",s=r.tagName.toLowerCase()==="ul"&&!r.hasAttribute("data-type");if(l){const d=r.querySelectorAll('li[data-type="checklist-item"]'),p=Array.from(d).map(g=>`<p>${g.innerHTML}</p>`).join("");return r.outerHTML=p,setTimeout(()=>{const g=window.getSelection();if(g&&n)try{const m=n.querySelectorAll("p"),b=o?.closest('li[data-type="checklist-item"]'),x=b?Array.from(d).indexOf(b):-1;if(m[x]&&x>=0){const C=m[x],k=document.createRange();k.setStart(C,C.childNodes.length),k.setEnd(C,C.childNodes.length),g.removeAllRanges(),g.addRange(k)}}catch{console.warn("Could not restore selection after checklist removal")}},10),!0}else if(c||s)return r.setAttribute("data-type","checklist"),r.querySelectorAll("li").forEach(d=>{d.setAttribute("data-type","checklist-item"),d.setAttribute("data-checked","false")}),!0}const i=t.toString().trim(),a=o?.closest("p, div, h1, h2, h3, h4, h5, h6");if(a){const c=`<ul data-type="checklist"><li data-type="checklist-item" data-checked="false"><p>${i||a.innerHTML}</p></li></ul>`,s=document.createElement("div");s.innerHTML=c;const d=s.firstElementChild;return a.parentNode?.replaceChild(d,a),setTimeout(()=>{const p=window.getSelection();if(p)try{const g=d.querySelector('li[data-type="checklist-item"]');if(g){const m=g.querySelector("p");if(m&&m.firstChild){const b=document.createRange();b.setStart(m.firstChild,m.textContent?.length||0),b.collapse(!0),p.removeAllRanges(),p.addRange(b)}}}catch(g){console.warn("Could not restore selection after checklist insertion:",g)}},10),!0}else return console.warn("[ChecklistPlugin] No block element found"),!1;return!0}catch(n){return console.error("Failed to toggle checklist:",n),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}}),ct=[],dt=[],Nt={},Le=(n,e)=>{Nt[n]=e,typeof window<"u"&&(window.registerEditorCommand||(window.registerEditorCommand=(t,o)=>{Nt[t]=o}),window.registerEditorCommand(n,e))},ji=(n,...e)=>{Nt[n]&&Nt[n](...e)},zr=()=>(document.execCommand("undo",!1),!0),Ir=()=>(document.execCommand("redo",!1),!0),Dr=(n,e,t)=>{const o=n.getAttribute(e);n.setAttribute(e,t),ct.push(()=>{o==null?n.removeAttribute(e):n.setAttribute(e,o)}),dt.length=0},_r=(n,e)=>{const t=n.textContent;n.textContent=e,ct.push(()=>{n.textContent=t??""}),dt.length=0},Hr=n=>{const e=n.element;if(!e)return;const t=window.a11yRuleRegistry?.find(r=>r.id===n.rule);let o=null;if(t&&t.fix){const r={};for(const i of e.getAttributeNames())r[i]=e.getAttribute(i);t.fix(n),o=()=>{for(const i of Object.keys(r))r[i]==null?e.removeAttribute(i):e.setAttribute(i,r[i])}}o&&ct.push(o),dt.length=0},Pr=()=>{const n=ct.pop();n&&(n(),dt.push(n))},Or=()=>{const n=dt.pop();n&&(n(),ct.push(n))},Po=()=>{typeof window>"u"||(window.execEditorCommand||(window.execEditorCommand=ji),Le("undo",zr),Le("redo",Ir),Le("setAttribute",Dr),Le("setText",_r),Le("autoFixA11y",Hr),Le("undoDom",Pr),Le("redoDom",Or))};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Po):Po());const Vi=()=>({name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:zr,redo:Ir,setAttribute:Dr,setText:_r,autoFixA11y:Hr,undoDom:Pr,redoDom:Or},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});let he=null,Rt=!1,ee=null;const Ui=n=>{if(!n)return null;let e=n;for(;e;){if(e.hasAttribute("contenteditable")&&e.getAttribute("contenteditable")==="true"||e.hasAttribute("data-editora-content"))return e;e=e.parentElement}return null},Wi=n=>{if(!he){console.warn("No selection range stored");return}const e=he.startContainer,t=e.nodeType===Node.TEXT_NODE?e.parentElement:e,o=Ui(t);if(o){if(Rt&&ee){ee.href=n.url,ee.textContent=n.text,ee.target=n.target,n.target==="_blank"?ee.setAttribute("rel","noopener noreferrer"):ee.removeAttribute("rel"),n.title?ee.title=n.title:ee.removeAttribute("title");const r=document.createRange();r.selectNodeContents(ee);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}else{const r=document.createElement("a");r.href=n.url,r.textContent=n.text,r.target=n.target,n.target==="_blank"&&r.setAttribute("rel","noopener noreferrer"),n.title&&(r.title=n.title),he.deleteContents(),he.insertNode(r),he.setStartAfter(r),he.setEndAfter(r);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(he))}o.focus(),he=null,Rt=!1,ee=null}},Oo=n=>{const e=document.createElement("div");e.className="link-dialog-overlay",e.style.cssText=`
2
- position: fixed;
3
- top: 0;
4
- left: 0;
5
- right: 0;
6
- bottom: 0;
7
- background: rgba(0, 0, 0, 0.5);
8
- display: flex;
9
- align-items: center;
10
- justify-content: center;
11
- z-index: 10000;
12
- `;const t=document.createElement("div");t.className="link-dialog",t.style.cssText=`
13
- background: white;
14
- border-radius: 8px;
15
- width: 500px;
16
- max-width: 90%;
17
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
18
- `,t.innerHTML=`
19
- <div class="link-dialog-header" style="padding: 16px 20px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center;">
20
- <h3 style="margin: 0; font-size: 18px;">${n.isEditing?"Edit Link":"Insert Link"}</h3>
21
- <button class="link-dialog-close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px;">×</button>
22
- </div>
23
- <form id="link-form">
24
- <div class="link-dialog-body" style="padding: 20px;">
25
- <div class="form-group" style="margin-bottom: 16px;">
26
- <label for="link-text" style="display: block; margin-bottom: 6px; font-weight: 500;">Link Text:</label>
27
- <input
28
- id="link-text"
29
- type="text"
30
- value="${n.text||""}"
31
- placeholder="Enter link text"
32
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
33
- />
34
- </div>
35
- <div class="form-group" style="margin-bottom: 16px;">
36
- <label for="link-url" style="display: block; margin-bottom: 6px; font-weight: 500;">URL:</label>
37
- <input
38
- id="link-url"
39
- type="url"
40
- value="${n.url||""}"
41
- placeholder="https://example.com"
42
- required
43
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
44
- />
45
- </div>
46
- <div class="form-group" style="margin-bottom: 16px;">
47
- <label for="link-title" style="display: block; margin-bottom: 6px; font-weight: 500;">Title (optional):</label>
48
- <input
49
- id="link-title"
50
- type="text"
51
- value="${n.title||""}"
52
- placeholder="Link tooltip text"
53
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
54
- />
55
- </div>
56
- <div class="form-group" style="margin-bottom: 0;">
57
- <label style="display: flex; align-items: center; cursor: pointer;">
58
- <input
59
- id="link-target"
60
- type="checkbox"
61
- ${n.target==="_blank"?"checked":""}
62
- style="margin-right: 8px;"
63
- />
64
- Open in new window/tab
65
- </label>
66
- </div>
67
- </div>
68
- <div class="link-dialog-footer" style="padding: 12px 20px; border-top: 1px solid #ddd; display: flex; justify-content: flex-end; gap: 10px;">
69
- <button type="button" class="btn-cancel" style="padding: 8px 16px; border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer;">Cancel</button>
70
- <button type="submit" class="btn-submit" style="padding: 8px 16px; border: none; background: #007bff; color: white; border-radius: 4px; cursor: pointer;">
71
- ${n.isEditing?"Update Link":"Insert Link"}
72
- </button>
73
- </div>
74
- </form>
75
- `,e.appendChild(t),document.body.appendChild(e);const o=t.querySelector("#link-form"),r=t.querySelector("#link-text"),i=t.querySelector("#link-url"),a=t.querySelector("#link-title"),l=t.querySelector("#link-target"),c=t.querySelector(".link-dialog-close"),s=t.querySelector(".btn-cancel"),d=()=>{document.body.removeChild(e)};c.addEventListener("click",d),s.addEventListener("click",d),e.addEventListener("click",p=>{p.target===e&&d()}),o.addEventListener("submit",p=>{p.preventDefault();const g=i.value.trim();g&&(Wi({text:r.value.trim()||g,url:g,target:l.checked?"_blank":"_self",title:a.value.trim()||void 0}),d())}),setTimeout(()=>r.focus(),100)},$r=()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const e=n.getRangeAt(0).cloneRange();he=e;const t=n.toString()||"",o=e.startContainer,i=(o.nodeType===Node.TEXT_NODE?o.parentElement:o)?.closest("a");return i?(Rt=!0,ee=i,Oo({text:i.textContent||"",url:i.href,target:i.target||"_self",title:i.title||"",isEditing:!0})):(Rt=!1,ee=null,Oo({text:t,url:"",target:"_self",isEditing:!1})),!0},Br=()=>(document.execCommand("unlink",!1),!0),un=(n,e)=>{typeof window<"u"&&window.registerEditorCommand?.(n,e)},$o=()=>{un("openLinkDialog",$r),un("removeLink",Br),un("createLink",n=>{n&&document.execCommand("createLink",!1,n)})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",$o):$o());const Gi=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:n=>({href:n.getAttribute("href"),title:n.getAttribute("title"),target:n.getAttribute("target")})}],toDOM:n=>["a",{href:n.attrs.href,title:n.attrs.title,target:n.attrs.target,rel:n.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:$r,removeLink:Br},keymap:{"Mod-k":"openLinkDialog"}}),Zi=()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return!1;let e=n.anchorNode,t=!1;for(;e&&e!==document.body;){if(e.nodeName==="BLOCKQUOTE"){t=!0;break}e=e.parentNode}return t?document.execCommand("formatBlock",!1,"p"):document.execCommand("formatBlock",!1,"blockquote"),!0}},keymap:{"Mod-Shift-9":"toggleBlockquote"}}),Ki=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>(document.execCommand("removeFormat",!1),!0)},keymap:{"Mod-\\":"clearFormatting"}});class Yn{constructor(e=""){this._lines=[],this._version=0,this.setText(e)}getLine(e){return this._lines[e]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
76
- `)}setText(e){this._lines=e.split(`
77
- `),this._version++}getTextInRange(e){if(e.start.line===e.end.line)return this.getLine(e.start.line).substring(e.start.column,e.end.column);const t=[];t.push(this.getLine(e.start.line).substring(e.start.column));for(let o=e.start.line+1;o<e.end.line;o++)t.push(this.getLine(o));return e.end.line<this.getLineCount()&&t.push(this.getLine(e.end.line).substring(0,e.end.column)),t.join(`
78
- `)}replaceRange(e,t){const o=this.getTextInRange(e);if(e.start.line===e.end.line){const r=this.getLine(e.start.line),i=r.substring(0,e.start.column)+t+r.substring(e.end.column);this._lines[e.start.line]=i}else{const r=this.getLine(e.start.line),i=this.getLine(e.end.line),a=r.substring(0,e.start.column)+t,l=i.substring(e.end.column),c=t.split(`
79
- `);c[0]=a+c[0],c[c.length-1]=c[c.length-1]+l,this._lines.splice(e.start.line,e.end.line-e.start.line+1,...c)}return this._version++,{range:e,text:t,oldText:o}}insertText(e,t){const o={start:e,end:e};return this.replaceRange(o,t)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let t=0;for(let o=0;o<e.line;o++)t+=this.getLine(o).length+1;return t+=e.column,t}offsetToPosition(e){let t=e;for(let o=0;o<this.getLineCount();o++){const r=this.getLine(o).length;if(t<=r)return{line:o,column:t};t-=r+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(e){return!(e.line<0||e.line>=this.getLineCount()||e.column<0||e.column>this.getLine(e.line).length)}isValidRange(e){return this.isValidPosition(e.start)&&this.isValidPosition(e.end)}getVersion(){return this._version}clone(){const e=new Yn;return e._lines=[...this._lines],e._version=this._version,e}}class Xi{constructor(e){this.gutterWidth=50,this.lineHeight=21,this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");e.style.cssText=`
80
- position: relative;
81
- display: flex;
82
- width: 100%;
83
- height: 100%;
84
- background: var(--editor-background, #1e1e1e);
85
- color: var(--editor-foreground, #f8f9fa);
86
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
87
- font-size: 14px;
88
- line-height: ${this.lineHeight}px;
89
- overflow: hidden;
90
- `,this.lineNumbersElement=document.createElement("div"),this.lineNumbersElement.style.cssText=`
91
- position: sticky;
92
- left: 0;
93
- top: 0;
94
- width: ${this.gutterWidth}px;
95
- background: var(--editor-gutter-background, #252526);
96
- color: var(--editor-gutter-foreground, #858585);
97
- padding: 0;
98
- text-align: right;
99
- border-right: 1px solid var(--editor-gutter-border, #3e3e42);
100
- user-select: none;
101
- overflow: hidden;
102
- z-index: 1;
103
- `,this.contentElement=document.createElement("div"),this.contentElement.style.cssText=`
104
- flex: 1;
105
- padding: 0;
106
- background: transparent;
107
- border: none;
108
- outline: none;
109
- white-space: pre;
110
- overflow-x: auto;
111
- overflow-y: auto;
112
- min-height: 400px;
113
- font-family: inherit;
114
- font-size: inherit;
115
- line-height: inherit;
116
- color: inherit;
117
- tab-size: 2;
118
- -moz-tab-size: 2;
119
- `,this.contentElement.contentEditable="true",this.contentElement.spellcheck=!1,e.appendChild(this.lineNumbersElement),e.appendChild(this.contentElement),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){const t=Math.max(e,20),o=Array.from({length:t},(r,i)=>i+1);this.lineNumbersElement.innerHTML=o.map(r=>`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${r}</div>`).join("")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.contentElement.textContent||""}setText(e){this.contentElement.textContent=e;const t=e.split(`
120
- `).length;this.updateLineNumbers(t)}getCursorPosition(){const e=window.getSelection();if(!e||e.rangeCount===0)return{line:0,column:0};const t=e.getRangeAt(0),o=t.cloneRange();o.selectNodeContents(this.contentElement),o.setEnd(t.endContainer,t.endOffset);const r=o.toString().split(`
121
- `);return{line:r.length-1,column:r[r.length-1].length}}setCursorPosition(e){const t=this.getText().split(`
122
- `),o=Math.min(e.line,t.length-1),r=Math.min(e.column,t[o]?.length||0);let i=0;for(let m=0;m<o;m++)i+=t[m].length+1;i+=r;const a=document.createRange(),l=window.getSelection();let c=0,s=null,d=0;const p=document.createTreeWalker(this.contentElement,NodeFilter.SHOW_TEXT,null);let g;for(;g=p.nextNode();){const m=g.textContent?.length||0;if(c+m>=i){s=g,d=i-c;break}c+=m}if(s)try{a.setStart(s,d),a.setEnd(s,d),l?.removeAllRanges(),l?.addRange(a)}catch(m){console.warn("Could not set cursor position:",m)}}getSelectionRange(){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return;const t=e.getRangeAt(0),o=t.cloneRange();o.selectNodeContents(this.contentElement),o.setEnd(t.startContainer,t.startOffset);const r=o.toString().split(`
123
- `),i=t.cloneRange();i.selectNodeContents(this.contentElement),i.setEnd(t.endContainer,t.endOffset);const a=i.toString().split(`
124
- `);return{start:{line:r.length-1,column:r[r.length-1].length},end:{line:a.length-1,column:a[a.length-1].length}}}setSelectionRange(e){this.setCursorPosition(e.start)}focus(){this.contentElement.focus()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([t,o])=>{this.container.style.setProperty(`--${t}`,o)})}scrollToPosition(e){const t=this.lineNumbersElement.children[e.line];t&&t.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.contentElement.scrollTop}setScrollTop(e){this.contentElement.scrollTop=e,this.lineNumbersElement.scrollTop=e}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}class Yi{constructor(e,t={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...t},this.textModel=new Yn(this.config.value),this.view=new Xi(e),this.view.setText(this.textModel.getText()),this.view.setReadOnly(this.config.readOnly||!1),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(o=>this.addExtension(o)),this.setTheme(this.config.theme)}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const e=this.view.getContentElement();e.addEventListener("input",()=>{const t=this.view.getText(),o=this.textModel.getText();t!==o&&(this.textModel.setText(t),this.emit("change",[{range:this.getFullRange(),text:t,oldText:o}]),this.updateLineNumbers())}),e.addEventListener("selectionchange",()=>{const t=this.getCursor(),o=this.getSelection();this.emit("cursor",t),o&&this.emit("selection",o)}),e.addEventListener("keydown",t=>{this.emit("keydown",t);for(const o of this.extensions.values())if(o.onKeyDown&&o.onKeyDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("mousedown",t=>{this.emit("mousedown",t);for(const o of this.extensions.values())if(o.onMouseDown&&o.onMouseDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("focus",()=>{this.emit("focus")}),e.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const e=this.textModel.getLineCount();this.view.updateLineNumbers(e)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(e,...t){const o=this.eventListeners.get(e);o&&o.forEach(r=>r(...t))}getValue(){return this.textModel.getText()}setValue(e){this.textModel.setText(e),this.view.setText(e),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:this.getValue()}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){const e=this.view.getCursorPosition();return{position:e,anchor:e}}setCursor(e){this.view.setCursorPosition(e),this.emit("cursor",this.getCursor())}getSelection(){return this.view.getSelectionRange()}setSelection(e){this.view.setSelectionRange(e),this.emit("selection",e)}setTheme(e){this.currentTheme=e;const t={"editor-background":e==="dark"?"#1e1e1e":"#ffffff","editor-foreground":e==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":e==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":e==="dark"?"#858585":"#666666","editor-gutter-border":e==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(t)}setReadOnly(e){this.config.readOnly=e,this.view.setReadOnly(e)}addExtension(e){if(this.extensions.has(e.name))throw new Error(`Extension '${e.name}' already exists`);this.extensions.set(e.name,e),e.setup(this)}removeExtension(e){const t=this.extensions.get(e);t&&t.destroy&&t.destroy(),this.extensions.delete(e)}executeCommand(e,...t){const o=this.commands.get(e);o?o(this,...t):console.warn(`Command '${e}' not found`)}registerCommand(e,t){this.commands.set(e,t)}search(e,t={}){const o={caseSensitive:!1,regex:!1,...t},r=[],i=this.getValue();i.split(`
125
- `);let a=o.caseSensitive?i:i.toLowerCase(),l=o.caseSensitive?e:e.toLowerCase();if(o.regex){const c=new RegExp(l,o.caseSensitive?"g":"gi");let s;for(;(s=c.exec(a))!==null;){const d=this.textModel.offsetToPosition(s.index),p=this.textModel.offsetToPosition(s.index+s[0].length);r.push({range:{start:d,end:p},match:s[0]})}}else{let c=0,s=a.indexOf(l,c);for(;s!==-1;){const d=s+e.length,p=this.textModel.offsetToPosition(s),g=this.textModel.offsetToPosition(d);r.push({range:{start:p,end:g},match:i.substring(s,d)}),c=d,s=a.indexOf(l,c)}}return r}replace(e,t){const o=this.textModel.replaceRange(e,t);this.view.setText(this.getValue()),this.emit("change",[o])}replaceAll(e,t,o={}){const r=this.search(e,o);let i=0;for(let a=r.length-1;a>=0;a--)this.replace(r[a].range,t),i++;return i}fold(e){const t={start:e.start,end:e.end,collapsed:!0,level:0};this.folds.push(t)}unfold(e){this.folds=this.folds.filter(t=>!(t.start.line===e.start.line&&t.end.line===e.end.line))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(const e of this.extensions.values())e.destroy&&e.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}off(e,t){if(!this.eventListeners.has(e))return;const o=this.eventListeners.get(e);if(t){const r=o.indexOf(t);r!==-1&&o.splice(r,1)}else o.length=0}}class Qi{constructor(e){this.name="keymap",this.editor=null,this.keymap={},this.isMac=navigator.platform.toUpperCase().indexOf("MAC")>=0,this.keymap=e||this.getDefaultKeymap()}setup(e){this.editor=e,e.on("keydown",t=>this.handleKeyDown(t))}handleKeyDown(e){if(!this.editor)return;const t=this.findMatchingBinding(e);if(t)return this.editor.executeCommand(t.command),e.preventDefault(),e.stopPropagation(),!1}findMatchingBinding(e){const{key:t,ctrlKey:o,altKey:r,shiftKey:i,metaKey:a}=e,l=t.toLowerCase(),c=this.keymap[l];if(!c)return null;for(const s of c)if((s.ctrlKey===o||!s.ctrlKey&&!o)&&(s.altKey===r||!s.altKey&&!r)&&(s.shiftKey===i||!s.shiftKey&&!i)&&(s.metaKey===a||!s.metaKey&&!a))return s;return null}getDefaultKeymap(){const e={};return this.addBinding(e,"f",{ctrlKey:!this.isMac,metaKey:this.isMac},"find"),this.addBinding(e,"h",{ctrlKey:!this.isMac,metaKey:this.isMac},"replace"),this.addBinding(e,"f3",{},"findNext"),this.addBinding(e,"f3",{shiftKey:!0},"findPrev"),this.addBinding(e,"g",{ctrlKey:!this.isMac,metaKey:this.isMac},"findNext"),this.addBinding(e,"[",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"fold"),this.addBinding(e,"]",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"unfold"),this.addBinding(e,"s",{ctrlKey:!this.isMac,metaKey:this.isMac},"save"),this.addBinding(e,"z",{ctrlKey:!this.isMac,metaKey:this.isMac},"undo"),this.addBinding(e,"y",{ctrlKey:!this.isMac,metaKey:this.isMac},"redo"),this.addBinding(e,"z",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"redo"),this.addBinding(e,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),e}addBinding(e,t,o,r){const i=t.toLowerCase();e[i]||(e[i]=[]),e[i].push({key:i,command:r,...o})}setKeymap(e){this.keymap={...e}}addKeyBinding(e){const t=e.key.toLowerCase();this.keymap[t]||(this.keymap[t]=[]),this.keymap[t]=this.keymap[t].filter(o=>o.command!==e.command),this.keymap[t].push({...e,key:t})}removeKeyBinding(e,t){const o=e.toLowerCase();t?this.keymap[o]&&(this.keymap[o]=this.keymap[o].filter(r=>r.command!==t),this.keymap[o].length===0&&delete this.keymap[o]):delete this.keymap[o]}getKeymap(){return{...this.keymap}}getBindingsForCommand(e){const t=[];for(const o in this.keymap)for(const r of this.keymap[o])r.command===e&&t.push({...r});return t}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}class Ji{constructor(){this.name="line-numbers",this.editor=null,this.lineNumbersElement=null,this.isEnabled=!0}setup(e){this.editor=e,this.createLineNumbers(),e.registerCommand("toggleLineNumbers",()=>{this.toggle()}),e.on("change",()=>{this.updateLineNumbers()}),this.updateLineNumbers()}createLineNumbers(){if(!this.editor)return;const e=this.editor.getView();if(!e.container)return;this.lineNumbersElement=document.createElement("div"),this.lineNumbersElement.style.cssText=`
126
- position: absolute;
127
- left: 0;
128
- top: 0;
129
- bottom: 0;
130
- width: 50px;
131
- background: var(--editor-gutter-background, #252526);
132
- color: var(--editor-gutter-foreground, #858585);
133
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
134
- font-size: 14px;
135
- line-height: 21px;
136
- padding: 0;
137
- text-align: right;
138
- border-right: 1px solid var(--editor-gutter-border, #3e3e42);
139
- user-select: none;
140
- overflow: hidden;
141
- z-index: 1;
142
- pointer-events: none;
143
- `;const t=e.getContentElement();t&&t.parentNode&&(t.parentNode.insertBefore(this.lineNumbersElement,t),t.style.marginLeft="60px")}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const e=this.editor.getValue().split(`
144
- `).length,t=Array.from({length:Math.max(e,20)},(o,r)=>r+1);this.lineNumbersElement.innerHTML=t.map(o=>`<div style="height: 21px; line-height: 21px; padding-right: 12px;">${o}</div>`).join("")}toggle(){this.isEnabled=!this.isEnabled,this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"block":"none");const e=this.editor.getView().getContentElement();e&&(e.style.marginLeft=this.isEnabled?"60px":"0"),this.updateLineNumbers()}destroy(){this.lineNumbersElement&&this.lineNumbersElement.parentNode&&this.lineNumbersElement.parentNode.removeChild(this.lineNumbersElement),this.lineNumbersElement=null,this.editor=null}}class ea{constructor(){this.name="theme",this.editor=null,this.currentTheme="dark"}setup(e){this.editor=e,e.registerCommand("setTheme",t=>{this.setTheme(t)}),e.registerCommand("toggleTheme",()=>{this.toggleTheme()}),this.setTheme(this.currentTheme)}setTheme(e){this.editor&&(this.currentTheme=e,this.editor.setTheme(e))}toggleTheme(){const e=this.currentTheme==="dark"?"light":"dark";this.setTheme(e)}getCurrentTheme(){return this.currentTheme}destroy(){this.editor=null}}class ta{constructor(){this.name="read-only",this.editor=null,this.isReadOnly=!1}setup(e){this.editor=e,e.registerCommand("setReadOnly",t=>{this.setReadOnly(t)}),e.registerCommand("toggleReadOnly",()=>{this.toggleReadOnly()}),e.on("keydown",t=>{if(t.ctrlKey&&t.key==="r")return t.preventDefault(),this.toggleReadOnly(),!1})}setReadOnly(e){this.editor&&(this.isReadOnly=e,this.editor.setReadOnly(e))}toggleReadOnly(){this.setReadOnly(!this.isReadOnly)}isCurrentlyReadOnly(){return this.isReadOnly}destroy(){this.editor=null}}class na{constructor(){this.name="search",this.editor=null,this.searchUI=null,this.isVisible=!1,this.currentResults=[],this.currentIndex=-1}setup(e){this.editor=e,e.registerCommand("find",()=>{this.showSearch()}),e.registerCommand("findNext",()=>{this.findNext()}),e.registerCommand("findPrev",()=>{this.findPrev()}),e.registerCommand("replace",()=>{this.showReplace()}),e.registerCommand("replaceAll",(t,o)=>{this.replaceAll(t,o)})}showSearch(){if(this.editor&&(this.searchUI||this.createSearchUI(),this.isVisible=!0,this.searchUI)){this.searchUI.style.display="block";const e=this.searchUI.querySelector("input");e&&(e.focus(),e.select())}}showReplace(){this.showSearch();const e=this.searchUI?.querySelector(".search-replace-input");e&&(e.style.display="block",e.focus());const t=this.searchUI?.querySelector(".search-status");t&&(t.textContent="Replace mode - Enter to replace, Shift+Enter to replace all")}hideSearch(){this.isVisible=!1,this.searchUI&&(this.searchUI.style.display="none"),this.clearHighlights()}createSearchUI(){if(!this.editor)return;const e=document.querySelector(".rte-source-editor-modal");if(!e)return;this.searchUI=document.createElement("div"),this.searchUI.style.cssText=`
145
- position: absolute;
146
- top: 10px;
147
- right: 10px;
148
- background: var(--editor-background, #1e1e1e);
149
- border: 1px solid var(--editor-gutter-border, #3e3e42);
150
- border-radius: 4px;
151
- padding: 8px;
152
- z-index: 1000;
153
- display: none;
154
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
155
- min-width: 250px;
156
- `,this.searchUI.innerHTML=`
157
- <div style="display: flex; align-items: center; gap: 4px; margin-bottom: 4px;">
158
- <input type="text" placeholder="Find..." style="
159
- flex: 1;
160
- padding: 4px 8px;
161
- background: var(--editor-gutter-background, #252526);
162
- color: var(--editor-foreground, #f8f9fa);
163
- border: 1px solid var(--editor-gutter-border, #3e3e42);
164
- border-radius: 3px;
165
- font-size: 12px;
166
- outline: none;
167
- " />
168
- <button class="search-prev" style="
169
- padding: 2px 6px;
170
- background: var(--editor-gutter-background, #252526);
171
- color: var(--editor-gutter-foreground, #858585);
172
- border: 1px solid var(--editor-gutter-border, #3e3e42);
173
- border-radius: 3px;
174
- cursor: pointer;
175
- font-size: 11px;
176
- ">↑</button>
177
- <button class="search-next" style="
178
- padding: 2px 6px;
179
- background: var(--editor-gutter-background, #252526);
180
- color: var(--editor-gutter-foreground, #858585);
181
- border: 1px solid var(--editor-gutter-border, #3e3e42);
182
- border-radius: 3px;
183
- cursor: pointer;
184
- font-size: 11px;
185
- ">↓</button>
186
- <button class="search-close" style="
187
- padding: 2px 6px;
188
- background: var(--editor-gutter-background, #252526);
189
- color: var(--editor-gutter-foreground, #858585);
190
- border: 1px solid var(--editor-gutter-border, #3e3e42);
191
- border-radius: 3px;
192
- cursor: pointer;
193
- font-size: 11px;
194
- ">×</button>
195
- </div>
196
- <div class="search-status" style="
197
- font-size: 11px;
198
- color: var(--editor-gutter-foreground, #858585);
199
- text-align: center;
200
- "></div>
201
- <input type="text" class="search-replace-input" placeholder="Replace with..." style="
202
- width: 100%;
203
- padding: 4px 8px;
204
- background: var(--editor-gutter-background, #252526);
205
- color: var(--editor-foreground, #f8f9fa);
206
- border: 1px solid var(--editor-gutter-border, #3e3e42);
207
- border-radius: 3px;
208
- font-size: 12px;
209
- outline: none;
210
- display: none;
211
- margin-top: 4px;
212
- " />
213
- `;const t=this.searchUI.querySelector("input"),o=this.searchUI.querySelector(".search-replace-input"),r=this.searchUI.querySelector(".search-prev"),i=this.searchUI.querySelector(".search-next"),a=this.searchUI.querySelector(".search-close");t.addEventListener("input",()=>{this.performSearch(t.value)}),t.addEventListener("keydown",l=>{l.key==="Enter"&&(l.preventDefault(),l.shiftKey?this.findPrev():this.findNext())}),o.addEventListener("keydown",l=>{l.key==="Enter"&&(l.preventDefault(),l.shiftKey?this.replaceAll(t.value,o.value):this.replaceCurrent(t.value,o.value))}),r.addEventListener("click",()=>this.findPrev()),i.addEventListener("click",()=>this.findNext()),a.addEventListener("click",()=>this.hideSearch()),e.appendChild(this.searchUI)}performSearch(e){if(!this.editor||!e.trim()){this.clearHighlights(),this.updateStatus("");return}const t=this.editor.getValue(),o=[];let r=t.toLowerCase().indexOf(e.toLowerCase());for(;r!==-1;){const i=this.getPositionFromOffset(t,r),a=this.getPositionFromOffset(t,r+e.length);o.push({range:{start:i,end:a},match:t.substring(r,r+e.length)}),r=t.toLowerCase().indexOf(e.toLowerCase(),r+1)}this.currentResults=o,this.currentIndex=this.currentResults.length>0?0:-1,this.updateHighlights(),this.updateStatus(`${this.currentResults.length} matches`)}getPositionFromOffset(e,t){const o=e.substring(0,t).split(`
214
- `),r=o.length-1,i=o[o.length-1].length;return{line:r,column:i}}findNext(){this.currentResults.length!==0&&(this.currentIndex=(this.currentIndex+1)%this.currentResults.length,this.updateHighlights())}findPrev(){this.currentResults.length!==0&&(this.currentIndex=this.currentIndex<=0?this.currentResults.length-1:this.currentIndex-1,this.updateHighlights())}replaceCurrent(e,t){if(!this.editor||!e.trim()||this.currentIndex===-1)return;const o=this.currentResults[this.currentIndex];if(!o)return;const r=this.editor.getValue(),i=this.getOffsetFromPosition(r,o.range.start),a=r.substring(0,i),l=r.substring(i+e.length),c=a+t+l;this.editor.setValue(c),this.performSearch(e),this.updateStatus("Replaced current occurrence")}replaceAll(e,t){if(!this.editor||!e.trim())return;let o=this.editor.getValue(),r=0,i=o.toLowerCase().indexOf(e.toLowerCase());for(;i!==-1;)o=o.substring(0,i)+t+o.substring(i+e.length),r++,i=o.toLowerCase().indexOf(e.toLowerCase(),i+t.length);r>0&&(this.editor.setValue(o),this.updateStatus(`Replaced ${r} occurrences`))}getOffsetFromPosition(e,t){const o=e.split(`
215
- `);let r=0;for(let i=0;i<t.line;i++)r+=o[i].length+1;return r+=t.column,r}updateHighlights(){this.clearHighlights(),!(this.currentResults.length===0||this.currentIndex===-1)&&(this.currentResults[this.currentIndex],this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`))}clearHighlights(){}updateStatus(e){const t=this.searchUI?.querySelector(".search-status");t&&(t.textContent=e)}destroy(){this.searchUI&&this.searchUI.parentNode&&this.searchUI.parentNode.removeChild(this.searchUI),this.searchUI=null,this.editor=null}}class oa{constructor(){this.name="bracket-matching",this.editor=null,this.bracketPairs={"(":")","[":"]","{":"}","<":">"},this.reverseBracketPairs={")":"(","]":"[","}":"{",">":"<"},this.currentMatch=null}setup(e){this.editor=e,e.on("cursor",()=>{this.updateBracketMatching()}),e.on("change",()=>{this.updateBracketMatching()})}updateBracketMatching(){if(!this.editor)return;const e=this.editor.getCursor(),t=this.editor.getValue();this.clearBracketHighlighting();const o=this.getBracketAtPosition(t,e.position);if(!o)return;const r=this.findMatchingBracket(t,o);r&&(this.currentMatch=r,this.highlightBrackets(r))}getBracketAtPosition(e,t){const o=e.split(`
216
- `);if(t.line>=o.length)return null;const r=o[t.line];if(t.column>=r.length)return null;const i=r[t.column];return this.bracketPairs[i]||this.reverseBracketPairs[i]?{char:i,position:t}:null}findMatchingBracket(e,t){const o=e.split(`
217
- `),r=t.position.line,i=t.position.column,a=t.char;return this.bracketPairs[a]?this.findClosingBracket(e,o,r,i,a):this.reverseBracketPairs[a]?this.findOpeningBracket(e,o,r,i,a):null}findClosingBracket(e,t,o,r,i){const a=this.bracketPairs[i];let l=0;for(let c=o;c<t.length;c++){const s=t[c],d=c===o?r:0;for(let p=d;p<s.length;p++){const g=s[p];if(g===i)l++;else if(g===a&&(l--,l===0))return{open:{start:{line:o,column:r},end:{line:o,column:r+1}},close:{start:{line:c,column:p},end:{line:c,column:p+1}},type:i}}}return null}findOpeningBracket(e,t,o,r,i){const a=this.reverseBracketPairs[i];let l=0;for(let c=o;c>=0;c--){const s=t[c],d=c===o?r:s.length-1;for(let p=d;p>=0;p--){const g=s[p];if(g===i)l++;else if(g===a&&(l--,l===0))return{open:{start:{line:c,column:p},end:{line:c,column:p+1}},close:{start:{line:o,column:r},end:{line:o,column:r+1}},type:a}}}return null}highlightBrackets(e){console.log("Bracket match found:",e)}clearBracketHighlighting(){this.currentMatch=null}getCurrentMatch(){return this.currentMatch}destroy(){this.clearBracketHighlighting(),this.editor=null}}class ra{constructor(){this.name="code-folding",this.editor=null,this.foldIndicators=[],this.foldingUI=null}setup(e){this.editor=e,e.registerCommand("fold",()=>{console.log("Fold command executed - folding not yet implemented"),this.foldAtCursor()}),e.registerCommand("unfold",()=>{console.log("Unfold command executed - unfolding not yet implemented"),this.unfoldAtCursor()}),e.registerCommand("foldAll",()=>{console.log("Fold all command executed - folding not yet implemented"),this.foldAll()}),e.registerCommand("unfoldAll",()=>{console.log("Unfold all command executed - unfolding not yet implemented"),this.unfoldAll()}),e.on("change",()=>{this.updateFoldIndicators()}),this.createFoldingUI(),this.updateFoldIndicators()}createFoldingUI(){if(!this.editor)return;const e=document.querySelector(".rte-source-editor-modal");e&&(this.foldingUI=document.createElement("div"),this.foldingUI.style.cssText=`
218
- position: absolute;
219
- left: 40px;
220
- top: 0;
221
- bottom: 0;
222
- width: 20px;
223
- pointer-events: none;
224
- z-index: 2;
225
- `,e.appendChild(this.foldingUI))}updateFoldIndicators(){if(!this.editor||!this.foldingUI)return;this.foldingUI.innerHTML="",this.foldIndicators=[];const e=this.editor.getValue().split(`
226
- `);this.findFoldableLines(e).forEach(t=>{this.createFoldIndicator(t)})}findFoldableLines(e){const t=[];for(let o=0;o<e.length;o++){const r=e[o].trim();(r.startsWith("{")||r.startsWith("function")||r.startsWith("class")||r.startsWith("if")||r.includes("=>")||r.startsWith("for")||r.startsWith("while")||r.startsWith("try"))&&t.push(o)}return t}createFoldIndicator(e){if(!this.foldingUI)return;const t=document.createElement("div");t.style.cssText=`
227
- position: absolute;
228
- left: 0;
229
- top: ${e*21}px;
230
- width: 20px;
231
- height: 21px;
232
- display: flex;
233
- align-items: center;
234
- justify-content: center;
235
- cursor: pointer;
236
- pointer-events: auto;
237
- color: var(--editor-gutter-foreground, #858585);
238
- font-size: 10px;
239
- user-select: none;
240
- `,t.innerHTML="▶",t.title="Code folding not yet implemented - click shows fold indicators",t.addEventListener("click",()=>{console.log(`Fold toggle clicked at line ${e} - implementation pending`)}),this.foldingUI.appendChild(t),this.foldIndicators.push(t)}foldAtCursor(){console.log("foldAtCursor called - implementation pending")}unfoldAtCursor(){console.log("unfoldAtCursor called - implementation pending")}foldAll(){console.log("foldAll called - implementation pending")}unfoldAll(){console.log("unfoldAll called - implementation pending")}destroy(){this.foldingUI&&this.foldingUI.parentNode&&this.foldingUI.parentNode.removeChild(this.foldingUI),this.foldingUI=null,this.foldIndicators=[],this.editor=null}}class ia{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark"}setup(e){this.editor=e,console.log("SyntaxHighlightingExtension: Isolated extension loaded - ready for use")}setTheme(e){this.currentTheme=e,console.log(`SyntaxHighlightingExtension: Theme changed to ${e}`)}getSyntaxColors(){return this.currentTheme==="dark"?{tag:"#569cd6",comment:"#6a9955",attrValue:"#ce9178",text:"#d4d4d4"}:{tag:"#0000ff",comment:"#008000",attrValue:"#a31515",text:"#000000"}}highlightHTML(e){const t=this.getSyntaxColors();let o=e;return o=o.replace(/(<\/?[\w:-]+(?:\s[^>]*?)?\/?>)/g,`<span style="color: ${t.tag};">$1</span>`),o=o.replace(/(<!--[\s\S]*?-->)/g,`<span style="color: ${t.comment};">$1</span>`),o=o.replace(/("[^"]*"|'[^']*')/g,`<span style="color: ${t.attrValue};">$1</span>`),o}shouldHighlight(e){return/<\/?[\w:-]+|<!--/.test(e)}destroy(){this.editor=null,console.log("SyntaxHighlightingExtension: Extension destroyed")}}function aa(n,e){const t={...e};return t.extensions||(t.extensions=[]),t.extensions.some(o=>o.name==="keymap")||t.extensions.unshift(new Qi(t.keymap)),new Yi(n,t)}const la=`/* Source Editor Dialog Styles */
241
- .rte-source-editor-overlay {
242
- position: fixed !important;
243
- top: 0 !important;
244
- left: 0 !important;
245
- right: 0 !important;
246
- bottom: 0 !important;
247
- width: 100vw !important;
248
- height: 100vh !important;
249
- background-color: rgba(0, 0, 0, 0.6) !important;
250
- display: flex !important;
251
- align-items: center !important;
252
- justify-content: center !important;
253
- z-index: 10000 !important;
254
- padding: 20px !important;
255
- box-sizing: border-box !important;
256
- margin: 0 !important;
257
- }
258
-
259
- .rte-source-editor-overlay.fullscreen {
260
- padding: 0 !important;
261
- }
262
-
263
- .rte-source-editor-modal {
264
- background: white;
265
- border-radius: 8px;
266
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
267
- width: 100%;
268
- max-width: 1200px;
269
- max-height: 90vh;
270
- display: flex;
271
- flex-direction: column;
272
- overflow: hidden;
273
- position: relative;
274
- }
275
-
276
- .rte-source-editor-overlay.fullscreen .rte-source-editor-modal {
277
- border-radius: 0;
278
- max-width: 100%;
279
- max-height: 100vh;
280
- width: 100%;
281
- height: 100vh;
282
- }
283
-
284
- .rte-source-editor-header {
285
- display: flex;
286
- align-items: center;
287
- justify-content: space-between;
288
- padding: 16px 20px;
289
- border-bottom: 1px solid #e1e5e9;
290
- background: #f8f9fa;
291
- border-radius: 8px 8px 0 0;
292
- }
293
-
294
- .rte-source-editor-overlay.fullscreen .rte-source-editor-header {
295
- border-radius: 0;
296
- }
297
-
298
- .rte-source-editor-header h2 {
299
- margin: 0;
300
- font-size: 18px;
301
- font-weight: 600;
302
- color: #1a1a1a;
303
- }
304
-
305
- .rte-source-editor-header-toolbar {
306
- display: flex;
307
- gap: 8px;
308
- margin-left: auto;
309
- margin-right: 16px;
310
- }
311
-
312
- .rte-source-editor-toolbar-btn {
313
- background: none;
314
- border: none;
315
- cursor: pointer;
316
- padding: 6px;
317
- border-radius: 4px;
318
- font-size: 16px;
319
- line-height: 1;
320
- transition: all 0.2s ease;
321
- color: #666;
322
- }
323
-
324
- .rte-source-editor-toolbar-btn:hover:not(:disabled) {
325
- background: #e1e5e9;
326
- color: #1a1a1a;
327
- }
328
-
329
- .rte-source-editor-toolbar-btn:disabled {
330
- opacity: 0.5;
331
- cursor: not-allowed;
332
- }
333
-
334
- .rte-source-editor-toolbar-btn.active {
335
- background: #007acc;
336
- color: white;
337
- }
338
-
339
- .rte-source-editor-toolbar-btn.active:hover {
340
- background: #0056b3;
341
- }
342
-
343
- .rte-source-editor-header-actions {
344
- display: flex;
345
- gap: 8px;
346
- }
347
-
348
- .rte-source-editor-fullscreen-btn,
349
- .rte-source-editor-close-btn {
350
- background: none;
351
- border: none;
352
- cursor: pointer;
353
- padding: 4px;
354
- border-radius: 4px;
355
- color: #666;
356
- font-size: 16px;
357
- line-height: 1;
358
- transition: all 0.2s ease;
359
- }
360
-
361
- .rte-source-editor-fullscreen-btn:hover,
362
- .rte-source-editor-close-btn:hover {
363
- background: #e1e5e9;
364
- color: #1a1a1a;
365
- }
366
-
367
- .rte-source-editor-body {
368
- flex: 1;
369
- overflow: hidden;
370
- display: flex;
371
- flex-direction: column;
372
- }
373
-
374
- .rte-source-editor-loading {
375
- display: flex;
376
- flex-direction: column;
377
- align-items: center;
378
- justify-content: center;
379
- padding: 40px;
380
- color: #666;
381
- position: absolute;
382
- z-index: 9;
383
- margin: 0 auto;
384
- width: 100%;
385
- top: 44%;
386
- }
387
-
388
- .rte-source-editor-spinner {
389
- width: 32px;
390
- height: 32px;
391
- border: 3px solid #e1e5e9;
392
- border-top: 3px solid #007acc;
393
- border-radius: 50%;
394
- animation: spin 1s linear infinite;
395
- margin-bottom: 16px;
396
- }
397
-
398
- @keyframes spin {
399
- 0% { transform: rotate(0deg); }
400
- 100% { transform: rotate(360deg); }
401
- }
402
-
403
- .rte-source-editor-error {
404
- background: #fee;
405
- color: #c53030;
406
- padding: 12px 16px;
407
- border-left: 4px solid #c53030;
408
- margin: 16px;
409
- border-radius: 4px;
410
- font-size: 14px;
411
- }
412
-
413
- .rte-source-editor-content {
414
- flex: 1;
415
- display: flex;
416
- flex-direction: column;
417
- overflow: hidden;
418
- }
419
-
420
- .rte-source-editor-warning {
421
- background: #fefcbf;
422
- color: #744210;
423
- padding: 8px 16px;
424
- font-size: 12px;
425
- font-weight: 500;
426
- border-bottom: 1px solid #f6e05e;
427
- }
428
-
429
- .rte-source-editor-codemirror {
430
- flex: 1;
431
- overflow: auto;
432
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
433
- font-size: 14px;
434
- line-height: 1.5;
435
- }
436
-
437
- .rte-source-editor-codemirror .cm-editor {
438
- height: 100%;
439
- }
440
-
441
- .rte-source-editor-codemirror .cm-focused {
442
- outline: none;
443
- }
444
-
445
- .rte-source-editor-footer {
446
- display: flex;
447
- align-items: center;
448
- justify-content: space-between;
449
- padding: 16px 20px;
450
- border-top: 1px solid #e1e5e9;
451
- background: #f8f9fa;
452
- border-radius: 0 0 8px 8px;
453
- }
454
-
455
- .rte-source-editor-overlay.fullscreen .rte-source-editor-footer {
456
- border-radius: 0;
457
- }
458
-
459
- .rte-source-editor-footer-info {
460
- font-size: 12px;
461
- color: #666;
462
- }
463
-
464
- .unsaved-changes {
465
- color: #d69e2e;
466
- font-weight: 500;
467
- }
468
-
469
- .rte-source-editor-footer-actions {
470
- display: flex;
471
- gap: 12px;
472
- }
473
-
474
- .rte-source-editor-btn {
475
- padding: 8px 16px;
476
- border-radius: 4px;
477
- font-size: 14px;
478
- font-weight: 500;
479
- cursor: pointer;
480
- border: 1px solid transparent;
481
- transition: all 0.2s ease;
482
- }
483
-
484
- .rte-source-editor-btn:disabled {
485
- opacity: 0.6;
486
- cursor: not-allowed;
487
- }
488
-
489
- .rte-source-editor-btn-cancel {
490
- background: white;
491
- border-color: #d1d5db;
492
- color: #374151;
493
- }
494
-
495
- .rte-source-editor-btn-cancel:hover:not(:disabled) {
496
- background: #f9fafb;
497
- border-color: #9ca3af;
498
- }
499
-
500
- .rte-source-editor-btn-save {
501
- background: #007acc;
502
- color: white;
503
- }
504
-
505
- .rte-source-editor-btn-save:hover:not(:disabled) {
506
- background: #0056b3;
507
- }
508
-
509
- /* Dark theme support */
510
- @media (prefers-color-scheme: dark) {
511
- .rte-source-editor-modal {
512
- background: #1e1e1e;
513
- color: #f8f9fa;
514
- }
515
-
516
- .rte-source-editor-header {
517
- background: #2d2d2d;
518
- border-color: #404040;
519
- }
520
-
521
- .rte-source-editor-header h2 {
522
- color: #f8f9fa;
523
- }
524
-
525
- .rte-source-editor-fullscreen-btn,
526
- .rte-source-editor-close-btn {
527
- color: #ccc;
528
- }
529
-
530
- .rte-source-editor-fullscreen-btn:hover,
531
- .rte-source-editor-close-btn:hover {
532
- background: #404040;
533
- color: #f8f9fa;
534
- }
535
-
536
- .rte-source-editor-error {
537
- background: #2d1b1b;
538
- color: #fca5a5;
539
- border-color: #dc2626;
540
- }
541
-
542
- .rte-source-editor-warning {
543
- background: #2d2a1b;
544
- color: #fcd34d;
545
- border-color: #d97706;
546
- }
547
-
548
- .rte-source-editor-footer {
549
- background: #2d2d2d;
550
- border-color: #404040;
551
- }
552
-
553
- .rte-source-editor-footer-info {
554
- color: #ccc;
555
- }
556
-
557
- .rte-source-editor-btn-cancel {
558
- background: #374151;
559
- border-color: #4b5563;
560
- color: #f9fafb;
561
- }
562
-
563
- .rte-source-editor-btn-cancel:hover:not(:disabled) {
564
- background: #4b5563;
565
- border-color: #6b7280;
566
- }
567
- }
568
-
569
- /* Responsive design */
570
- @media (max-width: 768px) {
571
- .rte-source-editor-overlay {
572
- padding: 10px;
573
- }
574
-
575
- .rte-source-editor-modal {
576
- max-height: 95vh;
577
- }
578
-
579
- .rte-source-editor-header {
580
- padding: 12px 16px;
581
- }
582
-
583
- .rte-source-editor-footer {
584
- padding: 12px 16px;
585
- flex-direction: column;
586
- gap: 12px;
587
- align-items: stretch;
588
- }
589
-
590
- .rte-source-editor-footer-actions {
591
- justify-content: stretch;
592
- }
593
-
594
- .rte-source-editor-btn {
595
- flex: 1;
596
- text-align: center;
597
- }
598
- }`,sa=()=>({name:"code",toolbar:[{label:"Source",command:"toggleSourceView",type:"button",icon:"<>",shortcut:"Mod-Shift-S"}],commands:{toggleSourceView:()=>{const e=(()=>{const i=window.getSelection();if(i&&i.anchorNode){let l=i.anchorNode instanceof HTMLElement?i.anchorNode:i.anchorNode.parentElement;for(;l;){if(l.classList?.contains("rte-content"))return l;l=l.parentElement}}if(document.activeElement){let l=document.activeElement;if(l.classList?.contains("rte-content"))return l;for(;l&&l!==document.body;){if(l.classList?.contains("rte-content"))return l;const c=l.querySelector(".rte-content");if(c)return c;l=l.parentElement}}const a=document.querySelector("[data-editora-editor]");if(a){const l=a.querySelector(".rte-content");if(l)return l}return document.querySelector(".rte-content")})();if(!e)return console.error("[CodePlugin] Editor content area not found"),alert("Editor content area not found. Please click inside the editor first."),!1;const t=e.innerHTML,o=i=>{let a="",l=0;const c=2,s=i.split(/(<\/?[a-zA-Z][^>]*>)/);for(const d of s)d.trim()&&(d.match(/^<\/[a-zA-Z]/)?(l=Math.max(0,l-1),a+=`
599
- `+" ".repeat(l*c)+d):d.match(/^<[a-zA-Z]/)&&!d.match(/\/>$/)?(a+=`
600
- `+" ".repeat(l*c)+d,l++):d.match(/^<[a-zA-Z].*\/>$/)?a+=`
601
- `+" ".repeat(l*c)+d:a+=d.trim());return a.trim()};return(()=>{let i=null,a="dark",l=!1,c=!1,s=!1;const d=t,p=document.createElement("div");p.className="rte-source-editor-overlay";const g=document.createElement("div");g.className="rte-source-editor-modal",g.setAttribute("role","dialog"),g.setAttribute("aria-modal","true"),g.setAttribute("aria-labelledby","source-editor-title");const m=document.createElement("div");m.className="rte-source-editor-header",m.innerHTML=`
602
- <h2 id="source-editor-title">Source Editor</h2>
603
- <div class="rte-source-editor-header-toolbar">
604
- <button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
605
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
606
- <circle cx="12" cy="12" r="5"/>
607
- <line x1="12" y1="1" x2="12" y2="3"/>
608
- <line x1="12" y1="21" x2="12" y2="23"/>
609
- <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
610
- <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
611
- <line x1="1" y1="12" x2="3" y2="12"/>
612
- <line x1="21" y1="12" x2="23" y2="12"/>
613
- <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
614
- <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
615
- </svg>
616
- </button>
617
- <button class="rte-source-editor-toolbar-btn readonly-toggle-btn" title="Toggle read-only">
618
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
619
- <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
620
- <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
621
- </svg>
622
- </button>
623
- </div>
624
- <div class="rte-source-editor-header-actions">
625
- <button class="rte-source-editor-fullscreen-btn" title="Toggle fullscreen">
626
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
627
- <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
628
- </svg>
629
- </button>
630
- <button class="rte-source-editor-close-btn" aria-label="Close source editor">
631
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
632
- <line x1="18" y1="6" x2="6" y2="18"/>
633
- <line x1="6" y1="6" x2="18" y2="18"/>
634
- </svg>
635
- </button>
636
- </div>
637
- `;const b=document.createElement("div");b.className="rte-source-editor-body";const x=document.createElement("div");x.className="rte-source-editor-content";const C=document.createElement("div");C.className="rte-source-editor-warning",C.textContent="⚠️ Advanced users only. Invalid HTML may break the editor.";const k=document.createElement("div");k.className="rte-source-editor-light-editor",k.style.height="400px",x.appendChild(C),x.appendChild(k),b.appendChild(x);const y=document.createElement("div");if(y.className="rte-source-editor-footer",y.innerHTML=`
638
- <div class="rte-source-editor-footer-info">
639
- <span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
640
- </div>
641
- <div class="rte-source-editor-footer-actions">
642
- <button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
643
- <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
644
- </div>
645
- `,g.appendChild(m),g.appendChild(b),g.appendChild(y),p.appendChild(g),!document.getElementById("rte-source-editor-styles")){const N=document.createElement("style");N.id="rte-source-editor-styles",N.textContent=la,document.head.appendChild(N)}document.body.appendChild(p);try{i=aa(k,{value:o(t),theme:"dark",readOnly:!1,extensions:[new Ji,new ea,new ta,new oa,new na,new ra,new ia]}),i.on("change",()=>{s=(i?.getValue()||"")!==o(d);const F=y.querySelector(".unsaved-changes");F&&(F.style.display=s?"inline":"none")}),setTimeout(()=>i?.focus(),100)}catch(N){console.error("Failed to initialize code editor:",N)}const w=()=>{a=a==="dark"?"light":"dark",i?.setTheme(a);const N=m.querySelector(".theme-toggle-btn");N&&a==="light"&&(N.innerHTML=`
646
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
647
- <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
648
- </svg>
649
- `)},S=()=>{l=!l,i?.setReadOnly(l);const N=m.querySelector(".readonly-toggle-btn");N&&(l?(N.classList.add("active"),N.innerHTML=`
650
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
651
- <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
652
- <circle cx="12" cy="16" r="1"/>
653
- <path d="M7 11V7a5 5 0 0 1 10 0v4"/>
654
- </svg>
655
- `):(N.classList.remove("active"),N.innerHTML=`
656
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
657
- <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
658
- <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
659
- </svg>
660
- `))},E=()=>{c=!c,c?(p.classList.add("fullscreen"),k.style.height="calc(100vh - 200px)"):(p.classList.remove("fullscreen"),k.style.height="400px");const N=m.querySelector(".rte-source-editor-fullscreen-btn");N&&(N.innerHTML=c?`
661
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
662
- <path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3"/>
663
- </svg>
664
- `:`
665
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
666
- <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
667
- </svg>
668
- `)},f=()=>{i&&(i.destroy(),i=null),document.body.removeChild(p)},L=()=>{s&&!confirm("You have unsaved changes. Are you sure you want to cancel?")||f()},ve=()=>{try{const N=i?.getValue()||"",F=document.createElement("div");F.innerHTML=N,F.querySelectorAll('script, iframe[src^="javascript:"], object, embed').forEach(Q=>Q.remove()),e.innerHTML=F.innerHTML,s=!1,f()}catch(N){alert("Failed to update HTML. Please check your syntax."),console.error("HTML update error:",N)}};m.querySelector(".theme-toggle-btn")?.addEventListener("click",w),m.querySelector(".readonly-toggle-btn")?.addEventListener("click",S),m.querySelector(".rte-source-editor-fullscreen-btn")?.addEventListener("click",E),m.querySelector(".rte-source-editor-close-btn")?.addEventListener("click",f),y.querySelector(".rte-source-editor-btn-cancel")?.addEventListener("click",L),y.querySelector(".rte-source-editor-btn-save")?.addEventListener("click",ve),p.addEventListener("click",N=>{N.target===p&&f()});const H=N=>{N.key==="Escape"&&(f(),document.removeEventListener("keydown",H))};document.addEventListener("keydown",H)})(),!0}},keymap:{"Mod-Shift-s":"toggleSourceView","Mod-Shift-S":"toggleSourceView"}});function Qn(){const n=window.getSelection();if(!n||!n.rangeCount)return null;const t=n.getRangeAt(0).startContainer,o=t.nodeType===Node.TEXT_NODE?t.parentElement:t;return ca(o)}function ca(n){if(!n)return null;if(n.hasAttribute("data-editora-editor"))return n;let e=n.parentElement;for(;e;){if(e.hasAttribute("data-editora-editor"))return e;e=e.parentElement}return null}function Jn(n){return n?n.querySelector(".rte-content"):(console.warn("[Editora] Editor container not found"),null)}let D=null,O=null,Bo=null,Fo=null,qo=null,jo=null,Vo=null,rt=!1,Qe=null,Uo=0,Wo=0,pn=!1,Go=0,Zo=0,Ko=0,Xo=0;const da=()=>{const n=Qn(),e=Jn(n);if(!e)return alert("Please place your cursor in the editor before inserting a table"),!1;const t=window.getSelection();if(!t||t.rangeCount===0)return;const o=t.getRangeAt(0),r=document.createElement("table");r.className="rte-table";const i=document.createElement("thead"),a=document.createElement("tr");for(let s=0;s<3;s++){const d=document.createElement("th"),p=document.createElement("p");p.appendChild(document.createElement("br")),d.appendChild(p),a.appendChild(d)}i.appendChild(a);const l=document.createElement("tbody");for(let s=0;s<2;s++){const d=document.createElement("tr");for(let p=0;p<3;p++){const g=document.createElement("td"),m=document.createElement("p");m.appendChild(document.createElement("br")),g.appendChild(m),d.appendChild(g)}l.appendChild(d)}r.appendChild(i),r.appendChild(l),o.deleteContents(),o.insertNode(r);const c=r.querySelector("th p");if(c){const s=document.createRange();s.setStart(c,0),s.collapse(!0),t.removeAllRanges(),t.addRange(s)}e.focus()},ua=()=>{const n=ie();if(!n)return;const{table:e,rowIndex:t}=n,o=document.createElement("tr"),r=e.rows[0]?.cells.length||0;for(let a=0;a<r;a++){const l=document.createElement("td"),c=document.createElement("p");c.innerHTML="<br>",l.appendChild(c),o.appendChild(l)}const i=e.rows[t];i&&i.parentElement?i.parentElement.insertBefore(o,i):e.appendChild(o),xe()},eo=()=>{const n=ie();if(!n)return;const{table:e,rowIndex:t}=n,o=document.createElement("tr"),r=e.rows[0]?.cells.length||0;for(let i=0;i<r;i++){const a=document.createElement("td"),l=document.createElement("p");l.innerHTML="<br>",a.appendChild(l),o.appendChild(a)}t>=e.rows.length-1?e.appendChild(o):e.insertBefore(o,e.rows[t+1]),xe()},pa=()=>{const n=ie();if(!n)return;const{table:e,colIndex:t}=n;for(let o=0;o<e.rows.length;o++){const r=e.rows[o],i=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",i.appendChild(a),t===0?r.insertBefore(i,r.cells[0]):r.insertBefore(i,r.cells[t])}xe()},to=()=>{const n=ie();if(!n)return;const{table:e,colIndex:t}=n;for(let o=0;o<e.rows.length;o++){const r=e.rows[o],i=document.createElement("td"),a=document.createElement("p");a.innerHTML="<br>",i.appendChild(a),t>=r.cells.length-1?r.appendChild(i):r.insertBefore(i,r.cells[t+1])}xe()},ma=()=>{const n=ie();if(!n||n.rowCount<=1)return;const{table:e,rowIndex:t}=n;e.deleteRow(t),xe()},ga=()=>{const n=ie();if(!n||n.cellCount<=1)return;const{table:e,colIndex:t}=n;for(let o=0;o<e.rows.length;o++){const r=e.rows[o];r.cells[t]&&r.deleteCell(t)}xe()},ha=()=>{const n=ie();if(!n)return;const{table:e,rowIndex:t}=n,o=e.rows[t];if(o.parentElement?.tagName.toLowerCase()==="thead"){const i=e.querySelector("tbody")||e.appendChild(document.createElement("tbody")),a=e.querySelector("thead");a&&(i.insertBefore(o,i.firstChild),a.rows.length===0&&a.remove())}else{let i=e.querySelector("thead");i||(i=document.createElement("thead"),e.insertBefore(i,e.firstChild)),i.appendChild(o)}xe()},fa=()=>{const n=ie();if(!n)return;const{table:e,colIndex:t}=n;for(let o=0;o<e.rows.length;o++){const r=e.rows[o].cells[t];if(r){const i=r.tagName.toLowerCase()==="th"?"td":"th",a=document.createElement(i);a.innerHTML=r.innerHTML;for(let l=0;l<r.attributes.length;l++){const c=r.attributes[l];a.setAttribute(c.name,c.value)}r.parentNode?.replaceChild(a,r)}}xe()},ba=()=>{const n=ie();if(!n)return;n.table.remove(),document.dispatchEvent(new CustomEvent("tableDeleted"))},xa=()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return;const t=n.getRangeAt(0).startContainer;if(!(t.nodeType===Node.TEXT_NODE?t.parentElement?.closest("table"):t.closest("table")))return;let r=null;if(t.nodeType===Node.TEXT_NODE?r=t.parentElement?.closest("td, th"):t.nodeType===Node.ELEMENT_NODE&&(r=t.closest("td, th")),!r)return;const i=r.parentElement;if(!i)return;let a=-1;for(let p=0;p<i.cells.length;p++)if(i.cells[p]===r){a=p;break}if(a===-1||a===i.cells.length-1)return;const l=i.cells[a+1];if(!l)return;const c=parseInt(r.getAttribute("colspan")||"1"),s=parseInt(l.getAttribute("colspan")||"1");r.setAttribute("colspan",String(c+s)),Array.from(l.childNodes).forEach(p=>{r.appendChild(p)}),l.remove(),xe()};function ie(){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0).startContainer;let o=t.nodeType===Node.TEXT_NODE?t.parentElement?.closest("table"):t.closest("table");if(!o)return null;const r=o;let i=0,a=0;const l=t.nodeType===Node.TEXT_NODE?t.parentElement?.closest("td, th"):t.closest("td, th");if(l){let c=l.parentElement;for(;c&&c!==r.rows[i]&&(i++,!(i>=r.rows.length)););const s=c;if(s){for(let d=0;d<s.cells.length;d++)if(s.cells[d]===l){a=d;break}}}return{table:r,rowIndex:i,colIndex:a,rowCount:r.rows.length,cellCount:r.rows[0]?.cells.length||0}}function xe(){if(!D||!O)return;const n=ie();if(!n)return;const e=n.rowCount>1,t=n.cellCount>1;Fr(e,t)}function ya(){Bo=()=>{const n=ie();n?va(n.table):mn()},Fo=n=>{const e=n.target,t=e.closest("table"),o=e.closest(".table-toolbar");!t&&!o&&mn()},qo=()=>{mn()},jo=()=>{O&&D&&D.style.display!=="none"&&Nn(O)},Vo=()=>{O&&D&&D.style.display!=="none"&&Nn(O)},document.addEventListener("selectionchange",Bo),document.addEventListener("mousedown",Fo),document.addEventListener("tableDeleted",qo),window.addEventListener("scroll",jo,!0),window.addEventListener("resize",Vo)}function Nn(n){if(!D)return;const e=n.getBoundingClientRect(),t=D.getBoundingClientRect(),o=t.height||40,r=t.width||280,i=10;let a=e.top-o-i,l=e.left+e.width/2-r/2;a<i&&(a=e.bottom+i),l<i&&(l=i);const c=window.innerWidth;l+r>c-i&&(l=c-r-i);const s=window.innerHeight;a+o>s-i&&(a=s-o-i),D.style.top=a+"px",D.style.left=l+"px"}function va(n){O=n,D||(D=wa(),document.body.appendChild(D)),D.style.display="flex",D.style.visibility="hidden",requestAnimationFrame(()=>{Nn(n),D&&(D.style.visibility="visible")});const e=ie();e&&Fr(e.rowCount>1,e.cellCount>1),ka(n)}function mn(){if(D&&(D.style.display="none"),O){O.querySelectorAll(".resize-handle").forEach(t=>t.remove());const e=O.querySelector(".table-resize-handle");e&&e.remove()}O=null}function Fr(n,e){if(!D)return;const t=D.querySelector('[data-action="deleteRow"]'),o=D.querySelector('[data-action="deleteColumn"]');t&&(t.disabled=!n),o&&(o.disabled=!e)}function wa(){const n=document.createElement("div");n.className="table-toolbar",n.style.cssText=`
669
- position: fixed;
670
- z-index: 1000;
671
- display: none;
672
- `,n.setAttribute("role","toolbar"),n.setAttribute("aria-label","Table editing toolbar");const e=d=>{const p=document.createElement("button");return p.className="toolbar-icon-btn",d.danger&&p.classList.add("toolbar-icon-btn-danger"),d.delete&&p.classList.add("toolbar-icon-btn-delete"),p.innerHTML=d.icon,p.title=d.title,p.setAttribute("aria-label",d.title),p.setAttribute("type","button"),p.setAttribute("data-action",d.action),p.onclick=()=>Ca(d.action),p},t=()=>{const d=document.createElement("div");return d.className="toolbar-divider",d},o=(...d)=>{const p=document.createElement("div");return p.className="toolbar-section",d.forEach(g=>p.appendChild(g)),p},r=o(e({icon:Ta(),title:"Add row above (Ctrl+Shift+R)",action:"addRowAbove"}),e({icon:La(),title:"Add row below",action:"addRowBelow"}),e({icon:Aa(),title:"Delete row",action:"deleteRow",danger:!0})),i=o(e({icon:Ma(),title:"Add column left",action:"addColumnLeft"}),e({icon:Na(),title:"Add column right (Ctrl+Shift+C)",action:"addColumnRight"}),e({icon:Ra(),title:"Delete column",action:"deleteColumn",danger:!0})),a=o(e({icon:za(),title:"Toggle header row",action:"toggleHeaderRow"}),e({icon:Ia(),title:"Toggle header column",action:"toggleHeaderColumn"})),l=o(e({icon:_a(),title:"Merge cells (horizontally)",action:"mergeCells"})),c=o(e({icon:Da(),title:"Delete table",action:"deleteTable",delete:!0}));n.appendChild(r),n.appendChild(t()),n.appendChild(i),n.appendChild(t()),n.appendChild(a),n.appendChild(t()),n.appendChild(l),n.appendChild(t()),n.appendChild(c);const s=d=>{!D||D.style.display==="none"||(d.ctrlKey||d.metaKey)&&d.shiftKey&&(d.key==="r"||d.key==="R"?(d.preventDefault(),eo()):(d.key==="c"||d.key==="C")&&(d.preventDefault(),to()))};return window.addEventListener("keydown",s),n}function Ca(n){switch(n){case"addRowAbove":ua();break;case"addRowBelow":eo();break;case"addColumnLeft":pa();break;case"addColumnRight":to();break;case"deleteRow":ma();break;case"deleteColumn":ga();break;case"toggleHeaderRow":ha();break;case"toggleHeaderColumn":fa();break;case"deleteTable":ba();break;case"mergeCells":xa();break}}function ka(n){n.querySelectorAll(".resize-handle").forEach(a=>a.remove());const t=n.querySelector(".table-resize-handle");t&&t.remove();const o=n.querySelector("thead tr, tbody tr:first-child");if(!o)return;const r=o.querySelectorAll("td, th");r.forEach((a,l)=>{if(l===r.length-1)return;const c=document.createElement("div");c.className="resize-handle",c.style.cssText=`
673
- position: absolute;
674
- right: -4px;
675
- top: 0;
676
- bottom: 0;
677
- width: 8px;
678
- background: transparent;
679
- cursor: col-resize;
680
- z-index: 10;
681
- transition: background 0.15s ease;
682
- `,c.addEventListener("mouseenter",()=>{rt||(c.style.background="rgba(0, 102, 204, 0.3)")}),c.addEventListener("mouseleave",()=>{rt||(c.style.background="transparent")}),c.addEventListener("mousedown",s=>{s.preventDefault(),s.stopPropagation(),Ea(s,l)}),a.style.position="relative",a.appendChild(c)});const i=document.createElement("div");i.className="table-resize-handle",i.addEventListener("mousedown",a=>{a.preventDefault(),a.stopPropagation(),Sa(a)}),n.appendChild(i)}function Ea(n,e){if(rt=!0,Qe=e,Uo=n.clientX,!O)return;const t=O.querySelector("thead tr, tbody tr:first-child");t&&t.cells[e]&&(Wo=t.cells[e].offsetWidth),document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=i=>{if(!rt||Qe===null||!O)return;const a=i.clientX-Uo,l=Math.max(50,Wo+a);O.querySelectorAll("tr").forEach(s=>{s.cells[Qe]&&(s.cells[Qe].style.width=l+"px")})},r=()=>{rt=!1,Qe=null,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",r)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",r)}function Sa(n){if(!O)return;pn=!0,Go=n.clientX,Zo=n.clientY,Ko=O.offsetWidth,Xo=O.offsetHeight,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none";const e=o=>{if(!pn||!O)return;const r=o.clientX-Go,i=o.clientY-Zo,a=Math.max(200,Ko+r),l=Math.max(100,Xo+i);O.style.width=a+"px",O.style.height=l+"px"},t=()=>{pn=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)};document.addEventListener("mousemove",e),document.addEventListener("mouseup",t)}function Ta(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
683
- <path d="M2 7h12V5H2v2zm0 4h12V9H2v2zM8 1v3H5v2h3v3h2V6h3V4h-3V1H8z"/>
684
- </svg>`}function La(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
685
- <path d="M2 3h12V1H2v2zm0 4h12V5H2v2zm6 4v3h3v-2h2v-2h-2v-3h-2v3H5v2h3z"/>
686
- </svg>`}function Aa(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
687
- <path d="M2 5h12v2H2V5zm0 4h12v2H2V9zm4-6v2H4v2h2v2h2V7h2V5H8V3H6z"/>
688
- </svg>`}function Ma(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
689
- <path d="M7 2v12h2V2H7zm4 0v12h2V2h-2zM1 8h3v-3H1v3zm3 2H1v3h3v-3z"/>
690
- </svg>`}function Na(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
691
- <path d="M2 2v12h2V2H2zm4 0v12h2V2H6zM12 8h3v-3h-3v3zm0 2h3v3h-3v-3z"/>
692
- </svg>`}function Ra(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
693
- <path d="M5 2v12h2V2H5zm4 0v12h2V2H9zm3 2h3V1h-3v3zm3 2h-3v3h3V6zm0 4h-3v3h3v-3z"/>
694
- </svg>`}function za(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
695
- <path d="M2 2h12v3H2V2zm0 5h12v8H2V7zm2 2v4h2V9H4zm4 0v4h2V9H8zm4 0v4h2V9h-2z"/>
696
- </svg>`}function Ia(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
697
- <path d="M2 2v12h3V2H2zm5 0v12h8V2H7zm2 2h4v2H9V4zm0 4h4v2H9V8zm0 4h4v2H9v-2z"/>
698
- </svg>`}function Da(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
699
- <path d="M3 1h10v1H3V1zm1 2v11h8V3H4zM6 5h1v6H6V5zm3 0h1v6H9V5z"/>
700
- </svg>`}function _a(){return`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
701
- <path d="M2 2h4v3H2V2zm5 0h4v3H7V2zm5 0h2v3h-2V2zm-10 4h4v3H2V6zm5 0h4v3H7V6zm5 0h2v3h-2V6zm-10 4h4v3H2v-3zm5 0h4v3H7v-3zm5 0h2v3h-2v-3z"/>
702
- </svg>`}if(typeof window<"u"&&!window.__tablePluginInitialized){window.__tablePluginInitialized=!0;const n=()=>{ya()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n):setTimeout(n,100)}const Ha=()=>({name:"table",toolbar:[{label:"Insert Table",command:"insertTable",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 10V20M3 15L21 15M3 10H21M6.2 20H17.8C18.9201 20 19.4802 20 19.908 19.782C20.2843 19.5903 20.5903 19.2843 20.782 18.908C21 18.4802 21 17.9201 21 16.8V7.2C21 6.0799 21 5.51984 20.782 5.09202C20.5903 4.71569 20.2843 4.40973 19.908 4.21799C19.4802 4 18.9201 4 17.8 4H6.2C5.0799 4 4.51984 4 4.09202 4.21799C3.71569 4.40973 3.40973 4.71569 3.21799 5.09202C3 5.51984 3 6.07989 3 7.2V16.8C3 17.9201 3 18.4802 3.21799 18.908C3.40973 19.2843 3.71569 19.5903 4.09202 19.782C4.51984 20 5.07989 20 6.2 20Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>'}],commands:{insertTable:()=>(da(),!0)},keymap:{"Mod-Shift-r":()=>(eo(),!0),"Mod-Shift-c":()=>(to(),!0)}}),Pa=()=>({name:"fontSize",marks:{fontSize:{attrs:{size:{default:null}},parseDOM:[{tag:'span[style*="font-size"]',getAttrs:n=>{const t=n.style.fontSize;return t?{size:t}:!1}},{tag:"font[size]",getAttrs:n=>{const t=n.getAttribute("size");return t?{size:t}:!1}}],toDOM:n=>["span",{style:`font-size: ${n.attrs.size}`},0]}},toolbar:[{label:"Font Size",command:"fontSize",type:"group",items:[{label:"Decrease Font Size",command:"decreaseFontSize",icon:"−",type:"button"},{label:"Font Size",command:"setFontSize",type:"input",placeholder:"14"},{label:"Increase Font Size",command:"increaseFontSize",icon:"+",type:"button"}]}],commands:{decreaseFontSize:()=>{try{return Yo(-2),Qo(),!0}catch(n){return console.error("Failed to decrease font size:",n),!1}},increaseFontSize:()=>{try{return Yo(2),Qo(),!0}catch(n){return console.error("Failed to increase font size:",n),!1}},setFontSize:n=>{if(!n)return!1;try{const t=n.trim().match(/^(\d+(?:\.\d+)?)(px|em|rem)?$/i);if(!t)return!1;const o=parseFloat(t[1]),r=t[2]?.toLowerCase()||"px";return r==="px"&&(o<8||o>72)||(r==="em"||r==="rem")&&(o<.5||o>5)?!1:(jr(o,r),!0)}catch(e){return console.error("Failed to set font size:",e),!1}}},keymap:{}});function Yo(n){const e=window.getSelection();if(!e||e.rangeCount===0)return;const{value:t,unit:o}=qr();let r=n;(o==="em"||o==="rem")&&(r=n*.125);let i;o==="px"?i=n<0?Math.max(8,t+n):Math.min(72,t+n):i=n<0?Math.max(.5,t+r):Math.min(5,t+r),jr(i,o)}function qr(){const n=window.getSelection();if(!n||n.rangeCount===0)return{value:14,unit:"px"};const t=n.getRangeAt(0).startContainer,o=t.nodeType===Node.TEXT_NODE?t.parentElement:t;if(o){const r=o.style?.fontSize;if(r){const c=r.match(/^(\d+(?:\.\d+)?)(px|em|rem)$/i);if(c)return{value:parseFloat(c[1]),unit:c[2].toLowerCase()}}const l=window.getComputedStyle(o).fontSize.match(/^(\d+(?:\.\d+)?)(px|em|rem)$/i);if(l)return{value:parseFloat(l[1]),unit:l[2].toLowerCase()}}return{value:14,unit:"px"}}function jr(n,e="px"){const t=window.getSelection();if(!t||t.rangeCount===0)return;const o=t.getRangeAt(0);if(o.collapsed)return;const r=`${n}${e}`,i=o.commonAncestorContainer,a=Oa(i);if(a&&$a(o,a)){a.style.fontSize=r;const l=document.createRange();l.selectNodeContents(a),t.removeAllRanges(),t.addRange(l)}else{const l=document.createElement("span");l.style.fontSize=r;try{o.surroundContents(l)}catch{const d=o.extractContents();l.appendChild(d),o.insertNode(l)}const c=document.createRange();c.selectNodeContents(l),t.removeAllRanges(),t.addRange(c)}}function Oa(n){let e=n;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.tagName==="SPAN"&&t.style.fontSize)return t}e=e.parentNode}return null}function $a(n,e){const t=n.startContainer,o=n.endContainer;return e.contains(t)&&e.contains(o)}function Qo(){setTimeout(()=>{const{value:n,unit:e}=qr();let t=null;if(t=document.querySelector('input[placeholder="14"]'),t||(t=document.querySelector('.rte-toolbar-input[type="text"]')),!t){const o=Array.from(document.querySelectorAll("button")).find(r=>r.textContent?.trim()==="−");o&&o.parentElement&&(t=o.parentElement.querySelector('input[type="text"]'))}if(t){const o=n%1===0?n.toString():n.toFixed(2).replace(/\.?0+$/,"");t.value=`${o}${e}`}},10)}const Ba=()=>({name:"fontFamily",marks:{fontFamily:{attrs:{family:{default:null}},parseDOM:[{tag:'span[style*="font-family"]',getAttrs:n=>{const t=n.style.fontFamily;return t?{family:t}:!1}},{tag:"font[face]",getAttrs:n=>{const t=n.getAttribute("face");return t?{family:t}:!1}}],toDOM:n=>["span",{style:`font-family: ${n.attrs.family}`},0]}},toolbar:[{label:"Font Family",command:"setFontFamily",type:"inline-menu",options:[{label:"Arial",value:"Arial, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Helvetica",value:"Helvetica, Arial, sans-serif"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Impact",value:"Impact, sans-serif"}],icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path d="M15 4h7v2h-7zm1 4h6v2h-6zm2 4h4v2h-4zM9.307 4l-6 16h2.137l1.875-5h6.363l1.875 5h2.137l-6-16H9.307zm-1.239 9L10.5 6.515 12.932 13H8.068z"></path></g></svg>'}],commands:{setFontFamily:n=>{if(!n)return!1;try{return Fa(n),!0}catch(e){return console.error("Failed to set font family:",e),!1}}},keymap:{"Mod-Shift-f":"setFontFamily"}});function Fa(n){const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0);if(t.collapsed)return;const o=t.commonAncestorContainer,r=qa(o);if(r&&ja(t,r)){r.style.fontFamily=n;const i=document.createRange();i.selectNodeContents(r),e.removeAllRanges(),e.addRange(i);const a=r.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}else{const i=document.createElement("span");i.style.fontFamily=n,i.className="rte-font-family";try{t.cloneRange().surroundContents(i),t.selectNodeContents(i),e.removeAllRanges(),e.addRange(t)}catch{const c=t.extractContents();i.appendChild(c),t.insertNode(i);const s=document.createRange();s.selectNodeContents(i),e.removeAllRanges(),e.addRange(s)}const a=i.closest('[contenteditable="true"]');a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}}function qa(n){let e=n;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.tagName==="SPAN"&&t.style.fontFamily)return t}e=e.parentNode}return null}function ja(n,e){const t=n.startContainer,o=n.endContainer,r=e.contains(t)||t.nodeType===Node.TEXT_NODE&&t.parentElement===e,i=e.contains(o)||o.nodeType===Node.TEXT_NODE&&o.parentElement===e;return r&&i}const Rn=["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE","TD","TH"];function Jo(n){let e=n;if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(Rn.includes(t.tagName))return t}for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(Rn.includes(t.tagName))return t;if(t.hasAttribute("contenteditable"))return null}e=e.parentNode}return null}function Va(n){const e=[],t=Jo(n.startContainer),o=Jo(n.endContainer);if(!t&&!o)return e;if(n.collapsed)return t&&e.push(t),e;if(t===o)t&&e.push(t);else{let r=t;const i=new Set;for(t&&(e.push(t),i.add(t));r&&r!==o&&!i.has(o);){let a=r.nextElementSibling;for(;a;){if(Rn.includes(a.tagName)){r=a,i.has(r)||(e.push(r),i.add(r));break}a=a.nextElementSibling}if(!a)break}o&&!e.includes(o)&&e.push(o)}return e}const Ua=n=>{if(!n||!["left","center","right","justify"].includes(n))return!1;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const o=t.getRangeAt(0).cloneRange(),r=Va(o);if(r.length>0){r.forEach(a=>{a&&(a.style.textAlign=n)}),t.removeAllRanges(),t.addRange(o);const i=o.commonAncestorContainer.parentElement?.closest('[contenteditable="true"]');i&&i.dispatchEvent(new Event("input",{bubbles:!0}))}else try{const i=document.createElement("div");i.style.textAlign=n;const a=o.extractContents();i.appendChild(a),o.insertNode(i);const l=document.createRange();l.selectNodeContents(i),t.removeAllRanges(),t.addRange(l);const c=i.closest('[contenteditable="true"]');c&&c.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){return console.error("Failed to wrap content for alignment:",i),!1}return!0},Wa=()=>({name:"textAlignment",toolbar:[{label:"Text Alignment",command:"setTextAlignment",type:"inline-menu",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"},{label:"Justify",value:"justify"}],icon:'<svg width="24" height="24" focusable="false"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2Zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2Z" fill-rule="evenodd"></path></svg>'}],commands:{setTextAlignment:Ua},keymap:{}});let z=null,zt=null,It=null,te="#000000";const Ga=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function St(n){try{if(It){const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(It))}const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return!1;const t=e.getRangeAt(0),o=t.startContainer.nodeType===Node.TEXT_NODE?t.startContainer.parentElement:t.startContainer,r=t.endContainer.nodeType===Node.TEXT_NODE?t.endContainer.parentElement:t.endContainer;let i=null,a=o;for(;a&&a!==document.body;){if(a.classList.contains("rte-text-color")){const s=document.createRange();if(s.selectNodeContents(a),s.compareBoundaryPoints(Range.START_TO_START,t)<=0&&s.compareBoundaryPoints(Range.END_TO_END,t)>=0){i=a;break}}a=a.parentElement}if(i)return i.style.color=n,!0;const l=document.createElement("span");l.style.color=n,l.className="rte-text-color";const c=t.extractContents();return l.appendChild(c),t.insertNode(l),t.setStartAfter(l),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!0}catch(e){return console.error("Failed to set text color:",e),!1}}function Za(){const n=window.getSelection();if(!n||n.rangeCount===0)return"#000000";let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t,r=o.style.color||window.getComputedStyle(o).color;if(r&&r!=="rgb(0, 0, 0)")return Ka(r)}t=t.parentNode}return"#000000"}function Ka(n){if(n.startsWith("#"))return n;const e=n.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!e)return"#000000";const t=parseInt(e[1]),o=parseInt(e[2]),r=parseInt(e[3]);return"#"+[t,o,r].map(i=>{const a=i.toString(16);return a.length===1?"0"+a:a}).join("")}function Xa(n){const e=window.getSelection();e&&e.rangeCount>0&&(It=e.getRangeAt(0).cloneRange()),te=Za(),z=document.createElement("div"),z.className="rte-inline-color-picker",z.addEventListener("click",o=>o.stopPropagation()),z.innerHTML=`
703
- <div class="rte-color-picker-header">
704
- <span class="rte-color-picker-title">Text Color</span>
705
- <button class="rte-color-picker-close" aria-label="Close">×</button>
706
- </div>
707
-
708
- <div class="rte-color-picker-body">
709
- <!-- Current Color Preview -->
710
- <div class="rte-color-preview-section">
711
- <div class="rte-color-preview-box" style="background-color: ${te}; ${te==="#ffffff"?"border: 1px solid #ccc;":""}"></div>
712
- <span class="rte-color-preview-label">${te.toUpperCase()}</span>
713
- </div>
714
-
715
- <!-- Preset Colors -->
716
- <div class="rte-color-section">
717
- <label class="rte-color-section-label">Colors</label>
718
- <div class="rte-color-palette">
719
- ${Ga.map(o=>`
720
- <button
721
- class="rte-color-swatch ${te===o?"selected":""}"
722
- style="background-color: ${o}; ${o==="#ffffff"?"border: 1px solid #ccc;":""}"
723
- data-color="${o}"
724
- title="${o.toUpperCase()}"
725
- aria-label="${o.toUpperCase()}"
726
- ></button>
727
- `).join("")}
728
- </div>
729
- </div>
730
-
731
- <!-- Custom Color -->
732
- <div class="rte-color-section">
733
- <label class="rte-color-section-label">Custom</label>
734
- <div class="rte-custom-color-inputs">
735
- <input
736
- type="color"
737
- value="${te}"
738
- class="rte-color-input-native"
739
- aria-label="Color picker"
740
- />
741
- <input
742
- type="text"
743
- value="${te}"
744
- placeholder="#000000"
745
- pattern="^#[0-9A-Fa-f]{6}$"
746
- class="rte-color-input-text"
747
- aria-label="Hex color input"
748
- />
749
- </div>
750
- </div>
751
- </div>
752
- `;const t=n.getBoundingClientRect();z.style.position="absolute",z.style.top=`${t.bottom+window.scrollY+4}px`,z.style.left=`${t.left+window.scrollX}px`,z.style.zIndex="10000",document.body.appendChild(z),zt=n,Ya()}function Ya(){if(!z)return;z.querySelector(".rte-color-picker-close")?.addEventListener("click",()=>Ve()),z.querySelectorAll(".rte-color-swatch").forEach(r=>{r.addEventListener("click",()=>{const i=r.getAttribute("data-color");i&&(te=i,St(i),Ve())})});const t=z.querySelector(".rte-color-input-native");t?.addEventListener("change",r=>{const i=r.target.value;te=i,St(i),Ve()});const o=z.querySelector(".rte-color-input-text");o?.addEventListener("change",r=>{const i=r.target.value;/^#[0-9A-Fa-f]{6}$/.test(i)&&(te=i,St(i),Ve())}),t?.addEventListener("input",r=>{const i=r.target.value;te=i,er(i),tr(i),Ja(i)}),o?.addEventListener("input",r=>{const i=r.target.value;/^#[0-9A-Fa-f]{6}$/.test(i)&&(te=i,er(i),tr(i),Qa(i))})}function er(n){if(!z)return;const e=z.querySelector(".rte-color-preview-box"),t=z.querySelector(".rte-color-preview-label");e&&(e.style.backgroundColor=n,e.style.border=n==="#ffffff"?"1px solid #ccc":"none"),t&&(t.textContent=n.toUpperCase())}function tr(n){if(!z)return;z.querySelectorAll(".rte-color-swatch").forEach(t=>{t.getAttribute("data-color")===n?t.classList.add("selected"):t.classList.remove("selected")})}function Qa(n){if(!z)return;const e=z.querySelector(".rte-color-input-native");e&&(e.value=n)}function Ja(n){if(!z)return;const e=z.querySelector(".rte-color-input-text");e&&(e.value=n)}function Ve(){z&&(z.remove(),z=null),zt=null,It=null}function el(){if(z)return Ve(),!0;const n=document.querySelector('[data-command="openTextColorPicker"]');return n?(Xa(n),!0):!1}function nr(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,document.addEventListener("click",n=>{if(z&&zt){const e=n.target;!z.contains(e)&&!zt.contains(e)&&Ve()}}),!document.getElementById("text-color-plugin-styles"))){const n=document.createElement("style");n.id="text-color-plugin-styles",n.textContent=`
753
- .rte-inline-color-picker {
754
- background: white;
755
- border-radius: 8px;
756
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
757
- width: 220px;
758
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
759
- }
760
-
761
- .rte-color-picker-header {
762
- padding: 12px 16px;
763
- border-bottom: 1px solid #eee;
764
- display: flex;
765
- justify-content: space-between;
766
- align-items: center;
767
- }
768
-
769
- .rte-color-picker-title {
770
- font-size: 14px;
771
- font-weight: 600;
772
- color: #333;
773
- }
774
-
775
- .rte-color-picker-close {
776
- background: none;
777
- border: none;
778
- font-size: 24px;
779
- cursor: pointer;
780
- color: #999;
781
- padding: 0;
782
- width: 24px;
783
- height: 24px;
784
- display: flex;
785
- align-items: center;
786
- justify-content: center;
787
- line-height: 1;
788
- }
789
-
790
- .rte-color-picker-close:hover {
791
- color: #333;
792
- }
793
-
794
- .rte-color-picker-body {
795
- padding: 8px;
796
- }
797
-
798
- .rte-color-preview-section {
799
- display: flex;
800
- align-items: center;
801
- gap: 12px;
802
- margin-bottom: 8px;
803
- padding: 6px;
804
- background-color: #f8f9fa;
805
- border-radius: 6px;
806
- border: 1px solid #e0e0e0;
807
- }
808
-
809
- .rte-color-preview-box {
810
- width: 24px;
811
- height: 24px;
812
- border-radius: 4px;
813
- flex-shrink: 0;
814
- }
815
-
816
- .rte-color-preview-label {
817
- font-size: 13px;
818
- font-weight: 500;
819
- color: #666;
820
- font-family: monospace;
821
- }
822
-
823
- .rte-color-section {
824
- margin-bottom: 16px;
825
- }
826
-
827
- .rte-color-section:last-child {
828
- margin-bottom: 0;
829
- }
830
-
831
- .rte-color-section-label {
832
- display: block;
833
- font-size: 12px;
834
- font-weight: 600;
835
- color: #666;
836
- margin-bottom: 8px;
837
- text-transform: uppercase;
838
- letter-spacing: 0.5px;
839
- }
840
-
841
- .rte-color-palette {
842
- display: grid;
843
- grid-template-columns: repeat(7, 1fr);
844
- gap: 6px;
845
- max-width: 180px;
846
- }
847
-
848
- .rte-color-swatch {
849
- width: 100%;
850
- aspect-ratio: 1;
851
- border: 1px solid #e0e0e0;
852
- border-radius: 3px;
853
- cursor: pointer;
854
- transition: all 0.15s ease;
855
- padding: 0;
856
- min-height: 20px;
857
- }
858
-
859
- .rte-color-swatch:hover {
860
- transform: scale(1.05);
861
- border-color: #ccc;
862
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
863
- }
864
-
865
- .rte-color-swatch.selected {
866
- border-color: #1976d2;
867
- box-shadow: 0 0 0 1px rgba(25, 118, 210, 0.3);
868
- }
869
-
870
- .rte-custom-color-inputs {
871
- display: flex;
872
- gap: 8px;
873
- }
874
-
875
- .rte-color-input-native {
876
- width: 50px;
877
- height: 26px;
878
- border: 1px solid #ddd;
879
- border-radius: 4px;
880
- cursor: pointer;
881
- padding: 2px;
882
- }
883
-
884
- .rte-color-input-text {
885
- flex: 1;
886
- height: 26px;
887
- width: 50px;
888
- border: 1px solid #ddd;
889
- border-radius: 4px;
890
- padding: 0 12px;
891
- font-size: 13px;
892
- font-family: monospace;
893
- }
894
-
895
- .rte-color-input-text:focus {
896
- outline: none;
897
- border-color: #1976d2;
898
- }
899
-
900
- .rte-color-picker-footer {
901
- padding: 12px 16px;
902
- border-top: 1px solid #eee;
903
- display: flex;
904
- gap: 8px;
905
- justify-content: flex-end;
906
- }
907
-
908
- .rte-btn-primary,
909
- .rte-btn-secondary {
910
- padding: 6px 16px;
911
- border-radius: 4px;
912
- font-size: 13px;
913
- font-weight: 500;
914
- cursor: pointer;
915
- transition: all 0.2s;
916
- border: none;
917
- }
918
-
919
- .rte-btn-primary {
920
- background-color: #1976d2;
921
- color: white;
922
- }
923
-
924
- .rte-btn-primary:hover {
925
- background-color: #1565c0;
926
- }
927
-
928
- .rte-btn-secondary {
929
- background-color: #f5f5f5;
930
- color: #333;
931
- border: 1px solid #ddd;
932
- }
933
-
934
- .rte-btn-secondary:hover {
935
- background-color: #eeeeee;
936
- }
937
- `,document.head.appendChild(n)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",nr):setTimeout(nr,100);const tl=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:n=>{const t=(n.getAttribute("style")||"").match(/color:\s*([^;]+)/);return t?{color:t[1]}:null}},{tag:"font[color]",getAttrs:n=>{const e=n.getAttribute("color");return e?{color:e}:null}}],toDOM:n=>["span",{style:`color: ${n.attrs?.color||"#000000"}`,class:"rte-text-color"},0]}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>el(),setTextColor:n=>n?St(n):!1},keymap:{}});let _=null,Dt=null,_t=null,Y="#ffff00";const nl=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function ol(){if(document.getElementById("rte-bg-color-picker-styles"))return;const n=document.createElement("style");n.id="rte-bg-color-picker-styles",n.textContent=`
938
- /* Background Color Picker Container */
939
- .rte-bg-color-picker {
940
- position: absolute;
941
- background: white;
942
- border: 1px solid #ccc;
943
- border-radius: 8px;
944
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
945
- padding: 16px;
946
- z-index: 10000;
947
- width: 220px;
948
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
949
- font-size: 14px;
950
- display: flex;
951
- flex-direction: column;
952
- gap: 16px;
953
- }
954
-
955
- /* Preview Section */
956
- .rte-bg-color-preview {
957
- display: flex;
958
- flex-direction: column;
959
- gap: 8px;
960
- }
961
-
962
- .rte-bg-color-preview-label {
963
- font-weight: 600;
964
- color: #333;
965
- font-size: 13px;
966
- }
967
-
968
- .rte-bg-color-preview-box {
969
- display: flex;
970
- align-items: center;
971
- gap: 12px;
972
- padding: 3px;
973
- background: #f5f5f5;
974
- border-radius: 4px;
975
- border: 1px solid #e0e0e0;
976
- }
977
-
978
- .rte-bg-color-preview-swatch {
979
- width: 24px;
980
- height: 24px;
981
- border: 2px solid #ddd;
982
- border-radius: 4px;
983
- flex-shrink: 0;
984
- }
985
-
986
- .rte-bg-color-preview-hex {
987
- font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
988
- font-size: 14px;
989
- font-weight: 600;
990
- color: #555;
991
- user-select: all;
992
- }
993
-
994
- /* Preset Colors Section */
995
- .rte-bg-color-section {
996
- display: flex;
997
- flex-direction: column;
998
- gap: 8px;
999
- }
1000
-
1001
- .rte-bg-color-section-label {
1002
- font-weight: 600;
1003
- color: #333;
1004
- font-size: 13px;
1005
- }
1006
-
1007
- .rte-bg-color-grid {
1008
- display: grid;
1009
- grid-template-columns: repeat(7, 1fr);
1010
- gap: 6px;
1011
- max-width: 180px;
1012
- }
1013
-
1014
- .rte-bg-color-swatch {
1015
- width: 100%;
1016
- aspect-ratio: 1;
1017
- border: 1px solid #e0e0e0;
1018
- border-radius: 3px;
1019
- cursor: pointer;
1020
- transition: all 0.15s ease;
1021
- padding: 0;
1022
- background: none;
1023
- position: relative;
1024
- min-height: 20px;
1025
- }
1026
-
1027
- .rte-bg-color-swatch:hover {
1028
- border-color: #ccc;
1029
- transform: scale(1.05);
1030
- }
1031
-
1032
- .rte-bg-color-swatch.selected {
1033
- border-color: #1976d2;
1034
- border-width: 2px;
1035
- transform: scale(1.02);
1036
- }
1037
-
1038
- .rte-bg-color-swatch.selected::after {
1039
- content: '✓';
1040
- position: absolute;
1041
- top: 50%;
1042
- left: 50%;
1043
- transform: translate(-50%, -50%);
1044
- color: white;
1045
- font-weight: bold;
1046
- font-size: 12px;
1047
- text-shadow: 0 0 2px rgba(0,0,0,0.5);
1048
- }
1049
-
1050
- /* Custom Color Section */
1051
- .rte-bg-color-custom {
1052
- display: flex;
1053
- gap: 8px;
1054
- align-items: center;
1055
- }
1056
-
1057
- .rte-bg-color-input {
1058
- width: 50px;
1059
- height: 26px;
1060
- border: 2px solid #ddd;
1061
- border-radius: 4px;
1062
- cursor: pointer;
1063
- padding: 2px;
1064
- background: white;
1065
- }
1066
-
1067
- .rte-bg-color-input:hover {
1068
- border-color: #999;
1069
- }
1070
-
1071
- .rte-bg-color-text-input {
1072
- flex: 1;
1073
- height: 24px;
1074
- border: 2px solid #ddd;
1075
- border-radius: 4px;
1076
- padding: 0 12px;
1077
- width: 60px;
1078
- font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
1079
- font-size: 14px;
1080
- transition: border-color 0.2s ease;
1081
- }
1082
-
1083
- .rte-bg-color-text-input:focus {
1084
- outline: none;
1085
- border-color: #0066cc;
1086
- }
1087
-
1088
- .rte-bg-color-text-input::placeholder {
1089
- color: #aaa;
1090
- }
1091
-
1092
- /* Action Buttons */
1093
- .rte-bg-color-actions {
1094
- display: flex;
1095
- gap: 8px;
1096
- justify-content: flex-end;
1097
- padding-top: 8px;
1098
- border-top: 1px solid #e0e0e0;
1099
- }
1100
-
1101
- .rte-bg-color-btn {
1102
- padding: 8px 16px;
1103
- border: none;
1104
- border-radius: 4px;
1105
- font-size: 13px;
1106
- font-weight: 500;
1107
- cursor: pointer;
1108
- transition: all 0.2s ease;
1109
- }
1110
-
1111
- .rte-bg-color-btn-cancel {
1112
- background: #f5f5f5;
1113
- color: #666;
1114
- }
1115
-
1116
- .rte-bg-color-btn-cancel:hover {
1117
- background: #e0e0e0;
1118
- }
1119
-
1120
- .rte-bg-color-btn-apply {
1121
- background: #0066cc;
1122
- color: white;
1123
- }
1124
-
1125
- .rte-bg-color-btn-apply:hover {
1126
- background: #0052a3;
1127
- }
1128
-
1129
- .rte-bg-color-btn:active {
1130
- transform: scale(0.98);
1131
- }
1132
- `,document.head.appendChild(n)}function rl(){const n=document.createElement("div");n.className="rte-bg-color-picker";const e=document.createElement("div");e.className="rte-bg-color-preview";const t=document.createElement("div");t.className="rte-bg-color-preview-label",t.textContent="Current Color";const o=document.createElement("div");o.className="rte-bg-color-preview-box";const r=document.createElement("div");r.className="rte-bg-color-preview-swatch",r.id="rte-bg-color-preview-swatch";const i=document.createElement("span");i.className="rte-bg-color-preview-hex",i.id="rte-bg-color-preview-hex",o.appendChild(r),o.appendChild(i),e.appendChild(t),e.appendChild(o);const a=document.createElement("div");a.className="rte-bg-color-section";const l=document.createElement("div");l.className="rte-bg-color-section-label",l.textContent="Preset Colors";const c=document.createElement("div");c.className="rte-bg-color-grid",c.id="rte-bg-color-grid",nl.forEach(k=>{const y=document.createElement("button");y.type="button",y.className="rte-bg-color-swatch",y.style.backgroundColor=k,y.dataset.color=k,y.title=k,c.appendChild(y)}),a.appendChild(l),a.appendChild(c);const s=document.createElement("div");s.className="rte-bg-color-section";const d=document.createElement("div");d.className="rte-bg-color-section-label",d.textContent="Custom Color";const p=document.createElement("div");p.className="rte-bg-color-custom";const g=document.createElement("input");g.type="color",g.className="rte-bg-color-input",g.id="rte-bg-color-input",g.value=Y;const m=document.createElement("input");m.type="text",m.className="rte-bg-color-text-input",m.id="rte-bg-color-text-input",m.placeholder="#FFFF00",m.value=Y.toUpperCase(),m.maxLength=7,p.appendChild(g),p.appendChild(m),s.appendChild(d),s.appendChild(p);const b=document.createElement("div");b.className="rte-bg-color-actions";const x=document.createElement("button");x.type="button",x.className="rte-bg-color-btn rte-bg-color-btn-cancel",x.textContent="Cancel",x.id="rte-bg-color-cancel";const C=document.createElement("button");return C.type="button",C.className="rte-bg-color-btn rte-bg-color-btn-apply",C.textContent="Apply",C.id="rte-bg-color-apply",b.appendChild(x),b.appendChild(C),n.appendChild(e),n.appendChild(a),n.appendChild(s),n}function il(){if(!_)return;const n=_.querySelector("#rte-bg-color-grid");n&&n.addEventListener("click",r=>{const i=r.target;if(i.classList.contains("rte-bg-color-swatch")){const a=i.dataset.color;a&&(Y=a,Tt(a),nt())}});const e=_.querySelector("#rte-bg-color-input");e&&(e.addEventListener("change",r=>{const i=r.target.value.toUpperCase();Y=i,Tt(i),nt()}),e.addEventListener("input",r=>{Y=r.target.value.toUpperCase(),zn(),In()}));const t=_.querySelector("#rte-bg-color-text-input");t&&(t.addEventListener("change",r=>{let i=r.target.value.trim();i&&!i.startsWith("#")&&(i="#"+i),/^#[0-9A-F]{6}$/i.test(i)&&(Y=i.toUpperCase(),Tt(Y),nt())}),t.addEventListener("input",r=>{let i=r.target.value.trim();i&&!i.startsWith("#")&&(i="#"+i,t.value=i),/^#[0-9A-F]{6}$/i.test(i)&&(Y=i.toUpperCase(),zn(),In())}));const o=r=>{if(_&&Dt){const i=r.target;!_.contains(i)&&!Dt.contains(i)&&nt()}};setTimeout(()=>{document.addEventListener("click",o)},100),_._clickOutsideHandler=o}function zn(){if(!_)return;const n=_.querySelector("#rte-bg-color-preview-swatch"),e=_.querySelector("#rte-bg-color-preview-hex"),t=_.querySelector("#rte-bg-color-input"),o=_.querySelector("#rte-bg-color-text-input");n&&(n.style.backgroundColor=Y),e&&(e.textContent=Y.toUpperCase()),t&&(t.value=Y),o&&(o.value=Y.toUpperCase())}function In(){if(!_)return;_.querySelectorAll(".rte-bg-color-swatch").forEach(e=>{e.dataset.color?.toUpperCase()===Y.toUpperCase()?e.classList.add("selected"):e.classList.remove("selected")})}function al(){try{const n=window.getSelection();if(!n||n.rangeCount===0)return"#ffff00";const t=n.getRangeAt(0).commonAncestorContainer,o=t.nodeType===1?t:t.parentElement;if(o){const r=o.closest('[style*="background-color"]');if(r){const i=r.style.backgroundColor;if(i)return ll(i)}}return"#ffff00"}catch{return"#ffff00"}}function ll(n){if(n.startsWith("#"))return n.toUpperCase();const e=n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const t=parseInt(e[1]),o=parseInt(e[2]),r=parseInt(e[3]);return"#"+[t,o,r].map(i=>{const a=i.toString(16);return a.length===1?"0"+a:a}).join("").toUpperCase()}return"#ffff00"}function Tt(n){try{if(_t){const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(_t.cloneRange()))}const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return console.warn("[BackgroundColor] No valid selection"),!1;const t=e.getRangeAt(0);if(t.collapsed)return console.warn("[BackgroundColor] Range is collapsed"),!1;const o=t.startContainer.nodeType===Node.TEXT_NODE?t.startContainer.parentElement:t.startContainer,r=t.endContainer.nodeType===Node.TEXT_NODE?t.endContainer.parentElement:t.endContainer;let i=null,a=o;for(;a&&a!==document.body;){if(a.classList.contains("rte-bg-color")){const d=document.createRange();if(d.selectNodeContents(a),d.compareBoundaryPoints(Range.START_TO_START,t)<=0&&d.compareBoundaryPoints(Range.END_TO_END,t)>=0){i=a;break}}a=a.parentElement}if(i){i.style.backgroundColor=n;const d=i.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]');return d&&d.dispatchEvent(new Event("input",{bubbles:!0})),console.log("[BackgroundColor] Updated existing span with color:",n),!0}const l=document.createElement("span");l.style.backgroundColor=n,l.className="rte-bg-color";const c=t.extractContents();l.appendChild(c),t.insertNode(l),t.setStartAfter(l),t.setEndAfter(l),e.removeAllRanges(),e.addRange(t);const s=l.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]');return s&&s.dispatchEvent(new Event("input",{bubbles:!0})),console.log("[BackgroundColor] Applied color:",n),!0}catch(e){return console.error("[BackgroundColor] Failed to apply background color:",e),!1}}function nt(){if(_){const n=_._clickOutsideHandler;n&&document.removeEventListener("click",n),_.remove(),_=null}Dt=null,_t=null}function sl(n,e){const t=n.getBoundingClientRect(),o=450,r=280;let i=t.bottom+5,a=t.left;if(a+r>window.innerWidth&&(a=window.innerWidth-r-10),i+o>window.innerHeight){const l=t.top-o-5;l<0?i=window.scrollY+10:i=l+window.scrollY}else i=i+window.scrollY;a<0&&(a=10),e.style.top=`${i}px`,e.style.left=`${a}px`}function cl(){if(ol(),_)return nt(),!0;const n=document.querySelector('[data-command="openBackgroundColorPicker"]');if(!n)return!1;const e=window.getSelection();return!e||e.isCollapsed?(alert("Please select text to apply background color"),!1):(e.rangeCount>0&&(_t=e.getRangeAt(0).cloneRange()),Y=al(),_=rl(),document.body.appendChild(_),Dt=n,sl(n,_),zn(),In(),il(),!0)}const dl=()=>({name:"backgroundColor",marks:{backgroundColor:{attrs:{color:{default:"#ffffff"}},parseDOM:[{tag:'span[style*="background-color"]',getAttrs:n=>{const o=(n.getAttribute("style")||"").match(/background-color:\s*([^;]+)/);return o?{color:o[1]}:null}},{tag:"mark",getAttrs:n=>({color:n.style.backgroundColor||"#ffff00"})}],toDOM:n=>["span",{style:`background-color: ${n.attrs.color||"#ffffff"}`,class:"rte-bg-color"},0]}},toolbar:[{label:"Background Color",command:"openBackgroundColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-highlight-bg-color__color" d="M3 18h18v3H3z" fill="#000000"></path><path fill-rule="nonzero" d="M7.7 16.7H3l3.3-3.3-.7-.8L10.2 8l4 4.1-4 4.2c-.2.2-.6.2-.8 0l-.6-.7-1.1 1.1zm5-7.5L11 7.4l3-2.9a2 2 0 0 1 2.6 0L18 6c.7.7.7 2 0 2.7l-2.9 2.9-1.8-1.8-.5-.6"></path></g></svg>',shortcut:"Mod-Shift-h"}],commands:{openBackgroundColorPicker:()=>cl(),setBackgroundColor:n=>n?Tt(n):!1},keymap:{"Mod-Shift-h":"openBackgroundColorPicker"}}),ul=[{label:"1.0",value:"1.0"},{label:"1.15",value:"1.15"},{label:"1.5",value:"1.5"},{label:"2.0",value:"2.0"},{label:"2.5",value:"2.5"},{label:"3.0",value:"3.0"}],pl=n=>{let e=n;const t=["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE"];for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const o=e;if(t.includes(o.tagName))return o}e=e.parentNode}return null},Vr=n=>{if(!n)return!1;try{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0),o=pl(t.commonAncestorContainer);return o?(o.style.lineHeight=n,!0):!1}catch(e){return console.error("Failed to set line height:",e),!1}},ml=(n,e)=>{typeof window<"u"&&window.registerEditorCommand?.(n,e)},or=()=>{ml("setLineHeight",Vr)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",or):or());const gl=()=>({name:"lineHeight",marks:{lineHeight:{attrs:{height:{default:null}},parseDOM:[{tag:'span[style*="line-height"]',getAttrs:n=>{const t=n.style.lineHeight;return t?{height:t}:!1}}],toDOM:n=>["span",{style:`line-height: ${n.attrs.height}`},0]}},toolbar:[{label:"Line Height",command:"setLineHeight",type:"inline-menu",options:ul,icon:'<svg width="24" height="24" focusable="false"><path d="M21 5a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zm0 4a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zm0 4a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zm0 4a1 1 0 0 1 .1 2H13a1 1 0 0 1-.1-2H21zM7 3.6l3.7 3.7a1 1 0 0 1-1.3 1.5h-.1L8 7.3v9.2l1.3-1.3a1 1 0 0 1 1.3 0h.1c.4.4.4 1 0 1.3v.1L7 20.4l-3.7-3.7a1 1 0 0 1 1.3-1.5h.1L6 16.7V7.4L4.7 8.7a1 1 0 0 1-1.3 0h-.1a1 1 0 0 1 0-1.3v-.1L7 3.6z"></path></svg>'}],commands:{setLineHeight:Vr}}),Ur=40,Dn=n=>["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE"].includes(n.tagName),Wr=()=>{const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},rr=n=>{let e=n;if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(Dn(t))return t}for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(Dn(t))return t;if(t.getAttribute("contenteditable")==="true")break}e=e.parentNode}return null},Gr=n=>{const e=[],t=rr(n.startContainer),o=rr(n.endContainer);if(!t&&!o)return e;if(n.collapsed)return t&&e.push(t),e;if(t===o)t&&e.push(t);else{let r=t;for(;r&&r!==o;){e.push(r);let i=r.nextElementSibling;for(;i&&!Dn(i);)i=i.nextElementSibling;r=i}o&&o!==t&&e.push(o)}return e},Zr=n=>{const e=window.getComputedStyle(n),t=e.paddingLeft;if(t.endsWith("px"))return parseFloat(t);if(t.endsWith("em")){const o=parseFloat(e.fontSize);return parseFloat(t)*o}return 0},Kr=()=>{const n=Wr();if(!n)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);if(!n.contains(t.commonAncestorContainer))return!1;const o=Gr(t);return o.length===0?!1:(o.forEach(r=>{const a=Zr(r)+Ur;r.style.paddingLeft=`${a}px`}),!0)},Xr=()=>{const n=Wr();if(!n)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0);if(!n.contains(t.commonAncestorContainer))return!1;const o=Gr(t);return o.length===0?!1:(o.forEach(r=>{const i=Zr(r),a=Math.max(0,i-Ur);r.style.paddingLeft=`${a}px`}),!0)},ir=(n,e)=>{typeof window<"u"&&window.registerEditorCommand?.(n,e)},ar=()=>{ir("increaseIndent",Kr),ir("decreaseIndent",Xr)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ar):ar());const hl=()=>({name:"indent",toolbar:[{label:"Increase Indent",command:"increaseIndent",type:"button",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M3 4h18v2H3V4zm0 14h18v2H3v-2zm8-7h10v2H11v-2zm0 4h10v2H11v-2zM3 8l4 4-4 4V8z"/></svg>',shortcut:"Mod-]"},{label:"Decrease Indent",command:"decreaseIndent",type:"button",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M3 4h18v2H3V4zm0 14h18v2H3v-2zm8-7h10v2H11v-2zm0 4h10v2H11v-2zM7 8v8l-4-4 4-4z"/></svg>',shortcut:"Mod-["}],commands:{increaseIndent:Kr,decreaseIndent:Xr},keymap:{"Mod-]":"increaseIndent","Mod-[":"decreaseIndent",Tab:"increaseIndent","Shift-Tab":"decreaseIndent"}}),lr=["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE"],fl=()=>({name:"direction",toolbar:[{label:"Left to Right",command:"setDirectionLTR",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-l"},{label:"Right to Left",command:"setDirectionRTL",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-r"}],commands:{setDirectionLTR:()=>{try{const n=window.getSelection();if(!n||n.rangeCount===0)return!1;let t=n.getRangeAt(0).commonAncestorContainer;for(t&&t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);t&&t!==document.body;){const o=t;if(o.tagName&&lr.includes(o.tagName))return o.removeAttribute("dir"),!0;t=o.parentElement}return!1}catch(n){return console.error("Failed to set LTR direction:",n),!1}},setDirectionRTL:()=>{try{const n=window.getSelection();if(!n||n.rangeCount===0)return!1;let t=n.getRangeAt(0).commonAncestorContainer;for(t&&t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);t&&t!==document.body;){const o=t;if(o.tagName&&lr.includes(o.tagName))return o.setAttribute("dir","rtl"),!0;t=o.parentElement}return!1}catch(n){return console.error("Failed to set RTL direction:",n),!1}}},keymap:{"Mod-Shift-l":"setDirectionLTR","Mod-Shift-r":"setDirectionRTL"}}),bl=()=>{const n=()=>{try{const o=window.getSelection();if(o&&o.rangeCount>0&&!o.isCollapsed){const r=o.getRangeAt(0),a=r.toString().toUpperCase();return r.deleteContents(),r.insertNode(document.createTextNode(a)),!0}return!1}catch(o){return console.error("Failed to convert to uppercase:",o),!1}},e=()=>{try{const o=window.getSelection();if(o&&o.rangeCount>0&&!o.isCollapsed){const r=o.getRangeAt(0),a=r.toString().toLowerCase();return r.deleteContents(),r.insertNode(document.createTextNode(a)),!0}return!1}catch(o){return console.error("Failed to convert to lowercase:",o),!1}},t=()=>{try{const o=window.getSelection();if(o&&o.rangeCount>0&&!o.isCollapsed){const r=o.getRangeAt(0),a=r.toString().replace(/\w\S*/g,l=>l.charAt(0).toUpperCase()+l.substr(1).toLowerCase());return r.deleteContents(),r.insertNode(document.createTextNode(a)),!0}return!1}catch(o){return console.error("Failed to convert to title case:",o),!1}};return{name:"capitalization",toolbar:[{label:"Capitalization",command:"setCapitalization",type:"inline-menu",options:[{label:"lowercase",value:"lowercase"},{label:"UPPERCASE",value:"uppercase"},{label:"Title Case",value:"titlecase"}],icon:'<svg fill="#000000" width="24" height="24" viewBox="0 0 32.00 32.00" id="icon" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.192"></g><g id="SVGRepo_iconCarrier"><defs><style>.cls-1{fill:none;}</style></defs><title>letter--Aa</title><path d="M23,13H18v2h5v2H19a2,2,0,0,0-2,2v2a2,2,0,0,0,2,2h6V15A2,2,0,0,0,23,13Zm0,8H19V19h4Z"></path><path d="M13,9H9a2,2,0,0,0-2,2V23H9V18h4v5h2V11A2,2,0,0,0,13,9ZM9,16V11h4v5Z"></path><rect id="_Transparent_Rectangle_" data-name="&lt;Transparent Rectangle&gt;" class="cls-1" width="32" height="32"></rect></g></svg>'}],commands:{setCapitalization:o=>{if(!o)return!1;switch(o){case"uppercase":return n();case"lowercase":return e();case"titlecase":return t();default:return!1}},toUpperCase:n,toLowerCase:e,toTitleCase:t},keymap:{"Mod-Shift-u":"toUpperCase","Mod-Shift-k":"toLowerCase","Mod-Shift-t":"toTitleCase"}}},xl={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let xt=null,_n=null,sr=!1;const yl=()=>new Promise((n,e)=>{if(window.katex){n(window.katex);return}if(sr){const r=setInterval(()=>{window.katex&&(clearInterval(r),n(window.katex))},100);return}sr=!0;const t=document.createElement("link");t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(t);const o=document.createElement("script");o.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",o.onload=()=>n(window.katex),o.onerror=e,document.head.appendChild(o)}),Yr=async n=>{const e=window.getSelection();e&&e.rangeCount>0&&(xt=e.getRangeAt(0).cloneRange()),await yl();const t=document.createElement("div");t.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 99999;";const o=document.createElement("div");o.style.cssText="background: white; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);";let r=n?.format||"latex",i=n?.formula||"",a=n?.inline!==!1;o.innerHTML=`
1133
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e1e5e9; background: #f8f9fa;">
1134
- <h2 style="margin: 0; font-size: 18px; font-weight: 600;">${n?"Edit":"Insert"} Math Formula</h2>
1135
- <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: #6c757d; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
1136
- </div>
1137
-
1138
- <div style="padding: 20px; overflow-y: auto; flex: 1;">
1139
- <div style="margin-bottom: 20px;">
1140
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Format:</label>
1141
- <div style="display: flex; gap: 16px;">
1142
- <label style="cursor: pointer;"><input type="radio" name="format" value="latex" ${r==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
1143
- <label style="cursor: pointer;"><input type="radio" name="format" value="mathml" ${r==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
1144
- </div>
1145
- </div>
1146
-
1147
- <div style="margin-bottom: 20px;">
1148
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Quick Templates:</label>
1149
- <div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>
1150
- </div>
1151
-
1152
- <div style="margin-bottom: 20px;">
1153
- <label style="cursor: pointer;"><input type="checkbox" id="inline-cb" ${a?"checked":""} style="margin-right: 8px;"> Inline math</label>
1154
- </div>
1155
-
1156
- <div style="margin-bottom: 20px;">
1157
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Formula:</label>
1158
- <textarea id="formula-input" rows="4" style="width: 100%; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 14px;">${i}</textarea>
1159
- </div>
1160
-
1161
- <div style="margin-bottom: 20px;">
1162
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Preview:</label>
1163
- <div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid #dee2e6; border-radius: 4px; background: #f8f9fa; display: flex; align-items: center; justify-content: center; color: #6c757d;"></div>
1164
- </div>
1165
- </div>
1166
-
1167
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid #e1e5e9; background: #f8f9fa;">
1168
- <button class="cancel-btn" style="padding: 10px 20px; background: #fff; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
1169
- <button id="insert-btn" style="padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${n?"Update":"Insert"}</button>
1170
- </div>
1171
- `,t.appendChild(o),document.body.appendChild(t);const l=o.querySelector("#formula-input"),c=o.querySelector("#preview-area"),s=o.querySelector("#templates-grid"),d=o.querySelectorAll('input[name="format"]'),p=o.querySelector("#inline-cb"),g=o.querySelector("#insert-btn"),m=o.querySelector(".close-btn"),b=o.querySelector(".cancel-btn"),x=()=>{const w=xl[r];s.innerHTML=w.map(S=>`
1172
- <button type="button" data-formula="${S.formula.replace(/"/g,"&quot;")}" title="${S.description}" style="padding: 8px; border: 1px solid #ced4da; border-radius: 4px; background: #fff; cursor: pointer; text-align: left;">
1173
- <div style="font-weight: 600; font-size: 12px;">${S.name}</div>
1174
- <div style="font-size: 10px; color: #6c757d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${S.formula.substring(0,20)}...</div>
1175
- </button>
1176
- `).join(""),s.querySelectorAll("button").forEach(S=>{S.addEventListener("click",()=>{l.value=S.getAttribute("data-formula")||"",i=l.value,C()})})},C=()=>{const w=l.value.trim();if(!w){c.innerHTML='<span style="color: #6c757d;">Enter a formula to see preview</span>',g.disabled=!0;return}g.disabled=!1;try{if(r==="latex"){const S=window.katex;c.innerHTML=S.renderToString(w,{displayMode:!1,throwOnError:!1})}else w.trim().startsWith("<math")?c.innerHTML=w:c.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${w}</math>`}catch{c.innerHTML='<span style="color: #cc0000;">Invalid formula</span>'}},k=()=>document.body.removeChild(t),y=()=>{const w=l.value.trim();if(!w)return;const S={formula:w,format:r,inline:p.checked},E=S.inline?document.createElement("span"):document.createElement("div");if(E.className=S.inline?"math-formula":"math-block",E.setAttribute("data-math-formula",w),E.setAttribute("data-math-format",r),E.contentEditable="false",E.style.cssText=S.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",r==="latex"){const f=window.katex;try{E.innerHTML=f.renderToString(w,{displayMode:!S.inline,throwOnError:!1})}catch{E.textContent=S.inline?`$${w}$`:`$$${w}$$`}}else if(w.trim().startsWith("<math"))E.innerHTML=w;else{const f=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${S.inline?"inline":"block"}">${w}</math>`;E.innerHTML=f}_n?_n.replaceWith(E):xt&&(xt.deleteContents(),xt.insertNode(E)),k()};m.addEventListener("click",k),b.addEventListener("click",k),g.addEventListener("click",y),t.addEventListener("click",w=>{w.target===t&&k()}),d.forEach(w=>{w.addEventListener("change",S=>{r=S.target.value,x(),C()})}),l.addEventListener("input",()=>{i=l.value,C()}),l.addEventListener("keydown",w=>{(w.ctrlKey||w.metaKey)&&w.key==="Enter"&&(w.preventDefault(),y())}),x(),C(),l.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const n=t=>{const r=t.target.closest(".math-formula, .math-block");if(r){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),_n=r;const i=r.getAttribute("data-math-formula")||"",a=r.getAttribute("data-math-format")||"latex",l=r.classList.contains("math-formula");Yr({formula:i,format:a,inline:l})}},e=()=>{document.addEventListener("dblclick",n,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,100)}const vl=()=>({name:"math",toolbar:[{label:"Insert Math",command:"insertMath",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'}],commands:{insertMath:()=>(Yr(),!0)},keymap:{"Mod-Shift-m":"insertMath"}}),gn={all:{name:"All",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₴","₵","₶","₷","₹","₺","₼","₽","₾","₿",'"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟","‟","„","©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂","⁃","⁇","⁈","⁉","+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≈","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≠","≡","≢","≣","≤","≥","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃","←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]},currency:{name:"Currency",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₵","₶","₷","₼","₾","₿"]},text:{name:"Text",characters:["©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂"]},quotation:{name:"Quotation",characters:['"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟"]},mathematical:{name:"Mathematical",characters:["+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≢","≣","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿"]},"extended-latin":{name:"Extended Latin",characters:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"]},symbols:{name:"Symbols",characters:["¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃"]},arrows:{name:"Arrows",characters:["←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]}},cr={"€":"euro","£":"pound","¥":"yen","¢":"cent","₹":"rupee","₽":"ruble","₩":"won","₿":"bitcoin",'"':"quote","'":"apostrophe","«":"left angle quote","»":"right angle quote","„":"low quote","©":"copyright","®":"registered","™":"trademark","°":"degree","§":"section","¶":"paragraph","†":"dagger","‡":"double dagger","•":"bullet","‰":"per mille","′":"prime","″":"double prime","+":"plus","-":"minus","×":"multiplication","÷":"division","=":"equals","≠":"not equal","≈":"approximately","≡":"identical","≤":"less or equal","≥":"greater or equal","±":"plus minus",À:"a grave",Á:"a acute",Â:"a circumflex",Ã:"a tilde",Ä:"a diaeresis",Ç:"c cedilla","←":"left arrow","↑":"up arrow","→":"right arrow","↓":"down arrow","↔":"left right arrow"};let hn=!1;const wl=()=>{if(typeof document>"u")return;const n="special-characters-plugin-styles";if(document.getElementById(n))return;const e=document.createElement("style");e.id=n,e.textContent=`
1177
- .special-characters-overlay {
1178
- position: fixed;
1179
- top: 0;
1180
- left: 0;
1181
- right: 0;
1182
- bottom: 0;
1183
- background-color: rgba(0, 0, 0, 0.5);
1184
- display: flex;
1185
- align-items: center;
1186
- justify-content: center;
1187
- z-index: 10000;
1188
- }
1189
-
1190
- .special-characters-dialog {
1191
- background: white;
1192
- border-radius: 8px;
1193
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
1194
- max-width: 800px;
1195
- width: 90%;
1196
- max-height: 80vh;
1197
- display: flex;
1198
- flex-direction: column;
1199
- }
1200
-
1201
- .special-characters-header {
1202
- display: flex;
1203
- justify-content: space-between;
1204
- align-items: center;
1205
- padding: 16px 20px;
1206
- border-bottom: 1px solid #e1e5e9;
1207
- }
1208
-
1209
- .special-characters-header h2 {
1210
- margin: 0;
1211
- font-size: 18px;
1212
- font-weight: 600;
1213
- color: #1a202c;
1214
- }
1215
-
1216
- .special-characters-close {
1217
- background: none;
1218
- border: none;
1219
- font-size: 24px;
1220
- cursor: pointer;
1221
- color: #718096;
1222
- padding: 0;
1223
- width: 32px;
1224
- height: 32px;
1225
- display: flex;
1226
- align-items: center;
1227
- justify-content: center;
1228
- border-radius: 4px;
1229
- }
1230
-
1231
- .special-characters-close:hover {
1232
- background-color: #f7fafc;
1233
- color: #2d3748;
1234
- }
1235
-
1236
- .special-characters-content {
1237
- display: flex;
1238
- flex: 1;
1239
- overflow: hidden;
1240
- }
1241
-
1242
- .special-characters-main-content {
1243
- flex: 1;
1244
- display: flex;
1245
- flex-direction: column;
1246
- overflow: hidden;
1247
- }
1248
-
1249
- .special-characters-search {
1250
- padding: 16px 16px 0 16px;
1251
- }
1252
-
1253
- .special-characters-search-input {
1254
- width: 100%;
1255
- padding: 10px 12px;
1256
- border: 1px solid #e1e5e9;
1257
- border-radius: 6px;
1258
- font-size: 14px;
1259
- color: #2d3748;
1260
- background-color: #ffffff;
1261
- transition: border-color 0.2s ease, box-shadow 0.2s ease;
1262
- box-sizing: border-box;
1263
- }
1264
-
1265
- .special-characters-search-input:focus {
1266
- outline: none;
1267
- border-color: #4299e1;
1268
- box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
1269
- }
1270
-
1271
- .special-characters-tabs {
1272
- display: flex;
1273
- flex-direction: column;
1274
- width: 180px;
1275
- border-right: 1px solid #e1e5e9;
1276
- background-color: #f8fafc;
1277
- }
1278
-
1279
- .special-characters-tab {
1280
- padding: 12px 16px;
1281
- border: none;
1282
- background: none;
1283
- text-align: left;
1284
- cursor: pointer;
1285
- font-size: 14px;
1286
- color: #4a5568;
1287
- border-bottom: 1px solid #e1e5e9;
1288
- transition: all 0.2s ease;
1289
- }
1290
-
1291
- .special-characters-tab:hover {
1292
- background-color: #edf2f7;
1293
- color: #2d3748;
1294
- }
1295
-
1296
- .special-characters-tab.active {
1297
- background-color: #4299e1;
1298
- color: white;
1299
- font-weight: 500;
1300
- }
1301
-
1302
- .special-characters-grid {
1303
- padding: 16px;
1304
- overflow-y: auto;
1305
- display: grid;
1306
- grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
1307
- gap: 8px;
1308
- }
1309
-
1310
- .special-characters-item {
1311
- width: 40px;
1312
- height: 40px;
1313
- display: flex;
1314
- align-items: center;
1315
- justify-content: center;
1316
- border: 1px solid #e1e5e9;
1317
- background: white;
1318
- border-radius: 4px;
1319
- cursor: pointer;
1320
- font-size: 18px;
1321
- transition: all 0.2s ease;
1322
- color: #2d3748;
1323
- }
1324
-
1325
- .special-characters-item:hover {
1326
- background-color: #4299e1;
1327
- border-color: #4299e1;
1328
- color: white;
1329
- transform: scale(1.05);
1330
- }
1331
-
1332
- .special-characters-item:active {
1333
- transform: scale(0.95);
1334
- }
1335
-
1336
- .special-characters-no-results {
1337
- grid-column: 1 / -1;
1338
- text-align: center;
1339
- color: #718096;
1340
- font-size: 14px;
1341
- padding: 40px 20px;
1342
- background-color: #f8fafc;
1343
- border-radius: 6px;
1344
- border: 1px solid #e1e5e9;
1345
- }
1346
-
1347
- @media (max-width: 768px) {
1348
- .special-characters-dialog {
1349
- width: 95%;
1350
- max-height: 90vh;
1351
- }
1352
-
1353
- .special-characters-content {
1354
- flex-direction: column;
1355
- }
1356
-
1357
- .special-characters-tabs {
1358
- width: 100%;
1359
- border-right: none;
1360
- border-bottom: 1px solid #e1e5e9;
1361
- flex-direction: row;
1362
- overflow-x: auto;
1363
- }
1364
-
1365
- .special-characters-tab {
1366
- border-bottom: none;
1367
- border-right: 1px solid #e1e5e9;
1368
- white-space: nowrap;
1369
- }
1370
- }
1371
- `,document.head.appendChild(e)},Cl=n=>{const e=window.getSelection();if(e&&e.rangeCount>0){const t=e.getRangeAt(0);t.deleteContents();const o=document.createTextNode(n);t.insertNode(o),t.setStartAfter(o),t.setEndAfter(o),e.removeAllRanges(),e.addRange(t)}},kl=()=>{if(typeof window>"u"||hn)return;hn=!0,wl();let n="all",e="";const t=document.createElement("div");t.className="special-characters-overlay";const o=document.createElement("div");o.className="special-characters-dialog";const r=()=>{const l=gn[n].characters.filter(d=>{if(!e.trim())return!0;const p=e.toLowerCase();return d.toLowerCase().includes(p)||(cr[d]||"").toLowerCase().includes(p)});o.innerHTML=`
1372
- <div class="special-characters-header">
1373
- <h2>Insert Special Characters</h2>
1374
- <button class="special-characters-close">×</button>
1375
- </div>
1376
- <div class="special-characters-content">
1377
- <div class="special-characters-tabs">
1378
- ${Object.keys(gn).map(d=>`
1379
- <button class="special-characters-tab ${n===d?"active":""}" data-category="${d}">
1380
- ${gn[d].name}
1381
- </button>
1382
- `).join("")}
1383
- </div>
1384
- <div class="special-characters-main-content">
1385
- <div class="special-characters-search">
1386
- <input type="text" placeholder="Search characters..." value="${e}" class="special-characters-search-input">
1387
- </div>
1388
- <div class="special-characters-grid">
1389
- ${l.length>0?l.map(d=>`
1390
- <button class="special-characters-item" data-char="${d}" title="${cr[d]||d}">
1391
- ${d}
1392
- </button>
1393
- `).join(""):`<div class="special-characters-no-results">No characters found for "${e}"</div>`}
1394
- </div>
1395
- </div>
1396
- </div>
1397
- `,o.querySelector(".special-characters-close")?.addEventListener("click",i),o.querySelectorAll(".special-characters-tab").forEach(d=>{d.addEventListener("click",p=>{const g=p.target.getAttribute("data-category");g&&(n=g,r())})}),o.querySelector(".special-characters-search-input")?.addEventListener("input",d=>{e=d.target.value,r()}),o.querySelectorAll(".special-characters-item").forEach(d=>{d.addEventListener("click",p=>{const g=p.target.getAttribute("data-char");g&&(Cl(g),i())})})},i=()=>{t.parentNode&&t.parentNode.removeChild(t),hn=!1,document.removeEventListener("keydown",a)},a=l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),i())};t.addEventListener("click",l=>{l.target===t&&i()}),document.addEventListener("keydown",a),r(),t.appendChild(o),document.body.appendChild(t)},El=()=>({name:"specialCharacters",toolbar:[{label:"Special Characters",command:"insertSpecialCharacter",icon:'<svg width="24" height="24" focusable="false"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 0 0 1.8-2.9 6.3 6.3 0 0 0-.1-4.1 5.8 5.8 0 0 0-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 0 0-3.9 1.8 6.3 6.3 0 0 0-1.3 6 6.2 6.2 0 0 0 1.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 0 1 4 11c0-1 .2-1.9.6-2.7A7 7 0 0 1 6.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 0 1 5.7 2 7 7 0 0 1 1.7 2.3 6 6 0 0 1 .2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 0 1-3.6 2.5v.5Z" fill-rule="evenodd"></path></svg>'}],commands:{insertSpecialCharacter:()=>(kl(),!0)},keymap:{}}),Hn={all:{name:"All",emojis:["❤️","💔","💙","💚","💛","🖤","🤍","🤎","✔️","❌","☑️","❗","❓","⚠️","💯","➕","➖","✖️","➗","♻️","⚡","🔥","✨","⭐","⭕","🚫","😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😍","😘","😎","🤓","😐","😑","😬","🙄","😏","😌","🤩","🥳","🤔","😴","😭","😢","😡","🤯","👍","👎","👌","✌️","🤞","🙏","👏","🙌","💪","🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🦆","🦅","🦄","🐝","🦋","🌲","🌳","🌴","🌵","🌸","🌼","🌻","☀️","🌙","⭐","🌈","🌧️","❄️","🌊","🍎","🍌","🍉","🍇","🍓","🍒","🍍","🥭","🍐","🍊","🍋","🍑","🥝","🥑","🍔","🍟","🍕","🌭","🥪","🌮","🌯","🍣","🍜","🍰","🧁","🍩","🍪","🍫","☕","🍵","🥤","🍺","🍷","🍸","🍹","🥂","⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎮","🎯","🎳","🎲","♟️","🏃","🚴","🏊","🏋️","🧘","🎸","🎹","🥁","🎺","🎤","🏆","🥇","🚗","🚕","🚌","🚎","🚓","🚑","🚒","✈️","🚀","🚁","🚤","🛳️","🚢","🏠","🏢","🏬","🏫","🏥","🏰","🗼","🗽","⛩️","🕌","🌍","🌎","🌏","🏖️","🏝️","📱","💻","🖥️","⌨️","🖱️","📷","📸","🎥","📹","📚","📖","📝","📄","📂","🔒","🔑","🗝️","💡","🔦","🕯️","🧰","🛠️","🔧","⚙️","📦","💳","💰","🔋","🔌","🇮🇳","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇩🇪","🇫🇷","🇪🇸","🇮🇹","🇯🇵","🇰🇷","🇨🇳","🇧🇷","🇲🇽","🇷🇺","🇿🇦","🇳🇿"]},symbols:{name:"Symbols",emojis:["❤️","💔","💙","💚","💛","🖤","🤍","🤎","✔️","❌","☑️","❗","❓","⚠️","💯","➕","➖","✖️","➗","♻️","⚡","🔥","✨","⭐","⭕","🚫","⬆️","⬇️","⬅️","➡️","🔄","🔁","🔀","🔔","🔕","⏰","⌛","⏳"]},people:{name:"People",emojis:["😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😍","😘","😎","🤓","😐","😑","😬","🙄","😏","😌","🤩","🥳","🤔","😴","😭","😢","😡","🤯","👍","👎","👌","✌️","🤞","🙏","👏","🙌","💪"]},"animals-nature":{name:"Animals & Nature",emojis:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🦆","🦅","🦄","🐝","🦋","🌲","🌳","🌴","🌵","🌸","🌼","🌻","☀️","🌙","⭐","🌈","🌧️","❄️","🌊"]},"food-drink":{name:"Food & Drink",emojis:["🍎","🍌","🍉","🍇","🍓","🍒","🍍","🥭","🍐","🍊","🍋","🍑","🥝","🥑","🍔","🍟","🍕","🌭","🥪","🌮","🌯","🍣","🍜","🍰","🧁","🍩","🍪","🍫","☕","🍵","🥤","🍺","🍷","🍸","🍹","🥂"]},activity:{name:"Activity",emojis:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎮","🎯","🎳","🎲","♟️","🏃","🚴","🏊","🏋️","🧘","🎸","🎹","🥁","🎺","🎤","🏆","🥇","🥈","🥉"]},"travel-places":{name:"Travel & Places",emojis:["🚗","🚕","🚌","🚎","🚓","🚑","🚒","✈️","🚀","🚁","🚤","🛳️","🚢","🏠","🏢","🏬","🏫","🏥","🏰","🗼","🗽","⛩️","🕌","🌍","🌎","🌏","🏖️","🏝️"]},objects:{name:"Objects",emojis:["📱","💻","🖥️","⌨️","🖱️","📷","📸","🎥","📹","📚","📖","📝","📄","📂","🔒","🔑","🗝️","💡","🔦","🕯️","🧰","🛠️","🔧","⚙️","📦","💳","💰","🔋","🔌"]},flags:{name:"Flags",emojis:["🇮🇳","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇩🇪","🇫🇷","🇪🇸","🇮🇹","🇯🇵","🇰🇷","🇨🇳","🇧🇷","🇲🇽","🇷🇺","🇿🇦","🇳🇿"]}},Sl={"💙":"blue heart","💚":"green heart","💛":"yellow heart","🖤":"black heart","🤍":"white heart","🤎":"brown heart","☑️":"check box with check","🔴":"red circle","🟢":"green circle","🟡":"yellow circle","🔵":"blue circle","⬆️":"up arrow","⬇️":"down arrow","⬅️":"left arrow","➡️":"right arrow","🔄":"counterclockwise arrows","🔁":"repeat button","🔀":"shuffle tracks","🔔":"bell","🔕":"muted bell","⏰":"alarm clock","⏳":"hourglass not done","⌛":"hourglass done","♠️":"spade suit","♥️":"heart suit","♦️":"diamond suit","♣️":"club suit","🚫":"prohibited","⭕":"hollow red circle","❎":"cross mark button","😐":"neutral face","😑":"expressionless face","😬":"grimacing face","🙄":"face with rolling eyes","😏":"smirking face","😌":"relieved face","🤩":"star struck","😜":"winking face with tongue","😝":"squinting face with tongue","🤪":"zany face","😢":"crying face","😥":"sad but relieved face","😓":"downcast face with sweat","😱":"face screaming in fear","😨":"fearful face","🤗":"hugging face","🤭":"face with hand over mouth","🤫":"shushing face","🤥":"lying face","👌":"ok hand","✌️":"victory hand","🤞":"crossed fingers","🙌":"raising hands","💪":"flexed biceps","🐔":"chicken","🐧":"penguin","🐦":"bird","🐤":"baby chick","🦆":"duck","🦅":"eagle","🐺":"wolf","🦄":"unicorn","🐝":"honeybee","🐞":"lady beetle","🦋":"butterfly","🐢":"turtle","🐍":"snake","🦖":"t-rex","🌿":"herb","🍀":"four leaf clover","🍁":"maple leaf","🍂":"fallen leaf","🌊":"water wave","❄️":"snowflake","☁️":"cloud","⛈️":"cloud with lightning and rain","🌪️":"tornado","🍐":"pear","🍊":"tangerine","🍋":"lemon","🍑":"peach","🥝":"kiwi fruit","🥑":"avocado","🍆":"eggplant","🌽":"ear of corn","🥕":"carrot","🥔":"potato","🍞":"bread","🥐":"croissant","🥖":"baguette bread","🧀":"cheese wedge","🍖":"meat on bone","🍗":"poultry leg","🥩":"cut of meat","🍦":"soft ice cream","🍨":"ice cream","🍫":"chocolate bar","🍬":"candy","🥛":"glass of milk","🧃":"beverage box","🍹":"tropical drink","🥂":"clinking glasses","🏓":"ping pong","🥊":"boxing glove","🥋":"martial arts uniform","⛳":"flag in hole","🏹":"bow and arrow","🎿":"skis","⛷️":"skier","🏂":"snowboarder","🎤":"microphone","🎬":"clapper board","🎨":"artist palette","🧩":"puzzle piece","🪀":"yo-yo","🚇":"metro","🚉":"station","🚊":"tram","🚝":"monorail","🛻":"pickup truck","🚐":"minibus","🗺️":"world map","🧭":"compass","⛰️":"mountain","🏔️":"snow capped mountain","🌋":"volcano","🏜️":"desert","🏕️":"camping","🏙️":"cityscape","🌆":"city at dusk","🌃":"night with stars","📦":"package","📫":"closed mailbox with raised flag","📬":"open mailbox with raised flag","📭":"open mailbox with lowered flag","🧾":"receipt","💳":"credit card","💰":"money bag","🪙":"coin","🔋":"battery","🔌":"electric plug","🧯":"fire extinguisher","🪜":"ladder","🪞":"mirror","🧹":"broom","🧸":"teddy bear"};let Lt=null,it="all",Ht="",at=null;const Tl=()=>({name:"emojis",toolbar:[{label:"Insert Emoji",command:"openEmojiDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M9 11c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm6 0c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm-3 5.5c2.1 0 4-1.5 4.4-3.5H7.6c.5 2 2.3 3.5 4.4 3.5ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm0 14.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-j",type:"button"}],commands:{openEmojiDialog:(n,e)=>{const t=e?.contentElement||dr();return t?(Ll(t),!0):!1},insertEmoji:(n,e)=>{if(!n)return!1;const t=e?.contentElement||dr();if(!t)return!1;try{return Jr(n,t),!0}catch{return!1}}},keymap:{"Mod-Shift-j":"openEmojiDialog"}});function Ll(n){it="all",Ht="";const e=window.getSelection();at=null,e&&e.rangeCount>0&&n.contains(e.anchorNode)&&(at=e.getRangeAt(0).cloneRange());const t=document.createElement("div");t.className="emojis-overlay",t.onclick=no;const o=document.createElement("div");o.className="emojis-dialog",o.onclick=i=>i.stopPropagation();const r=Object.keys(Hn);o.innerHTML=`
1398
- <div class="rte-dialog-header emojis-header">
1399
- <h3>Insert Emojis</h3>
1400
- <button class="rte-dialog-close emojis-close">×</button>
1401
- </div>
1402
- <div class="rte-dialog-body emojis-content">
1403
- <div class="emojis-tabs">
1404
- ${r.map(i=>`
1405
- <button class="emojis-tab ${i===it?"active":""}" data-category="${i}">
1406
- ${Hn[i].name}
1407
- </button>
1408
- `).join("")}
1409
- </div>
1410
- <div class="emojis-main-content">
1411
- <div class="emojis-search">
1412
- <svg class="emojis-search-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1413
- <circle cx="11" cy="11" r="8"/>
1414
- <path d="m21 21-4.35-4.35"/>
1415
- </svg>
1416
- <input
1417
- type="text"
1418
- placeholder="Search emojis..."
1419
- class="emojis-search-input"
1420
- id="emoji-search-input"
1421
- />
1422
- </div>
1423
- <div class="emojis-grid" id="emojis-grid">
1424
- ${Qr(it,Ht)}
1425
- </div>
1426
- </div>
1427
- </div>
1428
- `,t.appendChild(o),document.body.appendChild(t),Lt=t,Al(o,n),Nl(),setTimeout(()=>{o.querySelector("#emoji-search-input")?.focus()},100)}function Al(n,e){n.querySelector(".emojis-close")?.addEventListener("click",no),n.querySelectorAll(".emojis-tab").forEach(o=>{o.addEventListener("click",r=>{const i=r.target.getAttribute("data-category");i&&Ml(n,i,e)})}),n.querySelector("#emoji-search-input")?.addEventListener("input",o=>{Ht=o.target.value,Pn(n,e)}),Pn(n,e)}function Ml(n,e,t){it=e,n.querySelectorAll(".emojis-tab").forEach(o=>{o.classList.toggle("active",o.getAttribute("data-category")===e)}),Pn(n,t)}function Pn(n,e){const t=n.querySelector("#emojis-grid");t&&(t.innerHTML=Qr(it,Ht),t.querySelectorAll(".emojis-item").forEach(o=>{o.addEventListener("click",()=>{const r=o.textContent?.trim()||"";r&&(Jr(r,e),no())})}))}function Qr(n,e){let t=Hn[n].emojis;return e.trim()&&(t=t.filter(o=>o.toLowerCase().includes(e.toLowerCase())?!0:(Sl[o]||"").toLowerCase().includes(e.toLowerCase()))),t.length===0&&e.trim()?`<div class="emojis-no-results">No emojis found for "${e}"</div>`:t.map((o,r)=>`
1429
- <button
1430
- class="emojis-item"
1431
- title="Insert ${o}"
1432
- data-emoji="${o}"
1433
- >
1434
- ${o}
1435
- </button>
1436
- `).join("")}function no(){Lt&&(document.body.removeChild(Lt),Lt=null)}function Jr(n,e){e.focus();let t=window.getSelection();if(at&&(t?.removeAllRanges(),t?.addRange(at),at=null),t=window.getSelection(),t&&t.rangeCount>0){const o=t.getRangeAt(0);o.deleteContents();const r=document.createTextNode(n);o.insertNode(r),o.setStartAfter(r),o.setEndAfter(r),t.removeAllRanges(),t.addRange(o)}}function dr(){const n=document.activeElement;return n&&(n.classList.contains("editora-content")||n.classList.contains("rte-content"))?n:document.querySelector(".editora-content, .rte-content")}function Nl(){if(document.getElementById("emojis-dialog-styles"))return;const n=document.createElement("style");n.id="emojis-dialog-styles",n.textContent=`
1437
- /* Emojis Dialog Styles */
1438
- .emojis-overlay {
1439
- position: fixed;
1440
- top: 0;
1441
- left: 0;
1442
- right: 0;
1443
- bottom: 0;
1444
- background-color: rgba(0, 0, 0, 0.5);
1445
- display: flex;
1446
- align-items: center;
1447
- justify-content: center;
1448
- z-index: 1000;
1449
- }
1450
-
1451
- .emojis-dialog {
1452
- background: white;
1453
- border-radius: 8px;
1454
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
1455
- max-width: 800px;
1456
- width: 90%;
1457
- max-height: 80vh;
1458
- display: flex;
1459
- flex-direction: column;
1460
- }
1461
-
1462
- .emojis-header h3 {
1463
- color: #1a202c;
1464
- }
1465
-
1466
- .emojis-content {
1467
- display: flex;
1468
- flex: 1;
1469
- overflow: hidden;
1470
- padding: 0;
1471
- }
1472
-
1473
- .emojis-main-content {
1474
- flex: 1;
1475
- display: flex;
1476
- flex-direction: column;
1477
- overflow: hidden;
1478
- }
1479
-
1480
- .emojis-search {
1481
- padding: 16px 16px 0 16px;
1482
- position: relative;
1483
- }
1484
-
1485
- .emojis-search-icon {
1486
- position: absolute;
1487
- left: 28px;
1488
- top: 27px;
1489
- color: #a0aec0;
1490
- pointer-events: none;
1491
- z-index: 1;
1492
- }
1493
-
1494
- .emojis-search-input {
1495
- width: calc(100% - 24px);
1496
- padding: 10px 12px 10px 40px;
1497
- border: 1px solid #e1e5e9;
1498
- border-radius: 6px;
1499
- font-size: 14px;
1500
- color: #2d3748;
1501
- background-color: #ffffff;
1502
- transition: border-color 0.2s ease, box-shadow 0.2s ease;
1503
- }
1504
-
1505
- .emojis-search-input:focus {
1506
- outline: none;
1507
- border-color: #4299e1;
1508
- box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
1509
- }
1510
-
1511
- .emojis-search-input:focus + .emojis-search-icon {
1512
- color: #4299e1;
1513
- }
1514
-
1515
- .emojis-search-input::placeholder {
1516
- color: #a0aec0;
1517
- }
1518
-
1519
- .emojis-tabs {
1520
- display: flex;
1521
- flex-direction: column;
1522
- width: 180px;
1523
- border-right: 1px solid #e1e5e9;
1524
- background-color: #f8fafc;
1525
- }
1526
-
1527
- .emojis-tab {
1528
- padding: 12px 16px;
1529
- border: none;
1530
- background: none;
1531
- text-align: left;
1532
- cursor: pointer;
1533
- font-size: 14px;
1534
- color: #4a5568;
1535
- border-bottom: 1px solid #e1e5e9;
1536
- transition: all 0.2s ease;
1537
- }
1538
-
1539
- .emojis-tab:hover {
1540
- background-color: #edf2f7;
1541
- color: #2d3748;
1542
- }
1543
-
1544
- .emojis-tab.active {
1545
- background-color: #4299e1;
1546
- color: white;
1547
- font-weight: 500;
1548
- }
1549
-
1550
- .emojis-tab.active:hover {
1551
- background-color: #3182ce;
1552
- }
1553
-
1554
- .emojis-grid {
1555
- padding: 16px;
1556
- overflow-y: auto;
1557
- display: grid;
1558
- grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
1559
- gap: 8px;
1560
- }
1561
-
1562
- .emojis-item {
1563
- width: 40px;
1564
- height: 40px;
1565
- display: flex;
1566
- align-items: center;
1567
- justify-content: center;
1568
- border: 1px solid #e1e5e9;
1569
- background: white;
1570
- border-radius: 4px;
1571
- cursor: pointer;
1572
- font-size: 18px;
1573
- transition: all 0.2s ease;
1574
- color: #2d3748;
1575
- }
1576
-
1577
- .emojis-item:hover {
1578
- background-color: #4299e1;
1579
- border-color: #4299e1;
1580
- color: white;
1581
- transform: scale(1.05);
1582
- }
1583
-
1584
- .emojis-item:active {
1585
- transform: scale(0.95);
1586
- }
1587
-
1588
- .emojis-no-results {
1589
- grid-column: 1 / -1;
1590
- text-align: center;
1591
- color: #718096;
1592
- font-size: 14px;
1593
- padding: 40px 20px;
1594
- background-color: #f8fafc;
1595
- border-radius: 6px;
1596
- border: 1px solid #e1e5e9;
1597
- }
1598
-
1599
- /* Responsive design */
1600
- @media (max-width: 768px) {
1601
- .emojis-dialog {
1602
- width: 95%;
1603
- max-height: 90vh;
1604
- }
1605
-
1606
- .emojis-content {
1607
- flex-direction: column;
1608
- }
1609
-
1610
- .emojis-tabs {
1611
- width: 100%;
1612
- border-right: none;
1613
- border-bottom: 1px solid #e1e5e9;
1614
- flex-direction: row;
1615
- overflow-x: auto;
1616
- }
1617
-
1618
- .emojis-tab {
1619
- border-bottom: none;
1620
- border-right: 1px solid #e1e5e9;
1621
- white-space: nowrap;
1622
- min-width: 80px;
1623
- }
1624
-
1625
- .emojis-grid {
1626
- grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
1627
- gap: 6px;
1628
- }
1629
-
1630
- .emojis-item {
1631
- width: 36px;
1632
- height: 36px;
1633
- font-size: 16px;
1634
- }
1635
- }
1636
- `,document.head.appendChild(n)}const Rl=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],fn=new WeakMap,ye=n=>(fn.has(n)||fn.set(n,{dialogElement:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),fn.get(n)),zl=()=>({name:"embedIframe",toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:n=>(Il(n),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function Il(n){if(!n){const r=document.activeElement;r&&r.closest("[data-editora-editor]")&&(n=r.closest("[data-editora-editor]"))}if(n||(n=document.querySelector("[data-editora-editor]")),!n){console.warn("Editor element not found");return}const e=ye(n);e.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},e.activeTab="general";const t=document.createElement("div");t.className="rte-dialog-overlay",t.onclick=Pt;const o=document.createElement("div");o.className="rte-dialog-content embed-iframe-dialog",o.onclick=r=>r.stopPropagation(),o.innerHTML=`
1637
- <div class="rte-dialog-header">
1638
- <h3>Embed Iframe</h3>
1639
- <button class="rte-dialog-close">×</button>
1640
- </div>
1641
- <div class="rte-dialog-body">
1642
- <div class="rte-vertical-tabs">
1643
- <div class="rte-tab-buttons">
1644
- <button class="rte-tab-button active" data-tab="general">General</button>
1645
- <button class="rte-tab-button" data-tab="advanced">Advanced</button>
1646
- </div>
1647
- <div class="rte-tab-content">
1648
- <div class="rte-tab-panel" data-panel="general" style="display: block;">
1649
- <div class="rte-form-group">
1650
- <label class="rte-form-label">Source</label>
1651
- <input type="url" class="rte-form-input" id="iframe-src" placeholder="https://example.com" required />
1652
- </div>
1653
- <div class="rte-form-group">
1654
- <label class="rte-form-label">Size</label>
1655
- <select class="rte-form-select" id="iframe-size">
1656
- ${Rl.map(r=>`<option value="${r.value}">${r.label}</option>`).join("")}
1657
- </select>
1658
- </div>
1659
- <div class="rte-form-row" id="dimensions-row">
1660
- <div class="rte-form-group">
1661
- <label class="rte-form-label">Width</label>
1662
- <input type="text" class="rte-form-input" id="iframe-width" placeholder="100%" value="100%" />
1663
- </div>
1664
- <div class="rte-form-group">
1665
- <label class="rte-form-label">Height</label>
1666
- <input type="text" class="rte-form-input" id="iframe-height" placeholder="400px" value="400px" />
1667
- </div>
1668
- <div class="rte-form-group constrain-group">
1669
- <button type="button" class="rte-constrain-btn locked" id="constrain-btn" title="Unlock proportions">🔒</button>
1670
- </div>
1671
- </div>
1672
- </div>
1673
- <div class="rte-tab-panel" data-panel="advanced" style="display: none;">
1674
- <div class="rte-form-group">
1675
- <label class="rte-form-label">Name</label>
1676
- <input type="text" class="rte-form-input" id="iframe-name" placeholder="Iframe name" />
1677
- </div>
1678
- <div class="rte-form-group">
1679
- <label class="rte-form-label">Title</label>
1680
- <input type="text" class="rte-form-input" id="iframe-title" placeholder="Iframe title" />
1681
- </div>
1682
- <div class="rte-form-group">
1683
- <label class="rte-form-label">Long Description</label>
1684
- <textarea class="rte-form-textarea" id="iframe-longdesc" placeholder="Detailed description of the iframe content" rows="3"></textarea>
1685
- </div>
1686
- <div class="rte-form-group">
1687
- <label class="rte-form-label">Description URL</label>
1688
- <input type="url" class="rte-form-input" id="iframe-desc-url" placeholder="https://example.com/description" />
1689
- </div>
1690
- <div class="rte-form-group">
1691
- <label class="rte-checkbox-label">
1692
- <input type="checkbox" id="iframe-border" checked />
1693
- Show iframe border
1694
- </label>
1695
- </div>
1696
- <div class="rte-form-group">
1697
- <label class="rte-checkbox-label">
1698
- <input type="checkbox" id="iframe-scrollbar" checked />
1699
- Enable scrollbar
1700
- </label>
1701
- </div>
1702
- </div>
1703
- </div>
1704
- </div>
1705
- </div>
1706
- <div class="rte-dialog-footer">
1707
- <button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
1708
- <button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
1709
- </div>
1710
- `,t.appendChild(o),document.body.appendChild(t),e.dialogElement=t,Dl(o,n),ql(),setTimeout(()=>{o.querySelector("#iframe-src")?.focus()},100)}function Dl(n,e){ye(e),n.querySelector(".rte-dialog-close")?.addEventListener("click",()=>Pt(e)),n.querySelectorAll(".rte-tab-button").forEach(i=>{i.addEventListener("click",a=>{const l=a.target.getAttribute("data-tab");l&&_l(n,l,e)})}),n.querySelector("#iframe-size")?.addEventListener("change",i=>Hl(n,i.target.value,e));const o=n.querySelector("#iframe-width"),r=n.querySelector("#iframe-height");o?.addEventListener("input",i=>Pl(n,i.target.value,e)),r?.addEventListener("input",i=>Ol(n,i.target.value,e)),n.querySelector("#constrain-btn")?.addEventListener("click",()=>$l(n,e)),n.querySelector("#cancel-btn")?.addEventListener("click",()=>Pt(e)),n.querySelector("#save-btn")?.addEventListener("click",()=>Bl(n,e))}function _l(n,e,t){const o=ye(t);o.activeTab=e,n.querySelectorAll(".rte-tab-button").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-tab")===e)}),n.querySelectorAll(".rte-tab-panel").forEach(r=>{r.style.display=r.getAttribute("data-panel")===e?"block":"none"})}function Hl(n,e,t){const o=ye(t);o.formData.selectedSize=e;const r=n.querySelector("#dimensions-row"),i=n.querySelector("#iframe-width"),a=n.querySelector("#iframe-height");e==="inline"?(r.style.display="flex",i.value="100%",a.value="400px",o.formData.width="100%",o.formData.height="400px"):(r.style.display="none",o.formData.width="100%",o.formData.height="auto")}function Pl(n,e,t){const o=ye(t);if(o.formData.width=e,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const r=parseFloat(e);if(!isNaN(r)){const i=r*9/16;o.formData.height=`${i}px`;const a=n.querySelector("#iframe-height");a&&(a.value=o.formData.height)}}}function Ol(n,e,t){const o=ye(t);if(o.formData.height=e,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const r=parseFloat(e);if(!isNaN(r)){const i=r*16/9;o.formData.width=`${i}px`;const a=n.querySelector("#iframe-width");a&&(a.value=o.formData.width)}}}function $l(n,e){const t=ye(e);t.formData.constrainProportions=!t.formData.constrainProportions;const o=n.querySelector("#constrain-btn");o&&(o.textContent=t.formData.constrainProportions?"🔒":"🔓",o.className=`rte-constrain-btn ${t.formData.constrainProportions?"locked":"unlocked"}`,o.title=t.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function Bl(n,e){const t=ye(e),o=n.querySelector("#iframe-src")?.value.trim();if(!o){alert("Please enter a source URL");return}if(!o.startsWith("https://")&&!o.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const r=n.querySelector("#iframe-name")?.value.trim(),i=n.querySelector("#iframe-title")?.value.trim(),a=n.querySelector("#iframe-longdesc")?.value.trim();n.querySelector("#iframe-desc-url")?.value.trim();const l=n.querySelector("#iframe-border")?.checked??!0,c=n.querySelector("#iframe-scrollbar")?.checked??!0;let s=t.formData.width,d=t.formData.height;t.formData.selectedSize!=="inline"&&(s="100%",d="auto"),Fl(e,{src:o,width:s,height:d,aspectRatio:t.formData.selectedSize,name:r||void 0,title:i||void 0,longDescription:a||void 0,showBorder:l,enableScrollbar:c}),Pt(e)}function Fl(n,e){const t=n.querySelector('[contenteditable="true"]');t&&(t.focus(),setTimeout(()=>{const o=[`src="${e.src}"`,`width="${e.width}"`,`height="${e.height}"`,"allowfullscreen",`frameborder="${e.showBorder?"1":"0"}"`,`scrolling="${e.enableScrollbar?"auto":"no"}"`];e.name&&o.push(`name="${e.name}"`),e.title&&o.push(`title="${e.title}"`),e.longDescription&&o.push(`longdesc="${e.longDescription}"`);const r=[];e.aspectRatio!=="inline"&&r.push(`rte-iframe-${e.aspectRatio}`);const i=r.length>0?`class="${r.join(" ")}"`:"",a=`data-aspect-ratio="${e.aspectRatio}"`,l=`<iframe ${o.join(" ")} ${i} ${a}></iframe>`;if(!document.execCommand("insertHTML",!1,l)){const s=window.getSelection();if(s&&s.rangeCount>0){const d=s.getRangeAt(0);d.deleteContents();const p=document.createElement("div");p.innerHTML=l;const g=document.createDocumentFragment();for(;p.firstChild;)g.appendChild(p.firstChild);d.insertNode(g)}}},10))}function Pt(n){const e=ye(n);e.dialogElement&&(document.body.removeChild(e.dialogElement),e.dialogElement=null)}function ql(){if(document.getElementById("embed-iframe-dialog-styles"))return;const n=document.createElement("style");n.id="embed-iframe-dialog-styles",n.textContent=`
1711
- /* Embed Iframe Dialog Styles */
1712
- .embed-iframe-dialog {
1713
- max-width: 600px;
1714
- width: 100%;
1715
- }
1716
-
1717
- .rte-vertical-tabs {
1718
- display: flex;
1719
- gap: 20px;
1720
- min-height: 400px;
1721
- }
1722
-
1723
- .rte-tab-buttons {
1724
- display: flex;
1725
- flex-direction: column;
1726
- width: 120px;
1727
- border-right: 1px solid #e1e5e9;
1728
- }
1729
-
1730
- .rte-tab-button {
1731
- padding: 12px 16px;
1732
- border: none;
1733
- background: none;
1734
- text-align: left;
1735
- cursor: pointer;
1736
- font-size: 14px;
1737
- font-weight: 500;
1738
- color: #666;
1739
- border-right: 3px solid transparent;
1740
- transition: all 0.2s ease;
1741
- }
1742
-
1743
- .rte-tab-button:hover {
1744
- background-color: #f8f9fa;
1745
- color: #333;
1746
- }
1747
-
1748
- .rte-tab-button.active {
1749
- background-color: #e3f2fd;
1750
- color: #1976d2;
1751
- border-right-color: #1976d2;
1752
- font-weight: 600;
1753
- }
1754
-
1755
- .rte-tab-content {
1756
- flex: 1;
1757
- padding: 0 0 0 20px;
1758
- }
1759
-
1760
- .rte-tab-panel {
1761
- padding: 0;
1762
- }
1763
-
1764
- .rte-form-group {
1765
- margin-bottom: 16px;
1766
- }
1767
-
1768
- .rte-form-label {
1769
- display: block;
1770
- margin-bottom: 6px;
1771
- font-size: 14px;
1772
- font-weight: 500;
1773
- color: #333;
1774
- }
1775
-
1776
- .rte-form-textarea,
1777
- .rte-form-select {
1778
- width: 100%;
1779
- padding: 8px 12px;
1780
- border: 1px solid #ccc;
1781
- border-radius: 4px;
1782
- font-size: 14px;
1783
- transition: border-color 0.2s ease;
1784
- box-sizing: border-box;
1785
- }
1786
-
1787
- .rte-form-textarea:focus,
1788
- .rte-form-select:focus {
1789
- outline: none;
1790
- border-color: #0066cc;
1791
- box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
1792
- }
1793
-
1794
- .rte-form-textarea {
1795
- resize: vertical;
1796
- min-height: 80px;
1797
- font-family: inherit;
1798
- }
1799
-
1800
- .rte-form-row {
1801
- display: flex;
1802
- gap: 12px;
1803
- align-items: flex-end;
1804
- }
1805
-
1806
- .rte-form-row .rte-form-group {
1807
- flex: 1;
1808
- }
1809
-
1810
- .rte-form-row .constrain-group {
1811
- flex: 0 0 auto;
1812
- margin-bottom: 0;
1813
- }
1814
-
1815
- .rte-constrain-btn {
1816
- padding: 8px 12px;
1817
- border: 1px solid #ddd;
1818
- background: white;
1819
- border-radius: 4px;
1820
- cursor: pointer;
1821
- font-size: 18px;
1822
- transition: all 0.2s ease;
1823
- height: 38px;
1824
- width: 48px;
1825
- display: flex;
1826
- align-items: center;
1827
- justify-content: center;
1828
- }
1829
-
1830
- .rte-constrain-btn:hover {
1831
- background-color: #f5f5f5;
1832
- border-color: #1976d2;
1833
- }
1834
-
1835
- .rte-constrain-btn.locked {
1836
- background-color: #e3f2fd;
1837
- border-color: #1976d2;
1838
- }
1839
-
1840
- .rte-checkbox-label {
1841
- display: flex;
1842
- align-items: center;
1843
- gap: 8px;
1844
- font-size: 14px;
1845
- color: #333;
1846
- cursor: pointer;
1847
- padding: 4px 0;
1848
- }
1849
-
1850
- .rte-checkbox-label input[type="checkbox"] {
1851
- width: 18px;
1852
- height: 18px;
1853
- cursor: pointer;
1854
- accent-color: #0066cc;
1855
- }
1856
-
1857
- .rte-checkbox-label:hover {
1858
- color: #000;
1859
- }
1860
-
1861
- /* Responsive iframe classes */
1862
- .rte-iframe-21x9,
1863
- .rte-iframe-16x9,
1864
- .rte-iframe-4x3,
1865
- .rte-iframe-1x1 {
1866
- position: relative;
1867
- width: 100%;
1868
- padding-bottom: 56.25%;
1869
- height: 0;
1870
- overflow: hidden;
1871
- }
1872
-
1873
- .rte-iframe-21x9 {
1874
- padding-bottom: 42.857%;
1875
- }
1876
-
1877
- .rte-iframe-16x9 {
1878
- padding-bottom: 56.25%;
1879
- }
1880
-
1881
- .rte-iframe-4x3 {
1882
- padding-bottom: 75%;
1883
- }
1884
-
1885
- .rte-iframe-1x1 {
1886
- padding-bottom: 100%;
1887
- }
1888
-
1889
- .rte-iframe-21x9 iframe,
1890
- .rte-iframe-16x9 iframe,
1891
- .rte-iframe-4x3 iframe,
1892
- .rte-iframe-1x1 iframe {
1893
- position: absolute;
1894
- top: 0;
1895
- left: 0;
1896
- width: 100%;
1897
- height: 100%;
1898
- }
1899
- `,document.head.appendChild(n)}const _e=new Set;function jl(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(e=>{e.forEach(t=>{t.removedNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE){const r=o;if(r.classList?.contains("rte-anchor")){const a=r.id;a&&_e.delete(a)}r.querySelectorAll?.(".rte-anchor")?.forEach(a=>{const l=a.id;l&&_e.delete(l)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function ur(n){return!n||n.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:n.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(n)?/^[a-z0-9\-_]+$/.test(n)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function Vl(){const n=Qn();if(!n)return;const e=Jn(n);if(!e)return;const t=e.querySelectorAll(".rte-anchor"),o=new Set;t.forEach(r=>{const i=r.id;i&&o.add(i)}),_e.clear(),o.forEach(r=>_e.add(r))}function Ul(n,e,t,o){Vl();const r=document.createElement("div");r.className="rte-anchor-dialog-overlay",r.style.cssText=`
1900
- position: fixed;
1901
- top: 0;
1902
- left: 0;
1903
- right: 0;
1904
- bottom: 0;
1905
- background: rgba(0, 0, 0, 0.5);
1906
- display: flex;
1907
- align-items: center;
1908
- justify-content: center;
1909
- z-index: 10000;
1910
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
1911
- `;const i=document.createElement("div");if(i.className="rte-anchor-dialog",i.style.cssText=`
1912
- background: white;
1913
- border-radius: 8px;
1914
- box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
1915
- width: 90%;
1916
- max-width: 450px;
1917
- overflow: hidden;
1918
- animation: rte-anchor-dialog-appear 0.2s ease;
1919
- `,!document.getElementById("rte-anchor-dialog-styles")){const f=document.createElement("style");f.id="rte-anchor-dialog-styles",f.textContent=`
1920
- @keyframes rte-anchor-dialog-appear {
1921
- from { opacity: 0; transform: scale(0.95); }
1922
- to { opacity: 1; transform: scale(1); }
1923
- }
1924
- .rte-anchor-dialog input:focus {
1925
- outline: none !important;
1926
- }
1927
- `,document.head.appendChild(f)}let a="";const l=document.createElement("div");l.style.cssText=`
1928
- display: flex;
1929
- align-items: center;
1930
- justify-content: space-between;
1931
- padding: 16px 20px;
1932
- border-bottom: 1px solid #e0e0e0;
1933
- background: #f9f9f9;
1934
- `;const c=document.createElement("h3");c.style.cssText="margin: 0; font-size: 18px; font-weight: 600; color: #333;",c.textContent="Add Anchor";const s=document.createElement("button");s.textContent="✕",s.style.cssText=`
1935
- background: none;
1936
- border: none;
1937
- font-size: 24px;
1938
- color: #999;
1939
- cursor: pointer;
1940
- padding: 0;
1941
- width: 32px;
1942
- height: 32px;
1943
- display: flex;
1944
- align-items: center;
1945
- justify-content: center;
1946
- border-radius: 4px;
1947
- transition: all 0.2s ease;
1948
- `,s.onmouseover=()=>{s.style.background="#e0e0e0",s.style.color="#333"},s.onmouseout=()=>{s.style.background="none",s.style.color="#999"},l.appendChild(c),l.appendChild(s);const d=document.createElement("div");d.style.cssText="padding: 20px;";const p=document.createElement("div");p.style.cssText="margin-bottom: 0;";const g=document.createElement("label");g.textContent="Anchor ID",g.style.cssText="display: block; font-size: 14px; font-weight: 500; color: #333; margin-bottom: 8px;",g.setAttribute("for","anchor-id-input");const m=document.createElement("input");m.id="anchor-id-input",m.type="text",m.placeholder="e.g., section-introduction",m.value="",m.style.cssText=`
1949
- width: 100%;
1950
- padding: 10px 12px;
1951
- font-size: 14px;
1952
- border: 1px solid #d0d0d0;
1953
- border-radius: 4px;
1954
- font-family: 'Courier New', monospace;
1955
- transition: all 0.2s ease;
1956
- box-sizing: border-box;
1957
- `;const b=document.createElement("div");b.style.cssText=`
1958
- color: #d32f2f;
1959
- font-size: 12px;
1960
- margin-top: 6px;
1961
- display: none;
1962
- `;const x=document.createElement("div");x.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",x.style.cssText="color: #999; font-size: 12px; margin-top: 8px; line-height: 1.4;",p.appendChild(g),p.appendChild(m),p.appendChild(b),p.appendChild(x),d.appendChild(p);const C=document.createElement("div");C.style.cssText=`
1963
- display: flex;
1964
- gap: 12px;
1965
- padding: 16px 20px;
1966
- border-top: 1px solid #e0e0e0;
1967
- background: #f9f9f9;
1968
- justify-content: flex-end;
1969
- `;const k=document.createElement("button");k.textContent="Cancel",k.style.cssText=`
1970
- padding: 8px 16px;
1971
- font-size: 14px;
1972
- font-weight: 500;
1973
- border: none;
1974
- border-radius: 4px;
1975
- cursor: pointer;
1976
- transition: all 0.2s ease;
1977
- background: #f0f0f0;
1978
- color: #333;
1979
- `,k.onmouseover=()=>k.style.background="#e0e0e0",k.onmouseout=()=>k.style.background="#f0f0f0";const y=document.createElement("button");y.textContent="Add Anchor",y.style.cssText=`
1980
- padding: 8px 16px;
1981
- font-size: 14px;
1982
- font-weight: 500;
1983
- border: none;
1984
- border-radius: 4px;
1985
- cursor: pointer;
1986
- transition: all 0.2s ease;
1987
- background: #0066cc;
1988
- color: white;
1989
- `,y.disabled=!m.value.trim();const w=()=>{m.value.trim()?(y.disabled=!1,y.style.background="#0066cc",y.style.color="white",y.style.cursor="pointer"):(y.disabled=!0,y.style.background="#d0d0d0",y.style.color="#999",y.style.cursor="not-allowed")};y.onmouseover=()=>{y.disabled||(y.style.background="#0052a3",y.style.boxShadow="0 2px 8px rgba(0, 102, 204, 0.3)")},y.onmouseout=()=>{y.disabled||(y.style.background="#0066cc",y.style.boxShadow="none")},C.appendChild(k),C.appendChild(y),m.oninput=()=>{const f=m.value;if(w(),f.trim()){const L=ur(f);L.valid?_e.has(f)?(a=`Anchor ID already exists: ${f}`,b.textContent="⚠ "+a,b.style.display="block",m.style.borderColor="#d32f2f",m.style.background="#ffebee"):(a="",b.style.display="none",m.style.borderColor="#d0d0d0",m.style.background="white"):(a=L.error,b.textContent="⚠ "+a,b.style.display="block",m.style.borderColor="#d32f2f",m.style.background="#ffebee")}else b.style.display="none",m.style.borderColor="#d0d0d0",m.style.background="white"},m.onfocus=()=>{m.style.borderColor=a?"#d32f2f":"#0066cc",m.style.boxShadow=a?"0 0 0 3px rgba(211, 47, 47, 0.1)":"0 0 0 3px rgba(0, 102, 204, 0.1)",m.style.background=a?"#ffebee":"#f9f9ff"},m.onblur=()=>{m.style.boxShadow="none",a||(m.style.background="white")};const S=()=>{const f=m.value.trim();!f||!ur(f).valid||_e.has(f)||(t&&t(f),r.remove())},E=()=>{r.remove()};y.onclick=S,k.onclick=E,s.onclick=E,m.onkeydown=f=>{f.key==="Enter"?(f.preventDefault(),S()):f.key==="Escape"&&(f.preventDefault(),E())},r.onclick=f=>{f.target===r&&E()},i.appendChild(l),i.appendChild(d),i.appendChild(C),r.appendChild(i),document.body.appendChild(r),setTimeout(()=>m.focus(),100)}function Wl(n,e){let t;if(e)t=e;else{const a=window.getSelection();if(!a||a.rangeCount===0)return;t=a.getRangeAt(0)}const o=document.createElement("span");o.id=n,o.className="rte-anchor",o.setAttribute("data-type","anchor"),o.setAttribute("data-anchor-id",n),o.setAttribute("title",`Anchor: ${n}`),o.style.cssText=`
1990
- display: inline;
1991
- position: relative;
1992
- cursor: pointer;
1993
- `,t.insertNode(o),_e.add(n),t.setStart(o.nextSibling||o.parentNode,0),t.collapse(!0);const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t));const i=Qn();if(i){const a=Jn(i);a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}ei()}function ei(){if(document.getElementById("rte-anchor-styles"))return;const n=document.createElement("style");n.id="rte-anchor-styles",n.textContent=`
1994
- .rte-anchor {
1995
- display: inline;
1996
- position: relative;
1997
- cursor: pointer;
1998
- transition: all 0.2s ease;
1999
- }
2000
-
2001
- .rte-anchor:hover::before {
2002
- content: '⚓';
2003
- position: absolute;
2004
- top: -1.2em;
2005
- left: 0;
2006
- background: #333;
2007
- color: #fff;
2008
- padding: 2px 6px;
2009
- border-radius: 3px;
2010
- font-size: 0.8em;
2011
- white-space: nowrap;
2012
- z-index: 100;
2013
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
2014
- }
2015
-
2016
- .rte-anchor:hover::after {
2017
- content: attr(data-anchor-id);
2018
- position: absolute;
2019
- top: -1.2em;
2020
- left: 1.4em;
2021
- background: #333;
2022
- color: #fff;
2023
- padding: 2px 6px;
2024
- border-radius: 3px;
2025
- font-size: 0.75em;
2026
- font-family: 'Courier New', monospace;
2027
- white-space: nowrap;
2028
- z-index: 100;
2029
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
2030
- }
2031
-
2032
- [contenteditable='true'] .rte-anchor::before {
2033
- content: '';
2034
- position: absolute;
2035
- width: 8px;
2036
- height: 8px;
2037
- background: #0066cc;
2038
- border-radius: 50%;
2039
- top: -3px;
2040
- left: 0;
2041
- opacity: 0.5;
2042
- transition: opacity 0.2s ease;
2043
- }
2044
-
2045
- [contenteditable='true'] .rte-anchor:hover::before {
2046
- opacity: 1;
2047
- width: auto;
2048
- height: auto;
2049
- background: #333;
2050
- border-radius: 3px;
2051
- top: -1.2em;
2052
- padding: 2px 6px;
2053
- font-size: 0.8em;
2054
- content: '⚓';
2055
- }
2056
-
2057
- @media print {
2058
- .rte-anchor::before,
2059
- .rte-anchor::after {
2060
- display: none;
2061
- }
2062
- .rte-anchor {
2063
- cursor: auto;
2064
- }
2065
- }
2066
-
2067
- .rte-anchor:focus {
2068
- outline: 2px solid #0066cc;
2069
- outline-offset: 2px;
2070
- }
2071
- `,document.head.appendChild(n)}const Gl=()=>(typeof window<"u"&&(jl(),ei()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const n=window.getSelection();if(!n||n.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const e=n.getRangeAt(0).cloneRange();return Ul("add","",t=>{Wl(t,e)},e),!0}catch(n){return console.error("Failed to insert anchor:",n),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});let yt=null,I=null,M=null,Ot=[],vt=!1,Je=null,pr=0,mr=0,Ae=0,Me=0,bn=1,xn=null;const gr=n=>{const e=window.getSelection();e&&e.rangeCount>0&&(yt=e.getRangeAt(0).cloneRange());const t=document.createElement("div");t.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 99999;";const o=document.createElement("div");o.style.cssText="background: white; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);";let r="upload",i="",a="",l="",c="";const s=()=>{o.innerHTML=`
2072
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e1e5e9; background: #f8f9fa;">
2073
- <h2 style="margin: 0; font-size: 18px; font-weight: 600;">Insert ${n==="image"?"Image":"Video"}</h2>
2074
- <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: #6c757d; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
2075
- </div>
2076
-
2077
- <div class="tabs" style="display: flex; border-bottom: 1px solid #e1e5e9;">
2078
- <button class="tab-upload" style="flex: 1; padding: 12px; border: none; background: ${r==="upload"?"#007bff":"#f8f9fa"}; color: ${r==="upload"?"white":"#495057"}; cursor: pointer; font-weight: 500;">📤 Upload</button>
2079
- <button class="tab-url" style="flex: 1; padding: 12px; border: none; background: ${r==="url"?"#007bff":"#f8f9fa"}; color: ${r==="url"?"white":"#495057"}; cursor: pointer; font-weight: 500;">🔗 URL</button>
2080
- </div>
2081
-
2082
- <div style="padding: 20px; overflow-y: auto; flex: 1;">
2083
- ${r==="upload"?`
2084
- <div id="upload-section">
2085
- <div class="dropzone" style="border: 2px dashed #ced4da; border-radius: 8px; padding: 40px; text-align: center; cursor: pointer; transition: all 0.3s;">
2086
- <div style="font-size: 48px; margin-bottom: 10px;">📁</div>
2087
- <p style="margin: 0 0 8px 0; font-weight: 600; font-size: 16px;">Drag and drop your ${n} here</p>
2088
- <p style="margin: 0 0 8px 0; color: #6c757d; font-size: 14px;">or click to browse</p>
2089
- <p style="margin: 0; color: #6c757d; font-size: 12px;">Max file size: 50MB</p>
2090
- </div>
2091
- <input type="file" id="file-input" accept="${n==="image"?"image/*":"video/*"}" style="display: none;">
2092
- <div id="upload-progress" style="display: none; margin-top: 20px;">
2093
- <div style="background: #e9ecef; border-radius: 4px; height: 8px; overflow: hidden;">
2094
- <div id="progress-bar" style="background: #007bff; height: 100%; width: 0%; transition: width 0.3s;"></div>
2095
- </div>
2096
- <p id="progress-text" style="margin-top: 8px; text-align: center; color: #6c757d; font-size: 14px;">Uploading...</p>
2097
- </div>
2098
- </div>
2099
- `:`
2100
- <div id="url-section">
2101
- <div style="margin-bottom: 20px;">
2102
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">URL:</label>
2103
- <input type="text" id="url-input" placeholder="https://example.com/${n}.${n==="image"?"jpg":"mp4"}" value="${i}" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;">
2104
- </div>
2105
- ${n==="image"?`
2106
- <div style="margin-bottom: 20px;">
2107
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Alt Text (for accessibility):</label>
2108
- <input type="text" id="alt-input" placeholder="Describe the image" value="${c}" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;">
2109
- </div>
2110
- `:""}
2111
- <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px;">
2112
- <div>
2113
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Width (px):</label>
2114
- <input type="number" id="width-input" placeholder="Auto" value="${a}" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;">
2115
- </div>
2116
- <div>
2117
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Height (px):</label>
2118
- <input type="number" id="height-input" placeholder="Auto" value="${l}" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;">
2119
- </div>
2120
- </div>
2121
- ${i?`
2122
- <div style="margin-bottom: 20px;">
2123
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Preview:</label>
2124
- <div style="border: 1px solid #dee2e6; border-radius: 4px; padding: 10px; background: #f8f9fa; text-align: center;">
2125
- ${n==="image"?`<img src="${i}" alt="Preview" style="max-width: 100%; max-height: 200px;">`:`<video src="${i}" controls style="max-width: 100%; max-height: 200px;"></video>`}
2126
- </div>
2127
- </div>
2128
- `:""}
2129
- </div>
2130
- `}
2131
- </div>
2132
-
2133
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid #e1e5e9; background: #f8f9fa;">
2134
- <button class="cancel-btn" style="padding: 10px 20px; background: #fff; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
2135
- <button id="insert-btn" style="padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" ${!i&&r==="url"?"disabled":""}>Insert</button>
2136
- </div>
2137
- `};s(),t.appendChild(o),document.body.appendChild(t);const d=()=>document.body.removeChild(t),p=()=>{if(!i)return;const b=n==="image"?document.createElement("img"):document.createElement("video");b.src=i,b.setAttribute("data-media-type",n),n==="image"&&c&&(b.alt=c),a&&(b.style.width=`${a}px`,b.setAttribute("width",a)),l&&(b.style.height=`${l}px`,b.setAttribute("height",l)),n==="video"&&(b.controls=!0),!a&&!l?b.style.cssText="max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;":b.style.cssText=`display: block; margin: 1em 0; cursor: pointer; ${a?`width: ${a}px;`:"max-width: 100%;"} ${l?`height: ${l}px;`:"height: auto;"}`,yt&&(yt.deleteContents(),yt.insertNode(b)),d()},g=async b=>{const x=o.querySelector("#upload-progress"),C=o.querySelector("#progress-bar"),k=o.querySelector("#progress-text");if(x&&C&&k){x.style.display="block";let y=0;const w=setInterval(()=>{y+=Math.random()*30,y>90&&(y=90),C.style.width=`${y}%`},200);try{const S=new FileReader;S.onload=()=>{clearInterval(w),C.style.width="100%",k.textContent="✅ Upload complete",setTimeout(()=>{i=S.result,r="url",s(),m()},500)},S.readAsDataURL(b)}catch{clearInterval(w),k.textContent="❌ Upload failed"}}},m=()=>{const b=o.querySelector(".close-btn"),x=o.querySelector(".cancel-btn"),C=o.querySelector("#insert-btn"),k=o.querySelector(".tab-upload"),y=o.querySelector(".tab-url");if(b?.addEventListener("click",d),x?.addEventListener("click",d),C?.addEventListener("click",p),k?.addEventListener("click",()=>{r="upload",s(),m()}),y?.addEventListener("click",()=>{r="url",s(),m()}),r==="upload"){const w=o.querySelector(".dropzone"),S=o.querySelector("#file-input");w?.addEventListener("click",()=>S?.click()),w?.addEventListener("dragover",E=>{E.preventDefault(),w.style.borderColor="#007bff",w.style.background="#f0f8ff"}),w?.addEventListener("dragleave",()=>{w.style.borderColor="#ced4da",w.style.background="transparent"}),w?.addEventListener("drop",E=>{E.preventDefault(),w.style.borderColor="#ced4da",w.style.background="transparent";const f=E.dataTransfer?.files[0];f&&g(f)}),S?.addEventListener("change",E=>{const f=E.target.files?.[0];f&&g(f)})}if(r==="url"){const w=o.querySelector("#url-input"),S=o.querySelector("#alt-input"),E=o.querySelector("#width-input"),f=o.querySelector("#height-input");w?.addEventListener("input",()=>{i=w.value,s(),m()}),S?.addEventListener("input",()=>{c=S.value}),E?.addEventListener("input",()=>{a=E.value}),f?.addEventListener("input",()=>{l=f.value})}};m(),t.addEventListener("click",b=>{b.target===t&&d()})},Zl=()=>{["nw","ne","sw","se"].forEach(e=>{const t=document.createElement("div");t.className=`media-resize-handle-${e}`,t.style.cssText=`
2138
- position: fixed;
2139
- width: 10px;
2140
- height: 10px;
2141
- background: #007bff;
2142
- border: 2px solid white;
2143
- border-radius: 50%;
2144
- cursor: ${e}-resize;
2145
- z-index: 10001;
2146
- display: none;
2147
- box-shadow: 0 1px 3px rgba(0,0,0,0.3);
2148
- `,t.setAttribute("data-position",e),document.body.appendChild(t),Ot.push(t)})},Re=()=>{if(!I){Ot.forEach(t=>t.style.display="none");return}const n=I.getBoundingClientRect(),e={nw:{x:n.left-5,y:n.top-5},ne:{x:n.right-5,y:n.top-5},sw:{x:n.left-5,y:n.bottom-5},se:{x:n.right-5,y:n.bottom-5}};Ot.forEach(t=>{const o=t.getAttribute("data-position"),r=e[o];t.style.left=`${r.x}px`,t.style.top=`${r.y}px`,t.style.display="block"})},Kl=n=>{const e=document.createElement("div");e.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 10001;";const t=document.createElement("div");t.style.cssText="background: white; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);",t.innerHTML=`
2149
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e1e5e9; background: #f8f9fa;">
2150
- <h2 style="margin: 0; font-size: 18px; font-weight: 600;">Edit Alt Text</h2>
2151
- <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: #6c757d; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
2152
- </div>
2153
- <div style="padding: 20px;">
2154
- <label style="display: block; margin-bottom: 8px; font-weight: 500;">Alternative Text (for accessibility):</label>
2155
- <textarea id="alt-text-input" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px; min-height: 80px; font-family: inherit; resize: vertical;" placeholder="Describe the image for screen readers...">${n.alt||""}</textarea>
2156
- <p style="margin-top: 8px; margin-bottom: 0; font-size: 12px; color: #6c757d;">Good alt text is descriptive and concise. It helps users with visual impairments understand your content.</p>
2157
- </div>
2158
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid #e1e5e9; background: #f8f9fa;">
2159
- <button class="cancel-btn" style="padding: 10px 20px; background: #fff; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
2160
- <button class="save-btn" style="padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;">Save</button>
2161
- </div>
2162
- `,e.appendChild(t),document.body.appendChild(e);const o=t.querySelector("#alt-text-input"),r=t.querySelector(".close-btn"),i=t.querySelector(".cancel-btn"),a=t.querySelector(".save-btn"),l=()=>document.body.removeChild(e);r.addEventListener("click",l),i.addEventListener("click",l),e.addEventListener("click",c=>{c.target===e&&l()}),a.addEventListener("click",()=>{n.alt=o.value,l()}),o.focus(),o.select()},Xl=n=>{const e=n.closest("a"),t=e?.getAttribute("href")||"",o=e?.getAttribute("target")||"_self",r=e?.getAttribute("title")||"",i=document.createElement("div");i.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 10001;";const a=document.createElement("div");a.style.cssText="background: white; border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);",a.innerHTML=`
2163
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e1e5e9; background: #f8f9fa;">
2164
- <h2 style="margin: 0; font-size: 18px; font-weight: 600;">${e?"Edit Link":"Add Link"}</h2>
2165
- <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: #6c757d; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
2166
- </div>
2167
- <div style="padding: 20px;">
2168
- <div style="margin-bottom: 16px;">
2169
- <label style="display: block; margin-bottom: 6px; font-weight: 500;">URL:</label>
2170
- <input id="link-url" type="url" value="${t}" placeholder="https://example.com" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;" />
2171
- </div>
2172
- <div style="margin-bottom: 16px;">
2173
- <label style="display: block; margin-bottom: 6px; font-weight: 500;">Title (tooltip):</label>
2174
- <input id="link-title" type="text" value="${r}" placeholder="Optional tooltip text" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;" />
2175
- </div>
2176
- <div>
2177
- <label style="display: flex; align-items: center; cursor: pointer;">
2178
- <input id="link-target" type="checkbox" ${o==="_blank"?"checked":""} style="margin-right: 8px;" />
2179
- Open in new window/tab
2180
- </label>
2181
- </div>
2182
- </div>
2183
- <div style="display: flex; justify-content: space-between; padding: 16px 20px; border-top: 1px solid #e1e5e9; background: #f8f9fa;">
2184
- ${e?'<button class="remove-link-btn" style="padding: 10px 20px; background: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;">Remove Link</button>':"<span></span>"}
2185
- <div style="display: flex; gap: 10px;">
2186
- <button class="cancel-btn" style="padding: 10px 20px; background: #fff; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
2187
- <button class="save-btn" style="padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;">Save</button>
2188
- </div>
2189
- </div>
2190
- `,i.appendChild(a),document.body.appendChild(i);const l=a.querySelector("#link-url"),c=a.querySelector("#link-title"),s=a.querySelector("#link-target"),d=a.querySelector(".close-btn"),p=a.querySelector(".cancel-btn"),g=a.querySelector(".save-btn"),m=a.querySelector(".remove-link-btn"),b=()=>document.body.removeChild(i);d.addEventListener("click",b),p.addEventListener("click",b),i.addEventListener("click",x=>{x.target===i&&b()}),g.addEventListener("click",()=>{const x=l.value.trim();if(x){const C=x.startsWith("http")?x:`https://${x}`;if(e)e.setAttribute("href",C),e.setAttribute("target",s.checked?"_blank":"_self"),s.checked?e.setAttribute("rel","noopener noreferrer"):e.removeAttribute("rel"),c.value.trim()?e.setAttribute("title",c.value.trim()):e.removeAttribute("title");else{const k=document.createElement("a");k.href=C,k.target=s.checked?"_blank":"_self",s.checked&&(k.rel="noopener noreferrer"),c.value.trim()&&(k.title=c.value.trim()),n.replaceWith(k),k.appendChild(n)}b(),M&&I&&On(I)}}),m?.addEventListener("click",()=>{e&&confirm("Remove link from this media?")&&(e.replaceWith(n),b(),M&&I&&On(I))}),l.focus()},Yl=n=>{const e=document.createElement("div");e.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 10001;";const t=document.createElement("div");t.style.cssText="background: white; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);";let o="url",r=n.src;const i=()=>{t.innerHTML=`
2191
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e1e5e9; background: #f8f9fa;">
2192
- <h2 style="margin: 0; font-size: 18px; font-weight: 600;">Replace Image</h2>
2193
- <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: #6c757d; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
2194
- </div>
2195
-
2196
- <div class="tabs" style="display: flex; border-bottom: 1px solid #e1e5e9;">
2197
- <button class="tab-upload" style="flex: 1; padding: 12px; border: none; background: ${o==="upload"?"#007bff":"#f8f9fa"}; color: ${o==="upload"?"white":"#495057"}; cursor: pointer; font-weight: 500;">📤 Upload</button>
2198
- <button class="tab-url" style="flex: 1; padding: 12px; border: none; background: ${o==="url"?"#007bff":"#f8f9fa"}; color: ${o==="url"?"white":"#495057"}; cursor: pointer; font-weight: 500;">🔗 URL</button>
2199
- </div>
2200
-
2201
- <div style="padding: 20px; overflow-y: auto; flex: 1;">
2202
- ${o==="upload"?`
2203
- <div id="upload-section">
2204
- <div class="dropzone" style="border: 2px dashed #ced4da; border-radius: 8px; padding: 40px; text-align: center; cursor: pointer; transition: all 0.3s;">
2205
- <div style="font-size: 48px; margin-bottom: 10px;">📁</div>
2206
- <p style="margin: 0 0 8px 0; font-weight: 600; font-size: 16px;">Drag and drop your image here</p>
2207
- <p style="margin: 0 0 8px 0; color: #6c757d; font-size: 14px;">or click to browse</p>
2208
- </div>
2209
- <input type="file" id="file-input" accept="image/*" style="display: none;">
2210
- <div id="upload-progress" style="display: none; margin-top: 20px;">
2211
- <div style="background: #e9ecef; border-radius: 4px; height: 8px; overflow: hidden;">
2212
- <div id="progress-bar" style="background: #007bff; height: 100%; width: 0%; transition: width 0.3s;"></div>
2213
- </div>
2214
- <p id="progress-text" style="margin-top: 8px; text-align: center; color: #6c757d; font-size: 14px;">Uploading...</p>
2215
- </div>
2216
- </div>
2217
- `:`
2218
- <div id="url-section">
2219
- <div style="margin-bottom: 20px;">
2220
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Image URL:</label>
2221
- <input type="text" id="url-input" placeholder="https://example.com/image.jpg" value="${r}" style="width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #ced4da; border-radius: 4px; font-size: 14px;">
2222
- </div>
2223
- ${r?`
2224
- <div style="margin-bottom: 20px;">
2225
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px;">Preview:</label>
2226
- <div style="border: 1px solid #dee2e6; border-radius: 4px; padding: 10px; background: #f8f9fa; text-align: center;">
2227
- <img src="${r}" alt="Preview" style="max-width: 100%; max-height: 300px;" onerror="this.parentElement.innerHTML='<p style=&quot;color: #dc3545;&quot;>Failed to load image</p>'">
2228
- </div>
2229
- </div>
2230
- `:""}
2231
- </div>
2232
- `}
2233
- </div>
2234
-
2235
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid #e1e5e9; background: #f8f9fa;">
2236
- <button class="cancel-btn" style="padding: 10px 20px; background: #fff; border: 1px solid #ced4da; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
2237
- <button id="replace-btn" style="padding: 10px 20px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" ${!r&&o==="url"?"disabled":""}>Replace</button>
2238
- </div>
2239
- `};i(),e.appendChild(t),document.body.appendChild(e);const a=()=>document.body.removeChild(e),l=()=>{r&&(n.src=r,a())},c=async d=>{const p=t.querySelector("#upload-progress"),g=t.querySelector("#progress-bar"),m=t.querySelector("#progress-text");if(p&&g&&m){p.style.display="block";let b=0;const x=setInterval(()=>{b+=Math.random()*30,b>90&&(b=90),g.style.width=`${b}%`},200);try{const C=new FileReader;C.onload=()=>{clearInterval(x),g.style.width="100%",m.textContent="✅ Upload complete",setTimeout(()=>{r=C.result,o="url",i(),s()},500)},C.readAsDataURL(d)}catch{clearInterval(x),m.textContent="❌ Upload failed"}}},s=()=>{const d=t.querySelector(".close-btn"),p=t.querySelector(".cancel-btn"),g=t.querySelector("#replace-btn"),m=t.querySelector(".tab-upload"),b=t.querySelector(".tab-url");if(d?.addEventListener("click",a),p?.addEventListener("click",a),g?.addEventListener("click",l),m?.addEventListener("click",()=>{o="upload",i(),s()}),b?.addEventListener("click",()=>{o="url",i(),s()}),o==="upload"){const x=t.querySelector(".dropzone"),C=t.querySelector("#file-input");x?.addEventListener("click",()=>C?.click()),x?.addEventListener("dragover",k=>{k.preventDefault(),x.style.borderColor="#007bff",x.style.background="#f0f8ff"}),x?.addEventListener("dragleave",()=>{x.style.borderColor="#ced4da",x.style.background="transparent"}),x?.addEventListener("drop",k=>{k.preventDefault(),x.style.borderColor="#ced4da",x.style.background="transparent";const y=k.dataTransfer?.files[0];y&&c(y)}),C?.addEventListener("change",k=>{const y=k.target.files?.[0];y&&c(y)})}if(o==="url"){const x=t.querySelector("#url-input");x?.addEventListener("input",()=>{r=x.value,i(),s()})}};s(),e.addEventListener("click",d=>{d.target===e&&a()})},pe=()=>{if(!M||!I)return;const n=M.offsetHeight||40,e=I.offsetTop,t=I.offsetLeft,o=I.offsetWidth,r=e-n-8,i=t+o/2-(M.offsetWidth||120)/2;M.style.top=`${r}px`,M.style.left=`${i}px`,setTimeout(()=>{M&&(M.style.display="flex")},100)},On=n=>{M&&(M._cleanup&&M._cleanup(),M.remove());const e=n.parentElement;if(e){const l=e.style.position;(!l||l==="static")&&(e.style.position="relative",e._originalPosition=l),M=document.createElement("div"),M.className="media-floating-toolbar",M.style.cssText=`
2240
- position: absolute;
2241
- background: white;
2242
- border: 1px solid #ced4da;
2243
- border-radius: 6px;
2244
- box-shadow: 0 2px 12px rgba(0,0,0,0.15);
2245
- gap: 2px;
2246
- padding: 4px;
2247
- z-index: 10000;
2248
- pointer-events: auto;
2249
- display: none;
2250
- `,e.insertBefore(M,e.firstChild),pe()}const t="padding: 6px 8px; border: none; background: white; cursor: pointer; border-radius: 4px; transition: background 0.2s; display: flex; align-items: center; justify-content: center;",o=n.tagName==="IMG",r=n.closest("a");M.innerHTML=`
2251
- <button class="btn-align-left" title="Align Left" style="${t}">
2252
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
2253
- </button>
2254
- <button class="btn-align-center" title="Align Center" style="${t}">
2255
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="18" y1="10" x2="6" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="18" y1="18" x2="6" y2="18"></line></svg>
2256
- </button>
2257
- <button class="btn-align-right" title="Align Right" style="${t}">
2258
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="21" y1="10" x2="7" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="21" y1="18" x2="7" y2="18"></line></svg>
2259
- </button>
2260
- <div style="width: 1px; height: 20px; background: #dee2e6; margin: 0 2px;"></div>
2261
- ${o?`
2262
- <button class="btn-alt" title="Edit Alt Text" style="${t}">
2263
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
2264
- </button>`:""}
2265
- <button class="btn-link" title="${r?"Edit/Remove Link":"Add Link"}" style="${t}">
2266
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
2267
- </button>
2268
- ${o?`
2269
- <button class="btn-replace" title="Replace Image" style="${t}">
2270
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></svg>
2271
- </button>`:""}
2272
- <div style="width: 1px; height: 20px; background: #dee2e6; margin: 0 2px;"></div>
2273
- <button class="btn-remove" title="Remove" style="${t}">
2274
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
2275
- </button>
2276
- `,setTimeout(()=>{pe()},0);const i=()=>pe();let a=I.parentElement;for(;a;)a.addEventListener("scroll",i),a=a.parentElement;window.addEventListener("scroll",i),window.addEventListener("resize",i),M._cleanup=()=>{let l=I?.parentElement;for(;l;)l.removeEventListener("scroll",i),l=l.parentElement;window.removeEventListener("scroll",i),window.removeEventListener("resize",i)},M.querySelectorAll("button").forEach(l=>{l.addEventListener("mouseenter",()=>{l.style.background="#f8f9fa"}),l.addEventListener("mouseleave",()=>{l.style.background="white"})}),M.querySelector(".btn-align-left")?.addEventListener("click",()=>{n.style.display="block",n.style.marginLeft="0",n.style.marginRight="auto",pe()}),M.querySelector(".btn-align-center")?.addEventListener("click",()=>{n.style.display="block",n.style.marginLeft="auto",n.style.marginRight="auto",pe()}),M.querySelector(".btn-align-right")?.addEventListener("click",()=>{n.style.display="block",n.style.marginLeft="auto",n.style.marginRight="0",pe()}),M.querySelector(".btn-alt")?.addEventListener("click",()=>{n.tagName==="IMG"&&Kl(n)}),M.querySelector(".btn-link")?.addEventListener("click",()=>{Xl(n)}),M.querySelector(".btn-replace")?.addEventListener("click",()=>{n.tagName==="IMG"&&Yl(n)}),M.querySelector(".btn-resize")?.addEventListener("click",()=>{const l=prompt("Enter width in pixels:",String(n.width||n.offsetWidth));if(l&&!isNaN(parseInt(l))){const c=parseInt(l);n.style.width=`${c}px`,n.setAttribute("width",String(c)),Re(),pe()}}),M.querySelector(".btn-remove")?.addEventListener("click",()=>{confirm("Remove this media?")&&(n.remove(),M&&(M._cleanup&&M._cleanup(),M.remove(),M=null),I=null,Re())}),M._cleanup=()=>{window.removeEventListener("scroll",pe),window.removeEventListener("resize",pe)}},ti=n=>{xn=n||null,Zl(),document.addEventListener("click",e=>{const t=e.target;if(t.tagName==="IMG"||t.tagName==="VIDEO"){const o=t;let r=!1;if(xn?r=xn.contains(o):r=!!o.closest('[contenteditable="true"]'),r){e.preventDefault(),e.stopPropagation(),I=o,I.style.display="block",On(o),Re();return}}if(!t.closest(".btn-link, .btn-resize, .btn-remove")&&M&&!t.closest("button")){if(M._cleanup&&M._cleanup(),M.remove(),M=null,I&&I.parentElement){const o=I.parentElement;o._originalPosition!==void 0&&(o.style.position=o._originalPosition,delete o._originalPosition)}I=null,Re()}}),Ot.forEach(e=>{e.addEventListener("mousedown",t=>{if(!I)return;t.preventDefault(),t.stopPropagation(),vt=!0,Je=e.getAttribute("data-position"),pr=t.clientX,mr=t.clientY;const o=I.getBoundingClientRect();Ae=o.width,Me=o.height,bn=Ae/Me,document.body.style.userSelect="none",document.body.style.cursor=`${Je}-resize`})}),document.addEventListener("mousemove",e=>{if(!vt||!I||!Je)return;const t=e.clientX-pr,o=e.clientY-mr;let r=Ae,i=Me;switch(Je){case"se":r=Ae+t,i=Me+o;break;case"sw":r=Ae-t,i=Me+o;break;case"ne":r=Ae+t,i=Me-o;break;case"nw":r=Ae-t,i=Me-o;break}Math.abs(t)>Math.abs(o)?i=r/bn:r=i*bn,r=Math.max(50,r),i=Math.max(50,i),I.style.width=`${r}px`,I.style.height=`${i}px`,I.setAttribute("width",String(Math.round(r))),I.setAttribute("height",String(Math.round(i))),Re(),pe()}),document.addEventListener("mouseup",()=>{vt&&(vt=!1,Je=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",Re),window.addEventListener("resize",Re)};typeof window<"u"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,ti());const Ql=()=>({name:"image",initialize:n=>{const e=n?.editorElement;ti(e)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:()=>(gr("image"),!0),insertVideo:()=>(gr("video"),!0)},keymap:{"Mod-Shift-i":"insertImage"}}),Jl={apiUrl:"http://localhost:3001/api/",headers:{}};let $n={...Jl};function es(n){$n={...$n,...n}}function oo(){return{...$n}}function ni(){return oo().headers||{}}function oi(n,e){const t=n.replace(/\/$/,""),o=e.replace(/^\//,"");return`${t}/${o}`}const ts={apiEndpoints:{upload:"/media/upload",library:"/media/library",delete:"/media/library"},maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif","video/mp4","video/webm"],headers:{}};let Bn={...ts};function ns(n){Bn={...Bn,...n}}function os(){return{...Bn}}const rs=()=>({name:"document-manager",toolbar:[{label:"Import Word",command:"importWord",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V15h-2V9h-4V5H5c0-1.1.9-2 2-2Z"></path><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4 18.2a1 1 0 0 0 1.2 1.6l1.4-1V22a1 1 0 1 0 2 0v-3.1l1.4 1a1 1 0 0 0 1.2-1.7L15 15.8l-3.6 2.4Z"></path></svg>',type:"button"},{label:"Export Word",command:"exportWord",icon:'<svg width="24" height="24" focusable="false"><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2ZM15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',type:"button"},{label:"Export PDF",command:"exportPdf",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2Z"></path><path d="M2.6 15.2v-1.9h1c.6 0 1-.2 1.4-.5.3-.3.5-.7.5-1.2s-.2-.9-.5-1.2a2 2 0 0 0-1.3-.4H1v5.2h1.6Zm.4-3h-.4v-1.1h.5l.6.1.2.5c0 .1 0 .3-.2.4l-.7.1Zm5.7 3 1-.1c.3 0 .5-.2.7-.4l.5-.8c.2-.3.2-.7.2-1.3v-1l-.5-.8c-.2-.3-.4-.5-.7-.6L8.7 10H6.3v5.2h2.4Zm-.4-1.1H8v-3h.4c.5 0 .8.2 1 .4l.2 1.1-.1 1-.3.3-.8.2Zm5.3 1.2V13h2v-1h-2v-1H16V10h-4v5.2h1.6Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',type:"button"}],commands:{importWord:()=>{const n=()=>{const t=window.getSelection();if(t&&t.rangeCount>0){let i=t.getRangeAt(0).startContainer;for(;i&&i!==document.body;){if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(a.getAttribute("contenteditable")==="true")return a}i=i.parentNode}}const o=document.activeElement;if(o?.getAttribute("contenteditable")==="true")return o;const r=o?.closest('[contenteditable="true"]');return r||document.querySelector('[contenteditable="true"]')},e=document.createElement("input");return e.type="file",e.accept=".docx",e.onchange=async t=>{const o=t.target.files?.[0];if(o)try{const r=n();if(r){const{importFromWord:i}=await Promise.resolve().then(()=>require("./documentManager-BGlu3WRB.js")).then(l=>l.documentManager),a=await i(o);r.innerHTML=a,r.dispatchEvent(new Event("input",{bubbles:!0}))}}catch(r){console.error("Import failed:",r),alert("Failed to import Word document. Please check the console for details.")}},e.click(),!0},exportWord:async()=>{const n=()=>{const e=window.getSelection();if(e&&e.rangeCount>0){let r=e.getRangeAt(0).startContainer;for(;r&&r!==document.body;){if(r.nodeType===Node.ELEMENT_NODE&&r.getAttribute("contenteditable")==="true")return r;r=r.parentNode}}const t=document.activeElement;return t?.getAttribute("contenteditable")==="true"?t:t?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')};try{const e=n();if(e){const t=e.innerHTML,{exportToWord:o}=await Promise.resolve().then(()=>require("./documentManager-BGlu3WRB.js")).then(r=>r.documentManager);await o(t,"document.docx")}return!0}catch(e){return console.error("Export failed:",e),alert("Failed to export to Word. Please check the console for details."),!1}},exportPdf:async()=>{const n=()=>{const e=window.getSelection();if(e&&e.rangeCount>0){let r=e.getRangeAt(0).startContainer;for(;r&&r!==document.body;){if(r.nodeType===Node.ELEMENT_NODE&&r.getAttribute("contenteditable")==="true")return r;r=r.parentNode}}const t=document.activeElement;return t?.getAttribute("contenteditable")==="true"?t:t?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')};try{const e=n();if(e){const t=e.innerHTML,{exportToPdf:o}=await Promise.resolve().then(()=>require("./documentManager-BGlu3WRB.js")).then(r=>r.documentManager);await o(t,"document.pdf",e)}else console.error("PDF Export: No editor element found"),alert("No active editor found. Please click in the editor area first.");return!0}catch(e){return console.error("PDF Export: Export failed:",e),alert("Failed to export to PDF. Please check the console for details."),!1}}},keymap:{}}),is={apiEndpoints:{exportWord:"/documents/export-word"},headers:{},useClientSideFallback:!0};let Fn={...is};function as(n){Fn={...Fn,...n}}function ro(){return{...Fn}}function ls(n){const e=ro(),t=oo(),o=e.apiUrl||t.apiUrl;return oi(o,e.apiEndpoints[n])}function ss(){const n=ni(),t=ro().headers||{};return{...n,...t}}let yn=!1;const cs=()=>{if(typeof document>"u")return;const n="rte-preview-plugin-styles";if(document.getElementById(n))return;const e=document.createElement("style");e.id=n,e.textContent=`
2277
- /* Preview Editor Dialog Styles */
2278
- .rte-preview-editor-overlay {
2279
- position: fixed !important;
2280
- top: 0 !important;
2281
- left: 0 !important;
2282
- right: 0 !important;
2283
- bottom: 0 !important;
2284
- width: 100vw !important;
2285
- height: 100vh !important;
2286
- background-color: rgba(0, 0, 0, 0.6) !important;
2287
- display: flex !important;
2288
- align-items: center !important;
2289
- justify-content: center !important;
2290
- z-index: 10000 !important;
2291
- padding: 20px !important;
2292
- box-sizing: border-box !important;
2293
- margin: 0 !important;
2294
- }
2295
-
2296
- .rte-preview-editor-modal {
2297
- background: white;
2298
- border-radius: 8px;
2299
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
2300
- width: 100%;
2301
- max-width: 1200px;
2302
- max-height: 90vh;
2303
- display: flex;
2304
- flex-direction: column;
2305
- overflow: hidden;
2306
- position: relative;
2307
- }
2308
-
2309
- .rte-preview-editor-header {
2310
- display: flex;
2311
- align-items: center;
2312
- justify-content: space-between;
2313
- padding: 16px 20px;
2314
- border-bottom: 1px solid #e1e5e9;
2315
- background: #f8f9fa;
2316
- border-radius: 8px 8px 0 0;
2317
- }
2318
-
2319
- .rte-preview-editor-header h2 {
2320
- margin: 0;
2321
- font-size: 18px;
2322
- font-weight: 600;
2323
- color: #1a1a1a;
2324
- }
2325
-
2326
- .rte-preview-editor-header-actions {
2327
- display: flex;
2328
- gap: 8px;
2329
- }
2330
-
2331
- .rte-preview-editor-close-btn {
2332
- background: none;
2333
- border: none;
2334
- cursor: pointer;
2335
- padding: 4px;
2336
- border-radius: 4px;
2337
- color: #666;
2338
- font-size: 16px;
2339
- line-height: 1;
2340
- transition: all 0.2s ease;
2341
- }
2342
-
2343
- .rte-preview-editor-close-btn:hover {
2344
- background: #e1e5e9;
2345
- color: #1a1a1a;
2346
- }
2347
-
2348
- .rte-preview-editor-body {
2349
- flex: 1;
2350
- overflow: auto;
2351
- display: flex;
2352
- flex-direction: column;
2353
- padding: 25px;
2354
- }
2355
-
2356
- .rte-preview-editor-content {
2357
- flex: 1;
2358
- display: flex;
2359
- flex-direction: column;
2360
- }
2361
-
2362
- .rte-preview-editor-light-editor {
2363
- flex: 1;
2364
- overflow: auto;
2365
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
2366
- font-size: 16px;
2367
- line-height: 1.6;
2368
- color: #1a1a1a;
2369
- padding: 20px;
2370
- background: #fafafa;
2371
- border: 1px solid #e1e5e9;
2372
- border-radius: 4px;
2373
- min-height: 400px;
2374
- }
2375
-
2376
- .rte-preview-editor-light-editor h1,
2377
- .rte-preview-editor-light-editor h2,
2378
- .rte-preview-editor-light-editor h3,
2379
- .rte-preview-editor-light-editor h4,
2380
- .rte-preview-editor-light-editor h5,
2381
- .rte-preview-editor-light-editor h6 {
2382
- margin-top: 1.5em;
2383
- margin-bottom: 0.5em;
2384
- font-weight: 600;
2385
- }
2386
-
2387
- .rte-preview-editor-light-editor h1 {
2388
- font-size: 2em;
2389
- }
2390
-
2391
- .rte-preview-editor-light-editor h2 {
2392
- font-size: 1.5em;
2393
- }
2394
-
2395
- .rte-preview-editor-light-editor h3 {
2396
- font-size: 1.25em;
2397
- }
2398
-
2399
- .rte-preview-editor-light-editor p {
2400
- margin: 1em 0;
2401
- }
2402
-
2403
- .rte-preview-editor-light-editor ul,
2404
- .rte-preview-editor-light-editor ol {
2405
- padding-left: 2em;
2406
- margin: 1em 0;
2407
- }
2408
-
2409
- .rte-preview-editor-light-editor li {
2410
- margin: 0.5em 0;
2411
- }
2412
-
2413
- .rte-preview-editor-light-editor table {
2414
- border-collapse: collapse;
2415
- width: 100%;
2416
- margin: 1em 0;
2417
- }
2418
-
2419
- .rte-preview-editor-light-editor table td,
2420
- .rte-preview-editor-light-editor table th {
2421
- border: 1px solid #ddd;
2422
- padding: 0.5em;
2423
- }
2424
-
2425
- .rte-preview-editor-light-editor table th {
2426
- background: #f5f5f5;
2427
- font-weight: 600;
2428
- }
2429
-
2430
- .rte-preview-editor-light-editor blockquote {
2431
- border-left: 4px solid #ddd;
2432
- margin: 1em 0;
2433
- padding-left: 1em;
2434
- color: #666;
2435
- }
2436
-
2437
- .rte-preview-editor-light-editor code {
2438
- background: #f5f5f5;
2439
- padding: 2px 6px;
2440
- border-radius: 3px;
2441
- font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
2442
- font-size: 0.9em;
2443
- }
2444
-
2445
- .rte-preview-editor-light-editor pre {
2446
- background: #f5f5f5;
2447
- padding: 1em;
2448
- border-radius: 4px;
2449
- overflow-x: auto;
2450
- margin: 1em 0;
2451
- }
2452
-
2453
- .rte-preview-editor-light-editor pre code {
2454
- background: none;
2455
- padding: 0;
2456
- }
2457
-
2458
- .rte-preview-editor-light-editor img {
2459
- max-width: 100%;
2460
- height: auto;
2461
- }
2462
-
2463
- .rte-preview-editor-light-editor a {
2464
- color: #007acc;
2465
- text-decoration: underline;
2466
- }
2467
-
2468
- .rte-preview-editor-light-editor a:hover {
2469
- color: #0056b3;
2470
- }
2471
-
2472
- /* Responsive design */
2473
- @media (max-width: 768px) {
2474
- .rte-preview-editor-overlay {
2475
- padding: 10px;
2476
- }
2477
-
2478
- .rte-preview-editor-modal {
2479
- max-height: 95vh;
2480
- }
2481
-
2482
- .rte-preview-editor-header {
2483
- padding: 12px 16px;
2484
- }
2485
-
2486
- .rte-preview-editor-body {
2487
- padding: 16px;
2488
- }
2489
-
2490
- .rte-preview-editor-light-editor {
2491
- padding: 12px;
2492
- font-size: 14px;
2493
- }
2494
- }
2495
- `,document.head.appendChild(e)},ds=()=>{const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},us=()=>{const n=ds();if(!n)return"";const e=n.cloneNode(!0);return[".rte-floating-toolbar",".rte-selection-marker",".rte-toolbar",".rte-resize-handle","[data-rte-internal]"].forEach(o=>{e.querySelectorAll(o).forEach(r=>r.remove())}),e.innerHTML},ps=n=>{const e=document.createElement("div");return e.innerHTML=n,e.querySelectorAll('script, iframe[src^="javascript:"], object, embed, form[action^="javascript:"]').forEach(r=>r.remove()),e.querySelectorAll("*").forEach(r=>{Array.from(r.attributes).forEach(i=>{i.name.startsWith("on")&&r.removeAttribute(i.name),(i.name==="href"||i.name==="src")&&i.value.startsWith("javascript:")&&r.removeAttribute(i.name)})}),e.innerHTML},ms=()=>{if(typeof window>"u"||yn)return;yn=!0,cs();const n=us(),e=ps(n),t=document.createElement("div");t.className="rte-preview-editor-overlay",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-labelledby","preview-editor-title");const o=document.createElement("div");o.className="rte-preview-editor-modal";const r=document.createElement("div");r.className="rte-preview-editor-header",r.innerHTML=`
2496
- <h2 id="preview-editor-title">Preview Editor</h2>
2497
- <div class="rte-preview-editor-header-actions">
2498
- <button class="rte-preview-editor-close-btn" aria-label="Close preview editor">
2499
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
2500
- <line x1="18" y1="6" x2="6" y2="18" />
2501
- <line x1="6" y1="6" x2="18" y2="18" />
2502
- </svg>
2503
- </button>
2504
- </div>
2505
- `;const i=document.createElement("div");i.className="rte-preview-editor-body";const a=document.createElement("div");a.className="rte-preview-editor-content";const l=document.createElement("div");l.className="rte-preview-editor-light-editor",l.innerHTML=e,a.appendChild(l),i.appendChild(a),o.appendChild(r),o.appendChild(i),t.appendChild(o);const c=()=>{t.parentNode&&t.parentNode.removeChild(t),yn=!1,document.removeEventListener("keydown",s)},s=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),c())},d=r.querySelector(".rte-preview-editor-close-btn");d&&d.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),c()}),t.addEventListener("click",p=>{p.target===t&&c()}),document.addEventListener("keydown",s),document.body.appendChild(t)},gs=()=>({name:"preview",toolbar:[{label:"Preview",command:"togglePreview",icon:'<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path id="XMLID_1239_" d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'}],commands:{togglePreview:()=>(ms(),!0)},keymap:{}}),vn=new WeakMap,ri="rte-fullscreen-active",$t=n=>(vn.has(n)||vn.set(n,{isFullscreen:!1,fullscreenButton:null}),vn.get(n)),hs=(n,e)=>{if(n.classList.add(ri),n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.right="0",n.style.bottom="0",n.style.width="100%",n.style.height="100%",n.style.maxWidth="100%",n.style.maxHeight="100%",n.style.borderRadius="0",n.style.zIndex="9999",n.style.margin="0",n.style.padding="0",n.style.boxShadow="none",n.style.display="flex",n.style.flexDirection="column",n.style.background="white",document.body.style.overflow="hidden",document.body.classList.add("fullscreen-active"),e.fullscreenButton){e.fullscreenButton.setAttribute("data-active","true"),e.fullscreenButton.style.backgroundColor="var(--rte-color-primary, #007bff)",e.fullscreenButton.style.color="white";const t=e.fullscreenButton.querySelector("svg");t&&(t.style.fill="white",t.style.stroke="white")}},qn=(n,e)=>{if(n.classList.remove(ri),n.style.position="",n.style.top="",n.style.left="",n.style.right="",n.style.bottom="",n.style.width="",n.style.height="",n.style.maxWidth="",n.style.maxHeight="",n.style.borderRadius="",n.style.zIndex="",n.style.margin="",n.style.padding="",n.style.boxShadow="",n.style.display="",n.style.flexDirection="",n.style.background="",document.body.style.overflow="",document.body.classList.remove("fullscreen-active"),e.fullscreenButton){e.fullscreenButton.setAttribute("data-active","false"),e.fullscreenButton.style.backgroundColor="",e.fullscreenButton.style.color="";const t=e.fullscreenButton.querySelector("svg");t&&(t.style.fill="",t.style.stroke="")}},fs=n=>{try{if(!n){const t=document.activeElement;t&&t.closest("[data-editora-editor]")&&(n=t.closest("[data-editora-editor]"))}if(n||(n=document.querySelector("[data-editora-editor]")),!n)return console.warn("Editor element not found"),!1;const e=$t(n);return e.fullscreenButton||(e.fullscreenButton=n.querySelector('[data-command="toggleFullscreen"]')),e.isFullscreen=!e.isFullscreen,e.isFullscreen?hs(n,e):qn(n,e),!0}catch(e){return console.error("Fullscreen toggle failed:",e),!1}},ii=n=>{if(!n){document.querySelectorAll("[data-editora-editor]").forEach(t=>{const o=t,r=$t(o);r.isFullscreen&&(r.isFullscreen=!1,qn(o,r))});return}const e=$t(n);e.isFullscreen&&(e.isFullscreen=!1,qn(n,e))},bs=n=>$t(n).isFullscreen,hr=()=>{const n=e=>{e.key==="Escape"&&ii()};return typeof window<"u"&&window.addEventListener("keydown",n),()=>{typeof window<"u"&&window.removeEventListener("keydown",n)}};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",hr):hr());const xs=()=>({name:"fullscreen",toolbar:[{label:"Fullscreen",command:"toggleFullscreen",type:"button",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>'}],commands:{toggleFullscreen:fs},keymap:{Escape:()=>{const n=document.querySelectorAll("[data-editora-editor]");for(const e of n)if(bs(e))return ii(e),!0;return!1}}}),ys=()=>`
2506
- * {
2507
- margin: 0;
2508
- padding: 0;
2509
- box-sizing: border-box;
2510
- }
2511
-
2512
- html, body {
2513
- background: white;
2514
- color: black;
2515
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
2516
- line-height: 1.5;
2517
- }
2518
-
2519
- .rte-print {
2520
- background: white;
2521
- color: black;
2522
- }
2523
-
2524
- /* Page break handling */
2525
- .rte-page-break {
2526
- page-break-after: always;
2527
- display: block;
2528
- height: 0;
2529
- margin: 0;
2530
- border: none;
2531
- background: none;
2532
- }
2533
-
2534
- .rte-page-break::before {
2535
- display: none;
2536
- }
2537
-
2538
- /* Code block formatting */
2539
- .rte-code-block,
2540
- pre {
2541
- background: #f5f5f5;
2542
- border: 1px solid #ddd;
2543
- border-radius: 4px;
2544
- padding: 12px;
2545
- margin: 12px 0;
2546
- overflow-x: auto;
2547
- page-break-inside: avoid;
2548
- }
2549
-
2550
- .rte-code-block code,
2551
- pre code {
2552
- font-family: 'Courier New', Courier, monospace;
2553
- font-size: 12px;
2554
- line-height: 1.4;
2555
- white-space: pre-wrap;
2556
- word-break: break-word;
2557
- }
2558
-
2559
- /* Footnotes */
2560
- .rte-footnotes {
2561
- border-top: 1px solid #ccc;
2562
- margin-top: 40px;
2563
- padding-top: 12px;
2564
- page-break-inside: avoid;
2565
- }
2566
-
2567
- .rte-footnotes ol {
2568
- margin-left: 20px;
2569
- }
2570
-
2571
- .rte-footnotes li {
2572
- margin: 8px 0;
2573
- font-size: 0.9em;
2574
- }
2575
-
2576
- .rte-footnote-ref {
2577
- vertical-align: super;
2578
- font-size: 0.8em;
2579
- }
2580
-
2581
- .rte-footnote-backref {
2582
- margin-left: 4px;
2583
- text-decoration: none;
2584
- color: #666;
2585
- }
2586
-
2587
- /* Anchors - preserve IDs but hide visual markers */
2588
- .rte-anchor {
2589
- display: none;
2590
- }
2591
-
2592
- /* Lists and tables */
2593
- ul, ol {
2594
- margin: 12px 0;
2595
- padding-left: 40px;
2596
- }
2597
-
2598
- li {
2599
- margin: 4px 0;
2600
- }
2601
-
2602
- table {
2603
- border-collapse: collapse;
2604
- width: 100%;
2605
- margin: 12px 0;
2606
- page-break-inside: avoid;
2607
- }
2608
-
2609
- th, td {
2610
- border: 1px solid #ddd;
2611
- padding: 8px;
2612
- text-align: left;
2613
- }
2614
-
2615
- th {
2616
- background: #f5f5f5;
2617
- font-weight: bold;
2618
- }
2619
-
2620
- /* Heading hierarchy */
2621
- h1 {
2622
- font-size: 2em;
2623
- margin: 20px 0 12px;
2624
- page-break-after: avoid;
2625
- }
2626
-
2627
- h2 {
2628
- font-size: 1.5em;
2629
- margin: 16px 0 10px;
2630
- page-break-after: avoid;
2631
- }
2632
-
2633
- h3 {
2634
- font-size: 1.25em;
2635
- margin: 14px 0 8px;
2636
- page-break-after: avoid;
2637
- }
2638
-
2639
- h4 {
2640
- font-size: 1.1em;
2641
- margin: 12px 0 6px;
2642
- page-break-after: avoid;
2643
- }
2644
-
2645
- h5 {
2646
- font-size: 1em;
2647
- margin: 12px 0 6px;
2648
- page-break-after: avoid;
2649
- }
2650
-
2651
- h6 {
2652
- font-size: 0.9em;
2653
- margin: 12px 0 6px;
2654
- page-break-after: avoid;
2655
- }
2656
-
2657
- p {
2658
- margin: 8px 0;
2659
- }
2660
-
2661
- /* Emphasis and strong */
2662
- strong, b {
2663
- font-weight: bold;
2664
- }
2665
-
2666
- em, i {
2667
- font-style: italic;
2668
- }
2669
-
2670
- u {
2671
- text-decoration: underline;
2672
- }
2673
-
2674
- /* Block elements */
2675
- blockquote {
2676
- border-left: 4px solid #ddd;
2677
- margin: 12px 0;
2678
- padding-left: 16px;
2679
- color: #666;
2680
- }
2681
-
2682
- hr {
2683
- border: none;
2684
- border-top: 1px solid #ddd;
2685
- margin: 16px 0;
2686
- page-break-after: avoid;
2687
- }
2688
-
2689
- /* Images */
2690
- img {
2691
- max-width: 100%;
2692
- height: auto;
2693
- page-break-inside: avoid;
2694
- }
2695
-
2696
- /* Links */
2697
- a {
2698
- color: #0066cc;
2699
- text-decoration: underline;
2700
- }
2701
-
2702
- /* Merge tags */
2703
- .rte-merge-tag {
2704
- background-color: #e3f2fd;
2705
- border: 1px solid #bbdefb;
2706
- border-radius: 3px;
2707
- padding: 2px 6px;
2708
- margin: 0 2px;
2709
- display: inline-block;
2710
- white-space: nowrap;
2711
- font-weight: 500;
2712
- color: #1976d2;
2713
- font-size: 0.9em;
2714
- }
2715
-
2716
- /* Hide selection */
2717
- ::selection {
2718
- background: transparent;
2719
- }
2720
-
2721
- /* Print-specific rules */
2722
- @media print {
2723
- body {
2724
- margin: 0;
2725
- padding: 0;
2726
- }
2727
-
2728
- .rte-page-break {
2729
- page-break-after: always;
2730
- }
2731
-
2732
- h1, h2, h3, h4, h5, h6 {
2733
- page-break-after: avoid;
2734
- page-break-inside: avoid;
2735
- }
2736
-
2737
- table, figure, img, pre {
2738
- page-break-inside: avoid;
2739
- }
2740
-
2741
- ul, ol, blockquote {
2742
- page-break-inside: avoid;
2743
- }
2744
- }
2745
- `,fr=()=>{if(typeof window>"u")return!1;const e=(()=>{const l=window.getSelection();if(l&&l.rangeCount>0){let s=l.getRangeAt(0).startContainer;for(;s&&s!==document.body;){if(s.nodeType===Node.ELEMENT_NODE){const d=s;if(d.getAttribute("contenteditable")==="true")return d}s=s.parentNode}}const c=document.activeElement;if(c){if(c.getAttribute("contenteditable")==="true")return c;const s=c.closest('[contenteditable="true"]');if(s)return s}return document.querySelector('[contenteditable="true"]')})();if(!e)return console.warn("Editor content not found"),!1;const t=e.cloneNode(!0),o=document.createElement("article");o.className="rte-document rte-print",o.appendChild(t);const r=`
2746
- <!DOCTYPE html>
2747
- <html>
2748
- <head>
2749
- <meta charset="UTF-8">
2750
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
2751
- <title>Print Document</title>
2752
- <style>${ys()}</style>
2753
- </head>
2754
- <body>
2755
- ${o.outerHTML}
2756
- </body>
2757
- </html>
2758
- `,i=document.createElement("iframe");i.style.position="absolute",i.style.left="-9999px",i.style.top="-9999px",i.style.width="0",i.style.height="0",document.body.appendChild(i);const a=i.contentDocument||i.contentWindow?.document;return a?(a.open(),a.write(r),a.close(),setTimeout(()=>{i.contentWindow&&(i.contentWindow.print(),setTimeout(()=>{document.body.removeChild(i)},100))},250),!0):(console.error("Could not access print frame document"),document.body.removeChild(i),!1)},vs=()=>({name:"print",toolbar:[{label:"Print",command:"print",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M7 18H6.2C5.0799 18 4.51984 18 4.09202 17.782C3.71569 17.5903 3.40973 17.2843 3.21799 16.908C3 16.4802 3 15.9201 3 14.8V10.2C3 9.0799 3 8.51984 3.21799 8.09202C3.40973 7.71569 3.71569 7.40973 4.09202 7.21799C4.51984 7 5.0799 7 6.2 7H7M17 18H17.8C18.9201 18 19.4802 18 19.908 17.782C20.2843 17.5903 20.5903 17.2843 20.782 16.908C21 16.4802 21 15.9201 21 14.8V10.2C21 9.07989 21 8.51984 20.782 8.09202C20.5903 7.71569 20.2843 7.40973 19.908 7.21799C19.4802 7 18.9201 7 17.8 7H17M7 11H7.01M17 7V5.4V4.6C17 4.03995 17 3.75992 16.891 3.54601C16.7951 3.35785 16.6422 3.20487 16.454 3.10899C16.2401 3 15.9601 3 15.4 3H8.6C8.03995 3 7.75992 3 7.54601 3.10899C7.35785 3.20487 7.20487 3.35785 7.10899 3.54601C7 3.75992 7 4.03995 7 4.6V5.4V7M17 7H7M8.6 21H15.4C15.9601 21 16.2401 21 16.454 20.891C16.6422 20.7951 16.7951 20.6422 16.891 20.454C17 20.2401 17 19.9601 17 19.4V16.6C17 16.0399 17 15.7599 16.891 15.546C16.7951 15.3578 16.6422 15.2049 16.454 15.109C16.2401 15 15.9601 15 15.4 15H8.6C8.03995 15 7.75992 15 7.54601 15.109C7.35785 15.2049 7.20487 15.3578 7.10899 15.546C7 15.7599 7 16.0399 7 16.6V19.4C7 19.9601 7 20.2401 7.10899 20.454C7.20487 20.6422 7.35785 20.7951 7.54601 20.891C7.75992 21 8.03995 21 8.6 21Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-p"}],commands:{print:fr},keymap:{"Mod-p":()=>(fr(),!0)}});let wt=null;const ws=()=>{wt||(wt=document.createElement("style"),wt.textContent=`
2759
- .rte-page-break {
2760
- display: block;
2761
- position: relative;
2762
- height: 12px;
2763
- margin: 8px 0;
2764
- background: linear-gradient(90deg, #ccc 0%, transparent 100%);
2765
- border-top: 2px dashed #999;
2766
- border-bottom: none;
2767
- cursor: pointer;
2768
- user-select: none;
2769
- transition: all 0.2s ease;
2770
- outline: none;
2771
- -webkit-user-select: none;
2772
- -moz-user-select: none;
2773
- -ms-user-select: none;
2774
- }
2775
-
2776
- .rte-page-break::before {
2777
- content: '⎙ PAGE BREAK';
2778
- position: absolute;
2779
- top: -12px;
2780
- left: 0;
2781
- font-size: 10px;
2782
- font-weight: bold;
2783
- color: #666;
2784
- background: white;
2785
- padding: 2px 6px;
2786
- letter-spacing: 0.5px;
2787
- opacity: 0.7;
2788
- pointer-events: none;
2789
- }
2790
-
2791
- .rte-page-break:hover {
2792
- background: linear-gradient(90deg, #999 0%, transparent 100%);
2793
- border-top-color: #666;
2794
- box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
2795
- }
2796
-
2797
- .rte-page-break:hover::before {
2798
- opacity: 1;
2799
- color: #333;
2800
- }
2801
-
2802
- .rte-page-break:focus,
2803
- .rte-page-break:focus-visible,
2804
- .rte-page-break-selected {
2805
- outline: 2px solid #0066cc;
2806
- outline-offset: -2px;
2807
- border-top-color: #0066cc;
2808
- background: linear-gradient(90deg, #0066cc 0%, transparent 100%);
2809
- }
2810
-
2811
- .rte-page-break * {
2812
- user-select: none;
2813
- }
2814
-
2815
- @media print {
2816
- .rte-page-break {
2817
- display: block;
2818
- height: 0;
2819
- margin: 0;
2820
- background: none;
2821
- border: none;
2822
- page-break-after: always;
2823
- }
2824
-
2825
- .rte-page-break::before {
2826
- display: none;
2827
- }
2828
- }
2829
- `,document.head.appendChild(wt))},Cs=n=>{const e=["SPAN","A","STRONG","EM","B","I","U","SUP","SUB","CODE"];let t=n.nodeType===Node.TEXT_NODE?n.parentElement:n;for(;t&&!t.hasAttribute("contenteditable");){if(e.includes(t.tagName))return!0;t=t.parentElement}return!1},ks=n=>{const e=["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"];let t=n;for(;t;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(e.includes(o.tagName))return o}t=t.parentNode}return null},Es=n=>{let e=n.nextElementSibling;for(;e&&e.classList.contains("rte-page-break");)e.remove(),e=n.nextElementSibling;let t=n.previousElementSibling;for(;t&&t.classList.contains("rte-page-break");){const o=t;t=t.previousElementSibling,o.remove()}},Ss=()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return!1;const t=n.getRangeAt(0).commonAncestorContainer;if(Cs(t))return console.warn("Page breaks cannot be inserted in inline contexts"),!1;const o=ks(t);if(!o)return console.warn("No block element found for page break insertion"),!1;const r=document.createElement("div");r.className="rte-page-break",r.setAttribute("data-page-break","true"),r.setAttribute("data-type","page-break"),r.setAttribute("contenteditable","false"),r.setAttribute("tabindex","0"),r.setAttribute("role","separator"),r.setAttribute("aria-label","Page break"),r.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),r.focus();const c=document.createRange();c.selectNode(r),n.removeAllRanges(),n.addRange(c)}),r.addEventListener("keydown",l=>{if(l.key==="Delete"||l.key==="Backspace"){l.preventDefault();const c=r.nextElementSibling||r.previousElementSibling;if(r.remove(),c){const s=document.createRange();s.selectNode(c),n.removeAllRanges(),n.addRange(s)}}else if(l.key==="ArrowDown"||l.key==="ArrowRight"){l.preventDefault();const c=r.nextElementSibling;if(c){const s=document.createRange();s.setStart(c,0),s.collapse(!0),n.removeAllRanges(),n.addRange(s)}}else if(l.key==="ArrowUp"||l.key==="ArrowLeft"){l.preventDefault();const c=r.previousElementSibling;if(c){const s=document.createRange();s.selectNodeContents(c),s.collapse(!1),n.removeAllRanges(),n.addRange(s)}}}),o.parentNode?.insertBefore(r,o.nextSibling),Es(r);const i=document.createRange(),a=r.nextSibling;if(a)i.setStart(a,0);else{const l=document.createElement("p");l.innerHTML="<br>",r.parentNode?.insertBefore(l,r.nextSibling),i.setStart(l,0)}return i.collapse(!0),n.removeAllRanges(),n.addRange(i),!0},Ts=()=>(ws(),{name:"pageBreak",toolbar:[{label:"Page Break",command:"insertPageBreak",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path d="M1,6 L3,6 C3.55228475,6 4,6.44771525 4,7 C4,7.55228475 3.55228475,8 3,8 L1,8 C0.44771525,8 0,7.55228475 0,7 C0,6.44771525 0.44771525,6 1,6 Z M11,6 L13,6 C13.5522847,6 14,6.44771525 14,7 C14,7.55228475 13.5522847,8 13,8 L11,8 C10.4477153,8 10,7.55228475 10,7 C10,6.44771525 10.4477153,6 11,6 Z M6,6 L8,6 C8.55228475,6 9,6.44771525 9,7 C9,7.55228475 8.55228475,8 8,8 L6,8 C5.44771525,8 5,7.55228475 5,7 C5,6.44771525 5.44771525,6 6,6 Z M0,1 C0,0.44771525 0.44771525,-2.26485497e-13 1,-2.26485497e-13 C1.55228475,-2.26485497e-13 2,0.44771525 2,1 L2,3.0142458 L12,3.0142458 L12,1 C12,0.44771525 12.4477153,-2.26485497e-13 13,-2.26485497e-13 C13.5522847,-2.26485497e-13 14,0.44771525 14,1 L14,3.0142458 C14,4.1188153 13.1045695,5.0142458 12,5.0142458 L2,5.0142458 C0.8954305,5.0142458 0,4.1188153 0,3.0142458 L0,1 Z M0,13.0142458 L0,11 C0,9.8954305 0.8954305,9 2,9 L12,9 C13.1045695,9 14,9.8954305 14,11 L14,13.0142458 C14,13.5665305 13.5522847,14.0142458 13,14.0142458 C12.4477153,14.0142458 12,13.5665305 12,13.0142458 L12,11 L2,11 L2,13.0142458 C2,13.5665305 1.55228475,14.0142458 1,14.0142458 C0.44771525,14.0142458 0,13.5665305 0,13.0142458 Z"></path></g></svg>',shortcut:"Mod-Enter"}],commands:{insertPageBreak:Ss},keymap:{"Mod-Enter":"insertPageBreak"}}),Ls=()=>({name:"footnote",toolbar:[{label:"Footnote",command:"insertFootnote",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><rect x="3" y="4" width="14" height="2" rx="1" /><rect x="3" y="8" width="18" height="2" rx="1" /><rect x="3" y="12" width="16" height="2" rx="1" /><rect x="3" y="16" width="10" height="1.5" rx="0.75" /><text x="19" y="11" font-size="9" font-weight="600" fill="currentColor" font-family="system-ui, sans-serif">1</text></svg>',type:"button"}],commands:{insertFootnote:()=>(Ns(),null)},keymap:{}}),As=new Map;function io(){const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')}function Ms(){const n=io();if(!n)throw new Error("Contenteditable element not found");let e=n.querySelector(".rte-footnotes");if(!e){e=document.createElement("section"),e.className="rte-footnotes",e.setAttribute("data-type","footnotes"),e.setAttribute("contenteditable","true");const t=document.createElement("ol");e.appendChild(t),n.appendChild(e)}return e}const Ns=(n="")=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0),o=`fn-${Date.now()}`,r=Rs(),i=document.createElement("sup");i.className="rte-footnote-ref",i.setAttribute("data-footnote-id",o),i.setAttribute("data-number",r.toString()),i.textContent=r.toString(),i.style.cursor="pointer";try{t.insertNode(i),t.setStartAfter(i),t.collapse(!0),e.removeAllRanges(),e.addRange(t)}catch(p){console.error("Error inserting footnote reference:",p);return}const l=Ms().querySelector("ol"),c=document.createElement("li");c.id=o,c.className="rte-footnote-item",c.setAttribute("data-type","footnote"),c.setAttribute("data-number",r.toString());const s=document.createElement("div");s.className="rte-footnote-content",s.setAttribute("contenteditable","true"),s.textContent=n||`Footnote ${r}`,c.appendChild(s);const d=document.createElement("a");d.className="rte-footnote-backref",d.href=`#ref-${o}`,d.setAttribute("aria-label",`Back to reference ${r}`),d.textContent="↩",c.appendChild(d),l?.appendChild(c),As.set(o,{id:o,number:r,content:n}),jn()};function Rs(){const e=io()?.querySelector(".rte-footnotes");return e?e.querySelectorAll('li[data-type="footnote"]').length+1:1}function jn(){const n=io();n&&(n.addEventListener("click",e=>{const t=e.target;if(t.classList.contains("rte-footnote-ref")){const o=t.getAttribute("data-footnote-id");if(o){const r=document.getElementById(o);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.style.backgroundColor="#fff3cd",setTimeout(()=>{r.style.backgroundColor=""},1500))}}}),n.addEventListener("click",e=>{const t=e.target;if(t.classList.contains("rte-footnote-backref")){e.preventDefault();const o=t.closest("li")?.id;if(o){const r=n.querySelector(`.rte-footnote-ref[data-footnote-id="${o}"]`);r&&(r.scrollIntoView({behavior:"smooth",block:"center"}),r.style.backgroundColor="#fff3cd",setTimeout(()=>{r.style.backgroundColor=""},1500))}}}))}typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",jn):jn());const Vn=()=>{const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},zs=[{value:"javascript",label:"JavaScript"},{value:"typescript",label:"TypeScript"},{value:"python",label:"Python"},{value:"java",label:"Java"},{value:"csharp",label:"C#"},{value:"cpp",label:"C++"},{value:"c",label:"C"},{value:"php",label:"PHP"},{value:"ruby",label:"Ruby"},{value:"go",label:"Go"},{value:"rust",label:"Rust"},{value:"swift",label:"Swift"},{value:"kotlin",label:"Kotlin"},{value:"html",label:"HTML"},{value:"css",label:"CSS"},{value:"scss",label:"SCSS"},{value:"json",label:"JSON"},{value:"xml",label:"XML"},{value:"yaml",label:"YAML"},{value:"markdown",label:"Markdown"},{value:"sql",label:"SQL"},{value:"bash",label:"Bash"},{value:"shell",label:"Shell"},{value:"plaintext",label:"Plain Text"}],ai=new Map;function li(n,e,t,o){const r=!!e,i=o||"javascript",a=t||"",l=document.createElement("div");l.className="rte-code-sample-overlay",l.style.cssText=`
2830
- position: fixed;
2831
- top: 0;
2832
- left: 0;
2833
- right: 0;
2834
- bottom: 0;
2835
- background: rgba(0, 0, 0, 0.5);
2836
- display: flex;
2837
- align-items: center;
2838
- justify-content: center;
2839
- z-index: 10000;
2840
- animation: fadeIn 160ms ease-out;
2841
- `;const c=document.createElement("div");c.className="rte-code-sample-dialog",c.style.cssText=`
2842
- background: #fff;
2843
- border-radius: 8px;
2844
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
2845
- max-width: 700px;
2846
- width: 90vw;
2847
- max-height: 80vh;
2848
- display: flex;
2849
- flex-direction: column;
2850
- animation: slideUp 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
2851
- `;const s=document.createElement("div");s.style.cssText=`
2852
- padding: 20px;
2853
- border-bottom: 1px solid #e0e0e0;
2854
- display: flex;
2855
- justify-content: space-between;
2856
- align-items: center;
2857
- `,s.innerHTML=`
2858
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: #333;">
2859
- ${r?"Edit Code Sample":"Insert Code Sample"}
2860
- </h2>
2861
- <button class="rte-code-close-btn" style="background: none; border: none; font-size: 28px; color: #999; cursor: pointer; padding: 0; width: 32px; height: 32px;">×</button>
2862
- `;const d=document.createElement("div");d.style.cssText=`
2863
- flex: 1;
2864
- overflow-y: auto;
2865
- padding: 20px;
2866
- `;const p=document.createElement("div");p.style.marginBottom="20px",p.innerHTML=`
2867
- <label style="display: block; margin-bottom: 8px; font-weight: 500; color: #333; font-size: 14px;">Language</label>
2868
- <select class="rte-code-language" style="
2869
- width: 100%;
2870
- padding: 10px 12px;
2871
- border: 1px solid #ddd;
2872
- border-radius: 4px;
2873
- font-size: 14px;
2874
- background-color: #fff;
2875
- cursor: pointer;
2876
- ">
2877
- ${zs.map(L=>`
2878
- <option value="${L.value}" ${L.value===i?"selected":""}>
2879
- ${L.label}
2880
- </option>
2881
- `).join("")}
2882
- </select>
2883
- `;const g=document.createElement("div");g.style.marginBottom="20px",g.innerHTML=`
2884
- <label style="display: block; margin-bottom: 8px; font-weight: 500; color: #333; font-size: 14px;">Code</label>
2885
- <textarea class="rte-code-textarea" spellcheck="false" placeholder="Paste or type your code here..." style="
2886
- width: 100%;
2887
- padding: 12px;
2888
- border: 1px solid #ddd;
2889
- border-radius: 4px;
2890
- font-family: 'Courier New', Courier, monospace;
2891
- font-size: 13px;
2892
- line-height: 1.5;
2893
- resize: vertical;
2894
- min-height: 250px;
2895
- max-height: 400px;
2896
- background-color: #f9f9f9;
2897
- color: #333;
2898
- box-sizing: border-box;
2899
- ">${a}</textarea>
2900
- <div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
2901
- `;const m=document.createElement("div");m.style.cssText="color: #666; font-size: 12px; margin-top: 10px;",m.innerHTML="💡 Tip: Press Ctrl+Enter (or Cmd+Enter on Mac) to save, or Escape to cancel",d.appendChild(p),d.appendChild(g),d.appendChild(m);const b=document.createElement("div");b.style.cssText=`
2902
- padding: 20px;
2903
- border-top: 1px solid #e0e0e0;
2904
- display: flex;
2905
- justify-content: flex-end;
2906
- gap: 12px;
2907
- `,b.innerHTML=`
2908
- <button class="rte-code-cancel-btn" style="
2909
- padding: 10px 16px;
2910
- border: none;
2911
- border-radius: 4px;
2912
- font-size: 14px;
2913
- font-weight: 500;
2914
- cursor: pointer;
2915
- background: #e5e7eb;
2916
- color: #333;
2917
- ">Cancel</button>
2918
- <button class="rte-code-save-btn" style="
2919
- padding: 10px 16px;
2920
- border: none;
2921
- border-radius: 4px;
2922
- font-size: 14px;
2923
- font-weight: 500;
2924
- cursor: pointer;
2925
- background: #2563eb;
2926
- color: #fff;
2927
- ">${r?"Update Code Sample":"Insert Code Sample"}</button>
2928
- `,c.appendChild(s),c.appendChild(d),c.appendChild(b),l.appendChild(c);const x=p.querySelector(".rte-code-language"),C=g.querySelector(".rte-code-textarea"),k=g.querySelector(".rte-code-error"),y=s.querySelector(".rte-code-close-btn"),w=b.querySelector(".rte-code-cancel-btn"),S=b.querySelector(".rte-code-save-btn"),E=()=>{l.remove()},f=()=>{const L=C.value.trim();if(!L){k.textContent="⚠ Code cannot be empty",k.style.display="block";return}const ve=x.value;n(L,ve),E()};if(y.onclick=E,w.onclick=E,S.onclick=f,C.addEventListener("keydown",L=>{(L.ctrlKey||L.metaKey)&&L.key==="Enter"&&(L.preventDefault(),f()),L.key==="Escape"&&E()}),C.addEventListener("input",()=>{k.style.display="none"}),l.addEventListener("click",L=>{L.target===l&&E()}),!document.getElementById("rte-code-sample-animations")){const L=document.createElement("style");L.id="rte-code-sample-animations",L.textContent=`
2929
- @keyframes fadeIn {
2930
- from { opacity: 0; }
2931
- to { opacity: 1; }
2932
- }
2933
- @keyframes slideUp {
2934
- from { transform: translateY(20px); opacity: 0; }
2935
- to { transform: translateY(0); opacity: 1; }
2936
- }
2937
- `,document.head.appendChild(L)}return document.body.appendChild(l),setTimeout(()=>C.focus(),100),l}function Is(){if(!Vn())return;let e=null;const t=window.getSelection();t&&t.rangeCount>0&&(e=t.getRangeAt(0).cloneRange()),li((o,r)=>{const i=window.getSelection();if(e&&(i?.removeAllRanges(),i?.addRange(e)),!i||i.rangeCount===0)return;const a=Vn();if(!a)return;const l=i.anchorNode;if(!l||!a.contains(l))return;const c=i.getRangeAt(0),s=`code-block-${Date.now()}`,d=document.createElement("pre");d.className="rte-code-block",d.id=s,d.setAttribute("data-type","code-block"),d.setAttribute("data-lang",r),d.setAttribute("data-code-id",s),d.setAttribute("contenteditable","false"),d.style.cssText=`
2938
- display: block;
2939
- position: relative;
2940
- background: #f5f5f5;
2941
- border: 1px solid #e0e0e0;
2942
- border-radius: 6px;
2943
- padding: 12px;
2944
- margin: 12px 0;
2945
- overflow-x: auto;
2946
- font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
2947
- font-size: 13px;
2948
- line-height: 1.5;
2949
- color: #333;
2950
- user-select: text;
2951
- cursor: default;
2952
- `;const p=document.createElement("code");p.className=`language-${r}`,p.style.cssText=`
2953
- font-family: inherit;
2954
- font-size: inherit;
2955
- line-height: inherit;
2956
- color: inherit;
2957
- white-space: pre;
2958
- word-break: normal;
2959
- display: block;
2960
- `,p.textContent=o;const g=document.createElement("span");g.style.cssText=`
2961
- position: absolute;
2962
- top: 0;
2963
- right: 0;
2964
- background: #333;
2965
- color: #fff;
2966
- padding: 2px 8px;
2967
- font-size: 11px;
2968
- font-weight: bold;
2969
- border-radius: 0 6px 0 4px;
2970
- text-transform: uppercase;
2971
- letter-spacing: 0.5px;
2972
- pointer-events: none;
2973
- `,g.textContent=r;const m=document.createElement("button");m.className="rte-code-copy",m.textContent="Copy",m.style.cssText=`
2974
- position: absolute;
2975
- top: 8px;
2976
- left: 8px;
2977
- background: #fff;
2978
- border: 1px solid #d0d0d0;
2979
- border-radius: 3px;
2980
- padding: 4px 8px;
2981
- font-size: 11px;
2982
- cursor: pointer;
2983
- opacity: 0;
2984
- transition: opacity 0.2s ease;
2985
- `,m.onclick=x=>{x.stopPropagation(),navigator.clipboard.writeText(o).then(()=>{m.textContent="✓ Copied!",setTimeout(()=>{m.textContent="Copy"},2e3)})},d.appendChild(g),d.appendChild(m),d.appendChild(p),d.addEventListener("mouseenter",()=>{m.style.opacity="1"}),d.addEventListener("mouseleave",()=>{m.style.opacity="0"}),d.addEventListener("dblclick",()=>{Ds(s)}),ai.set(s,{id:s,language:r,code:o}),c.insertNode(d);const b=document.createRange();b.setStartAfter(d),b.collapse(!0),i.removeAllRanges(),i.addRange(b)})}function Ds(n){const e=Vn();if(!e)return;const t=e.querySelector(`#${n}`);if(!t)return;const o=ai.get(n);o&&li((r,i)=>{const a=t.querySelector("code");a&&(a.textContent=r,a.className=`language-${i}`);const l=t.querySelector("span");l&&(l.textContent=i),t.setAttribute("data-lang",i),o.language=i,o.code=r;const c=t.querySelector(".rte-code-copy");c&&(c.onclick=s=>{s.stopPropagation(),navigator.clipboard.writeText(r).then(()=>{c.textContent="✓ Copied!",setTimeout(()=>{c.textContent="Copy"},2e3)})})},n,o.code,o.language)}const _s=()=>({name:"codeSample",toolbar:[{label:"Code Block",command:"insertCodeBlock",icon:'<svg width="18px" height="18px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 8L3 11.6923L7 16M17 8L21 11.6923L17 16M14 4L10 20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',shortcut:"Mod-Shift-C"}],commands:{insertCodeBlock:(...n)=>(Is(),!0)}}),wn={USER:{name:"User",tags:[{key:"first_name",label:"First Name",category:"User",preview:"John"},{key:"last_name",label:"Last Name",category:"User",preview:"Doe"},{key:"email",label:"Email",category:"User",preview:"john@example.com"},{key:"phone",label:"Phone",category:"User",preview:"+1-555-1234"},{key:"full_name",label:"Full Name",category:"User",preview:"John Doe"},{key:"username",label:"Username",category:"User",preview:"johndoe"}]},COMPANY:{name:"Company",tags:[{key:"company_name",label:"Company Name",category:"Company",preview:"Acme Corp"},{key:"company_address",label:"Company Address",category:"Company",preview:"123 Main St"},{key:"company_phone",label:"Company Phone",category:"Company",preview:"+1-555-0000"},{key:"company_email",label:"Company Email",category:"Company",preview:"info@acme.com"}]},DATE:{name:"Date",tags:[{key:"today",label:"Today",category:"Date",preview:new Date().toLocaleDateString()},{key:"tomorrow",label:"Tomorrow",category:"Date",preview:new Date(Date.now()+864e5).toLocaleDateString()},{key:"next_week",label:"Next Week",category:"Date",preview:new Date(Date.now()+6048e5).toLocaleDateString()}]},CUSTOM:{name:"Custom",tags:[]}};let Un=null,ae=null;function Cn(n){const e=Un;if(!e)return;const t=window.getSelection();if(!t)return;t.removeAllRanges(),t.addRange(e);const o=`merge-tag-${n.key}-${Date.now()}`,r=document.createElement("span");r.className="rte-merge-tag",r.id=o,r.setAttribute("contenteditable","false"),r.setAttribute("data-key",n.key),r.setAttribute("data-category",n.category),r.setAttribute("aria-label",`Merge tag: ${n.label}`),r.textContent=`{{ ${n.label} }}`,r.style.cssText="background-color: #e3f2fd; border: 1px solid #bbdefb; border-radius: 3px; padding: 2px 6px; margin: 0 2px; display: inline-block; white-space: nowrap; font-weight: 500; color: #1976d2; cursor: pointer; user-select: none;";try{e.deleteContents(),e.insertNode(r),e.setStartAfter(r),e.setEndAfter(r),t.removeAllRanges(),t.addRange(e);const i=r.closest('[contenteditable="true"]');i&&i.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){console.error("Failed to insert merge tag:",i)}}function Hs(){const n=window.getSelection();n&&n.rangeCount>0&&(Un=n.getRangeAt(0).cloneRange());let e="USER",t="",o=wn.USER.tags;ae=o[0]||null;const r=document.createElement("div");r.className="rte-dialog-overlay",r.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 10000;";const i=document.createElement("div");i.className="rte-dialog rte-merge-tag-dialog",i.style.cssText="background: white; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); width: 500px; max-width: 90vw; max-height: 600px; overflow: hidden; display: flex; flex-direction: column;";const a=document.createElement("div");a.className="rte-dialog-header",a.style.cssText="padding: 16px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center;",a.innerHTML=`
2986
- <h2 style="margin: 0; font-size: 18px; font-weight: 600;">Insert Merge Tag</h2>
2987
- <button class="rte-dialog-close" style="background: none; border: none; font-size: 24px; cursor: pointer; color: #999; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;" aria-label="Close">✕</button>
2988
- `;const l=document.createElement("div");l.className="rte-dialog-body",l.style.cssText="padding: 16px; overflow-y: auto; flex: 1;";const c=document.createElement("input");c.type="text",c.className="rte-input",c.placeholder="Search merge tags...",c.setAttribute("aria-label","Search merge tags"),c.style.cssText="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; box-sizing: border-box; margin-bottom: 12px;",l.appendChild(c);const s=document.createElement("div");s.className="rte-tabs",s.style.cssText="display: flex; gap: 8px; margin-bottom: 12px; border-bottom: 2px solid #eee;";const d=Object.entries(wn).map(([E,f])=>({key:E,name:f.name}));d.forEach(E=>{const f=document.createElement("button");f.className="rte-tab",f.textContent=E.name,f.setAttribute("aria-label",`${E.name} category`),f.style.cssText="padding: 8px 12px; background: none; border: none; cursor: pointer; border-bottom: 3px solid transparent; color: #666; font-weight: 500; transition: all 0.2s;",E.key===e&&(f.classList.add("active"),f.style.color="#1976d2",f.style.borderBottomColor="#1976d2"),f.addEventListener("click",()=>{e=E.key,t="",c.value="",m(),b()}),f.addEventListener("mouseenter",()=>{f.style.color="#333"}),f.addEventListener("mouseleave",()=>{f.classList.contains("active")||(f.style.color="#666")}),s.appendChild(f)}),l.appendChild(s);const p=document.createElement("div");p.className="rte-merge-tag-list",p.style.cssText="border: 1px solid #ddd; border-radius: 4px; max-height: 300px; overflow-y: auto; margin-bottom: 12px;",l.appendChild(p);const g=document.createElement("div");g.className="rte-merge-tag-preview",g.style.cssText="padding: 8px; background-color: #f5f5f5; border-radius: 4px; font-family: monospace; font-size: 12px;",l.appendChild(g);function m(){s.querySelectorAll(".rte-tab").forEach((f,L)=>{d[L].key===e?(f.classList.add("active"),f.style.color="#1976d2",f.style.borderBottomColor="#1976d2"):(f.classList.remove("active"),f.style.color="#666",f.style.borderBottomColor="transparent")})}function b(){const E=wn[e];let f=E?E.tags:[];if(t.trim()&&(f=f.filter(L=>L.label.toLowerCase().includes(t.toLowerCase())||L.key.toLowerCase().includes(t.toLowerCase()))),o=f,ae=f[0]||null,p.innerHTML="",f.length===0){const L=document.createElement("div");L.className="rte-empty-state",L.textContent="No merge tags found",L.style.cssText="padding: 24px; text-align: center; color: #999;",p.appendChild(L)}else f.forEach((L,ve)=>{const H=document.createElement("div");H.className="rte-merge-tag-item",H.setAttribute("data-tag-key",L.key),H.style.cssText="padding: 8px 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background-color 0.2s;",ve===0&&(H.classList.add("selected"),H.style.backgroundColor="#f5f5f5");const N=document.createElement("div");if(N.className="tag-label",N.textContent=L.label,N.style.cssText="font-weight: 600; color: #333;",H.appendChild(N),L.preview){const F=document.createElement("div");F.className="tag-preview",F.textContent=L.preview,F.style.cssText="font-size: 12px; color: #999; margin-top: 2px;",H.appendChild(F)}if(L.description){const F=document.createElement("div");F.className="tag-description",F.textContent=L.description,F.style.cssText="font-size: 12px; color: #aaa; margin-top: 2px;",H.appendChild(F)}H.addEventListener("click",()=>{ae=L,x(),C()}),H.addEventListener("dblclick",()=>{Cn(L),S()}),H.addEventListener("mouseenter",()=>{H.style.backgroundColor="#f5f5f5"}),H.addEventListener("mouseleave",()=>{H.classList.contains("selected")||(H.style.backgroundColor="")}),p.appendChild(H)});C()}function x(){p.querySelectorAll(".rte-merge-tag-item").forEach(f=>{f.getAttribute("data-tag-key")===ae?.key?(f.classList.add("selected"),f.style.backgroundColor="#f5f5f5"):(f.classList.remove("selected"),f.style.backgroundColor="")})}function C(){ae?(g.innerHTML=`<strong>Preview:</strong> {{ ${ae.label} }}`,g.style.display="block"):g.style.display="none"}c.addEventListener("input",E=>{t=E.target.value,b()}),c.addEventListener("keydown",E=>{E.key==="Enter"&&ae?(Cn(ae),S()):E.key==="Escape"&&S()});const k=document.createElement("div");k.className="rte-dialog-footer",k.style.cssText="padding: 12px 16px; border-top: 1px solid #eee; display: flex; gap: 8px; justify-content: flex-end;";const y=document.createElement("button");y.className="rte-button-secondary",y.textContent="Cancel",y.style.cssText="padding: 8px 16px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; cursor: pointer; background-color: #f5f5f5; color: #333; transition: all 0.2s;",y.addEventListener("click",S),y.addEventListener("mouseenter",()=>{y.style.backgroundColor="#eeeeee"}),y.addEventListener("mouseleave",()=>{y.style.backgroundColor="#f5f5f5"});const w=document.createElement("button");w.className="rte-button-primary",w.textContent="Insert",w.style.cssText="padding: 8px 16px; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; background-color: #1976d2; color: white; transition: all 0.2s;",w.addEventListener("click",()=>{ae&&(Cn(ae),S())}),w.addEventListener("mouseenter",()=>{w.style.backgroundColor="#1565c0"}),w.addEventListener("mouseleave",()=>{w.style.backgroundColor="#1976d2"}),k.appendChild(y),k.appendChild(w),i.appendChild(a),i.appendChild(l),i.appendChild(k),r.appendChild(i);function S(){r.remove(),Un=null,ae=null}a.querySelector(".rte-dialog-close")?.addEventListener("click",S),r.addEventListener("click",E=>{E.target===r&&S()}),document.body.appendChild(r),b(),setTimeout(()=>c.focus(),100)}const Ps=()=>({name:"mergeTag",toolbar:[{label:"Merge Tag",command:"insertMergeTag",icon:"{{ }}"}],commands:{insertMergeTag:()=>(Hs(),!0)}});function we(n){"@babel/helpers - typeof";return we=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},we(n)}function Wn(n,e){return Wn=Object.setPrototypeOf||function(o,r){return o.__proto__=r,o},Wn(n,e)}function Os(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function At(n,e,t){return Os()?At=Reflect.construct:At=function(r,i,a){var l=[null];l.push.apply(l,i);var c=Function.bind.apply(r,l),s=new c;return a&&Wn(s,a.prototype),s},At.apply(null,arguments)}function se(n){return $s(n)||Bs(n)||Fs(n)||qs()}function $s(n){if(Array.isArray(n))return Gn(n)}function Bs(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function Fs(n,e){if(n){if(typeof n=="string")return Gn(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Gn(n,e)}}function Gn(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,o=new Array(e);t<e;t++)o[t]=n[t];return o}function qs(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2989
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var js=Object.hasOwnProperty,br=Object.setPrototypeOf,Vs=Object.isFrozen,Us=Object.getPrototypeOf,Ws=Object.getOwnPropertyDescriptor,K=Object.freeze,oe=Object.seal,Gs=Object.create,si=typeof Reflect<"u"&&Reflect,Bt=si.apply,Zn=si.construct;Bt||(Bt=function(e,t,o){return e.apply(t,o)});K||(K=function(e){return e});oe||(oe=function(e){return e});Zn||(Zn=function(e,t){return At(e,se(t))});var Zs=re(Array.prototype.forEach),xr=re(Array.prototype.pop),et=re(Array.prototype.push),Mt=re(String.prototype.toLowerCase),kn=re(String.prototype.toString),yr=re(String.prototype.match),le=re(String.prototype.replace),Ks=re(String.prototype.indexOf),Xs=re(String.prototype.trim),G=re(RegExp.prototype.test),En=Ys(TypeError);function re(n){return function(e){for(var t=arguments.length,o=new Array(t>1?t-1:0),r=1;r<t;r++)o[r-1]=arguments[r];return Bt(n,e,o)}}function Ys(n){return function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return Zn(n,t)}}function A(n,e,t){var o;t=(o=t)!==null&&o!==void 0?o:Mt,br&&br(n,null);for(var r=e.length;r--;){var i=e[r];if(typeof i=="string"){var a=t(i);a!==i&&(Vs(e)||(e[r]=a),i=a)}n[i]=!0}return n}function Ne(n){var e=Gs(null),t;for(t in n)Bt(js,n,[t])===!0&&(e[t]=n[t]);return e}function Ct(n,e){for(;n!==null;){var t=Ws(n,e);if(t){if(t.get)return re(t.get);if(typeof t.value=="function")return re(t.value)}n=Us(n)}function o(r){return console.warn("fallback value for",r),null}return o}var vr=K(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Sn=K(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Tn=K(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Qs=K(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ln=K(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),Js=K(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wr=K(["#text"]),Cr=K(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),An=K(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),kr=K(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),kt=K(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ec=oe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),tc=oe(/<%[\w\W]*|[\w\W]*%>/gm),nc=oe(/\${[\w\W]*}/gm),oc=oe(/^data-[\-\w.\u00B7-\uFFFF]+$/),rc=oe(/^aria-[\-\w]+$/),ic=oe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ac=oe(/^(?:\w+script|data):/i),lc=oe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sc=oe(/^html$/i),cc=oe(/^[a-z][.\w]*(-[.\w]+)+$/i),dc=function(){return typeof window>"u"?null:window},uc=function(e,t){if(we(e)!=="object"||typeof e.createPolicy!="function")return null;var o=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(o=t.currentScript.getAttribute(r));var i="dompurify"+(o?"#"+o:"");try{return e.createPolicy(i,{createHTML:function(l){return l},createScriptURL:function(l){return l}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function ci(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:dc(),e=function(u){return ci(u)};if(e.version="2.5.8",e.removed=[],!n||!n.document||n.document.nodeType!==9)return e.isSupported=!1,e;var t=n.document,o=n.document,r=n.DocumentFragment,i=n.HTMLTemplateElement,a=n.Node,l=n.Element,c=n.NodeFilter,s=n.NamedNodeMap,d=s===void 0?n.NamedNodeMap||n.MozNamedAttrMap:s,p=n.HTMLFormElement,g=n.DOMParser,m=n.trustedTypes,b=l.prototype,x=Ct(b,"cloneNode"),C=Ct(b,"nextSibling"),k=Ct(b,"childNodes"),y=Ct(b,"parentNode");if(typeof i=="function"){var w=o.createElement("template");w.content&&w.content.ownerDocument&&(o=w.content.ownerDocument)}var S=uc(m,t),E=S?S.createHTML(""):"",f=o,L=f.implementation,ve=f.createNodeIterator,H=f.createDocumentFragment,N=f.getElementsByTagName,F=t.importNode,Wt={};try{Wt=Ne(o).documentMode?o.documentMode:{}}catch{}var Q={};e.isSupported=typeof y=="function"&&L&&L.createHTMLDocument!==void 0&&Wt!==9;var Gt=ec,Zt=tc,Kt=nc,Ci=oc,ki=rc,Ei=ac,po=lc,Si=cc,Xt=ic,q=null,mo=A({},[].concat(se(vr),se(Sn),se(Tn),se(Ln),se(wr))),j=null,go=A({},[].concat(se(Cr),se(An),se(kr),se(kt))),P=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ke=null,Yt=null,ho=!0,Qt=!0,fo=!1,bo=!0,Pe=!1,Jt=!0,Ee=!1,en=!1,tn=!1,Oe=!1,pt=!1,mt=!1,xo=!0,yo=!1,Ti="user-content-",nn=!0,Xe=!1,$e={},Be=null,vo=A({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),wo=null,Co=A({},["audio","video","img","source","image","track"]),on=null,ko=A({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gt="http://www.w3.org/1998/Math/MathML",ht="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml",Fe=me,rn=!1,an=null,Li=A({},[gt,ht,me],kn),Se,Ai=["application/xhtml+xml","text/html"],Mi="text/html",V,qe=null,Ni=o.createElement("form"),Eo=function(u){return u instanceof RegExp||u instanceof Function},ln=function(u){qe&&qe===u||((!u||we(u)!=="object")&&(u={}),u=Ne(u),Se=Ai.indexOf(u.PARSER_MEDIA_TYPE)===-1?Se=Mi:Se=u.PARSER_MEDIA_TYPE,V=Se==="application/xhtml+xml"?kn:Mt,q="ALLOWED_TAGS"in u?A({},u.ALLOWED_TAGS,V):mo,j="ALLOWED_ATTR"in u?A({},u.ALLOWED_ATTR,V):go,an="ALLOWED_NAMESPACES"in u?A({},u.ALLOWED_NAMESPACES,kn):Li,on="ADD_URI_SAFE_ATTR"in u?A(Ne(ko),u.ADD_URI_SAFE_ATTR,V):ko,wo="ADD_DATA_URI_TAGS"in u?A(Ne(Co),u.ADD_DATA_URI_TAGS,V):Co,Be="FORBID_CONTENTS"in u?A({},u.FORBID_CONTENTS,V):vo,Ke="FORBID_TAGS"in u?A({},u.FORBID_TAGS,V):{},Yt="FORBID_ATTR"in u?A({},u.FORBID_ATTR,V):{},$e="USE_PROFILES"in u?u.USE_PROFILES:!1,ho=u.ALLOW_ARIA_ATTR!==!1,Qt=u.ALLOW_DATA_ATTR!==!1,fo=u.ALLOW_UNKNOWN_PROTOCOLS||!1,bo=u.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pe=u.SAFE_FOR_TEMPLATES||!1,Jt=u.SAFE_FOR_XML!==!1,Ee=u.WHOLE_DOCUMENT||!1,Oe=u.RETURN_DOM||!1,pt=u.RETURN_DOM_FRAGMENT||!1,mt=u.RETURN_TRUSTED_TYPE||!1,tn=u.FORCE_BODY||!1,xo=u.SANITIZE_DOM!==!1,yo=u.SANITIZE_NAMED_PROPS||!1,nn=u.KEEP_CONTENT!==!1,Xe=u.IN_PLACE||!1,Xt=u.ALLOWED_URI_REGEXP||Xt,Fe=u.NAMESPACE||me,P=u.CUSTOM_ELEMENT_HANDLING||{},u.CUSTOM_ELEMENT_HANDLING&&Eo(u.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(P.tagNameCheck=u.CUSTOM_ELEMENT_HANDLING.tagNameCheck),u.CUSTOM_ELEMENT_HANDLING&&Eo(u.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(P.attributeNameCheck=u.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),u.CUSTOM_ELEMENT_HANDLING&&typeof u.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(P.allowCustomizedBuiltInElements=u.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Pe&&(Qt=!1),pt&&(Oe=!0),$e&&(q=A({},se(wr)),j=[],$e.html===!0&&(A(q,vr),A(j,Cr)),$e.svg===!0&&(A(q,Sn),A(j,An),A(j,kt)),$e.svgFilters===!0&&(A(q,Tn),A(j,An),A(j,kt)),$e.mathMl===!0&&(A(q,Ln),A(j,kr),A(j,kt))),u.ADD_TAGS&&(q===mo&&(q=Ne(q)),A(q,u.ADD_TAGS,V)),u.ADD_ATTR&&(j===go&&(j=Ne(j)),A(j,u.ADD_ATTR,V)),u.ADD_URI_SAFE_ATTR&&A(on,u.ADD_URI_SAFE_ATTR,V),u.FORBID_CONTENTS&&(Be===vo&&(Be=Ne(Be)),A(Be,u.FORBID_CONTENTS,V)),nn&&(q["#text"]=!0),Ee&&A(q,["html","head","body"]),q.table&&(A(q,["tbody"]),delete Ke.tbody),K&&K(u),qe=u)},So=A({},["mi","mo","mn","ms","mtext"]),To=A({},["annotation-xml"]),Ri=A({},["title","style","font","a","script"]),ft=A({},Sn);A(ft,Tn),A(ft,Qs);var sn=A({},Ln);A(sn,Js);var zi=function(u){var h=y(u);(!h||!h.tagName)&&(h={namespaceURI:Fe,tagName:"template"});var v=Mt(u.tagName),R=Mt(h.tagName);return an[u.namespaceURI]?u.namespaceURI===ht?h.namespaceURI===me?v==="svg":h.namespaceURI===gt?v==="svg"&&(R==="annotation-xml"||So[R]):!!ft[v]:u.namespaceURI===gt?h.namespaceURI===me?v==="math":h.namespaceURI===ht?v==="math"&&To[R]:!!sn[v]:u.namespaceURI===me?h.namespaceURI===ht&&!To[R]||h.namespaceURI===gt&&!So[R]?!1:!sn[v]&&(Ri[v]||!ft[v]):!!(Se==="application/xhtml+xml"&&an[u.namespaceURI]):!1},J=function(u){et(e.removed,{element:u});try{u.parentNode.removeChild(u)}catch{try{u.outerHTML=E}catch{u.remove()}}},bt=function(u,h){try{et(e.removed,{attribute:h.getAttributeNode(u),from:h})}catch{et(e.removed,{attribute:null,from:h})}if(h.removeAttribute(u),u==="is"&&!j[u])if(Oe||pt)try{J(h)}catch{}else try{h.setAttribute(u,"")}catch{}},Lo=function(u){var h,v;if(tn)u="<remove></remove>"+u;else{var R=yr(u,/^[\r\n\t ]+/);v=R&&R[0]}Se==="application/xhtml+xml"&&Fe===me&&(u='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+u+"</body></html>");var X=S?S.createHTML(u):u;if(Fe===me)try{h=new g().parseFromString(X,Se)}catch{}if(!h||!h.documentElement){h=L.createDocument(Fe,"template",null);try{h.documentElement.innerHTML=rn?E:X}catch{}}var Z=h.body||h.documentElement;return u&&v&&Z.insertBefore(o.createTextNode(v),Z.childNodes[0]||null),Fe===me?N.call(h,Ee?"html":"body")[0]:Ee?h.documentElement:Z},Ao=function(u){return ve.call(u.ownerDocument||u,u,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null,!1)},cn=function(u){return u instanceof p&&(typeof u.nodeName!="string"||typeof u.textContent!="string"||typeof u.removeChild!="function"||!(u.attributes instanceof d)||typeof u.removeAttribute!="function"||typeof u.setAttribute!="function"||typeof u.namespaceURI!="string"||typeof u.insertBefore!="function"||typeof u.hasChildNodes!="function")},Ye=function(u){return we(a)==="object"?u instanceof a:u&&we(u)==="object"&&typeof u.nodeType=="number"&&typeof u.nodeName=="string"},ge=function(u,h,v){Q[u]&&Zs(Q[u],function(R){R.call(e,h,v,qe)})},Mo=function(u){var h;if(ge("beforeSanitizeElements",u,null),cn(u)||G(/[\u0080-\uFFFF]/,u.nodeName))return J(u),!0;var v=V(u.nodeName);if(ge("uponSanitizeElement",u,{tagName:v,allowedTags:q}),u.hasChildNodes()&&!Ye(u.firstElementChild)&&(!Ye(u.content)||!Ye(u.content.firstElementChild))&&G(/<[/\w]/g,u.innerHTML)&&G(/<[/\w]/g,u.textContent)||v==="select"&&G(/<template/i,u.innerHTML)||u.nodeType===7||Jt&&u.nodeType===8&&G(/<[/\w]/g,u.data))return J(u),!0;if(!q[v]||Ke[v]){if(!Ke[v]&&Ro(v)&&(P.tagNameCheck instanceof RegExp&&G(P.tagNameCheck,v)||P.tagNameCheck instanceof Function&&P.tagNameCheck(v)))return!1;if(nn&&!Be[v]){var R=y(u)||u.parentNode,X=k(u)||u.childNodes;if(X&&R)for(var Z=X.length,W=Z-1;W>=0;--W){var Te=x(X[W],!0);Te.__removalCount=(u.__removalCount||0)+1,R.insertBefore(Te,C(u))}}return J(u),!0}return u instanceof l&&!zi(u)||(v==="noscript"||v==="noembed"||v==="noframes")&&G(/<\/no(script|embed|frames)/i,u.innerHTML)?(J(u),!0):(Pe&&u.nodeType===3&&(h=u.textContent,h=le(h,Gt," "),h=le(h,Zt," "),h=le(h,Kt," "),u.textContent!==h&&(et(e.removed,{element:u.cloneNode()}),u.textContent=h)),ge("afterSanitizeElements",u,null),!1)},No=function(u,h,v){if(xo&&(h==="id"||h==="name")&&(v in o||v in Ni))return!1;if(!(Qt&&!Yt[h]&&G(Ci,h))){if(!(ho&&G(ki,h))){if(!j[h]||Yt[h]){if(!(Ro(u)&&(P.tagNameCheck instanceof RegExp&&G(P.tagNameCheck,u)||P.tagNameCheck instanceof Function&&P.tagNameCheck(u))&&(P.attributeNameCheck instanceof RegExp&&G(P.attributeNameCheck,h)||P.attributeNameCheck instanceof Function&&P.attributeNameCheck(h))||h==="is"&&P.allowCustomizedBuiltInElements&&(P.tagNameCheck instanceof RegExp&&G(P.tagNameCheck,v)||P.tagNameCheck instanceof Function&&P.tagNameCheck(v))))return!1}else if(!on[h]){if(!G(Xt,le(v,po,""))){if(!((h==="src"||h==="xlink:href"||h==="href")&&u!=="script"&&Ks(v,"data:")===0&&wo[u])){if(!(fo&&!G(Ei,le(v,po,"")))){if(v)return!1}}}}}}return!0},Ro=function(u){return u!=="annotation-xml"&&yr(u,Si)},zo=function(u){var h,v,R,X;ge("beforeSanitizeAttributes",u,null);var Z=u.attributes;if(!(!Z||cn(u))){var W={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j};for(X=Z.length;X--;){h=Z[X];var Te=h,$=Te.name,dn=Te.namespaceURI;if(v=$==="value"?h.value:Xs(h.value),R=V($),W.attrName=R,W.attrValue=v,W.keepAttr=!0,W.forceKeepAttr=void 0,ge("uponSanitizeAttribute",u,W),v=W.attrValue,!W.forceKeepAttr&&(bt($,u),!!W.keepAttr)){if(!bo&&G(/\/>/i,v)){bt($,u);continue}Pe&&(v=le(v,Gt," "),v=le(v,Zt," "),v=le(v,Kt," "));var Io=V(u.nodeName);if(No(Io,R,v)){if(yo&&(R==="id"||R==="name")&&(bt($,u),v=Ti+v),Jt&&G(/((--!?|])>)|<\/(style|title)/i,v)){bt($,u);continue}if(S&&we(m)==="object"&&typeof m.getAttributeType=="function"&&!dn)switch(m.getAttributeType(Io,R)){case"TrustedHTML":{v=S.createHTML(v);break}case"TrustedScriptURL":{v=S.createScriptURL(v);break}}try{dn?u.setAttributeNS(dn,$,v):u.setAttribute($,v),cn(u)?J(u):xr(e.removed)}catch{}}}}ge("afterSanitizeAttributes",u,null)}},Ii=function T(u){var h,v=Ao(u);for(ge("beforeSanitizeShadowDOM",u,null);h=v.nextNode();)ge("uponSanitizeShadowNode",h,null),Mo(h),zo(h),h.content instanceof r&&T(h.content);ge("afterSanitizeShadowDOM",u,null)};return e.sanitize=function(T){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h,v,R,X,Z;if(rn=!T,rn&&(T="<!-->"),typeof T!="string"&&!Ye(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw En("dirty is not a string, aborting")}else throw En("toString is not a function");if(!e.isSupported){if(we(n.toStaticHTML)==="object"||typeof n.toStaticHTML=="function"){if(typeof T=="string")return n.toStaticHTML(T);if(Ye(T))return n.toStaticHTML(T.outerHTML)}return T}if(en||ln(u),e.removed=[],typeof T=="string"&&(Xe=!1),Xe){if(T.nodeName){var W=V(T.nodeName);if(!q[W]||Ke[W])throw En("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof a)h=Lo("<!---->"),v=h.ownerDocument.importNode(T,!0),v.nodeType===1&&v.nodeName==="BODY"||v.nodeName==="HTML"?h=v:h.appendChild(v);else{if(!Oe&&!Pe&&!Ee&&T.indexOf("<")===-1)return S&&mt?S.createHTML(T):T;if(h=Lo(T),!h)return Oe?null:mt?E:""}h&&tn&&J(h.firstChild);for(var Te=Ao(Xe?T:h);R=Te.nextNode();)R.nodeType===3&&R===X||(Mo(R),zo(R),R.content instanceof r&&Ii(R.content),X=R);if(X=null,Xe)return T;if(Oe){if(pt)for(Z=H.call(h.ownerDocument);h.firstChild;)Z.appendChild(h.firstChild);else Z=h;return(j.shadowroot||j.shadowrootmod)&&(Z=F.call(t,Z,!0)),Z}var $=Ee?h.outerHTML:h.innerHTML;return Ee&&q["!doctype"]&&h.ownerDocument&&h.ownerDocument.doctype&&h.ownerDocument.doctype.name&&G(sc,h.ownerDocument.doctype.name)&&($="<!DOCTYPE "+h.ownerDocument.doctype.name+`>
2990
- `+$),Pe&&($=le($,Gt," "),$=le($,Zt," "),$=le($,Kt," ")),S&&mt?S.createHTML($):$},e.setConfig=function(T){ln(T),en=!0},e.clearConfig=function(){qe=null,en=!1},e.isValidAttribute=function(T,u,h){qe||ln({});var v=V(T),R=V(u);return No(v,R,h)},e.addHook=function(T,u){typeof u=="function"&&(Q[T]=Q[T]||[],et(Q[T],u))},e.removeHook=function(T){if(Q[T])return xr(Q[T])},e.removeHooks=function(T){Q[T]&&(Q[T]=[])},e.removeAllHooks=function(){Q={}},e}var di=ci();const pc=Object.freeze(Object.defineProperty({__proto__:null,default:di},Symbol.toStringTag,{value:"Module"}));let B=null,Ce=null,fe=null,U=null,Ge="",Ze="",lt="insert";const mc=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
2991
- <p>{{ Today }}</p>
2992
- <p>Dear {{ first_name }} {{ last_name }},</p>
2993
- <p>I hope this letter finds you well. [Your letter content here]</p>
2994
- <p>Thank you for your time and consideration.</p>
2995
- <p>Sincerely,<br>Your Name</p>`},{id:"meeting-notes",name:"Meeting Notes",category:"Notes",description:"Template for meeting notes with attendees and action items",html:`<h2>Meeting Notes - {{ today }}</h2>
2996
- <p><strong>Attendees:</strong> [List attendees]</p>
2997
- <p><strong>Agenda:</strong></p>
2998
- <ul>
2999
- <li>[Item 1]</li>
3000
- <li>[Item 2]</li>
3001
- <li>[Item 3]</li>
3002
- </ul>
3003
- <p><strong>Action Items:</strong></p>
3004
- <ul>
3005
- <li>[Owner]: [Task] - [Due Date]</li>
3006
- </ul>
3007
- <p><strong>Next Meeting:</strong> [Date]</p>`},{id:"proposal",name:"Project Proposal",category:"Business",description:"Structured project proposal template",html:`<h1>Project Proposal</h1>
3008
- <h2>Executive Summary</h2>
3009
- <p>[Summary of the proposal]</p>
3010
- <h2>Objectives</h2>
3011
- <ul>
3012
- <li>[Objective 1]</li>
3013
- <li>[Objective 2]</li>
3014
- </ul>
3015
- <h2>Scope</h2>
3016
- <p>[Project scope details]</p>
3017
- <h2>Timeline</h2>
3018
- <p>[Project timeline]</p>
3019
- <h2>Budget</h2>
3020
- <p>[Budget details]</p>
3021
- <h2>Contact</h2>
3022
- <p>{{ first_name }} {{ last_name }}<br>{{ email }}<br>{{ phone }}</p>`},{id:"faq",name:"FAQ Template",category:"Documentation",description:"FAQ document structure",html:`<h1>Frequently Asked Questions</h1>
3023
- <h2>General Questions</h2>
3024
- <h3>Q: What is this about?</h3>
3025
- <p>A: [Answer here]</p>
3026
- <h3>Q: Who should use this?</h3>
3027
- <p>A: [Answer here]</p>
3028
- <h2>Technical Questions</h2>
3029
- <h3>Q: How do I get started?</h3>
3030
- <p>A: [Answer here]</p>
3031
- <h3>Q: What are the requirements?</h3>
3032
- <p>A: [Answer here]</p>`}];let ao=[...mc];const Kn=()=>ao,ui=()=>{const n=new Set(ao.map(e=>e.category));return Array.from(n)},gc=n=>{const e=n.toLowerCase();return ao.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)||t.tags?.some(o=>o.toLowerCase().includes(e)))},pi=n=>di.sanitize(n,{ALLOWED_TAGS:["p","br","strong","em","u","h1","h2","h3","h4","ul","ol","li","blockquote","table","thead","tbody","tr","th","td","a","span"],ALLOWED_ATTR:["href","target","class","data-key","data-category"]});function hc(){Ce=document.createElement("div"),Ce.className="rte-dialog-overlay",Ce.addEventListener("click",()=>Ie()),B=document.createElement("div"),B.className="rte-dialog rte-template-dialog",B.addEventListener("click",e=>e.stopPropagation());const n=ui();n.length>0&&!Ge&&(Ge=n[0]),st(),Ce.appendChild(B),document.body.appendChild(Ce)}function st(){if(!B)return;const n=ui(),e=lo();B.innerHTML=`
3033
- <div class="rte-dialog-header">
3034
- <h2>Insert Template</h2>
3035
- <button class="rte-dialog-close" aria-label="Close">✕</button>
3036
- </div>
3037
-
3038
- <div class="rte-dialog-body">
3039
- <!-- Search -->
3040
- <input
3041
- type="text"
3042
- placeholder="Search templates..."
3043
- value="${Ze}"
3044
- class="rte-input rte-template-search"
3045
- aria-label="Search templates"
3046
- />
3047
-
3048
- <!-- Category Tabs -->
3049
- <div class="rte-tabs">
3050
- ${n.map(t=>`
3051
- <button class="rte-tab ${Ge===t?"active":""}" data-category="${t}">
3052
- ${t}
3053
- </button>
3054
- `).join("")}
3055
- </div>
3056
-
3057
- <!-- Template List -->
3058
- <div class="rte-template-list">
3059
- ${e.length>0?e.map(t=>`
3060
- <div
3061
- class="rte-template-item ${U?.id===t.id?"selected":""}"
3062
- data-template-id="${t.id}"
3063
- >
3064
- <div class="template-name">${t.name}</div>
3065
- ${t.description?`<div class="template-description">${t.description}</div>`:""}
3066
- </div>
3067
- `).join(""):'<div class="rte-empty-state">No templates found</div>'}
3068
- </div>
3069
-
3070
- <!-- Preview -->
3071
- ${U?`
3072
- <div class="rte-template-preview">
3073
- <strong>Preview:</strong>
3074
- <div class="template-preview-content">${U.html}</div>
3075
- </div>
3076
- `:""}
3077
-
3078
- <!-- Insert Mode Toggle -->
3079
- <div class="rte-insert-mode">
3080
- <label>
3081
- <input type="radio" name="insertMode" value="insert" ${lt==="insert"?"checked":""} />
3082
- Insert at cursor
3083
- </label>
3084
- <label>
3085
- <input type="radio" name="insertMode" value="replace" ${lt==="replace"?"checked":""} />
3086
- Replace document
3087
- </label>
3088
- </div>
3089
- </div>
3090
-
3091
- <div class="rte-dialog-footer">
3092
- <button class="rte-button-secondary rte-cancel-btn">Cancel</button>
3093
- <button class="rte-button-primary rte-insert-btn" ${U?"":"disabled"}>
3094
- ${lt==="insert"?"Insert":"Replace"}
3095
- </button>
3096
- </div>
3097
- `,bc()}function fc(){if(!B)return;B.innerHTML=`
3098
- <div class="rte-dialog-header">
3099
- <h2>Replace Document?</h2>
3100
- </div>
3101
- <div class="rte-dialog-body">
3102
- <p>This will replace your current document content. Continue?</p>
3103
- </div>
3104
- <div class="rte-dialog-footer">
3105
- <button class="rte-button-secondary rte-cancel-warning-btn">Cancel</button>
3106
- <button class="rte-button-primary rte-confirm-replace-btn">Replace</button>
3107
- </div>
3108
- `;const n=B.querySelector(".rte-cancel-warning-btn"),e=B.querySelector(".rte-confirm-replace-btn");n?.addEventListener("click",()=>st()),e?.addEventListener("click",()=>xc())}function lo(){const n=Kn();return Ze.trim()?gc(Ze):Ge?n.filter(e=>e.category===Ge):n}function bc(){if(!B)return;B.querySelector(".rte-dialog-close")?.addEventListener("click",()=>Ie()),B.querySelector(".rte-cancel-btn")?.addEventListener("click",()=>Ie()),B.querySelector(".rte-insert-btn")?.addEventListener("click",()=>Mn());const o=B.querySelector(".rte-template-search");o?.addEventListener("input",l=>{Ze=l.target.value,Er()}),o?.addEventListener("keydown",l=>{l.key==="Enter"&&U?Mn():l.key==="Escape"&&Ie()}),B.querySelectorAll(".rte-tab").forEach(l=>{l.addEventListener("click",()=>{const c=l.getAttribute("data-category");c&&(Ge=c,Ze="",Er())})}),B.querySelectorAll(".rte-template-item").forEach(l=>{l.addEventListener("click",()=>{const c=l.getAttribute("data-template-id");if(c){const s=Kn().find(d=>d.id===c);s&&(U=s,st())}}),l.addEventListener("dblclick",()=>{const c=l.getAttribute("data-template-id");if(c){const s=Kn().find(d=>d.id===c);s&&(U=s,Mn())}})}),B.querySelectorAll('input[name="insertMode"]').forEach(l=>{l.addEventListener("change",c=>{lt=c.target.value,st()})})}function Er(){const n=lo();n.length>0?(!U||!n.find(e=>e.id===U.id))&&(U=n[0]):U=null,st()}function Mn(){if(U)if(lt==="replace"){let n=null;if(fe){let e=fe.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.getAttribute("contenteditable")==="true"){n=t;break}}e=e.parentNode}}if(n||(n=document.querySelector('[contenteditable="true"]')),n?.innerHTML?.trim()){fc();return}mi(U),Ie()}else yc(U),Ie()}function xc(){U&&(mi(U),Ie())}function yc(n){if(fe){const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(fe))}const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0),o=document.createRange().createContextualFragment(pi(n.html));t.deleteContents(),t.insertNode(o);const r=document.createRange();r.setStartAfter(t.endContainer),r.collapse(!0),e.removeAllRanges(),e.addRange(r),console.log(`Template inserted: ${n.name}`)}function mi(n){let e=null;if(fe){let t=fe.startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true"){e=o;break}}t=t.parentNode}}e||(e=document.querySelector('[contenteditable="true"]')),e&&(e.innerHTML=pi(n.html),e.dispatchEvent(new Event("input",{bubbles:!0}))),console.log(`Document replaced with template: ${n.name}`)}function Ie(){Ce&&(Ce.remove(),Ce=null),B=null,fe=null,Ze=""}function vc(){const n=window.getSelection();n&&n.rangeCount>0?fe=n.getRangeAt(0).cloneRange():fe=null;const e=lo();e.length>0&&!U&&(U=e[0]),hc()}function Sr(){if(!window.__templatePluginInitialized&&(window.__templatePluginInitialized=!0,!document.getElementById("template-plugin-styles"))){const n=document.createElement("style");n.id="template-plugin-styles",n.textContent=`
3109
- .rte-dialog-overlay {
3110
- position: fixed;
3111
- top: 0;
3112
- left: 0;
3113
- right: 0;
3114
- bottom: 0;
3115
- background-color: rgba(0, 0, 0, 0.5);
3116
- display: flex;
3117
- align-items: center;
3118
- justify-content: center;
3119
- z-index: 10000;
3120
- }
3121
-
3122
- .rte-dialog {
3123
- background: white;
3124
- border-radius: 8px;
3125
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
3126
- max-width: 90vw;
3127
- max-height: 90vh;
3128
- overflow: hidden;
3129
- display: flex;
3130
- flex-direction: column;
3131
- }
3132
-
3133
- .rte-dialog-header {
3134
- padding: 16px;
3135
- border-bottom: 1px solid #eee;
3136
- display: flex;
3137
- justify-content: space-between;
3138
- align-items: center;
3139
- }
3140
-
3141
- .rte-dialog-header h2 {
3142
- margin: 0;
3143
- font-size: 18px;
3144
- font-weight: 600;
3145
- }
3146
-
3147
- .rte-dialog-close {
3148
- background: none;
3149
- border: none;
3150
- font-size: 24px;
3151
- cursor: pointer;
3152
- color: #999;
3153
- padding: 0;
3154
- width: 32px;
3155
- height: 32px;
3156
- display: flex;
3157
- align-items: center;
3158
- justify-content: center;
3159
- }
3160
-
3161
- .rte-dialog-close:hover {
3162
- color: #333;
3163
- }
3164
-
3165
- .rte-dialog-body {
3166
- padding: 16px;
3167
- overflow-y: auto;
3168
- flex: 1;
3169
- }
3170
-
3171
- .rte-dialog-footer {
3172
- padding: 12px 16px;
3173
- border-top: 1px solid #eee;
3174
- display: flex;
3175
- gap: 8px;
3176
- justify-content: flex-end;
3177
- }
3178
-
3179
- .rte-button-primary {
3180
- padding: 8px 16px;
3181
- border: none;
3182
- border-radius: 4px;
3183
- font-size: 14px;
3184
- cursor: pointer;
3185
- background-color: #1976d2;
3186
- color: white;
3187
- transition: all 0.2s;
3188
- }
3189
-
3190
- .rte-button-primary:hover:not([disabled]) {
3191
- background-color: #1565c0;
3192
- }
3193
-
3194
- .rte-button-primary[disabled] {
3195
- opacity: 0.5;
3196
- cursor: not-allowed;
3197
- }
3198
-
3199
- .rte-button-secondary {
3200
- padding: 8px 16px;
3201
- border: 1px solid #ddd;
3202
- border-radius: 4px;
3203
- font-size: 14px;
3204
- cursor: pointer;
3205
- background-color: #f5f5f5;
3206
- color: #333;
3207
- transition: all 0.2s;
3208
- }
3209
-
3210
- .rte-button-secondary:hover {
3211
- background-color: #eeeeee;
3212
- }
3213
-
3214
- .rte-template-dialog {
3215
- width: 600px;
3216
- max-height: 700px;
3217
- }
3218
-
3219
- .rte-input {
3220
- width: 100%;
3221
- padding: 8px 12px;
3222
- border: 1px solid #ddd;
3223
- border-radius: 4px;
3224
- font-size: 14px;
3225
- box-sizing: border-box;
3226
- }
3227
-
3228
- .rte-input:focus {
3229
- outline: none;
3230
- border-color: #1976d2;
3231
- }
3232
-
3233
- .rte-tabs {
3234
- display: flex;
3235
- gap: 8px;
3236
- margin-top: 12px;
3237
- border-bottom: 1px solid #eee;
3238
- padding-bottom: 8px;
3239
- }
3240
-
3241
- .rte-tab {
3242
- padding: 6px 12px;
3243
- border: none;
3244
- background: none;
3245
- cursor: pointer;
3246
- font-size: 14px;
3247
- color: #666;
3248
- border-bottom: 2px solid transparent;
3249
- transition: all 0.2s;
3250
- }
3251
-
3252
- .rte-tab:hover {
3253
- color: #333;
3254
- }
3255
-
3256
- .rte-tab.active {
3257
- color: #1976d2;
3258
- border-bottom-color: #1976d2;
3259
- font-weight: 600;
3260
- }
3261
-
3262
- .rte-template-list {
3263
- border: 1px solid #ddd;
3264
- border-radius: 4px;
3265
- max-height: 250px;
3266
- overflow-y: auto;
3267
- margin: 12px 0;
3268
- }
3269
-
3270
- .rte-template-item {
3271
- padding: 12px;
3272
- border-bottom: 1px solid #f0f0f0;
3273
- cursor: pointer;
3274
- transition: background-color 0.2s;
3275
- }
3276
-
3277
- .rte-template-item:last-child {
3278
- border-bottom: none;
3279
- }
3280
-
3281
- .rte-template-item:hover,
3282
- .rte-template-item.selected {
3283
- background-color: #f5f5f5;
3284
- }
3285
-
3286
- .template-name {
3287
- font-weight: 600;
3288
- color: #333;
3289
- margin-bottom: 4px;
3290
- }
3291
-
3292
- .template-description {
3293
- font-size: 12px;
3294
- color: #999;
3295
- }
3296
-
3297
- .rte-template-preview {
3298
- padding: 12px;
3299
- background-color: #fafafa;
3300
- border: 1px solid #eee;
3301
- border-radius: 4px;
3302
- margin-top: 12px;
3303
- max-height: 200px;
3304
- overflow-y: auto;
3305
- }
3306
-
3307
- .template-preview-content {
3308
- font-size: 13px;
3309
- line-height: 1.5;
3310
- margin-top: 8px;
3311
- }
3312
-
3313
- .template-preview-content * {
3314
- margin: 4px 0;
3315
- }
3316
-
3317
- .rte-insert-mode {
3318
- margin-top: 12px;
3319
- padding: 12px;
3320
- background-color: #f5f5f5;
3321
- border-radius: 4px;
3322
- display: flex;
3323
- gap: 16px;
3324
- }
3325
-
3326
- .rte-insert-mode label {
3327
- display: flex;
3328
- align-items: center;
3329
- cursor: pointer;
3330
- font-size: 14px;
3331
- }
3332
-
3333
- .rte-insert-mode input {
3334
- margin-right: 6px;
3335
- cursor: pointer;
3336
- }
3337
-
3338
- .rte-empty-state {
3339
- padding: 40px;
3340
- text-align: center;
3341
- color: #999;
3342
- font-size: 14px;
3343
- }
3344
- `,document.head.appendChild(n)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Sr):setTimeout(Sr,100);const wc=()=>({name:"template",toolbar:[{label:"Template",command:"insertTemplate",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'}],commands:{insertTemplate:()=>(vc(),!0)},keymap:{}}),be=new Map;let De=!1,ce=null,Et=new Set,tt={},He=null,ue="";const Ft="User";let Ue=null;function Cc(){return Array.from(be.values())}function Tr(n,e,t=!1){if(t){const g=`comment-${Date.now()}`,m={id:g,anchorId:"",selectedText:"",author:n,text:e,createdAt:new Date().toISOString(),resolved:!1,replies:[]};return be.set(g,m),de(),g}const o=window.getSelection();if(!o||o.rangeCount===0)return"";const r=He||o.getRangeAt(0),i=r.toString();if(!i)return"";const a=`comment-${Date.now()}`,l=`comment-anchor-${Date.now()}`,c=document.createElement("span");c.id=l,c.className="rte-comment-anchor",c.setAttribute("data-comment-id",a),c.style.cssText=`
3345
- background-color: #ffeb3b;
3346
- border-bottom: 2px solid #fbc02d;
3347
- cursor: pointer;
3348
- position: relative;
3349
- `,c.title="Click to view comment";const s=r.cloneRange(),d=s.extractContents();c.appendChild(d),s.insertNode(c);const p={id:a,anchorId:l,selectedText:i,author:n,text:e,createdAt:new Date().toISOString(),resolved:!1,replies:[]};return be.set(a,p),c.onclick=()=>{De=!0,Xn()},de(),He=null,o.removeAllRanges(),a}function kc(n,e){const t=be.get(n);if(t){if(t.resolved=!0,t.resolvedAt=new Date().toISOString(),t.resolvedBy=e,t.anchorId){const o=document.getElementById(t.anchorId);o&&(o.style.backgroundColor="#e0e0e0",o.style.borderBottom="2px solid #bdbdbd",o.style.opacity="0.6")}de()}}function Ec(n){const e=be.get(n);if(e){if(e.resolved=!1,e.resolvedAt=void 0,e.resolvedBy=void 0,e.anchorId){const t=document.getElementById(e.anchorId);t&&(t.style.backgroundColor="#ffeb3b",t.style.borderBottom="2px solid #fbc02d",t.style.opacity="1")}de()}}function Sc(n){const e=be.get(n);if(e){if(e.anchorId){const t=document.getElementById(e.anchorId);if(t){const o=t.parentNode;for(;t.firstChild;)o?.insertBefore(t.firstChild,t);t.remove()}}be.delete(n),de()}}function Tc(n,e,t){const o=be.get(n);if(!o)return;const r={id:`reply-${Date.now()}`,author:e,text:t,createdAt:new Date().toISOString()};o.replies.push(r),de()}function Lr(n,e){const t=be.get(n);if(!t||!t.anchorId)return;const o=document.getElementById(t.anchorId);o&&(e?(o.classList.add("highlighted"),o.style.outline="2px solid #0066cc",o.style.outlineOffset="2px"):(o.classList.remove("highlighted"),o.style.outline="none"))}function Xn(){if(ce){ce.style.display=De?"block":"none",De?(de(),Ar()):gi();return}const n=document.createElement("div");n.className="rte-comments-panel",ce=n,document.body.appendChild(n),de(),Ar(),Ac()}function Ar(){Ue||(Ue=()=>{const n=window.getSelection();n&&n.rangeCount>0&&!n.isCollapsed&&(He=n.getRangeAt(0).cloneRange())},document.addEventListener("selectionchange",Ue))}function gi(){Ue&&(document.removeEventListener("selectionchange",Ue),Ue=null),He=null}function de(){if(!ce)return;const n=Cc();ce.innerHTML=`
3350
- <div class="comments-header" style="display: flex; justify-content: space-between; align-items: center;">
3351
- <h3 style="margin: 0;">Comments (${n.length})</h3>
3352
- <button class="rte-comments-close" aria-label="Close comments panel">✕</button>
3353
- </div>
3354
-
3355
- <div class="comment-add-box">
3356
- <textarea class="new-comment-textarea" placeholder="Add a new comment..." rows="2"></textarea>
3357
- <button class="rte-button-small add-comment-btn">Add Comment</button>
3358
- </div>
3359
-
3360
- ${n.length===0?'<div class="comments-empty">No comments yet</div>':'<div class="comments-list"></div>'}
3361
- `;const e=ce.querySelector(".rte-comments-close");e&&e.addEventListener("click",()=>{De=!1,ce&&(ce.style.display="none"),gi()});const t=ce.querySelector(".new-comment-textarea"),o=ce.querySelector(".add-comment-btn");if(t&&o&&(t.value=ue,t.oninput=()=>{ue=t.value,o.disabled=!ue.trim(),o.style.opacity=ue.trim()?"1":"0.5"},o.disabled=!ue.trim(),o.style.opacity=ue.trim()?"1":"0.5",o.onclick=()=>{if(!ue.trim()){alert("Comment cannot be empty"),t.focus();return}He?Tr(Ft,ue.trim()):Tr(Ft,ue.trim(),!0),ue="",t.value="",de()}),n.length>0){const r=ce.querySelector(".comments-list");r&&n.forEach(i=>{const a=Lc(i);r.appendChild(a)})}}function Lc(n){const e=Et.has(n.id),t=document.createElement("div");t.className=`comment-item${n.resolved?" resolved":""}`;const o=document.createElement("div");o.className="comment-header",o.innerHTML=`
3362
- <div class="comment-meta">
3363
- <strong>${n.author}</strong>
3364
- <span class="comment-date">${new Date(n.createdAt).toLocaleDateString()}</span>
3365
- </div>
3366
- <button class="comment-expand" aria-label="Toggle comment">${e?"▼":"▶"}</button>
3367
- `;const r=o.querySelector(".comment-expand");r&&r.addEventListener("click",()=>{Et.has(n.id)?Et.delete(n.id):Et.add(n.id),de()}),t.appendChild(o);const i=document.createElement("div");if(i.className="comment-text",i.textContent=n.text,t.appendChild(i),n.selectedText){const a=document.createElement("div");a.className="comment-selection",a.textContent=`"${n.selectedText}"`,t.appendChild(a)}if(e){const a=document.createElement("div");if(a.className="comment-expanded",n.replies.length>0){const s=document.createElement("div");s.className="comment-replies",n.replies.forEach(d=>{const p=document.createElement("div");p.className="comment-reply",p.innerHTML=`
3368
- <div class="reply-header">
3369
- <strong>${d.author}</strong>
3370
- <span class="reply-date">${new Date(d.createdAt).toLocaleDateString()}</span>
3371
- </div>
3372
- <div class="reply-text">${d.text}</div>
3373
- `,s.appendChild(p)}),a.appendChild(s)}if(!n.resolved){const s=document.createElement("div");s.className="comment-reply-input";const d=document.createElement("textarea");d.placeholder="Add a reply...",d.rows=2,d.value=tt[n.id]||"",d.oninput=()=>{tt[n.id]=d.value};const p=document.createElement("button");p.className="rte-button-small",p.textContent="Reply",p.onclick=()=>{tt[n.id]?.trim()&&(Tc(n.id,Ft,tt[n.id]),tt[n.id]="",de())},s.appendChild(d),s.appendChild(p),a.appendChild(s)}const l=document.createElement("div");if(l.className="comment-actions",n.resolved){const s=document.createElement("button");s.className="action-button reopen",s.textContent="↻ Reopen",s.onclick=()=>Ec(n.id),l.appendChild(s)}else{const s=document.createElement("button");s.className="action-button resolve",s.textContent="✓ Resolve",s.onclick=()=>kc(n.id,Ft),l.appendChild(s)}const c=document.createElement("button");c.className="action-button delete",c.textContent="🗑 Delete",c.onclick=()=>{confirm("Delete this comment?")&&Sc(n.id)},l.appendChild(c),a.appendChild(l),t.appendChild(a)}return t.onmouseenter=()=>Lr(n.id,!0),t.onmouseleave=()=>Lr(n.id,!1),t}function Ac(){if(document.getElementById("rte-comments-panel-styles"))return;const n=document.createElement("style");n.id="rte-comments-panel-styles",n.textContent=`
3374
- .rte-comments-close:hover {
3375
- color: #d32f2f;
3376
- }
3377
- .rte-comments-panel {
3378
- position: fixed;
3379
- right: 0;
3380
- top: 0;
3381
- width: 350px;
3382
- height: 100%;
3383
- background: white;
3384
- border-left: 1px solid #ddd;
3385
- box-shadow: -2px 0 4px rgba(0,0,0,0.1);
3386
- overflow-y: auto;
3387
- z-index: 1000;
3388
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
3389
- display: flex;
3390
- flex-direction: column;
3391
- }
3392
- .comments-header {
3393
- padding: 16px;
3394
- border-bottom: 1px solid #eee;
3395
- background-color: #fafafa;
3396
- }
3397
- .comments-header h3 {
3398
- margin: 0;
3399
- font-size: 14px;
3400
- font-weight: 600;
3401
- }
3402
- .rte-comments-close {
3403
- background: none;
3404
- border: none;
3405
- font-size: 22px;
3406
- cursor: pointer;
3407
- color: #888;
3408
- margin-left: 8px;
3409
- padding: 0;
3410
- }
3411
- .comment-add-box {
3412
- padding: 12px;
3413
- border-bottom: 1px solid #eee;
3414
- background: #fafafa;
3415
- display: flex;
3416
- flex-direction: column;
3417
- gap: 8px;
3418
- }
3419
- .new-comment-textarea {
3420
- font-size: 13px;
3421
- padding: 8px;
3422
- border-radius: 3px;
3423
- border: 1px solid #ddd;
3424
- resize: vertical;
3425
- font-family: inherit;
3426
- }
3427
- .comments-empty {
3428
- padding: 16px;
3429
- text-align: center;
3430
- color: #999;
3431
- font-size: 13px;
3432
- }
3433
- .comments-list {
3434
- padding: 12px;
3435
- }
3436
- .comment-item {
3437
- padding: 12px;
3438
- margin-bottom: 12px;
3439
- border: 1px solid #eee;
3440
- border-radius: 4px;
3441
- background-color: white;
3442
- transition: all 0.2s;
3443
- }
3444
- .comment-item:hover {
3445
- border-color: #ddd;
3446
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
3447
- }
3448
- .comment-item.resolved {
3449
- opacity: 0.6;
3450
- background-color: #f5f5f5;
3451
- }
3452
- .comment-header {
3453
- display: flex;
3454
- justify-content: space-between;
3455
- align-items: center;
3456
- margin-bottom: 8px;
3457
- }
3458
- .comment-meta {
3459
- display: flex;
3460
- flex-direction: column;
3461
- gap: 2px;
3462
- }
3463
- .comment-meta strong {
3464
- font-size: 13px;
3465
- color: #333;
3466
- }
3467
- .comment-date {
3468
- font-size: 11px;
3469
- color: #999;
3470
- }
3471
- .comment-expand {
3472
- background: none;
3473
- border: none;
3474
- cursor: pointer;
3475
- color: #666;
3476
- font-size: 12px;
3477
- padding: 0;
3478
- }
3479
- .comment-text {
3480
- font-size: 13px;
3481
- line-height: 1.4;
3482
- color: #333;
3483
- margin-bottom: 8px;
3484
- }
3485
- .comment-selection {
3486
- font-size: 12px;
3487
- color: #666;
3488
- font-style: italic;
3489
- background-color: #f9f9f9;
3490
- padding: 6px;
3491
- border-radius: 3px;
3492
- margin-bottom: 8px;
3493
- }
3494
- .comment-expanded {
3495
- margin-top: 12px;
3496
- padding-top: 12px;
3497
- border-top: 1px solid #eee;
3498
- }
3499
- .comment-replies {
3500
- margin-bottom: 12px;
3501
- }
3502
- .comment-reply {
3503
- padding: 8px;
3504
- background-color: #fafafa;
3505
- border-radius: 3px;
3506
- margin-bottom: 8px;
3507
- font-size: 12px;
3508
- }
3509
- .reply-header {
3510
- display: flex;
3511
- gap: 8px;
3512
- margin-bottom: 4px;
3513
- }
3514
- .reply-header strong {
3515
- font-size: 12px;
3516
- color: #333;
3517
- }
3518
- .reply-date {
3519
- font-size: 11px;
3520
- color: #999;
3521
- }
3522
- .reply-text {
3523
- font-size: 12px;
3524
- color: #666;
3525
- line-height: 1.3;
3526
- }
3527
- .comment-reply-input {
3528
- display: flex;
3529
- flex-direction: column;
3530
- gap: 6px;
3531
- margin-bottom: 12px;
3532
- }
3533
- .comment-reply-input textarea {
3534
- font-size: 12px;
3535
- padding: 6px;
3536
- border: 1px solid #ddd;
3537
- border-radius: 3px;
3538
- font-family: inherit;
3539
- resize: vertical;
3540
- }
3541
- .rte-button-small {
3542
- font-size: 12px;
3543
- padding: 4px 8px;
3544
- background-color: #1976d2;
3545
- color: white;
3546
- border: none;
3547
- border-radius: 3px;
3548
- cursor: pointer;
3549
- align-self: flex-end;
3550
- }
3551
- .rte-button-small:hover {
3552
- background-color: #1565c0;
3553
- }
3554
- .rte-button-small:disabled {
3555
- opacity: 0.5;
3556
- pointer-events: none;
3557
- }
3558
- .comment-actions {
3559
- display: flex;
3560
- gap: 6px;
3561
- justify-content: flex-end;
3562
- }
3563
- .action-button {
3564
- font-size: 12px;
3565
- padding: 4px 8px;
3566
- background-color: #f5f5f5;
3567
- border: 1px solid #ddd;
3568
- border-radius: 3px;
3569
- cursor: pointer;
3570
- transition: all 0.2s;
3571
- }
3572
- .action-button:hover {
3573
- background-color: #eeeeee;
3574
- }
3575
- .action-button.resolve {
3576
- color: #2e7d32;
3577
- }
3578
- .action-button.delete {
3579
- color: #c62828;
3580
- }
3581
- .rte-comment-anchor {
3582
- position: relative;
3583
- }
3584
- .rte-comment-anchor.highlighted {
3585
- background-color: #ffeb3b !important;
3586
- border-radius: 3px;
3587
- }
3588
- `,document.head.appendChild(n)}const Mc=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><defs><style>.cls-1{fill:none;}</style></defs><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z" transform="translate(0 0)"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect id="_Transparent_Rectangle_" data-name="&lt;Transparent Rectangle&gt;" class="cls-1" width="32" height="32"></rect></g></svg>'},{label:"Show / Hide Comments",command:"toggleComments",type:"button",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M16 1H4V11H8L10 13L12 11H16V1Z" fill="#000000"></path> <path d="M2 5V13H7.17157L8.70711 14.5355L7.29289 15.9497L6.34315 15H0V5H2Z" fill="#000000"></path> </g></svg>'}],commands:{addComment:()=>{const n=window.getSelection();return n&&n.rangeCount>0&&!n.isCollapsed?He=n.getRangeAt(0).cloneRange():He=null,De=!0,Xn(),!0},toggleComments:()=>(De=!De,Xn(),!0)},keymap:{}}),hi=new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","is","are","be","was","were","have","has","had","do","does","did","will","would","could","should","may","might","must","can","this","that","these","those","what","which","who","whom","where","when","why","how","all","each","every","both","few","more","most","other","same","such","no","nor","not","only","own","so","than","too","very","just","as","if","because","while","although","though","it","its","their","them","they","you","he","she","we","me","him","her","us","our","i","my","your","his","hers","ours","yours","theirs","editor","document","text","word","paragraph","line","page","content","hello","world","test","example","sample","demo","lorem","ipsum"]),qt=new Set,jt=new Set;let ot=!1,ze=null,We=null,ne=null;const Nc=()=>{try{const n=localStorage.getItem("rte-custom-dictionary");n&&JSON.parse(n).forEach(t=>qt.add(t.toLowerCase()))}catch(n){console.warn("Failed to load custom dictionary:",n)}},Rc=()=>{try{const n=Array.from(qt);localStorage.setItem("rte-custom-dictionary",JSON.stringify(n))}catch(n){console.warn("Failed to save custom dictionary:",n)}};function zc(n,e){const t=[];for(let o=0;o<=e.length;o++)t[o]=[o];for(let o=0;o<=n.length;o++)t[0][o]=o;for(let o=1;o<=e.length;o++)for(let r=1;r<=n.length;r++)e.charAt(o-1)===n.charAt(r-1)?t[o][r]=t[o-1][r-1]:t[o][r]=Math.min(t[o-1][r-1]+1,t[o][r-1]+1,t[o-1][r]+1);return t[e.length][n.length]}function Ic(n){const e=n.toLowerCase();return hi.has(e)||qt.has(e)||jt.has(e)}function Dc(n,e=5){const t=n.toLowerCase(),r=Array.from(hi).map(i=>({word:i,distance:zc(t,i)}));return r.sort((i,a)=>i.distance-a.distance),r.filter(i=>i.distance<=3).slice(0,e).map(i=>i.word)}function _c(n){if(n.nodeType!==Node.ELEMENT_NODE)return!1;const e=n;return!!(e.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag')||e.hasAttribute("data-comment-id")||e.hasAttribute("data-template")||e.hasAttribute("data-merge-tag"))}function Hc(n){const e=[],t=/([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;let o;for(;(o=t.exec(n.data))!==null;){const r=o[0],i=o.index,a=i+r.length;/https?:\/\//.test(r)||/@/.test(r)||/\{\{.*\}\}/.test(r)||/^\d+$/.test(r)||Ic(r)||/[a-z][A-Z]/.test(r)||/-/.test(r)||r[0]===r[0].toUpperCase()&&r.length>1||e.push({id:`${r}-${i}`,node:n,startOffset:i,endOffset:a,word:r,suggestions:Dc(r),ignored:!1})}return e}const Vt=()=>{const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')};function so(){const n=Vt();if(!n)return[];const e=[],t=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,{acceptNode:r=>!r.textContent?.trim()||r.parentNode&&_c(r.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let o=t.nextNode();for(;o;)e.push(...Hc(o)),o=t.nextNode();return e}function Ut(n){const e=Vt();e&&(n||(n=so()),e.querySelectorAll(".rte-misspelled").forEach(t=>{const o=t.parentNode;if(o){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t)}}),n.forEach(t=>{if(jt.has(t.word.toLowerCase()))return;const o=t.node.data.length;if(!(t.startOffset<0||t.endOffset>o||t.startOffset>=t.endOffset))try{const r=document.createRange();r.setStart(t.node,t.startOffset),r.setEnd(t.node,t.endOffset);const i=document.createElement("span");i.className="rte-misspelled",i.setAttribute("data-word",t.word),i.setAttribute("data-suggestions",t.suggestions.join(",")),i.setAttribute("title",`Suggestions: ${t.suggestions.join(", ")}`),i.style.borderBottom="2px wavy red",i.style.cursor="pointer",r.surroundContents(i)}catch{}}),ut())}function co(){const n=document.querySelector('[contenteditable="true"]');n&&n.querySelectorAll(".rte-misspelled").forEach(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})}function fi(n,e){const t=document.createRange();t.setStart(n.node,n.startOffset),t.setEnd(n.node,n.endOffset);const o=document.createTextNode(e);t.deleteContents(),t.insertNode(o)}function bi(n){jt.add(n.toLowerCase()),co(),Ut(),ut()}function xi(n){qt.add(n.toLowerCase()),Rc(),co(),Ut(),ut()}function Pc(n){const e=Vt();if(!e)return{total:0,misspelled:0,accuracy:100};n||(n=so());const t=n.filter(a=>!jt.has(a.word.toLowerCase())).length,i=((e.textContent||"").match(/[\p{L}\p{M}\p{N}]+/gu)||[]).length;return{total:i,misspelled:t,accuracy:i>0?(i-t)/i*100:100}}function Oc(n,e,t,o,r){document.querySelectorAll(".rte-spellcheck-menu").forEach(d=>d.remove());const i=document.createElement("div");if(i.className="rte-spellcheck-menu",i.style.cssText=`
3589
- position: fixed;
3590
- left: ${n}px;
3591
- top: ${e}px;
3592
- background: #fff;
3593
- border: 1px solid #ccc;
3594
- border-radius: 4px;
3595
- box-shadow: 0 2px 8px rgba(0,0,0,0.15);
3596
- z-index: 99999;
3597
- padding: 4px 0;
3598
- min-width: 160px;
3599
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
3600
- font-size: 13px;
3601
- `,o.slice(0,5).forEach(d=>{const p=document.createElement("div");p.className="rte-spellcheck-menu-item",p.textContent=d,p.style.cssText="padding: 6px 16px; cursor: pointer; transition: background 0.2s;",p.onmouseenter=()=>p.style.backgroundColor="#f0f0f0",p.onmouseleave=()=>p.style.backgroundColor="transparent",p.onclick=()=>{const g=r.parentNode;if(g){for(const m of g.childNodes)if(m.nodeType===Node.TEXT_NODE&&m.textContent?.includes(t)){const b=m.textContent.indexOf(t),x={node:m,startOffset:b,endOffset:b+t.length};fi(x,d);break}}i.remove()},i.appendChild(p)}),o.length>0){const d=document.createElement("div");d.style.cssText="height: 1px; background: #ddd; margin: 4px 0;",i.appendChild(d)}const a=document.createElement("div");a.className="rte-spellcheck-menu-item",a.textContent="Ignore Once",a.style.cssText="padding: 6px 16px; cursor: pointer; color: #666;",a.onmouseenter=()=>a.style.backgroundColor="#f0f0f0",a.onmouseleave=()=>a.style.backgroundColor="transparent",a.onclick=()=>{r.remove(),i.remove()},i.appendChild(a);const l=document.createElement("div");l.className="rte-spellcheck-menu-item",l.textContent="Ignore All",l.style.cssText="padding: 6px 16px; cursor: pointer; color: #666;",l.onmouseenter=()=>l.style.backgroundColor="#f0f0f0",l.onmouseleave=()=>l.style.backgroundColor="transparent",l.onclick=()=>{bi(t),i.remove()},i.appendChild(l);const c=document.createElement("div");c.className="rte-spellcheck-menu-item",c.textContent="Add to Dictionary",c.style.cssText="padding: 6px 16px; cursor: pointer; color: #1976d2;",c.onmouseenter=()=>c.style.backgroundColor="#f0f0f0",c.onmouseleave=()=>c.style.backgroundColor="transparent",c.onclick=()=>{xi(t),i.remove()},i.appendChild(c),document.body.appendChild(i);const s=d=>{i.contains(d.target)||(i.remove(),document.removeEventListener("mousedown",s))};setTimeout(()=>document.addEventListener("mousedown",s),0)}function $c(){document.addEventListener("contextmenu",n=>{const e=n.target;if(e&&e.classList.contains("rte-misspelled")){n.preventDefault();const t=e.getAttribute("data-word"),o=(e.getAttribute("data-suggestions")||"").split(",").filter(r=>r);Oc(n.clientX,n.clientY,t,o,e)}})}function Bc(){const n=document.createElement("div");return n.className="rte-spell-check-panel",n.style.cssText=`
3602
- position: fixed;
3603
- right: 0;
3604
- top: 0;
3605
- width: 350px;
3606
- height: 100vh;
3607
- background: white;
3608
- border-left: 1px solid #ddd;
3609
- box-shadow: -2px 0 4px rgba(0,0,0,0.1);
3610
- overflow-y: auto;
3611
- z-index: 10000;
3612
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
3613
- padding: 16px;
3614
- `,document.body.appendChild(n),n}function ut(){if(!ne)return;const n=so(),e=Pc(n);ne.innerHTML=`
3615
- <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
3616
- <h3 style="margin: 0; font-size: 16px; font-weight: 600;">Spell Check</h3>
3617
- <button class="rte-spellcheck-close" style="background: none; border: none; font-size: 22px; cursor: pointer; color: #888;">✕</button>
3618
- </div>
3619
-
3620
- <div style="display: flex; gap: 24px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid #eee;">
3621
- <div>
3622
- <div style="font-size: 12px; color: #999;">Total Words</div>
3623
- <div style="font-size: 16px; font-weight: 600; color: #333;">${e.total}</div>
3624
- </div>
3625
- <div>
3626
- <div style="font-size: 12px; color: #999;">Misspelled</div>
3627
- <div style="font-size: 16px; font-weight: 600; color: #d32f2f;">${e.misspelled}</div>
3628
- </div>
3629
- <div>
3630
- <div style="font-size: 12px; color: #999;">Accuracy</div>
3631
- <div style="font-size: 16px; font-weight: 600; color: #388e3c;">${e.accuracy.toFixed(1)}%</div>
3632
- </div>
3633
- </div>
3634
-
3635
- <div class="misspellings-list">
3636
- ${n.length===0?'<div style="padding: 12px; text-align: center; color: #999; font-size: 13px;">No spelling errors found</div>':n.map((o,r)=>`
3637
- <div class="misspelling-item" data-word="${o.word}" data-index="${r}" style="padding: 8px; margin-bottom: 8px; background-color: #f5f5f5; border-radius: 4px;">
3638
- <div class="word-header" style="display: flex; justify-content: space-between; align-items: center; cursor: pointer;">
3639
- <span style="font-weight: 600; color: #d32f2f;">${o.word}</span>
3640
- <button class="expand-btn" style="background: none; border: none; cursor: pointer; font-size: 12px; color: #666;">▶</button>
3641
- </div>
3642
- <div class="suggestions" style="display: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid #ddd;">
3643
- ${o.suggestions.length>0?`<div style="font-size: 12px; font-weight: 600; color: #333; margin-bottom: 6px;">Suggestions:</div>
3644
- ${o.suggestions.map(i=>`<button class="suggestion-btn" data-suggestion="${i}" style="display: inline-block; margin-right: 6px; margin-bottom: 6px; padding: 4px 8px; background-color: #1976d2; color: white; border: none; border-radius: 3px; font-size: 12px; cursor: pointer;">${i}</button>`).join("")}`:'<div style="font-size: 12px; color: #999; margin-bottom: 8px;">No suggestions</div>'}
3645
- <div style="margin-top: 8px; display: flex; gap: 6px;">
3646
- <button class="ignore-btn" style="font-size: 12px; padding: 4px 8px; background-color: white; border: 1px solid #ddd; border-radius: 3px; cursor: pointer;">Ignore</button>
3647
- <button class="add-btn" style="font-size: 12px; padding: 4px 8px; background-color: white; border: 1px solid #ddd; border-radius: 3px; cursor: pointer;">Add to Dictionary</button>
3648
- </div>
3649
- </div>
3650
- </div>
3651
- `).join("")}
3652
- </div>
3653
- `,ne.querySelector(".rte-spellcheck-close")?.addEventListener("click",()=>{yi()}),ne.querySelectorAll(".word-header").forEach((o,r)=>{o.addEventListener("click",()=>{const a=o.closest(".misspelling-item")?.querySelector(".suggestions"),l=o.querySelector(".expand-btn");a&&l&&(a.style.display==="none"?(a.style.display="block",l.textContent="▼"):(a.style.display="none",l.textContent="▶"))})}),ne.querySelectorAll(".suggestion-btn").forEach(o=>{o.addEventListener("click",()=>{const r=o.getAttribute("data-suggestion"),i=o.closest(".misspelling-item");i?.getAttribute("data-word");const a=parseInt(i?.getAttribute("data-index")||"0");n[a]&&fi(n[a],r)})}),ne.querySelectorAll(".ignore-btn").forEach(o=>{o.addEventListener("click",()=>{const i=o.closest(".misspelling-item")?.getAttribute("data-word");bi(i)})}),ne.querySelectorAll(".add-btn").forEach(o=>{o.addEventListener("click",()=>{const i=o.closest(".misspelling-item")?.getAttribute("data-word");xi(i)})})}function Fc(){const n=Vt();n&&(ze&&ze.disconnect(),ze=new MutationObserver(e=>{e.some(t=>t.type==="characterData"||t.type==="childList")&&(We&&clearTimeout(We),We=window.setTimeout(()=>{ot&&(Ut(),ut())},350))}),ze.observe(n,{characterData:!0,childList:!0,subtree:!0}))}function qc(){ze&&(ze.disconnect(),ze=null),We&&(clearTimeout(We),We=null)}function yi(){return ot=!ot,ot?(Ut(),$c(),Fc(),ne||(ne=Bc(),ut())):(co(),qc(),ne&&(ne.remove(),ne=null)),ot}const jc=()=>({name:"spellCheck",init:()=>{Nc()},toolbar:[{label:"Spell Check",command:"toggleSpellCheck",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M3 12.5L3.84375 9.5M3.84375 9.5L5 5.38889C5 5.38889 5.25 4.5 6 4.5C6.75 4.5 7 5.38889 7 5.38889L8.15625 9.5M3.84375 9.5H8.15625M9 12.5L8.15625 9.5M13 16.8333L15.4615 19.5L21 13.5M12 8.5H15C16.1046 8.5 17 7.60457 17 6.5C17 5.39543 16.1046 4.5 15 4.5H12V8.5ZM12 8.5H16C17.1046 8.5 18 9.39543 18 10.5C18 11.6046 17.1046 12.5 16 12.5H12V8.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"F7"}],commands:{toggleSpellCheck:()=>(yi(),!0)},keymap:{F7:"toggleSpellCheck"}}),Vc=new Set,uo=[],ke=n=>{uo.push(n)};ke({id:"image-alt-text",wcag:"1.1.1",description:"Images must have alt text",severity:"error",selector:"img",evaluate(n,e){const t=n;return t.hasAttribute("role")&&t.getAttribute("role")==="presentation"||t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="image-alt-text"?null:!t.hasAttribute("alt")||t.getAttribute("alt")?.trim()===""?{id:`img-alt-${e.cache.get("imgIdx")}`,rule:"image-alt-text",wcag:"1.1.1",severity:"error",message:"Image missing alt text",nodePath:e.cache.get("imgPath"),element:t,suggestion:"Add descriptive alt text to all images",fixable:!0,fixLabel:"Add empty alt"}:null},fix(n){n.element&&n.element.setAttribute("alt","")}});ke({id:"empty-interactive",wcag:"4.1.2",description:"Interactive elements must have accessible names",severity:"error",selector:'button, a, [role="button"]',evaluate(n,e){const t=n;if(t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="empty-interactive")return null;const o=t.textContent?.trim(),r=t.hasAttribute("aria-label"),i=t.hasAttribute("aria-labelledby"),a=t.hasAttribute("title");return!o&&!r&&!i&&!a?{id:`interactive-empty-${e.cache.get("buttonIdx")}`,rule:"empty-interactive",wcag:"4.1.2",severity:"error",message:"Interactive element has no accessible name",nodePath:e.cache.get("buttonPath"),element:t,suggestion:"Add text, aria-label, aria-labelledby, or title",fixable:!0,fixLabel:"Add aria-label"}:null},fix(n){n.element&&n.element.setAttribute("aria-label","Button")}});ke({id:"form-label",wcag:"1.3.1",description:"Form controls must have labels",severity:"error",selector:"input, textarea, select",evaluate(n,e){const t=n;if(t.hasAttribute("type")&&t.getAttribute("type")==="hidden"||t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="form-label")return null;const o=e.doc.querySelector(`label[for="${t.getAttribute("id")}"]`),r=t.hasAttribute("aria-label"),i=t.hasAttribute("aria-labelledby");return!o&&!r&&!i?{id:`form-label-${e.cache.get("inputIdx")}`,rule:"form-label",wcag:"1.3.1",severity:"error",message:"Form control missing label",nodePath:e.cache.get("inputPath"),element:t,suggestion:"Add <label>, aria-label, or aria-labelledby",fixable:!0,fixLabel:"Add aria-label"}:null},fix(n){n.element&&n.element.setAttribute("aria-label","Input")}});ke({id:"table-headers",wcag:"1.3.1",description:"Tables must have header rows",severity:"error",selector:"table",evaluate(n,e){const t=n;if(t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="table-headers")return null;const o=t.querySelectorAll("th"),r=t.querySelectorAll("tr");return o.length===0&&r.length>0?{id:`table-no-headers-${e.cache.get("tableIdx")}`,rule:"table-headers",wcag:"1.3.1",severity:"error",message:"Table missing header row (<th> elements)",nodePath:e.cache.get("tablePath"),element:t,suggestion:"Add <th> elements to first row",fixable:!0,fixLabel:"Convert first row to headers"}:null},fix(n){if(n.element){const t=n.element.querySelector("tr");t&&Array.from(t.children).forEach(o=>{if(o.tagName==="TD"){const r=document.createElement("th");r.innerHTML=o.innerHTML,t.replaceChild(r,o)}})}}});ke({id:"heading-empty",wcag:"1.3.1",description:"Headings must not be empty",severity:"error",selector:"h1, h2, h3, h4, h5, h6",evaluate(n,e){const t=n;if(t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="heading-empty")return null;const o=t.textContent?.replace(/\s+/g,"")||"",r=t.childNodes.length===1&&t.childNodes[0].nodeName==="BR";return!o&&!r?{id:`heading-empty-${e.cache.get("headingIdx")}`,rule:"heading-empty",wcag:"1.3.1",severity:"error",message:`Empty ${t.tagName.toLowerCase()} heading`,nodePath:e.cache.get("headingPath"),element:t,suggestion:"All headings must contain text",fixable:!1}:null}});ke({id:"heading-order",wcag:"1.3.1",description:"Headings should not skip levels",severity:"warning",selector:"h1, h2, h3, h4, h5, h6",evaluate(n,e){const t=n,o=parseInt(t.tagName[1]),r=e.cache.get("previousHeadingLevel")||o;return e.cache.set("previousHeadingLevel",o),o-r>1?{id:`heading-order-${e.cache.get("headingIdx")}`,rule:"heading-order",wcag:"1.3.1",severity:"warning",message:`Heading skips level (${r} → ${o})`,nodePath:e.cache.get("headingPath"),element:t,suggestion:`Use heading level ${r+1} instead`,fixable:!1}:null}});ke({id:"link-text",wcag:"2.4.4",description:"Links must have descriptive text",severity:"error",selector:"a",evaluate(n,e){const t=n;if(t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="link-text")return null;const o=t.textContent?.replace(/\s+/g,"").toLowerCase()||"",r=t.childNodes.length===1&&t.childNodes[0].nodeName==="BR",i=["clickhere","readmore","link","here","this","page"];return!o&&!r?{id:`link-empty-${e.cache.get("aIdx")}`,rule:"link-text",wcag:"2.4.4",severity:"error",message:"Link has no text content",nodePath:e.cache.get("aPath"),element:t,suggestion:"All links must have descriptive text",fixable:!0,fixLabel:"Insert placeholder"}:i.some(a=>o.includes(a))?{id:`link-vague-${e.cache.get("aIdx")}`,rule:"link-text",wcag:"2.4.4",severity:"warning",message:`Vague link text: "${t.textContent?.trim()}"`,nodePath:e.cache.get("aPath"),element:t,suggestion:"Use descriptive link text",fixable:!1}:null},fix(n){n.element&&(n.element.textContent="Link")}});ke({id:"list-structure",wcag:"1.3.1",description:"Lists must only contain <li> children",severity:"error",selector:"ul, ol",evaluate(n,e){const t=n;if(t.hasAttribute("data-a11y-ignore")&&t.getAttribute("data-a11y-ignore")==="list-structure")return null;const o=t.querySelectorAll(":scope > li");return Array.from(t.children).filter(i=>i.tagName!=="LI").length>0?{id:`list-structure-${e.cache.get("ulIdx")}`,rule:"list-structure",wcag:"1.3.1",severity:"error",message:"List contains non-li elements",nodePath:e.cache.get("ulPath"),element:t,suggestion:"All direct children of ul/ol must be li elements",fixable:!1}:o.length===0?{id:`list-empty-${e.cache.get("ulIdx")}`,rule:"list-structure",wcag:"1.3.1",severity:"warning",message:"Empty list element",nodePath:e.cache.get("ulPath"),element:t,suggestion:"Remove empty lists or add list items",fixable:!1}:null}});const Uc=()=>{const n=window.getSelection();if(n&&n.rangeCount>0){let t=n.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const o=t;if(o.getAttribute("contenteditable")==="true")return o}t=t.parentNode}}const e=document.activeElement;if(e){if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');if(t)return t}return document.querySelector('[contenteditable="true"]')},vi=()=>{const n=Uc();if(!n)return[];const e=[],t={doc:n.ownerDocument||document,cache:new Map},o=t.doc.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,null);let r=o.currentNode,i={},a={},l=0;for(;r&&l<5e3;){const c=r,s=c.tagName?.toLowerCase?.()||"";if(c.hidden||c.style.display==="none"||c.style.visibility==="hidden"){r=o.nextNode(),l++;continue}i[s]=(i[s]||0)+1,a[s]=`${s}[${i[s]-1}]`;for(const d of uo){if(Vc.has(d.id)||d.selector&&!r.matches?.(d.selector))continue;t.cache.set(`${s}Idx`,i[s]-1),t.cache.set(`${s}Path`,a[s]),/^h[1-6]$/.test(s)&&(t.cache.set("headingIdx",i[s]-1),t.cache.set("headingPath",a[s])),s==="a"&&(t.cache.set("aIdx",i[s]-1),t.cache.set("aPath",a[s])),s==="table"&&(t.cache.set("tableIdx",i[s]-1),t.cache.set("tablePath",a[s])),s==="button"&&(t.cache.set("buttonIdx",i[s]-1),t.cache.set("buttonPath",a[s])),s==="input"&&(t.cache.set("inputIdx",i[s]-1),t.cache.set("inputPath",a[s])),(s==="ul"||s==="ol")&&(t.cache.set("ulIdx",i[s]-1),t.cache.set("ulPath",a[s]));const p=d.evaluate(r,t);p&&e.push(p)}r=o.nextNode(),l++}return e},je=(n,e=!0)=>{n.element&&(e?(n.element.classList.add("a11y-highlighted"),n.element.style.outline="2px solid #ff9800",n.element.style.backgroundColor="#fff3cd"):(n.element.classList.remove("a11y-highlighted"),n.element.style.outline="",n.element.style.backgroundColor=""))},Wc=n=>{n||(n=vi());const e=n.filter(r=>r.severity==="error").length,t=n.filter(r=>r.severity==="warning").length;let o=100-e*20-t*5;return Math.max(0,o)},Gc=n=>{const e=uo.find(t=>t.id===n.rule);e&&e.fix&&e.fix(n)},wi=()=>{const n=vi(),e=Wc(n),t=document.createElement("div");t.className="a11y-dialog-overlay",t.style.cssText=`
3654
- position: fixed;
3655
- top: 0;
3656
- left: 0;
3657
- right: 0;
3658
- bottom: 0;
3659
- background: rgba(0, 0, 0, 0.5);
3660
- z-index: 10000;
3661
- display: flex;
3662
- align-items: center;
3663
- justify-content: center;
3664
- `;const o=document.createElement("div");o.className="a11y-dialog",o.style.cssText=`
3665
- background: white;
3666
- border-radius: 8px;
3667
- max-width: 800px;
3668
- width: 90%;
3669
- max-height: 80vh;
3670
- display: flex;
3671
- flex-direction: column;
3672
- box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
3673
- `;const r=document.createElement("div");r.style.cssText=`
3674
- padding: 20px;
3675
- border-bottom: 1px solid #e0e0e0;
3676
- display: flex;
3677
- align-items: center;
3678
- justify-content: space-between;
3679
- `;const i=document.createElement("h2");i.style.cssText="margin: 0; font-size: 20px; font-weight: 600;",i.textContent="Accessibility Checker";const a=document.createElement("div");a.style.cssText=`
3680
- font-size: 24px;
3681
- font-weight: bold;
3682
- padding: 8px 16px;
3683
- border-radius: 4px;
3684
- background: ${e>=80?"#4caf50":e>=60?"#ff9800":"#f44336"};
3685
- color: white;
3686
- `,a.textContent=`${e}/100`;const l=document.createElement("button");l.textContent="✕",l.style.cssText=`
3687
- background: none;
3688
- border: none;
3689
- font-size: 24px;
3690
- cursor: pointer;
3691
- padding: 0;
3692
- width: 32px;
3693
- height: 32px;
3694
- display: flex;
3695
- align-items: center;
3696
- justify-content: center;
3697
- border-radius: 4px;
3698
- `,l.onmouseover=()=>l.style.background="#f0f0f0",l.onmouseout=()=>l.style.background="none",l.onclick=()=>{n.forEach(p=>je(p,!1)),t.remove()};const c=document.createElement("div");c.style.cssText="display: flex; align-items: center; gap: 16px;",c.appendChild(i),c.appendChild(a),r.appendChild(c),r.appendChild(l);const s=document.createElement("div");if(s.style.cssText=`
3699
- flex: 1;
3700
- overflow-y: auto;
3701
- padding: 20px;
3702
- `,n.length===0)s.innerHTML=`
3703
- <div style="text-align: center; padding: 40px 20px;">
3704
- <div style="font-size: 48px; margin-bottom: 16px;">✅</div>
3705
- <h3 style="margin: 0 0 8px 0; color: #4caf50;">No issues found!</h3>
3706
- <p style="margin: 0; color: #666;">Your content meets WCAG 2.1 AA standards.</p>
3707
- </div>
3708
- `;else{const p=document.createElement("div");p.style.cssText=`
3709
- background: #f5f5f5;
3710
- padding: 12px 16px;
3711
- border-radius: 6px;
3712
- margin-bottom: 20px;
3713
- display: flex;
3714
- gap: 20px;
3715
- `;const g=n.filter(x=>x.severity==="error").length,m=n.filter(x=>x.severity==="warning").length,b=n.filter(x=>x.severity==="info").length;p.innerHTML=`
3716
- <div><strong style="color: #f44336;">${g}</strong> <span style="color: #666;">Errors</span></div>
3717
- <div><strong style="color: #ff9800;">${m}</strong> <span style="color: #666;">Warnings</span></div>
3718
- <div><strong style="color: #2196f3;">${b}</strong> <span style="color: #666;">Info</span></div>
3719
- `,s.appendChild(p),n.forEach(x=>{const C=document.createElement("div");C.style.cssText=`
3720
- border: 1px solid #e0e0e0;
3721
- border-radius: 6px;
3722
- padding: 16px;
3723
- margin-bottom: 12px;
3724
- transition: all 0.2s;
3725
- `,C.onmouseover=()=>{C.style.borderColor="#2196f3",C.style.background="#f5f9ff",je(x,!0)},C.onmouseout=()=>{C.style.borderColor="#e0e0e0",C.style.background="white",je(x,!1)};const k=x.severity==="error"?"#f44336":x.severity==="warning"?"#ff9800":"#2196f3";if(C.innerHTML=`
3726
- <div style="display: flex; align-items: start; gap: 12px; margin-bottom: 8px;">
3727
- <span style="
3728
- background: ${k};
3729
- color: white;
3730
- padding: 2px 8px;
3731
- border-radius: 4px;
3732
- font-size: 12px;
3733
- font-weight: 600;
3734
- text-transform: uppercase;
3735
- ">${x.severity}</span>
3736
- <div style="flex: 1;">
3737
- <div style="font-weight: 600; margin-bottom: 4px;">${x.message}</div>
3738
- <div style="font-size: 12px; color: #666;">WCAG ${x.wcag} · ${x.rule}</div>
3739
- </div>
3740
- </div>
3741
- <div style="font-size: 14px; color: #444; margin-bottom: 8px; padding-left: 68px;">
3742
- ${x.suggestion||""}
3743
- </div>
3744
- `,x.fixable){const y=document.createElement("button");y.textContent=`🔧 ${x.fixLabel||"Auto-fix"}`,y.style.cssText=`
3745
- background: #2196f3;
3746
- color: white;
3747
- border: none;
3748
- padding: 6px 12px;
3749
- border-radius: 4px;
3750
- cursor: pointer;
3751
- font-size: 13px;
3752
- margin-left: 68px;
3753
- `,y.onmouseover=()=>y.style.background="#1976d2",y.onmouseout=()=>y.style.background="#2196f3",y.onclick=()=>{Gc(x),y.textContent="✓ Fixed",y.style.background="#4caf50",y.disabled=!0,y.style.cursor="not-allowed",je(x,!1),setTimeout(()=>{t.remove(),wi()},1e3)},C.appendChild(y)}s.appendChild(C)})}o.appendChild(r),o.appendChild(s),t.appendChild(o),document.body.appendChild(t),t.onclick=p=>{p.target===t&&(n.forEach(g=>je(g,!1)),t.remove())};const d=p=>{p.key==="Escape"&&(n.forEach(g=>je(g,!1)),t.remove(),document.removeEventListener("keydown",d))};document.addEventListener("keydown",d)},Zc=()=>({name:"a11yChecker",toolbar:[{label:"Accessibility",command:"toggleA11yChecker",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M9 6.82954C10.1652 6.4177 11 5.30646 11 4.00024C11 2.34339 9.65686 1.00024 8 1.00024C6.34315 1.00024 5 2.34339 5 4.00024C5 5.30646 5.83481 6.4177 7 6.82954V12.0002C7 13.6571 8.34315 15.0002 10 15.0002H14.9296C15.264 15.0002 15.5762 15.1673 15.7617 15.4455L18.4913 19.54C19.1914 20.5901 20.6772 20.7373 21.5696 19.8448L22.7071 18.7074C23.0976 18.3168 23.0976 17.6837 22.7071 17.2931C22.3166 16.9026 21.6834 16.9026 21.2929 17.2931L20.1554 18.4306L17.4258 14.3361C16.8694 13.5015 15.9327 13.0002 14.9296 13.0002H10C9.44772 13.0002 9 12.5525 9 12.0002V11.0002H15C15.5523 11.0002 16 10.5525 16 10.0002C16 9.44796 15.5523 9.00025 15 9.00025H9V6.82954ZM8 5.10758C7.38844 5.10758 6.89267 4.61181 6.89267 4.00024C6.89267 3.38868 7.38844 2.89291 8 2.89291C8.61157 2.89291 9.10734 3.38868 9.10734 4.00024C9.10734 4.61181 8.61157 5.10758 8 5.10758Z" fill="#0F0F0F"></path> <path d="M4.6328 9.07414C5.10517 8.78987 5.69738 9.0279 5.91645 9.53381C6.13552 10.0397 5.89604 10.6205 5.43795 10.9272C4.92993 11.2673 4.48018 11.6911 4.10882 12.1826C3.53598 12.9408 3.16922 13.8345 3.04425 14.7765C2.91928 15.7185 3.04036 16.6768 3.3957 17.5582C3.75103 18.4395 4.32852 19.2138 5.07194 19.8058C5.81535 20.3977 6.69937 20.787 7.63791 20.9359C8.57646 21.0847 9.53756 20.988 10.4276 20.6552C11.3177 20.3223 12.1065 19.7647 12.7171 19.0366C13.1129 18.5645 13.4251 18.0313 13.6428 17.46C13.8391 16.9448 14.3514 16.5813 14.8936 16.6815C15.4357 16.7816 15.8004 17.3054 15.6291 17.8295C15.3326 18.7372 14.8644 19.583 14.2468 20.3194C13.4147 21.3117 12.3399 22.0716 11.1269 22.5252C9.91394 22.9787 8.6042 23.1105 7.32518 22.9077C6.04617 22.7048 4.84148 22.1742 3.82838 21.3676C2.81528 20.561 2.02831 19.5058 1.54407 18.3047C1.05983 17.1037 0.894836 15.7977 1.06514 14.5139C1.23545 13.2302 1.73525 12.0124 2.51589 10.9791C3.09523 10.2123 3.81459 9.56654 4.6328 9.07414Z" fill="#0F0F0F"></path> </g></svg>',shortcut:"Mod-Shift-Alt-a"}],commands:{toggleA11yChecker:()=>{try{return wi(),!0}catch(n){return console.error("Failed to open accessibility checker:",n),!1}}},keymap:{"Mod-Shift-Alt-a":"toggleA11yChecker"}});exports.A11yCheckerPlugin=Zc;exports.AnchorPlugin=Gl;exports.BackgroundColorPlugin=dl;exports.BlockquotePlugin=Zi;exports.BoldPlugin=_i;exports.CapitalizationPlugin=bl;exports.ChecklistPlugin=qi;exports.ClearFormattingPlugin=Ki;exports.CodePlugin=sa;exports.CodeSamplePlugin=_s;exports.CommentsPlugin=Mc;exports.DirectionPlugin=fl;exports.DocumentManagerPlugin=rs;exports.EmbedIframePlugin=zl;exports.EmojisPlugin=Tl;exports.FontFamilyPlugin=Ba;exports.FontSizePlugin=Pa;exports.FootnotePlugin=Ls;exports.FullscreenPlugin=xs;exports.HeadingPlugin=Di;exports.HistoryPlugin=Vi;exports.IndentPlugin=hl;exports.ItalicPlugin=Pi;exports.LineHeightPlugin=gl;exports.LinkPlugin=Gi;exports.ListPlugin=Bi;exports.MathPlugin=vl;exports.MediaManagerPlugin=Ql;exports.MergeTagPlugin=Ps;exports.PageBreakPlugin=Ts;exports.PreviewPlugin=gs;exports.PrintPlugin=vs;exports.SpecialCharactersPlugin=El;exports.SpellCheckPlugin=jc;exports.StrikethroughPlugin=$i;exports.TablePlugin=Ha;exports.TemplatePlugin=wc;exports.TextAlignmentPlugin=Wa;exports.TextColorPlugin=tl;exports.UnderlinePlugin=Oi;exports.buildApiUrl=oi;exports.getApiHeaders=ss;exports.getApiUrl=ls;exports.getDocumentManagerConfig=ro;exports.getGlobalApiConfig=oo;exports.getGlobalApiHeaders=ni;exports.getMediaManagerConfig=os;exports.purify_es=pc;exports.setDocumentManagerConfig=as;exports.setGlobalApiConfig=es;exports.setMediaManagerConfig=ns;