@editora/core 1.0.20 → 1.0.22
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-BcVqm5MS.mjs → CodePlugin.native-CAHk9ecG.mjs} +214 -96
- package/dist/{CodePlugin.native-Rgxx2Igx.mjs → CodePlugin.native-DZgIez08.mjs} +374 -256
- package/dist/editora.min.js +2 -2
- package/dist/editora.umd.js +2 -2
- package/dist/index-C1sO7DAC.js +12 -0
- package/dist/{index-BxlbmLsp.mjs → index-DGMYWPLx.mjs} +4 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/webcomponent-core.js +4 -2
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +20 -19
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +4 -2
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +68 -67
- package/index.d.ts +4 -0
- package/package.json +1 -1
- package/dist/index-Cdy6TOCy.js +0 -12
package/dist/editora.min.js
CHANGED
|
@@ -4,7 +4,7 @@ var Editora=(function(g){"use strict";class lt{constructor(t,e,o){this.doc=t,thi
|
|
|
4
4
|
|
|
5
5
|
`,n.forEach(s=>{const c=this.getShortcutDescription(s);o+=`- **${c}**: ${s.description||s.command}
|
|
6
6
|
`}),o+=`
|
|
7
|
-
`}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}const Ne=new Set;function ze(a,t){Ne.has(a)||(Ne.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${t} instead.`))}function rn(a={}){ze("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:t=!1,provider:e="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:i}),e){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:f=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:f=>(console.log("[Spellcheck] Add to dictionary:",f),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){ze("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:t="",libraryUrl:e="",maxFileSize:o=10485760,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1048576,enableChunking:u=!0,onProgress:f,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:o,allowedTypes:n}),t||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Fe{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Rt{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new xt,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=lt.create(e),this.commandRegistry=new Fe(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let n;return e.length===0?n=o(this.state):e.length===1?n=o(this.state,e[0]):n=o(this.state,...e),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${t}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const n=o.indexOf(e);n>-1&&o.splice(n,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(n=>{try{n(...e)}catch(i){console.error(`Error in ${t} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class kt{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new kt(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new kt(this.doc,t)}update(t,e){return new kt(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pt{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&e.push(u)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const f=c.lastElementChild;f instanceof HTMLElement&&(this.overflowUnits.push(f),this.overflowUnitHomes.set(f,c))}),e.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",e.appendChild(u)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,t.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=t.clientWidth,f=16,b=40,T=4,v=Math.max(0,u-f-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const Z=k<c.length;o.style.display=Z?"":"none",o.classList.toggle("active",Z&&this.expandedOpen),!Z&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(t),s()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=t.icon,e.appendChild(n)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,t.items.forEach(i=>{this.appendToolbarButton(n,i)}),e.appendChild(n)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var f;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=(f=this.container)==null?void 0:f.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class He{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Ue{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class et{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height);const e=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
|
|
7
|
+
`}),o}getShortcutCategory(t){return t.includes("toggle")&&(t.includes("Bold")||t.includes("Italic")||t.includes("Underline")||t.includes("Strike")||t.includes("Code")||t.includes("Super")||t.includes("Sub"))?"Text Formatting":t.includes("Heading")||t.includes("Paragraph")?"Block Formatting":t.includes("List")||t.includes("Checklist")?"Lists":t.includes("Alignment")||t.includes("Indent")?"Alignment & Indentation":t.includes("undo")||t.includes("redo")?"History":t.includes("insert")?"Insert":t.includes("find")||t.includes("replace")?"Find & Replace":t.includes("Accessibility")||t.includes("spell")?"Tools":"Other"}}const Ne=new Set;function ze(a,t){Ne.has(a)||(Ne.add(a),console.warn(`[Editora] ${a} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${t} instead.`))}function rn(a={}){ze("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:t=!1,provider:e="browser",apiUrl:o="",apiHeaders:n={},language:i="en",customDictionary:s=[],ignoreAllCaps:c=!0,ignoreNumbers:u=!0}=a;return{name:"spellcheck",context:{initialize:()=>{if(t)switch(console.log("[Spellcheck Plugin] Initialized",{provider:e,language:i}),e){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":o?console.log("[Spellcheck] Using API:",o):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:f=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:f=>(console.log("[Spellcheck] Add to dictionary:",f),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:t?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function an(a={}){ze("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:t="",libraryUrl:e="",maxFileSize:o=10485760,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:i={},withCredentials:s=!1,chunkSize:c=1048576,enableChunking:u=!0,onProgress:f,onError:b,onSuccess:T}=a;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:t,libraryUrl:e,maxFileSize:o,allowedTypes:n}),t||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:v=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async v=>{if(console.log("[Media] Insert image command (not implemented)",v),!v)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(v.type)){const x=new Error(`File type ${v.type} not allowed`);return b==null||b(x),null}if(v.size>o){const x=new Error(`File size ${v.size} exceeds max ${o}`);return b==null||b(x),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),e||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async v=>(console.log("[Media] Upload media (not implemented)",{name:v.name,size:v.size,type:v.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class Fe{constructor(t={}){this.commands=new Map,Object.entries(t).forEach(([e,o])=>{this.register(e,o)})}register(t,e){this.commands.has(t)&&console.warn(`Command ${t} is being overwritten`),this.commands.set(t,e)}unregister(t){this.commands.delete(t)}get(t){return this.commands.get(t)}has(t){return this.commands.has(t)}getCommandNames(){return Array.from(this.commands.keys())}clear(){this.commands.clear()}}class Rt{constructor(t={}){this.listeners=new Map,this.isReadonly=!1,this.isDestroyed=!1,this.isReadonly=t.readonly||!1,this.pluginManager=new xt,t.plugins&&Array.isArray(t.plugins)&&t.plugins.forEach(o=>this.pluginManager.register(o));const e=this.pluginManager.buildSchema();this.state=lt.create(e),this.commandRegistry=new Fe(this.pluginManager.getCommands())}execCommand(t,...e){if(this.isReadonly)return console.warn("Cannot execute commands in readonly mode"),!1;if(this.isDestroyed)return console.warn("Cannot execute commands on destroyed editor"),!1;const o=this.commandRegistry.get(t);if(!o)return console.warn(`Command not found: ${t}`),!1;let n;return e.length===0?n=o(this.state):e.length===1?n=o(this.state,e[0]):n=o(this.state,...e),n instanceof Promise?(n.then(i=>{i&&typeof i=="object"&&"doc"in i&&"selection"in i&&(this.setState(i),this.emit("change",this.state))}).catch(i=>{console.error(`Async command failed: ${t}`,i)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),this.emit("change",this.state),!0):n!==!1&&n!=null}setState(t){this.isDestroyed||(this.state=t,this.emit("stateChange",t))}getState(){return this.state}setReadonly(t){this.isReadonly=t,this.emit("readonlyChange",t)}isReadOnly(){return this.isReadonly}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push(e),()=>{const o=this.listeners.get(t);if(o){const n=o.indexOf(e);n>-1&&o.splice(n,1)}}}emit(t,...e){const o=this.listeners.get(t);o&&o.forEach(n=>{try{n(...e)}catch(i){console.error(`Error in ${t} handler:`,i)}})}destroy(){this.isDestroyed||(this.isDestroyed=!0,this.listeners.clear(),this.emit("destroy"))}isEditorDestroyed(){return this.isDestroyed}}class kt{constructor(t,e={anchor:0,head:0}){this.doc=t,this.selection=e}getDocument(){return this.doc}setDocument(t){return new kt(t,this.selection)}getSelection(){return{...this.selection}}setSelection(t){return new kt(this.doc,t)}update(t,e){return new kt(t||this.doc,e||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class Pt{constructor(t,e,o){this.overflowUnits=[],this.overflowUnitHomes=new WeakMap,this.expandedOpen=!1,this.onDocumentPointerDownForOverflow=n=>{var s,c;if(!this.expandedOpen)return;const i=n.target;i&&((s=this.moreButton)!=null&&s.contains(i)||(c=this.expandedRow)!=null&&c.contains(i))||this.setExpandedOpen(!1)},this.config=t,this.plugins=e,this.pluginLoader=o}setLastCommandTrigger(t,e){if(typeof window=="undefined"||!t)return;const o=e||t.getAttribute("data-command")||void 0;o&&(window.__editoraLastCommandButton=t,window.__editoraLastCommand=o)}setCommandHandler(t){this.commandHandler=t}parseToolbarString(t){const e=[],o=t.split("|").map(c=>c.trim()),n=this.getAvailableToolbarItems(),i=new Map;n.forEach(c=>{c.command&&i.set(c.command,c),c.type==="group"&&c.label&&i.set(c.label,c)});const s={bold:"toggleBold",italic:"toggleItalic",underline:"toggleUnderline",strikethrough:"toggleStrikethrough",bullist:"toggleBulletList",numlist:"toggleOrderedList",checklist:"toggleChecklist",link:"openLinkDialog",image:"openImageDialog",table:"insertTable",trackChanges:"toggleTrackChanges",acceptTrackChanges:"acceptAllTrackChanges",rejectTrackChanges:"rejectAllTrackChanges",anchor:"insertAnchor",code:"toggleSourceView",blockquote:"toggleBlockquote",undo:"undo",redo:"redo",textColor:"openTextColorPicker",backgroundColor:"openBackgroundColorPicker",fontSize:"fontSize",fontFamily:"setFontFamily",lineHeight:"setLineHeight",heading:"setBlockType",paragraph:"setParagraph",textAlignment:"setTextAlignment",direction:"setDirectionLTR",indent:"increaseIndent",outdent:"decreaseIndent",capitalization:"setCapitalization",math:"insertMath",specialCharacters:"insertSpecialCharacter",emojis:"openEmojiDialog",embedIframe:"openEmbedIframeDialog",fullscreen:"toggleFullscreen",preview:"togglePreview",print:"print",a11yChecker:"toggleA11yChecker",spellCheck:"toggleSpellCheck",comments:"addComment",showHideComments:"toggleComments",toggleComments:"toggleComments",footnote:"insertFootnote",mergeTags:"insertMergeTag",dataBinding:"openDataBindingDialog",dataBindingPreview:"openDataBindingDialog",contentRules:"toggleContentRulesPanel",contentRulesAudit:"runContentRulesAudit",contentRulesRealtime:"toggleContentRulesRealtime",mention:"insertMention",slash:"openSlashCommands",slashCommands:"openSlashCommands",pageBreak:"insertPageBreak",template:"insertTemplate",importWord:"importWord",exportWord:"exportWord",exportPdf:"exportPdf",insertImage:"insertImage",insertVideo:"insertVideo",codeBlock:"insertCodeBlock"};return o.forEach(c=>{const u=[];c.split(/\s+/).filter(Boolean).forEach(b=>{if(b==="direction"){const x=i.get("setDirectionLTR"),k=i.get("setDirectionRTL");x&&u.push({id:"directionLTR",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"directionRTL",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}if(b==="comments"){const x=i.get("addComment"),k=i.get("toggleComments");x&&u.push({id:"addComment",label:x.label,command:x.command,icon:x.icon,type:x.type||"button",options:x.options}),k&&u.push({id:"toggleComments",label:k.label,command:k.command,icon:k.icon,type:k.type||"button",options:k.options});return}const T=s[b]||b;let v=i.get(T);v||(v=i.get(b)),v&&u.push({id:b,label:v.label,command:v.command,icon:v.icon,type:v.type==="separator"?"separator":v.type||"button",options:v.options,items:v.items})}),u.length>0&&e.push(u)}),e}getAvailableToolbarItems(){return this.plugins.flatMap(e=>e.toolbar||[])}render(t){this.container=t,t.innerHTML="",t.className="editora-toolbar",this.config.sticky&&t.classList.add("editora-toolbar-sticky"),this.config.position&&t.classList.add(`editora-toolbar-${this.config.position}`);const e=document.createElement("div");e.className="editora-toolbar-items-container",this.itemsContainer=e,this.overflowUnits=[];const o=this.config.items||this.getDefaultToolbarString(),n=this.parseToolbarString(o);n.forEach((i,s)=>{const c=document.createElement("div");if(c.className="editora-toolbar-group",i.forEach(u=>{this.appendToolbarButton(c,u);const f=c.lastElementChild;f instanceof HTMLElement&&(this.overflowUnits.push(f),this.overflowUnitHomes.set(f,c))}),e.appendChild(c),s<n.length-1){const u=document.createElement("div");u.className="editora-toolbar-separator",e.appendChild(u)}}),t.appendChild(e),this.setupOverflow(t)}setupOverflow(t){if(!this.itemsContainer||typeof ResizeObserver=="undefined")return;const o=document.createElement("button");o.type="button",o.className="editora-toolbar-more-button",o.title="Show more options",o.setAttribute("aria-label","More toolbar options"),o.textContent="☰",o.style.display="none",o.addEventListener("click",c=>{c.preventDefault(),this.setExpandedOpen(!this.expandedOpen)}),this.moreButton=o,t.appendChild(o);const n=document.createElement("div");n.className="editora-toolbar-expanded-row",this.expandedRow=n,t.appendChild(n),document.addEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0);const i=()=>{const c=this.overflowUnits;if(c.length===0)return;c.forEach(R=>{var z;R.parentElement===n&&((z=this.overflowUnitHomes.get(R))==null||z.appendChild(R))});const u=t.clientWidth,f=16,b=40,T=4,v=Math.max(0,u-f-b-T);let x=0,k=0;for(const R of c){const z=R.getBoundingClientRect().width+T;if(x+z<=v)x+=z,k++;else break}k=Math.max(1,Math.min(k,c.length));const Z=k<c.length;o.style.display=Z?"":"none",o.classList.toggle("active",Z&&this.expandedOpen),!Z&&this.expandedOpen&&this.setExpandedOpen(!1),c.forEach((R,z)=>{z>=k&&n.appendChild(R)})},s=()=>{this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),this.overflowRafId=requestAnimationFrame(i)};this.resizeObserver=new ResizeObserver(()=>s()),this.resizeObserver.observe(t),s()}setExpandedOpen(t){var e,o;this.expandedOpen=t,(e=this.expandedRow)==null||e.classList.toggle("show",t),(o=this.moreButton)==null||o.classList.toggle("active",t)}appendToolbarButton(t,e){if(e.type==="separator"){const o=document.createElement("div");o.className="editora-toolbar-separator",t.appendChild(o)}else if(e.type==="dropdown"){const o=this.createDropdown(e);t.appendChild(o)}else if(e.type==="inline-menu"){const o=this.createInlineMenu(e);t.appendChild(o)}else if(e.type==="group"&&e.items&&e.items.length){const o=this.createGroupButton(e);t.appendChild(o)}else if(e.type==="input"){const o=this.createInput(e);t.appendChild(o)}else{const o=this.createButton(e);t.appendChild(o)}}createGroupButton(t){const e=document.createElement("div"),o=t.label.toLowerCase().replace(/\s+/g,"-");if(e.className=`editora-toolbar-group-button ${o}`,e.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const n=document.createElement("span");n.className="editora-toolbar-icon",n.innerHTML=t.icon,e.appendChild(n)}else e.innerHTML=t.icon;if(t.items&&t.items.length){const n=document.createElement("div");n.className=`editora-toolbar-group-items ${o}`,t.items.forEach(i=>{this.appendToolbarButton(n,i)}),e.appendChild(n)}return e}createInput(t){const e=document.createElement("input");return e.className=`editora-toolbar-input ${t.label.toLowerCase().replace(/\s+/g,"-")}`,e.type="text",e.title=t.label,e.setAttribute("aria-label",t.label),e.placeholder=t.placeholder||"",t.command&&e.setAttribute("data-command",t.command),t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.setLastCommandTrigger(e,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createButton(t){const e=document.createElement("button");if(e.className="editora-toolbar-button",e.type="button",e.title=t.label,t.command&&e.setAttribute("data-command",t.command),t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const o=document.createElement("span");o.className="editora-toolbar-icon",o.innerHTML=t.icon,e.appendChild(o)}else e.innerHTML=t.icon;else e.textContent=t.label;return t.active&&e.classList.add("active"),t.disabled&&(e.disabled=!0),e.addEventListener("click",o=>{o.preventDefault(),this.commandHandler&&t.command&&this.commandHandler(t.command)}),e}createDropdown(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown";const o=document.createElement("button");o.className="editora-toolbar-button editora-toolbar-dropdown-trigger",o.type="button",o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=n.style.display==="block";n.style.display=u?"none":"block"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}createInlineMenu(t){const e=document.createElement("div");e.className="editora-toolbar-dropdown editora-toolbar-inline-menu";const o=document.createElement("button");if(o.className="editora-toolbar-button",o.type="button",o.title=t.label,t.icon)if(t.icon.startsWith("<svg")&&t.icon.endsWith("</svg>")){const c=document.createElement("span");c.className="editora-toolbar-icon",c.innerHTML=t.icon,o.appendChild(c)}else o.innerHTML=t.icon;else o.textContent=t.label;const n=document.createElement("div");n.className="editora-toolbar-dropdown-menu",n.style.display="none",t.options&&t.options.forEach(c=>{const u=document.createElement("button");u.className="editora-toolbar-dropdown-item",u.type="button",u.textContent=c.label,u.setAttribute("data-value",c.value),u.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this.setLastCommandTrigger(o,t.command),this.commandHandler&&t.command&&this.commandHandler(t.command,c.value),n.style.display="none"}),n.appendChild(u)}),o.addEventListener("click",c=>{var f;c.preventDefault(),c.stopPropagation(),this.setLastCommandTrigger(o,t.command);const u=(f=this.container)==null?void 0:f.querySelectorAll(".editora-toolbar-dropdown-menu");u==null||u.forEach(b=>{b!==n&&(b.style.display="none")}),n.style.display=n.style.display==="none"?"block":"none"});const i=c=>{e.contains(c.target)||(n.style.display="none")},s=c=>{c.key==="Escape"&&(n.style.display="none")};return document.addEventListener("mousedown",i,!0),document.addEventListener("keydown",s),e._cleanupDropdown=()=>{document.removeEventListener("mousedown",i,!0),document.removeEventListener("keydown",s)},e.appendChild(o),e.appendChild(n),e}getDefaultToolbarString(){return this.getAvailableToolbarItems().map(e=>e.command).join(" ")}updateButtonState(t,e){if(!this.container)return;const o=this.container.querySelector(`[data-command="${t}"]`);o&&(e.active!==void 0&&o.classList.toggle("active",e.active),e.disabled!==void 0&&(o.disabled=e.disabled))}destroy(){var t;this.container&&(this.container.querySelectorAll(".editora-toolbar-dropdown").forEach(o=>{const n=o._cleanupDropdown;n&&n()}),this.container.innerHTML=""),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=void 0,this.overflowRafId!==void 0&&cancelAnimationFrame(this.overflowRafId),document.removeEventListener("mousedown",this.onDocumentPointerDownForOverflow,!0),this.itemsContainer=void 0,this.moreButton=void 0,this.expandedRow=void 0,this.commandHandler=void 0}}class He{constructor(t){this.visible=!1,this.config=t}create(t){const e=document.createElement("div");return e.className="editora-floating-toolbar",e.style.display="none",e.style.position="absolute",e.style.zIndex="1000",this.container=e,t.appendChild(e),e}show(t,e){this.container&&(this.container.style.display="block",this.container.style.left=`${t}px`,this.container.style.top=`${e}px`,this.visible=!0)}hide(){this.container&&(this.container.style.display="none",this.visible=!1)}updatePosition(t,e){!this.container||!this.visible||(this.container.style.left=`${t}px`,this.container.style.top=`${e}px`)}isVisible(){return this.visible}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0,this.visible=!1}}class Ue{constructor(t={}){this.statusInfo={},this.config=t}create(t){const e=document.createElement("div");return e.className="editora-statusbar",this.config.position&&e.classList.add(`editora-statusbar-${this.config.position}`),this.container=e,t.appendChild(e),e}update(t){this.statusInfo={...this.statusInfo,...t},this.render()}render(){if(!this.container)return;this.container.innerHTML="";const t=document.createElement("div");t.className="editora-statusbar-left";const e=document.createElement("div");e.className="editora-statusbar-right";const o=[];if(this.statusInfo.selectionInfo){const i=this.statusInfo.selectionInfo;i.startLine===i.endLine&&i.startColumn===i.endColumn?o.push(`Ln ${i.startLine}, Col ${i.startColumn}`):(i.startLine===i.endLine?o.push(`Ln ${i.startLine}, Col ${i.startColumn}-${i.endColumn}`):o.push(`Ln ${i.startLine}:${i.startColumn} - ${i.endLine}:${i.endColumn}`),o.push(`${i.selectedChars} chars selected`))}else if(this.statusInfo.cursorPosition){const i=this.statusInfo.cursorPosition;o.push(`Ln ${i.line}, Col ${i.column}`)}this.statusInfo.language&&o.push(this.statusInfo.language);const n=[];this.statusInfo.wordCount!==void 0&&n.push(`${this.statusInfo.wordCount} words`),this.statusInfo.charCount!==void 0&&n.push(`${this.statusInfo.charCount} chars`),this.statusInfo.lineCount!==void 0&&n.push(`${this.statusInfo.lineCount} lines`),this.statusInfo.custom&&Object.entries(this.statusInfo.custom).forEach(([i,s])=>{n.push(`${i}: ${s}`)}),o.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,t.appendChild(c),s<o.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",t.appendChild(u)}}),n.forEach((i,s)=>{const c=document.createElement("span");if(c.className="editora-statusbar-item",c.textContent=i,e.appendChild(c),s<n.length-1){const u=document.createElement("span");u.className="editora-statusbar-separator",u.textContent="|",e.appendChild(u)}}),this.container.appendChild(t),this.container.appendChild(e)}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.container=void 0}}class et{constructor(t){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...t},this.element=this.createElement(),this.attachEventListeners()}createElement(){const t=document.createElement("dialog");t.className="editora-dialog",this.config.width&&(t.style.width=this.config.width),this.config.height&&(t.style.height=this.config.height);const e=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((o,n)=>`<button type="button" class="editora-btn ${o.type==="danger"?"editora-btn-danger":o.type==="primary"||o.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${o.label}</button>`).join(""):`
|
|
8
8
|
<button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
|
|
9
9
|
<button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
|
|
10
10
|
`;if(t.innerHTML=`
|
|
@@ -522,5 +522,5 @@ var Editora=(function(g){"use strict";class lt{constructor(t,e,o){this.doc=t,thi
|
|
|
522
522
|
`),s=i.length,c=i[i.length-1].length+1;return{line:s,column:c}}function je(a,t,e){var s;let o=0;const n=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,null);let i=n.firstChild();for(;i;){if(i===t){o+=e;break}else i.nodeType===Node.TEXT_NODE&&(o+=((s=i.textContent)==null?void 0:s.length)||0);i=n.nextNode()}return o}function $e(a){var o,n;const t=a.querySelectorAll("div, p, br, h1, h2, h3, h4, h5, h6, blockquote, li, pre");let e=1;if(t.length>0){e=t.length;const i=t[t.length-1];(i.tagName==="BR"||((o=i.innerHTML)==null?void 0:o.trim())===""||((n=i.textContent)==null?void 0:n.trim())==="")&&e++}else{const s=(a.textContent||"").split(`
|
|
523
523
|
`).length;e=Math.max(1,s)}return e}function We(a){const t=a.trim()?a.trim().split(/\s+/).length:0,e=a.length;return{words:t,chars:e}}function qe(a,t){const e=a.toString();return{startLine:t.line,startColumn:t.column,endLine:t.line,endColumn:t.column+e.length,selectedChars:e.length,selectedWords:e.trim().split(/\s+/).filter(Boolean).length}}function Ge(a,t){(t==null||t>a.length)&&(t=a.length);for(var e=0,o=Array(t);e<t;e++)o[e]=a[e];return o}function fn(a){if(Array.isArray(a))return a}function gn(a,t){var e=a==null?null:typeof Symbol!="undefined"&&a[Symbol.iterator]||a["@@iterator"];if(e!=null){var o,n,i,s,c=[],u=!0,f=!1;try{if(i=(e=e.call(a)).next,t!==0)for(;!(u=(o=i.call(e)).done)&&(c.push(o.value),c.length!==t);u=!0);}catch(b){f=!0,n=b}finally{try{if(!u&&e.return!=null&&(s=e.return(),Object(s)!==s))return}finally{if(f)throw n}}return c}}function bn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
524
524
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yn(a,t){return fn(a)||gn(a,t)||vn(a,t)||bn()}function vn(a,t){if(a){if(typeof a=="string")return Ge(a,t);var e={}.toString.call(a).slice(8,-1);return e==="Object"&&a.constructor&&(e=a.constructor.name),e==="Map"||e==="Set"?Array.from(a):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Ge(a,t):void 0}}const Ke=Object.entries,Ve=Object.setPrototypeOf,En=Object.isFrozen,wn=Object.getPrototypeOf,xn=Object.getOwnPropertyDescriptor;let _=Object.freeze,D=Object.seal,ct=Object.create,Ye=typeof Reflect!="undefined"&&Reflect,ee=Ye.apply,oe=Ye.construct;_||(_=function(t){return t}),D||(D=function(t){return t}),ee||(ee=function(t,e){for(var o=arguments.length,n=new Array(o>2?o-2:0),i=2;i<o;i++)n[i-2]=arguments[i];return t.apply(e,n)}),oe||(oe=function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;n<e;n++)o[n-1]=arguments[n];return new t(...o)});const ot=I(Array.prototype.forEach),kn=I(Array.prototype.lastIndexOf),Xe=I(Array.prototype.pop),Tt=I(Array.prototype.push),Tn=I(Array.prototype.splice),dt=Array.isArray,Ct=I(String.prototype.toLowerCase),ne=I(String.prototype.toString),Ze=I(String.prototype.match),St=I(String.prototype.replace),Je=I(String.prototype.indexOf),Cn=I(String.prototype.trim),Sn=I(Number.prototype.toString),An=I(Boolean.prototype.toString),Qe=typeof BigInt=="undefined"?null:I(BigInt.prototype.toString),to=typeof Symbol=="undefined"?null:I(Symbol.prototype.toString),N=I(Object.prototype.hasOwnProperty),At=I(Object.prototype.toString),O=I(RegExp.prototype.test),K=Ln(TypeError);function I(a){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,o=new Array(e>1?e-1:0),n=1;n<e;n++)o[n-1]=arguments[n];return ee(a,t,o)}}function Ln(a){return function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return oe(a,e)}}function w(a,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ct;if(Ve&&Ve(a,null),!dt(t))return a;let o=t.length;for(;o--;){let n=t[o];if(typeof n=="string"){const i=e(n);i!==n&&(En(t)||(t[o]=i),n=i)}a[n]=!0}return a}function Mn(a){for(let t=0;t<a.length;t++)N(a,t)||(a[t]=null);return a}function H(a){const t=ct(null);for(const o of Ke(a)){var e=yn(o,2);const n=e[0],i=e[1];N(a,n)&&(dt(i)?t[n]=Mn(i):i&&typeof i=="object"&&i.constructor===Object?t[n]=H(i):t[n]=i)}return t}function In(a){switch(typeof a){case"string":return a;case"number":return Sn(a);case"boolean":return An(a);case"bigint":return Qe?Qe(a):"0";case"symbol":return to?to(a):"Symbol()";case"undefined":return At(a);case"function":case"object":{if(a===null)return At(a);const t=a,e=j(t,"toString");if(typeof e=="function"){const o=e(t);return typeof o=="string"?o:At(o)}return At(a)}default:return At(a)}}function j(a,t){for(;a!==null;){const o=xn(a,t);if(o){if(o.get)return I(o.get);if(typeof o.value=="function")return I(o.value)}a=wn(a)}function e(){return null}return e}function _n(a){try{return O(a,""),!0}catch(t){return!1}}const eo=_(["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"]),ie=_(["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"]),re=_(["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"]),Dn=_(["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"]),ae=_(["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"]),On=_(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),oo=_(["#text"]),no=_(["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"]),se=_(["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"]),io=_(["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"]),Nt=_(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Rn=D(/{{[\w\W]*|^[\w\W]*}}/g),Pn=D(/<%[\w\W]*|^[\w\W]*%>/g),Nn=D(/\${[\w\W]*/g),zn=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),Fn=D(/^aria-[\-\w]+$/),ro=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Hn=D(/^(?:\w+script|data):/i),Un=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Bn=D(/^html$/i),jn=D(/^[a-z][.\w]*(-[.\w]+)+$/i),ao=D(/<[/\w!]/g),so=D(/<[/\w]/g),$n=D(/<\/no(script|embed|frames)/i),Wn=D(/\/>/i),U={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},lo=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],qn=_(w({},lo)),Gn=(function(){const a={};return ot(lo,t=>{a[t]=D(new RegExp("</"+t+"(?=[\\t\\n\\f\\r />])","i"))}),_(a)})(),Kn=function(){return typeof window=="undefined"?null:window},Vn=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let o=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(o=e.getAttribute(n));const i="dompurify"+(o?"#"+o:"");try{return t.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch(s){return console.warn("TrustedTypes policy "+i+" could not be created."),null}},co=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},V=function(t,e,o,n){return N(t,e)&&dt(t[e])?w(n.base?H(n.base):{},t[e],n.transform):o},le=function(t,e,o){const n=N(t,e)?t[e]:void 0;return n&&typeof n=="object"?H(n):o()};function uo(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Kn();const t=h=>uo(h);if(t.version="3.4.16",t.removed=[],!a||!a.document||a.document.nodeType!==U.document||!a.Element)return t.isSupported=!1,t;let e=a.document;const o=e,n=o.currentScript;a.DocumentFragment;const i=a.HTMLTemplateElement,s=a.Node,c=a.Element,u=a.NodeFilter;a.NamedNodeMap===void 0&&(a.NamedNodeMap||a.MozNamedAttrMap),a.HTMLFormElement;const f=a.DOMParser,b=a.trustedTypes,T=c.prototype,v=j(T,"cloneNode"),x=j(T,"remove"),k=j(T,"removeAttributeNode"),Z=j(T,"nextSibling"),R=j(T,"childNodes"),z=j(T,"parentNode"),xo=j(T,"shadowRoot"),me=j(T,"attributes"),nt=s&&s.prototype?j(s.prototype,"nodeType"):null,ht=s&&s.prototype?j(s.prototype,"nodeName"):null,Bt=s&&s.prototype?j(s.prototype,"ownerDocument"):null,Mt=function(r){return nt?nt(r):r.nodeType},fe=function(r){return ht?ht(r):r.nodeName};if(typeof i=="function"){const h=e.createElement("template");h.content&&h.content.ownerDocument&&(e=h.content.ownerDocument)}let F,it="",ge,ko=!1,It=0;const To=function(){if(It>0)throw K('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.')},pt=function(r){To(),It++;try{return F.createHTML(r)}finally{It--}},pi=function(r){To(),It++;try{return F.createScriptURL(r)}finally{It--}},mi=function(){return ko||(ge=Vn(b,n),ko=!0),ge},jt=e,be=jt.implementation,Co=jt.createNodeIterator,fi=jt.createDocumentFragment,gi=jt.getElementsByTagName,bi=o.importNode;let C=co();t.isSupported=typeof Ke=="function"&&typeof z=="function"&&be&&be.createHTMLDocument!==void 0;const yi=Rn,vi=Pn,Ei=Nn,wi=zn,xi=Fn,ki=Hn,So=Un,Ti=jn;let Ao=ro,S=null;const ye=w({},[...eo,...ie,...re,...ae,...oo]);let A=null;const ve=w({},[...no,...se,...io,...Nt]);let W=Object.seal(ct(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}})),_t=null,Lo=null;const J=Object.seal(ct(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mo=!0,Ee=!0,Io=!1,_o=!0,Q=!1,rt=!0,at=!1,we=!1,$t=null,Wt=null,xe=!1,mt=!1,qt=!1,Gt=!1,Do=!0,Oo=!1;const Ro="user-content-";let ke=!0,Te=!1,ft={},gt=null;const Po=w({},["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 No=null;const zo=w({},["audio","video","img","source","image","track"]);let Fo=null;const Ho=w({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Kt="http://www.w3.org/1998/Math/MathML",Vt="http://www.w3.org/2000/svg",q="http://www.w3.org/1999/xhtml";let bt=q,Ce=!1,Se=null;const Ci=w({},[Kt,Vt,q],ne),Uo=_(["mi","mo","mn","ms","mtext"]);let Ae=w({},Uo);const Bo=_(["annotation-xml"]);let Le=w({},Bo);const Si=w({},["title","style","font","a","script"]);let Dt=null;const Ai=["application/xhtml+xml","text/html"],Li="text/html";let M=null,yt=null;const Mi=e.createElement("form"),jo=function(r){return r instanceof RegExp||r instanceof Function},Me=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(yt&&yt===r)return;(!r||typeof r!="object")&&(r={}),r=H(r),Dt=Ai.indexOf(r.PARSER_MEDIA_TYPE)===-1?Li:r.PARSER_MEDIA_TYPE,M=Dt==="application/xhtml+xml"?ne:Ct,S=V(r,"ALLOWED_TAGS",ye,{transform:M}),A=V(r,"ALLOWED_ATTR",ve,{transform:M}),Se=V(r,"ALLOWED_NAMESPACES",Ci,{transform:ne}),Fo=V(r,"ADD_URI_SAFE_ATTR",Ho,{transform:M,base:Ho}),No=V(r,"ADD_DATA_URI_TAGS",zo,{transform:M,base:zo}),gt=V(r,"FORBID_CONTENTS",Po,{transform:M}),_t=V(r,"FORBID_TAGS",H({}),{transform:M}),Lo=V(r,"FORBID_ATTR",H({}),{transform:M}),ft=N(r,"USE_PROFILES")?r.USE_PROFILES&&typeof r.USE_PROFILES=="object"?H(r.USE_PROFILES):r.USE_PROFILES:!1,Mo=r.ALLOW_ARIA_ATTR!==!1,Ee=r.ALLOW_DATA_ATTR!==!1,Io=r.ALLOW_UNKNOWN_PROTOCOLS||!1,_o=r.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=r.SAFE_FOR_TEMPLATES||!1,rt=r.SAFE_FOR_XML!==!1,at=r.WHOLE_DOCUMENT||!1,mt=r.RETURN_DOM||!1,qt=r.RETURN_DOM_FRAGMENT||!1,Gt=r.RETURN_TRUSTED_TYPE||!1,xe=r.FORCE_BODY||!1,Do=r.SANITIZE_DOM!==!1,Oo=r.SANITIZE_NAMED_PROPS||!1,ke=r.KEEP_CONTENT!==!1,Te=r.IN_PLACE||!1,Ao=_n(r.ALLOWED_URI_REGEXP)?r.ALLOWED_URI_REGEXP:ro,bt=typeof r.NAMESPACE=="string"?r.NAMESPACE:q,Ae=le(r,"MATHML_TEXT_INTEGRATION_POINTS",()=>w({},Uo)),Le=le(r,"HTML_INTEGRATION_POINTS",()=>w({},Bo));const l=le(r,"CUSTOM_ELEMENT_HANDLING",()=>ct(null));if(W=ct(null),N(l,"tagNameCheck")&&jo(l.tagNameCheck)&&(W.tagNameCheck=l.tagNameCheck),N(l,"attributeNameCheck")&&jo(l.attributeNameCheck)&&(W.attributeNameCheck=l.attributeNameCheck),N(l,"allowCustomizedBuiltInElements")&&typeof l.allowCustomizedBuiltInElements=="boolean"&&(W.allowCustomizedBuiltInElements=l.allowCustomizedBuiltInElements),D(W),Q&&(Ee=!1),qt&&(mt=!0),ft&&(S=w({},oo),A=ct(null),ft.html===!0&&(w(S,eo),w(A,no)),ft.svg===!0&&(w(S,ie),w(A,se),w(A,Nt)),ft.svgFilters===!0&&(w(S,re),w(A,se),w(A,Nt)),ft.mathMl===!0&&(w(S,ae),w(A,io),w(A,Nt))),J.tagCheck=null,J.attributeCheck=null,N(r,"ADD_TAGS")&&(typeof r.ADD_TAGS=="function"?J.tagCheck=r.ADD_TAGS:dt(r.ADD_TAGS)&&(S===ye&&(S=H(S)),w(S,r.ADD_TAGS,M))),N(r,"ADD_ATTR")&&(typeof r.ADD_ATTR=="function"?J.attributeCheck=r.ADD_ATTR:dt(r.ADD_ATTR)&&(A===ve&&(A=H(A)),w(A,r.ADD_ATTR,M))),N(r,"ADD_FORBID_CONTENTS")&&dt(r.ADD_FORBID_CONTENTS)&&(gt===Po&&(gt=H(gt)),w(gt,r.ADD_FORBID_CONTENTS,M)),ke&&(S["#text"]=!0),at&&w(S,["html","head","body"]),S.table&&(w(S,["tbody"]),delete _t.tbody),r.TRUSTED_TYPES_POLICY){if(typeof r.TRUSTED_TYPES_POLICY.createHTML!="function")throw K('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof r.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw K('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const d=F;F=r.TRUSTED_TYPES_POLICY;try{it=pt("")}catch(p){throw F=d,p}}else r.TRUSTED_TYPES_POLICY===null?(F=void 0,it=""):(F===void 0&&(F=mi()),F&&typeof it=="string"&&(it=pt("")));_&&_(r),yt=r},$o=w({},[...ie,...re,...Dn]),Wo=w({},[...ae,...On]),Ii=function(r,l,d){return l.namespaceURI===q?r==="svg":l.namespaceURI===Kt?r==="svg"&&(d==="annotation-xml"||Ae[d]):!!$o[r]},_i=function(r,l,d){return l.namespaceURI===q?r==="math":l.namespaceURI===Vt?r==="math"&&Le[d]:!!Wo[r]},Di=function(r,l,d){return l.namespaceURI===Vt&&!Le[d]||l.namespaceURI===Kt&&!Ae[d]?!1:!Wo[r]&&(Si[r]||!$o[r])},Oi=function(r){let l=z(r);(!l||!l.tagName)&&(l={namespaceURI:bt,tagName:"template"});const d=Ct(r.tagName),p=Ct(l.tagName);return Se[r.namespaceURI]?r.namespaceURI===Vt?Ii(d,l,p):r.namespaceURI===Kt?_i(d,l,p):r.namespaceURI===q?Di(d,l,p):!!(Dt==="application/xhtml+xml"&&Se[r.namespaceURI]):!1},tt=function(r){Tt(t.removed,{element:r});try{z(r).removeChild(r)}catch(l){if(x(r),!z(r))throw K("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},qo=function(r,l,d){try{k(r,l)}catch(p){try{r.removeAttribute(d)}catch(m){}}},Yt=function(r){Xt(r);const l=R(r);if(l){const p=[];ot(l,m=>{Tt(p,m)}),ot(p,m=>{try{x(m)}catch(y){}})}const d=me(r);if(d)for(let p=d.length-1;p>=0;--p){const m=d[p],y=m&&m.name;typeof y=="string"&&qo(r,m,y)}},st=function(r,l,d){if(!d)try{d=l.getAttributeNode(r)}catch(p){d=null}Tt(t.removed,{attribute:d||null,from:l});try{d?k(l,d):l.removeAttribute(r)}catch(p){try{l.removeAttribute(r)}catch(m){}}if(r==="is")if(mt||qt)try{tt(l)}catch(p){}else try{l.setAttribute(r,"")}catch(p){}},Ri=function(r){const l=me(r);if(l)for(let d=l.length-1;d>=0;--d){const p=l[d],m=p&&p.name;typeof m!="string"||A[M(m)]||qo(r,p,m)}},Xt=function(r){const l=[r];for(;l.length>0;){const d=l.pop();Mt(d)===U.element&&Ri(d);const p=R(d);if(p)for(let m=p.length-1;m>=0;--m)l.push(p[m])}},Go=function(r,l){return rt?r==="patchsrc"?!0:r==="for"&&l!=="label"&&l!=="output":!1},Pi=function(r){if(!rt)return;const l=[r];for(;l.length>0;){const d=l.pop(),p=Mt(d);if(p===U.processingInstruction||p===U.comment&&O(so,d.data)){try{x(d)}catch(y){}continue}if(p===U.element){const y=d,E=M(fe(d));try{y.hasAttribute&&y.hasAttribute("patchsrc")&&y.removeAttribute("patchsrc"),y.hasAttribute&&y.hasAttribute("for")&&Go("for",E)&&y.removeAttribute("for")}catch(L){}}const m=R(d);if(m)for(let y=m.length-1;y>=0;--y)l.push(m[y])}},Ko=function(r){let l=null,d=null;if(xe)r="<remove></remove>"+r;else{const y=Ze(r,/^[\r\n\t ]+/);d=y&&y[0]}Dt==="application/xhtml+xml"&&bt===q&&(r='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+r+"</body></html>");const p=F?pt(r):r;if(bt===q)try{l=new f().parseFromString(p,Dt)}catch(y){}if(!l||!l.documentElement){l=be.createDocument(bt,"template",null);try{l.documentElement.innerHTML=Ce?it:p}catch(y){}}const m=l.body||l.documentElement;return r&&d&&m.insertBefore(e.createTextNode(d),m.childNodes[0]||null),bt===q?gi.call(l,at?"html":"body")[0]:at?l.documentElement:m},Vo=function(r){const l=Bt?Bt(r):r.ownerDocument;return Co.call(l||r,r,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Zt=function(r){return r=St(r,yi," "),r=St(r,vi," "),r=St(r,Ei," "),r},Ie=function(r){var l;r.normalize();const d=Bt?Bt(r):r.ownerDocument,p=Co.call(d||r,r,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null);let m=p.nextNode();for(;m;)m.data=Zt(m.data),m=p.nextNode();const y=(l=r.querySelectorAll)===null||l===void 0?void 0:l.call(r,"template");y&&ot(y,E=>{vt(E.content)&&Ie(E.content)})},Jt=function(r){const l=ht?ht(r):null;return typeof l!="string"||M(l)!=="form"?!1:typeof r.nodeName!="string"||typeof r.textContent!="string"||typeof r.removeChild!="function"||r.attributes!==me(r)||typeof r.removeAttribute!="function"||typeof r.removeAttributeNode!="function"||typeof r.getAttributeNode!="function"||typeof r.setAttribute!="function"||typeof r.namespaceURI!="string"||typeof r.insertBefore!="function"||typeof r.hasChildNodes!="function"||r.nodeType!==nt(r)||r.childNodes!==R(r)},vt=function(r){if(!nt||typeof r!="object"||r===null)return!1;try{return nt(r)===U.documentFragment}catch(l){return!1}},Ot=function(r){if(!nt||typeof r!="object"||r===null)return!1;try{return typeof nt(r)=="number"}catch(l){return!1}};function G(h,r,l){h.length!==0&&ot(h,d=>{d.call(t,r,l,yt)})}const Ni=function(r,l){return!!(rt&&r.hasChildNodes()&&!Ot(r.firstElementChild)&&O(ao,r.textContent)&&O(ao,r.innerHTML)||rt&&r.namespaceURI===q&&qn[l]&&(Ot(r.firstElementChild)||typeof r.textContent=="string"&&O(Gn[l],r.textContent))||r.nodeType===U.processingInstruction||rt&&r.nodeType===U.comment&&O(so,r.data))},Qt=function(r,l){if(r instanceof RegExp)return O(r,l);if(r instanceof Function){for(var d=arguments.length,p=new Array(d>2?d-2:0),m=2;m<d;m++)p[m-2]=arguments[m];return!!r(l,...p)}return!1},zi=function(r,l,d){if(!_t[l]&&Jo(l)&&Qt(W.tagNameCheck,l))return!1;if(ke&&!gt[l]){const p=z(r),m=R(r);if(m&&p){const y=m.length;for(let E=y-1;E>=0;--E){const L=r===d?v(m[E],!0):m[E];p.insertBefore(L,Z(r))}}}return tt(r),!0},Yo=function(r,l,d,p){return r.length===0?l:l===d||l===p?H(l):l},Et=function(r,l){return r===l||z(r)!==null?!1:(Te&&Xt(r),!0)},Xo=function(r,l){if(G(C.beforeSanitizeElements,r,null),Et(r,l))return!0;if(Jt(r))return tt(r),!0;const d=M(fe(r));if(S=Yo(C.uponSanitizeElement,S,ye,$t),G(C.uponSanitizeElement,r,{tagName:d,allowedTags:S}),Et(r,l))return!0;if(Ni(r,d))return tt(r),!0;if(_t[d]||!(J.tagCheck instanceof Function&&J.tagCheck(d))&&!S[d]){const p=zi(r,d,l);return p===!1&&(G(C.afterSanitizeElements,r,null),Et(r,l))?!0:p}if(Mt(r)===U.element&&!Oi(r)||(d==="noscript"||d==="noembed"||d==="noframes")&&O($n,r.innerHTML))return tt(r),!0;if(Q&&r.nodeType===U.text){const p=Zt(r.textContent);r.textContent!==p&&(Tt(t.removed,{element:r.cloneNode()}),r.textContent=p)}return G(C.afterSanitizeElements,r,null),Et(r,l)},Zo=function(r,l,d){if(Lo[l]||Go(l,r)||Do&&(l==="id"||l==="name")&&(d in e||d in Mi))return!1;const p=A[l]||J.attributeCheck instanceof Function&&J.attributeCheck(l,r);return Ee&&O(wi,l)||Mo&&O(xi,l)?!0:p?Fo[l]||O(Ao,St(d,So,""))||(l==="src"||l==="xlink:href"||l==="href")&&r!=="script"&&Je(d,"data:")===0&&No[r]||Io&&!O(ki,St(d,So,""))?!0:!d:Jo(r)&&Qt(W.tagNameCheck,r)&&Qt(W.attributeNameCheck,l,r)||l==="is"&&W.allowCustomizedBuiltInElements&&Qt(W.tagNameCheck,d)},Fi=w({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Jo=function(r){return!Fi[Ct(r)]&&O(Ti,r)},Hi=function(r,l,d,p){if(F&&typeof b=="object"&&typeof b.getAttributeType=="function"&&!d)switch(b.getAttributeType(r,l)){case"TrustedHTML":return pt(p);case"TrustedScriptURL":return pi(p)}return p},Ui=function(r,l,d,p){try{return d?r.setAttributeNS(d,l,p):r.setAttribute(l,p),Jt(r)?(tt(r),!1):!0}catch(m){return st(l,r),!1}},Qo=function(r,l){if(G(C.beforeSanitizeAttributes,r,null),Et(r,l))return;const d=r.attributes;if(!d||Jt(r))return;A=Yo(C.uponSanitizeAttribute,A,ve,Wt);const p={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0};let m=d.length;const y=M(r.nodeName);for(;m--;){const E=d[m],L=E.name,$=E.namespaceURI,B=E.value,wt=M(L),De=B;let P=L==="value"?De:Cn(De),tn=!1;if(p.attrName=wt,p.attrValue=P,p.keepAttr=!0,p.forceKeepAttr=void 0,G(C.uponSanitizeAttribute,r,p),P=p.attrValue,Oo&&(wt==="id"||wt==="name")&&Je(P,Ro)!==0&&(st(L,r,E),P=Ro+P,tn=!0),rt&&O(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,P)){st(L,r,E);continue}if(wt==="attributename"&&Ze(P,"href")){st(L,r,E);continue}if(!p.forceKeepAttr){if(!p.keepAttr){st(L,r,E);continue}if(!_o&&O(Wn,P)){st(L,r,E);continue}if(Q&&(P=Zt(P)),!Zo(y,wt,P)){st(L,r,E);continue}P=Hi(y,wt,$,P),P!==De&&Ui(r,L,$,P)&&tn&&Xe(t.removed)}}G(C.afterSanitizeAttributes,r,null),Et(r,l)},te=function(r){let l=null;const d=Vo(r);for(G(C.beforeSanitizeShadowDOM,r,null);l=d.nextNode();)if(G(C.uponSanitizeShadowNode,l,null),Xo(l,r),Qo(l,r),vt(l.content)&&te(l.content),Mt(l)===U.element){const p=xo(l);vt(p)&&(_e(p),te(p))}G(C.afterSanitizeShadowDOM,r,null)},_e=function(r){const l=[{node:r,shadow:null}];for(;l.length>0;){const d=l.pop();if(d.shadow){te(d.shadow);continue}const p=d.node,m=Mt(p)===U.element,y=R(p);if(y)for(let E=y.length-1;E>=0;--E)l.push({node:y[E],shadow:null});if(m){const E=ht?ht(p):null;if(typeof E=="string"&&M(E)==="template"){const L=p.content;vt(L)&&l.push({node:L,shadow:null})}}if(m){const E=xo(p);vt(E)&&l.push({node:null,shadow:E},{node:E,shadow:null})}}};return t.sanitize=function(h){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,d=null,p=null,m=null;if(Ce=!h,Ce&&(h="<!-->"),typeof h!="string"&&!Ot(h)&&(h=In(h),typeof h!="string"))throw K("dirty is not a string, aborting");if(!t.isSupported)return h;we?(S=$t,A=Wt):Me(r),(C.uponSanitizeElement.length>0||C.uponSanitizeAttribute.length>0)&&(S=H(S)),C.uponSanitizeAttribute.length>0&&(A=H(A)),t.removed=[];const y=Te&&typeof h!="string"&&Ot(h);if(y){Pi(h);const $=fe(h);if(typeof $=="string"){const B=M($);if(!S[B]||_t[B])throw Yt(h),K("root node is forbidden and cannot be sanitized in-place")}if(Jt(h))throw Yt(h),K("root node is clobbered and cannot be sanitized in-place");try{_e(h)}catch(B){throw Yt(h),B}}else if(Ot(h))l=Ko("<!---->"),d=l.ownerDocument.importNode(h,!0),d.nodeType===U.element&&d.nodeName==="BODY"||d.nodeName==="HTML"?l=d:l.appendChild(d),_e(l);else{if(!mt&&!Q&&!at&&h.indexOf("<")===-1)return F&&Gt?pt(h):h;if(l=Ko(h),!l)return mt?null:Gt?it:""}l&&xe&&tt(l.firstChild);const E=y?h:l;try{const $=Vo(E);for(;p=$.nextNode();)Xo(p,E),Qo(p,E),vt(p.content)&&te(p.content)}catch($){throw y&&(Yt(h),ot(t.removed,B=>{B.element&&Xt(B.element)})),$}if(y){let $=!1;if(ot(t.removed,B=>{B.element&&(B.element===h&&($=!0),Xt(B.element))}),$)throw K("a node selected for removal could not be safely returned; refusing to sanitize in place");return Q&&Ie(h),h}if(mt){if(Q&&Ie(l),qt)for(m=fi.call(l.ownerDocument);l.firstChild;)m.appendChild(l.firstChild);else m=l;return(A.shadowroot||A.shadowrootmode)&&(m=bi.call(o,m,!0)),m}let L=at?l.outerHTML:l.innerHTML;return at&&S["!doctype"]&&l.ownerDocument&&l.ownerDocument.doctype&&l.ownerDocument.doctype.name&&O(Bn,l.ownerDocument.doctype.name)&&(L="<!DOCTYPE "+l.ownerDocument.doctype.name+`>
|
|
525
|
-
`+L),Q&&(L=Zt(L)),F&&Gt?pt(L):L},t.setConfig=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Me(h),we=!0,$t=S,Wt=A},t.clearConfig=function(){yt=null,we=!1,$t=null,Wt=null,F=ge,it=""},t.isValidAttribute=function(h,r,l){yt||Me({});const d=M(h),p=M(r);return Zo(d,p,l)},t.addHook=function(h,r){typeof r=="function"&&N(C,h)&&Tt(C[h],r)},t.removeHook=function(h,r){if(N(C,h)){if(r!==void 0){const l=kn(C[h],r);return l===-1?void 0:Tn(C[h],l,1)[0]}return Xe(C[h])}},t.removeHooks=function(h){N(C,h)&&(C[h]=[])},t.removeAllHooks=function(){C=co()},t}var zt=uo();const Yn=["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"],Xn={"*":["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"]},Zn="data-editora-embed";function Jn(a){if(!a||/\s/.test(a.trim()))return!1;try{const t=new URL(a.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function ho(a,t,e,o){if((t==null?void 0:t.sanitize)===!1)return a;const n=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:Yn,i=e!=null&&e.length?Array.from(new Set([...n,...e])):n,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:Xn,u=new Set;for(const T of Object.values(c))for(const v of T)u.add(v);const f={ALLOWED_TAGS:i,ALLOWED_ATTR:Array.from(u)};if(!o)return zt.sanitize(a,f);const b=i.includes("iframe");zt.addHook("uponSanitizeElement",(T,v)=>{var k;if(v.tagName!=="iframe")return;const x=T;v.allowedTags.iframe=b||((k=x.getAttribute)==null?void 0:k.call(x,Zn))==="true"&&Jn(x.getAttribute("src"))});try{return zt.sanitize(a,f)}finally{zt.removeHook("uponSanitizeElement")}}function po(a,t,e,o){return ho(a,t,o,!1)}function mo(a,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?a:po(a,t)}function ce(a,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?a:ho(a,t,o,!0)}const Qn=".resize-handle, .table-resize-handle",ti=/resize-handle/;function de(a){if(!a||!ti.test(a))return a;const t=document.createElement("template");t.innerHTML=a;const e=new Set;return t.content.querySelectorAll(Qn).forEach(o=>{const n=o.parentElement;n&&(n.tagName==="TD"||n.tagName==="TH")&&e.add(n),o.remove()}),e.forEach(o=>{var n;o.style.position==="relative"&&(o.style.removeProperty("position"),(n=o.getAttribute("style"))!=null&&n.trim()||o.removeAttribute("style"))}),t.innerHTML}function ut(a){return a?de(a.innerHTML):""}const Ut=class Ut{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 s=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(s.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(s.sticky=!!e.toolbarSticky),e.toolbar=s}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 s=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(s.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(s.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(s.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(s.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(s.apiUrl=e.autosaveApiUrl),e.autosave=s}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 s={...o,...e.autosave};s.intervalMs===void 0&&s.interval!==void 0&&(s.intervalMs=Number(s.interval)),s.enabled===void 0&&(s.enabled=!0),(!Number.isFinite(s.intervalMs)||s.intervalMs<=0)&&(s.intervalMs=o.intervalMs),e.autosave=s}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const s=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(s.locale=e.languageLocale),e.languageDirection!==void 0&&(s.direction=e.languageDirection),e.language=s}const n={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:n.direction}:typeof e.language=="object"&&e.language?e.language={...n,...e.language}:e.language=n,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const s=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(s.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(s.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(s.apiUrl=e.spellcheckApiUrl),e.spellcheck=s}const i={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...i,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const s={...i,...e.spellcheck};!s.provider&&s.mode&&(s.provider=s.mode==="local"?"browser":"api"),s.enabled===void 0&&(s.enabled=!!(s.mode||s.provider||s.apiUrl)),e.spellcheck=s}else e.spellcheck=i;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,n]of Object.entries(t)){const i=this.kebabToCamel(o);e[i]=this.BOOLEAN_ATTRIBUTES.has(o)&&(n===""||n===o)?!0:this.parseAttributeValue(n)}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[n,i]of Object.entries(o))i!=null&&(typeof i=="object"&&!Array.isArray(i)&&e[n]?e[n]=this.merge(e[n],i):e[n]=i);return e}};Ut.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},Ut.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 Ft=Ut;class fo{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 n=await o();return e&&this.applyPluginConfig(n,e),this.loadedPlugins.set(t,n),n}async loadMultiple(t,e){return(await Promise.all(t.map(n=>this.load(n,e)))).filter(n=>n!==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)}}class go{constructor(t={}){this.changeListeners=[],this.options=t,this.engine=new Rt({content:t.content,plugins:t.plugins||[],readonly:t.readonly}),t.onChange&&this.onChange(t.onChange),this.engine.on("change",()=>{const e=this.getHTML();this.changeListeners.forEach(o=>o(e))})}mount(t,e){this.contentElement=t,this.toolbarElement=e,this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.className="rte-content",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.options.toolbar!==!1&&this.toolbarElement&&(this.toolbar=new Pt({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((o,n)=>{this.execCommand(o,n)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const o=this.getHTML();this.changeListeners.forEach(n=>n(o))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setHTML(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){const o=this.engine.execCommand(t,e);return this.toolbar,o}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}onChange(t){return this.changeListeners.push(t),()=>{const e=this.changeListeners.indexOf(t);e>-1&&this.changeListeners.splice(e,1)}}registerCommand(t,e){if(typeof window!="undefined"){const o=window.__editorCommands||new Map;o.set(t,e),window.__editorCommands=o}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var t;return{getHTML:()=>this.getHTML(),setHTML:e=>this.setHTML(e),execCommand:(e,o)=>this.execCommand(e,o),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(e,o)=>this.registerCommand(e,o),onChange:e=>this.onChange(e),getState:()=>this.getState(),toolbar:{items:((t=this.options.plugins)==null?void 0:t.flatMap(e=>e.toolbar||[]))||[]}}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function ei(a){return new go(a)}class bo{constructor(t){this.options=t,this.containerElement=t.element;const e=this.resolvePlugins(t.plugins);this.engine=new Rt({content:t.content,plugins:e,readonly:t.readonly}),this.initializeDOM()}resolvePlugins(t){return t?typeof t=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):t:[]}initializeDOM(){this.containerElement.innerHTML="",this.containerElement.classList.add("editora-editor"),this.options.enableToolbar!==!1&&this.options.toolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.containerElement.appendChild(this.toolbarElement),this.toolbar=new Pt({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((t,e)=>{this.execCommand(t,e)}),this.toolbar.render(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content",this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.containerElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.containerElement.dispatchEvent(new CustomEvent("change",{detail:{html:this.getContent()}}))})}getContent(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){return this.engine.execCommand(t,e)}focus(){var t;(t=this.contentElement)==null||t.focus()}on(t,e){const o=n=>{e(n.detail)};return this.containerElement.addEventListener(t,o),()=>{this.containerElement.removeEventListener(t,o)}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.containerElement.innerHTML=""}}const oi='.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 Ht;const ni="__editoraCommandEditorRoot",ii="__editoraLastCommandButton",yo="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",vo=".rte-content, .editora-content",ri="Rich text editor",ue=new Set;let Y=null,Eo=!1,he=null,pe=null;function wo(a){if(!(a instanceof HTMLElement))return!1;const t=a;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function ai(a){return a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null}function Lt(a){if(!a)return null;if(wo(a))return a;const t=a.matches(yo)?a:a.closest(yo);return!t||!wo(t)?null:t}function si(){var n;if(typeof window=="undefined")return null;const a=window[ni];if(a instanceof HTMLElement){const i=Lt(a);if(i)return i;const s=a.matches(vo)?a:a.querySelector(vo);if(s){const c=Lt(s);if(c)return c}}const t=window[ii];if(t instanceof HTMLElement){const i=Lt(t);if(i)return i}const e=document.activeElement;if(e){const i=Lt(e);if(i)return i}const o=(n=window.getSelection)==null?void 0:n.call(window);if(o&&o.rangeCount>0){const i=Lt(ai(o.getRangeAt(0).startContainer));if(i)return i}if(Y&&Y.isConnected)return Y;for(const i of ue)if(i.isConnected)return i;return null}function li(){if(typeof window=="undefined"||Eo)return;he=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,pe=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const a=(t,...e)=>{const o=si();return o?o.execCommand(t,...e):he?he(t,...e):pe?pe(t,...e):!1};window.executeEditorCommand=a,window.execEditorCommand=a,Eo=!0}function ci(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const t=document.createElement("style");t.id=a,t.textContent=oi,document.head.appendChild(t)}}function di(){if(!Ht){const a=X.__globalPluginLoader;a?Ht=a:Ht=new fo}return Ht}class X extends HTMLElement{constructor(){if(super(),this.pluginLoader=di(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Pe,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,ci(),!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","aria-label","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(X.__globalPluginLoader){this.pluginLoader=X.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{X.__globalPluginLoader?(this.pluginLoader=X.__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 n;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),ue.add(this),Y||(Y=this),li(),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(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(s){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,s)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const i=this.innerHTML.trim();i&&this.setAttribute("data-initial-content",i)}const e=this.preservedContent;this.preservedContent=null;const o=this.sanitizeLoadedContent((n=e!=null?e:this.restoreAutosavedContent())!=null?n:this.getAttribute("data-initial-content")||"");this.engine=new Rt({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),n=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const i=this.config.plugins.split(/\s+/).filter(Boolean);n&&!i.includes("a11yChecker")&&i.push("a11yChecker");for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const i of this.config.plugins)if(typeof i=="string"){const s=await this.pluginLoader.load(i,this.getPluginLoadConfig(i));s&&t.push(s)}else t.push(i);if(n&&!t.some(i=>(i==null?void 0:i.name)==="a11yChecker")){const i=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));i&&t.push(i)}}}else{const i=this.pluginLoader.getRegisteredPluginNames();for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));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(){var e;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 o=(e=this.getAttribute("aria-label"))==null?void 0:e.trim(),n=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||n||ri)}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 i;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},n=this.loadedPlugins.find(s=>s.commands&&s.commands[t]);if(n&&n.commands){const s=n.commands[t];if(typeof s=="function")try{return t==="toggleFullscreen"?s(this,o):s(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((i=this.engine)==null?void 0:i.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const i=e[t];if(i&&typeof i=="object")return i}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"]},n=[t,t.toLowerCase(),...o[t]||[]];for(const i of n){const s=this.config[i];if(s&&typeof s=="object"&&!Array.isArray(s))return s}}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 ce(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 n=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(n)&&n>0?n: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(ut(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 n=document.createElement("div");n.innerHTML=t;const i=document.createDocumentFragment();for(;n.firstChild;)i.appendChild(n.firstChild);o.insertNode(i),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"]'),n=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 Pt({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((i,s)=>{var c;if(this.contentElement){this.contentElement.focus();const u=window.getSelection();if(!u||u.rangeCount===0||!this.contentElement.contains(u.anchorNode)){const f=document.createRange(),b=this.contentElement.lastChild||this.contentElement;b.nodeType===Node.TEXT_NODE?f.setStart(b,((c=b.textContent)==null?void 0:c.length)||0):b.nodeType===Node.ELEMENT_NODE?(f.selectNodeContents(b),f.collapse(!1)):f.setStart(this.contentElement,0),f.collapse(!0),u==null||u.removeAllRanges(),u==null||u.addRange(f)}}return this.executeCommand(i,s)}),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(i){console.warn("defaultParagraphSeparator not supported:",i)}if(e){const i=document.createElement("div");i.innerHTML=e.trim(),!Array.from(i.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const u=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(u)}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 He({enabled:!0}),this.floatingToolbar.create(this)),n?this.appendChild(n):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Ue({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var i;return(i=this.contentElement)==null?void 0:i.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 v;if(!this.contentElement)return;let n=this.contentElement.innerHTML;const i=(v=o==null?void 0:o.detail)==null?void 0:v.allowedTags,s=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),f=this.lastBeforeInputType;if(this.lastBeforeInputType=null,u.sanitizeOnInput!==!1&&c.sanitize!==!1&&!f){const x=ce(n,c,u,i);if(x!==n){const k=window.getSelection(),Z=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=x,Z&&k)try{k.removeAllRanges(),k.addRange(Z)}catch(R){}n=x}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const T=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:de(n)},bubbles:!0}))};s.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(T,s.debounceInputMs):T(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const n=this.config.contextMenu;(n===!1||typeof n=="object"&&n!==null&&n.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var b,T;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const n=this.config.paste||{};let i=((b=o.clipboardData)==null?void 0:b.getData("text/html"))||"";const s=((T=o.clipboardData)==null?void 0:T.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),f=!!i&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);if((n.clean||!n.keepFormatting)&&s){document.execCommand("insertText",!1,s);return}if(n.convertWord===!1&&f&&s){document.execCommand("insertText",!1,s);return}if(i){u.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(i=mo(i,c,u)),this.insertHTMLAtSelection(i);return}s&&document.execCommand("insertText",!1,s)}),this.contentElement.addEventListener("focus",()=>{Y=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:ut(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,(i,s)=>{this.executeCommand(i,s)})});const e=()=>{const o=this.getSelectionRangeInEditor(),n=document.activeElement,i=!!n&&!!this.contentElement&&(n===this.contentElement||this.contentElement.contains(n));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!i||!o&&!i||(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(i=>i.width>0||i.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 n=this.getSelectionRangeInEditor();if(!n){this.floatingToolbar.hide();return}if(n.collapsed){this.floatingToolbar.hide();return}const i=window.getSelection();if(!i){this.floatingToolbar.hide();return}const s=this.getSelectionAnchorRect(i,n);if(!s){this.floatingToolbar.hide();return}this.floatingToolbar.show(s.left,s.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:n,chars:i}=We(o),s=$e(this.contentElement);let c,u;const f=this.getSelectionRangeInEditor();f&&(c=Be(this.contentElement,f),f.collapsed||(u=qe(f,c),c=void 0)),this.statusBar.update({wordCount:n,charCount:i,lineCount:s,cursorPosition:c,selectionInfo:u})}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"aria-label":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 Ft.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>ut(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,n;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=ut(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(),(n=this.statusBar)==null||n.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,ue.delete(this),Y===this&&(Y=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return ut(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()}}function ui(a){return new bo(a)}function hi(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",X)}return g.CharacterDialog=pn,g.ColorPicker=ln,g.CommandRegistry=Fe,g.ConfigResolver=Ft,g.Dialog=et,g.DocumentModel=kt,g.Dropdown=sn,g.Editor=on,g.EditorEngine=Rt,g.EditorState=lt,g.EmojiDialog=mn,g.FloatingToolbar=He,g.ImageDialog=un,g.KeyboardShortcutManager=Pe,g.LinkDialog=cn,g.MathDialog=hn,g.MediaPlugin=an,g.PluginLoader=fo,g.PluginManager=xt,g.PluginRuntime=Re,g.ReactAdapter=go,g.RichTextEditorElement=X,g.Schema=Oe,g.SpellcheckPlugin=rn,g.StatusBar=Ue,g.TableDialog=dn,g.ToolbarRenderer=Pt,g.VanillaAdapter=bo,g.calculateTextStats=We,g.countLines=$e,g.createEditor=ui,g.createPluginManager=en,g.createPluginRuntime=nn,g.createReactAdapter=ei,g.getCleanEditorHTML=ut,g.getCursorPosition=Be,g.getSelectionInfo=qe,g.getTextOffset=je,g.initWebComponent=hi,g.sanitizeHTML=po,g.sanitizeInputHTML=ce,g.sanitizePastedHTML=mo,g.stripEditorUiArtifacts=de,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}),g})({});
|
|
525
|
+
`+L),Q&&(L=Zt(L)),F&&Gt?pt(L):L},t.setConfig=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Me(h),we=!0,$t=S,Wt=A},t.clearConfig=function(){yt=null,we=!1,$t=null,Wt=null,F=ge,it=""},t.isValidAttribute=function(h,r,l){yt||Me({});const d=M(h),p=M(r);return Zo(d,p,l)},t.addHook=function(h,r){typeof r=="function"&&N(C,h)&&Tt(C[h],r)},t.removeHook=function(h,r){if(N(C,h)){if(r!==void 0){const l=kn(C[h],r);return l===-1?void 0:Tn(C[h],l,1)[0]}return Xe(C[h])}},t.removeHooks=function(h){N(C,h)&&(C[h]=[])},t.removeAllHooks=function(){C=co()},t}var zt=uo();const Yn=["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"],Xn={"*":["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"],ol:["start","reversed"],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"]},Zn="data-editora-embed";function Jn(a){if(!a||/\s/.test(a.trim()))return!1;try{const t=new URL(a.trim());return(t.protocol==="https:"||t.protocol==="http:")&&t.hostname.length>0}catch(t){return!1}}function ho(a,t,e,o){if((t==null?void 0:t.sanitize)===!1)return a;const n=t!=null&&t.allowedTags&&t.allowedTags.length>0?t.allowedTags:Yn,i=e!=null&&e.length?Array.from(new Set([...n,...e])):n,c=!!(t!=null&&t.allowedAttributes)&&Object.keys(t.allowedAttributes).length>0?t.allowedAttributes:Xn,u=new Set;for(const T of Object.values(c))for(const v of T)u.add(v);const f={ALLOWED_TAGS:i,ALLOWED_ATTR:Array.from(u)};if(!o)return zt.sanitize(a,f);const b=i.includes("iframe");zt.addHook("uponSanitizeElement",(T,v)=>{var k;if(v.tagName!=="iframe")return;const x=T;v.allowedTags.iframe=b||((k=x.getAttribute)==null?void 0:k.call(x,Zn))==="true"&&Jn(x.getAttribute("src"))});try{return zt.sanitize(a,f)}finally{zt.removeHook("uponSanitizeElement")}}function po(a,t,e,o){return ho(a,t,o,!1)}function mo(a,t,e){return(e==null?void 0:e.sanitizeOnPaste)===!1?a:po(a,t)}function ce(a,t,e,o){return(e==null?void 0:e.sanitizeOnInput)===!1?a:ho(a,t,o,!0)}const Qn=".resize-handle, .table-resize-handle",ti=/resize-handle/;function de(a){if(!a||!ti.test(a))return a;const t=document.createElement("template");t.innerHTML=a;const e=new Set;return t.content.querySelectorAll(Qn).forEach(o=>{const n=o.parentElement;n&&(n.tagName==="TD"||n.tagName==="TH")&&e.add(n),o.remove()}),e.forEach(o=>{var n;o.style.position==="relative"&&(o.style.removeProperty("position"),(n=o.getAttribute("style"))!=null&&n.trim()||o.removeAttribute("style"))}),t.innerHTML}function ut(a){return a?de(a.innerHTML):""}const Ut=class Ut{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 s=typeof e.toolbar=="object"&&e.toolbar?{...e.toolbar}:typeof e.toolbar=="string"?{items:e.toolbar}:{};e.toolbarFloating!==void 0&&(s.floating=!!e.toolbarFloating),e.toolbarSticky!==void 0&&(s.sticky=!!e.toolbarSticky),e.toolbar=s}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 s=typeof e.autosave=="object"&&e.autosave?{...e.autosave}:{};e.autosaveEnabled!==void 0&&(s.enabled=!!e.autosaveEnabled),e.autosaveIntervalMs!==void 0&&(s.intervalMs=Number(e.autosaveIntervalMs)),e.autosaveStorageKey!==void 0&&(s.storageKey=e.autosaveStorageKey),e.autosaveProvider!==void 0&&(s.provider=e.autosaveProvider),e.autosaveApiUrl!==void 0&&(s.apiUrl=e.autosaveApiUrl),e.autosave=s}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 s={...o,...e.autosave};s.intervalMs===void 0&&s.interval!==void 0&&(s.intervalMs=Number(s.interval)),s.enabled===void 0&&(s.enabled=!0),(!Number.isFinite(s.intervalMs)||s.intervalMs<=0)&&(s.intervalMs=o.intervalMs),e.autosave=s}else e.autosave=o;if(e.languageLocale!==void 0||e.languageDirection!==void 0){const s=typeof e.language=="object"&&e.language?{...e.language}:{};e.languageLocale!==void 0&&(s.locale=e.languageLocale),e.languageDirection!==void 0&&(s.direction=e.languageDirection),e.language=s}const n={locale:"en",direction:"ltr"};if(typeof e.language=="string"?e.language={locale:e.language,direction:n.direction}:typeof e.language=="object"&&e.language?e.language={...n,...e.language}:e.language=n,e.spellcheckEnabled!==void 0||e.spellcheckProvider!==void 0||e.spellcheckApiUrl!==void 0){const s=typeof e.spellcheck=="object"&&e.spellcheck?{...e.spellcheck}:{};e.spellcheckEnabled!==void 0&&(s.enabled=!!e.spellcheckEnabled),e.spellcheckProvider!==void 0&&(s.provider=e.spellcheckProvider),e.spellcheckApiUrl!==void 0&&(s.apiUrl=e.spellcheckApiUrl),e.spellcheck=s}const i={enabled:!1,provider:"browser",apiUrl:""};if(typeof e.spellcheck=="boolean")e.spellcheck={...i,enabled:e.spellcheck};else if(typeof e.spellcheck=="object"&&e.spellcheck){const s={...i,...e.spellcheck};!s.provider&&s.mode&&(s.provider=s.mode==="local"?"browser":"api"),s.enabled===void 0&&(s.enabled=!!(s.mode||s.provider||s.apiUrl)),e.spellcheck=s}else e.spellcheck=i;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,n]of Object.entries(t)){const i=this.kebabToCamel(o);e[i]=this.BOOLEAN_ATTRIBUTES.has(o)&&(n===""||n===o)?!0:this.parseAttributeValue(n)}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[n,i]of Object.entries(o))i!=null&&(typeof i=="object"&&!Array.isArray(i)&&e[n]?e[n]=this.merge(e[n],i):e[n]=i);return e}};Ut.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},Ut.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 Ft=Ut;class fo{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 n=await o();return e&&this.applyPluginConfig(n,e),this.loadedPlugins.set(t,n),n}async loadMultiple(t,e){return(await Promise.all(t.map(n=>this.load(n,e)))).filter(n=>n!==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)}}class go{constructor(t={}){this.changeListeners=[],this.options=t,this.engine=new Rt({content:t.content,plugins:t.plugins||[],readonly:t.readonly}),t.onChange&&this.onChange(t.onChange),this.engine.on("change",()=>{const e=this.getHTML();this.changeListeners.forEach(o=>o(e))})}mount(t,e){this.contentElement=t,this.toolbarElement=e,this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.className="rte-content",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.options.toolbar!==!1&&this.toolbarElement&&(this.toolbar=new Pt({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((o,n)=>{this.execCommand(o,n)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const o=this.getHTML();this.changeListeners.forEach(n=>n(o))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setHTML(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){const o=this.engine.execCommand(t,e);return this.toolbar,o}focus(){var t;(t=this.contentElement)==null||t.focus()}blur(){var t;(t=this.contentElement)==null||t.blur()}onChange(t){return this.changeListeners.push(t),()=>{const e=this.changeListeners.indexOf(t);e>-1&&this.changeListeners.splice(e,1)}}registerCommand(t,e){if(typeof window!="undefined"){const o=window.__editorCommands||new Map;o.set(t,e),window.__editorCommands=o}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var t;return{getHTML:()=>this.getHTML(),setHTML:e=>this.setHTML(e),execCommand:(e,o)=>this.execCommand(e,o),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(e,o)=>this.registerCommand(e,o),onChange:e=>this.onChange(e),getState:()=>this.getState(),toolbar:{items:((t=this.options.plugins)==null?void 0:t.flatMap(e=>e.toolbar||[]))||[]}}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function ei(a){return new go(a)}class bo{constructor(t){this.options=t,this.containerElement=t.element;const e=this.resolvePlugins(t.plugins);this.engine=new Rt({content:t.content,plugins:e,readonly:t.readonly}),this.initializeDOM()}resolvePlugins(t){return t?typeof t=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):t:[]}initializeDOM(){this.containerElement.innerHTML="",this.containerElement.classList.add("editora-editor"),this.options.enableToolbar!==!1&&this.options.toolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.containerElement.appendChild(this.toolbarElement),this.toolbar=new Pt({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((t,e)=>{this.execCommand(t,e)}),this.toolbar.render(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content",this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.containerElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.containerElement.dispatchEvent(new CustomEvent("change",{detail:{html:this.getContent()}}))})}getContent(){var t;return((t=this.contentElement)==null?void 0:t.innerHTML)||""}setContent(t){this.contentElement&&(this.contentElement.innerHTML=t)}execCommand(t,e){return this.engine.execCommand(t,e)}focus(){var t;(t=this.contentElement)==null||t.focus()}on(t,e){const o=n=>{e(n.detail)};return this.containerElement.addEventListener(t,o),()=>{this.containerElement.removeEventListener(t,o)}}destroy(){var t;this.engine.destroy(),(t=this.toolbar)==null||t.destroy(),this.containerElement.innerHTML=""}}const oi='.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 Ht;const ni="__editoraCommandEditorRoot",ii="__editoraLastCommandButton",yo="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",vo=".rte-content, .editora-content",ri="Rich text editor",ue=new Set;let Y=null,Eo=!1,he=null,pe=null;function wo(a){if(!(a instanceof HTMLElement))return!1;const t=a;return typeof t.execCommand=="function"&&(t.tagName.toLowerCase()==="editora-editor"||t.classList.contains("editora-editor")||t.hasAttribute("data-editora-editor"))}function ai(a){return a?a.nodeType===Node.ELEMENT_NODE?a:a.parentElement:null}function Lt(a){if(!a)return null;if(wo(a))return a;const t=a.matches(yo)?a:a.closest(yo);return!t||!wo(t)?null:t}function si(){var n;if(typeof window=="undefined")return null;const a=window[ni];if(a instanceof HTMLElement){const i=Lt(a);if(i)return i;const s=a.matches(vo)?a:a.querySelector(vo);if(s){const c=Lt(s);if(c)return c}}const t=window[ii];if(t instanceof HTMLElement){const i=Lt(t);if(i)return i}const e=document.activeElement;if(e){const i=Lt(e);if(i)return i}const o=(n=window.getSelection)==null?void 0:n.call(window);if(o&&o.rangeCount>0){const i=Lt(ai(o.getRangeAt(0).startContainer));if(i)return i}if(Y&&Y.isConnected)return Y;for(const i of ue)if(i.isConnected)return i;return null}function li(){if(typeof window=="undefined"||Eo)return;he=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,pe=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const a=(t,...e)=>{const o=si();return o?o.execCommand(t,...e):he?he(t,...e):pe?pe(t,...e):!1};window.executeEditorCommand=a,window.execEditorCommand=a,Eo=!0}function ci(){const a="editora-webcomponent-styles";if(!document.getElementById(a)){const t=document.createElement("style");t.id=a,t.textContent=oi,document.head.appendChild(t)}}function di(){if(!Ht){const a=X.__globalPluginLoader;a?Ht=a:Ht=new fo}return Ht}class X extends HTMLElement{constructor(){if(super(),this.pluginLoader=di(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new Pe,this.lastAutosavedContent="",this.preservedContent=null,this.loadedPlugins=[],this.lastBeforeInputType=null,ci(),!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","aria-label","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(X.__globalPluginLoader){this.pluginLoader=X.__globalPluginLoader;return}return new Promise(t=>{const e=()=>{X.__globalPluginLoader?(this.pluginLoader=X.__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 n;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),ue.add(this),Y||(Y=this),li(),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(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(s){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,s)}}),!this.hasAttribute("data-initial-content")&&!this.contentElement){const i=this.innerHTML.trim();i&&this.setAttribute("data-initial-content",i)}const e=this.preservedContent;this.preservedContent=null;const o=this.sanitizeLoadedContent((n=e!=null?e:this.restoreAutosavedContent())!=null?n:this.getAttribute("data-initial-content")||"");this.engine=new Rt({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),n=this.getAccessibilityConfig().checker===!0;if(e){if(typeof this.config.plugins=="string"){const i=this.config.plugins.split(/\s+/).filter(Boolean);n&&!i.includes("a11yChecker")&&i.push("a11yChecker");for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));c&&t.push(c)}}else if(Array.isArray(this.config.plugins)){for(const i of this.config.plugins)if(typeof i=="string"){const s=await this.pluginLoader.load(i,this.getPluginLoadConfig(i));s&&t.push(s)}else t.push(i);if(n&&!t.some(i=>(i==null?void 0:i.name)==="a11yChecker")){const i=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));i&&t.push(i)}}}else{const i=this.pluginLoader.getRegisteredPluginNames();for(const s of i){const c=await this.pluginLoader.load(s,this.getPluginLoadConfig(s));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(){var e;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 o=(e=this.getAttribute("aria-label"))==null?void 0:e.trim(),n=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";this.contentElement.setAttribute("aria-label",o||n||ri)}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 i;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const o={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},n=this.loadedPlugins.find(s=>s.commands&&s.commands[t]);if(n&&n.commands){const s=n.commands[t];if(typeof s=="function")try{return t==="toggleFullscreen"?s(this,o):s(...e,o),!0}catch(c){return console.error(`[RichTextEditor] Error executing native command ${t}:`,c),!1}}return((i=this.engine)==null?void 0:i.execCommand(t,...e))||!1}getPluginLoadConfig(t){const e=this.config.pluginConfig;if(e&&typeof e=="object"){const i=e[t];if(i&&typeof i=="object")return i}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"]},n=[t,t.toLowerCase(),...o[t]||[]];for(const i of n){const s=this.config[i];if(s&&typeof s=="object"&&!Array.isArray(s))return s}}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 ce(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 n=Number((o=(e=t.intervalMs)!=null?e:t.interval)!=null?o:3e4);return{enabled:!!t.enabled,intervalMs:Number.isFinite(n)&&n>0?n: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(ut(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 n=document.createElement("div");n.innerHTML=t;const i=document.createDocumentFragment();for(;n.firstChild;)i.appendChild(n.firstChild);o.insertNode(i),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"]'),n=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 Pt({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},t,this.pluginLoader),this.toolbar.setCommandHandler((i,s)=>{var c;if(this.contentElement){this.contentElement.focus();const u=window.getSelection();if(!u||u.rangeCount===0||!this.contentElement.contains(u.anchorNode)){const f=document.createRange(),b=this.contentElement.lastChild||this.contentElement;b.nodeType===Node.TEXT_NODE?f.setStart(b,((c=b.textContent)==null?void 0:c.length)||0):b.nodeType===Node.ELEMENT_NODE?(f.selectNodeContents(b),f.collapse(!1)):f.setStart(this.contentElement,0),f.collapse(!0),u==null||u.removeAllRanges(),u==null||u.addRange(f)}}return this.executeCommand(i,s)}),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(i){console.warn("defaultParagraphSeparator not supported:",i)}if(e){const i=document.createElement("div");i.innerHTML=e.trim(),!Array.from(i.childNodes).some(c=>{if(c.nodeType===Node.ELEMENT_NODE){const u=c.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(u)}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 He({enabled:!0}),this.floatingToolbar.create(this)),n?this.appendChild(n):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new Ue({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var i;return(i=this.contentElement)==null?void 0:i.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 v;if(!this.contentElement)return;let n=this.contentElement.innerHTML;const i=(v=o==null?void 0:o.detail)==null?void 0:v.allowedTags,s=this.getPerformanceConfig(),c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),f=this.lastBeforeInputType;if(this.lastBeforeInputType=null,u.sanitizeOnInput!==!1&&c.sanitize!==!1&&!f){const x=ce(n,c,u,i);if(x!==n){const k=window.getSelection(),Z=k&&k.rangeCount>0?k.getRangeAt(0):null;if(this.contentElement.innerHTML=x,Z&&k)try{k.removeAllRanges(),k.addRange(Z)}catch(R){}n=x}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const T=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:de(n)},bubbles:!0}))};s.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(T,s.debounceInputMs):T(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",o=>{const n=this.config.contextMenu;(n===!1||typeof n=="object"&&n!==null&&n.enabled===!1)&&o.preventDefault()}),this.contentElement.addEventListener("paste",o=>{var b,T;if(o.__editoraSmartPasteHandled===!0||o.defaultPrevented)return;o.preventDefault();const n=this.config.paste||{};let i=((b=o.clipboardData)==null?void 0:b.getData("text/html"))||"";const s=((T=o.clipboardData)==null?void 0:T.getData("text/plain"))||"",c=this.getContentSanitizeConfig(),u=this.getSecurityConfig(),f=!!i&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(i);if((n.clean||!n.keepFormatting)&&s){document.execCommand("insertText",!1,s);return}if(n.convertWord===!1&&f&&s){document.execCommand("insertText",!1,s);return}if(i){u.sanitizeOnPaste!==!1&&c.sanitize!==!1&&(i=mo(i,c,u)),this.insertHTMLAtSelection(i);return}s&&document.execCommand("insertText",!1,s)}),this.contentElement.addEventListener("focus",()=>{Y=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:ut(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,(i,s)=>{this.executeCommand(i,s)})});const e=()=>{const o=this.getSelectionRangeInEditor(),n=document.activeElement,i=!!n&&!!this.contentElement&&(n===this.contentElement||this.contentElement.contains(n));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!i||!o&&!i||(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(i=>i.width>0||i.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 n=this.getSelectionRangeInEditor();if(!n){this.floatingToolbar.hide();return}if(n.collapsed){this.floatingToolbar.hide();return}const i=window.getSelection();if(!i){this.floatingToolbar.hide();return}const s=this.getSelectionAnchorRect(i,n);if(!s){this.floatingToolbar.hide();return}this.floatingToolbar.show(s.left,s.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:n,chars:i}=We(o),s=$e(this.contentElement);let c,u;const f=this.getSelectionRangeInEditor();f&&(c=Be(this.contentElement,f),f.collapsed||(u=qe(f,c),c=void 0)),this.statusBar.update({wordCount:n,charCount:i,lineCount:s,cursorPosition:c,selectionInfo:u})}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"aria-label":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 Ft.resolve({jsConfig:this.jsConfig,attributes:t})}getAPI(){return{getContent:()=>ut(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,n;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&(this.preservedContent=ut(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(),(n=this.statusBar)==null||n.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,ue.delete(this),Y===this&&(Y=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){return ut(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()}}function ui(a){return new bo(a)}function hi(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",X)}return g.CharacterDialog=pn,g.ColorPicker=ln,g.CommandRegistry=Fe,g.ConfigResolver=Ft,g.Dialog=et,g.DocumentModel=kt,g.Dropdown=sn,g.Editor=on,g.EditorEngine=Rt,g.EditorState=lt,g.EmojiDialog=mn,g.FloatingToolbar=He,g.ImageDialog=un,g.KeyboardShortcutManager=Pe,g.LinkDialog=cn,g.MathDialog=hn,g.MediaPlugin=an,g.PluginLoader=fo,g.PluginManager=xt,g.PluginRuntime=Re,g.ReactAdapter=go,g.RichTextEditorElement=X,g.Schema=Oe,g.SpellcheckPlugin=rn,g.StatusBar=Ue,g.TableDialog=dn,g.ToolbarRenderer=Pt,g.VanillaAdapter=bo,g.calculateTextStats=We,g.countLines=$e,g.createEditor=ui,g.createPluginManager=en,g.createPluginRuntime=nn,g.createReactAdapter=ei,g.getCleanEditorHTML=ut,g.getCursorPosition=Be,g.getSelectionInfo=qe,g.getTextOffset=je,g.initWebComponent=hi,g.sanitizeHTML=po,g.sanitizeInputHTML=ce,g.sanitizePastedHTML=mo,g.stripEditorUiArtifacts=de,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}),g})({});
|
|
526
526
|
//# sourceMappingURL=editora.min.js.map
|