@editora/core 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CodePlugin.native-BH-K4xmW.mjs → CodePlugin.native-BcVqm5MS.mjs} +64 -65
- package/dist/{CodePlugin.native-hNgfXlfS.mjs → CodePlugin.native-Rgxx2Igx.mjs} +2708 -1225
- package/dist/{DocumentManagerPlugin.native-iFip6s4Q.mjs → DocumentManagerPlugin.native-B8K-Oqom.mjs} +12 -11
- package/dist/{PreviewPlugin.native-CiR51jql.mjs → PreviewPlugin.native-Dyht8mGi.mjs} +48 -51
- package/dist/{TablePlugin.native-BjIxYZ2X.mjs → TablePlugin.native-C1YZ372P.mjs} +156 -147
- package/dist/TemplatePlugin.native-BDV2eik2.mjs +628 -0
- package/dist/{documentManager-BcBIv5P-.mjs → documentManager-BWK_-KJp.mjs} +524 -526
- package/dist/editora.min.js +17 -17
- package/dist/editora.umd.js +22 -22
- package/dist/index-CclXYzUB.js +12 -0
- package/dist/{index-XsYC_KdJ.mjs → index-DeUjxpKd.mjs} +406 -386
- package/dist/index.cjs.js +10 -10
- package/dist/index.esm.js +78 -67
- package/dist/plugin-loader.js +4 -4
- package/dist/purify.es-BHa5gZB7.mjs +1481 -0
- package/dist/sanitizeHtml-DA0ajC6k.mjs +17 -0
- package/dist/webcomponent-core.js +376 -362
- package/dist/webcomponent-core.min.js +91 -89
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +2 -2
- package/dist/webcomponent.js +382 -368
- package/dist/webcomponent.min.js +968 -967
- package/index.d.ts +9 -0
- package/package.json +1 -1
- package/dist/TemplatePlugin.native-D6n5RUnC.mjs +0 -1176
- package/dist/index-_eKRBZPq.js +0 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";class Lt{constructor(t,e,o){this.doc=t,this.selection=e,this.schema=o}static create(t,e){const o=e||t.node("doc",{},[t.node("paragraph")]);return new Lt(o,{anchor:0,head:0},t)}apply(t,e){return new Lt(t,e||this.selection,this.schema)}}class So{constructor(t,e){this.nodes=new Map(Object.entries(t)),this.marks=new Map(Object.entries(e))}node(t,e,o){return{type:t,attrs:e,content:o}}text(t,e){return{type:"text",text:t,marks:e}}}class Ae{constructor(){this.plugins=[],this.pluginConfigs=new Map}register(t,e){this.plugins.push(t),e&&this.pluginConfigs.set(t.name,e);const o=this.pluginConfigs.get(t.name)||t.config;if(t.initialize)try{t.initialize(o)}catch(i){console.error(`Failed to initialize plugin "${t.name}":`,i)}if(t.init&&t.init!==t.initialize)try{t.init(o)}catch(i){console.error(`Failed to run init hook for plugin "${t.name}":`,i)}}unregister(t){const e=this.plugins.findIndex(o=>o.name===t);if(e>-1){const o=this.plugins[e];o.destroy&&o.destroy(),this.plugins.splice(e,1),this.pluginConfigs.delete(t)}}getPlugin(t){return this.plugins.find(e=>e.name===t)}getPluginConfig(t){return this.pluginConfigs.get(t)}buildSchema(){const t={},e={};return this.plugins.forEach(o=>{o.nodes&&Object.assign(t,o.nodes),o.marks&&Object.assign(e,o.marks)}),new So(t,e)}getCommands(){const t={};return this.plugins.forEach(e=>{e.commands&&Object.assign(t,e.commands)}),t}getToolbarItems(){return this.plugins.flatMap(t=>t.toolbar||[])}async executePluginCommand(t,e,...o){const i=this.getPlugin(t);if(!i)throw new Error(`Plugin not found: ${t}`);const r=this.getPluginConfig(t)||i.config||{},l=r.mode||"local";try{switch(l){case"local":return i.executeLocal?i.executeLocal(e,...o):null;case"api":if(!i.executeAPI)throw new Error(`Plugin ${t} does not support API mode`);return await i.executeAPI(e,...o);case"hybrid":if(i.executeHybrid)return await i.executeHybrid(e,...o);try{if(i.executeAPI)return await i.executeAPI(e,...o)}catch(c){if(console.warn(`API execution failed for ${t}, falling back to local`,c),i.executeLocal&&r.fallbackToLocal!==!1)return i.executeLocal(e,...o);throw c}break;default:throw new Error(`Unknown plugin mode: ${l}`)}}catch(c){throw console.error(`Error executing command ${e} on plugin ${t}:`,c),c}}async destroyAll(){const t=this.plugins.filter(e=>e.destroy).map(e=>e.destroy());await Promise.all(t),this.plugins=[],this.pluginConfigs.clear()}}function kn(){return new Ae}class _o{constructor(t){this.shortcuts=new Map,this.enabled=!0,this.isMac=typeof navigator!="undefined"&&navigator.platform.toUpperCase().indexOf("MAC")>=0,(t==null?void 0:t.enabled)===!1&&(this.enabled=!1),this.registerDefaultShortcuts(),t!=null&&t.shortcuts&&t.shortcuts.forEach(e=>this.registerShortcut(e)),t!=null&&t.customShortcuts&&Object.values(t.customShortcuts).forEach(e=>{this.registerShortcut(e)})}registerDefaultShortcuts(){this.registerShortcut({key:"b",ctrl:!this.isMac,meta:this.isMac,command:"toggleBold",description:"Bold",preventDefault:!0}),this.registerShortcut({key:"i",ctrl:!this.isMac,meta:this.isMac,command:"toggleItalic",description:"Italic",preventDefault:!0}),this.registerShortcut({key:"u",ctrl:!this.isMac,meta:this.isMac,command:"toggleUnderline",description:"Underline",preventDefault:!0}),this.registerShortcut({key:"d",ctrl:!this.isMac,meta:this.isMac,command:"toggleStrikethrough",description:"Strikethrough",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,command:"undo",description:"Undo",preventDefault:!0}),this.registerShortcut({key:"z",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"redo",description:"Redo",preventDefault:!0}),this.registerShortcut({key:"y",ctrl:!this.isMac,meta:this.isMac,command:"redo",description:"Redo",preventDefault:!0});for(let t=1;t<=6;t++)this.registerShortcut({key:String(t),ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:`h${t}`,description:`Heading ${t}`,preventDefault:!0});this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"setBlockType",params:"p",description:"Paragraph",preventDefault:!0}),this.registerShortcut({key:"7",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleOrderedList",description:"Numbered List",preventDefault:!0}),this.registerShortcut({key:"8",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBulletList",description:"Bullet List",preventDefault:!0}),this.registerShortcut({key:"k",ctrl:!this.isMac,meta:this.isMac,command:"openLinkDialog",description:"Insert/Edit Link",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertCodeBlock",description:"Code Block",preventDefault:!0}),this.registerShortcut({key:"q",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleBlockquote",description:"Blockquote",preventDefault:!0}),this.registerShortcut({key:"l",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"left",description:"Align Left",preventDefault:!0}),this.registerShortcut({key:"e",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"setTextAlignment",params:"center",description:"Align Center",preventDefault:!0}),this.registerShortcut({key:"r",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"right",description:"Align Right",preventDefault:!0}),this.registerShortcut({key:"j",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"setTextAlignment",params:"justify",description:"Justify",preventDefault:!0}),this.registerShortcut({key:"\\",ctrl:!this.isMac,meta:this.isMac,command:"clearFormatting",description:"Clear Formatting",preventDefault:!0}),this.registerShortcut({key:"]",ctrl:!this.isMac,meta:this.isMac,command:"increaseIndent",description:"Indent",preventDefault:!0}),this.registerShortcut({key:"[",ctrl:!this.isMac,meta:this.isMac,command:"decreaseIndent",description:"Outdent",preventDefault:!0}),this.registerShortcut({key:"g",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertImage",description:"Insert Image",preventDefault:!0}),this.registerShortcut({key:"t",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertTable",description:"Insert Table",preventDefault:!0}),this.registerShortcut({key:"f11",command:"toggleFullscreen",description:"Toggle Fullscreen",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"togglePreview",description:"Preview",preventDefault:!0}),this.registerShortcut({key:"p",ctrl:!this.isMac,meta:this.isMac,command:"print",description:"Print",preventDefault:!0}),this.registerShortcut({key:"s",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"insertSpecialCharacter",description:"Insert Special Character",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"insertEmoji",description:"Insert Emoji",preventDefault:!0}),this.registerShortcut({key:"9",ctrl:!this.isMac,meta:this.isMac,shift:!0,command:"toggleChecklist",description:"Checklist",preventDefault:!0}),this.registerShortcut({key:"a",ctrl:!this.isMac,meta:this.isMac,shift:!0,alt:!0,command:"toggleA11yChecker",description:"Accessibility Checker",preventDefault:!0}),this.registerShortcut({key:"F7",command:"toggleSpellCheck",description:"Spell Check",preventDefault:!0}),this.registerShortcut({key:"m",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertMath",description:"Insert Math",preventDefault:!0}),this.registerShortcut({key:"f",ctrl:!this.isMac,meta:this.isMac,alt:!0,command:"insertFootnote",description:"Insert Footnote",preventDefault:!0})}registerShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.set(e,t)}unregisterShortcut(t){const e=this.getShortcutKey(t);this.shortcuts.delete(e)}getShortcutKey(t){const e=[];return t.ctrl&&e.push("ctrl"),t.alt&&e.push("alt"),t.shift&&e.push("shift"),t.meta&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}getEventKey(t){const e=[];return t.ctrlKey&&e.push("ctrl"),t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),t.metaKey&&e.push("meta"),e.push(t.key.toLowerCase()),e.join("+")}handleKeyDown(t,e){if(!this.enabled)return!1;const o=this.getEventKey(t),i=this.shortcuts.get(o);return i?(i.preventDefault!==!1&&(t.preventDefault(),t.stopPropagation()),e(i.command,i.params),!0):!1}enable(){this.enabled=!0}disable(){this.enabled=!1}isEnabled(){return this.enabled}getAllShortcuts(){return Array.from(this.shortcuts.values())}getShortcutForCommand(t){return Array.from(this.shortcuts.values()).find(e=>e.command===t)}getShortcutDescription(t){const e=[];this.isMac?(t.meta&&e.push("⌘"),t.ctrl&&e.push("⌃"),t.alt&&e.push("⌥"),t.shift&&e.push("⇧")):(t.ctrl&&e.push("Ctrl"),t.alt&&e.push("Alt"),t.shift&&e.push("Shift"));const o=t.key.length===1?t.key.toUpperCase():t.key;return e.push(o),e.join("+")}getShortcutsHelp(){const t=this.getAllShortcuts(),e=new Map;t.forEach(i=>{const r=this.getShortcutCategory(i.command);e.has(r)||e.set(r,[]),e.get(r).push(i)});let o=`# Keyboard Shortcuts
|
|
2
|
+
|
|
3
|
+
`;return e.forEach((i,r)=>{o+=`## ${r}
|
|
4
|
+
|
|
5
|
+
`,i.forEach(l=>{const c=this.getShortcutDescription(l);o+=`- **${c}**: ${l.description||l.command}
|
|
6
|
+
`}),o+=`
|
|
7
|
+
`}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}class Lo{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Mo{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new Ae,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=Lt.create(e),this.commandRegistry=new Lo(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let i;return e.length===0?i=o(this.state):e.length===1?i=o(this.state,e[0]):i=o(this.state,...e),i instanceof Promise?(i.then(r=>{r&&typeof r=="object"&&"doc"in r&&"selection"in r&&(this.setState(r),this.emit("change",this.state))}).catch(r=>{console.error(`Async command failed: ${t}`,r)}),!0):i&&typeof i=="object"&&"doc"in i&&"selection"in i?(this.setState(i),this.emit("change",this.state),!0):i!==!1&&i!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const i=o.indexOf(e);i>-1&&o.splice(i,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(i=>{try{i(...e)}catch(r){console.error(`Error in ${t} handler:`,r)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class Io{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=i=>{var l,c;if(!this.expandedOpen)return;const r=i.target;r&&((l=this.moreButton)!=null&&l.contains(r)||(c=this.expandedRow)!=null&&c.contains(r))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),i=this.getAvailableToolbarItems(),r=new Map;i.forEach(c=>{c.command&&r.set(c.command,c),c.type==="group"&&c.label&&r.set(c.label,c)});const l={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const p=[];c.split(/\s+/).filter(Boolean).forEach(v=>{if(v==="direction"){const T=r.get("setDirectionLTR"),E=r.get("setDirectionRTL");T&&p.push({id:"directionLTR",label:T.label,command:T.command,icon:T.icon,type:T.type||"button",options:T.options}),E&&p.push({id:"directionRTL",label:E.label,command:E.command,icon:E.icon,type:E.type||"button",options:E.options});return}if(v==="comments"){const T=r.get("addComment"),E=r.get("toggleComments");T&&p.push({id:"addComment",label:T.label,command:T.command,icon:T.icon,type:T.type||"button",options:T.options}),E&&p.push({id:"toggleComments",label:E.label,command:E.command,icon:E.icon,type:E.type||"button",options:E.options});return}const C=l[v]||v;let A=r.get(C);A||(A=r.get(v)),A&&p.push({id:v,label:A.label,command:A.command,icon:A.icon,type:A.type==="separator"?"separator":A.type||"button",options:A.options,items:A.items})}),p.length>0&&e.push(p)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),i=this.parseToolbarString(o);i.forEach((r,l)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",r.forEach(p=>{this.appendToolbarButton(c,p);const m=c.lastElementChild;m instanceof HTMLElement&&(this.overflowUnits.push(m),this.overflowUnitHomes.set(m,c))}),e.appendChild(c),l<i.length-1){const p=document.createElement("div");p.className="editora-toolbar-separator",e.appendChild(p)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const i=document.createElement("div");i.className="editora-toolbar-expanded-row",this.expandedRow=i,t.appendChild(i),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const r=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(D=>{var N;D.parentElement===i&&((N=this.overflowUnitHomes.get(D))==null||N.appendChild(D))});const p=t.clientWidth,m=16,v=40,C=4,A=Math.max(0,p-m-v-C);let T=0,E=0;for(const D of c){const N=D.getBoundingClientRect().width+C;if(T+N<=A)T+=N,E++;else break}E=Math.max(1,Math.min(E,c.length));const K=E<c.length;o.style.display=K?"":"none",o.classList.toggle("active",K&&this.expandedOpen),!K&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((D,N)=>{N>=E&&i.appendChild(D)})},l=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(r)};this.resizeObserver=new ResizeObserver(()=>l()),this.resizeObserver.observe(t),l()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const i=document.createElement("span");i.className="editora-toolbar-icon",i.innerHTML=t.icon,e.appendChild(i)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const i=document.createElement("div");i.className=`editora-toolbar-group-items ${o}`,t.items.forEach(r=>{this.appendToolbarButton(i,r)}),e.appendChild(i)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const p=document.createElement("button");p.className="editora-toolbar-dropdown-item",p.type="button",p.textContent=c.label,p.setAttribute("data-value",c.value),p.addEventListener("click",m=>{m.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(p)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const p=i.style.display==="block";i.style.display=p?"none":"block"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const i=document.createElement("div");i.className="editora-toolbar-dropdown-menu",i.style.display="none",t.options&&t.options.forEach(c=>{const p=document.createElement("button");p.className="editora-toolbar-dropdown-item",p.type="button",p.textContent=c.label,p.setAttribute("data-value",c.value),p.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),i.style.display="none"}),i.appendChild(p)}),o.addEventListener("click",c=>{var m;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const p=(m=this.container)==null?void 0:m.querySelectorAll(".editora-toolbar-dropdown-menu");p==null||p.forEach(v=>{v!==i&&(v.style.display="none")}),i.style.display=i.style.display==="none"?"block":"none"});const r=c=>{e.contains(c.target)||(i.style.display="none")},l=c=>{c.key==="Escape"&&(i.style.display="none")};return document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l)},e.appendChild(o),e.appendChild(i),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const i=o._cleanupDropdown;i&&i()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class Oo{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Do{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const r=this.statusInfo.selectionInfo;r.startLine===r.endLine&&r.startColumn===r.endColumn?o.push(`Ln ${r.startLine}, Col ${r.startColumn}`):(r.startLine===r.endLine?o.push(`Ln ${r.startLine}, Col ${r.startColumn}-${r.endColumn}`):o.push(`Ln ${r.startLine}:${r.startColumn} - ${r.endLine}:${r.endColumn}`),o.push(`${r.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const r=this.statusInfo.cursorPosition;o.push(`Ln ${r.line}, Col ${r.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const i=[];this.statusInfo.wordCount!==void 0&&i.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&i.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&i.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([r,l])=>{i.push(`${r}: ${l}`)}),o.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,t.appendChild(c),l<o.length-1){const p=document.createElement("span");p.className="editora-statusbar-separator",p.textContent="|",t.appendChild(p)}}),i.forEach((r,l)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=r,e.appendChild(c),l<i.length-1){const p=document.createElement("span");p.className="editora-statusbar-separator",p.textContent="|",e.appendChild(p)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}function Ro(s,t){const e=s.textContent||"",o=No(s,t.startContainer,t.startOffset),r=e.substring(0,o).split(`
|
|
8
|
+
`),l=r.length,c=r[r.length-1].length+1;return{line:l,column:c}}function No(s,t,e){var l;let o=0;const i=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);let r=i.firstChild();for(;r;){if(r===t){o+=e;break}else r.nodeType===Node.TEXT_NODE&&(o+=((l=r.textContent)==null?void 0:l.length)||0);r=i.nextNode()}return o}function Po(s){var o,i;const t=s.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let e=1;if(t.length>0){e=t.length;const r=t[t.length-1];(r.tagName==="BR"||((o=r.innerHTML)==null?void 0:o.trim())===""||((i=r.textContent)==null?void 0:i.trim())==="")&&e++}else{const l=(s.textContent||"").split(`
|
|
9
|
+
`).length;e=Math.max(1,l)}return e}function zo(s){const t=s.trim()?s.trim().split(/\s+/).length:0,e=s.length;return{words:t,chars:e}}function Bo(s,t){const e=s.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}function so(s,t){(t==null||t>s.length)&&(t=s.length);for(var e=0,o=Array(t);e<t;e++)o[e]=s[e];return o}function xn(s){if(Array.isArray(s))return s}function Cn(s,t){var e=s==null?null:typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e!=null){var o,i,r,l,c=[],p=!0,m=!1;try{if(r=(e=e.call(s)).next,t!==0)for(;!(p=(o=r.call(e)).done)&&(c.push(o.value),c.length!==t);p=!0);}catch(v){m=!0,i=v}finally{try{if(!p&&e.return!=null&&(l=e.return(),Object(l)!==l))return}finally{if(m)throw i}}return c}}function An(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
10
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sn(s,t){return xn(s)||Cn(s,t)||_n(s,t)||An()}function _n(s,t){if(s){if(typeof s=="string")return so(s,t);var e={}.toString.call(s).slice(8,-1);return e==="Object"&&s.constructor&&(e=s.constructor.name),e==="Map"||e==="Set"?Array.from(s):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?so(s,t):void 0}}const Fo=Object.entries,lo=Object.setPrototypeOf,Ln=Object.isFrozen,Mn=Object.getPrototypeOf,In=Object.getOwnPropertyDescriptor;let M=Object.freeze,I=Object.seal,gt=Object.create,Ho=typeof Reflect!="undefined"&&Reflect,we=Ho.apply,ke=Ho.construct;M||(M=function(t){return t});I||(I=function(t){return t});we||(we=function(t,e){for(var o=arguments.length,i=new Array(o>2?o-2:0),r=2;r<o;r++)i[r-2]=arguments[r];return t.apply(e,i)});ke||(ke=function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return new t(...o)});const it=L(Array.prototype.forEach),On=L(Array.prototype.lastIndexOf),co=L(Array.prototype.pop),xt=L(Array.prototype.push),Dn=L(Array.prototype.splice),yt=Array.isArray,_t=L(String.prototype.toLowerCase),he=L(String.prototype.toString),uo=L(String.prototype.match),Ct=L(String.prototype.replace),fo=L(String.prototype.indexOf),Rn=L(String.prototype.trim),Nn=L(Number.prototype.toString),Pn=L(Boolean.prototype.toString),po=typeof BigInt=="undefined"?null:L(BigInt.prototype.toString),ho=typeof Symbol=="undefined"?null:L(Symbol.prototype.toString),z=L(Object.prototype.hasOwnProperty),At=L(Object.prototype.toString),O=L(RegExp.prototype.test),X=zn(TypeError);function L(s){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];return we(s,t,o)}}function zn(s){return function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return ke(s,e)}}function y(s,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_t;if(lo&&lo(s,null),!yt(t))return s;let o=t.length;for(;o--;){let i=t[o];if(typeof i=="string"){const r=e(i);r!==i&&(Ln(t)||(t[o]=r),i=r)}s[i]=!0}return s}function Bn(s){for(let t=0;t<s.length;t++)z(s,t)||(s[t]=null);return s}function H(s){const t=gt(null);for(const o of Fo(s)){var e=Sn(o,2);const i=e[0],r=e[1];z(s,i)&&(yt(r)?t[i]=Bn(r):r&&typeof r=="object"&&r.constructor===Object?t[i]=H(r):t[i]=r)}return t}function Fn(s){switch(typeof s){case"string":return s;case"number":return Nn(s);case"boolean":return Pn(s);case"bigint":return po?po(s):"0";case"symbol":return ho?ho(s):"Symbol()";case"undefined":return At(s);case"function":case"object":{if(s===null)return At(s);const t=s,e=j(t,"toString");if(typeof e=="function"){const o=e(t);return typeof o=="string"?o:At(o)}return At(s)}default:return At(s)}}function j(s,t){for(;s!==null;){const o=In(s,t);if(o){if(o.get)return L(o.get);if(typeof o.value=="function")return L(o.value)}s=Mn(s)}function e(){return null}return e}function Hn(s){try{return O(s,""),!0}catch(t){return!1}}const mo=M(["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","search","section","select","shadow","slot","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"]),me=M(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ge=M(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Un=M(["animate","color-profile","cursor","discard","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"]),be=M(["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","mprescripts"]),jn=M(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),go=M(["#text"]),bo=M(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","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","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ye=M(["accent-height","accumulate","additive","alignment-baseline","amplitude","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","dominant-baseline","dur","edgemode","elevation","end","exponent","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","intercept","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","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","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","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","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"]),yo=M(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","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"]),$t=M(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Wn=I(/{{[\w\W]*|^[\w\W]*}}/g),$n=I(/<%[\w\W]*|^[\w\W]*%>/g),Gn=I(/\${[\w\W]*/g),Kn=I(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yn=I(/^aria-[\-\w]+$/),Eo=I(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qn=I(/^(?:\w+script|data):/i),Vn=I(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Xn=I(/^html$/i),Zn=I(/^[a-z][.\w]*(-[.\w]+)+$/i),vo=I(/<[/\w!]/g),To=I(/<[/\w]/g),Jn=I(/<\/no(script|embed|frames)/i),Qn=I(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Uo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],ti=M(y({},Uo)),ei=(function(){const s={};return it(Uo,t=>{s[t]=I(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),M(s)})(),oi=function(){return typeof window=="undefined"?null:window},ni=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(o=e.getAttribute(i));const r="dompurify"+(o?"#"+o:"");try{return t.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch(l){return console.warn("TrustedTypes policy "+r+" could not be created."),null}},wo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Z=function(t,e,o,i){return z(t,e)&&yt(t[e])?y(i.base?H(i.base):{},t[e],i.transform):o},Ee=function(t,e,o){const i=z(t,e)?t[e]:void 0;return i&&typeof i=="object"?H(i):o()};function jo(){let s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oi();const t=u=>jo(u);if(t.version="3.4.16",t.removed=[],!s||!s.document||s.document.nodeType!==F.document||!s.Element)return t.isSupported=!1,t;let e=s.document;const o=e,i=o.currentScript;s.DocumentFragment;const r=s.HTMLTemplateElement,l=s.Node,c=s.Element,p=s.NodeFilter;s.NamedNodeMap===void 0&&(s.NamedNodeMap||s.MozNamedAttrMap),s.HTMLFormElement;const m=s.DOMParser,v=s.trustedTypes,C=c.prototype,A=j(C,"cloneNode"),T=j(C,"remove"),E=j(C,"removeAttributeNode"),K=j(C,"nextSibling"),D=j(C,"childNodes"),N=j(C,"parentNode"),_e=j(C,"shadowRoot"),Vt=j(C,"attributes"),Q=l&&l.prototype?j(l.prototype,"nodeType"):null,at=l&&l.prototype?j(l.prototype,"nodeName"):null,Mt=l&&l.prototype?j(l.prototype,"ownerDocument"):null,Et=function(n){return Q?Q(n):n.nodeType},Xt=function(n){return at?at(n):n.nodeName};if(typeof r=="function"){const u=e.createElement("template");u.content&&u.content.ownerDocument&&(e=u.content.ownerDocument)}let P,tt="",Zt,Le=!1,vt=0;const Me=function(){if(vt>0)throw X('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},st=function(n){Me(),vt++;try{return P.createHTML(n)}finally{vt--}},qo=function(n){Me(),vt++;try{return P.createScriptURL(n)}finally{vt--}},Vo=function(){return Le||(Zt=ni(v,i),Le=!0),Zt},It=e,Jt=It.implementation,Ie=It.createNodeIterator,Xo=It.createDocumentFragment,Zo=It.getElementsByTagName,Jo=o.importNode;let w=wo();t.isSupported=typeof Fo=="function"&&typeof N=="function"&&Jt&&Jt.createHTMLDocument!==void 0;const Qo=Wn,tn=$n,en=Gn,on=Kn,nn=Yn,rn=qn,Oe=Vn,an=Zn;let De=Eo,k=null;const Qt=y({},[...mo,...me,...ge,...be,...go]);let x=null;const te=y({},[...bo,...ye,...yo,...$t]);let W=Object.seal(gt(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}})),Tt=null,Re=null;const Y=Object.seal(gt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ne=!0,ee=!0,Pe=!1,ze=!0,q=!1,et=!0,ot=!1,oe=!1,Ot=null,Dt=null,ne=!1,lt=!1,Rt=!1,Nt=!1,Be=!0,Fe=!1;const He="user-content-";let ie=!0,re=!1,ct={},dt=null;const Ue=y({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let je=null;const We=y({},["audio","video","img","source","image","track"]);let $e=null;const Ge=y({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pt="http://www.w3.org/1998/Math/MathML",zt="http://www.w3.org/2000/svg",$="http://www.w3.org/1999/xhtml";let ut=$,ae=!1,se=null;const sn=y({},[Pt,zt,$],he),Ke=M(["mi","mo","mn","ms","mtext"]);let le=y({},Ke);const Ye=M(["annotation-xml"]);let ce=y({},Ye);const ln=y({},["title","style","font","a","script"]);let wt=null;const cn=["application/xhtml+xml","text/html"],dn="text/html";let _=null,ft=null;const un=e.createElement("form"),qe=function(n){return n instanceof RegExp||n instanceof Function},de=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ft&&ft===n)return;(!n||typeof n!="object")&&(n={}),n=H(n),wt=cn.indexOf(n.PARSER_MEDIA_TYPE)===-1?dn:n.PARSER_MEDIA_TYPE,_=wt==="application/xhtml+xml"?he:_t,k=Z(n,"ALLOWED_TAGS",Qt,{transform:_}),x=Z(n,"ALLOWED_ATTR",te,{transform:_}),se=Z(n,"ALLOWED_NAMESPACES",sn,{transform:he}),$e=Z(n,"ADD_URI_SAFE_ATTR",Ge,{transform:_,base:Ge}),je=Z(n,"ADD_DATA_URI_TAGS",We,{transform:_,base:We}),dt=Z(n,"FORBID_CONTENTS",Ue,{transform:_}),Tt=Z(n,"FORBID_TAGS",H({}),{transform:_}),Re=Z(n,"FORBID_ATTR",H({}),{transform:_}),ct=z(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?H(n.USE_PROFILES):n.USE_PROFILES:!1,Ne=n.ALLOW_ARIA_ATTR!==!1,ee=n.ALLOW_DATA_ATTR!==!1,Pe=n.ALLOW_UNKNOWN_PROTOCOLS||!1,ze=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=n.SAFE_FOR_TEMPLATES||!1,et=n.SAFE_FOR_XML!==!1,ot=n.WHOLE_DOCUMENT||!1,lt=n.RETURN_DOM||!1,Rt=n.RETURN_DOM_FRAGMENT||!1,Nt=n.RETURN_TRUSTED_TYPE||!1,ne=n.FORCE_BODY||!1,Be=n.SANITIZE_DOM!==!1,Fe=n.SANITIZE_NAMED_PROPS||!1,ie=n.KEEP_CONTENT!==!1,re=n.IN_PLACE||!1,De=Hn(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:Eo,ut=typeof n.NAMESPACE=="string"?n.NAMESPACE:$,le=Ee(n,"MATHML_TEXT_INTEGRATION_POINTS",()=>y({},Ke)),ce=Ee(n,"HTML_INTEGRATION_POINTS",()=>y({},Ye));const a=Ee(n,"CUSTOM_ELEMENT_HANDLING",()=>gt(null));if(W=gt(null),z(a,"tagNameCheck")&&qe(a.tagNameCheck)&&(W.tagNameCheck=a.tagNameCheck),z(a,"attributeNameCheck")&&qe(a.attributeNameCheck)&&(W.attributeNameCheck=a.attributeNameCheck),z(a,"allowCustomizedBuiltInElements")&&typeof a.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=a.allowCustomizedBuiltInElements),I(W),q&&(ee=!1),Rt&&(lt=!0),ct&&(k=y({},go),x=gt(null),ct.html===!0&&(y(k,mo),y(x,bo)),ct.svg===!0&&(y(k,me),y(x,ye),y(x,$t)),ct.svgFilters===!0&&(y(k,ge),y(x,ye),y(x,$t)),ct.mathMl===!0&&(y(k,be),y(x,yo),y(x,$t))),Y.tagCheck=null,Y.attributeCheck=null,z(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?Y.tagCheck=n.ADD_TAGS:yt(n.ADD_TAGS)&&(k===Qt&&(k=H(k)),y(k,n.ADD_TAGS,_))),z(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?Y.attributeCheck=n.ADD_ATTR:yt(n.ADD_ATTR)&&(x===te&&(x=H(x)),y(x,n.ADD_ATTR,_))),z(n,"ADD_FORBID_CONTENTS")&&yt(n.ADD_FORBID_CONTENTS)&&(dt===Ue&&(dt=H(dt)),y(dt,n.ADD_FORBID_CONTENTS,_)),ie&&(k["#text"]=!0),ot&&y(k,["html","head","body"]),k.table&&(y(k,["tbody"]),delete Tt.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw X('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw X('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=P;P=n.TRUSTED_TYPES_POLICY;try{tt=st("")}catch(f){throw P=d,f}}else n.TRUSTED_TYPES_POLICY===null?(P=void 0,tt=""):(P===void 0&&(P=Vo()),P&&typeof tt=="string"&&(tt=st("")));M&&M(n),ft=n},Ve=y({},[...me,...ge,...Un]),Xe=y({},[...be,...jn]),fn=function(n,a,d){return a.namespaceURI===$?n==="svg":a.namespaceURI===Pt?n==="svg"&&(d==="annotation-xml"||le[d]):!!Ve[n]},pn=function(n,a,d){return a.namespaceURI===$?n==="math":a.namespaceURI===zt?n==="math"&&ce[d]:!!Xe[n]},hn=function(n,a,d){return a.namespaceURI===zt&&!ce[d]||a.namespaceURI===Pt&&!le[d]?!1:!Xe[n]&&(ln[n]||!Ve[n])},mn=function(n){let a=N(n);(!a||!a.tagName)&&(a={namespaceURI:ut,tagName:"template"});const d=_t(n.tagName),f=_t(a.tagName);return se[n.namespaceURI]?n.namespaceURI===zt?fn(d,a,f):n.namespaceURI===Pt?pn(d,a,f):n.namespaceURI===$?hn(d,a,f):!!(wt==="application/xhtml+xml"&&se[n.namespaceURI]):!1},V=function(n){xt(t.removed,{element:n});try{N(n).removeChild(n)}catch(a){if(T(n),!N(n))throw X("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ze=function(n,a,d){try{E(n,a)}catch(f){try{n.removeAttribute(d)}catch(h){}}},Bt=function(n){Ft(n);const a=D(n);if(a){const f=[];it(a,h=>{xt(f,h)}),it(f,h=>{try{T(h)}catch(g){}})}const d=Vt(n);if(d)for(let f=d.length-1;f>=0;--f){const h=d[f],g=h&&h.name;typeof g=="string"&&Ze(n,h,g)}},nt=function(n,a,d){if(!d)try{d=a.getAttributeNode(n)}catch(f){d=null}xt(t.removed,{attribute:d||null,from:a});try{d?E(a,d):a.removeAttribute(n)}catch(f){try{a.removeAttribute(n)}catch(h){}}if(n==="is")if(lt||Rt)try{V(a)}catch(f){}else try{a.setAttribute(n,"")}catch(f){}},gn=function(n){const a=Vt(n);if(a)for(let d=a.length-1;d>=0;--d){const f=a[d],h=f&&f.name;typeof h!="string"||x[_(h)]||Ze(n,f,h)}},Ft=function(n){const a=[n];for(;a.length>0;){const d=a.pop();Et(d)===F.element&&gn(d);const f=D(d);if(f)for(let h=f.length-1;h>=0;--h)a.push(f[h])}},Je=function(n,a){return et?n==="patchsrc"?!0:n==="for"&&a!=="label"&&a!=="output":!1},bn=function(n){if(!et)return;const a=[n];for(;a.length>0;){const d=a.pop(),f=Et(d);if(f===F.processingInstruction||f===F.comment&&O(To,d.data)){try{T(d)}catch(g){}continue}if(f===F.element){const g=d,b=_(Xt(d));try{g.hasAttribute&&g.hasAttribute("patchsrc")&&g.removeAttribute("patchsrc"),g.hasAttribute&&g.hasAttribute("for")&&Je("for",b)&&g.removeAttribute("for")}catch(S){}}const h=D(d);if(h)for(let g=h.length-1;g>=0;--g)a.push(h[g])}},Qe=function(n){let a=null,d=null;if(ne)n="<remove></remove>"+n;else{const g=uo(n,/^[\r\n\t ]+/);d=g&&g[0]}wt==="application/xhtml+xml"&&ut===$&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const f=P?st(n):n;if(ut===$)try{a=new m().parseFromString(f,wt)}catch(g){}if(!a||!a.documentElement){a=Jt.createDocument(ut,"template",null);try{a.documentElement.innerHTML=ae?tt:f}catch(g){}}const h=a.body||a.documentElement;return n&&d&&h.insertBefore(e.createTextNode(d),h.childNodes[0]||null),ut===$?Zo.call(a,ot?"html":"body")[0]:ot?a.documentElement:h},to=function(n){const a=Mt?Mt(n):n.ownerDocument;return Ie.call(a||n,n,p.SHOW_ELEMENT|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},Ht=function(n){return n=Ct(n,Qo," "),n=Ct(n,tn," "),n=Ct(n,en," "),n},ue=function(n){var a;n.normalize();const d=Mt?Mt(n):n.ownerDocument,f=Ie.call(d||n,n,p.SHOW_TEXT|p.SHOW_COMMENT|p.SHOW_CDATA_SECTION|p.SHOW_PROCESSING_INSTRUCTION,null);let h=f.nextNode();for(;h;)h.data=Ht(h.data),h=f.nextNode();const g=(a=n.querySelectorAll)===null||a===void 0?void 0:a.call(n,"template");g&&it(g,b=>{pt(b.content)&&ue(b.content)})},Ut=function(n){const a=at?at(n):null;return typeof a!="string"||_(a)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==Vt(n)||typeof n.removeAttribute!="function"||typeof n.removeAttributeNode!="function"||typeof n.getAttributeNode!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==Q(n)||n.childNodes!==D(n)},pt=function(n){if(!Q||typeof n!="object"||n===null)return!1;try{return Q(n)===F.documentFragment}catch(a){return!1}},kt=function(n){if(!Q||typeof n!="object"||n===null)return!1;try{return typeof Q(n)=="number"}catch(a){return!1}};function G(u,n,a){u.length!==0&&it(u,d=>{d.call(t,n,a,ft)})}const yn=function(n,a){return!!(et&&n.hasChildNodes()&&!kt(n.firstElementChild)&&O(vo,n.textContent)&&O(vo,n.innerHTML)||et&&n.namespaceURI===$&&ti[a]&&(kt(n.firstElementChild)||typeof n.textContent=="string"&&O(ei[a],n.textContent))||n.nodeType===F.processingInstruction||et&&n.nodeType===F.comment&&O(To,n.data))},jt=function(n,a){if(n instanceof RegExp)return O(n,a);if(n instanceof Function){for(var d=arguments.length,f=new Array(d>2?d-2:0),h=2;h<d;h++)f[h-2]=arguments[h];return!!n(a,...f)}return!1},En=function(n,a,d){if(!Tt[a]&&io(a)&&jt(W.tagNameCheck,a))return!1;if(ie&&!dt[a]){const f=N(n),h=D(n);if(h&&f){const g=h.length;for(let b=g-1;b>=0;--b){const S=n===d?A(h[b],!0):h[b];f.insertBefore(S,K(n))}}}return V(n),!0},eo=function(n,a,d,f){return n.length===0?a:a===d||a===f?H(a):a},ht=function(n,a){return n===a||N(n)!==null?!1:(re&&Ft(n),!0)},oo=function(n,a){if(G(w.beforeSanitizeElements,n,null),ht(n,a))return!0;if(Ut(n))return V(n),!0;const d=_(Xt(n));if(k=eo(w.uponSanitizeElement,k,Qt,Ot),G(w.uponSanitizeElement,n,{tagName:d,allowedTags:k}),ht(n,a))return!0;if(yn(n,d))return V(n),!0;if(Tt[d]||!(Y.tagCheck instanceof Function&&Y.tagCheck(d))&&!k[d]){const f=En(n,d,a);return f===!1&&(G(w.afterSanitizeElements,n,null),ht(n,a))?!0:f}if(Et(n)===F.element&&!mn(n)||(d==="noscript"||d==="noembed"||d==="noframes")&&O(Jn,n.innerHTML))return V(n),!0;if(q&&n.nodeType===F.text){const f=Ht(n.textContent);n.textContent!==f&&(xt(t.removed,{element:n.cloneNode()}),n.textContent=f)}return G(w.afterSanitizeElements,n,null),ht(n,a)},no=function(n,a,d){if(Re[a]||Je(a,n)||Be&&(a==="id"||a==="name")&&(d in e||d in un))return!1;const f=x[a]||Y.attributeCheck instanceof Function&&Y.attributeCheck(a,n);return ee&&O(on,a)||Ne&&O(nn,a)?!0:f?$e[a]||O(De,Ct(d,Oe,""))||(a==="src"||a==="xlink:href"||a==="href")&&n!=="script"&&fo(d,"data:")===0&&je[n]||Pe&&!O(rn,Ct(d,Oe,""))?!0:!d:io(n)&&jt(W.tagNameCheck,n)&&jt(W.attributeNameCheck,a,n)||a==="is"&&W.allowCustomizedBuiltInElements&&jt(W.tagNameCheck,d)},vn=y({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),io=function(n){return!vn[_t(n)]&&O(an,n)},Tn=function(n,a,d,f){if(P&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!d)switch(v.getAttributeType(n,a)){case"TrustedHTML":return st(f);case"TrustedScriptURL":return qo(f)}return f},wn=function(n,a,d,f){try{return d?n.setAttributeNS(d,a,f):n.setAttribute(a,f),Ut(n)?(V(n),!1):!0}catch(h){return nt(a,n),!1}},ro=function(n,a){if(G(w.beforeSanitizeAttributes,n,null),ht(n,a))return;const d=n.attributes;if(!d||Ut(n))return;x=eo(w.uponSanitizeAttribute,x,te,Dt);const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:x,forceKeepAttr:void 0};let h=d.length;const g=_(n.nodeName);for(;h--;){const b=d[h],S=b.name,U=b.namespaceURI,B=b.value,mt=_(S),pe=B;let R=S==="value"?pe:Rn(pe),ao=!1;if(f.attrName=mt,f.attrValue=R,f.keepAttr=!0,f.forceKeepAttr=void 0,G(w.uponSanitizeAttribute,n,f),R=f.attrValue,Fe&&(mt==="id"||mt==="name")&&fo(R,He)!==0&&(nt(S,n,b),R=He+R,ao=!0),et&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,R)){nt(S,n,b);continue}if(mt==="attributename"&&uo(R,"href")){nt(S,n,b);continue}if(!f.forceKeepAttr){if(!f.keepAttr){nt(S,n,b);continue}if(!ze&&O(Qn,R)){nt(S,n,b);continue}if(q&&(R=Ht(R)),!no(g,mt,R)){nt(S,n,b);continue}R=Tn(g,mt,U,R),R!==pe&&wn(n,S,U,R)&&ao&&co(t.removed)}}G(w.afterSanitizeAttributes,n,null),ht(n,a)},Wt=function(n){let a=null;const d=to(n);for(G(w.beforeSanitizeShadowDOM,n,null);a=d.nextNode();)if(G(w.uponSanitizeShadowNode,a,null),oo(a,n),ro(a,n),pt(a.content)&&Wt(a.content),Et(a)===F.element){const f=_e(a);pt(f)&&(fe(f),Wt(f))}G(w.afterSanitizeShadowDOM,n,null)},fe=function(n){const a=[{node:n,shadow:null}];for(;a.length>0;){const d=a.pop();if(d.shadow){Wt(d.shadow);continue}const f=d.node,h=Et(f)===F.element,g=D(f);if(g)for(let b=g.length-1;b>=0;--b)a.push({node:g[b],shadow:null});if(h){const b=at?at(f):null;if(typeof b=="string"&&_(b)==="template"){const S=f.content;pt(S)&&a.push({node:S,shadow:null})}}if(h){const b=_e(f);pt(b)&&a.push({node:null,shadow:b},{node:b,shadow:null})}}};return t.sanitize=function(u){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,d=null,f=null,h=null;if(ae=!u,ae&&(u="<!-->"),typeof u!="string"&&!kt(u)&&(u=Fn(u),typeof u!="string"))throw X("dirty is not a string, aborting");if(!t.isSupported)return u;oe?(k=Ot,x=Dt):de(n),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(k=H(k)),w.uponSanitizeAttribute.length>0&&(x=H(x)),t.removed=[];const g=re&&typeof u!="string"&&kt(u);if(g){bn(u);const U=Xt(u);if(typeof U=="string"){const B=_(U);if(!k[B]||Tt[B])throw Bt(u),X("root node is forbidden and cannot be sanitized in-place")}if(Ut(u))throw Bt(u),X("root node is clobbered and cannot be sanitized in-place");try{fe(u)}catch(B){throw Bt(u),B}}else if(kt(u))a=Qe("<!---->"),d=a.ownerDocument.importNode(u,!0),d.nodeType===F.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?a=d:a.appendChild(d),fe(a);else{if(!lt&&!q&&!ot&&u.indexOf("<")===-1)return P&&Nt?st(u):u;if(a=Qe(u),!a)return lt?null:Nt?tt:""}a&&ne&&V(a.firstChild);const b=g?u:a;try{const U=to(b);for(;f=U.nextNode();)oo(f,b),ro(f,b),pt(f.content)&&Wt(f.content)}catch(U){throw g&&(Bt(u),it(t.removed,B=>{B.element&&Ft(B.element)})),U}if(g){let U=!1;if(it(t.removed,B=>{B.element&&(B.element===u&&(U=!0),Ft(B.element))}),U)throw X("a node selected for removal could not be safely returned; refusing to sanitize in place");return q&&ue(u),u}if(lt){if(q&&ue(a),Rt)for(h=Xo.call(a.ownerDocument);a.firstChild;)h.appendChild(a.firstChild);else h=a;return(x.shadowroot||x.shadowrootmode)&&(h=Jo.call(o,h,!0)),h}let S=ot?a.outerHTML:a.innerHTML;return ot&&k["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&O(Xn,a.ownerDocument.doctype.name)&&(S="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
|
|
11
|
+
`+S),q&&(S=Ht(S)),P&&Nt?st(S):S},t.setConfig=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};de(u),oe=!0,Ot=k,Dt=x},t.clearConfig=function(){ft=null,oe=!1,Ot=null,Dt=null,P=Zt,tt=""},t.isValidAttribute=function(u,n,a){ft||de({});const d=_(u),f=_(n);return no(d,f,a)},t.addHook=function(u,n){typeof n=="function"&&z(w,u)&&xt(w[u],n)},t.removeHook=function(u,n){if(z(w,u)){if(n!==void 0){const a=On(w[u],n);return a===-1?void 0:Dn(w[u],a,1)[0]}return co(w[u])}},t.removeHooks=function(u){z(w,u)&&(w[u]=[])},t.removeAllHooks=function(){w=wo()},t}var Gt=jo();const ii=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],ri={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"],iframe:["src","width","height","name","title","frameborder","scrolling","allowfullscreen","longdesc","allow"]},ai="data-editora-embed";function si(s){if(!s||/\s/.test(s.trim()))return!1;try{const t=new URL(s.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function Wo(s,t,e,o){if((t==null?void 0:t.sanitize)===!1)return s;const i=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:ii,r=e!=null&&e.length?Array.from(new Set([...i,...e])):i,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:ri,p=new Set;for(const C of Object.values(c))for(const A of C)p.add(A);const m={ALLOWED_TAGS:r,ALLOWED_ATTR:Array.from(p)};if(!o)return Gt.sanitize(s,m);const v=r.includes("iframe");Gt.addHook("uponSanitizeElement",(C,A)=>{var E;if(A.tagName!=="iframe")return;const T=C;A.allowedTags.iframe=v||((E=T.getAttribute)==null?void 0:E.call(T,ai))==="true"&&si(T.getAttribute("src"))});try{return Gt.sanitize(s,m)}finally{Gt.removeHook("uponSanitizeElement")}}function $o(s,t,e,o){return Wo(s,t,o,!1)}function Go(s,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?s:$o(s,t)}function xe(s,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?s:Wo(s,t,o,!0)}const li=".resize-handle, .table-resize-handle",ci=/resize-handle/;function Se(s){if(!s||!ci.test(s))return s;const t=document.createElement("template");t.innerHTML=s;const e=new Set;return t.content.querySelectorAll(li).forEach(o=>{const i=o.parentElement;i&&(i.tagName==="TD"||i.tagName==="TH")&&e.add(i),o.remove()}),e.forEach(o=>{var i;o.style.position==="relative"&&(o.style.removeProperty("position"),(i=o.getAttribute("style"))!=null&&i.trim()||o.removeAttribute("style"))}),t.innerHTML}function bt(s){return s?Se(s.innerHTML):""}const qt=class qt{static resolve(t){const e={};if(Object.assign(e,this.EDITOR_DEFAULTS),t.pluginDefaults&&Object.assign(e,t.pluginDefaults),t.attributes){const o=this.parseAttributes(t.attributes);Object.assign(e,o)}return t.jsConfig&&Object.assign(e,t.jsConfig),this.normalizeConfig(e)}static normalizeConfig(t){const e={...t};if(e.toolbarFloating!==void 0||e.toolbarSticky!==void 0){const l=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(l.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(l.sticky=!!e.toolbarSticky),e.toolbar=l}if(e.toolbarItems!==void 0&&typeof e.toolbar=="object"&&e.toolbar&&(e.toolbar.items=e.toolbarItems),e.autosaveEnabled!==void 0||e.autosaveIntervalMs!==void 0||e.autosaveStorageKey!==void 0||e.autosaveProvider!==void 0||e.autosaveApiUrl!==void 0){const l=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(l.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(l.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(l.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(l.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(l.apiUrl=e.autosaveApiUrl),e.autosave=l}const o={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof e.autosave=="boolean")e.autosave={...o,enabled:e.autosave};else if(typeof e.autosave=="object"&&e.autosave){const l={...o,...e.autosave};l.intervalMs===void 0&&l.interval!==void 0&&(l.intervalMs=Number(l.interval)),l.enabled===void 0&&(l.enabled=!0),(!Number.isFinite(l.intervalMs)||l.intervalMs<=0)&&(l.intervalMs=o.intervalMs),e.autosave=l}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const l=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(l.locale=e.languageLocale),e.languageDirection!==void 0&&(l.direction=e.languageDirection),e.language=l}const i={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:i.direction}:typeof e.language=="object"&&e.language?e.language={...i,...e.language}:e.language=i,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const l=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(l.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(l.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(l.apiUrl=e.spellcheckApiUrl),e.spellcheck=l}const r={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...r,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const l={...r,...e.spellcheck};!l.provider&&l.mode&&(l.provider=l.mode==="local"?"browser":"api"),l.enabled===void 0&&(l.enabled=!!(l.mode||l.provider||l.apiUrl)),e.spellcheck=l}else e.spellcheck=r;return e.contextMenuEnabled!==void 0&&(e.contextMenu={enabled:!!e.contextMenuEnabled}),typeof e.contextMenu=="boolean"?e.contextMenu={enabled:e.contextMenu}:typeof e.contextMenu=="object"&&e.contextMenu?e.contextMenu={enabled:e.contextMenu.enabled!==!1}:e.contextMenu={enabled:!0},(e.pasteClean!==void 0||e.pasteKeepFormatting!==void 0||e.pasteConvertWord!==void 0)&&(e.paste={...e.paste||{},...e.pasteClean!==void 0?{clean:!!e.pasteClean}:{},...e.pasteKeepFormatting!==void 0?{keepFormatting:!!e.pasteKeepFormatting}:{},...e.pasteConvertWord!==void 0?{convertWord:!!e.pasteConvertWord}:{}}),e.paste={clean:!0,keepFormatting:!1,convertWord:!0,...e.paste||{}},e.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...e.contentConfig||{}},(e.securitySanitizeOnPaste!==void 0||e.securitySanitizeOnInput!==void 0)&&(e.security={...e.security||{},...e.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!e.securitySanitizeOnPaste}:{},...e.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!e.securitySanitizeOnInput}:{}}),e.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...e.security||{}},(e.accessibilityEnableAria!==void 0||e.accessibilityKeyboardNavigation!==void 0||e.accessibilityChecker!==void 0)&&(e.accessibility={...e.accessibility||{},...e.accessibilityEnableAria!==void 0?{enableARIA:!!e.accessibilityEnableAria}:{},...e.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!e.accessibilityKeyboardNavigation}:{},...e.accessibilityChecker!==void 0?{checker:!!e.accessibilityChecker}:{}}),typeof e.accessibility=="boolean"&&(e.accessibility={enableARIA:e.accessibility,keyboardNavigation:e.accessibility,checker:!1}),e.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...e.accessibility||{}},(e.performanceDebounceInputMs!==void 0||e.performanceViewportOnlyScan!==void 0)&&(e.performance={...e.performance||{},...e.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(e.performanceDebounceInputMs)}:{},...e.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!e.performanceViewportOnlyScan}:{}}),typeof e.performance=="boolean"&&(e.performance={debounceInputMs:100,viewportOnlyScan:e.performance}),e.performance={debounceInputMs:100,viewportOnlyScan:!0,...e.performance||{}},(typeof e.performance.debounceInputMs!="number"||!Number.isFinite(e.performance.debounceInputMs)||e.performance.debounceInputMs<0)&&(e.performance.debounceInputMs=100),e}static parseAttributes(t){const e={};for(const[o,i]of Object.entries(t)){const r=this.kebabToCamel(o);e[r]=this.BOOLEAN_ATTRIBUTES.has(o)&&(i===""||i===o)?!0:this.parseAttributeValue(i)}return e}static parseAttributeValue(t){if(t==="true")return!0;if(t==="false")return!1;if(/^\d+$/.test(t))return parseInt(t,10);if(/^\d+\.\d+$/.test(t))return parseFloat(t);if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(e){return t}return t}static kebabToCamel(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}static validate(t){const e=[];return t.height!==void 0&&typeof t.height=="number"&&t.height<0&&e.push("height must be a positive number"),t.width!==void 0&&typeof t.width=="number"&&t.width<0&&e.push("width must be a positive number"),t.plugins!==void 0&&!Array.isArray(t.plugins)&&typeof t.plugins!="string"&&e.push("plugins must be an array or string"),t.theme!==void 0&&typeof t.theme!="string"&&e.push("theme must be a string"),{valid:e.length===0,errors:e}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...t){const e={};for(const o of t)for(const[i,r]of Object.entries(o))r!=null&&(typeof r=="object"&&!Array.isArray(r)&&e[i]?e[i]=this.merge(e[i],r):e[i]=r);return e}};qt.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1},qt.BOOLEAN_ATTRIBUTES=new Set(["readonly","disabled","autofocus","statusbar","toolbar-floating","toolbar-sticky","autosave-enabled","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance-viewport-only-scan","spellcheck-enabled","context-menu-enabled","paste-clean","paste-keep-formatting","paste-convert-word","security-sanitize-on-paste","security-sanitize-on-input"]);let Yt=qt;class Ko{constructor(){this.loadedPlugins=new Map,this.pluginRegistry=new Map}register(t,e){this.pluginRegistry.set(t,e)}async load(t,e){if(this.loadedPlugins.has(t))return this.loadedPlugins.get(t);const o=this.pluginRegistry.get(t);if(!o)return console.warn(`Plugin not found: ${t}`),null;const i=await o();return e&&this.applyPluginConfig(i,e),this.loadedPlugins.set(t,i),i}async loadMultiple(t,e){return(await Promise.all(t.map(i=>this.load(i,e)))).filter(i=>i!==null)}async parsePluginString(t,e){const o=t.split(/\s+/).filter(Boolean);return this.loadMultiple(o,e)}applyPluginConfig(t,e){t.__pluginConfig=e}unload(t){this.loadedPlugins.delete(t)}clear(){this.loadedPlugins.clear()}getLoadedPlugins(){return Array.from(this.loadedPlugins.values())}getRegisteredPluginNames(){return Array.from(this.pluginRegistry.keys())}isLoaded(t){return this.loadedPlugins.has(t)}}const di='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor}.editora-theme-dark .editora-toolbar-button svg:not([fill=none i]),.editora-theme-dark .editora-toolbar-icon svg:not([fill=none i]){fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-items-container{display:flex;align-items:center;gap:4px;flex:1;min-width:0;overflow:hidden}.editora-toolbar-more-button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;flex-shrink:0;padding:0;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-size:16px}.editora-toolbar-more-button:hover{background:#e0e0e0}.editora-toolbar-more-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-more-button{background:var(--editora-dark-content);border-color:var(--editora-dark-border);color:var(--editora-dark-text)}.editora-theme-dark .editora-toolbar-more-button:hover,.editora-theme-dark .editora-toolbar-more-button.active{background:#3a4554;border-color:#607088}.editora-toolbar-expanded-row{display:none;flex-wrap:wrap;align-items:center;gap:4px;width:100%;padding:8px;border-top:1px solid #ddd;background:#f5f5f5}.editora-toolbar-expanded-row.show{display:flex}.editora-theme-dark .editora-toolbar-expanded-row{border-top-color:var(--editora-dark-border);background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%)}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let Kt;const ui="__editoraCommandEditorRoot",fi="__editoraLastCommandButton",ko="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",xo=".rte-content, .editora-content",Ce=new Set;let J=null,Co=!1,ve=null,Te=null;function Ao(s){if(!(s instanceof HTMLElement))return!1;const t=s;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function pi(s){return s?s.nodeType===Node.ELEMENT_NODE?s:s.parentElement:null}function St(s){if(!s)return null;if(Ao(s))return s;const t=s.matches(ko)?s:s.closest(ko);return!t||!Ao(t)?null:t}function hi(){var i;if(typeof window=="undefined")return null;const s=window[ui];if(s instanceof HTMLElement){const r=St(s);if(r)return r;const l=s.matches(xo)?s:s.querySelector(xo);if(l){const c=St(l);if(c)return c}}const t=window[fi];if(t instanceof HTMLElement){const r=St(t);if(r)return r}const e=document.activeElement;if(e){const r=St(e);if(r)return r}const o=(i=window.getSelection)==null?void 0:i.call(window);if(o&&o.rangeCount>0){const r=St(pi(o.getRangeAt(0).startContainer));if(r)return r}if(J&&J.isConnected)return J;for(const r of Ce)if(r.isConnected)return r;return null}function mi(){if(typeof window=="undefined"||Co)return;ve=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,Te=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const s=(t,...e)=>{const o=hi();return o?o.execCommand(t,...e):ve?ve(t,...e):Te?Te(t,...e):!1};window.executeEditorCommand=s,window.execEditorCommand=s,Co=!0}function gi(){const s="editora-webcomponent-styles";if(!document.getElementById(s)){const t=document.createElement("style");t.id=s,t.textContent=di,document.head.appendChild(t)}}function Yo(){if(!Kt){const s=rt.__globalPluginLoader;s?Kt=s:Kt=new Ko}return Kt}function bi(s){const t=Yo();Object.entries(s).forEach(([e,o])=>{t.register(e,o)})}class rt extends HTMLElement{constructor(){if(super(),this.pluginLoader=Yo(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new _o,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,gi(),!this.hasAttribute("data-initial-content")){const t=this.innerHTML.trim();t&&this.setAttribute("data-initial-content",t)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(rt.__globalPluginLoader){this.pluginLoader=rt.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{rt.__globalPluginLoader?(this.pluginLoader=rt.__globalPluginLoader,t()):setTimeout(e,0)};e()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(t,e,o){e!==o&&(this.config=this.resolveConfig(),this.handleAttributeChange(t,o))}async setConfig(t){this.jsConfig=t,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var i;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),Ce.add(this),J||(J=this),mi(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const t=await this.loadPlugins();if(this.loadedPlugins=t,t.forEach(r=>{if(r.init&&typeof r.init=="function")try{r.init({editorElement:this})}catch(l){console.error(`[RichTextEditor] Error initializing plugin ${r.name}:`,l)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const r=this.innerHTML.trim();r&&this.setAttribute("data-initial-content",r)}const e=this.preservedContent;this.preservedContent=null;const o=this.sanitizeLoadedContent((i=e!=null?e:this.restoreAutosavedContent())!=null?i:this.getAttribute("data-initial-content")||"");this.engine=new Mo({content:o,plugins:t,readonly:this.config.readonly}),this.createUI(t,o),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const t=this.querySelector("[slot]");return t?t.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(o=>o.nodeType===Node.TEXT_NODE?o.textContent:o.nodeType===Node.ELEMENT_NODE?o.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const t=[],e=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const r=this.config.plugins.split(/\s+/).filter(Boolean);i&&!r.includes("a11yChecker")&&r.push("a11yChecker");for(const l of r){const c=await this.pluginLoader.load(l,this.getPluginLoadConfig(l));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const r of this.config.plugins)if(typeof r=="string"){const l=await this.pluginLoader.load(r,this.getPluginLoadConfig(r));l&&t.push(l)}else t.push(r);if(i&&!t.some(r=>(r==null?void 0:r.name)==="a11yChecker")){const r=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));r&&t.push(r)}}}else{const r=this.pluginLoader.getRegisteredPluginNames();for(const l of r){const c=await this.pluginLoader.load(l,this.getPluginLoadConfig(l));c&&t.push(c)}}return t}resolveToolbarItems(){const t=this.config.toolbarItems;if(typeof t=="string")return t;if(Array.isArray(t))return t.join(" ");const e=this.config.toolbar;if(typeof e=="string")return e;if(!e||typeof e!="object")return;const o=e.items;if(typeof o=="string")return o;if(Array.isArray(o))return o.join(" ")}isToolbarStickyEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.sticky}isToolbarFloatingEnabled(){const t=this.config.toolbar;return!t||typeof t!="object"?!1:!!t.floating}isStatusbarEnabled(){const t=this.config.statusbar;return typeof t=="boolean"?t:t&&typeof t=="object"?t.enabled!==!1:!1}getStatusbarPosition(){const t=this.config.statusbar;return t&&typeof t=="object"&&t.position==="top"?"top":"bottom"}getLanguageConfig(){const t=this.config.language;return typeof t=="string"?{locale:t,direction:"ltr"}:t&&typeof t=="object"?{locale:t.locale||"en",direction:t.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const t=this.config.accessibility;return typeof t=="boolean"?{enableARIA:t,keyboardNavigation:t,checker:!1}:t&&typeof t=="object"?{enableARIA:t.enableARIA!==!1,keyboardNavigation:t.keyboardNavigation!==!1,checker:!!t.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var e;const t=this.config.performance;if(typeof t=="boolean")return{debounceInputMs:100,viewportOnlyScan:t};if(t&&typeof t=="object"){const o=Number((e=t.debounceInputMs)!=null?e:100);return{debounceInputMs:Number.isFinite(o)&&o>=0?o:100,viewportOnlyScan:t.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const t=this.contentElement.getBoundingClientRect();return t.bottom>=0&&t.top<=window.innerHeight}applyAccessibilitySettings(){if(!this.contentElement)return;const t=this.getAccessibilityConfig();if(t.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const e=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";e?this.contentElement.setAttribute("aria-label",e):this.contentElement.removeAttribute("aria-label")}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=t.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const t=this.getLanguageConfig();this.contentElement.setAttribute("lang",t.locale),this.contentElement.setAttribute("dir",t.direction)}getSpellcheckConfig(){const t=this.config.spellcheck;if(typeof t=="boolean")return{enabled:t,provider:"browser"};if(t&&typeof t=="object"){const e=t.provider||"browser";return{enabled:!!t.enabled,provider:e,mode:t.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const t=this.getSpellcheckConfig(),e=t.enabled&&t.provider==="browser";this.contentElement.spellcheck=e,this.contentElement.setAttribute("spellcheck",e?"true":"false")}executeCommand(t,...e){var r;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(l=>l.commands&&l.commands[t]);if(i&&i.commands){const l=i.commands[t];if(typeof l=="function")try{return t==="toggleFullscreen"?l(this,o):l(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((r=this.engine)==null?void 0:r.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const r=e[t];if(r&&typeof r=="object")return r}const o={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"],formatPainter:["formatpainter","format-painter","formatPainter"],"format-painter":["formatpainter","format-painter","formatPainter"]},i=[t,t.toLowerCase(),...o[t]||[]];for(const r of i){const l=this.config[r];if(l&&typeof l=="object"&&!Array.isArray(l))return l}}getContentSanitizeConfig(){const t=this.config.contentConfig;return t&&typeof t=="object"?t:{sanitize:!0}}getSecurityConfig(){const t=this.config.security;return t&&typeof t=="object"?t:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}sanitizeLoadedContent(t){return xe(t,this.getContentSanitizeConfig(),this.getSecurityConfig())}getAutosaveConfig(){var e,o;const t=this.config.autosave;if(typeof t=="boolean")return{enabled:t,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(t&&typeof t=="object"){const i=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(t.storageKey||"rte-autosave"),provider:t.provider||"localStorage",apiUrl:t.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(t){const e=this.getAutosaveConfig();if(e.enabled&&t!==this.lastAutosavedContent){if(this.lastAutosavedContent=t,e.provider==="localStorage"){try{localStorage.setItem(e.storageKey,t),localStorage.setItem(`${e.storageKey}-timestamp`,Date.now().toString())}catch(o){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",o)}return}e.provider==="api"&&e.apiUrl&&fetch(e.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,timestamp:Date.now()})}).catch(o=>{console.error("[RichTextEditor] Failed to save autosave content to API:",o)})}}restoreAutosavedContent(){const t=this.getAutosaveConfig();if(!t.enabled||t.provider!=="localStorage")return null;try{const e=localStorage.getItem(t.storageKey);if(e)return this.lastAutosavedContent=e,e}catch(e){console.error("[RichTextEditor] Failed to restore autosaved content:",e)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const t=this.getAutosaveConfig();!t.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{this.persistAutosave(bt(this.contentElement))},t.intervalMs))}insertHTMLAtSelection(t){if(!this.contentElement)return;const e=window.getSelection();if(e&&e.rangeCount>0){const o=e.getRangeAt(0);o.deleteContents();const i=document.createElement("div");i.innerHTML=t;const r=document.createDocumentFragment();for(;i.firstChild;)r.appendChild(i.firstChild);o.insertNode(r),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,t)}createUI(t,e){const o=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!o?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new Io({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((r,l)=>{var c;if(this.contentElement){this.contentElement.focus();const p=window.getSelection();if(!p||p.rangeCount===0||!this.contentElement.contains(p.anchorNode)){const m=document.createRange(),v=this.contentElement.lastChild||this.contentElement;v.nodeType===Node.TEXT_NODE?m.setStart(v,((c=v.textContent)==null?void 0:c.length)||0):v.nodeType===Node.ELEMENT_NODE?(m.selectNodeContents(v),m.collapse(!1)):m.setStart(this.contentElement,0),m.collapse(!0),p==null||p.removeAllRanges(),p==null||p.addRange(m)}}return this.executeCommand(r,l)}),this.toolbar.render(this.toolbarElement)):o&&this.appendChild(o),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(r){console.warn("defaultParagraphSeparator not supported:",r)}if(e){const r=document.createElement("div");r.innerHTML=e.trim(),!Array.from(r.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const p=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(p)}return!1})&&e.trim()?this.contentElement.innerHTML=`<p>${e.trim()}</p>`:this.contentElement.innerHTML=e}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new Oo({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Do({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var r;return(r=this.contentElement)==null?void 0:r.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const t=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",o=>{this.lastBeforeInputType=o.inputType||null}),this.contentElement.addEventListener("input",o=>{var A;if(!this.contentElement)return;let i=this.contentElement.innerHTML;const r=(A=o==null?void 0:o.detail)==null?void 0:A.allowedTags,l=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),p=this.getSecurityConfig(),m=this.lastBeforeInputType;if(this.lastBeforeInputType=null,p.sanitizeOnInput!==!1&&c.sanitize!==!1&&!m){const T=xe(i,c,p,r);if(T!==i){const E=window.getSelection(),K=E&&E.rangeCount>0?E.getRangeAt(0):null;if(this.contentElement.innerHTML=T,K&&E)try{E.removeAllRanges(),E.addRange(K)}catch(D){}i=T}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const C=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:Se(i)},bubbles:!0}))};l.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(C,l.debounceInputMs):C(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var v,C;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const i=this.config.paste||{};let r=((v=o.clipboardData)==null?void 0:v.getData("text/html"))||"";const l=((C=o.clipboardData)==null?void 0:C.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),p=this.getSecurityConfig(),m=!!r&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(r);if((i.clean||!i.keepFormatting)&&l){document.execCommand("insertText",!1,l);return}if(i.convertWord===!1&&m&&l){document.execCommand("insertText",!1,l);return}if(r){p.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(r=Go(r,c,p)),this.insertHTMLAtSelection(r);return}l&&document.execCommand("insertText",!1,l)}),this.contentElement.addEventListener("focus",()=>{J=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:bt(this.contentElement)},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",o=>{this.getAccessibilityConfig().keyboardNavigation&&t.handleKeyDown(o,(r,l)=>{this.executeCommand(r,l)})});const e=()=>{const o=this.getSelectionRangeInEditor(),i=document.activeElement,r=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!r||!o&&!r||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=e,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0),o=e.commonAncestorContainer;return this.contentElement.contains(o)?e:null}isSelectionBackward(t){if(!t.anchorNode||!t.focusNode)return!1;try{const e=document.createRange();return e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset),e.collapsed}catch(e){return!1}}getSelectionAnchorRect(t,e){const o=Array.from(e.getClientRects()).filter(r=>r.width>0||r.height>0);return o.length===0?e.getBoundingClientRect():this.isSelectionBackward(t)?o[0]:o[o.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.isReadonlyAttribute(this.getAttribute("readonly"))||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const e=this.getPerformanceConfig(),o=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!o){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const r=window.getSelection();if(!r){this.floatingToolbar.hide();return}const l=this.getSelectionAnchorRect(r,i);if(!l){this.floatingToolbar.hide();return}this.floatingToolbar.show(l.left,l.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const t=this.getPerformanceConfig(),e=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(t.viewportOnlyScan&&!this.isEditorInViewport()&&!e)return;const o=this.contentElement.textContent||"",{words:i,chars:r}=zo(o),l=Po(this.contentElement);let c,p;const m=this.getSelectionRangeInEditor();m&&(c=Ro(this.contentElement,m),m.collapsed||(p=Bo(m,c),c=void 0)),this.statusBar.update({wordCount:i,charCount:r,lineCount:l,cursorPosition:c,selectionInfo:p})}isReadonlyAttribute(t){return t!==null&&t!=="false"}handleAttributeChange(t,e){switch(t){case"readonly":this.contentElement&&(this.contentElement.contentEditable=this.isReadonlyAttribute(e)?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(this.isReadonlyAttribute(e));break;case"theme":this.classList.forEach(o=>{o.startsWith("editora-theme-")&&this.classList.remove(o)}),e&&this.classList.add(`editora-theme-${e}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",e),this.applyAccessibilitySettings());break;case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(o=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",o)})}));break}}resolveConfig(){const t={};for(let e=0;e<this.attributes.length;e++){const o=this.attributes[e];t[o.name]=o.value}return Yt.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>bt(this.contentElement),setContent:t=>{this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))},execCommand:(t,e)=>this.executeCommand(t,e),focus:()=>{var t;(t=this.contentElement)==null||t.focus()},blur:()=>{var t;(t=this.contentElement)==null||t.blur()},destroy:()=>{this.destroy()},on:(t,e)=>(this.addEventListener(t,e),()=>this.removeEventListener(t,e)),getConfig:()=>({...this.config}),setReadonly:t=>{this.setAttribute("readonly",t.toString())}}}destroy(){var t,e,o,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=bt(this.contentElement),this.persistAutosave(this.preservedContent)),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(t=this.engine)==null||t.destroy(),(e=this.toolbar)==null||e.destroy(),(o=this.floatingToolbar)==null||o.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,Ce.delete(this),J===this&&(J=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return bt(this.contentElement)}setContent(t){this.contentElement&&(this.contentElement.innerHTML=this.sanitizeLoadedContent(t))}execCommand(t,...e){return this.executeCommand(t,...e)}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}}exports.CommandRegistry=Lo;exports.ConfigResolver=Yt;exports.EditorEngine=Mo;exports.EditorState=Lt;exports.FloatingToolbar=Oo;exports.KeyboardShortcutManager=_o;exports.PluginLoader=Ko;exports.PluginManager=Ae;exports.RichTextEditorElement=rt;exports.Schema=So;exports.StatusBar=Do;exports.ToolbarRenderer=Io;exports.calculateTextStats=zo;exports.countLines=Po;exports.createPluginManager=kn;exports.getCleanEditorHTML=bt;exports.getCursorPosition=Ro;exports.getSelectionInfo=Bo;exports.getTextOffset=No;exports.initWebComponent=bi;exports.sanitizeHTML=$o;exports.sanitizeInputHTML=xe;exports.sanitizePastedHTML=Go;exports.stripEditorUiArtifacts=Se;
|
|
12
|
+
//# sourceMappingURL=index-CclXYzUB.js.map
|