@oix1987/yjd 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -22
- package/dist/rich-editor.esm.js +2 -0
- package/dist/rich-editor.esm.js.map +1 -0
- package/dist/rich-editor.min.js +2 -0
- package/dist/rich-editor.min.js.map +1 -0
- package/package.json +12 -7
- package/index.js +0 -221
- package/lib/core/editor.js +0 -1175
- package/lib/core/format.js +0 -542
- package/lib/core/module.js +0 -81
- package/lib/core/registry.js +0 -152
- package/lib/formats/background.js +0 -212
- package/lib/formats/bold.js +0 -67
- package/lib/formats/capitalization.js +0 -563
- package/lib/formats/color.js +0 -165
- package/lib/formats/emoji.js +0 -282
- package/lib/formats/font-family.js +0 -547
- package/lib/formats/heading.js +0 -502
- package/lib/formats/image.js +0 -344
- package/lib/formats/import.js +0 -385
- package/lib/formats/indent.js +0 -297
- package/lib/formats/italic.js +0 -27
- package/lib/formats/line-height.js +0 -558
- package/lib/formats/link.js +0 -251
- package/lib/formats/list.js +0 -635
- package/lib/formats/strike.js +0 -31
- package/lib/formats/subscript.js +0 -36
- package/lib/formats/superscript.js +0 -35
- package/lib/formats/table.js +0 -288
- package/lib/formats/tag.js +0 -304
- package/lib/formats/text-align.js +0 -421
- package/lib/formats/text-size.js +0 -497
- package/lib/formats/underline.js +0 -30
- package/lib/formats/video.js +0 -372
- package/lib/modules/block-toolbar.js +0 -628
- package/lib/modules/code-view.js +0 -434
- package/lib/modules/history.js +0 -410
- package/lib/modules/resize-handles.js +0 -677
- package/lib/modules/table-toolbar.js +0 -618
- package/lib/modules/toolbar.js +0 -424
- package/lib/styles-loader.js +0 -144
- package/lib/styles.css +0 -2123
- package/lib/ui/color-picker.js +0 -296
- package/lib/ui/customselect.js +0 -319
- package/lib/ui/emoji-picker.js +0 -196
- package/lib/ui/icons.js +0 -413
- package/lib/ui/image-popup.js +0 -444
- package/lib/ui/import-popup.js +0 -288
- package/lib/ui/link-popup.js +0 -191
- package/lib/ui/list-picker.js +0 -307
- package/lib/ui/select-button.js +0 -61
- package/lib/ui/table-popup.js +0 -171
- package/lib/ui/tag-popup.js +0 -249
- package/lib/ui/text-align-picker.js +0 -281
- package/lib/ui/video-popup.js +0 -422
- package/lib/utils/history-helper.js +0 -50
- package/lib/utils/popup-helper.js +0 -219
- package/lib/utils/popup-positioning.js +0 -231
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RichEditor={})}(this,function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;const n=new class{constructor(){this.modules=new Map,this.formats=new Map,this.themes=new Map,this.ui=new Map}register(t,e,n=!1){if("object"==typeof t)return void Object.entries(t).forEach(([t,e])=>{this.register(t,e,n)});const[i,s]=t.split("/");switch(!n&&this.get(t),i){case"modules":this.modules.set(s,e);break;case"formats":this.formats.set(s,e);break;case"themes":this.themes.set(s,e);break;case"ui":this.ui.set(s,e)}}get(t){const[e,n]=t.split("/");switch(e){case"modules":return this.modules.get(n);case"formats":return this.formats.get(n);case"themes":return this.themes.get(n);case"ui":return this.ui.get(n);default:return null}}has(t){return null!==this.get(t)&&void 0!==this.get(t)}getAll(t){switch(t){case"modules":return new Map(this.modules);case"formats":return new Map(this.formats);case"themes":return new Map(this.themes);case"ui":return new Map(this.ui);default:return new Map}}unregister(t){const[e,n]=t.split("/");switch(e){case"modules":this.modules.delete(n);break;case"formats":this.formats.delete(n);break;case"themes":this.themes.delete(n);break;case"ui":this.ui.delete(n)}}clear(){this.modules.clear(),this.formats.clear(),this.themes.clear(),this.ui.clear()}getAllItems(){const t={};return t.modules=Array.from(this.modules.keys()),t.formats=Array.from(this.formats.keys()),t.themes=Array.from(this.themes.keys()),t.ui=Array.from(this.ui.keys()),t}};class i{static DEFAULTS={};constructor(t,e={}){this.editor=t,this.options={...this.constructor.DEFAULTS,...e},this.events=new Map}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){if(this.events.has(t)){const n=this.events.get(t),i=n.indexOf(e);i>-1&&n.splice(i,1)}}emit(t,e){this.events.has(t)&&this.events.get(t).forEach(t=>{try{t(e)}catch(t){}})}destroy(){this.events.clear()}onContentChange(){}onSelectionChange(t){}}class s{static DEFAULTS={placeholder:"Start typing...",theme:"light",height:400,width:800,maxWidth:1200,maxHeight:800,content:null,features:{emoji:!0,image:!0,table:!0,wordCount:!0,breadcrumb:!0}};static currentInstance=null;static instances=new Map;constructor(t,e={}){this.options={...s.DEFAULTS,...e},this.root="string"==typeof t?document.querySelector(t):t,this.modules=new Map,this.formats=new Map,this.registry=n,this.events=new Map,this.toolbarBtns={},this.statusbarEls={},this.dropdownMenus={},this.popupInstances=new Map,s.currentInstance=this;const i=this.generateInstanceId();this.instanceId=i,s.instances.set(i,this),this.init()}generateInstanceId(){return"editor_"+Date.now()+"_"+Math.random().toString(36).substr(2,9)}init(){this.createStructure(),this.loadModules(),this.loadFormats(),this.setupEventListeners(),this.updateStatusbar()}createStructure(){this.wrapper=document.createElement("div"),this.wrapper.className="yjd-rich-editor",this.wrapper.style.width=this.options.width+"px",this.wrapper.style.maxWidth=this.options.maxWidth+"px",this.wrapper.style.minHeight=this.options.height+"px",this.wrapper.style.maxHeight=this.options.maxHeight+"px",this.wrapper.style.position="relative",this.editor=document.createElement("div"),this.editor.className="rich-editor-area",this.editor.contentEditable=!0,this.editor.setAttribute("data-placeholder",this.options.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(t){}this.editor.innerHTML=this.getDefaultContent(),this.wrapper.appendChild(this.editor),this.popupContainer=document.createElement("div"),this.popupContainer.className="rich-editor-popup-container",this.popupContainer.style.position="absolute",this.popupContainer.style.top="0",this.popupContainer.style.left="0",this.popupContainer.style.width="100%",this.popupContainer.style.height="100%",this.popupContainer.style.pointerEvents="none",this.popupContainer.style.zIndex="1000",this.wrapper.appendChild(this.popupContainer),(this.options.features.wordCount||this.options.features.breadcrumb)&&this.createStatusbar(),this.root.appendChild(this.wrapper),this.updatePlaceholderVisibility()}isHtmlContent(t){if(!t||"string"!=typeof t)return!1;const e=t.trim();return[/<[^>]+>/,/&[a-zA-Z]+;/,/&#\d+;/].some(t=>t.test(e))}wrapTextInParagraph(t){if(!t||"string"!=typeof t)return"<p><br></p>";const e=t.trim();return this.isHtmlContent(e)?e:""===e?"<p><br></p>":`<p>${e}</p>`}getDefaultContent(){return this.options.content?this.wrapTextInParagraph(this.options.content):""}createStatusbar(){this.statusbar=document.createElement("div"),this.statusbar.className="rich-editor-statusbar",this.statusbarEls.breadcrumb=document.createElement("span"),this.statusbarEls.breadcrumb.className="rich-editor-breadcrumb",this.statusbarEls.wordcount=document.createElement("span"),this.statusbarEls.wordcount.className="wordcount",this.statusbar.appendChild(this.statusbarEls.breadcrumb),this.statusbar.appendChild(this.statusbarEls.wordcount),this.wrapper.appendChild(this.statusbar)}loadModules(){let t;t=this.options.toolbar||this.options.toolbar1||this.options.toolbar2?this.options.modules||["toolbar","history"]:this.options.modules||["toolbar","history","block-toolbar","table-toolbar","code-view","theme-switcher","resize-handles"],t.forEach(t=>{const e=this.registry.get(`modules/${t}`);if(e){const n=new e(this,"toolbar"===t?this.options:this.options[t]||this.options);if(this.modules.set(t,n),"toolbar"===t&&n.getContainer){const t=n.getContainer();this.wrapper.insertBefore(t,this.editor),n.on("toolbar-click",t=>{this.handleToolbarClick(t)})}}})}loadFormats(){let t;t=this.options.toolbar||this.options.toolbar1||this.options.toolbar2?this.options.formats||["bold","italic","underline","strike"]:this.options.formats||["bold","italic","underline","strike","subscript","superscript","color","background","text-align","text-size","link","code","h1","h2","h3","h4","h5","h6","paragraph","pre"],t.forEach(t=>{const e=this.registry.get(`formats/${t}`);e&&this.formats.set(t,e)})}setupEventListeners(){this.editor.addEventListener("input",()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility(),this.updateStatusbar(),this.onContentChange()}),document.addEventListener("selectionchange",()=>{(document.activeElement===this.editor||this.editor.contains(document.activeElement))&&this.onSelectionChange()}),this.editor.addEventListener("mouseup",()=>{setTimeout(()=>{this.onSelectionChange()},10)}),this.editor.addEventListener("click",t=>{setTimeout(()=>{this.ensureEditorHasContent()},0)}),this.editor.addEventListener("contextmenu",t=>{}),this.editor.addEventListener("keydown",t=>{"Delete"!==t.key&&"Backspace"!==t.key||setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("paste",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("drop",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("cut",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility(),this.focus()},100),this.editor.addEventListener("focus",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)})}onContentChange(){this.ensureEditorHasContent(),this.modules.forEach(t=>{"function"==typeof t.onContentChange&&t.onContentChange()});const t=this.getContent();this.options.onChange&&"function"==typeof this.options.onChange&&this.options.onChange(t),this.emit("text-change",t)}ensureEditorHasContent(){if(this.isEditorEmpty()){const t=document.createElement("p");t.innerHTML="<br>",this.editor.innerHTML="",this.editor.appendChild(t),this.setCursorToElement(t),this.editor.focus()}}ensureParagraphForEditing(){const t=this.editor.children;if(0===t.length){const t=document.createElement("p");return t.innerHTML="<br>",this.editor.appendChild(t),void this.setCursorToElement(t)}const e=t[t.length-1];if(!["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","ARTICLE","SECTION","MAIN","ASIDE"].includes(e.tagName)){const t=document.createElement("p");t.innerHTML="<br>",this.editor.appendChild(t)}}isEditorEmpty(){const t=this.editor.innerHTML.trim();if(""===t)return!0;if(["<br>","<div><br></div>","<p><br></p>","<p></p>","<div></div>","<p> </p>","<div> </div>"].includes(t))return!0;const e=this.editor.children;if(0===e.length)return!0;for(let t=0;t<e.length;t++){const n=e[t].innerHTML.trim();if(""!==n&&"<br>"!==n&&" "!==n&&"<br> "!==n&&" <br>"!==n)return!1}return!0}setCursorToElement(t){const e=document.createRange(),n=window.getSelection();t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE?e.setStart(t.firstChild,0):e.setStart(t,0),e.collapse(!0),n.removeAllRanges(),n.addRange(e)}onSelectionChange(){const t=window.getSelection(),e=t.rangeCount>0?t.getRangeAt(0):null,n=this.isSelectionInEditableArea(t);this.modules.forEach(t=>{"function"==typeof t.onSelectionChange&&t.onSelectionChange(e,n)}),this.updateToolbarButtonStates(),this.updateToolbarAccessibility(n),this.updateStatusbar()}isSelectionInEditableArea(t){if(!t||0===t.rangeCount)return!1;const e=t.getRangeAt(0),n=e.startContainer,i=e.endContainer,s=this.isNodeInEditableArea(n),o=this.isNodeInEditableArea(i);return s&&o}isNodeInEditableArea(t){if(!t)return!1;let e=t.nodeType===Node.TEXT_NODE?t.parentNode:t;for(;e&&e!==document.body;){if(e===this.editor||e.classList&&e.classList.contains("rich-editor-area"))return!0;e=e.parentNode}return!1}updateToolbarAccessibility(t){const e=this.getModule("toolbar");if(!e)return;["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size"].forEach(n=>{e.setButtonDisabled(n,!t)});["more","undo","redo","code-view","theme"].forEach(t=>{e.setButtonDisabled(t,!1)})}updateStatusbar(){if(!this.statusbar)return;const t=window.getSelection();if(t){if(this.statusbarEls.breadcrumb&&this.options.features.breadcrumb){const e=t.anchorNode,n=[];let i=3===e?.nodeType?e.parentElement:e;for(;i&&i!==this.editor&&i!==document.body;){if(i.tagName){let t=i.tagName.toLowerCase();if(i.className&&"string"==typeof i.className){const e=i.className.trim();e&&(t+="."+e.split(" ").join("."))}i.id&&(t+="#"+i.id),n.unshift(t)}i=i.parentElement}this.statusbarEls.breadcrumb.textContent=n.length>0?n.join(" > "):"editor"}if(this.statusbarEls.wordcount&&this.options.features.wordCount){const t=this.editor.textContent||"",e=t.trim()?t.trim().split(/\s+/).length:0,n=t.length,i=t.replace(/\s/g,"").length;this.statusbarEls.wordcount.textContent=`${e} words, ${n} chars (${i} no spaces)`}}}focus(){this.editor&&this.editor.focus()}getContent(){return this.editor.innerHTML}setContent(t){const e=this.wrapTextInParagraph(t);this.editor.innerHTML=e,this.onContentChange()}getModule(t){return this.modules.get(t)}getFormat(t){return this.formats.get(t)}register(t,e,n=!1){this.registry.register(t,e,n)}handleToolbarClick(t){const{command:e,button:n,value:i}=t;s.currentInstance,s.currentInstance=this,this.emit("toolbar-click",t);if(["more","undo","redo","code-view","theme"].includes(e))switch(e){case"more":case"code-view":return;case"undo":return void this.undo();case"redo":return void this.redo()}const o=window.getSelection();if(this.isSelectionInEditableArea(o))switch(e){case"bold":case"italic":case"underline":case"strike":case"subscript":case"superscript":case"color":case"background":case"link":case"table":case"heading":case"font-family":case"line-height":case"capitalization":case"text-align":case"text-size":case"list":case"indent-increase":case"indent-decrease":case"emoji":case"image":case"video":case"tag":case"import":this.toggleFormat(e)}}toggleFormat(t){const e=this.getModule("history");e&&"function"==typeof e.saveBeforeFormat&&e.saveBeforeFormat();const n={bold:"bold",italic:"italic",underline:"underline",strike:"strike",subscript:"subscript",superscript:"superscript",color:"color",background:"background",link:"link",table:"table",heading:"heading","font-family":"font-family","line-height":"line-height",capitalization:"capitalization","text-align":"text-align","text-size":"text-size",list:"list","indent-increase":"indent-increase","indent-decrease":"indent-decrease",emoji:"emoji",image:"image",video:"video",tag:"tag",import:"import"}[t];if(!n)return;const i=this.registry.get(`formats/${n}`);if(!i)return;(new i).toggle(),this.updateToolbarButtonStates();["bold","italic","underline","strike","subscript","superscript"].includes(t)&&setTimeout(()=>{this.onContentChange()},0)}updateToolbarButtonStates(){const t=this.getModule("toolbar");if(!t)return;const e=window.getSelection();if(!e||!e.rangeCount)return;const n=this.isSelectionInEditableArea(e);if(["heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","bold","italic","underline","strike","subscript","superscript","color","background","link","table","text-size"].forEach(e=>{if(n){const n=this.registry.get(`formats/${e}`);if(n){let i;if(n.createForEditor)i=n.createForEditor(this.instanceId);else{const t=s.currentInstance;s.currentInstance=this,i=new n,s.currentInstance=t}if(i){const n=i.isActive();t.setButtonActive(e,n),"line-height"===e&&"function"==typeof i.updateButtonText&&i.updateButtonText()}}}else t.setButtonActive(e,!1)}),n){const t=this.registry.get("formats/text-size");t&&"function"==typeof t.updateButtonTextStatic&&t.updateButtonTextStatic(this.instanceId)}}undo(){const t=this.getModule("history");t&&"function"==typeof t.undo?t.undo():document.execCommand("undo")}redo(){const t=this.getModule("history");t&&"function"==typeof t.redo?t.redo():document.execCommand("redo")}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){if(this.events.has(t)){const n=this.events.get(t),i=n.indexOf(e);i>-1&&n.splice(i,1)}}emit(t,e){this.events.has(t)&&this.events.get(t).forEach(t=>{try{t(e)}catch(t){}})}preventFocusLoss(t,e="button, input, select, textarea, [contenteditable]"){t&&t.addEventListener("mousedown",t=>{t.target.closest(e)||(t.preventDefault(),setTimeout(()=>{this.focus()},0))})}static getCurrentInstance(){return s.currentInstance}static maintainFocus(t,e=null){"function"==typeof t&&t();const n=e||s.getCurrentInstance();n&&setTimeout(()=>n.focus(),0)}getPopupContainer(){return this.popupContainer}static getPopupContainer(){const t=s.getCurrentInstance();return t?t.getPopupContainer():null}getPopupInstance(t){return this.popupInstances.get(t)}setPopupInstance(t,e){this.popupInstances.set(t,e)}static getPopupInstanceById(t,e){const n=s.instances.get(t);return n?n.getPopupInstance(e):null}static getInstanceById(t){return s.instances.get(t)}static getAllInstances(){return s.instances}destroyPopupInstances(){this.popupInstances.forEach((t,e)=>{t&&"function"==typeof t.destroy&&t.destroy()}),this.popupInstances.clear()}updatePlaceholderVisibility(){this.editor.textContent.trim().length>0?this.editor.classList.remove("placeholder-visible"):this.editor.classList.add("placeholder-visible")}destroy(){this.modules.forEach(t=>{"function"==typeof t.destroy&&t.destroy()}),this.destroyPopupInstances(),this.wrapper&&this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper),this.modules.clear(),this.formats.clear(),this.events.clear(),s.instances.delete(this.instanceId),s.currentInstance===this&&(s.currentInstance=null)}}class o{static formatName="";static tagName="";static className="";constructor(t){this.domNode=t}static create(t){const e=document.createElement(this.tagName);return this.className&&(e.className=this.className),e}getOffsetWithin(t,e){let n=0;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let s;for(;s=i.nextNode();){if(s===e.startContainer)return n+e.startOffset;n+=s.textContent.length}return n}}class r extends o{static create(t){return super.create(t)}apply(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0);if(n.collapsed){const i=this.constructor.create(t);i.appendChild(document.createTextNode("")),n.insertNode(i);const s=document.createRange();s.setStart(i.firstChild,1),s.collapse(!0),e.removeAllRanges(),e.addRange(s)}else{const i=n.extractContents(),s=this.constructor.create(t);s.appendChild(i),n.insertNode(s);const o=document.createRange();o.selectNodeContents(s),e.removeAllRanges(),e.addRange(o)}}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.collapsed?this.removeAtCursor(e,t):this.removeFromSelection(e,t)}removeAtCursor(t,e){const n=t.startContainer,i=this.findFormatNode(n);if(!i||!i.parentNode)return;const s=i.textContent,o=this.getOffsetWithin(i,t),r=s.slice(0,o),l=s.slice(o),a=document.createDocumentFragment();if(r){const t=i.cloneNode(!1);t.textContent=r,a.appendChild(t)}const c=document.createTextNode("");if(a.appendChild(c),l){const t=i.cloneNode(!1);t.textContent=l,a.appendChild(t)}i.replaceWith(a);const d=document.createRange();d.setStartAfter(c),d.collapse(!0),e.removeAllRanges(),e.addRange(d)}removeFromSelection(t,e){const n=this.constructor.formatName;document.execCommand(n),"strike"===n&&document.execCommand("strikeThrough")}findFormatNode(t){for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE&&t.tagName===this.constructor.tagName)return t;t=t.parentNode}return null}findFormatNodesInRange(t){const e=[],n=document.createTreeWalker(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tagName===this.constructor.tagName&&t.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let i;for(;i=n.nextNode();)e.push(i);return e}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;const n=this.constructor.tagName,i=this.constructor.alternativeTagNames||[],s=this.constructor.formatName;if(["bold","italic","underline"].includes(s?.toLowerCase()))try{return document.queryCommandState(s)}catch(t){}for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&(e.tagName===n||i.includes(e.tagName)))return!0;e=e.parentNode}return!1}}class l extends o{static create(t){return super.create(t)}apply(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0),i=this.getBlockElements(n);0===i.length?this.createBlockAtCursor(n,t):i.forEach(e=>{this.convertBlock(e,t)})}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);this.getBlockElements(e).forEach(t=>{this.removeBlockFormat(t)})}createBlockAtCursor(t,e){const n=this.constructor.create(e),i=this.getBlockElement(t.startContainer);if(i&&i.style&&i.style.cssText&&(n.style.cssText=i.style.cssText),t.collapsed){n.appendChild(document.createTextNode("")),t.insertNode(n);const e=document.createRange();e.setStart(n,0),e.collapse(!0);const i=window.getSelection();i.removeAllRanges(),i.addRange(e)}else{const e=t.extractContents();n.appendChild(e),t.insertNode(n);const i=document.createRange();i.selectNodeContents(n);const s=window.getSelection();s.removeAllRanges(),s.addRange(i)}}convertBlock(t,e){const n=this.constructor.create(e);for(;t.firstChild;)n.appendChild(t.firstChild);t.className&&this.shouldPreserveClass(t.className)&&(n.className=t.className),t.style&&t.style.cssText&&(n.style.cssText=t.style.cssText),t.parentNode.replaceChild(n,t)}removeBlockFormat(t){const e=document.createElement("P");for(;t.firstChild;)e.appendChild(t.firstChild);t.style&&t.style.cssText&&(e.style.cssText=t.style.cssText),t.parentNode.replaceChild(e,t)}getBlockElements(t){const e=[];let n=this.getBlockElement(t.startContainer),i=this.getBlockElement(t.endContainer);if(n&&i&&n.nextElementSibling===i){t.endContainer===i&&0===t.endOffset&&(i=n)}if(n===i)n&&e.push(n);else{let t=n;for(;t&&t!==i;)this.isBlockElement(t)&&e.push(t),t=this.getNextBlockElement(t);i&&this.isBlockElement(i)&&e.push(i)}return e.filter((t,e,n)=>n.indexOf(t)===e)}getBlockElement(t){for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;for(;t&&t!==document.body;){if(this.isBlockElement(t))return t;t=t.parentNode}return null}isBlockElement(t){if(!t||t.nodeType!==Node.ELEMENT_NODE)return!1;return["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI","SECTION","ARTICLE"].includes(t.tagName.toUpperCase())}getNextBlockElement(t){let e=t.nextElementSibling;for(;e;){if(this.isBlockElement(e))return e;e=e.nextElementSibling}return null}isActive(t=null){const e=window.getSelection();if(!e||!e.rangeCount)return!1;const n=e.getRangeAt(0),i=this.getBlockElement(n.startContainer);return!!i&&(i.tagName===this.constructor.tagName&&(!t||this.hasValue(i,t)))}hasValue(t,e){return!0}shouldPreserveClass(t){return!1}}function a(){const t=s.getCurrentInstance();if(t){const e=t.getModule("history");e&&"function"==typeof e.saveBeforeFormat&&e.saveBeforeFormat()}}class c extends r{static formatName="bold";static tagName="B";static alternativeTagNames=["STRONG"];apply(){a();try{document.execCommand("bold",!1,null)}catch(t){}}remove(){try{document.execCommand("bold",!1,null)}catch(t){}}toggle(){a();try{document.execCommand("bold",!1,null)}catch(t){}}isActive(){try{return document.queryCommandState("bold")}catch(t){return!1}}}class d extends r{static formatName="italic";static tagName="I";static alternativeTagNames=["EM"];toggle(){a(),this.isActive()?this.remove():this.apply()}}class h extends r{static formatName="underline";static tagName="U";static alternativeTagNames=["SPAN"];toggle(){a(),this.isActive()?this.remove():this.apply()}}class u extends r{static formatName="strike";static tagName="S";static alternativeTagNames=["STRIKE","DEL"];toggle(){a(),this.isActive()?this.remove():this.apply()}}class p extends r{static formatName="superscript";static tagName="SUP";removeSubscriptBeforeApply(){const t=new m;t.isActive()&&t.remove()}toggle(){a(),this.isActive()?this.remove():(this.removeSubscriptBeforeApply(),this.apply())}}class m extends r{static formatName="subscript";static tagName="SUB";removeSuperscriptBeforeApply(){const t=new p;t.isActive()&&t.remove()}toggle(){a(),this.isActive()?this.remove():(this.removeSuperscriptBeforeApply(),this.apply())}}const g={bold:'<svg xmlns="http://www.w3.org/2000/svg" width="11" height="14" viewBox="0 0 11 14" fill="none">\n<path d="M0 1.72875C0 1.24281 0.407135 0.85022 0.911072 0.85022H2.27768H2.73322H6.3775C8.3904 0.85022 10.0218 2.42334 10.0218 4.36435C10.0218 5.22367 9.70007 6.01435 9.16766 6.62383C10.2239 7.23881 10.9329 8.35619 10.9329 9.63556C10.9329 11.5766 9.30147 13.1497 7.28857 13.1497H2.73322H2.27768H0.911072C0.407135 13.1497 0 12.7571 0 12.2712C0 11.7852 0.407135 11.3926 0.911072 11.3926H1.36661V6.99995V2.60729H0.911072C0.407135 2.60729 0 2.21469 0 1.72875ZM6.3775 6.12142C7.38253 6.12142 8.19965 5.33349 8.19965 4.36435C8.19965 3.39522 7.38253 2.60729 6.3775 2.60729H3.18875V6.12142H6.3775ZM3.18875 7.87849V11.3926H7.28857C8.2936 11.3926 9.11072 10.6047 9.11072 9.63556C9.11072 8.66642 8.2936 7.87849 7.28857 7.87849H6.3775H3.18875Z" fill="#454545"/>\n</svg>',italic:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">\n <path d="M4.31684 1.02168C4.31684 0.562739 4.6949 0.191956 5.16284 0.191956H10.2388C10.7067 0.191956 11.0848 0.562739 11.0848 1.02168C11.0848 1.48062 10.7067 1.85141 10.2388 1.85141H8.68694L5.16284 10.1487H6.85483C7.32277 10.1487 7.70082 10.5195 7.70082 10.9784C7.70082 11.4373 7.32277 11.8081 6.85483 11.8081H1.77886C1.31092 11.8081 0.932861 11.4373 0.932861 10.9784C0.932861 10.5195 1.31092 10.1487 1.77886 10.1487H3.33073L6.85483 1.85141H5.16284C4.6949 1.85141 4.31684 1.48062 4.31684 1.02168Z" fill="#454545"/>\n</svg>',underline:'\x3c!-- Underline icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">\n <path d="M0.475176 1.02168C0.475176 0.562739 0.824149 0.191956 1.25609 0.191956H3.59885C4.0308 0.191956 4.37977 0.562739 4.37977 1.02168C4.37977 1.48062 4.0308 1.85141 3.59885 1.85141H3.20839V5.17031C3.20839 6.54455 4.25775 7.65949 5.55115 7.65949C6.84454 7.65949 7.8939 6.54455 7.8939 5.17031V1.85141H7.50344C7.0715 1.85141 6.72253 1.48062 6.72253 1.02168C6.72253 0.562739 7.0715 0.191956 7.50344 0.191956H9.8462C10.2781 0.191956 10.6271 0.562739 10.6271 1.02168C10.6271 1.48062 10.2781 1.85141 9.8462 1.85141H9.45574V5.17031C9.45574 7.46243 7.70844 9.31894 5.55115 9.31894C3.39386 9.31894 1.64655 7.46243 1.64655 5.17031V1.85141H1.25609C0.824149 1.85141 0.475176 1.48062 0.475176 1.02168ZM0.0847168 10.9784C0.0847168 10.5195 0.43369 10.1487 0.865636 10.1487H10.2367C10.6686 10.1487 11.0176 10.5195 11.0176 10.9784C11.0176 11.4373 10.6686 11.8081 10.2367 11.8081H0.865636C0.43369 11.8081 0.0847168 11.4373 0.0847168 10.9784Z" fill="#454545"/>\n</svg>',strike:'\x3c!-- Strike icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">\n <g clip-path="url(#clip0_3_45)">\n <path d="M5.28358 4.92512C5.37144 4.4529 5.66794 4.09874 6.20879 3.86538C6.78807 3.6183 7.63091 3.5277 8.64123 3.68693C8.96793 3.73909 9.98099 3.93676 10.2912 4.01638C10.7607 4.13993 11.2411 3.86264 11.3674 3.39317C11.4937 2.92371 11.2137 2.44326 10.7442 2.31697C10.3516 2.21264 9.27267 2.00399 8.91577 1.94908C7.68857 1.7569 6.49157 1.83378 5.51969 2.24833C4.51761 2.67662 3.75164 3.47828 3.54848 4.64508C3.54573 4.66156 3.54299 4.67528 3.54299 4.69175C3.46612 5.34791 3.55672 5.94367 3.82028 6.46529C3.94382 6.71238 4.10031 6.92927 4.27876 7.12145H1.73376C1.24782 7.12145 0.855225 7.51404 0.855225 7.99998C0.855225 8.48592 1.24782 8.87852 1.73376 8.87852H14.0332C14.5192 8.87852 14.9118 8.48592 14.9118 7.99998C14.9118 7.51404 14.5192 7.12145 14.0332 7.12145H8.2706L8.25962 7.1187L8.22942 7.11047C7.24107 6.81396 6.4394 6.57237 5.89032 6.20173C5.635 6.02877 5.47851 5.85581 5.39065 5.67736C5.30555 5.50989 5.24789 5.27653 5.28633 4.92512H5.28358ZM10.434 10.2293C10.5081 10.4077 10.5548 10.663 10.4861 11.0556C10.4038 11.5388 10.1073 11.9012 9.55545 12.1373C8.97617 12.3844 8.13607 12.475 7.12576 12.3158C6.63158 12.2362 5.77776 11.9451 5.08317 11.709C4.92942 11.6569 4.78117 11.6075 4.64665 11.5608C4.18542 11.407 3.6885 11.6569 3.53475 12.1181C3.38101 12.5793 3.63084 13.0763 4.09207 13.23C4.19091 13.2629 4.30896 13.3041 4.44074 13.3481C5.12435 13.5814 6.18682 13.9438 6.84573 14.0509H6.85122C8.07842 14.2431 9.27542 14.1662 10.2473 13.7516C11.2494 13.3233 12.0153 12.5217 12.2185 11.3549C12.3173 10.7783 12.2926 10.2457 12.1334 9.75979H10.0551C10.2473 9.91354 10.3681 10.0673 10.4367 10.232L10.434 10.2293Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_3_45">\n <rect width="14.0565" height="14.0565" fill="white" transform="translate(0.855225 0.971741)"/>\n </clipPath>\n </defs>\n</svg>',subscript:'\x3c!-- Subscript icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_26_737)">\n <path d="M1.50049 1.75C1.0165 1.75 0.625488 2.14102 0.625488 2.625C0.625488 3.10898 1.0165 3.5 1.50049 3.5H1.91885L4.36885 7L1.91885 10.5H1.50049C1.0165 10.5 0.625488 10.891 0.625488 11.375C0.625488 11.859 1.0165 12.25 1.50049 12.25H2.37549C2.65986 12.25 2.92783 12.1105 3.09189 11.8781L5.43799 8.52578L7.78408 11.8781C7.94814 12.1133 8.21611 12.25 8.50049 12.25H9.37549C9.85947 12.25 10.2505 11.859 10.2505 11.375C10.2505 10.891 9.85947 10.5 9.37549 10.5H8.95713L6.50713 7L8.95713 3.5H9.37549C9.85947 3.5 10.2505 3.10898 10.2505 2.625C10.2505 2.14102 9.85947 1.75 9.37549 1.75H8.50049C8.21611 1.75 7.94814 1.88945 7.78408 2.12187L5.43799 5.47422L3.09189 2.12187C2.92783 1.88945 2.65986 1.75 2.37549 1.75H1.50049ZM13.7505 8.75C13.7505 8.44648 13.5946 8.16484 13.3349 8.00625C13.0751 7.84766 12.7552 7.83125 12.4845 7.96797L11.6095 8.40547C11.1774 8.62148 11.0024 9.14648 11.2185 9.57852C11.3716 9.88477 11.6806 10.0625 12.0005 10.0625V12.25C11.5165 12.25 11.1255 12.641 11.1255 13.125C11.1255 13.609 11.5165 14 12.0005 14H12.8755H13.7505C14.2345 14 14.6255 13.609 14.6255 13.125C14.6255 12.641 14.2345 12.25 13.7505 12.25V8.75Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_737">\n <rect width="14" height="14" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',superscript:'\x3c!-- Superscript icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_26_735)">\n <path d="M13.7505 0.874642C13.7505 0.571127 13.5946 0.289486 13.3349 0.130892C13.0751 -0.0277016 12.7552 -0.0441078 12.4845 0.092611L11.6095 0.530111C11.1774 0.746127 11.0024 1.27113 11.2185 1.70316C11.3716 2.00941 11.6806 2.18714 12.0005 2.18714V4.37464C11.5165 4.37464 11.1255 4.76566 11.1255 5.24964C11.1255 5.73363 11.5165 6.12464 12.0005 6.12464H12.8755H13.7505C14.2345 6.12464 14.6255 5.73363 14.6255 5.24964C14.6255 4.76566 14.2345 4.37464 13.7505 4.37464V0.874642ZM1.50049 1.74964C1.0165 1.74964 0.625488 2.14066 0.625488 2.62464C0.625488 3.10863 1.0165 3.49964 1.50049 3.49964H1.91885L4.36885 6.99964L1.91885 10.4996H1.50049C1.0165 10.4996 0.625488 10.8907 0.625488 11.3746C0.625488 11.8586 1.0165 12.2496 1.50049 12.2496H2.37549C2.65986 12.2496 2.92783 12.1102 3.09189 11.8778L5.43799 8.52542L7.78408 11.8778C7.94814 12.1129 8.21611 12.2496 8.50049 12.2496H9.37549C9.85947 12.2496 10.2505 11.8586 10.2505 11.3746C10.2505 10.8907 9.85947 10.4996 9.37549 10.4996H8.95713L6.50713 6.99964L8.95713 3.49964H9.37549C9.85947 3.49964 10.2505 3.10863 10.2505 2.62464C10.2505 2.14066 9.85947 1.74964 9.37549 1.74964H8.50049C8.21611 1.74964 7.94814 1.8891 7.78408 2.12152L5.43799 5.47386L3.09189 2.12152C2.92783 1.8891 2.65986 1.74964 2.37549 1.74964H1.50049Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_735">\n <rect width="14" height="14" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',"align-left":'<svg xmlns="http://www.w3.org/2000/svg" width="13" height="16" viewBox="0 0 13 16" fill="none">\n <path d="M8.35714 2C8.35714 2.55313 7.94219 3 7.42857 3H0.928571C0.414955 3 0 2.55313 0 2C0 1.44687 0.414955 1 0.928571 1H7.42857C7.94219 1 8.35714 1.44687 8.35714 2ZM8.35714 10C8.35714 10.5531 7.94219 11 7.42857 11H0.928571C0.414955 11 0 10.5531 0 10C0 9.44687 0.414955 9 0.928571 9H7.42857C7.94219 9 8.35714 9.44687 8.35714 10ZM0 6C0 5.44688 0.414955 5 0.928571 5H12.0714C12.585 5 13 5.44688 13 6C13 6.55312 12.585 7 12.0714 7H0.928571C0.414955 7 0 6.55312 0 6ZM13 14C13 14.5531 12.585 15 12.0714 15H0.928571C0.414955 15 0 14.5531 0 14C0 13.4469 0.414955 13 0.928571 13H12.0714C12.585 13 13 13.4469 13 14Z" fill="#454545"/>\n</svg>',"align-center":'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">\n <g clip-path="url(#clip0_12_238)">\n <path d="M11 1.875C11 1.35645 10.5531 0.9375 10 0.9375H4C3.44688 0.9375 3 1.35645 3 1.875C3 2.39355 3.44688 2.8125 4 2.8125H10C10.5531 2.8125 11 2.39355 11 1.875ZM14 5.625C14 5.10645 13.5531 4.6875 13 4.6875H1C0.446875 4.6875 0 5.10645 0 5.625C0 6.14355 0.446875 6.5625 1 6.5625H13C13.5531 6.5625 14 6.14355 14 5.625ZM0 13.125C0 13.6436 0.446875 14.0625 1 14.0625H13C13.5531 14.0625 14 13.6436 14 13.125C14 12.6064 13.5531 12.1875 13 12.1875H1C0.446875 12.1875 0 12.6064 0 13.125ZM11 9.375C11 8.85645 10.5531 8.4375 10 8.4375H4C3.44688 8.4375 3 8.85645 3 9.375C3 9.89355 3.44688 10.3125 4 10.3125H10C10.5531 10.3125 11 9.89355 11 9.375Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_12_238">\n <rect width="14" height="15" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"align-right":'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">\n <g clip-path="url(#clip0_12_244)">\n <path d="M14 1.875C14 2.39355 13.5531 2.8125 13 2.8125H6C5.44688 2.8125 5 2.39355 5 1.875C5 1.35645 5.44688 0.9375 6 0.9375H13C13.5531 0.9375 14 1.35645 14 1.875ZM14 9.375C14 9.89355 13.5531 10.3125 13 10.3125H6C5.44688 10.3125 5 9.89355 5 9.375C5 8.85645 5.44688 8.4375 6 8.4375H13C13.5531 8.4375 14 8.85645 14 9.375ZM0 5.625C0 5.10645 0.446875 4.6875 1 4.6875H13C13.5531 4.6875 14 5.10645 14 5.625C14 6.14355 13.5531 6.5625 13 6.5625H1C0.446875 6.5625 0 6.14355 0 5.625ZM14 13.125C14 13.6436 13.5531 14.0625 13 14.0625H1C0.446875 14.0625 0 13.6436 0 13.125C0 12.6064 0.446875 12.1875 1 12.1875H13C13.5531 12.1875 14 12.6064 14 13.125Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_12_244">\n <rect width="14" height="15" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"align-justify":'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">\n <g clip-path="url(#clip0_12_240)">\n <path d="M14 1.875C14 1.35645 13.5531 0.9375 13 0.9375H1C0.446875 0.9375 0 1.35645 0 1.875C0 2.39355 0.446875 2.8125 1 2.8125H13C13.5531 2.8125 14 2.39355 14 1.875ZM14 9.375C14 8.85645 13.5531 8.4375 13 8.4375H1C0.446875 8.4375 0 8.85645 0 9.375C0 9.89355 0.446875 10.3125 1 10.3125H13C13.5531 10.3125 14 9.89355 14 9.375ZM0 5.625C0 6.14355 0.446875 6.5625 1 6.5625H13C13.5531 6.5625 14 6.14355 14 5.625C14 5.10645 13.5531 4.6875 13 4.6875H1C0.446875 4.6875 0 5.10645 0 5.625ZM14 13.125C14 12.6064 13.5531 12.1875 13 12.1875H1C0.446875 12.1875 0 12.6064 0 13.125C0 13.6436 0.446875 14.0625 1 14.0625H13C13.5531 14.0625 14 13.6436 14 13.125Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_12_240">\n <rect width="14" height="15" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"list-bullet":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"/></svg>',"list-ordered":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>',"list-check":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M152.1 38.2c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 113C-2.3 103.6-2.3 88.4 7 79s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zm0 160c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 273c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zM224 96c0-17.7 14.3-32 32-32l224 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32zm0 160c0-17.7 14.3-32 32-32l224 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32zM160 416c0-17.7 14.3-32 32-32l288 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-288 0c-17.7 0-32-14.3-32-32zM48 368a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/></svg>',"list-alpha":'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14" fill="none">\n <g clip-path="url(#clip0_28_112)">\n <path d="M9.6648 0.278534H18.8487C19.4853 0.278534 20.0001 0.78256 20.0001 1.40596C20.0001 2.02936 19.4853 2.53339 18.8487 2.53339H9.6648C9.02816 2.53339 8.51343 2.02936 8.51343 1.40596C8.51343 0.78256 9.02816 0.278534 9.6648 0.278534ZM9.6648 5.90241H18.8487C19.4853 5.90241 20.0001 6.40644 20.0001 7.02984C20.0001 7.65324 19.4853 8.15726 18.8487 8.15726H9.6648C9.02816 8.15726 8.51343 7.65324 8.51343 7.02984C8.51343 6.40644 9.02816 5.90241 9.6648 5.90241ZM9.6648 11.5197H18.8487C19.4853 11.5197 20.0001 12.0237 20.0001 12.6471C20.0001 13.2705 19.4853 13.7745 18.8487 13.7745H9.6648C9.02816 13.7745 8.51343 13.2705 8.51343 12.6471C8.51343 12.0237 9.02816 11.5197 9.6648 11.5197Z" fill="#010101"/>\n <path d="M1.80823 9.37091C2.07914 9.04595 2.60742 8.88678 3.18988 8.88678C4.6257 8.88678 5.51294 9.99431 5.51294 11.4401C5.51294 12.8858 4.61216 13.9934 3.18988 13.9934C2.56001 13.9934 1.97078 13.7215 1.76759 13.4164C1.67278 13.7811 1.46959 13.9536 1.1445 13.9536C0.663632 13.9536 0.460449 13.7016 0.460449 13.2307V7.30175C0.460449 6.81762 0.683951 6.59213 1.13095 6.59213C1.57796 6.59213 1.80823 6.82425 1.80823 7.30175V9.36428V9.37091ZM1.80823 11.4467C1.80823 12.1364 2.30264 12.6802 2.98669 12.6802C3.67074 12.6802 4.16516 12.1364 4.16516 11.4467C4.16516 10.757 3.67074 10.2132 2.98669 10.2132C2.30264 10.2132 1.80823 10.7769 1.80823 11.4467Z" fill="#231F20"/>\n <path d="M3.77237 0.58361C3.84687 0.258645 4.04328 0.092847 4.38192 0.092847C4.82215 0.092847 5.04565 0.311701 5.04565 0.762672V4.34391C5.04565 4.82804 4.82215 5.06679 4.3616 5.06679C4.04328 5.06679 3.8401 4.88773 3.73851 4.52961C3.53532 4.83468 2.94609 5.10658 2.31623 5.10658C0.893943 5.10658 -0.00683594 3.97252 -0.00683594 2.55329C-0.00683594 1.13406 0.88717 0 2.323 0C2.96641 0 3.52855 0.179062 3.77914 0.58361H3.77237ZM1.34772 2.55329C1.34772 3.25628 1.84213 3.78683 2.52618 3.78683C3.21023 3.78683 3.70464 3.24964 3.70464 2.55329C3.70464 1.85694 3.21023 1.31975 2.52618 1.31975C1.84213 1.31975 1.34772 1.88347 1.34772 2.55329Z" fill="#231F20"/>\n </g>\n <defs>\n <clipPath id="clip0_28_112">\n <rect width="20" height="14" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"list-roman":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="13" viewBox="0 0 19 13" fill="none">\n <g clip-path="url(#clip0_28_165)">\n <path d="M9.89384 0.533844H17.9855C18.5465 0.533844 19 0.979692 19 1.53114C19 2.08258 18.5465 2.52843 17.9855 2.52843H9.89384C9.33291 2.52843 8.87939 2.08258 8.87939 1.53114C8.87939 0.979692 9.33291 0.533844 9.89384 0.533844ZM9.89384 5.50271H17.9855C18.5465 5.50271 19 5.94856 19 6.5C19 7.05144 18.5465 7.49729 17.9855 7.49729H9.89384C9.33291 7.49729 8.87939 7.05144 8.87939 6.5C8.87939 5.94856 9.33291 5.50271 9.89384 5.50271ZM9.89384 10.4774H17.9855C18.5465 10.4774 19 10.9233 19 11.4747C19 12.0262 18.5465 12.472 17.9855 12.472H9.89384C9.33291 12.472 8.87939 12.0262 8.87939 11.4747C8.87939 10.9233 9.33291 10.4774 9.89384 10.4774Z" fill="#010101"/>\n <path d="M2.6495 7.15703C3.06124 7.15703 3.27607 7.35062 3.27607 7.7202C3.27607 8.08979 3.06124 8.28338 2.6495 8.28338H2.23178V11.8678H2.6495C3.06124 11.8678 3.27607 12.0614 3.27607 12.4309C3.27607 12.8005 3.06124 12.9941 2.6495 12.9941H0.62657C0.208857 12.9941 0 12.8064 0 12.4192C0 12.032 0.202889 11.8619 0.62657 11.8619H1.07412V8.27751H0.62657C0.208857 8.27751 0 8.08979 0 7.7026C0 7.31542 0.202889 7.14529 0.62657 7.14529H2.6495V7.15703Z" fill="#231F20"/>\n <path d="M6.33724 7.15703C6.74899 7.15703 6.96381 7.35062 6.96381 7.7202C6.96381 8.08979 6.74899 8.28338 6.33724 8.28338H5.91953V11.8678H6.33724C6.74899 11.8678 6.96381 12.0614 6.96381 12.4309C6.96381 12.8005 6.74899 12.9941 6.33724 12.9941H4.31431C3.8966 12.9941 3.68774 12.8064 3.68774 12.4192C3.68774 12.032 3.89063 11.8619 4.31431 11.8619H4.76186V8.27751H4.31431C3.8966 8.27751 3.68774 8.08979 3.68774 7.7026C3.68774 7.31542 3.89063 7.14529 4.31431 7.14529H6.33724V7.15703Z" fill="#231F20"/>\n <path d="M4.49349 0C4.90524 0 5.12006 0.193592 5.12006 0.563177C5.12006 0.932762 4.90524 1.12635 4.49349 1.12635H4.07578V4.71074H4.49349C4.90524 4.71074 5.12006 4.90433 5.12006 5.27392C5.12006 5.6435 4.90524 5.83709 4.49349 5.83709H2.47056C2.05285 5.83709 1.84399 5.64937 1.84399 5.26218C1.84399 4.875 2.04688 4.70487 2.47056 4.70487H2.91811V1.13222H2.47056C2.05285 1.13222 1.84399 0.944495 1.84399 0.55731C1.84399 0.170126 2.04688 0 2.47056 0H4.49349Z" fill="#231F20"/>\n </g>\n <defs>\n <clipPath id="clip0_28_165">\n <rect width="19" height="13" fill="white"/>\n </clipPath>\n </defs>\n</svg>',list:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"/></svg>',"indent-increase":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 64C0 46.3 14.3 32 32 32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64zM192 192c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32zm32 96l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32zM127.8 268.6L25.8 347.9C15.3 356.1 0 348.6 0 335.3L0 176.7c0-13.3 15.3-20.8 25.8-12.6l101.9 79.3c8.2 6.4 8.2 18.9 0 25.3z"/></svg>',"indent-decrease":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 64C0 46.3 14.3 32 32 32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64zM192 192c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32zm32 96l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32zM.2 268.6c-8.2-6.4-8.2-18.9 0-25.3l101.9-79.3c10.5-8.2 25.8-.7 25.8 12.6l0 158.6c0 13.3-15.3 20.8-25.8 12.6L.2 268.6z"/></svg>',image:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>',video:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM48 368l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0c-8.8 0-16 7.2-16 16zm368-16c-8.8 0-16 7.2-16 16l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0zM48 240l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0c-8.8 0-16 7.2-16 16zm368-16c-8.8 0-16 7.2-16 16l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0zM48 112l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16L64 96c-8.8 0-16 7.2-16 16zM416 96c-8.8 0-16 7.2-16 16l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0zM160 128l0 64c0 17.7 14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-64c0-17.7-14.3-32-32-32L192 96c-17.7 0-32 14.3-32 32zm32 160c-17.7 0-32 14.3-32 32l0 64c0 17.7 14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-64c0-17.7-14.3-32-32-32l-128 0z"/></svg>',table:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">\n <g clip-path="url(#clip0_26_744)">\n <path d="M2.50049 8V5.1875H7.18799V8H2.50049ZM2.50049 9.875H7.18799V12.6875H2.50049V9.875ZM9.06299 12.6875V9.875H13.7505V12.6875H9.06299ZM13.7505 8H9.06299V5.1875H13.7505V8ZM2.50049 1.4375C1.46631 1.4375 0.625488 2.27832 0.625488 3.3125V12.6875C0.625488 13.7217 1.46631 14.5625 2.50049 14.5625H13.7505C14.7847 14.5625 15.6255 13.7217 15.6255 12.6875V3.3125C15.6255 2.27832 14.7847 1.4375 13.7505 1.4375H2.50049Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_744">\n <rect width="15" height="15" fill="white" transform="translate(0.625488 0.5)"/>\n </clipPath>\n </defs>\n</svg>',"table-profile":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <g clip-path="url(#clip0_23_620)">\n <path d="M17.2744 10.9348V2.16365C17.2744 0.994844 16.3413 0.0475311 15.1901 0.0475311H2.35536C1.20413 0.0475311 0.274414 0.991437 0.274414 2.16024V10.9382C0.274414 12.1036 1.20413 13.0509 2.35536 13.0509H15.1935C16.3447 13.0509 17.2744 12.1036 17.2744 10.9382V10.9348ZM2.31844 7.60218H7.66178V10.8803H2.31844V7.60218ZM15.0827 10.8803H9.74273V7.60218H15.0827V10.8803ZM15.0827 5.48947H9.74273V2.21477H15.0827V5.48947ZM2.31844 2.21477H7.66178V5.48947H2.31844V2.21477Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_23_620">\n <rect width="17" height="13" fill="white" transform="translate(0.274414 0.0475311)"/>\n </clipPath>\n </defs>\n</svg>',"add-row-above":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="16" viewBox="0 0 18 16" fill="none">\n <path d="M15.6134 2.02472H13.216C13.3691 2.47353 13.4541 2.9566 13.4541 3.4568C13.4541 3.71033 13.4337 3.96043 13.3895 4.20368H15.6508V7.49953H10.7847C10.2678 7.71537 9.70328 7.83528 9.10819 7.83528C8.5131 7.83528 7.94861 7.71537 7.43173 7.49953H2.71859V4.20368H4.82692C4.78271 3.96043 4.76231 3.71033 4.76231 3.4568C4.76231 2.9566 4.84732 2.47353 5.00035 2.02472H2.60637C1.43999 2.02472 0.498047 2.97716 0.498047 4.15229V12.9709C0.498047 14.146 1.43999 15.0951 2.60637 15.0951H15.6134C16.7764 15.0951 17.7217 14.146 17.7217 12.9743V4.14886C17.7217 2.97716 16.7764 2.02472 15.6134 2.02472ZM8.12884 12.9161H2.71859V9.62367H8.12884V12.9161ZM15.6508 12.9161H10.2372V9.62367H15.6508V12.9161Z" fill="#454545"/>\n <path d="M12.2335 2.02479C11.6962 0.832527 10.4992 0 9.1118 0C7.72438 0 6.52739 0.832527 5.99011 2.02479C5.78948 2.4599 5.68066 2.94639 5.68066 3.45687C5.68066 3.71383 5.70787 3.96393 5.76228 4.20375C6.02752 5.4337 6.94566 6.41697 8.13245 6.77328C8.44189 6.86578 8.77174 6.91717 9.1118 6.91717C9.50626 6.91717 9.88712 6.84865 10.2408 6.72531C11.3527 6.33474 12.2063 5.38231 12.4613 4.20375C12.5157 3.96393 12.5429 3.71383 12.5429 3.45687C12.5429 2.94639 12.4341 2.4599 12.2335 2.02479ZM10.8393 3.77549H9.42465V5.1973C9.42465 5.37203 9.28522 5.5125 9.1118 5.5125C8.93837 5.5125 8.79895 5.37203 8.79895 5.1973V3.77549H7.38433C7.2109 3.77549 7.07148 3.6316 7.07148 3.45687C7.07148 3.28214 7.2109 3.14168 7.38433 3.14168H8.79895V1.71987C8.79895 1.54514 8.93837 1.40125 9.1118 1.40125C9.28522 1.40125 9.42465 1.54514 9.42465 1.71987V3.14168H10.8393C11.0127 3.14168 11.1521 3.28214 11.1521 3.45687C11.1521 3.6316 11.0127 3.77549 10.8393 3.77549Z" fill="#454545"/>\n</svg>',"add-row-below":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="16" viewBox="0 0 18 16" fill="none">\n <path d="M2.83001 13.0703H5.22738C5.07436 12.6215 4.98935 12.1385 4.98935 11.6383C4.98935 11.3847 5.00975 11.1346 5.05396 10.8914H2.79261V7.59554H7.65876C8.17564 7.3797 8.74013 7.25979 9.33522 7.25979C9.93032 7.25979 10.4948 7.3797 11.0117 7.59554H15.7248V10.8914H13.6165C13.6607 11.1346 13.6811 11.3847 13.6811 11.6383C13.6811 12.1385 13.5961 12.6215 13.4431 13.0703H15.837C17.0034 13.0703 17.9454 12.1179 17.9454 10.9428V2.12416C17.9454 0.949028 17.0034 1.52588e-05 15.837 1.52588e-05H2.83001C1.66703 1.52588e-05 0.72168 0.949028 0.72168 2.12073V10.9462C0.72168 12.1179 1.66703 13.0703 2.83001 13.0703ZM10.3146 2.17898H15.7248V5.4714H10.3146V2.17898ZM2.79261 2.17898H8.20625V5.4714H2.79261V2.17898Z" fill="#454545"/>\n <path d="M6.2135 13.0703C6.75079 14.2625 7.94777 15.095 9.33519 15.095C10.7226 15.095 11.9196 14.2625 12.4569 13.0703C12.6575 12.6351 12.7663 12.1486 12.7663 11.6382C12.7663 11.3812 12.7391 11.1311 12.6847 10.8913C12.4195 9.66135 11.5013 8.67807 10.3145 8.32177C10.0051 8.22926 9.67524 8.17787 9.33519 8.17787C8.94072 8.17787 8.55987 8.24639 8.20621 8.36973C7.09424 8.7603 6.24071 9.71274 5.98567 10.8913C5.93126 11.1311 5.90405 11.3812 5.90405 11.6382C5.90405 12.1486 6.01287 12.6351 6.2135 13.0703ZM7.60772 11.3195H9.02234V9.89774C9.02234 9.72302 9.16176 9.58255 9.33519 9.58255C9.50861 9.58255 9.64803 9.72302 9.64803 9.89774V11.3195H11.0627C11.2361 11.3195 11.3755 11.4634 11.3755 11.6382C11.3755 11.8129 11.2361 11.9534 11.0627 11.9534H9.64803V13.3752C9.64803 13.5499 9.50861 13.6938 9.33519 13.6938C9.16176 13.6938 9.02234 13.5499 9.02234 13.3752V11.9534H7.60772C7.43429 11.9534 7.29487 11.8129 7.29487 11.6382C7.29487 11.4634 7.43429 11.3195 7.60772 11.3195Z" fill="#454545"/>\n</svg>',"add-col-left":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="14" viewBox="0 0 19 14" fill="none">\n <path d="M16.4982 0.0123596H3.49115C2.32476 0.0123596 1.38281 0.964798 1.38281 2.1365V2.78402C2.03231 2.39346 2.79063 2.17076 3.60336 2.17076C3.73938 2.17076 3.872 2.17762 4.00462 2.19132H9.0136V5.48717H7.82001C7.90503 5.82977 7.94924 6.18265 7.94924 6.54924C7.94924 6.91583 7.90503 7.27213 7.82001 7.61131H9.0136V10.9037H4.04883C3.9026 10.9209 3.75298 10.9277 3.60336 10.9277C2.79063 10.9277 2.03231 10.705 1.38281 10.3145V10.9586C1.38281 12.1303 2.32476 13.0827 3.49115 13.0827H16.4982C17.6612 13.0827 18.6065 12.1337 18.6065 10.962V2.1365C18.6065 0.964798 17.6612 0.0123596 16.4982 0.0123596ZM16.5356 10.9037H11.1219V7.61131H16.5356V10.9037ZM16.5356 5.48717H11.1219V2.19132H16.5356V5.48717Z" fill="#454545"/>\n <path d="M6.87164 5.48725C6.42617 4.09627 5.13057 3.08902 3.60373 3.08902C2.75699 3.08902 1.98167 3.39736 1.38318 3.91469C0.638465 4.54509 0.169189 5.49067 0.169189 6.54932C0.169189 7.60796 0.638465 8.55012 1.38318 9.18052C1.98167 9.69785 2.75699 10.0062 3.60373 10.0062C5.13057 10.0062 6.42617 8.99894 6.87164 7.61139C6.97706 7.27906 7.03486 6.91933 7.03486 6.54932C7.03486 6.17931 6.97706 5.81957 6.87164 5.48725ZM5.3278 6.86451H3.91658V8.28632C3.91658 8.46105 3.77715 8.60494 3.60373 8.60494C3.4303 8.60494 3.28748 8.46105 3.28748 8.28632V6.86451H1.87626C1.70284 6.86451 1.56341 6.72405 1.56341 6.54932C1.56341 6.37459 1.70284 6.2307 1.87626 6.2307H3.28748V4.80889C3.28748 4.63416 3.4303 4.4937 3.60373 4.4937C3.77715 4.4937 3.91658 4.63416 3.91658 4.80889V6.2307H5.3278C5.50123 6.2307 5.64405 6.37459 5.64405 6.54932C5.64405 6.72405 5.50123 6.86451 5.3278 6.86451Z" fill="#454545"/>\n</svg>',"add-col-right":'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14" fill="none">\n <path d="M2.71478 13.0827H15.7218C16.8882 13.0827 17.8301 12.1303 17.8301 10.9586V10.311C17.1806 10.7016 16.4223 10.9243 15.6096 10.9243C15.4736 10.9243 15.3409 10.9174 15.2083 10.9037H10.1993V7.60789H11.3929C11.3079 7.26528 11.2637 6.9124 11.2637 6.54581C11.2637 6.17923 11.3079 5.82292 11.3929 5.48374H10.1993V2.19132H15.1641C15.3103 2.17419 15.46 2.16734 15.6096 2.16734C16.4223 2.16734 17.1806 2.39003 17.8301 2.7806V2.1365C17.8301 0.964798 16.8882 0.0123596 15.7218 0.0123596H2.71478C1.5518 0.0123596 0.606445 0.961372 0.606445 2.13308V10.9586C0.606445 12.1303 1.5518 13.0827 2.71478 13.0827ZM2.67737 2.19132H8.09102V5.48374H2.67737V2.19132ZM2.67737 7.60789H8.09102V10.9037H2.67737V7.60789Z" fill="#454545"/>\n <path d="M12.3419 7.60796C12.7874 8.99894 14.083 10.0062 15.6098 10.0062C16.4566 10.0062 17.2319 9.69785 17.8304 9.18052C18.5751 8.55012 19.0444 7.60454 19.0444 6.54589C19.0444 5.48725 18.5751 4.54509 17.8304 3.91469C17.2319 3.39736 16.4566 3.08902 15.6098 3.08902C14.083 3.08902 12.7874 4.09627 12.3419 5.48382C12.2365 5.81615 12.1787 6.17588 12.1787 6.54589C12.1787 6.9159 12.2365 7.27564 12.3419 7.60796ZM13.8858 6.2307H15.297V4.80889C15.297 4.63416 15.4364 4.49027 15.6098 4.49027C15.7833 4.49027 15.9261 4.63416 15.9261 4.80889V6.2307H17.3373C17.5107 6.2307 17.6502 6.37116 17.6502 6.54589C17.6502 6.72062 17.5107 6.86451 17.3373 6.86451H15.9261V8.28632C15.9261 8.46105 15.7833 8.60152 15.6098 8.60152C15.4364 8.60152 15.297 8.46105 15.297 8.28632V6.86451H13.8858C13.7124 6.86451 13.5695 6.72062 13.5695 6.54589C13.5695 6.37116 13.7124 6.2307 13.8858 6.2307Z" fill="#454545"/>\n</svg>',"delete-row":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="14" viewBox="0 0 19 14" fill="none">\n <path d="M18.169 2.13993V10.9586C18.169 12.1337 17.2271 13.0827 16.0607 13.0827H3.05365C1.89066 13.0827 0.945312 12.1337 0.945312 10.962V2.1365C0.945312 0.964798 1.89066 0.0123596 3.05365 0.0123596H7.45053C7.10367 0.204218 6.77723 0.450893 6.48478 0.745532C6.06311 1.17036 5.74346 1.66371 5.53263 2.19132H3.01624V5.48374H5.53263C5.74346 6.01135 6.05971 6.50813 6.48478 6.93638C6.74662 7.20019 7.03226 7.42288 7.33831 7.60789H3.01624V10.9037H8.42988V8.0704C9.12019 8.25541 9.8445 8.26911 10.5382 8.10466V10.9037H15.9485V7.60789H11.7794C12.0855 7.42288 12.3711 7.20019 12.6329 6.93638C13.058 6.50813 13.3743 6.01135 13.5851 5.48374H15.9485V2.19132H13.5851C13.3743 1.66371 13.0546 1.17036 12.6329 0.745532C12.3405 0.450893 12.014 0.204218 11.6672 0.0123596H16.0607C17.2271 0.0123596 18.169 0.964798 18.169 2.13993Z" fill="#454545"/>\n <path d="M12.5751 2.19137C12.4221 1.90701 12.2249 1.63635 11.9869 1.39653C10.6436 0.04324 8.4707 0.04324 7.1309 1.39653C6.89286 1.63635 6.69563 1.90701 6.5426 2.19137C5.98832 3.21575 5.98832 4.4594 6.53921 5.48379C6.69223 5.77158 6.88946 6.04223 7.1309 6.28548C8.4707 7.63534 10.6436 7.63534 11.9869 6.28548C12.2283 6.04223 12.4255 5.77158 12.5785 5.48379C13.1294 4.4594 13.1294 3.21575 12.5751 2.19137ZM10.5382 4.3806L11.0007 4.84655C11.1231 4.96988 11.1231 5.16859 11.0007 5.29536C10.8783 5.41869 10.681 5.41869 10.5586 5.29536L9.55887 4.2881L8.55912 5.29536C8.52171 5.33304 8.47751 5.36045 8.4299 5.37073C8.32108 5.40842 8.20207 5.38101 8.11705 5.29536C7.99463 5.16859 7.99463 4.96988 8.11705 4.84655L8.4299 4.53135L9.1134 3.83929L8.11705 2.83546C7.99463 2.71212 7.99463 2.50999 8.11705 2.38665C8.20207 2.301 8.32108 2.27359 8.4299 2.31128C8.47751 2.32156 8.52171 2.34896 8.55912 2.38665L9.55887 3.39391L10.5586 2.38665C10.681 2.26331 10.8783 2.26331 11.0007 2.38665C11.1231 2.50999 11.1231 2.71212 11.0007 2.83546L10.5382 3.3014L10.0009 3.83929L10.5382 4.3806Z" fill="#454545"/>\n</svg>',"delete-col":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="14" viewBox="0 0 19 14" fill="none">\n <path d="M16.5185 0.0123596H3.51142C2.34844 0.0123596 1.40649 0.964798 1.40649 2.1365V2.69495C2.18522 2.27012 3.06596 2.10224 3.92289 2.19132H8.89106V5.48374H7.69069C7.86412 6.17923 7.86412 6.9124 7.69069 7.60789H8.89106V10.9037H3.89228C3.04215 10.986 2.17501 10.8181 1.40649 10.3967V10.962C1.40649 12.1337 2.34844 13.0827 3.51142 13.0827H16.5185C17.6848 13.0827 18.6302 12.1303 18.6302 10.9586V2.13993C18.6302 0.964798 17.6848 0.0123596 16.5185 0.0123596ZM16.4096 10.9037H10.9994V7.60789H16.4096V10.9037ZM16.4096 5.48374H10.9994V2.19132H16.4096V5.48374Z" fill="#454545"/>\n <path d="M6.74518 5.48377C6.58195 4.97671 6.30312 4.50049 5.90185 4.09965C5.23195 3.42472 4.35801 3.08554 3.47727 3.08554C2.74616 3.08554 2.01504 3.31851 1.40634 3.78788C1.28052 3.88038 1.16151 3.98659 1.04929 4.09965C-0.290519 5.44951 -0.290519 7.64217 1.04929 8.99203C1.16151 9.10509 1.28052 9.2113 1.40634 9.3038C2.01504 9.77317 2.74616 10.0061 3.47727 10.0061C4.35801 10.0061 5.23195 9.66696 5.90185 8.99203C6.30312 8.59119 6.58195 8.11496 6.74518 7.60791C6.96281 6.91928 6.96281 6.1724 6.74518 5.48377ZM4.9191 7.55309C4.9191 7.55309 4.9497 7.58736 4.9633 7.60791C5.03812 7.72782 5.02451 7.89227 4.9191 7.99848C4.79668 8.12182 4.59605 8.12182 4.47363 7.99848L4.08596 7.60791L3.47727 6.99465L2.47752 7.99848C2.3551 8.12182 2.15787 8.12182 2.03205 7.99848C1.90963 7.87514 1.90963 7.67643 2.03205 7.55309L3.0318 6.54584L2.03205 5.53858C1.90963 5.41525 1.90963 5.21654 2.03205 5.0932C2.15787 4.96986 2.3551 4.96986 2.47752 5.0932L3.47727 6.09703L4.47363 5.0932C4.59605 4.96986 4.79668 4.96986 4.9191 5.0932C5.02451 5.19941 5.03812 5.36386 4.9633 5.48377C4.9497 5.50432 4.9361 5.52145 4.9191 5.53858L3.91934 6.54584L4.9191 7.55309Z" fill="#454545"/>\n</svg>',"delete-table":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <path d="M15.3864 0.0123596H2.37934C1.21636 0.0123596 0.274414 0.964798 0.274414 2.1365V10.962C0.274414 12.1337 1.21636 13.0827 2.37934 13.0827H15.3864C16.5528 13.0827 17.4981 12.1337 17.4981 10.9586V2.13993C17.4981 0.964798 16.5528 0.0123596 15.3864 0.0123596ZM15.2776 5.48374H13.2542C13.4209 6.18265 13.4209 6.9124 13.2542 7.60789H15.2776V10.9037H10.1257C9.31642 11.1367 8.45609 11.1367 7.64676 10.9037H2.34534V7.60789H4.51488C4.34825 6.9124 4.34825 6.18265 4.51488 5.48374H2.34534V2.19132H7.66037C8.46289 1.96178 9.31302 1.96178 10.1155 2.19132H15.2776V5.48374Z" fill="#454545"/>\n <path d="M12.2715 5.48376C12.1083 4.9493 11.8158 4.44567 11.3942 4.02084C10.9521 3.57546 10.4284 3.27396 9.86732 3.11294C9.18041 2.9108 8.4425 2.92793 7.75899 3.15748C7.25231 3.32535 6.77624 3.61657 6.37497 4.02084C5.95331 4.44567 5.66086 4.9493 5.49764 5.48376C5.28 6.17239 5.28 6.91927 5.49424 7.6079C5.65746 8.14579 5.95331 8.65284 6.37497 9.07767C6.79664 9.5025 7.25231 9.77316 7.75899 9.94103C8.4425 10.1706 9.18041 10.1877 9.86732 9.98557C10.4284 9.82455 10.9521 9.52306 11.3942 9.07767C11.8362 8.63229 12.1117 8.14579 12.2749 7.6079C12.4891 6.91927 12.4891 6.17239 12.2715 5.48376ZM10.3774 7.59077C10.3774 7.59077 10.3876 7.60105 10.391 7.6079C10.5032 7.73467 10.4964 7.92995 10.3774 8.05329C10.2516 8.18005 10.0441 8.18005 9.91833 8.05329L9.86732 8.0019L8.88457 7.01177L7.8508 8.05329C7.8236 8.0807 7.793 8.10468 7.75899 8.11838C7.63997 8.1732 7.49375 8.15264 7.39173 8.05329C7.27271 7.92995 7.26591 7.73467 7.37813 7.6079C7.38153 7.60105 7.38493 7.59762 7.39173 7.59077L8.42549 6.54926L7.39173 5.50774C7.39173 5.50774 7.37813 5.49404 7.37133 5.48376C7.26591 5.357 7.27271 5.16514 7.39173 5.04523C7.49375 4.94587 7.63997 4.92531 7.75899 4.98013C7.793 4.99384 7.8236 5.01782 7.8508 5.04523L8.88457 6.08674L9.86732 5.09662L9.91833 5.04523C10.0441 4.91846 10.2516 4.91846 10.3774 5.04523C10.4964 5.16514 10.5032 5.357 10.3978 5.48376C10.391 5.49404 10.3842 5.50089 10.3774 5.50774L9.34364 6.54926L10.3774 7.59077Z" fill="#454545"/>\n</svg>',color:'<svg xmlns="http://www.w3.org/2000/svg" width="13" height="14" viewBox="0 0 13 14" fill="none">\n <g clip-path="url(#clip0_26_733)">\n <path d="M7.55292 1.73122C7.43003 1.4071 7.11626 1.19189 6.76851 1.19189C6.42076 1.19189 6.107 1.4071 5.98411 1.73122L2.42291 11.1486H1.74832C1.28552 11.1486 0.911621 11.5194 0.911621 11.9783C0.911621 12.4373 1.28552 12.8081 1.74832 12.8081H4.25842C4.72121 12.8081 5.09511 12.4373 5.09511 11.9783C5.09511 11.5194 4.72121 11.1486 4.25842 11.1486H4.21135L4.68199 9.90402H8.85503L9.32567 11.1486H9.27861C8.81581 11.1486 8.44191 11.5194 8.44191 11.9783C8.44191 12.4373 8.81581 12.8081 9.27861 12.8081H11.7887C12.2515 12.8081 12.6254 12.4373 12.6254 11.9783C12.6254 11.5194 12.2515 11.1486 11.7887 11.1486H11.1141L7.55292 1.73122ZM8.2275 8.24457H5.30952L6.76851 4.38375L8.2275 8.24457Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_733">\n <rect width="11.7138" height="13.2756" fill="white" transform="translate(0.911621 0.362183)"/>\n </clipPath>\n </defs>\n</svg>',background:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_3_40)">\n <path d="M1.08399 0.605877C1.40598 0.281765 1.92632 0.281765 2.24831 0.605877L4.34514 2.7139L5.71296 1.33707C6.4368 0.60847 7.61144 0.60847 8.33528 1.33707L12.2353 5.26531C12.9591 5.99391 12.9591 7.17627 12.2353 7.90487L7.33066 12.8443C6.36468 13.8167 4.7985 13.8167 3.83252 12.8443L0.805784 9.79769C-0.160196 8.82535 -0.160196 7.24887 0.805784 6.27654L3.17823 3.88848L1.08399 1.77786C0.761993 1.45375 0.761993 0.927396 1.08399 0.603284V0.605877ZM5.61765 6.34395L4.34514 5.06306L1.97269 7.45112C1.8645 7.56002 1.79237 7.69226 1.75631 7.82968H9.97873L11.0684 6.73289C11.1482 6.65251 11.1482 6.52027 11.0684 6.43989L7.17095 2.51165C7.09109 2.43127 6.95972 2.43127 6.87987 2.51165L5.51204 3.88848L6.78456 5.16937C7.10655 5.49348 7.10655 6.01984 6.78456 6.34395C6.46256 6.66806 5.93965 6.66806 5.61765 6.34395ZM13.2064 13.6378C12.2971 13.6378 11.5578 12.8936 11.5578 11.9783C11.5578 11.3249 12.3975 9.91437 12.8767 9.15983C13.0312 8.9161 13.379 8.9161 13.5335 9.15983C14.0152 9.91437 14.855 11.3249 14.855 11.9783C14.855 12.8936 14.1157 13.6378 13.2064 13.6378Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_3_40">\n <rect width="14.8375" height="13.2756" fill="white" transform="translate(0.0175781 0.362183)"/>\n </clipPath>\n </defs>\n</svg>',"no-color":'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">\n <line x1="1.24715" y1="6.41398" x2="21.5343" y2="18.1268" stroke="#EA6666" stroke-width="0.842105"/>\n <circle cx="11.7127" cy="11.7128" r="11.2918" transform="rotate(90 11.7127 11.7128)" stroke="#D7D7D7" stroke-width="0.842105"/>\n</svg> ',"custom-color":'<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" viewBox="0 0 17 16" fill="none">\n <g clip-path="url(#clip0_6_132)">\n <path d="M16.07 7.7128C16.07 7.73944 16.07 7.76609 16.07 7.79273C16.0582 8.87332 15.0753 9.60753 13.9947 9.60753H11.0963C10.3118 9.60753 9.67527 10.244 9.67527 11.0286C9.67527 11.1292 9.68711 11.2269 9.70487 11.3217C9.76704 11.6237 9.89731 11.9138 10.0246 12.2069C10.2052 12.6154 10.3828 13.021 10.3828 13.4503C10.3828 14.3917 9.74336 15.2473 8.80191 15.2858C8.69829 15.2888 8.59468 15.2917 8.4881 15.2917C4.30487 15.2917 0.912109 11.899 0.912109 7.7128C0.912109 3.52661 4.30487 0.13385 8.49106 0.13385C12.6772 0.13385 16.07 3.52661 16.07 7.7128ZM4.70158 8.66017C4.70158 8.40891 4.60177 8.16794 4.42411 7.99028C4.24644 7.81261 4.00547 7.7128 3.75421 7.7128C3.50296 7.7128 3.26199 7.81261 3.08432 7.99028C2.90666 8.16794 2.80685 8.40891 2.80685 8.66017C2.80685 8.91142 2.90666 9.15239 3.08432 9.33006C3.26199 9.50772 3.50296 9.60753 3.75421 9.60753C4.00547 9.60753 4.24644 9.50772 4.42411 9.33006C4.60177 9.15239 4.70158 8.91142 4.70158 8.66017ZM4.70158 5.81806C4.95284 5.81806 5.19381 5.71825 5.37147 5.54058C5.54914 5.36292 5.64895 5.12195 5.64895 4.87069C5.64895 4.61943 5.54914 4.37847 5.37147 4.2008C5.19381 4.02314 4.95284 3.92332 4.70158 3.92332C4.45033 3.92332 4.20936 4.02314 4.03169 4.2008C3.85403 4.37847 3.75421 4.61943 3.75421 4.87069C3.75421 5.12195 3.85403 5.36292 4.03169 5.54058C4.20936 5.71825 4.45033 5.81806 4.70158 5.81806ZM9.43843 2.97596C9.43843 2.7247 9.33861 2.48373 9.16095 2.30606C8.98328 2.1284 8.74231 2.02859 8.49106 2.02859C8.2398 2.02859 7.99883 2.1284 7.82117 2.30606C7.6435 2.48373 7.54369 2.7247 7.54369 2.97596C7.54369 3.22721 7.6435 3.46818 7.82117 3.64585C7.99883 3.82351 8.2398 3.92332 8.49106 3.92332C8.74231 3.92332 8.98328 3.82351 9.16095 3.64585C9.33861 3.46818 9.43843 3.22721 9.43843 2.97596ZM12.2805 5.81806C12.5318 5.81806 12.7728 5.71825 12.9504 5.54058C13.1281 5.36292 13.2279 5.12195 13.2279 4.87069C13.2279 4.61943 13.1281 4.37847 12.9504 4.2008C12.7728 4.02314 12.5318 3.92332 12.2805 3.92332C12.0293 3.92332 11.7883 4.02314 11.6106 4.2008C11.433 4.37847 11.3332 4.61943 11.3332 4.87069C11.3332 5.12195 11.433 5.36292 11.6106 5.54058C11.7883 5.71825 12.0293 5.81806 12.2805 5.81806Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_6_132">\n <rect width="15.1579" height="15.1579" fill="white" transform="translate(0.912109 0.13385)"/>\n </clipPath>\n </defs>\n</svg>',undo:'\x3c!-- Undo icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <path d="M1.95166 6.12501H1.71924C1.35557 6.12501 1.06299 5.83243 1.06299 5.46876V1.96876C1.06299 1.70353 1.22158 1.4629 1.46768 1.36173C1.71377 1.26056 1.99541 1.31525 2.18408 1.50392L3.32158 2.64142C5.7169 0.276185 9.5751 0.284388 11.9567 2.66876C14.3493 5.06134 14.3493 8.93869 11.9567 11.3313C9.56416 13.7238 5.68682 13.7238 3.29424 11.3313C2.95244 10.9895 2.95244 10.4344 3.29424 10.0926C3.63604 9.7508 4.19111 9.7508 4.53291 10.0926C6.2419 11.8016 9.01182 11.8016 10.7208 10.0926C12.4298 8.38361 12.4298 5.61369 10.7208 3.9047C9.02002 2.20392 6.27197 2.19572 4.56025 3.87736L5.68408 5.00392C5.87275 5.19259 5.92744 5.47423 5.82627 5.72033C5.7251 5.96642 5.48447 6.12501 5.21924 6.12501H1.95166Z" fill="#454545"/>\n</svg>',redo:'\x3c!-- Redo icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_26_755)">\n <path d="M11.1883 4.37501H9.81294C9.32896 4.37501 8.93794 4.76603 8.93794 5.25001C8.93794 5.734 9.32896 6.12501 9.81294 6.12501H13.3129C13.7969 6.12501 14.1879 5.734 14.1879 5.25001V1.75001C14.1879 1.26603 13.7969 0.875012 13.3129 0.875012C12.829 0.875012 12.4379 1.26603 12.4379 1.75001V3.15001L11.9567 2.66876C9.56411 0.276184 5.68677 0.276184 3.29419 2.66876C0.901611 5.06134 0.901611 8.93868 3.29419 11.3313C5.68677 13.7238 9.56411 13.7238 11.9567 11.3313C12.2985 10.9895 12.2985 10.4344 11.9567 10.0926C11.6149 9.75079 11.0598 9.75079 10.718 10.0926C9.00903 11.8016 6.23911 11.8016 4.53013 10.0926C2.82114 8.38361 2.82114 5.61368 4.53013 3.9047C6.23911 2.19572 9.00903 2.19572 10.718 3.9047L11.1883 4.37501Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_755">\n <rect width="14" height="14" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',link:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="12" viewBox="0 0 16 12" fill="none">\n <path d="M14.5737 6.29853C15.9761 4.85693 15.9761 2.5223 14.5737 1.0807C13.3327 -0.195058 11.3769 -0.360906 9.94976 0.687763L9.91005 0.71583C9.55264 0.978635 9.47074 1.48894 9.72638 1.8538C9.98203 2.21867 10.4784 2.30542 10.8334 2.04261L10.8731 2.01455C11.6698 1.43025 12.7594 1.52211 13.4494 2.23398C14.2312 3.0377 14.2312 4.33897 13.4494 5.14269L10.6646 8.01059C9.88275 8.81431 8.61693 8.81431 7.83509 8.01059C7.14261 7.29872 7.05326 6.17861 7.62164 5.36212L7.64894 5.3213C7.90459 4.95388 7.8202 4.44358 7.46527 4.18333C7.11035 3.92307 6.61147 4.00727 6.3583 4.37214L6.331 4.41296C5.30841 5.87753 5.46974 7.88811 6.71075 9.16387C8.11308 10.6055 10.3841 10.6055 11.7864 9.16387L14.5737 6.29853ZM1.67724 5.70147C0.274905 7.14307 0.274905 9.4777 1.67724 10.9193C2.91824 12.1951 4.87406 12.3609 6.30121 11.3122L6.34093 11.2842C6.69834 11.0214 6.78024 10.5111 6.5246 10.1462C6.26895 9.78133 5.77255 9.69458 5.41762 9.95739L5.37791 9.98545C4.58118 10.5697 3.49158 10.4779 2.80159 9.76602C2.01976 8.95975 2.01976 7.65848 2.80159 6.85475L5.5864 3.98941C6.36823 3.18569 7.63405 3.18569 8.41588 3.98941C9.10836 4.70128 9.19771 5.82139 8.62934 6.64043L8.60203 6.68125C8.34639 7.04867 8.43078 7.55897 8.7857 7.81922C9.14063 8.07948 9.63951 7.99528 9.89268 7.63041L9.91998 7.58959C10.9426 6.12247 10.7812 4.11189 9.54023 2.83613C8.1379 1.39453 5.86686 1.39453 4.46453 2.83613L1.67724 5.70147Z" fill="#454545"/>\n</svg>',emoji:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm177.6 62.1C192.8 334.5 218.8 352 256 352s63.2-17.5 78.4-33.9c9-9.7 24.2-10.4 33.9-1.4s10.4 24.2 1.4 33.9c-22 23.8-60 49.4-113.6 49.4s-91.7-25.5-113.6-49.4c-9-9.7-8.4-24.9 1.4-33.9s24.9-8.4 33.9 1.4zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',tag:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 80L0 229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7L48 32C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',import:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M128 64c0-35.3 28.7-64 64-64L352 0l0 128c0 17.7 14.3 32 32 32l128 0 0 288c0 35.3-28.7 64-64 64l-256 0c-35.3 0-64-28.7-64-64l0-112 174.1 0-39 39c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l80-80c9.4-9.4 9.4-24.6 0-33.9l-80-80c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l39 39L128 288l0-224zm0 224l0 48L24 336c-13.3 0-24-10.7-24-24s10.7-24 24-24l104 0zM512 128l-128 0L384 0 512 128z"/></svg>',code:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <g clip-path="url(#clip0_131_130)">\n <path d="M10.6186 0.421434C10.1623 0.294382 9.68715 0.551079 9.55561 0.991871L6.11957 12.608C5.98803 13.0488 6.25379 13.5078 6.71014 13.6348C7.16649 13.7619 7.64163 13.5052 7.77316 13.0644L11.2092 1.44822C11.3407 1.00743 11.075 0.548486 10.6186 0.421434ZM12.7823 3.5355C12.4467 3.85961 12.4467 4.38597 12.7823 4.71008L15.1794 7.02813L12.7796 9.34618C12.444 9.67029 12.444 10.1966 12.7796 10.5208C13.1151 10.8449 13.6601 10.8449 13.9956 10.5208L17.0022 7.61672C17.3377 7.2926 17.3377 6.76625 17.0022 6.44213L13.9956 3.53809C13.6601 3.21398 13.1151 3.21398 12.7796 3.53809L12.7823 3.5355ZM4.54919 3.5355C4.21364 3.21139 3.6687 3.21139 3.33315 3.5355L0.326614 6.43954C-0.00893658 6.76365 -0.00893658 7.29001 0.326614 7.61412L3.33315 10.5182C3.6687 10.8423 4.21364 10.8423 4.54919 10.5182C4.88474 10.1941 4.88474 9.66769 4.54919 9.34358L2.14933 7.02813L4.54919 4.71008C4.88474 4.38597 4.88474 3.85961 4.54919 3.5355Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_131_130">\n <rect width="17.1802" height="13.2756" fill="white" transform="translate(0.0742188 0.390442)"/>\n </clipPath>\n </defs>\n</svg>',"code-view":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <g clip-path="url(#clip0_131_130)">\n <path d="M10.6186 0.421434C10.1623 0.294382 9.68715 0.551079 9.55561 0.991871L6.11957 12.608C5.98803 13.0488 6.25379 13.5078 6.71014 13.6348C7.16649 13.7619 7.64163 13.5052 7.77316 13.0644L11.2092 1.44822C11.3407 1.00743 11.075 0.548486 10.6186 0.421434ZM12.7823 3.5355C12.4467 3.85961 12.4467 4.38597 12.7823 4.71008L15.1794 7.02813L12.7796 9.34618C12.444 9.67029 12.444 10.1966 12.7796 10.5208C13.1151 10.8449 13.6601 10.8449 13.9956 10.5208L17.0022 7.61672C17.3377 7.2926 17.3377 6.76625 17.0022 6.44213L13.9956 3.53809C13.6601 3.21398 13.1151 3.21398 12.7796 3.53809L12.7823 3.5355ZM4.54919 3.5355C4.21364 3.21139 3.6687 3.21139 3.33315 3.5355L0.326614 6.43954C-0.00893658 6.76365 -0.00893658 7.29001 0.326614 7.61412L3.33315 10.5182C3.6687 10.8423 4.21364 10.8423 4.54919 10.5182C4.88474 10.1941 4.88474 9.66769 4.54919 9.34358L2.14933 7.02813L4.54919 4.71008C4.88474 4.38597 4.88474 3.85961 4.54919 3.5355Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_131_130">\n <rect width="17.1802" height="13.2756" fill="white" transform="translate(0.0742188 0.390442)"/>\n </clipPath>\n </defs>\n</svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="none">\n <g clip-path="url(#clip0_4_79)">\n <path d="M9.68012 2.27338C9.93724 2.52649 9.93724 2.93753 9.68012 3.19063L4.41429 8.37417C4.15717 8.62728 3.73961 8.62728 3.48249 8.37417L0.849578 5.7824C0.592458 5.5293 0.592458 5.11826 0.849578 4.86516C1.1067 4.61205 1.52426 4.61205 1.78138 4.86516L3.94942 6.99729L8.75037 2.27338C9.00749 2.02028 9.42505 2.02028 9.68217 2.27338H9.68012Z" fill="currentColor"/>\n </g>\n <defs>\n <clipPath id="clip0_4_79">\n <rect width="9.21519" height="10.3671" fill="white" transform="translate(0.658203 0.139252)"/>\n </clipPath>\n </defs>\n</svg> ',dropdown:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 8 7" fill="none">\n <g clip-path="url(#clip0_4_66)">\n <path d="M3.81655 5.55897C3.98745 5.72987 4.26499 5.72987 4.43589 5.55897L7.06089 2.93397C7.23179 2.76307 7.23179 2.48553 7.06089 2.31464C6.88999 2.14374 6.61245 2.14374 6.44155 2.31464L4.12554 4.63065L1.80952 2.316C1.63862 2.1451 1.36108 2.1451 1.19019 2.316C1.01929 2.4869 1.01929 2.76444 1.19019 2.93534L3.81519 5.56034L3.81655 5.55897Z" fill="#CCCCCC"/>\n </g>\n <defs>\n <clipPath id="clip0_4_66">\n <rect width="12" height="12" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg> ',more:'\x3c!-- More options icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">\n <g clip-path="url(#clip0_26_758)">\n <path d="M0.875488 8C0.875488 7.53587 1.05986 7.09075 1.38805 6.76256C1.71624 6.43437 2.16136 6.25 2.62549 6.25C3.08962 6.25 3.53474 6.43437 3.86293 6.76256C4.19111 7.09075 4.37549 7.53587 4.37549 8C4.37549 8.46413 4.19111 8.90925 3.86293 9.23744C3.53474 9.56563 3.08962 9.75 2.62549 9.75C2.16136 9.75 1.71624 9.56563 1.38805 9.23744C1.05986 8.90925 0.875488 8.46413 0.875488 8ZM5.87549 8C5.87549 7.53587 6.05986 7.09075 6.38805 6.76256C6.71624 6.43437 7.16136 6.25 7.62549 6.25C8.08962 6.25 8.53474 6.43437 8.86293 6.76256C9.19111 7.09075 9.37549 7.53587 9.37549 8C9.37549 8.46413 9.19111 8.90925 8.86293 9.23744C8.53474 9.56563 8.08962 9.75 7.62549 9.75C7.16136 9.75 6.71624 9.56563 6.38805 9.23744C6.05986 8.90925 5.87549 8.46413 5.87549 8ZM12.6255 6.25C13.0896 6.25 13.5347 6.43437 13.8629 6.76256C14.1911 7.09075 14.3755 7.53587 14.3755 8C14.3755 8.46413 14.1911 8.90925 13.8629 9.23744C13.5347 9.56563 13.0896 9.75 12.6255 9.75C12.1614 9.75 11.7162 9.56563 11.3881 9.23744C11.0599 8.90925 10.8755 8.46413 10.8755 8C10.8755 7.53587 11.0599 7.09075 11.3881 6.76256C11.7162 6.43437 12.1614 6.25 12.6255 6.25Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_758">\n <rect width="14" height="16" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',theme:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">\n <circle cx="8" cy="8" r="3" stroke="#454545" stroke-width="1.5" fill="none"/>\n <path d="M8 1V2M8 14V15M15 8H14M2 8H1M12.5 3.5L11.8 4.2M4.2 11.8L3.5 12.5M12.5 12.5L11.8 11.8M4.2 4.2L3.5 3.5" stroke="#454545" stroke-width="1.5" stroke-linecap="round"/>\n</svg> ',heading:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="14" viewBox="0 0 12 14" fill="none">\n <g clip-path="url(#clip0_17_399)">\n <path d="M6.89569 1.75949C6.7728 1.43538 6.45904 1.22017 6.11129 1.22017C5.76353 1.22017 5.44977 1.43538 5.32688 1.75949L1.76568 11.1769H1.09109C0.628294 11.1769 0.254395 11.5477 0.254395 12.0066C0.254395 12.4656 0.628294 12.8363 1.09109 12.8363H3.60119C4.06399 12.8363 4.43789 12.4656 4.43789 12.0066C4.43789 11.5477 4.06399 11.1769 3.60119 11.1769H3.55412L4.02477 9.93229H8.1978L8.66844 11.1769H8.62138C8.15858 11.1769 7.78468 11.5477 7.78468 12.0066C7.78468 12.4656 8.15858 12.8363 8.62138 12.8363H11.1315C11.5943 12.8363 11.9682 12.4656 11.9682 12.0066C11.9682 11.5477 11.5943 11.1769 11.1315 11.1769H10.4569L6.89569 1.75949ZM7.57028 8.27284H4.65229L6.11129 4.41202L7.57028 8.27284Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_17_399">\n <rect width="11.7138" height="13.2756" fill="white" transform="translate(0.254395 0.390457)"/>\n </clipPath>\n </defs>\n</svg>',"font-family":'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h8v2H2V6zm0 4h10v2H2v-2zm0 4h6v2H2v-2z" fill="currentColor"/>\n <path d="M4 4h8v1H4V4zm0 2h6v1H4V6zm0 2h8v1H4V8z" fill="currentColor"/>\n </svg>',"line-height":'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h12v2H2V6zm0 4h12v2H2v-2zm0 4h12v2H2v-2z" fill="currentColor"/>\n <path d="M4 3h8v1H4V3zm0 2h8v1H4V5zm0 2h8v1H4V7zm0 2h8v1H4V9z" fill="currentColor"/>\n </svg>',capitalization:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h8v2H2V6zm0 4h10v2H2v-2zm0 4h6v2H2v-2z" fill="currentColor"/>\n <path d="M4 4h8v1H4V4zm0 2h6v1H4V6zm0 2h8v1H4V8z" fill="currentColor"/>\n </svg>',"text-size":'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h8v2H2V6zm0 4h10v2H2v-2zm0 4h6v2H2v-2z" fill="currentColor"/>\n <path d="M4 4h8v1H4V4zm0 2h6v1H4V6zm0 2h8v1H4V8z" fill="currentColor"/>\n </svg>'};class f{static getIcon(t){return g[t]||""}static createIconElement(t,e={}){const n=document.createElement("span");return n.className=`icon icon-${t}`,n.style.display="inline-block",n.style.width=e.width||"16px",n.style.height=e.height||"16px",n.style.verticalAlign="middle",n.innerHTML=this.getIcon(t),n}static hasIcon(t){return t in g}static getIconNames(){return Object.keys(g)}}function C(t=null){let e;return e=t?s.getInstanceById(t):s.getCurrentInstance(),e?e.getPopupContainer():document.body}function b(t,e=null){const n=C(e);t.parentNode&&t.parentNode.removeChild(t),n.appendChild(t)}function y(t){if(!t)return{width:300,height:200};const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{width:e.width,height:e.height};if(t.offsetWidth>0&&t.offsetHeight>0)return{width:t.offsetWidth,height:t.offsetHeight};const n=window.getComputedStyle(t);if("none"===n.display||"hidden"===n.visibility){const e=t.style.display,n=t.style.visibility,i=t.style.position,s=t.style.top,o=t.style.left,r=t.style.zIndex;t.style.display="block",t.style.visibility="visible",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.zIndex="-1",t.offsetHeight;const l=t.getBoundingClientRect(),a=l.width>0?l.width:300,c=l.height>0?l.height:200;return t.style.display=e,t.style.visibility=n,t.style.position=i,t.style.top=s,t.style.left=o,t.style.zIndex=r,{width:a,height:c}}const i=parseInt(n.width),s=parseInt(n.height);return{width:i>0?i:300,height:s>0?s:200}}function v(t,e,n={}){const{offsetX:i=0,offsetY:s=5,preferTop:o=!1,preferLeft:r=!1}=n,l=t.getBoundingClientRect(),a=C();let c,d;if(a.classList.contains("rich-editor-popup-container")){const t=a.getBoundingClientRect();c=l.top-t.top+l.height+s,d=l.left-t.left+i;const{width:n,height:h}=y(e);if(c+h>t.height&&!o){const e=l.top-t.top-h-s;c=e>=0?e:Math.max(s,(t.height-h)/2)}d+n+5>t.width&&!r&&(d=t.width-n-i-15),d<0&&(d=i),c<0&&(c=s)}else{c=l.bottom+window.scrollY+s,d=l.left+window.scrollX+i;const{width:t,height:n}=y(e);if(d+t>window.innerWidth&&!r&&(d=window.innerWidth-t-i),c+n>window.innerHeight+window.scrollY&&!o){const t=l.top+window.scrollY-n-s;c=t>=window.scrollY?t:Math.max(window.scrollY+s,window.scrollY+(window.innerHeight-n)/2)}d<0&&(d=i),c<0&&(c=s)}return{top:c,left:d}}function w(t,e){t.style.position="absolute",t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.zIndex="1000"}class E{constructor(t={}){this.options={colors:["#000000","#333333","#666666","#999999","#cccccc","#eeeeee","#ff0000","#ff6600","#ffcc00","#ffff00","#99ff00","#00ff00","#00ffcc","#00ccff","#0066ff","#0000ff","#6600ff","#cc00ff","#ff00cc","#ff0066","#800000","#ff8000","#808000","#008000","#008080","#0080ff","#004080","#800080","#804080","#ff0080"],customColorEnabled:!0,onColorSelect:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.currentColor="#000000",this.clickOutsideHandler=null,this.createColorPicker()}createColorPicker(){this.popup=document.createElement("div"),this.popup.className="color-picker-popup",this.createColorGrid(),this.options.customColorEnabled&&this.createCustomColorInput(),b(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}createColorGrid(){const t=document.createElement("div");t.className="color-grid",this.options.colors.forEach(e=>{const n=document.createElement("button");n.type="button",n.className="color-button",n.style.backgroundColor=e,n.dataset.color=e,n.title=e,n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor(e),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),t.appendChild(n)}),this.popup.appendChild(t)}createCustomColorInput(){const t=document.createElement("div");t.className="custom-color-container";const e=document.createElement("button");e.type="button",e.className="color-button no-color-button",e.title="No Color",e.style.backgroundColor="transparent";const n=f.createIconElement("no-color",{width:"24",height:"24"});e.appendChild(n),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("transparent"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const i=document.createElement("button");i.type="button",i.className="color-button white-button",i.style.backgroundColor="#ffffff",i.style.border="1px solid #ccc",i.title="White",i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("#ffffff"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const s=document.createElement("button");s.type="button",s.className="color-button black-button",s.style.backgroundColor="#000000",s.title="Black",s.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("#000000"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const o=document.createElement("button");o.type="button",o.className="color-button custom-color-button",o.title="Custom Color",o.style.backgroundColor="transparent",o.style.border="1px solid #ccc",o.style.font="none !important";const r=f.createIconElement("custom-color",{width:"16px",height:"16px"});o.appendChild(r);const l=document.createElement("input");l.type="color",l.className="custom-color-input",l.value=this.currentColor,l.style.visibility="hidden",l.style.pointerEvents="none",l.style.opacity="0",o.addEventListener("click",t=>{l.style.visibility="visible",l.style.pointerEvents="auto",l.style.opacity="1",t.preventDefault(),t.stopPropagation(),l.click()}),l.addEventListener("change",t=>{l.style.visibility="hidden",l.style.pointerEvents="none",l.style.opacity="0",this.selectColor(t.target.value),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),t.appendChild(e),t.appendChild(i),t.appendChild(s),t.appendChild(o),t.appendChild(l),this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||b(this.popup);const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectColor(t){this.currentColor=t,this.options.onColorSelect&&this.options.onColorSelect(t),this.hide()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class T extends r{static formatName="color";static tagName="SPAN";static attribute="color";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("color");e||(e=new E({onColorSelect:t=>{T.applyColorToCurrentSelection(t)},editor:s.getCurrentInstance()}),t.setPopupInstance("color",e)),this.colorPicker=e}static applyColorToCurrentSelection(t){const e=window.getSelection();if(!e||!e.rangeCount||e.isCollapsed)return;a();const n=document.querySelector(".rich-editor-toolbar-btn.color-btn");try{document.execCommand("styleWithCSS",!1,!0),"transparent"===t?(document.execCommand("foreColor",!1,"#2c3e50"),n.classList.remove("active")):(document.execCommand("foreColor",!1,t),n.classList.add("active"))}catch(t){}setTimeout(()=>{const t=s.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}toggle(){this.colorPicker.isVisible?this.colorPicker.hide():this.showColorPicker()}showColorPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("color")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.color-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.color-btn")),n&&this.colorPicker.show(n)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=window.getComputedStyle(e).color;if("rgb(44, 62, 80)"===t)return!1;if(t&&"rgba(0, 0, 0, 0)"!==t)return!0}e=e.parentNode}return!1}}class I extends r{static formatName="background";static tagName="SPAN";static attribute="background-color";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("background");e||(e=new E({onColorSelect:t=>{I.applyBackgroundToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("background",e)),this.colorPicker=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new I;return s.currentInstance=n,i}static applyBackgroundToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount||i.isCollapsed)return;a();const o=n.getModule("toolbar");let r=null;if(o&&(r=o.getButton("background")),!r){const t=o?.getContainer();t&&(r=t.querySelector(".rich-editor-toolbar-btn.background-btn"))}r||(r=n.wrapper.querySelector(".rich-editor-toolbar-btn.background-btn"));try{document.execCommand("styleWithCSS",!1,!0),document.execCommand("backColor",!1,t),r&&r.classList.add("active")}catch(t){}setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}toggle(){this.colorPicker.isVisible?this.colorPicker.hide():this.showColorPicker()}showColorPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("background")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.background-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.background-btn")),n&&this.colorPicker.show(n)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=window.getComputedStyle(e).backgroundColor;if(t&&"rgba(0, 0, 0, 0)"!=t&&"transparent"!==t&&t&&"rgb(255, 255, 255)"!=t&&"transparent"!==t)return!0}e=e.parentNode}return!1}}class x{constructor(t={}){this.options={onLinkSelect:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.urlInput=null,this.textInput=null,this.createPopup()}createPopup(){this.popup=document.createElement("div"),this.popup.className="link-popup";const t=document.createElement("div");t.className="link-popup-content";const e=document.createElement("h2");e.textContent="Upload link",e.className="yjd-input-title";const n=document.createElement("div");n.className="yjd-input-group";const i=document.createElement("p");i.textContent="Your URL",i.className="yjd-input-label",this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your URL",n.appendChild(i),n.appendChild(this.urlInput);const s=document.createElement("div");s.className="yjd-input-group";const o=document.createElement("p");o.textContent="Your display text",o.className="yjd-input-label",this.textInput=document.createElement("input"),this.textInput.type="text",this.textInput.className="yjd-input",this.textInput.placeholder="Please enter display text",s.appendChild(o),s.appendChild(this.textInput);const r=document.createElement("div");r.className="yjd-button-container";const l=document.createElement("button");l.type="button",l.className="yjd-button-confirm",l.textContent="Add link",l.onclick=()=>{this.handleOk(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)};const a=document.createElement("button");a.type="button",a.className="yjd-button-cancel",a.textContent="Cancel",a.onclick=()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)},this.urlInput.onkeydown=t=>{"Enter"===t.key&&this.handleOk(),"Escape"===t.key&&this.hide()},this.textInput.onkeydown=t=>{"Enter"===t.key&&this.handleOk(),"Escape"===t.key&&this.hide()},r.appendChild(a),r.appendChild(l),t.appendChild(e),t.appendChild(n),t.appendChild(s),t.appendChild(r),this.popup.appendChild(t),b(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}handleOk(){const t=this.urlInput.value.trim();if(!t)return alert("Please enter a URL"),void this.urlInput.focus();try{new URL(t)}catch(t){return alert("Please enter a valid URL"),void this.urlInput.focus()}const e=this.textInput.value.trim();this.options.onLinkSelect&&this.options.onLinkSelect({url:t,text:e}),this.hide()}show(t,e=null,n=""){if(!t)return;this.urlInput.value=e?e.url:"",this.textInput.value=n||(e?e.text:"");const i=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,i),this.popup.classList.add("visible"),this.isVisible=!0,setTimeout(()=>this.urlInput.focus(),100),setTimeout(()=>{document.addEventListener("click",this.closeOnClickOutside)},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,document.removeEventListener("click",this.closeOnClickOutside)}closeOnClickOutside=t=>{this.popup.contains(t.target)||this.hide()};destroy(){document.removeEventListener("click",this.closeOnClickOutside),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class L extends r{static formatName="link";static tagName="A";static savedRanges=new Map;constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("link");e||(e=new x({onLinkSelect:t=>{L.insertLink(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("link",e)),this.linkPopup=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new L;return s.currentInstance=n,i}static insertLink(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=L.savedRanges.get(e);if(!i)return;const o=window.getSelection();o.removeAllRanges(),o.addRange(i);const r=o.getRangeAt(0);if(r.collapsed){const e=document.createElement("A");e.href=t.url,e.target="_blank",e.rel="noopener noreferrer",e.textContent=t.text||t.url,r.insertNode(e)}else{const e=r.extractContents(),n=document.createElement("A");for(n.href=t.url,n.target="_blank",n.rel="noopener noreferrer";e.firstChild;)n.appendChild(e.firstChild);r.insertNode(n)}const l=document.createRange();l.setStartAfter(r.endContainer),l.collapse(!0),o.removeAllRanges(),o.addRange(l),setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0),L.savedRanges.delete(e),n&&"function"==typeof n.onContentChange&&n.onContentChange()}toggle(){this.linkPopup.isVisible?this.linkPopup.hide():this.showPopup()}showPopup(){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).cloneRange();L.savedRanges.set(this.editorId,e)}const e=s.getInstanceById(this.editorId);if(!e)return;const n=e.getModule("toolbar");if(!n)return;let i=n.getButton("link");if(!i){const t=n.getContainer();t&&(i=t.querySelector('.rich-editor-toolbar-btn[data-command="link"]'))}if(i||(i=e.wrapper.querySelector('.rich-editor-toolbar-btn[data-command="link"]')),!i)return;const o=this.getCurrentLink();let r="";t&&!t.isCollapsed&&(r=t.toString().trim()),this.linkPopup.show(i,o,r)}getCurrentLink(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"A"===e.tagName)return{url:e.href||"",text:e.textContent||""};e=e.parentNode}return null}isActive(){return null!==this.getCurrentLink()}}class S{constructor(t={}){this.options={maxRows:8,maxCols:8,onTableSelect:null,...t},this.popup=null,this.isVisible=!1,this.selectedRows=1,this.selectedCols=1,this.grid=null,this.sizeDisplay=null,this.createPopup()}createPopup(){this.popup=document.createElement("div"),this.popup.className="table-popup";const t=document.createElement("div");t.className="table-popup-content",this.createSizeDisplay(),this.createGridSelector(),t.appendChild(this.grid),t.appendChild(this.sizeDisplay),this.popup.appendChild(t),b(this.popup)}createSizeDisplay(){this.sizeDisplay=document.createElement("div"),this.sizeDisplay.className="table-size-display"}createGridSelector(){this.grid=document.createElement("div"),this.grid.className="table-grid-selector";for(let t=1;t<=this.options.maxRows;t++)for(let e=1;e<=this.options.maxCols;e++){const n=document.createElement("div");n.className="table-grid-cell",n.dataset.row=t,n.dataset.col=e,n.addEventListener("mouseenter",()=>{this.highlightGrid(t,e)}),n.addEventListener("click",()=>{this.selectSize(t,e),this.handleInsert()}),this.grid.appendChild(n)}this.grid.addEventListener("mouseleave",()=>{this.highlightGrid(1,1)})}highlightGrid(t,e){this.selectedRows=t,this.selectedCols=e,this.updateSizeDisplay(t,e);this.grid.querySelectorAll(".table-grid-cell").forEach(n=>{const i=parseInt(n.dataset.row),s=parseInt(n.dataset.col);i<=t&&s<=e?n.classList.add("highlighted"):n.classList.remove("highlighted")})}updateSizeDisplay(t,e){this.sizeDisplay&&(this.sizeDisplay.textContent=`${t}x${e}`)}selectSize(t,e){this.selectedRows=t,this.selectedCols=e,this.updateSizeDisplay(t,e)}handleInsert(){this.options.onTableSelect&&this.options.onTableSelect({rows:this.selectedRows,cols:this.selectedCols}),this.hide()}show(t){if(!t)return;this.selectedRows=1,this.selectedCols=1,this.highlightGrid(1,1);const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,setTimeout(()=>{document.addEventListener("click",this.closeOnClickOutside)},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,document.removeEventListener("click",this.closeOnClickOutside)}closeOnClickOutside=t=>{this.popup.contains(t.target)||this.hide()};destroy(){document.removeEventListener("click",this.closeOnClickOutside),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class N extends l{static formatName="table";static tagName="TABLE";static savedRanges=new Map;constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("table");e||(e=new S({onTableSelect:t=>{N.insertTable(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("table",e)),this.tablePopup=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new N;return s.currentInstance=n,i}static insertTable(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=N.savedRanges.get(e);if(!i)return;const o=window.getSelection();o.removeAllRanges(),o.addRange(i);const r=o.getRangeAt(0),l=N.createTableElement(t.rows,t.cols);r.collapsed||r.deleteContents(),r.insertNode(l);const a=l.querySelector("td");if(a){const t=document.createRange();t.setStart(a,0),t.collapse(!0),o.removeAllRanges(),o.addRange(t)}N.savedRanges.delete(e),n&&"function"==typeof n.onContentChange&&n.onContentChange()}static createTableElement(t,e){const n=document.createElement("table");n.className="rich-editor-table",n.cellSpacing="0",n.cellPadding="0",n.border="1";const i=document.createElement("tbody");for(let n=0;n<t;n++){const t=document.createElement("tr");for(let n=0;n<e;n++){const e=document.createElement("td");e.innerHTML=" ",e.style.minWidth="50px",e.style.minHeight="24px",e.style.padding="4px 8px",e.style.border="1px solid #ddd",e.style.verticalAlign="top",e.contentEditable="true",t.appendChild(e)}i.appendChild(t)}return n.appendChild(i),n.style.borderCollapse="collapse",n.style.width="100%",n.style.margin="10px 0",n}toggle(){this.tablePopup.isVisible?this.tablePopup.hide():this.showPopup()}showPopup(){const t=window.getSelection();t&&t.rangeCount>0&&N.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange());const e=s.getInstanceById(this.editorId);if(!e)return;const n=e.getModule("toolbar");let i=null;if(n&&(i=n.getButton("table")),!i){const t=n?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.table-btn"))}i||(i=e.wrapper.querySelector(".rich-editor-toolbar-btn.table-btn")),i&&this.tablePopup.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"TABLE"===e.tagName)return!0;e=e.parentNode}return!1}getCurrentTable(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"TABLE"===e.tagName)return e;e=e.parentNode}return null}apply(){this.showPopup()}remove(){const t=this.getCurrentTable();t&&(window.richEditor&&window.richEditor.resizeHandles&&window.richEditor.resizeHandles.hideHandles(),t.parentNode.removeChild(t))}}class H{constructor(t={}){this.options={items:[],onItemSelect:null,displayProperty:"label",valueProperty:"value",className:"custom-select",width:200,height:280,...t},this.popup=null,this.isVisible=!1,this.currentValue=null,this.clickOutsideHandler=null,this.initialized=!1,this.createSelect()}createSelect(){this.popup=document.createElement("div"),this.popup.className=`${this.options.className}-popup`,b(this.popup),this.init()}async init(){await this.createItemList(),this.initialized=!0}async createItemList(){const t=document.createElement("div");t.className="item-list";const e=f.getIcon("check");this.options.items.forEach(n=>{const i=document.createElement("button");i.type="button",i.className="custom-select-item-button",i.dataset.value=this.getItemValue(n);const s=document.createElement("div");s.className="item-text",s.innerHTML=this.getItemDisplay(n);const o=document.createElement("span");o.className="item-checkmark",o.innerHTML=e||"",i.appendChild(s),i.appendChild(o),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectItem(n)}),t.appendChild(i)}),this.popup.appendChild(t)}getItemDisplay(t){return t[this.options.displayProperty]||t.toString()}getItemValue(t){return t[this.options.valueProperty]||t[this.options.displayProperty]||t}async updateItems(t){this.options.items=t;const e=this.popup.querySelector(".item-list");e&&e.remove(),await this.createItemList()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{t.target.closest(".block-toolbar")||this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}setupScrollHandler(){this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=()=>{this.isVisible&&this.updatePosition()},window.addEventListener("scroll",this.scrollHandler)}removeScrollHandler(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null)}async show(t){if(!t)return;this.initialized||await new Promise(t=>{const e=()=>{this.initialized?t():setTimeout(e,10)};e()}),document.body.contains(this.popup)||b(this.popup),this.highlightCurrentItem(this.currentValue);const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside(),this.setupScrollHandler(),this.currentAnchor=t}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.currentAnchor=null}updatePosition(){if(this.isVisible&&this.currentAnchor){const t=v(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});w(this.popup,t)}}setCurrentValue(t){this.currentValue=t,this.highlightCurrentItem(t)}highlightCurrentItem(t){if(this.popup.querySelectorAll(".custom-select-item-button.current").forEach(t=>{t.classList.remove("current")}),null!=t){const e=this.popup.querySelectorAll(".custom-select-item-button");for(const n of e)if(n.dataset.value===t.toString()){n.classList.add("current");break}}}selectItem(t){const e=this.getItemValue(t);this.currentValue=e,this.options.onItemSelect&&this.options.onItemSelect(e,t),this.hide()}getCurrentValue(){return this.currentValue}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class k extends l{static formatName="heading";static tagName="H1";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("heading");if(!e){const n=k.getTagMap(),i=Object.values(n).map(t=>({value:t.tag,label:t.element,title:t.title}));e=new H({items:i,displayProperty:"label",valueProperty:"value",className:"heading-select",onItemSelect:(t,e)=>{k.applyTagToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("heading",e)}this.customSelect=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new k;return s.currentInstance=n,i}static getTagMap(){return{H1:{tag:"H1",element:'<h1 style="margin:0">Heading 1</h1>',title:"Heading 1"},H2:{tag:"H2",element:'<h2 style="margin:0">Heading 2</h2>',title:"Heading 2"},H3:{tag:"H3",element:'<h3 style="margin:0">Heading 3</h3>',title:"Heading 3"},H4:{tag:"H4",element:'<h4 style="margin:0">Heading 4</h4>',title:"Heading 4"},H5:{tag:"H5",element:'<h5 style="margin:0">Heading 5</h5>',title:"Heading 5"},H6:{tag:"H6",element:'<h6 style="margin:0">Heading 6</h6>',title:"Heading 6"},P:{tag:"P",element:'<p style="margin:0">Paragraph</p>',title:"Paragraph"},PRE:{tag:"PRE",element:'<pre style="margin:0">Code</pre>',title:"Preformatted"},BLOCKQUOTE:{tag:"BLOCKQUOTE",element:'<blockquote style="margin:0">Quote</blockquote>',title:"Quote"}}}static getTagDisplayName(t){const e=this.getTagMap();return e[t]?.title||"Paragraph"}updateButtonText(){const t=this.getCurrentTag(),e=k.getTagDisplayName(t||"P"),n=s.getInstanceById(this.editorId);if(!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("heading")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.heading-btn"))}o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.heading-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="P"){return document.createElement(t.toUpperCase())}static applyTagToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount)return;a(),i.getRangeAt(0);const o=k.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}apply(t="P"){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0);n.collapsed;const i=this.getBlockElements(n);if(0===i.length){const s=this.createBlockAtCursor(n,t),o=document.createRange();o.setStart(s,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}else{const r=window.getSelection();if(!r.rangeCount)return;const l=r.getRangeAt(0),a=l.collapsed,c=Array.from(i);function d(t,e){for(;t&&9!==t.nodeType;){const n=e.indexOf(t);if(-1!==n)return n;t=t.parentNode}return-1}function h(t,e,n){const i=document.createRange();return i.setStart(t,0),i.setEnd(e,n),i.toString().length}const u=d(l.startContainer,c),p=d(l.endContainer,c);let m=0,g=0;-1!==u&&(m=h(c[u],l.startContainer,l.startOffset)),a||-1===p||(g=h(c[p],l.endContainer,l.endOffset));const f=c.map(e=>this.convertBlock(e,t)||e);function C(t,e){const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let i,s=e;for(;i=n.nextNode();){const t=i.nodeValue.length;if(s<=t)return{node:i,offset:s};s-=t}return{node:t,offset:t.childNodes.length}}const b=document.createRange();if(a){const y=C(f[-1!==u?u:0],m);y.node.nodeType===Node.TEXT_NODE?b.setStart(y.node,y.offset):b.setStart(y.node,Math.max(0,y.offset)),b.collapse(!0)}else{if(-1===u||-1===p)return r.removeAllRanges(),void r.addRange(l);const v=C(f[u],m),w=C(f[p],g);v.node.nodeType===Node.TEXT_NODE?b.setStart(v.node,v.offset):b.setStart(v.node,Math.min(v.offset,v.node.childNodes.length)),w.node.nodeType===Node.TEXT_NODE?b.setEnd(w.node,w.offset):b.setEnd(w.node,Math.min(w.offset,w.node.childNodes.length))}r.removeAllRanges(),r.addRange(b)}}createBlockAtCursor(t,e){const n=this.constructor.create(e),i=this.getBlockElement(t.startContainer);if(i&&i.style&&i.style.cssText&&(n.style.cssText=i.style.cssText),t.collapsed){n.appendChild(document.createTextNode("")),t.insertNode(n);const e=document.createRange();e.setStart(n,0),e.collapse(!0);const i=window.getSelection();i.removeAllRanges(),i.addRange(e)}else{const e=t.extractContents();n.appendChild(e),t.insertNode(n);const i=document.createRange();i.selectNodeContents(n);const s=window.getSelection();s.removeAllRanges(),s.addRange(i)}}convertBlock(t,e){const n=this.constructor.create(e);for(;t.firstChild;)n.appendChild(t.firstChild);return t.className&&this.shouldPreserveClass(t.className)&&(n.className=t.className),t.style&&t.style.cssText&&(n.style.cssText=t.style.cssText),t.parentNode.replaceChild(n,t),n}setCursorAtStartOfBlock(t){const e=window.getSelection(),n=document.createRange(),i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1).nextNode();i?(n.setStart(i,0),n.collapse(!0)):(n.setStart(t,0),n.collapse(!0)),e.removeAllRanges(),e.addRange(n)}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showTagPicker()}async showTagPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("heading")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.heading-btn"))}if(n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.heading-btn")),!n)return;const i=this.getCurrentTag();i&&this.customSelect.setCurrentValue(i),await this.customSelect.show(n)}isActive(t=null){return this.updateButtonText(),!1}getCurrentTag(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=this.getBlockElement(e.startContainer);if(!n)return null;return["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE"].includes(n.tagName)?n.tagName:null}}class A extends r{static formatName="fontFamily";static tagName="SPAN";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("font-family");if(!e){const n=A.getFontMap(),i=Object.values(n).map(t=>({value:t.font,label:t.element,title:t.title}));e=new H({items:i,displayProperty:"label",valueProperty:"value",className:"font-family-select",onItemSelect:(t,e)=>{A.applyFontFamilyToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("font-family",e)}this.customSelect=e,this.setupSelectionListener()}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new A;return s.currentInstance=n,i}setupSelectionListener(){let t;const e=()=>{clearTimeout(t),t=setTimeout(()=>{const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=s.getInstanceById(this.editorId);n&&(n.editor.contains(e.startContainer)||n.editor.isSameNode(e.startContainer))&&this.updateButtonText()}},50)};document.addEventListener("selectionchange",e),document.addEventListener("mouseup",e),document.addEventListener("keyup",e),this.selectionListener=e}static getFontMap(){return{Arial:{font:"Arial, sans-serif",element:'<span style="font-family: Arial, sans-serif">Arial</span>',title:"Arial"},Helvetica:{font:"Helvetica, Arial, sans-serif",element:'<span style="font-family: Helvetica, Arial, sans-serif">Helvetica</span>',title:"Helvetica"},"Times New Roman":{font:'"Times New Roman", Times, serif',element:"<span style=\"font-family: 'Times New Roman', Times, serif\">Times New Roman</span>",title:"Times New Roman"},Georgia:{font:"Georgia, serif",element:'<span style="font-family: Georgia, serif">Georgia</span>',title:"Georgia"},Verdana:{font:"Verdana, Geneva, sans-serif",element:'<span style="font-family: Verdana, Geneva, sans-serif">Verdana</span>',title:"Verdana"},"Courier New":{font:'"Courier New", Courier, monospace',element:"<span style=\"font-family: 'Courier New', Courier, monospace\">Courier New</span>",title:"Courier New"},"Trebuchet MS":{font:'"Trebuchet MS", Helvetica, sans-serif',element:"<span style=\"font-family: 'Trebuchet MS', Helvetica, sans-serif\">Trebuchet MS</span>",title:"Trebuchet MS"},"Comic Sans MS":{font:'"Comic Sans MS", cursive',element:"<span style=\"font-family: 'Comic Sans MS', cursive\">Comic Sans MS</span>",title:"Comic Sans MS"},Impact:{font:"Impact, Charcoal, sans-serif",element:'<span style="font-family: Impact, Charcoal, sans-serif">Impact</span>',title:"Impact"},"Lucida Console":{font:'"Lucida Console", Monaco, monospace',element:"<span style=\"font-family: 'Lucida Console', Monaco, monospace\">Lucida Console</span>",title:"Lucida Console"}}}static getFontDisplayName(t){const e=this.getFontMap();for(const[n,i]of Object.entries(e))if(i.font===t||n===t)return i.title;return"Arial"}updateButtonText(){const t=this.getCurrentFont(),e=A.getFontDisplayName(t||"Arial, sans-serif"),n=s.getInstanceById(this.editorId);if(!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("font-family")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.font-family-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="Arial, sans-serif"){const e=document.createElement("span");return e.style.fontFamily=t,e}static applyFontFamilyToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount)return;a(),i.getRangeAt(0);const o=A.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}apply(t="Arial, sans-serif"){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0);function i(t){const e=window.getSelection(),n=document.createRange(),i=t.firstChild;n.setStart(i,i.length),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}if(n.collapsed){if(function(t,e){if(!t.rangeCount)return!1;let n=t.getRangeAt(0).startContainer;n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);const i=e.split(",")[0].trim().toLowerCase();for(;n&&n.nodeType===Node.ELEMENT_NODE;){if("SPAN"===n.tagName){const t=n.style.fontFamily;if(t&&t.split(",")[0].trim().toLowerCase()===i)return 1===n.childNodes.length&&n.firstChild.nodeType===Node.TEXT_NODE&&n.firstChild.textContent,!0}n=n.parentNode}return!1}(e,t))return;let s=n.startContainer;n.startOffset,s.nodeType===Node.TEXT_NODE&&(s=s.parentNode);const o=s.closest&&s.closest("span");if(o&&""===o.textContent)return void(o.style.fontFamily=t);if(o&&o.firstChild&&o.firstChild.nodeType===Node.TEXT_NODE){const e=o.firstChild,s=n.startOffset,r=e.data.slice(0,s),l=e.data.slice(s),a=o.parentNode;if(0===s){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("")),a.insertBefore(e,o),i(e)}else if(s===e.data.length){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("")),a.insertBefore(e,o.nextSibling),i(e)}else{const e=document.createElement("span");e.style.fontFamily=o.style.fontFamily,e.appendChild(document.createTextNode(r));const n=document.createElement("span");n.style.fontFamily=t,n.appendChild(document.createTextNode(""));const s=document.createElement("span");s.style.fontFamily=o.style.fontFamily,s.appendChild(document.createTextNode(l)),a.insertBefore(e,o),a.insertBefore(n,o),a.insertBefore(s,o),a.removeChild(o),i(n)}return}const r=document.createElement("span");r.style.fontFamily=t,r.appendChild(document.createTextNode("")),n.insertNode(r),i(r)}else document.execCommand("fontName",!1,t)}async toggle(t=null){this.customSelect.isVisible?this.customSelect.hide():await this.showFontPicker(t)}async showFontPicker(t=null){let e=t;if(!e){const t=s.getInstanceById(this.editorId);if(!t)return;const n=t.getModule("toolbar");if(n&&(e=n.getButton("font-family")),!e){const t=n?.getContainer();t&&(e=t.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}e||(e=t.wrapper.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}if(!e)return;const n=this.getCurrentFont();n&&this.customSelect.setCurrentValue(n),await this.customSelect.show(e)}isActive(t=null){return this.updateButtonText(),!1}getCurrentFont(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);const n=s.getInstanceById(this.editorId);if(!n)return"Arial, sans-serif";if(!n.editor.contains(e)&&!n.editor.isSameNode(e))return"Arial, sans-serif";for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.style.fontFamily)return t.style.fontFamily;const n=window.getComputedStyle(t).fontFamily;if(n&&"initial"!==n&&"inherit"!==n)return n}e=e.parentElement}return"Arial, sans-serif"}setCurrentFont(t){this.currentFont=t}}class B extends r{static formatName="lineHeight";static tagName="SPAN";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("line-height");if(!e){const n=B.getHeightMap(),i=Object.values(n).map(t=>({value:t.height,label:t.element,title:t.title}));e=new H({items:i,displayProperty:"label",valueProperty:"value",className:"line-height-select",onItemSelect:(t,e)=>{B.applyLineHeightToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("line-height",e)}this.customSelect=e,this.setupSelectionListener()}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new B;return s.currentInstance=n,i}setupSelectionListener(){let t;const e=()=>{clearTimeout(t),t=setTimeout(()=>{const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=s.getInstanceById(this.editorId);n&&(n.editor.contains(e.startContainer)||n.editor.isSameNode(e.startContainer))&&this.updateButtonText()}},50)};document.addEventListener("selectionchange",e),document.addEventListener("mouseup",e),document.addEventListener("keyup",e),this.selectionListener=e}static getHeightMap(){return{"1.0":{height:"1",element:"<span>1.0</span>",title:"1.0"},1.2:{height:"1.2",element:"<span>1.2</span>",title:"1.2"},1.5:{height:"1.5",element:"<span>1.5</span>",title:"1.5"},1.8:{height:"1.8",element:"<span>1.8</span>",title:"1.8"},"2.0":{height:"2",element:"<span>2.0</span>",title:"2.0"},2.5:{height:"2.5",element:"<span>2.5</span>",title:"2.5"},"3.0":{height:"3",element:"<span>3.0</span>",title:"3.0"}}}static getHeightDisplayName(t){const e=this.getHeightMap();return e[t]?.title||"line height"}updateButtonText(){const t=this.getCurrentHeight(),e=B.getHeightDisplayName(t||"1.15"),n=s.getInstanceById(this.editorId);if(!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("line-height")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.line-height-btn"))}o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.line-height-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="1.15"){const e=document.createElement("span");return e.style.lineHeight=t,e}static applyLineHeightToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount)return;a(),i.getRangeAt(0);const o=B.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}apply(t="1.15"){const e=window.getSelection();if(!e||!e.rangeCount)return;a();const n=e.getRangeAt(0);if(n.collapsed){let e=n.startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);const i=e.closest("div, p, li, section, article")||e;return i.style.lineHeight=t,void function(t){const e=window.getSelection(),n=document.createRange(),i=t.firstChild;n.setStart(i,i.length),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}(i)}const i=this.getBlockElementsInRange(n);if(i.length>0)i.forEach(e=>{e.style.lineHeight=t});else{const i=this.constructor.create(t);try{const t=n.extractContents();i.appendChild(t),n.insertNode(i);const s=document.createRange();s.selectNodeContents(i),e.removeAllRanges(),e.addRange(s)}catch(t){}}}getBlockElementsInRange(t){const e=[],n=["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI"],i=t.cloneContents(),s=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>n.includes(t.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=s.nextNode();for(;o;){const n=t.commonAncestorContainer.querySelector(`${o.tagName.toLowerCase()}:not([data-processed])`);n&&t.intersectsNode(n)&&(e.push(n),n.setAttribute("data-processed","true")),o=s.nextNode()}if(e.forEach(t=>t.removeAttribute("data-processed")),0===e.length){let i=t.startContainer;for(i.nodeType===Node.TEXT_NODE&&(i=i.parentElement);i&&i!==document.body;){if(i.nodeType===Node.ELEMENT_NODE&&n.includes(i.tagName)){e.push(i);break}i=i.parentElement}}return e}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showHeightPicker()}async showHeightPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("line-height")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.line-height-btn"))}if(n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.line-height-btn")),!n)return;const i=this.getCurrentHeight();i&&this.customSelect.setCurrentValue(i),await this.customSelect.show(n)}isActive(t=null){return this.updateButtonText(),!1}getCurrentHeight(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);const n=s.getInstanceById(this.editorId);if(!n)return"1.15";if(!n.editor.contains(e)&&!n.editor.isSameNode(e))return"1.15";for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.style.lineHeight){const e=t.style.lineHeight;return this.normalizeHeightValue(e)}const n=window.getComputedStyle(t),i=n.lineHeight;if(i&&"normal"!==i&&"initial"!==i&&"inherit"!==i){if(i.endsWith("px")){const t=parseFloat(n.fontSize),e=parseFloat(i);if(t>0){const n=(e/t).toFixed(2);return this.normalizeHeightValue(n)}}return this.normalizeHeightValue(i)}}e=e.parentElement}return"1.15"}normalizeHeightValue(t){if(!t)return"1.15";const e=parseFloat(t);if(isNaN(e))return"1.15";const n=e.toFixed(1);return this.constructor.getHeightMap()[n]?n:t}destroy(){this.selectionListener&&(document.removeEventListener("selectionchange",this.selectionListener),document.removeEventListener("mouseup",this.selectionListener),document.removeEventListener("keyup",this.selectionListener),this.selectionListener=null)}}class P extends r{static formatName="capitalization";static tagName="SPAN";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("capitalization");if(!e){const n=P.getCapitalizationMap(),i=Object.values(n).map(t=>({value:t.style,label:t.element,title:t.title}));e=new H({items:i,displayProperty:"label",valueProperty:"value",className:"capitalization-select",onItemSelect:(t,e)=>{P.applyCapitalizationToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("capitalization",e)}this.customSelect=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new P;return s.currentInstance=n,i}static getCapitalizationMap(){return{capitalize:{style:"capitalize",element:"<span>Capitalize</span>",title:"Capitalize"},uppercase:{style:"uppercase",element:"<span>UPPERCASE</span>",title:"UPPERCASE"},lowercase:{style:"lowercase",element:"<span>lowercase</span>",title:"lowercase"},"small-caps":{style:"small-caps",element:"<span>Small Caps</span>",title:"Small Caps"}}}static getCapitalizationDisplayName(t){const e=this.getCapitalizationMap();return e[t]?.title||"Capitalization"}updateButtonText(){const t=this.getCurrentCapitalization(),e=P.getCapitalizationDisplayName(t||"none"),n=s.getInstanceById(this.editorId);if(!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("capitalization")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.capitalization-btn"))}o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.capitalization-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="none"){const e=document.createElement("span");return"small-caps"===t?e.style.fontVariant="small-caps":e.style.textTransform=t,e}static applyCapitalizationToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount)return;a(),i.getRangeAt(0);const o=P.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}hasCapitalizationStyling(t){if(!t||t.nodeType!==Node.ELEMENT_NODE)return!1;if("small-caps"===t.style.fontVariant)return!0;if(t.style.textTransform&&"none"!==t.style.textTransform)return!0;const e=window.getComputedStyle(t);return"small-caps"===e.fontVariant||!(!e.textTransform||"none"===e.textTransform)}isCapitalizationElement(t){return!(!t||t.nodeType!==Node.ELEMENT_NODE)&&("small-caps"===t.style.fontVariant||!(!t.style.textTransform||"none"===t.style.textTransform))}findAncestorCapitalizationElement(t){let e=t;if(!e)return null;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(this.isCapitalizationElement(e))return e;e=e.parentElement}return null}setElementCapitalizationStyle(t,e){t&&("small-caps"===e?(t.style.fontVariant="small-caps",t.style.textTransform=""):"none"===e?(t.style.fontVariant="",t.style.textTransform=""):(t.style.fontVariant="",t.style.textTransform=e))}apply(t="none"){const e=window.getSelection();if(!e||!e.rangeCount)return;a();const n=e.getRangeAt(0);function i(t,e){switch(e){case"uppercase":return t.toUpperCase();case"lowercase":return t.toLowerCase();case"capitalize":return(t=t.toLowerCase()).replace(/\b\w/g,t=>t.toUpperCase());default:return t}}const s=n.extractContents(),o=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){const e=o.currentNode;e.textContent=i(e.textContent,t)}n.deleteContents(),n.insertNode(s),function(t){if(!t)return;const e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),n=[];for(;e.nextNode();){const t=e.currentNode;t.textContent.trim()||0!==t.childElementCount||n.push(t)}n.forEach(t=>t.remove())}(n.commonAncestorContainer),e.removeAllRanges(),e.addRange(n)}removeExistingCapitalization(t){const e=t.commonAncestorContainer,n=new Set,i=e=>{e&&e.nodeType===Node.ELEMENT_NODE&&this.hasCapitalizationStyling(e)&&t.intersectsNode(e)&&n.add(e)};e&&e.nodeType===Node.ELEMENT_NODE&&i(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>t.intersectsNode(e)&&this.hasCapitalizationStyling(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o;for(;o=s.nextNode();)n.add(o);const r=t=>{let e=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;e&&e!==document.body;)i(e),e=e.parentElement};r(t.startContainer),r(t.endContainer),Array.from(n).forEach(t=>{t.style.textTransform="",t.style.fontVariant="",t.style.cssText.trim()||t.className||this.unwrapElement(t)})}unwrapElement(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showCapitalizationPicker()}async showCapitalizationPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("capitalization")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.capitalization-btn"))}if(n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.capitalization-btn")),!n)return;const i=this.getCurrentCapitalization();i&&this.customSelect.setCurrentValue(i),await this.customSelect.show(n)}isActive(t=null){return this.updateButtonText(),!1}getCurrentCapitalization(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if("small-caps"===t.style.fontVariant)return"small-caps";if(t.style.textTransform&&"none"!==t.style.textTransform)return t.style.textTransform;const n=window.getComputedStyle(t);if("small-caps"===n.fontVariant)return"small-caps";if(n.textTransform&&"none"!==n.textTransform)return n.textTransform}e=e.parentElement}return"none"}setCurrentCapitalization(t){this.currentCapitalization=t}static toggleUppercase(){const t="uppercase"===(new P).getCurrentCapitalization()?"none":"uppercase";P.applyCapitalizationToCurrentSelection(t)}static toggleLowercase(){const t="lowercase"===(new P).getCurrentCapitalization()?"none":"lowercase";P.applyCapitalizationToCurrentSelection(t)}static toggleCapitalize(){const t="capitalize"===(new P).getCurrentCapitalization()?"none":"capitalize";P.applyCapitalizationToCurrentSelection(t)}static toggleSmallCaps(){const t="small-caps"===(new P).getCurrentCapitalization()?"none":"small-caps";P.applyCapitalizationToCurrentSelection(t)}}class M{constructor(t={}){this.options={alignments:[{value:"left",label:"Align Left",icon:"align-left"},{value:"center",label:"Align Center",icon:"align-center"},{value:"right",label:"Align Right",icon:"align-right"},{value:"justify",label:"Justify",icon:"align-justify"}],onAlignSelect:null,...t},this.popup=null,this.isVisible=!1,this.currentAlignment="left",this.clickOutsideHandler=null,this.createAlignPicker()}createAlignPicker(){this.popup=document.createElement("div"),this.popup.className="text-align-picker-popup",this.createAlignmentButtons(),b(this.popup)}async createAlignmentButtons(){const t=document.createElement("div");t.className="align-button-container";for(const e of this.options.alignments){const n=document.createElement("button");n.type="button",n.className="align-button",n.dataset.alignment=e.value,n.title=e.label;const i=f.getIcon(e.icon);i?n.innerHTML=`\n <span class="icon-wrapper">${i}</span>\n <span class="label-text">${e.label}</span>\n `:n.textContent=e.label.charAt(0),n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectAlignment(e.value)}),t.appendChild(n)}this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||b(this.popup),this.updateCurrentAlignment();const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectAlignment(t){this.currentAlignment=t,this.options.onAlignSelect&&this.options.onAlignSelect(t),this.hide()}updateCurrentAlignment(){const t=window.getSelection();if(t&&t.rangeCount)try{const e=t.getRangeAt(0),n=this.getSelectedBlockElements(e),i=n.length>0?n[0]:this.getBlockElement(e.commonAncestorContainer);if(i){const t=window.getComputedStyle(i).textAlign;this.currentAlignment="left"!==t&&"start"!==t&&t?t:"left"}else this.currentAlignment="left";this.popup.querySelectorAll(".align-button").forEach(t=>{t.dataset.alignment===this.currentAlignment?t.classList.add("active"):t.classList.remove("active")}),this.updateToolbarButtonIcon(this.currentAlignment)}catch(t){}}getSelectedBlockElements(t){const e=[],n=this.getBlockElement(t.startContainer),i=this.getBlockElement(t.endContainer);if(n&&e.push(n),n&&i&&n!==i){let t=n;for(;t&&t!==i;)t=t.nextElementSibling,t&&this.getBlockElement(t)&&!e.includes(t)&&e.push(t);i&&!e.includes(i)&&e.push(i)}return e}updateToolbarButtonIcon(t){Promise.resolve().then(function(){return R}).then(e=>{e.default.updateToolbarButtonIcon(t)}).catch(t=>{})}getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class V extends l{static formatName="text-align";static tagName="P";static attribute="style";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("text-align");e||(e=new M({onAlignSelect:t=>{V.applyAlignToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("text-align",e)),this.alignPicker=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new V;return s.currentInstance=n,i}static create(t){const e=document.createElement(this.tagName);return t&&"left"!==t&&(e.style.textAlign=t),e}static applyAlignToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount)return;a();const o=i.getRangeAt(0),r=o.endContainer,l=o.endOffset;try{const n=i.getRangeAt(0),s=V.getSelectedBlockElements(n);if(0===s.length){document.execCommand("formatBlock",!1,"p");const e=i.getRangeAt(0);V.getSelectedBlockElements(e).forEach(e=>{V.applyAlignmentToBlock(e,t)})}else s.forEach(e=>{V.applyAlignmentToBlock(e,t)});V.updateToolbarButtonIcon(t,e),i.removeAllRanges();const o=document.createRange();o.setStart(r,l),o.collapse(!0),i.addRange(o)}catch(t){}setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}static applyAlignmentToBlock(t,e){t.style.textAlign="left"===e?"":e}static getIconNameForAlignment(t){return{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"}[t]||"align-center"}static updateToolbarButtonIcon(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("text-align")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.text-align-btn"))}if(o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.text-align-btn")),!o)return;const r=V.getIconNameForAlignment(t);o.title={left:"Align Left",center:"Align Center",right:"Align Right",justify:"Justify"}[t]||"Text Alignment";const l=f.getIcon(r);if(l){const t=o.querySelector(".icon");t?t.innerHTML=l:o.innerHTML=`<span class="icon">${l}</span>`}}static getSelectedBlockElements(t){const e=[],n=V.getBlockElement(t.startContainer),i=V.getBlockElement(t.endContainer);if(!n||!i)return e;if(n===i)return e.push(n),e;let s=n;for(;s;){const n=document.createRange();if(n.selectNodeContents(s),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0&&e.push(s),s===i)break;s=V.getNextBlockElement(s)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="left"){V.applyAlignToCurrentSelection(t,this.editorId)}remove(){V.applyAlignToCurrentSelection("left",this.editorId)}toggle(){this.alignPicker.isVisible?this.alignPicker.hide():this.showAlignPicker()}showAlignPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("text-align")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.text-align-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.text-align-btn")),n&&this.alignPicker.show(n)}isActive(t=null){const e=V.getCurrentAlignment();return V.updateToolbarButtonIcon(e,this.editorId),!1}static getCurrentAlignment(){const t=window.getSelection();if(!t||!t.rangeCount)return"left";try{const e=t.getRangeAt(0),n=V.getSelectedBlockElements(e),i=n.length>0?n[0]:V.getBlockElement(e.commonAncestorContainer);if(!i)return"left";const s=window.getComputedStyle(i).textAlign;return"left"!==s&&"start"!==s&&s?s:"left"}catch(t){return"left"}}}var R=Object.freeze({__proto__:null,default:V});class O{constructor(t={}){this.options={listTypes:[{value:"bullet",label:"Bullet List",icon:"list-bullet"},{value:"ordered",label:"Numbered List",icon:"list-ordered"},{value:"roman",label:"Roman Numerals List",icon:"list-roman"},{value:"alpha",label:"Alphabetical List",icon:"list-alpha"}],onListSelect:null,...t},this.popup=null,this.isVisible=!1,this.currentListType=null,this.clickOutsideHandler=null,this.createListPicker()}createListPicker(){this.popup=document.createElement("div"),this.popup.className="list-picker-popup",this.createListTypeButtons(),b(this.popup)}async createListTypeButtons(){const t=document.createElement("div");t.className="list-button-container";for(const e of this.options.listTypes){const n=document.createElement("button");n.type="button",n.className="list-button",n.dataset.listType=e.value,n.title=e.label;const i=f.getIcon(e.icon);i?n.innerHTML=i:n.textContent=e.label.charAt(0),n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectListType(e.value)}),t.appendChild(n)}this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||b(this.popup),this.updateCurrentListType();const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectListType(t){this.currentListType=t,this.options.onListSelect&&this.options.onListSelect(t),this.hide()}updateCurrentListType(){try{const t=this.getCurrentListType();this.currentListType=t,this.updateButtonStates(t)}catch(t){}}updateButtonStates(t){this.popup.querySelectorAll(".list-button").forEach(e=>{e.classList.remove("active"),t&&e.dataset.listType===t&&e.classList.add("active")})}updateToolbarButtonIcon(t){const e=document.querySelector(".rich-editor-toolbar-btn.list-btn");if(!e)return;const n={bullet:"list-bullet",ordered:"list-ordered",roman:"list-roman",alpha:"list-alpha"}[t]||"list-bullet";e.title={bullet:"Bullet List",ordered:"Numbered List",roman:"Roman Numerals List",alpha:"Alphabetical List"}[t]||"List";const i=f.getIcon(n);if(i){const t=e.querySelector(".icon");t?t.innerHTML=i:e.innerHTML=`<span class="icon">${i}</span>`}}getParentList(t){let e=t;for(;e&&e!==document.body;){if("UL"===e.tagName||"OL"===e.tagName)return e;e=e.parentElement}return null}getListType(t){if("OL"===t.tagName){const e=t.style.listStyleType;return"upper-roman"===e?"roman":"lower-alpha"===e?"alpha":"ordered"}return"bullet"}getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI","UL","OL"].includes(t))return e}e=e.parentNode}return null}getCurrentListType(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=this.getParentList(e.commonAncestorContainer);return n?this.getListType(n):null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1,this.currentListType=null}}class z extends l{static formatName="list";static tagName="UL";static attribute="class";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("list");e||(e=new O({onListSelect:t=>{z.applyListToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("list",e)),this.listPicker=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new z;return s.currentInstance=n,i}static create(t){let e;switch(t){case"ordered":e=document.createElement("OL"),e.style.listStyleType="decimal";break;case"roman":e=document.createElement("OL"),e.style.listStyleType="upper-roman";break;case"alpha":e=document.createElement("OL"),e.style.listStyleType="lower-alpha";break;default:e=document.createElement("UL"),e.style.listStyleType="disc"}return e}static applyListToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(i&&i.rangeCount){a();try{const n=i.getRangeAt(0),s=z.getSelectedBlockElements(n);0===s.length?z.createListFromSelection(t):z.convertBlocksToList(s,t),z.updateToolbarButtonIcon(t,e)}catch(t){}setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}}static createListFromSelection(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0),i=n.toString()||"List item",s=z.create(t),o=document.createElement("LI");if(n.toString()===n.cloneContents().textContent)o.textContent=i;else{const t=n.cloneContents();o.appendChild(t)}const r=z.getBlockElement(n.startContainer);r&&r.style&&r.style.cssText&&(o.style.cssText=r.style.cssText),s.appendChild(o),n.deleteContents(),n.insertNode(s);const l=document.createRange();l.selectNodeContents(o),l.collapse(!1),e.removeAllRanges(),e.addRange(l)}static convertBlocksToList(t,e){if(0===t.length)return;const n=z.getParentList(t[0]);if(n)return void z.toggleOrChangeListType(n,e);const i=z.create(e),s=t[0];s.parentNode.insertBefore(i,s);let o=null;if(t.forEach((t,e)=>{const n=document.createElement("LI");n.innerHTML=t.innerHTML||t.textContent||"",t.style&&t.style.cssText&&(n.style.cssText=t.style.cssText),i.appendChild(n),t.remove(),0===e&&(o=n)}),o){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(o),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static toggleOrChangeListType(t,e){z.getListType(t)===e?z.removeListFormatting(t):z.changeListType(t,e)}static getListType(t){if("OL"===t.tagName){const e=t.style.listStyleType;return"upper-roman"===e?"roman":"lower-alpha"===e?"alpha":"ordered"}return"bullet"}static changeListType(t,e){const n=z.create(e);if(Array.from(t.children).forEach(t=>{const e=document.createElement("LI");e.innerHTML=t.innerHTML||t.textContent||"",t.style&&t.style.cssText&&(e.style.cssText=t.style.cssText),n.appendChild(e)}),t.parentNode.replaceChild(n,t),n.firstElementChild){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(n.firstElementChild),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static removeListFormatting(t){const e=t.parentNode;let n=null;if(Array.from(t.children).forEach((i,s)=>{const o=document.createElement("P");o.innerHTML=i.innerHTML||i.textContent||"",i.style&&i.style.cssText&&(o.style.cssText=i.style.cssText),e.insertBefore(o,t),0===s&&(n=o)}),t.remove(),n){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(n),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static getParentList(t){let e=t;for(;e&&e!==document.body;){if("UL"===e.tagName||"OL"===e.tagName)return e;e=e.parentElement}return null}static getIconNameForListType(t){return{bullet:"list-bullet",ordered:"list-ordered",roman:"list-roman",alpha:"list-alpha"}[t]||"list-bullet"}static updateToolbarButtonIcon(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("list")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.list-btn"))}if(o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.list-btn")),!o)return;const r=z.getIconNameForListType(t);o.title={bullet:"Bullet List",ordered:"Numbered List",roman:"Roman Numerals List",alpha:"Alphabetical List"}[t]||"List";const l=f.getIcon(r);if(l){const t=o.querySelector(".icon");t?t.innerHTML=l:o.innerHTML=`<span class="icon">${l}</span>`}}static getSelectedBlockElements(t){const e=[],n=t.startContainer,i=t.endContainer,s=z.getBlockElement(n);if(s&&e.push(s),n!==i){let t=s;for(;t&&t!==i;){const n=z.getNextBlockElement(t);if(!n||e.includes(n))break;e.push(n),t=n}const n=z.getBlockElement(i);n&&!e.includes(n)&&e.push(n)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="bullet"){z.applyListToCurrentSelection(t,this.editorId)}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=z.getParentList(e.commonAncestorContainer);n&&z.removeListFormatting(n)}toggle(){this.listPicker.isVisible?this.listPicker.hide():this.showListPicker()}showListPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("list")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.list-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.list-btn")),n&&this.listPicker.show(n)}isActive(t=null){const e=z.getCurrentListType();return e?z.updateToolbarButtonIcon(e,this.editorId):z.updateToolbarButtonIcon("bullet",this.editorId),!1}static getCurrentListType(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=z.getParentList(e.commonAncestorContainer);return n?z.getListType(n):null}getCurrentListType(){return z.getCurrentListType()}}class F extends l{static formatName="indent";static tagName="DIV";static attribute="style";constructor(){super()}static create(t){const e=document.createElement("DIV");return t&&(e.style.paddingLeft=t),e}static applyIndentToCurrentSelection(t){const e=window.getSelection();if(e&&e.rangeCount){a();try{const n=e.getRangeAt(0),i=F.getSelectedBlockElements(n);if(0===i.length){const i=document.createElement("DIV");i.style.paddingLeft="increase"===t?"20px":"0px";const s=n.toString()||"";s?(i.textContent=s,n.deleteContents(),n.insertNode(i)):(n.insertNode(i),i.innerHTML="<br>");const o=document.createRange();o.selectNodeContents(i),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else i.forEach(e=>{F.applyIndentToBlock(e,t)})}catch(t){}setTimeout(()=>{const t=s.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}}static applyIndentToBlock(t,e){if(!t||!t.style)return;const n=parseInt(t.style.paddingLeft)||0;let i;i="increase"===e?n+20:Math.max(0,n-20),t.style.paddingLeft=0===i?"":i+"px"}static getSelectedBlockElements(t){const e=[],n=t.startContainer,i=t.endContainer,s=F.getBlockElement(n);if(s&&e.push(s),n!==i){let t=s;for(;t&&t!==i;){const n=F.getNextBlockElement(t);if(!n||e.includes(n))break;e.push(n),t=n}const n=F.getBlockElement(i);n&&!e.includes(n)&&e.push(n)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="increase"){F.applyIndentToCurrentSelection(t)}remove(){F.applyIndentToCurrentSelection("remove")}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0),n=F.getBlockElement(e.commonAncestorContainer);if(!n)return!1;return(parseInt(n.style.paddingLeft)||0)>0}static getCurrentIndentLevel(){const t=window.getSelection();if(!t||!t.rangeCount)return 0;const e=t.getRangeAt(0),n=F.getBlockElement(e.commonAncestorContainer);return n&&parseInt(n.style.paddingLeft)||0}getCurrentIndentLevel(){return F.getCurrentIndentLevel()}}class _ extends F{static formatName="indent-increase";apply(){F.applyIndentToCurrentSelection("increase")}toggle(){this.apply()}isActive(){return!1}}class D extends F{static formatName="indent-decrease";apply(){F.applyIndentToCurrentSelection("decrease")}toggle(){this.apply()}isActive(){return!1}}class j{constructor(t={}){this.options={emojis:["😀","😁","😂","🤣","😃","😄","😅","😆","😉","😊","😋","😎","😍","🥰","😘","😗","😙","😚","🙂","🤗","😳","🥺","😦","😧","😨","😰","😥","😢","😭","😱","🤬","😈","👿","💀","☠️","💩","🤡","👹","👺","👻"],onEmojiSelect:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.createEmojiPicker()}detectOS(){const t=navigator.platform.toLowerCase();return t.includes("mac")?"mac":(t.includes("win"),"windows")}getEmojiShortcutMessage(){return"mac"===this.detectOS()?'<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">⌘</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">CTRL</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">SPACE</span></div>':'<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">WIN</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">.</span></div>'}createEmojiPicker(){this.popup=document.createElement("div"),this.popup.className="emoji-picker-popup",this.createEmojiGrid();const t=document.createElement("div");t.className="emoji-text-message",t.innerHTML=this.getEmojiShortcutMessage(),this.popup.appendChild(t),b(this.popup)}createEmojiGrid(){const t=document.createElement("div");t.className="emoji-grid",this.options.emojis.forEach(e=>{const n=document.createElement("button");n.type="button",n.className="emoji-button",n.textContent=e,n.title=e,n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectEmoji(e)}),t.appendChild(n)}),this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||b(this.popup);const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectEmoji(t){this.options.onEmojiSelect&&this.options.onEmojiSelect(t),this.hide()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class Z extends r{static formatName="emoji";static tagName="SPAN";static className="emoji";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("emoji");e||(e=new j({onEmojiSelect:t=>{Z.insertEmojiAtCurrentPosition(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("emoji",e)),this.emojiPicker=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new Z;return s.currentInstance=n,i}static create(t){const e=document.createElement("SPAN");return e.className="emoji",e.textContent=t,e.setAttribute("data-emoji",t),e}static insertEmojiAtCurrentPosition(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(i&&i.rangeCount)try{const e=i.getRangeAt(0);let s=e.startContainer,o=null;for(s.nodeType===Node.TEXT_NODE&&(s=s.parentNode);s&&s!==n.element;){if(s.classList&&s.classList.contains("emoji")){o=s;break}s=s.parentNode}o&&(e.setStartAfter(o),e.collapse(!0),i.removeAllRanges(),i.addRange(e));const r=Z.create(t);e.deleteContents(),e.insertNode(r);const l=document.createTextNode("");e.setStartAfter(r),e.insertNode(l),e.setStartAfter(l),e.collapse(!0),i.removeAllRanges(),i.addRange(e),n&&"function"==typeof n.onContentChange&&n.onContentChange()}catch(t){}}apply(t){t?Z.insertEmojiAtCurrentPosition(t,this.editorId):this.showEmojiPicker()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getEmojiElement(e);if(n){const t=document.createTextNode(n.textContent);n.parentNode.replaceChild(t,n)}}toggle(){this.emojiPicker.isVisible?this.emojiPicker.hide():this.showEmojiPicker()}showEmojiPicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("emoji")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.emoji-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.emoji-btn")),n&&this.emojiPicker.show(n)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getEmojiElement(e)}getEmojiElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),e.classList&&e.classList.contains("emoji"))return e;const n=t.cloneContents().querySelector(".emoji");return n||null}}class U{constructor(t={}){this.options={onImageInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedImageSrc=null,this.savedSelection=null,this.resizeHandler=null,this.createImagePopup()}createImagePopup(){this.popup=document.createElement("div"),this.popup.className="image-popup";const t=document.createElement("div");t.className="image-popup-content";const e=document.createElement("h3");e.textContent="Upload image",e.className="yjd-input-title",t.appendChild(e);const n=document.createElement("div");n.className="image-input-container";const i=document.createElement("p");i.textContent="Your image url",i.className="yjd-input-label";const s=document.createElement("div");s.className="yjd-input-upload-group",this.inputGroup=s,this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your image URL",this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="image/*",this.fileInput.className="image-input-hidden",this.fileInput.addEventListener("change",t=>this.handleFileSelect(t));const o=document.createElement("button");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 17 17" fill="none">\n <g clip-path="url(#clip0_243_650)">\n <path d="M9.45721 4.06101V11.4287C9.45721 11.966 9.02311 12.4001 8.48578 12.4001C7.94846 12.4001 7.51436 11.966 7.51436 11.4287V4.06101L5.28614 6.28923C4.90668 6.66869 4.29043 6.66869 3.91096 6.28923C3.5315 5.90976 3.5315 5.29351 3.91096 4.91405L7.79668 1.02833C8.17614 0.64887 8.79239 0.64887 9.17186 1.02833L13.0576 4.91405C13.437 5.29351 13.437 5.90976 13.0576 6.28923C12.6781 6.66869 12.0619 6.66869 11.6824 6.28923L9.45721 4.06101ZM2.65721 11.4287H6.54293C6.54293 12.5003 7.41418 13.3715 8.48578 13.3715C9.55739 13.3715 10.4286 12.5003 10.4286 11.4287H14.3144C15.386 11.4287 16.2572 12.2999 16.2572 13.3715V14.343C16.2572 15.4146 15.386 16.2858 14.3144 16.2858H2.65721C1.58561 16.2858 0.714355 15.4146 0.714355 14.343V13.3715C0.714355 12.2999 1.58561 11.4287 2.65721 11.4287ZM13.8286 14.5858C14.0219 14.5858 14.2072 14.5091 14.3438 14.3724C14.4805 14.2358 14.5572 14.0505 14.5572 13.8573C14.5572 13.664 14.4805 13.4787 14.3438 13.3421C14.2072 13.2055 14.0219 13.1287 13.8286 13.1287C13.6354 13.1287 13.4501 13.2055 13.3135 13.3421C13.1768 13.4787 13.1001 13.664 13.1001 13.8573C13.1001 14.0505 13.1768 14.2358 13.3135 14.3724C13.4501 14.5091 13.6354 14.5858 13.8286 14.5858Z" fill="#252424"/>\n </g>\n <defs>\n <clipPath id="clip0_243_650">\n <rect width="15.5429" height="15.5429" fill="white" transform="translate(0.714355 0.742859)"/>\n </clipPath>\n </defs>\n </svg>',o.className="yjd-custom-upload-button",this.customButton=o,o.addEventListener("click",()=>this.fileInput.click()),this.createPreviewContainer(),s.appendChild(this.urlInput),s.appendChild(this.fileInput),s.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(this.previewContainer),t.appendChild(n),this.urlInput.addEventListener("input",()=>{this.updateInsertButton();const t=this.urlInput.value.trim();t&&this.isValidImageUrl(t)?this.showPreview(t):this.removePreview(),this.urlInput.value.trim()?this.customButton.style.display="none":this.customButton.style.display="flex"});const r=document.createElement("div");r.className="yjd-button-container";const l=document.createElement("button");l.type="button",l.className="image-button yjd-button-cancel",l.textContent="Cancel",l.addEventListener("click",()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="image-button yjd-button-confirm button-disable",this.insertButton.textContent="Add image",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>{this.insertImage(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),r.appendChild(l),r.appendChild(this.insertButton),t.appendChild(r),this.popup.appendChild(t),b(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}async handleFileSelect(t){const e=t.target.files[0];if(e)try{const{default:t}=await Promise.resolve().then(function(){return W});this.selectedImageSrc=await t.handleFileUpload(e),this.urlInput.value="",this.showPreview(this.selectedImageSrc),this.updateInsertButton()}catch(t){alert(t.message)}}updateInsertButton(){const t=this.selectedImageSrc||this.urlInput.value.trim();this.insertButton.disabled=!t,this.insertButton.classList.toggle("button-disable",!t)}showPreview(t){t&&(this.imagePreview.src=t,this.previewContainer.style.display="block",this.selectedImageSrc=t,this.toggleInputGroup(!1),this.recalculatePosition())}removePreview(){this.selectedImageSrc=null,this.previewContainer.style.display="none",this.imagePreview.src="",this.toggleInputGroup(!0),this.fileInput&&(this.fileInput.value=""),this.updateInsertButton(),this.recalculatePosition()}toggleInputGroup(t){this.inputGroup&&(t?(this.inputGroup.style.display="flex",this.inputGroup.style.visibility="visible",this.customButton&&(this.customButton.style.pointerEvents="auto")):(this.inputGroup.style.display="none",this.inputGroup.style.visibility="hidden"))}createPreviewContainer(){this.previewContainer=document.createElement("div"),this.previewContainer.className="image-preview-container",this.previewContainer.style.cssText="display: none; position: relative;",this.imagePreview=document.createElement("img"),this.imagePreview.className="image-preview",this.imagePreview.style.cssText="max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;",this.removeButton=document.createElement("button"),this.removeButton.className="image-remove-button",this.removeButton.innerHTML="×",this.removeButton.style.cssText="\n position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.7);\n color: white; border: none; border-radius: 50%; width: 24px; height: 24px;\n cursor: pointer; font-size: 16px; font-weight: bold;\n ",this.removeButton.addEventListener("click",()=>this.removePreview()),this.previewContainer.appendChild(this.imagePreview),this.previewContainer.appendChild(this.removeButton)}isValidImageUrl(t){try{const e=new URL(t),n=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"],i=["imgur.com","images.unsplash.com","picsum.photos","via.placeholder.com"],s=e.pathname.toLowerCase(),o=n.some(t=>s.endsWith(t)),r=i.some(t=>e.hostname.includes(t));return o||r}catch{return!1}}async insertImage(){let t=this.selectedImageSrc||this.urlInput.value.trim();if(t){try{const{default:e}=await Promise.resolve().then(function(){return W});if(!await e.validateImageUrl(t))return void alert("Invalid image URL. Please check the URL and try again.")}catch(t){return void alert("Error validating image URL.")}this.restoreSelection(),this.options.onImageInsert&&this.options.onImageInsert(t,""),this.hide(),this.reset()}}reset(){this.fileInput.value="",this.urlInput.value="",this.selectedImageSrc=null,this.previewContainer.style.display="none",this.imagePreview.src="",this.toggleInputGroup(!0),this.updateInsertButton(),this.customButton.style.display="block"}saveSelection(){const t=window.getSelection();t&&t.rangeCount>0&&(this.savedSelection=t.getRangeAt(0).cloneRange())}restoreSelection(){if(this.savedSelection){const t=window.getSelection();t.removeAllRanges(),t.addRange(this.savedSelection)}}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}setupResizeHandler(){this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=()=>{this.isVisible&&this.recalculatePosition()},window.addEventListener("resize",this.resizeHandler)}removeResizeHandler(){this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;this.saveSelection(),this.reset(),this.currentAnchor=t;const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}recalculatePosition(){this.currentAnchor&&this.isVisible&&setTimeout(()=>{const t=v(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});w(this.popup,t)},10)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.savedSelection=null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class q extends r{static formatName="image";static tagName="IMG";static className="inserted-image";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("image");e||(e=new U({onImageInsert:(t,e)=>{q.insertImageAtCurrentPosition(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("image",e)),this.imagePopup=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new q;return s.currentInstance=n,i}static create(t,e=""){const n=document.createElement("IMG");return n.src=t,n.alt=e||"Inserted image",n.className="inserted-image",n.style.maxWidth="100%",n.style.height="auto",n.setAttribute("contenteditable","false"),n}static insertImageAtCurrentPosition(t,e="",n=null){let i=null;if(i=n?s.getInstanceById(n):s.getCurrentInstance(),!i)return;const o=window.getSelection();if(o&&o.rangeCount){try{const n=o.getRangeAt(0),s=q.create(t,e);n.deleteContents(),n.insertNode(s);const r=document.createTextNode(" ");n.setStartAfter(s),n.insertNode(r),n.setStartAfter(r),n.collapse(!0),o.removeAllRanges(),o.addRange(n),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}setTimeout(()=>{const t=s.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}}apply(t,e){t?q.insertImageAtCurrentPosition(t,e,this.editorId):this.showImagePopup()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getImageElement(e);n&&n.remove()}toggle(){this.imagePopup.isVisible?this.imagePopup.hide():this.showImagePopup()}showImagePopup(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("image")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.image-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.image-btn")),n&&this.imagePopup.show(n)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getImageElement(e)}getImageElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),"IMG"===e.tagName&&e.classList&&e.classList.contains("inserted-image"))return e;const n=t.cloneContents().querySelector(".inserted-image");return n||null}static async handleFileUpload(t){return new Promise((e,n)=>{if(!t||!t.type.startsWith("image/"))return void n(new Error("Please select a valid image file"));const i=new FileReader;i.onload=t=>{e(t.target.result)},i.onerror=()=>{n(new Error("Failed to read file"))},i.readAsDataURL(t)})}static validateImageUrl(t){return new Promise(e=>{const n=["jpg","jpeg","png","gif","bmp","webp","svg"].some(e=>t.toLowerCase().includes(`.${e}`));if(t.startsWith("data:image/"))return void e(!0);if(!/^https?:\/\//.test(t))return void e(!1);if(n)return void e(!0);const i=new q;i.onload=()=>{e(!0)},i.onerror=()=>{t.includes("imgur.com")||t.includes("drive.google.com")||n?e(!0):e(!1)},setTimeout(()=>{n||t.includes("imgur.com")||t.includes("drive.google.com")?e(!0):e(!1)},5e3),i.src=t})}}var W=Object.freeze({__proto__:null,default:q});class X{constructor(t={}){this.options={onVideoInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedVideoSrc=null,this.savedSelection=null,this.createVideoPopup()}createVideoPopup(){this.popup=document.createElement("div"),this.popup.className="video-popup";const t=document.createElement("div");t.className="video-popup-content";const e=document.createElement("h3");e.textContent="Upload video",e.className="yjd-input-title",t.appendChild(e);const n=document.createElement("div");n.className="video-input-container";const i=document.createElement("p");i.textContent="Your video url",i.className="yjd-input-label";const s=document.createElement("div");s.className="yjd-input-upload-group",this.inputGroup=s,this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your video URL",this.urlInput.addEventListener("input",()=>{this.updateInsertButton();const t=this.urlInput.value.trim();t&&this.isValidVideoUrl(t)?this.showPreview(t):this.removePreview(),this.urlInput.value.trim()?this.customButton.style.display="none":this.customButton.style.display="block"}),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="video/*",this.fileInput.className="image-input-hidden",this.fileInput.addEventListener("change",t=>this.handleFileSelect(t));const o=document.createElement("button");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 17 17" fill="none">\n <g clip-path="url(#clip0_243_650)">\n <path d="M9.45721 4.06101V11.4287C9.45721 11.966 9.02311 12.4001 8.48578 12.4001C7.94846 12.4001 7.51436 11.966 7.51436 11.4287V4.06101L5.28614 6.28923C4.90668 6.66869 4.29043 6.66869 3.91096 6.28923C3.5315 5.90976 3.5315 5.29351 3.91096 4.91405L7.79668 1.02833C8.17614 0.64887 8.79239 0.64887 9.17186 1.02833L13.0576 4.91405C13.437 5.29351 13.437 5.90976 13.0576 6.28923C12.6781 6.66869 12.0619 6.66869 11.6824 6.28923L9.45721 4.06101ZM2.65721 11.4287H6.54293C6.54293 12.5003 7.41418 13.3715 8.48578 13.3715C9.55739 13.3715 10.4286 12.5003 10.4286 11.4287H14.3144C15.386 11.4287 16.2572 12.2999 16.2572 13.3715V14.343C16.2572 15.4146 15.386 16.2858 14.3144 16.2858H2.65721C1.58561 16.2858 0.714355 15.4146 0.714355 14.343V13.3715C0.714355 12.2999 1.58561 11.4287 2.65721 11.4287ZM13.8286 14.5858C14.0219 14.5858 14.2072 14.5091 14.3438 14.3724C14.4805 14.2358 14.5572 14.0505 14.5572 13.8573C14.5572 13.664 14.4805 13.4787 14.3438 13.3421C14.2072 13.2055 14.0219 13.1287 13.8286 13.1287C13.6354 13.1287 13.4501 13.2055 13.3135 13.3421C13.1768 13.4787 13.1001 13.664 13.1001 13.8573C13.1001 14.0505 13.1768 14.2358 13.3135 14.3724C13.4501 14.5091 13.6354 14.5858 13.8286 14.5858Z" fill="#252424"/>\n </g>\n <defs>\n <clipPath id="clip0_243_650">\n <rect width="15.5429" height="15.5429" fill="white" transform="translate(0.714355 0.742859)"/>\n </clipPath>\n </defs>\n </svg>',o.className="yjd-custom-upload-button",this.customButton=o,o.addEventListener("click",()=>this.fileInput.click()),this.createPreviewContainer(),s.appendChild(this.urlInput),s.appendChild(this.fileInput),s.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(this.previewContainer),t.appendChild(n);const r=document.createElement("div");r.className="yjd-button-container";const l=document.createElement("button");l.type="button",l.className="image-button yjd-button-cancel",l.textContent="Cancel",l.addEventListener("click",()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="image-button yjd-button-confirm button-disable",this.insertButton.textContent="Add video",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>{this.insertVideo(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),r.appendChild(l),r.appendChild(this.insertButton),t.appendChild(r),this.popup.appendChild(t),b(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}async handleFileSelect(t){const e=t.target.files[0];if(e)try{const{default:t}=await Promise.resolve().then(function(){return Y});this.selectedVideoSrc=await t.handleFileUpload(e),this.urlInput.value="",this.showPreview(this.selectedVideoSrc),this.updateInsertButton()}catch(t){alert(t.message)}}updateInsertButton(){const t=this.selectedVideoSrc||this.urlInput.value.trim();this.insertButton.disabled=!t,this.insertButton.classList.toggle("button-disable",!t)}showPreview(t){t&&(this.videoPreview.src=t,this.previewContainer.style.display="block",this.selectedVideoSrc=t,this.toggleInputGroup(!1),this.recalculatePosition())}removePreview(){this.selectedVideoSrc=null,this.previewContainer.style.display="none",this.videoPreview.src="",this.toggleInputGroup(!0),this.fileInput&&(this.fileInput.value=""),this.updateInsertButton(),this.recalculatePosition()}toggleInputGroup(t){this.inputGroup&&(t?(this.inputGroup.style.display="flex",this.inputGroup.style.visibility="visible",this.customButton&&(this.customButton.style.pointerEvents="auto")):(this.inputGroup.style.display="none",this.inputGroup.style.visibility="hidden"))}createPreviewContainer(){this.previewContainer=document.createElement("div"),this.previewContainer.className="video-preview-container",this.previewContainer.style.cssText="display: none; position: relative;",this.videoPreview=document.createElement("video"),this.videoPreview.className="video-preview",this.videoPreview.style.cssText="max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;",this.videoPreview.controls=!0,this.videoPreview.muted=!0,this.removeButton=document.createElement("button"),this.removeButton.className="video-remove-button",this.removeButton.innerHTML="×",this.removeButton.style.cssText="\n position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.7);\n color: white; border: none; border-radius: 50%; width: 24px; height: 24px;\n cursor: pointer; font-size: 16px; font-weight: bold;\n ",this.removeButton.addEventListener("click",()=>this.removePreview()),this.previewContainer.appendChild(this.videoPreview),this.previewContainer.appendChild(this.removeButton)}isValidVideoUrl(t){try{const e=new URL(t),n=[".mp4",".webm",".ogg",".mov",".avi",".mkv"],i=["youtube.com","youtu.be","vimeo.com","dailymotion.com"],s=e.pathname.toLowerCase(),o=n.some(t=>s.endsWith(t)),r=i.some(t=>e.hostname.includes(t));return o||r}catch{return!1}}async insertVideo(){let t=this.selectedVideoSrc||this.urlInput.value.trim();if(t){try{const{default:e}=await Promise.resolve().then(function(){return Y});if(!await e.validateVideoUrl(t))return void alert("Invalid video URL. Please check the URL and try again.")}catch(t){return void alert("Error validating video URL.")}this.restoreSelection(),this.options.onVideoInsert&&this.options.onVideoInsert(t),this.hide(),this.reset()}}reset(){this.fileInput.value="",this.urlInput.value="",this.selectedVideoSrc=null,this.previewContainer.style.display="none",this.videoPreview.src="",this.toggleInputGroup(!0),this.updateInsertButton(),this.customButton.style.display="block"}saveSelection(){const t=window.getSelection();t&&t.rangeCount>0&&(this.savedSelection=t.getRangeAt(0).cloneRange())}restoreSelection(){if(this.savedSelection){const t=window.getSelection();t.removeAllRanges(),t.addRange(this.savedSelection)}}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;this.saveSelection(),this.reset(),this.currentAnchor=t;const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}recalculatePosition(){this.currentAnchor&&this.isVisible&&setTimeout(()=>{const t=v(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});w(this.popup,t)},10)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.savedSelection=null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class G extends r{static formatName="video";static tagName="VIDEO";static className="inserted-video";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("video");e||(e=new X({onVideoInsert:t=>{G.insertVideoAtCurrentPosition(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("video",e)),this.videoPopup=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new G;return s.currentInstance=n,i}static create(t){if(G.isYouTubeUrl(t))return G.createYouTubeEmbed(t);const e=document.createElement("VIDEO");return e.src=t,e.className="inserted-video",e.controls=!0,e.style.maxWidth="100%",e.style.height="auto",e.setAttribute("contenteditable","false"),e}static createYouTubeEmbed(t){const e=G.getYouTubeVideoId(t);if(!e)throw new Error("Invalid YouTube URL");const n=document.createElement("IFRAME");return n.src=`https://www.youtube.com/embed/${e}`,n.className="inserted-video youtube-video",n.width="560",n.height="315",n.style.maxWidth="100%",n.style.width="560px",n.style.height="315px",n.style.position="relative",n.style.display="block",n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),n.setAttribute("contenteditable","false"),n}static insertVideoAtCurrentPosition(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(i&&i.rangeCount)try{const e=i.getRangeAt(0),s=G.create(t);e.deleteContents(),e.insertNode(s);const o=document.createTextNode(" ");e.setStartAfter(s),e.insertNode(o),e.setStartAfter(o),e.collapse(!0),i.removeAllRanges(),i.addRange(e),n&&"function"==typeof n.onContentChange&&n.onContentChange()}catch(t){}}apply(t){t?G.insertVideoAtCurrentPosition(t,this.editorId):this.showVideoPopup()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getVideoElement(e);n&&n.remove()}toggle(){this.videoPopup.isVisible?this.videoPopup.hide():this.showVideoPopup()}showVideoPopup(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("video")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.video-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.video-btn")),n&&this.videoPopup.show(n)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getVideoElement(e)}getVideoElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),("VIDEO"===e.tagName||"IFRAME"===e.tagName)&&e.classList&&e.classList.contains("inserted-video"))return e;const n=t.cloneContents().querySelector(".inserted-video");return n||null}static async handleFileUpload(t){return new Promise((e,n)=>{if(!t||!t.type.startsWith("video/"))return void n(new Error("Please select a valid video file"));const i=new FileReader;i.onload=t=>{e(t.target.result)},i.onerror=()=>{n(new Error("Failed to read file"))},i.readAsDataURL(t)})}static validateVideoUrl(t){return new Promise(e=>{if(G.isYouTubeUrl(t))return void e(!0);if(["mp4","webm","ogg","mov","avi","mkv"].some(e=>t.toLowerCase().includes(`.${e}`)))return void e(!0);const n=document.createElement("video");n.onloadedmetadata=()=>{e(!0)},n.onerror=()=>{e(!1)},setTimeout(()=>{e(!1)},5e3),n.src=t})}static isYouTubeUrl(t){return/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.test(t)}static getYouTubeVideoId(t){const e=t.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return e?e[1]:null}}var Y=Object.freeze({__proto__:null,default:G});class ${constructor(t={}){this.options={onTagInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedTagType="mention",this.createTagPopup()}createTagPopup(){this.popup=document.createElement("div"),this.popup.className="tag-popup";const t=document.createElement("div");t.className="tag-popup-content";const e=document.createElement("h3");e.textContent="Insert tags",e.className="yjd-input-title",t.appendChild(e);const n=document.createElement("div");n.className="yjd-input-group";const i=document.createElement("label");i.textContent="Type",i.className="yjd-input-label",this.typeSelect=document.createElement("select"),this.typeSelect.className="yjd-select-input",this.typeSelect.innerHTML='\n <option value="mention">Mention</option>\n <option value="hashtag">Hashtag</option>\n <option value="custom">Custom</option>\n ',this.typeSelect.addEventListener("change",()=>this.updateSuggestions()),n.appendChild(i),n.appendChild(this.typeSelect),t.appendChild(n);const s=document.createElement("div");s.className="yjd-input-group";const o=document.createElement("label");o.textContent="Content",o.className="yjd-input-label",this.contentInput=document.createElement("input"),this.contentInput.type="text",this.contentInput.className="yjd-input",this.contentInput.placeholder="Please enter tag content",this.contentInput.addEventListener("input",()=>this.updateInsertButton()),this.contentInput.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTag())}),s.appendChild(o),s.appendChild(this.contentInput),t.appendChild(s);const r=document.createElement("div");r.className="yjd-input-group",this.suggestionsContainer=document.createElement("div"),this.suggestionsContainer.className="tag-suggestions-container";const l=document.createElement("label");l.textContent="Suggestions",l.className="yjd-input-label",this.suggestionsList=document.createElement("div"),this.suggestionsList.className="yjd-suggestions-list",this.suggestionsContainer.appendChild(this.suggestionsList),r.appendChild(l),r.appendChild(this.suggestionsContainer),t.appendChild(r);const a=document.createElement("div");a.className="yjd-button-container";const c=document.createElement("button");c.type="button",c.className="yjd-button-cancel",c.textContent="Cancel",c.addEventListener("click",()=>this.hide()),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="yjd-button-confirm",this.insertButton.textContent="Insert Tag",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>this.insertTag()),a.appendChild(c),a.appendChild(this.insertButton),t.appendChild(a),this.popup.appendChild(t),b(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup),this.updateSuggestions()}updateSuggestions(){this.selectedTagType=this.typeSelect.value,this.suggestionsList.innerHTML="";this.getSuggestions(this.selectedTagType).forEach(t=>{const e=document.createElement("button");e.type="button",e.className="yjd-suggestion-button",e.textContent=t,e.addEventListener("click",()=>{this.contentInput.value=t,this.updateInsertButton(),this.contentInput.focus()}),this.suggestionsList.appendChild(e)})}getSuggestions(t){return{mention:["john","admin","team","support"],hashtag:["urgent","done","important"],custom:["warning","info","success"]}[t]||[]}updateInsertButton(){const t=this.contentInput.value.trim();this.insertButton.disabled=!t}insertTag(){const t=this.contentInput.value.trim();t&&(this.options.onTagInsert&&this.options.onTagInsert(this.selectedTagType,t),this.hide(),this.reset())}reset(){this.contentInput.value="",this.typeSelect.value="mention",this.selectedTagType="mention",this.updateInsertButton(),this.updateSuggestions()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside(),setTimeout(()=>{this.contentInput.focus()},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class K extends r{static formatName="tag";static tagName="SPAN";static className="custom-tag";static savedRanges=new Map;constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("tag");e||(e=new $({onTagInsert:(t,e)=>{K.insertTagAtCurrentPosition(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("tag",e)),this.tagPopup=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new K;return s.currentInstance=n,i}static create(t,e){const n=document.createElement("SPAN");n.className=`custom-tag tag-${t}`;let i=e;return"mention"===t?i=`@${e}`:"hashtag"===t?i=`#${e}`:"custom"===t&&(i=`<${e}>`),n.textContent=i,n.setAttribute("data-tag-type",t),n.setAttribute("data-tag-content",e),n.setAttribute("contenteditable","false"),n}static insertTagAtCurrentPosition(t,e,n=null){let i=null;if(i=n?s.getInstanceById(n):s.getCurrentInstance(),!i)return;const o=window.getSelection();if(o)try{const s=K.savedRanges.get(n);if(s)o.removeAllRanges(),o.addRange(s),K.savedRanges.delete(n);else if(!o.rangeCount)return;const r=o.getRangeAt(0),l=K.create(t,e);r.deleteContents(),r.insertNode(l);const a=document.createTextNode(" ");r.setStartAfter(l),r.insertNode(a),r.setStartAfter(a),r.collapse(!0),o.removeAllRanges(),o.addRange(r),i&&i.element&&i.element.focus(),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}}apply(t,e){if(t&&e)K.insertTagAtCurrentPosition(t,e,this.editorId);else{const t=window.getSelection();t&&t.rangeCount>0&&K.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange()),this.showTagPopup()}}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getTagElement(e);if(n){const t=document.createTextNode(n.textContent);n.parentNode.replaceChild(t,n)}}toggle(){if(this.tagPopup.isVisible)this.tagPopup.hide();else{const t=window.getSelection();t&&t.rangeCount>0&&K.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange()),this.showTagPopup()}}showTagPopup(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("tag")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.tag-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.tag-btn")),n&&this.tagPopup.show(n)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getTagElement(e)}getTagElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),e.classList&&e.classList.contains("custom-tag"))return e;return t.cloneContents().querySelector(".custom-tag")||null}static getSuggestions(t){return{mention:["john","sarah","admin","team","support"],hashtag:["urgent","todo","done","review","important"],custom:["note","warning","tip","info","success"]}[t]||[]}}class Q extends r{static formatName="textSize";static tagName="SPAN";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("text-size");if(!e){const n=Q.getSizeMap(),i=Object.values(n).map(t=>({value:t.size,label:t.element,title:t.title}));e=new H({items:i,displayProperty:"label",valueProperty:"value",className:"text-size-select",onItemSelect:t=>{Q.applyTextSizeToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("text-size",e)}this.customSelect=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new Q;return s.currentInstance=n,i}static getSizeMap(){return{1:{size:"1",element:"<span >XX-Small</span>",title:"XX-Small"},2:{size:"2",element:"<span >X-Small</span>",title:"X-Small"},3:{size:"3",element:"<span >Small</span>",title:"Small"},4:{size:"4",element:"<span >Medium</span>",title:"Medium"},5:{size:"5",element:"<span >Large</span>",title:"Large"},6:{size:"6",element:"<span >X-Large</span>",title:"X-Large"},7:{size:"7",element:"<span >XX-Large</span>",title:"XX-Large"}}}static getSizeDisplayName(t){const e=this.getSizeMap();return e[t]?.title||"Medium"}updateButtonText(){const t=this.getCurrentSize(),e=Q.getSizeDisplayName(t||"4"),n=s.getInstanceById(this.editorId);if(!n)return;const i=n.getModule("toolbar");let o=null;if(i&&(o=i.getButton("text-size")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}o||(o=n.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static updateButtonTextStatic(t=null){let e=null;if(e=t?s.getInstanceById(t):s.getCurrentInstance(),!e)return;const n=Q.getCurrentSizeStatic(),i=Q.getSizeDisplayName(n||"4"),o=e.getModule("toolbar");let r=null;if(o&&(r=o.getButton("text-size")),!r){const t=o?.getContainer();t&&(r=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}r||(r=e.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),r&&r.updateText?r.updateText(i):r&&(r.textContent=i)}static create(t="4"){const e=document.createElement("span");return e.style.fontSize=Q.sizeToCss(t),e}static applyTextSizeToCurrentSelection(t,e=null){let n=null;if(n=e?s.getInstanceById(e):s.getCurrentInstance(),!n)return;const i=window.getSelection();if(!i||!i.rangeCount)return;a();const o=Q.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{n&&"function"==typeof n.onContentChange&&n.onContentChange()},0)}static sizeToCss(t){return{1:"10px",2:"12px",3:"14px",4:"16px",5:"20px",6:"28px",7:"36px"}[String(t)]||"16px"}apply(t="4"){const e=window.getSelection();if(!e||!e.rangeCount)return;a();const n=e.getRangeAt(0);if(!n.collapsed){document.execCommand("fontSize",!1,String(t));const e=window.getSelection();if(e.rangeCount>0){const t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===Node.TEXT_NODE?t.parentNode.normalize():t.normalize()}return}let i=n.startContainer;n.startOffset,i.nodeType===Node.TEXT_NODE&&(i=i.parentNode);const s=i.closest&&i.closest("font");if(s&&""===s.textContent)return void s.setAttribute("size",String(t));if(s&&s.firstChild&&s.firstChild.nodeType===Node.TEXT_NODE){const e=s.firstChild,i=n.startOffset,o=e.data.slice(0,i),r=e.data.slice(i),a=s.parentNode;if(0===i){const e=document.createElement("font");e.setAttribute("size",String(t)),e.appendChild(document.createTextNode("")),a.insertBefore(e,s),l(e)}else if(i===e.data.length){const e=document.createElement("font");e.setAttribute("size",String(t)),e.appendChild(document.createTextNode("")),a.insertBefore(e,s.nextSibling),l(e)}else{const e=document.createElement("font");e.setAttribute("size",s.getAttribute("size")),e.appendChild(document.createTextNode(o));const n=document.createElement("font");n.setAttribute("size",String(t)),n.appendChild(document.createTextNode(""));const i=document.createElement("font");i.setAttribute("size",s.getAttribute("size")),i.appendChild(document.createTextNode(r)),a.insertBefore(e,s),a.insertBefore(n,s),a.insertBefore(i,s),a.removeChild(s),l(n)}return}const o=document.createElement("font");o.setAttribute("size",String(t));const r=document.createTextNode("");function l(t){const e=window.getSelection(),n=document.createRange(),i=t.firstChild;n.setStart(i,i.length),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}o.appendChild(r),n.insertNode(o),l(o)}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showSizePicker()}async showSizePicker(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("text-size")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}if(n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),!n)return;const i=this.getCurrentSize();i&&this.customSelect.setCurrentValue(i),await this.customSelect.show(n)}isActive(t=null){return this.updateButtonText(),!1}getCurrentSize(){return Q.getCurrentSizeStatic()}static getCurrentSizeStatic(){const t=window.getSelection();if(!t||!t.rangeCount)return"4";try{const t=document.queryCommandValue("fontSize"),e=parseInt(t,10);if(!isNaN(e)&&e>=1&&e<=7)return String(e)}catch(t){}let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e,n=t.style?.fontSize;if(n)return this.normalizeCssSizeToExecSize(n);const i=window.getComputedStyle(t).fontSize;if(i)return this.normalizeCssSizeToExecSize(i)}e=e.parentElement}return"4"}normalizeCssSizeToExecSize(t){const e=parseFloat(t);if(isNaN(e))return"4";const n=[10,12,14,16,20,28,36];let i=3,s=1/0;for(let t=0;t<n.length;t++){const o=Math.abs(e-n[t]);o<s&&(s=o,i=t)}return String(i+1)}}class J{constructor(t={}){this.options={onImport:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedFile=null,this.fileType=null,this.createImportPopup()}createImportPopup(){this.popup=document.createElement("div"),this.popup.className="import-popup";const t=document.createElement("div");t.className="import-popup-content";const e=document.createElement("h3");e.textContent="Import File",e.className="import-popup-title",t.appendChild(e);const n=document.createElement("div");n.className="import-type-container";const i=document.createElement("label");i.textContent="File Type:",i.className="import-input-label",this.typeSelect=document.createElement("select"),this.typeSelect.className="import-type-select",this.typeSelect.innerHTML='\n <option value="">Select file type...</option>\n <option value="html">HTML (.html, .htm)</option>\n <option value="excel">Excel/CSV (.csv, .xlsx, .xls)</option>\n <option value="pdf">PDF (.pdf)</option>\n <option value="word">Word (.doc, .docx)</option>\n ',this.typeSelect.addEventListener("change",()=>this.updateFileInput()),n.appendChild(i),n.appendChild(this.typeSelect),t.appendChild(n),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.className="import-file-input",this.fileInput.disabled=!0,this.fileInput.addEventListener("change",t=>this.handleFileSelect(t)),t.appendChild(this.fileInput),this.fileInfo=document.createElement("div"),this.fileInfo.className="import-file-info",this.fileInfo.style.display="none",t.appendChild(this.fileInfo);const s=document.createElement("div");s.className="import-button-container";const o=document.createElement("button");o.type="button",o.className="import-button cancel-button",o.textContent="Cancel",o.addEventListener("click",()=>this.hide()),this.importButton=document.createElement("button"),this.importButton.type="button",this.importButton.className="import-button import-button-main",this.importButton.textContent="Import",this.importButton.disabled=!0,this.importButton.addEventListener("click",()=>this.processImport()),s.appendChild(o),s.appendChild(this.importButton),t.appendChild(s),this.popup.appendChild(t),b(this.popup)}updateFileInput(){const t=this.typeSelect.value;if(t){this.fileType=t,this.fileInput.disabled=!1;const e=this.getAcceptTypes(t);this.fileInput.accept=e}else this.fileType=null,this.fileInput.disabled=!0,this.fileInput.accept="";this.updateImportButton()}getAcceptTypes(t){return{html:".html,.htm,text/html",excel:".csv,.xlsx,.xls,text/csv",pdf:".pdf,application/pdf",word:".doc,.docx"}[t]||""}handleFileSelect(t){const e=t.target.files[0];e&&this.setSelectedFile(e)}setSelectedFile(t){this.selectedFile=t,this.fileInfo.style.display="block",this.fileInfo.innerHTML=`\n <div><strong>Name:</strong> ${t.name}</div>\n <div><strong>Size:</strong> ${this.formatFileSize(t.size)}</div>\n <div><strong>Type:</strong> ${t.type||"Unknown"}</div>\n `,this.updateImportButton()}formatFileSize(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB"][e]}updateImportButton(){this.importButton.disabled=!this.selectedFile||!this.fileType}async processImport(){if(this.selectedFile&&this.fileType)try{let t;if("html"===this.fileType)t=await this.readAsText(this.selectedFile);else if("excel"===this.fileType){if(!this.selectedFile.name.toLowerCase().endsWith(".csv"))return void alert("Excel files (.xlsx/.xls) require additional libraries. Please use CSV format.");{const e=await this.readAsText(this.selectedFile);t=this.parseCSV(e)}}else{if("pdf"===this.fileType)return void alert("PDF import requires additional libraries. Feature coming soon.");if("word"===this.fileType)return void alert("Word document import requires additional libraries. Feature coming soon.")}this.options.onImport&&this.options.onImport(t,this.fileType),this.hide(),this.reset()}catch(t){alert("Error importing file: "+t.message)}}parseCSV(t){const e=t.split("\n"),n=[];return e.forEach(t=>{if(t.trim()){const e=t.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""));n.push(e)}}),n}readAsText(t){return new Promise((e,n)=>{const i=new FileReader;i.onload=t=>e(t.target.result),i.onerror=()=>n(new Error("Failed to read file")),i.readAsText(t)})}reset(){this.selectedFile=null,this.fileType=null,this.typeSelect.value="",this.fileInput.value="",this.fileInput.disabled=!0,this.fileInfo.style.display="none",this.updateImportButton()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;const e=v(t,this.popup,{offsetY:5,offsetX:0});w(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class tt extends r{static formatName="import";static tagName="DIV";static className="imported-content";constructor(){super();const t=s.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("import");e||(e=new J({onImport:(t,e)=>{tt.insertImportedContent(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("import",e)),this.importPopup=e}static createForEditor(t){const e=s.getInstanceById(t);if(!e)return null;const n=s.currentInstance;s.currentInstance=e;const i=new tt;return s.currentInstance=n,i}static insertImportedContent(t,e,n=null){let i=null;if(i=n?s.getInstanceById(n):s.getCurrentInstance(),!i)return;const o=window.getSelection();if(o&&o.rangeCount)try{const n=o.getRangeAt(0);let s;s="html"===e?tt.processHtmlContent(t):"excel"===e?tt.processExcelContent(t):tt.processTextContent(t),n.deleteContents(),n.insertNode(s),n.setStartAfter(s),n.collapse(!0),o.removeAllRanges(),o.addRange(n),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}}static processHtmlContent(t){const e=document.createElement("div");e.className="imported-content html-content";const n=document.createElement("div");return n.innerHTML=t,tt.cleanHtmlContent(n),e.appendChild(n),e}static processExcelContent(t){const e=document.createElement("div");if(e.className="imported-content excel-content",!Array.isArray(t)||0===t.length)return e.textContent="No data to import",e;const n=document.createElement("table");if(n.className="imported-table",t.length>0){const e=document.createElement("thead"),i=document.createElement("tr");t[0].forEach(t=>{const e=document.createElement("th");e.textContent=t||"",i.appendChild(e)}),e.appendChild(i),n.appendChild(e)}if(t.length>1){const e=document.createElement("tbody");for(let n=1;n<t.length;n++){const i=document.createElement("tr");t[n].forEach(t=>{const e=document.createElement("td");e.textContent=t||"",i.appendChild(e)}),e.appendChild(i)}n.appendChild(e)}return e.appendChild(n),e}static processTextContent(t){const e=document.createElement("div");e.className="imported-content text-content";return t.split(/\n\s*\n/).forEach(t=>{if(t.trim()){const n=document.createElement("p");n.textContent=t.trim(),e.appendChild(n)}}),e}static cleanHtmlContent(t){const e=["p","div","span","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","ul","ol","li","br","table","thead","tbody","tr","th","td"],n=["class","style"],i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,!1),s=[];for(;i.nextNode();){const t=i.currentNode;if(!e.includes(t.tagName.toLowerCase())){s.push(t);continue}Array.from(t.attributes).forEach(e=>{n.includes(e.name.toLowerCase())||t.removeAttribute(e.name)})}s.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)})}static parseCSV(t){const e=t.split("\n"),n=[];return e.forEach(t=>{if(t.trim()){const e=t.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""));n.push(e)}}),n}apply(){this.showImportPopup()}toggle(){this.importPopup.isVisible?this.importPopup.hide():this.showImportPopup()}showImportPopup(){const t=s.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let n=null;if(e&&(n=e.getButton("import")),!n){const t=e?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.import-btn"))}n||(n=t.wrapper.querySelector(".rich-editor-toolbar-btn.import-btn")),n&&this.importPopup.show(n)}isActive(){return!1}static getSupportedTypes(){return{html:{extensions:[".html",".htm"],mimeTypes:["text/html"],name:"HTML Files"},excel:{extensions:[".csv",".xlsx",".xls"],mimeTypes:["text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],name:"Excel Files"},pdf:{extensions:[".pdf"],mimeTypes:["application/pdf"],name:"PDF Files"},word:{extensions:[".doc",".docx"],mimeTypes:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],name:"Word Documents"}}}}function et(t="Button",e={}){const{width:n="auto"}=e,i=document.createElement("button");i.type="button",i.className="custom-select-button";const s=document.createElement("span");s.textContent=t,s.className="button-text";const o=f.createIconElement("dropdown");return o.className="dropdown-icon",i.appendChild(s),i.appendChild(o),i.style.width=n,i.style.padding="0px 5px 0px 8px",i.style.setProperty("height","32px","important"),i.style.setProperty("borderRadius","6px","important"),i.style.setProperty("alignItems","center","important"),i.style.fontSize="14px",i.style.fontWeight="400",i.style.color="#374151",i.style.background="#FFFFFF",i.style.cursor="pointer",i.style.border="1px solid #d1d5db",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",s.style.flex="1",s.style.textAlign="left",i.updateText=function(t){s.textContent=t},i}class nt extends i{static DEFAULTS={container:null,toolbar1:[{group:"text-format",items:["bold","italic","underline","strike"]},{group:"script",items:["subscript","superscript"]},{group:"colors",items:["color","background"]},{group:"link",items:["link"]},{group:"structure",items:["heading","text-size"]},{group:"table",items:["table"]},{group:"alignment",items:["text-align"]},{group:"actions",items:["undo","redo"]},{group:"more",items:["more"]}],toolbar2:[{group:"structure",items:["list"]},{group:"indent",items:["indent-increase","indent-decrease"]},{group:"font-family",items:["font-family"]},{group:"line-height",items:["line-height"]},{group:"capitalization",items:["capitalization"]},{group:"media",items:["emoji","image","video"]},{group:"content",items:["tag"]},{group:"view",items:["code-view"]}]};constructor(t,e={}){super(t,e),this.buttons=new Map,this.toolbar2Visible=!1,this.events=new Map,Array.isArray(e.toolbar)?this.options={container:null,toolbar1:[{group:"text-format",items:e.toolbar}],toolbar2:[]}:e.toolbar1||e.toolbar2?this.options={container:null,toolbar1:e.toolbar1||[],toolbar2:e.toolbar2||[]}:this.options={...nt.DEFAULTS,...e},this.init(),this.preloadIcons()}init(){this.container=this.createToolbarContainer()}async preloadIcons(){}createToolbarContainer(){const t=document.createElement("div");return t.className="rich-editor-toolbar-container",this.editor.preventFocusLoss(t),this.toolbar1=this.createToolbar("rich-editor-toolbar-1",this.options.toolbar1),t.appendChild(this.toolbar1),this.toolbar2=this.createToolbar("rich-editor-toolbar-2",this.options.toolbar2),this.toolbar2.style.display="none",t.appendChild(this.toolbar2),t}createToolbar(t,e){const n=document.createElement("div");return n.className=t,Array.isArray(e)&&e.forEach(t=>{if(t&&t.group&&Array.isArray(t.items)){const e=document.createElement("div");e.className=`toolbar-group toolbar-group-${t.group}`,t.items.forEach(t=>{"string"==typeof t&&this.addButton(e,t)}),n.appendChild(e)}}),n}addButton(t,e){if("more"===e)return this.addMoreButton(t);const n={heading:{text:"Paragraph",width:"110px",title:"Format (Headings & Paragraphs)"},"font-family":{text:"Font Family",width:"150px",title:"Font Family"},"line-height":{text:"Line Height",width:"110px",title:"Line Height"},capitalization:{text:"Capitalization",width:"130px",title:"Text Capitalization"},"text-size":{text:"Text Size",width:"100px",title:"Text Size"}};if(n[e]){const i=n[e],s=et(i.text,{width:i.width});return s.dataset.command=e,s.classList.add("rich-editor-toolbar-btn",`${e}-btn`),s.title=i.title,s.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:s}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,s),t.appendChild(s),s}const i={"text-align":{icon:"align-left",title:"Align Left"},list:{icon:"list",title:"List"}};if(i[e]){const n=i[e],s=document.createElement("button");s.type="button",s.className=`rich-editor-toolbar-btn ${e}-btn`,s.dataset.command=e,s.title=n.title;const o=f.getIcon(n.icon);return o?s.innerHTML=`<span class="icon">${o}</span>`:s.textContent="text-align"===e?"≡":"•",s.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:s}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,s),t.appendChild(s),s}const s=document.createElement("button");s.type="button",s.className=`rich-editor-toolbar-btn ${e}-btn`,s.dataset.command=e;const o=f.createIconElement(e,{width:"16px",height:"16px"});s.appendChild(o);return s.title={bold:"Bold (Ctrl+B)",italic:"Italic (Ctrl+I)",underline:"Underline (Ctrl+U)",strike:"Strikethrough",subscript:"Subscript",superscript:"Superscript",color:"Text Color",background:"Background Color",link:"Insert/Edit Link",table:"Insert Table",undo:"Undo (Ctrl+Z)",redo:"Redo (Ctrl+Y)","indent-increase":"Increase Indent","indent-decrease":"Decrease Indent",emoji:"Insert Emoji",image:"Insert Image",video:"Insert Video",tag:"Insert Tag",import:"Import Files","code-view":"Switch to HTML Editor"}[e]||e,"code-view"===e&&setTimeout(()=>{o.innerHTML.trim()||(o.innerHTML="</>",o.style.fontSize="12px",o.style.fontWeight="bold")},1e3),s.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:s}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,s),t.appendChild(s),s}addMoreButton(t){const e=document.createElement("button");e.type="button",e.className="rich-editor-toolbar-btn more-btn",e.dataset.command="more";const n=f.createIconElement("more",{width:"16px",height:"16px"});return e.appendChild(n),e.title="More Options",e.addEventListener("click",t=>{t.preventDefault(),this.toggleToolbar2(),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set("more",e),t.appendChild(e),e}toggleToolbar2(){this.toolbar2Visible=!this.toolbar2Visible,this.toolbar2Visible?(this.toolbar2.style.display="flex",this.toolbar2.style.borderTop="1px solid #d1d5db"):this.toolbar2.style.display="none";const t=this.buttons.get("more");t&&(this.toolbar2Visible?(t.classList.add("active"),t.title="Hide More Options"):(t.classList.remove("active"),t.title="More Options"))}getContainer(){return this.container}getButton(t){return this.buttons.get(t)}setButtonActive(t,e){const n=this.buttons.get(t);n&&n.classList&&(e?n.classList.add("active"):n.classList.remove("active"))}setButtonDisabled(t,e){const n=this.buttons.get(t);n&&(n.disabled=e,n.style.opacity=e?"0.5":"1",n.style.cursor=e?"not-allowed":"pointer")}setButtonTitle(t,e){const n=this.buttons.get(t);n&&(n.title=e)}isToolbar2Visible(){return this.toolbar2Visible}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}emit(t,e){const n=this.events.get(t);n&&n.forEach(t=>{try{t(e)}catch(t){}})}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.buttons.clear(),this.events.clear()}}class it extends i{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};constructor(t,e={}){super(t,e),this.stack=[],this.index=-1,this.lastSave=0,this.savedSelection=null,this.init()}init(){this.setupEventListeners(),this.saveState()}setupEventListeners(){this.editor.editor.addEventListener("input",()=>{this.handleInput()}),this.editor.editor.addEventListener("keydown",t=>{"Enter"!==t.key&&"Backspace"!==t.key&&"Delete"!==t.key||this.saveState()}),this.setupMutationObserver(),this.editor.wrapper.addEventListener("click",t=>{t.target.closest(".rich-editor-toolbar-btn")&&setTimeout(()=>{this.saveState()},0)}),this.editor.editor.addEventListener("keydown",t=>{!t.ctrlKey&&!t.metaKey||t.shiftKey||"z"!==t.key?((t.ctrlKey||t.metaKey)&&t.shiftKey&&"z"===t.key||(t.ctrlKey||t.metaKey)&&"y"===t.key)&&(t.preventDefault(),this.redo()):(t.preventDefault(),this.undo())})}setupMutationObserver(){this.mutationObserver=new MutationObserver(t=>{let e=!1;for(const n of t)if("childList"===n.type||"attributes"===n.type&&(n.target.nodeType===Node.TEXT_NODE||["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI","SPAN","STRONG","EM","U","S","SUB","SUP","A","IMG","VIDEO","TABLE","TR","TD","TH"].includes(n.target.tagName))){e=!0;break}e&&(clearTimeout(this.mutationTimeout),this.mutationTimeout=setTimeout(()=>{this.saveState()},100))}),this.mutationObserver.observe(this.editor.editor,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","href","src","alt","title"]})}handleInput(){const t=Date.now();t-this.lastSave>this.options.delay&&(this.saveState(),this.lastSave=t)}saveState(){const t=this.editor.getContent(),e=this.saveSelection();if(this.stack.length>0&&this.stack[this.index]?.content===t)return;const n=Date.now();this.lastSave&&n-this.lastSave<50||(this.index<this.stack.length-1&&this.stack.splice(this.index+1),this.stack.push({content:t,selection:e,timestamp:n}),this.stack.length>this.options.maxStack?this.stack.shift():this.index++,this.lastSave=n)}undo(){if(!this.canUndo())return!1;this.index--;const t=this.stack[this.index];return this.restoreState(t),this.onHistoryChange("undo"),!0}redo(){if(!this.canRedo())return!1;this.index++;const t=this.stack[this.index];return this.restoreState(t),this.onHistoryChange("redo"),!0}canUndo(){return this.index>0}canRedo(){return this.index<this.stack.length-1}restoreState(t){t&&(this.editor.setContent(t.content),t.selection&&setTimeout(()=>{this.restoreSelection(t.selection)},10))}saveSelection(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=this.editor.editor;return{startOffset:this.getOffsetInEditor(e.startContainer,e.startOffset,n),endOffset:this.getOffsetInEditor(e.endContainer,e.endOffset,n),collapsed:e.collapsed}}restoreSelection(t){if(!t)return;const e=this.editor.editor,n=document.createRange(),i=window.getSelection();try{const s=this.getNodeAtOffset(e,t.startOffset),o=this.getNodeAtOffset(e,t.endOffset);s&&o&&(n.setStart(s.node,s.offset),n.setEnd(o.node,o.offset),i.removeAllRanges(),i.addRange(n))}catch(t){this.editor.focus()}}getOffsetInEditor(t,e,n){let i=0;const s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,!1);let o;for(;o=s.nextNode();){if(o===t)return i+e;i+=o.textContent.length}return i}getNodeAtOffset(t,e){let n=0;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let s;for(;s=i.nextNode();){const t=s.textContent.length;if(n+t>=e)return{node:s,offset:e-n};n+=t}return{node:t.lastChild||t,offset:0}}clear(){this.stack=[],this.index=-1,this.saveState()}getState(){return{canUndo:this.canUndo(),canRedo:this.canRedo(),stackLength:this.stack.length,currentIndex:this.index}}onHistoryChange(t){this.editor.modules.forEach(e=>{e!==this&&"function"==typeof e.onHistoryChange&&e.onHistoryChange(t,this.getState())});const e=new CustomEvent("historychange",{detail:{action:t,state:this.getState()}});this.editor.editor.dispatchEvent(e)}forceSave(){const t=this.lastSave;this.lastSave=0,this.saveState(),this.lastSave=t}saveBeforeFormat(){this.forceSave()}destroy(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.mutationTimeout&&(clearTimeout(this.mutationTimeout),this.mutationTimeout=null),this.stack=[],this.index=-1,this.savedSelection=null}}class st extends i{static DEFAULTS={showOnSelection:!0,showOnEnter:!0,buttons:["bold","italic","underline","strike","code"]};constructor(t,e={}){super(t,e),this.blockToolbar=null,this.isVisible=!1,this.currentSelection=null,this.currentCursorPosition=null,this.originalTags=new Map,this.init()}init(){this.preloadIcons(),this.createBlockToolbar(),this.setupEventListeners()}async preloadIcons(){}createBlockToolbar(){this.blockToolbar=document.createElement("div"),this.blockToolbar.className="block-toolbar";const t=document.createElement("div");t.className="block-toolbar-container";[{cmd:"bold",icon:"bold",title:"Bold (Ctrl+B)"},{cmd:"italic",icon:"italic",title:"Italic (Ctrl+I)"},{cmd:"underline",icon:"underline",title:"Underline (Ctrl+U)"},{cmd:"strike",icon:"strike",title:"Strikethrough"},{cmd:"code",icon:"code",title:"Code"},{cmd:"font-family",icon:"heading",title:"Font Family"}].forEach(({cmd:e,icon:n,title:i})=>{const s=document.createElement("button");s.className="block-toolbar-btn",s.title=i,s.dataset.command=e;const o=f.createIconElement(n,{width:"16px",height:"16px"});s.appendChild(o),s.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.handleCommand(e,s)}),t.appendChild(s)});const e=document.createElement("div");e.className="block-toolbar-arrow",this.blockToolbar.appendChild(t),this.blockToolbar.appendChild(e),this.editor.wrapper.appendChild(this.blockToolbar)}setupEventListeners(){this.options.showOnSelection&&this.editor.editor.addEventListener("mouseup",()=>{setTimeout(()=>this.handleSelectionChange(),0)}),this.options.showOnEnter&&this.editor.editor.addEventListener("keydown",t=>{"Enter"!==t.key||t.shiftKey?this.hide():requestAnimationFrame(()=>{setTimeout(()=>this.showAtCursorAfterEnter(),10)})}),document.addEventListener("mousedown",t=>{t.target.closest(".font-family-select-popup")||t.target.closest(".custom-select-popup")||t.target.closest(".block-toolbar")||t.target.closest(".rich-editor-area")||this.hide()}),window.addEventListener("scroll",()=>{this.isVisible&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("scroll",()=>{this.isVisible&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("keyup",t=>{"Enter"===t.key&&t.shiftKey?this.hide():this.isVisible?this.updateButtonStates():this.handleSelectionChange()})}handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return this.hide();const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return this.hide();!e.collapsed&&t.toString().trim().length>0?this.showAtSelection(t):this.hide()}showAtSelection(t){if(!t||0===t.rangeCount)return;this.currentSelection=t,this.currentCursorPosition=null;const e=t.getRangeAt(0).getBoundingClientRect(),n=this.editor.wrapper.getBoundingClientRect(),i=window.pageYOffset||document.documentElement.scrollTop,s=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(e.left+e.width/2-n.left+s,e.top-n.top+i-10)}showAtCursorAfterEnter(){this.editor.focus();const t=window.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return;this.ensureCursorAtEndOfLine(e),this.currentSelection=t,this.currentCursorPosition=this.getCursorPositionAfterEnter();const n=this.currentCursorPosition;if(!n)return;const i=this.editor.wrapper.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(n.left-i.left+o,n.top-i.top+s-10)}ensureCursorAtEndOfLine(t){if(!t.collapsed)return;const e=window.getSelection(),n=t.startContainer;if(n.nodeType===Node.TEXT_NODE){const i=n.textContent.length;t.startOffset<i&&(t.setStart(n,i),t.setEnd(n,i),e.removeAllRanges(),e.addRange(t))}else if(n.nodeType===Node.ELEMENT_NODE){const i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,!1);let s,o=null;for(;s=i.nextNode();)o=s;if(o){const n=o.textContent.length;t.setStart(o,n),t.setEnd(o,n),e.removeAllRanges(),e.addRange(t)}}}getCursorPositionAfterEnter(){const t=window.getSelection();if(!t||0===t.rangeCount)return null;const e=t.getRangeAt(0),n=document.createElement("span");n.innerHTML="​",n.style.position="absolute",n.style.visibility="hidden",n.style.pointerEvents="none",e.insertNode(n);const i=n.getBoundingClientRect();n.parentNode&&n.parentNode.removeChild(n);const s=document.createRange();return s.setStart(e.startContainer,e.startOffset),s.collapse(!0),t.removeAllRanges(),t.addRange(s),i}showAtCursor(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return;let n;if(e.collapsed){const i=document.createElement("span");i.innerHTML="​",i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",e.insertNode(i),n=i.getBoundingClientRect(),i.parentNode&&i.parentNode.removeChild(i);const s=document.createRange();s.setStart(e.startContainer,e.startOffset),s.collapse(!0),t.removeAllRanges(),t.addRange(s)}else n=e.getBoundingClientRect();const i=this.editor.wrapper.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(n.left-i.left+o,n.top-i.top+s-10)}showAt(t,e){this.blockToolbar&&(this.blockToolbar.classList.add("visible"),this.isVisible=!0,this.ensureToolbarInViewport(t,e),this.updateButtonStates())}ensureToolbarInViewport(t,e){if(!this.blockToolbar)return;const n=this.editor.editor,i=n.getBoundingClientRect();this.blockToolbar.getBoundingClientRect();const s=this.editor.wrapper.querySelector(".rich-editor-toolbar-container"),o=s?s.getBoundingClientRect():null;let r=t-this.blockToolbar.offsetWidth/2,l=i.y+e-o.height-n.scrollTop-(i.y+window.scrollY)+s.offsetHeight-49,a="50%",c="down";if(r<0&&(r=t-.1*this.blockToolbar.offsetWidth,r<0&&(r=0),a="10%"),r+this.blockToolbar.offsetWidth>this.editor.wrapper.offsetWidth-2&&(r=t-.9*this.blockToolbar.offsetWidth,a="90%"),l<o.height&&(l=i.y+e-o.height-n.scrollTop+100-(i.y+window.scrollY)+s.offsetHeight-49,c="up",l<o.height))return void this.hide();if(l>i.height)return void this.hide();const d=this.blockToolbar.querySelector(".block-toolbar-arrow");d&&(d.style.left=a,"up"===c?(d.style.bottom="auto",d.style.top="-8px",d.style.borderTop="none",d.style.borderBottom="8px solid #fff",d.style.borderLeft="6px solid transparent",d.style.borderRight="6px solid transparent"):(d.style.top="auto",d.style.bottom="-8px",d.style.borderBottom="none",d.style.borderTop="8px solid #fff",d.style.borderLeft="6px solid transparent",d.style.borderRight="6px solid transparent")),this.blockToolbar.style.left=r+"px",this.blockToolbar.style.top=l+"px"}updateToolbarPosition(){if(!this.isVisible)return;const t=window.getSelection();if(!t||0===t.rangeCount)return void this.hide();const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return void this.hide();let n;if(e.collapsed){const i=document.createElement("span");i.innerHTML="​",i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none";try{e.insertNode(i),n=i.getBoundingClientRect(),i.parentNode&&i.parentNode.removeChild(i);const s=document.createRange();s.setStart(e.startContainer,e.startOffset),s.collapse(!0),t.removeAllRanges(),t.addRange(s)}catch(t){return void this.hide()}}else n=e.getBoundingClientRect();const i=this.editor.wrapper.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;let r,l;e.collapsed?(r=n.left-i.left+o,l=n.top-i.top+s-10):(r=n.left+n.width/2-i.left+o,l=n.top-i.top+s-10),this.updateToolbarAt(r,l);const a=this.editor.registry.get("formats/font-family");a&&a.selectInstance&&a.selectInstance.isVisible&&a.selectInstance.updatePosition()}updateToolbarAt(t,e){this.blockToolbar&&(this.ensureToolbarInViewport(t,e),this.updateButtonStates())}hide(){if(!this.blockToolbar||!this.isVisible)return;this.blockToolbar.classList.remove("visible"),this.isVisible=!1,this.currentSelection=null,this.currentCursorPosition=null;const t=this.editor.registry.get("formats/font-family");t&&t.selectInstance&&t.selectInstance.hide()}handleCommand(t,e){const n=window.getSelection();if(!(!this.editor.isSelectionInEditableArea||this.editor.isSelectionInEditableArea(n)))return void this.hide();if("font-family"===t){const n=this.editor.registry.get("formats/font-family");if(n){return(new n).toggle(e),this.updateButtonState(t,e),void this.editor.focus()}}if("code"===t){const n=this.editor.registry.get("formats/heading");if(n){const i=new n,s=i.getCurrentTag();if("PRE"===s){const t=window.getSelection();if(t&&t.rangeCount){const e=t.getRangeAt(0),n=this.getBlockElement(e.startContainer);if(n){const t=this.originalTags.get(n)||"P";i.apply(t),this.originalTags.delete(n)}else i.apply("P")}else i.apply("P")}else{const t=window.getSelection();if(t&&t.rangeCount){const e=t.getRangeAt(0),n=this.getBlockElement(e.startContainer);n&&this.originalTags.set(n,s||"P")}i.apply("PRE")}return this.updateButtonState(t,e),void this.editor.focus()}}const i=this.editor.registry.get(`formats/${t}`);if(i){const t=new i;"function"==typeof t.toggle?t.toggle():"function"==typeof t.apply&&t.apply()}else document.execCommand(t,!1,null);this.updateButtonState(t,e),this.editor.focus()}updateButtonStates(){if(!this.blockToolbar)return;this.blockToolbar.querySelectorAll(".block-toolbar-btn").forEach(t=>{const e=t.dataset.command;this.updateButtonState(e,t)})}updateButtonState(t,e){if(!e)return;let n=!1;if("font-family"===t){const t=this.editor.registry.get("formats/font-family");if(t){n=(new t).isActive()}}else if("code"===t){const t=this.editor.registry.get("formats/heading");if(t){n="PRE"===(new t).getCurrentTag()}}else if("strike"===t){const e=this.editor.registry.get(`formats/${t}`);if(e){n=(new e).isActive()}}else try{n=document.queryCommandState(t)}catch(t){n=!1}n?e.classList.add("active"):e.classList.remove("active")}getBlockElement(t){if(!t)return null;if(t.nodeType===Node.ELEMENT_NODE){if(["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE","DIV"].includes(t.tagName))return t}let e=t;for(;e&&e!==this.editor.editor;){if(e.nodeType===Node.ELEMENT_NODE){if(["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE","DIV"].includes(e.tagName))return e}e=e.parentNode}return null}destroy(){this.blockToolbar&&this.blockToolbar.parentNode&&this.blockToolbar.parentNode.removeChild(this.blockToolbar),this.blockToolbar=null,this.isVisible=!1,this.originalTags.clear()}}class ot extends i{static DEFAULTS={fadeDelay:3e3,buttons:["tableProfile","deleteTable","insertRowAbove","insertRowBelow","deleteRow","insertColRight","insertColLeft","deleteCol"]};constructor(t,e={}){super(t,e),this.tableToolbar=null,this.currentTable=null,this.currentCell=null,this.hideTimeout=null,this.isVisible=!1,this.init()}async init(){await this.createTableToolbar(),this.setupEventListeners()}async createTableToolbar(){this.tableToolbar=document.createElement("div"),this.tableToolbar.className="table-toolbar";const t=document.createElement("div");t.className="table-toolbar-container";const e=[{name:"table-actions",buttons:[{cmd:"tableProfile",icon:"icon-table-profile",title:"Table Profile"},{cmd:"deleteTable",icon:"icon-delete-table",title:"Delete Table"}]},{name:"row-actions",buttons:[{cmd:"insertRowAbove",icon:"icon-add-row-above",title:"Add Row Above"},{cmd:"insertRowBelow",icon:"icon-add-row-below",title:"Add Row Below"},{cmd:"deleteRow",icon:"icon-delete-row",title:"Delete Selected Row"}]},{name:"col-actions",buttons:[{cmd:"insertColRight",icon:"icon-add-col-right",title:"Add Column Right"},{cmd:"insertColLeft",icon:"icon-add-col-left",title:"Add Column Left"},{cmd:"deleteCol",icon:"icon-delete-col",title:"Delete Selected Column"}]}];for(const n of e){const e=document.createElement("div");e.className=`table-toolbar-group ${n.name}`;for(const{cmd:t,icon:i,title:s}of n.buttons){const n=document.createElement("button");n.className="table-toolbar-btn",n.title=s,n.dataset.command=t;const o=f.getIcon(i.replace("icon-",""));o&&(n.innerHTML=o),n.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.handleCommand(t,n)}),e.appendChild(n)}t.appendChild(e)}const n=document.createElement("div");n.className="table-toolbar-arrow",this.tableToolbar.appendChild(t),this.tableToolbar.appendChild(n),this.editor.wrapper.appendChild(this.tableToolbar)}setupEventListeners(){this.editor.editor.addEventListener("click",t=>{const e=t.target.closest("td, th"),n=t.target.closest("table");if(n&&e){if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(n)))return void this.hide();this.currentTable=n,this.currentCell=e,this.showAtTable(n)}else this.hide()}),document.addEventListener("mousedown",t=>{t.target.closest(".table-toolbar")||t.target.closest("table")||this.hide()}),window.addEventListener("scroll",()=>{this.isVisible&&this.currentTable&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("scroll",()=>{this.isVisible&&this.currentTable&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("keyup",()=>{if(this.isVisible&&this.currentTable){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).startContainer,n=e.nodeType===Node.TEXT_NODE?e.parentElement.closest("td, th"):e.closest("td, th");if(n&&n!==this.currentCell){if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(n)))return void this.hide();this.currentCell=n}}}})}updateToolbarPosition(){if(!this.isVisible||!this.currentTable)return;if(!document.body.contains(this.currentTable))return void this.hide();if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(this.currentTable)))return void this.hide();const t=this.currentTable.getBoundingClientRect(),e=this.editor.wrapper.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,i=window.pageXOffset||document.documentElement.scrollLeft;this.updateToolbarAt(t.left-e.left+i,t.top-e.top+n,t.width,t.height)}updateToolbarAt(t,e,n,i){this.tableToolbar&&this.ensureToolbarInViewport(t,e,n,i)}showAtTable(t){if(!t||!this.tableToolbar)return;const e=t.getBoundingClientRect(),n=this.editor.wrapper.getBoundingClientRect(),i=window.pageYOffset||document.documentElement.scrollTop,s=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(e.left-n.left+s,e.top-n.top+i,e.width,e.height)}showAt(t,e,n,i){this.tableToolbar&&(this.tableToolbar.classList.add("visible"),this.isVisible=!0,this.ensureToolbarInViewport(t,e,n,i),this.clearHideTimeout())}ensureToolbarInViewport(t,e,n,i){if(!this.tableToolbar)return;const s=this.editor.editor.getBoundingClientRect();this.tableToolbar.getBoundingClientRect();const o=this.editor.wrapper.querySelector(".rich-editor-toolbar-container"),r=o?o.getBoundingClientRect():null;let l=t+n/2-this.tableToolbar.offsetWidth/2,a=e-60-document.documentElement.scrollTop,c="50%",d="down";if(l<0&&(l=t-.1*this.tableToolbar.offsetWidth,l<0&&(l=0),c="10%"),l+this.tableToolbar.offsetWidth>this.editor.wrapper.offsetWidth-2&&(l=t-.9*this.tableToolbar.offsetWidth,c="90%"),a<(r?r.height:48)&&(a=e+i+10-document.documentElement.scrollTop,d="up",a<(r?r.height:48)))return void this.hide();if(a>s.height)return void this.hide();const h=this.tableToolbar.querySelector(".table-toolbar-arrow");h&&(h.style.left=c,"up"===d?(h.style.bottom="auto",h.style.top="-8px",h.style.borderTop="none",h.style.borderBottom="8px solid #fff",h.style.borderLeft="6px solid transparent",h.style.borderRight="6px solid transparent"):(h.style.top="auto",h.style.bottom="-8px",h.style.borderBottom="none",h.style.borderTop="8px solid #fff",h.style.borderLeft="6px solid transparent",h.style.borderRight="6px solid transparent")),this.tableToolbar.style.left=l+"px",this.tableToolbar.style.top=a+"px"}hide(){this.tableToolbar&&this.isVisible&&(this.tableToolbar.classList.remove("visible"),this.isVisible=!1,this.currentTable=null,this.currentCell=null,this.clearHideTimeout())}clearHideTimeout(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}handleCommand(t,e){if(!this.currentTable||!this.currentCell)return;if(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(this.currentTable)){switch(t){case"tableProfile":this.showTableProfile();break;case"deleteTable":this.deleteTable();break;case"insertRowAbove":this.insertRowAbove();break;case"insertRowBelow":this.insertRowBelow();break;case"deleteRow":this.deleteRow();break;case"insertColRight":this.insertColumnRight();break;case"insertColLeft":this.insertColumnLeft();break;case"deleteCol":this.deleteColumn()}this.editor.focus()}else this.hide()}insertRowAbove(){const t=this.currentCell.parentElement,e=this.createNewRow(t.cells.length);t.parentElement.insertBefore(e,t),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertRowBelow(){const t=this.currentCell.parentElement,e=this.createNewRow(t.cells.length);t.nextElementSibling?t.parentElement.insertBefore(e,t.nextElementSibling):t.parentElement.appendChild(e),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertColumnLeft(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell);(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr").forEach(e=>{const n=this.createNewCell(),i=e.children[t];i?e.insertBefore(n,i):e.appendChild(n)}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertColumnRight(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell);(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr").forEach(e=>{const n=this.createNewCell(),i=e.children[t+1];i?e.insertBefore(n,i):e.appendChild(n)}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}deleteRow(){const t=this.currentCell.parentElement;t.parentElement.children.length<=1||(t.remove(),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles(),this.hide())}deleteColumn(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell),e=(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr");this.currentCell.parentElement.children.length<=1||(e.forEach(e=>{e.children[t]&&e.children[t].remove()}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles(),this.hide())}showTableProfile(){if(!this.currentTable)return;const t=this.currentTable.querySelectorAll("tr").length,e=this.currentTable.querySelector("tr")?this.currentTable.querySelector("tr").querySelectorAll("td, th").length:0,n=t,i=e,s=t*e,o=this.currentTable.offsetWidth,r=this.currentTable.offsetHeight;alert(`Table Profile:\nRows: ${n}\nColumns: ${i}\nTotal Cells: ${s}\nWidth: ${o}px\nHeight: ${r}px`)}deleteTable(){this.editor.resizeHandles&&this.editor.resizeHandles.hideHandles(),this.currentTable.remove(),this.hide()}createNewRow(t){const e=document.createElement("tr");for(let n=0;n<t;n++)e.appendChild(this.createNewCell());return e}createNewCell(){const t=document.createElement("td");return t.innerHTML=" ",t.style.minWidth="50px",t.style.minHeight="24px",t.style.padding="4px 8px",t.style.border="1px solid #ddd",t.style.verticalAlign="top",t.contentEditable="true",t}destroy(){this.tableToolbar&&this.tableToolbar.parentNode&&this.tableToolbar.parentNode.removeChild(this.tableToolbar),this.clearHideTimeout(),this.tableToolbar=null,this.currentTable=null,this.currentCell=null,this.isVisible=!1}}class rt extends i{constructor(t,e={}){super(t,e),this.isCodeView=!1,this.originalContent="",this.codeTextarea=null,this.disabledModules=new Set,this.init()}init(){this.editor.on("toolbar-click",t=>{"code-view"===t.command&&this.toggleCodeView()})}toggleCodeView(){this.isCodeView?this.showNormalView():this.showCodeView(),this.updateToolbarButton()}showCodeView(){const t=this.editor.editor;if(!t)return;this.originalContent=t.innerHTML,this.codeTextarea=document.createElement("textarea"),this.codeTextarea.className="code-view-textarea",this.codeTextarea.value=this.formatHTML(this.originalContent),t.style.display="none",t.parentNode.insertBefore(this.codeTextarea,t);const e=this.editor.wrapper;e&&e.classList.add("code-view-active"),this.codeTextarea.focus(),this.isCodeView=!0,this.disableOtherFeatures(),this.codeTextarea.addEventListener("input",()=>{this.updateOriginalContent()})}showNormalView(){const t=this.editor.editor;if(!t||!this.codeTextarea)return;const e=this.codeTextarea.value;this.codeTextarea.parentNode.removeChild(this.codeTextarea),this.codeTextarea=null;const n=this.editor.wrapper;n&&n.classList.remove("code-view-active"),t.style.display="",t.innerHTML=e,t.focus(),this.isCodeView=!1,this.enableOtherFeatures(),this.editor.onContentChange()}disableOtherFeatures(){const t=this.editor.getModule("toolbar");if(t){["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size","emoji","image","video","tag","import","undo","redo"].forEach(e=>{t.setButtonDisabled(e,!0)}),t.setButtonDisabled("code-view",!1),t.setButtonDisabled("theme",!1)}this.disableEditorEvents(),this.disableOtherModules(),this.hideAllPopups()}enableOtherFeatures(){const t=this.editor.getModule("toolbar");if(t){["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size","emoji","image","video","tag","import","undo","redo"].forEach(e=>{t.setButtonDisabled(e,!1)})}this.enableEditorEvents(),this.enableOtherModules()}disableEditorEvents(){const t=this.editor.editor;t&&(t.contentEditable=!1,t.style.opacity="0.5",t.style.pointerEvents="none",t.style.cursor="not-allowed",t.title='Editor is disabled in code view mode. Click "Switch to Visual Editor" to return to normal editing.')}enableEditorEvents(){const t=this.editor.editor;t&&(t.contentEditable=!0,t.style.opacity="",t.style.pointerEvents="",t.style.cursor="",t.title="")}disableOtherModules(){["history","block-toolbar","table-toolbar","resize-handles"].forEach(t=>{const e=this.editor.getModule(t);if(e)if("function"==typeof e.disable)e.disable(),this.disabledModules.add(t);else if(e.getContainer&&"function"==typeof e.getContainer){const n=e.getContainer();n&&(n.style.display="none",this.disabledModules.add(t))}})}enableOtherModules(){this.disabledModules.forEach(t=>{const e=this.editor.getModule(t);if(e)if("function"==typeof e.enable)e.enable();else if(e.getContainer&&"function"==typeof e.getContainer){const t=e.getContainer();t&&(t.style.display="")}}),this.disabledModules.clear()}updateOriginalContent(){if(this.codeTextarea){this.originalContent=this.codeTextarea.value;const t=this.codeTextarea.value;this.editor.options.onChange&&"function"==typeof this.editor.options.onChange&&this.editor.options.onChange(t),this.editor.emit("text-change",t)}}formatHTML(t){let e=t;e=e.replace(/></g,">\n<"),e=e.replace(/>([^<>\s][^<]*)</g,">\n$1\n<");const n=e.split("\n"),i=[],s=[];for(let t of n){const e=t.trim();if(!e)continue;if(/^<\/(\w+)/.test(e)){const t=e.match(/^<\/(\w+)/);if(t){const e=t[1];for(let t=s.length-1;t>=0;t--)if(s[t]===e){s.splice(t,1);break}}}let n=s.length;e.startsWith("<")||(n=s.length),i.push(" ".repeat(4*n)+e);const o=e.match(/^<(\w+)/);if(o&&!e.startsWith("</")&&!e.endsWith("/>")&&!["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(o[1].toLowerCase())){const t=o[1];s.push(t)}}return i.join("\n")}updateToolbarButton(){const t=this.editor.getModule("toolbar");if(t){t.setButtonActive("code-view",this.isCodeView);const e=this.isCodeView?"Switch to Visual Editor":"Switch to HTML Editor";t.setButtonTitle("code-view",e)}}isInCodeView(){return this.isCodeView}getCurrentContent(){return this.isCodeView&&this.codeTextarea?this.codeTextarea.value:this.editor.editor.innerHTML}setContent(t){this.isCodeView&&this.codeTextarea?(this.codeTextarea.value=this.formatHTML(t),this.updateOriginalContent()):this.editor.editor.innerHTML=t}hideAllPopups(){document.querySelectorAll(".rich-editor-popup, .color-picker-popup, .emoji-picker-popup, .link-popup, .image-popup, .video-popup, .table-popup, .tag-popup, .import-popup").forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.editor.popupInstances&&this.editor.popupInstances.clear()}destroy(){this.isCodeView&&this.showNormalView(),this.codeTextarea&&this.codeTextarea.parentNode&&this.codeTextarea.parentNode.removeChild(this.codeTextarea),this.codeTextarea=null,this.originalContent="",this.isCodeView=!1,this.disabledModules.clear()}}class lt extends i{static DEFAULTS={minWidth:50,minHeight:50,maxWidth:800,maxHeight:600,maintainAspectRatio:!0,snapToGrid:!1,gridSize:10};constructor(t,e={}){super(t,e),this.activeElement=null,this.handles=[],this.isResizing=!1,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.currentHandle=null,this.aspectRatio=1,this.init()}init(){this.createHandles(),this.setupEventListeners()}createHandles(){this.handlesContainer=document.createElement("div"),this.handlesContainer.className="resize-handles-container",this.handlesContainer.style.position="absolute",this.handlesContainer.style.pointerEvents="none",this.handlesContainer.style.zIndex="997",this.handlesContainer.style.display="none";[{name:"nw",cursor:"nw-resize",position:{top:-4,left:-4}},{name:"ne",cursor:"ne-resize",position:{top:-4,right:-4}},{name:"sw",cursor:"sw-resize",position:{bottom:-4,left:-4}},{name:"se",cursor:"se-resize",position:{bottom:-4,right:-4}}].forEach(t=>{const e=this.createHandle(t);this.handles.push(e),this.handlesContainer.appendChild(e)}),this.editor.wrapper.appendChild(this.handlesContainer)}createHandle(t){const e=document.createElement("div");return e.className=`resize-handle resize-handle-${t.name}`,e.style.position="absolute",e.style.width="8px",e.style.height="8px",e.style.backgroundColor="#3b82f6",e.style.border="1px solid #fff",e.style.borderRadius="50%",e.style.cursor=t.cursor,e.style.pointerEvents="auto",e.style.boxShadow="0 2px 4px rgba(0,0,0,0.2)",e.style.zIndex="999",e.dataset.handle=t.name,Object.entries(t.position).forEach(([t,n])=>{e.style[t]=n+"px"}),e.addEventListener("mousedown",e=>this.handleMouseDown(e,t.name)),e}setupEventListeners(){this.editor.editor.addEventListener("click",t=>{this.handleElementClick(t)}),document.addEventListener("click",t=>{this.isClickOnResizableElement(t)||this.isClickOnHandle(t)||this.hideHandles()}),document.addEventListener("mousemove",t=>this.handleMouseMove(t)),document.addEventListener("mouseup",t=>this.handleMouseUp(t)),window.addEventListener("scroll",()=>{this.activeElement&&this.updateHandlePosition()}),this.editor.editor.addEventListener("scroll",()=>{this.activeElement&&this.updateHandlePosition()}),this.setupMutationObserver()}handleElementClick(t){const e=t.target;let n=this.findResizableElement(e);n&&(t.preventDefault(),t.stopPropagation(),this.showHandles(n))}findResizableElement(t){if(this.isResizableElement(t))return t;if("TD"===t.tagName||"TH"===t.tagName||"TR"===t.tagName||"TBODY"===t.tagName){let e=t.parentElement;for(;e&&"TABLE"!==e.tagName;)e=e.parentElement;if(e&&this.isResizableElement(e))return e}let e=t.parentElement;for(;e&&e!==this.editor.wrapper;){if(this.isResizableElement(e))return e;e=e.parentElement}return null}isResizableElement(t){const e=t.classList.contains("inserted-image"),n=t.classList.contains("inserted-video"),i=t.classList.contains("rich-editor-table");return e||n||i}isClickOnResizableElement(t){return this.isResizableElement(t.target)}isClickOnHandle(t){return t.target.classList.contains("resize-handle")}showHandles(t){this.activeElement=t,this.updateHandlePosition(),this.handlesContainer.style.display="block",(t.classList.contains("inserted-image")||t.classList.contains("inserted-video"))&&(this.aspectRatio=t.offsetWidth/t.offsetHeight),t.classList.contains("rich-editor-table")&&(t.style.position="relative",t.style.display="table",this.lastTableWidth=t.offsetWidth,this.lastTableHeight=t.offsetHeight,this.setupTableSizeMonitoring(t))}hideHandles(){this.tableSizeInterval&&(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null),this.activeElement=null,this.handlesContainer.style.display="none"}updateHandlePosition(){if(!this.activeElement)return;if(!document.body.contains(this.activeElement))return void this.hideHandles();const t=this.activeElement.getBoundingClientRect(),e=this.editor.wrapper.getBoundingClientRect(),n=this.editor.wrapper.scrollTop||0,i=this.editor.wrapper.scrollLeft||0,s=t.top-e.top+n,o=t.left-e.left+i,r=t.width,l=t.height,a=s+l;this.handlesContainer.style.top=s+"px",this.handlesContainer.style.left=o+"px",this.handlesContainer.style.width=r+"px",this.handlesContainer.style.height=l+"px",(a<0||s>e.height)&&this.hideHandles()}handleMouseDown(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.currentHandle=e,this.startX=t.clientX,this.startY=t.clientY,this.startWidth=this.activeElement.offsetWidth,this.startHeight=this.activeElement.offsetHeight;const n=this.activeElement.getBoundingClientRect();this.startLeft=n.left,this.startTop=n.top,this.activeElement.classList.add("resizing"),document.body.style.cursor=t.target.style.cursor,document.body.style.userSelect="none"}handleMouseMove(t){if(!this.isResizing||!this.activeElement)return;const e=t.clientX-this.startX,n=t.clientY-this.startY;let i=this.startWidth,s=this.startHeight;switch(this.currentHandle){case"nw":i=this.startWidth-e,s=this.startHeight-n;break;case"ne":i=this.startWidth+e,s=this.startHeight-n;break;case"sw":i=this.startWidth-e,s=this.startHeight+n;break;case"se":i=this.startWidth+e,s=this.startHeight+n}if(i=Math.max(this.options.minWidth,Math.min(this.options.maxWidth,i)),s=Math.max(this.options.minHeight,Math.min(this.options.maxHeight,s)),(this.activeElement.classList.contains("inserted-image")||this.activeElement.classList.contains("inserted-video"))&&this.options.maintainAspectRatio){const t=i/this.aspectRatio,e=s*this.aspectRatio;Math.abs(i-e)<Math.abs(s-t)?i=e:s=t}this.options.snapToGrid&&(i=Math.round(i/this.options.gridSize)*this.options.gridSize,s=Math.round(s/this.options.gridSize)*this.options.gridSize),this.applyDimensions(i,s),this.updateHandlePosition(),this.emit("element-resize",{element:this.activeElement,width:i,height:s,handle:this.currentHandle})}handleMouseUp(t){this.isResizing&&(this.isResizing=!1,this.currentHandle=null,this.activeElement&&this.activeElement.classList.remove("resizing"),document.body.style.cursor="",document.body.style.userSelect="",this.emit("element-resize-complete",{element:this.activeElement,width:this.activeElement.offsetWidth,height:this.activeElement.offsetHeight}))}applyDimensions(t,e){if(this.activeElement)if(this.activeElement.classList.contains("rich-editor-table")){this.activeElement.style.width=t+"px",this.activeElement.style.minWidth=t+"px",this.activeElement.style.height=e+"px",this.activeElement.style.minHeight=e+"px";const n=this.activeElement.querySelectorAll("tr"),i=n.length>0?n[0].querySelectorAll("td, th").length:0;if(n.length>0&&i>0){const s=Math.floor(t/i),o=Math.floor(e/n.length);this.activeElement.querySelectorAll("td, th").forEach(t=>{t.style.minWidth=s+"px",t.style.minHeight=o+"px",t.style.height=o+"px"})}}else this.activeElement.style.width=t+"px",this.activeElement.style.height=e+"px","IFRAME"===this.activeElement.tagName&&(this.activeElement.width=t,this.activeElement.height=e)}getActiveElement(){return this.activeElement}setActiveElement(t){this.isResizableElement(t)&&this.showHandles(t)}checkAndUpdateHandles(){if(this.activeElement){if(!document.body.contains(this.activeElement)||!this.isResizableElement(this.activeElement))return void this.hideHandles();this.updateHandlePosition(),this.activeElement.classList.contains("rich-editor-table")&&this.checkTableSizeChange()}}refreshHandles(){this.activeElement&&document.body.contains(this.activeElement)&&this.updateHandlePosition()}setupTableSizeMonitoring(t){this.tableSizeInterval&&clearInterval(this.tableSizeInterval),this.tableSizeInterval=setInterval(()=>{this.activeElement&&this.activeElement.classList.contains("rich-editor-table")?this.checkTableSizeChange():(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null)},100)}checkTableSizeChange(){if(!this.activeElement||!this.activeElement.classList.contains("rich-editor-table"))return;const t=this.activeElement.offsetWidth,e=this.activeElement.offsetHeight;(Math.abs(t-this.lastTableWidth)>1||Math.abs(e-this.lastTableHeight)>1)&&(this.lastTableWidth=t,this.lastTableHeight=e,this.updateHandlePosition(),this.emit("table-size-changed",{element:this.activeElement,width:t,height:e,previousWidth:this.lastTableWidth,previousHeight:this.lastTableHeight}))}setupMutationObserver(){"undefined"!=typeof MutationObserver&&(this.mutationObserver=new MutationObserver(t=>{let e=!1;t.forEach(t=>{if(this.activeElement){if("childList"===t.type){if(t.removedNodes)for(let n of t.removedNodes)if(n===this.activeElement||n.contains(this.activeElement)){e=!0;break}(t.target===this.activeElement||t.target.nodeType===Node.ELEMENT_NODE&&this.activeElement.contains(t.target))&&(e=!0)}if("characterData"===t.type&&this.activeElement.classList.contains("rich-editor-table")){let n=t.target;for(;n&&n!==this.activeElement;)n=n.parentNode;n===this.activeElement&&(e=!0)}if("attributes"===t.type&&this.activeElement.classList.contains("rich-editor-table")){const n=t.attributeName;"style"!==n&&"class"!==n||(e=!0)}}}),e&&setTimeout(()=>{this.checkAndUpdateHandles()},0)}),this.mutationObserver.observe(this.editor.editor,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0,characterDataOldValue:!0}))}setMaintainAspectRatio(t){this.options.maintainAspectRatio=t}setConstraints(t,e,n,i){this.options.minWidth=t||this.options.minWidth,this.options.minHeight=e||this.options.minHeight,this.options.maxWidth=n||this.options.maxWidth,this.options.maxHeight=i||this.options.maxHeight}destroy(){this.hideHandles(),this.handlesContainer&&this.handlesContainer.remove(),this.tableSizeInterval&&(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),super.destroy()}}n.register("formats/bold",c,!0),n.register("formats/italic",d,!0),n.register("formats/underline",h,!0),n.register("formats/strike",u,!0),n.register("formats/subscript",m,!0),n.register("formats/superscript",p,!0),n.register("formats/color",T,!0),n.register("formats/background",I,!0),n.register("formats/link",L,!0),n.register("formats/table",N,!0),n.register("formats/heading",k,!0),n.register("formats/font-family",A,!0),n.register("formats/line-height",B,!0),n.register("formats/capitalization",P,!0),n.register("formats/text-align",V,!0),n.register("formats/list",z,!0),n.register("formats/indent",F,!0),n.register("formats/indent-increase",_,!0),n.register("formats/indent-decrease",D,!0),n.register("formats/emoji",Z,!0),n.register("formats/image",q,!0),n.register("formats/video",G,!0),n.register("formats/tag",K,!0),n.register("formats/text-size",Q,!0),n.register("formats/import",tt,!0),n.register("modules/toolbar",nt,!0),n.register("modules/history",it,!0),n.register("modules/block-toolbar",st,!0),n.register("modules/table-toolbar",ot,!0),n.register("modules/code-view",rt,!0),n.register("modules/resize-handles",lt,!0),n.register("ui/color-picker",E,!0),n.register("ui/text-align-picker",M,!0),n.register("ui/list-picker",O,!0),n.register("ui/emoji-picker",j,!0),n.register("ui/image-popup",U,!0),n.register("ui/video-popup",X,!0),n.register("ui/tag-popup",$,!0),n.register("ui/custom-button",et,!0),class{static loaded=!1;static styleElement=null;static async loadStyles(){if(!this.loaded)try{this.styleElement=document.createElement("style"),this.styleElement.id="rich-editor-styles";const t=await fetch(new URL("./styles.css","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("rich-editor.min.js",document.baseURI).href)),n=await t.text();this.styleElement.textContent=n,document.head.appendChild(this.styleElement),this.loaded=!0}catch(t){this.loadFallbackStyles()}}static loadFallbackStyles(){this.styleElement=document.createElement("style"),this.styleElement.id="rich-editor-styles-fallback",this.styleElement.textContent="\n .yjd-rich-editor { \n position: relative; \n background: #fff; \n border: 1px solid #ddd; \n border-radius: 4px; \n display: flex; \n flex-direction: column; \n font-family: system-ui, sans-serif; \n }\n .yjd-rich-editor .rich-editor-area { \n flex: 1; \n padding: 20px; \n outline: none; \n min-height: 100px; \n }\n .yjd-rich-editor .rich-editor-toolbar { \n display: flex; \n gap: 4px; \n padding: 8px; \n border-bottom: 1px solid #ddd; \n background: #f9f9f9; \n }\n .yjd-rich-editor .rich-editor-toolbar-btn { \n padding: 4px 8px; \n border: 1px solid #ccc; \n border-radius: 3px; \n background: #fff; \n cursor: pointer; \n }\n .yjd-rich-editor .table-grid-selector { \n position: absolute; \n background: white; \n border: 1px solid #ccc; \n border-radius: 4px; \n padding: 10px; \n box-shadow: 0 2px 8px rgba(0,0,0,0.15); \n z-index: 1000; \n display: none; \n }\n .yjd-rich-editor .table-grid-cell { \n width: 20px; \n height: 20px; \n border: 1px solid #ddd; \n cursor: pointer; \n background: white; \n }\n ",document.head.appendChild(this.styleElement),this.loaded=!0}static unloadStyles(){this.styleElement&&this.styleElement.parentNode&&(this.styleElement.parentNode.removeChild(this.styleElement),this.styleElement=null,this.loaded=!1)}static isLoaded(){return this.loaded}static async reloadStyles(){this.unloadStyles(),await this.loadStyles()}static addCustomCSS(t,e="rich-editor-custom"){const n=document.getElementById(e);n&&n.remove();const i=document.createElement("style");i.id=e,i.textContent=t,document.head.appendChild(i)}}.loadStyles().catch(t=>{});class at extends s{static register(t,e,i=!1){n.register(t,e,i)}static get(t){return n.get(t)}static create(t,e={}){return new at(t,e)}}t.Background=I,t.BlockFormat=l,t.BlockToolbar=st,t.Bold=c,t.Capitalization=P,t.CodeView=rt,t.Color=T,t.ColorPicker=E,t.Editor=s,t.Emoji=Z,t.EmojiPicker=j,t.FontFamily=A,t.Format=o,t.Heading=k,t.History=it,t.IconUtils=f,t.Image=q,t.ImagePopup=U,t.Import=tt,t.Indent=F,t.IndentDecrease=D,t.IndentIncrease=_,t.InlineFormat=r,t.Italic=d,t.LineHeight=B,t.Link=L,t.LinkPopup=x,t.List=z,t.ListPicker=O,t.Module=i,t.ResizeHandles=lt,t.Strike=u,t.Subscript=m,t.Superscript=p,t.Table=N,t.TablePopup=S,t.TableToolbar=ot,t.Tag=K,t.TagPopup=$,t.TextAlign=V,t.TextAlignPicker=M,t.TextSize=Q,t.Toolbar=nt,t.Underline=h,t.Video=G,t.VideoPopup=X,t.createCustomButton=et,t.createEditor=function(t,e={}){return new at(t,e)},t.default=at,t.registry=n,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
2
|
+
//# sourceMappingURL=rich-editor.min.js.map
|