@ryzeup/richtexteditor 1.0.16 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var lt=Object.defineProperty,ct=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var Ce=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable;var Re=(a,c,s)=>c in a?lt(a,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[c]=s,te=(a,c)=>{for(var s in c||(c={}))st.call(c,s)&&Re(a,s,c[s]);if(Ce)for(var s of Ce(c))ut.call(c,s)&&Re(a,s,c[s]);return a},ne=(a,c)=>ct(a,it(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),dt=require("react-dom");function mt(a){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const s in a)if(s!=="default"){const d=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(c,s,d.get?d:{enumerable:!0,get:()=>a[s]})}}return c.default=a,Object.freeze(c)}const ft=mt(n);window.React=ft;var Ae={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},xe=n.createContext&&n.createContext(Ae),gt=["attr","size","title"];function ht(a,c){if(a==null)return{};var s=pt(a,c),d,m;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(a);for(m=0;m<y.length;m++)d=y[m],!(c.indexOf(d)>=0)&&Object.prototype.propertyIsEnumerable.call(a,d)&&(s[d]=a[d])}return s}function pt(a,c){if(a==null)return{};var s={};for(var d in a)if(Object.prototype.hasOwnProperty.call(a,d)){if(c.indexOf(d)>=0)continue;s[d]=a[d]}return s}function X(){return X=Object.assign?Object.assign.bind():function(a){for(var c=1;c<arguments.length;c++){var s=arguments[c];for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(a[d]=s[d])}return a},X.apply(this,arguments)}function Le(a,c){var s=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);c&&(d=d.filter(function(m){return Object.getOwnPropertyDescriptor(a,m).enumerable})),s.push.apply(s,d)}return s}function Y(a){for(var c=1;c<arguments.length;c++){var s=arguments[c]!=null?arguments[c]:{};c%2?Le(Object(s),!0).forEach(function(d){vt(a,d,s[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(s)):Le(Object(s)).forEach(function(d){Object.defineProperty(a,d,Object.getOwnPropertyDescriptor(s,d))})}return a}function vt(a,c,s){return c=Et(c),c in a?Object.defineProperty(a,c,{value:s,enumerable:!0,configurable:!0,writable:!0}):a[c]=s,a}function Et(a){var c=yt(a,"string");return typeof c=="symbol"?c:c+""}function yt(a,c){if(typeof a!="object"||!a)return a;var s=a[Symbol.toPrimitive];if(s!==void 0){var d=s.call(a,c);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}function ze(a){return a&&a.map((c,s)=>n.createElement(c.tag,Y({key:s},c.attr),ze(c.child)))}function M(a){return c=>n.createElement(wt,X({attr:Y({},a.attr)},c),ze(a.child))}function wt(a){var c=s=>{var{attr:d,size:m,title:y}=a,S=ht(a,gt),C=m||s.size||"1em",E;return s.className&&(E=s.className),a.className&&(E=(E?E+" ":"")+a.className),n.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,d,S,{className:E,style:Y(Y({color:a.color||s.color},s.style),a.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),y&&n.createElement("title",null,y),a.children)};return xe!==void 0?n.createElement(xe.Consumer,null,s=>c(s)):c(Ae)}function bt(a){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(a)}function Ct(a){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(a)}function Rt(a){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(a)}function xt(a){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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"},child:[]}]})(a)}function Lt(a){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function St(a){return M({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(a)}function Mt(a){return M({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(a)}function At(a){return M({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(a)}function zt(a){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(a)}function Nt(a){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function kt(a){return M({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(a)}function Tt(a){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(a)}function Ot(a){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(a)}function Dt(a){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(a)}function jt(a){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(a)}const Ht=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],Ne=({exec:a,saveSelection:c,handleFileChange:s,handleFontSizeChange:d,handleFontFamilyChange:m,insertEmoji:y,handleLink:S,removeFormatting:C,visibleActions:E,className:O,style:H})=>{var q,k;const A=n.useRef(null),D=n.useRef(null),R=n.useRef(null),[Z,I]=n.useState(!1),[P,F]=n.useState({x:0,y:0});n.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&I(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const _=g=>{var j;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":a(w);break;case"insertImage":{(j=A.current)==null||j.click();break}default:console.warn("Unknown command:",w)}},Q=g=>{a("foreColor",g.target.value)},J=g=>{a("backColor",g.target.value)},[L,N]=n.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return n.useEffect(()=>{const g=()=>{N({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),n.createElement("div",{className:`rte-toolbar ${O||""}`,style:H},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:_,className:L.bold?"rte-active":""},n.createElement(St,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:_,className:L.italic?"rte-active":""},n.createElement(At,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:_,className:L.underline?"rte-active":""},n.createElement(Ot,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:_,title:"UnorderedList",className:L.unorderedList?"rte-active":""},n.createElement(Nt,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:_,className:L.orderedList?"rte-active":""},n.createElement(xt,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:S,className:L.link?"rte-active":""},n.createElement(zt,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),c(),C()},className:L.removeFormat?"rte-active":""},n.createElement(jt,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:_,className:L.image?"rte-active":""},n.createElement(Rt,null)),n.createElement("input",{type:"file",accept:"image/*",ref:A,style:{display:"none"},onChange:s}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),c();const w=g.currentTarget.getBoundingClientRect();F({x:w.left,y:w.bottom+8}),I(j=>!j)},className:L.emoji?"rte-active":""},n.createElement(kt,null)),Z&&dt.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:P.y,left:P.x}},Ht.map((g,w)=>n.createElement("span",{key:w,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:j=>{j.preventDefault(),y(g),I(!1)}},g))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),c(),(w=D.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((q=D.current)==null?void 0:q.value)||"#000",fontSize:"18px"},className:L.color?"rte-active":""},n.createElement(Dt,null)),n.createElement("input",{ref:D,type:"color",defaultValue:"#000000",onChange:g=>{var w;Q(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),c(),(w=R.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((k=R.current)==null?void 0:k.value)||"#000",fontSize:"18px"},className:L.highlight?"rte-active":""},n.createElement(Mt,null)),n.createElement("input",{ref:R,type:"color",onChange:g=>{var w;J(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&n.createElement(n.Fragment,null,n.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:L.alignLeft?"rte-active":""},n.createElement(Lt,null)),n.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:L.alignCenter?"rte-active":""},n.createElement(bt,null)),n.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:L.alignRight?"rte-active":""},n.createElement(Ct,null))),E.table&&n.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:L.table?"rte-active":""},n.createElement(Tt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Family"),n.createElement("option",{value:"Arial"},"Arial"),n.createElement("option",{value:"Georgia"},"Georgia"),n.createElement("option",{value:"Times New Roman"},"Times New Roman"),n.createElement("option",{value:"Courier New"},"Courier New"),n.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:d},n.createElement("option",{value:"",disabled:!0},"Font Size"),n.createElement("option",{value:"2"},"Small "),n.createElement("option",{value:"3"},"Normal"),n.createElement("option",{value:"4"},"Medium"),n.createElement("option",{value:"5"},"Large")))},_t=({show:a,position:c,filtered:s,insertMention:d,onClose:m,query:y})=>{const S=n.useRef(null);return n.useEffect(()=>{const C=E=>{S.current&&!S.current.contains(E.target)&&m()};return a&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[a,m]),a?n.createElement("ul",{ref:S,className:"rte-popup",style:{top:c.y,left:c.x}},s.length>0?s.map(({name:C,value:E})=>{const O=C.toLowerCase(),H=y.toLowerCase(),A=O.indexOf(H);let D=C;if(A!==-1&&y.length>0){const R=A+y.length;D=C.substring(0,A)+`<span class="rte-highlight">${C.substring(A,R)}</span>`+C.substring(R)}return n.createElement("li",{key:E,onMouseDown:R=>{R.preventDefault(),d({name:C,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:D},onMouseEnter:R=>R.currentTarget.style.background="#f0f0f0",onMouseLeave:R=>R.currentTarget.style.background="#fff"})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function Se(a){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(a)}function K(a){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(a)}const Ft=({visible:a,x:c,y:s,onAction:d,onClose:m})=>{if(!a)return null;const y={top:s,left:c};return n.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:m},n.createElement("button",{onClick:()=>d("insertRowAbove")},n.createElement(K,null)," Insert row above"),n.createElement("button",{onClick:()=>d("insertRowBelow")},n.createElement(K,null)," Insert row below"),n.createElement("button",{onClick:()=>d("insertColLeft")},n.createElement(K,null)," Insert col left"),n.createElement("button",{onClick:()=>d("insertColRight")},n.createElement(K,null)," Insert col right"),n.createElement("button",{onClick:()=>d("deleteRow")},n.createElement(Se,null)," Delete row"),n.createElement("button",{onClick:()=>d("deleteCol")},n.createElement(Se,null)," Delete column"))},ke=({html:a,className:c,style:s})=>{const d=y=>{const S=y.target;if(S.tagName==="A"){y.preventDefault();const C=S.href;C&&window.open(C,"_blank","noopener,noreferrer")}},m=y=>y.replace(/{{\s*(.*?)\s*}}/g,"$1");return n.createElement("div",{className:`rte-preview ${c||""}`,style:s,onClick:d,dangerouslySetInnerHTML:{__html:m(a)}})},Pt=({visible:a,linkData:c,onClose:s,onInsert:d})=>{const[m,y]=n.useState(""),[S,C]=n.useState(""),[E,O]=n.useState(""),[H,A]=n.useState("_self");if(n.useEffect(()=>{a?(y(c.url||""),C(c.text||""),O(c.title||""),A(c.target||"_self")):(y(""),C(""),O(""),A("_self"))},[a,c]),!a)return null;const D=()=>{d({url:m,text:S,title:E,target:H})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:s}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},m?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:m,onChange:R=>y(R.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:S,onChange:R=>C(R.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:R=>O(R.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:H,onChange:R=>A(R.target.value)},n.createElement("option",{value:"_self"},"Same tab"),n.createElement("option",{value:"_blank"},"New tab")),n.createElement("div",{className:"rte-link-modal__actions"},n.createElement("button",{className:"rte-link-modal__btn",onClick:s},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:D},"OK"))))};function Me(a){return Array.from(new Map(a.map(c=>[c.value,c])).values())}const qt=({atSuggestions:a=[],showOutput:c=!1,showPreview:s=!1,toolbarConfig:d={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:m={},styles:y={},handleGetHtml:S=()=>{},onChange:C=()=>{},value:E,onMentionSelect:O=()=>{},handleAddAttributes:H=()=>{}})=>{var fe,ge,he,pe,ve,Ee,ye,we;const A=n.useRef(null),[D,R]=n.useState(E!=null&&E.length?E:" "),[Z,I]=n.useState(""),[P,F]=n.useState(!1),[_,Q]=n.useState({x:0,y:0}),[J,L]=n.useState([]),N=n.useRef(null),q=n.useRef(null),[k,g]=n.useState({visible:!1,x:0,y:0}),[w,j]=n.useState(!1),U=n.useRef(null),[Te,re]=n.useState({url:"",text:"",title:"",target:"_self"}),Oe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(fe=d.link)!=null?fe:!1,image:(ge=d.image)!=null?ge:!1,emoji:(he=d.emoji)!=null?he:!1,table:(pe=d.table)!=null?pe:!1,color:(ve=d.color)!=null?ve:!1,fontFamily:(Ee=d.fontFamily)!=null?Ee:!1,fontSize:(ye=d.fontSize)!=null?ye:!1,highlight:(we=d.fontSize)!=null?we:!1},[De,ae]=n.useState(""),[oe,G]=n.useState([]),T=()=>A.current,x=()=>{const e=me();I(e),S==null||S(e);const t=rt(e);C(t);const r=Ie(),o=Me(r);JSON.stringify(o)!==JSON.stringify(oe)&&(G(o),O(o))},B=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const r=e.getRangeAt(0);t.contains(r.startContainer)&&(N.current=r.cloneRange())},V=()=>{const e=window.getSelection();!e||!N.current||(e.removeAllRanges(),e.addRange(N.current))},le=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(N.current=r.getRangeAt(0)),V(),document.execCommand(e,!1,t),x()};n.useEffect(()=>{const e=T();e&&!e.innerHTML&&(e.innerHTML=D),x()},[]),n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{H&&H(e=>{Be(e)})},[]),n.useEffect(()=>{const e=T();if(!e)return;e.querySelectorAll("table").forEach(r=>{ue(r),r.querySelectorAll("th, td").forEach(u=>W(u))})},[]);const ce=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},je=e=>{let t=0,r=e.parentElement;for(;r;)(r.tagName==="UL"||r.tagName==="OL")&&t++,r=r.parentElement;return t},He=e=>{const t=e.querySelector("li"),r=t?je(t):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${r>1?r:""}}}`,u=`{{/arrayData${r>1?r:""}}}`,l=document.createElement("span");l.textContent=o,l.style.display="none",l.setAttribute("data-hidden-array-start","true"),e.insertBefore(l,e.firstChild);const i=document.createElement("span");i.textContent=u,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},ie=e=>{var v;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),o=ce(r.startContainer);let u,l;if(o){let f=o.querySelector(e);f||(f=document.createElement(e),f.style.margin="0",f.style.paddingLeft="20px",o.appendChild(f)),l=f,u=document.createElement("li"),u.textContent="​",l.appendChild(u)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const f=T();if(l=f==null?void 0:f.querySelector(`${e}:last-child`),!l)return;u=l.querySelector("li:last-child")}He(l);const i=document.createRange();i.setStart(u,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),(v=T())==null||v.focus(),x()},$=(e,t)=>{e==="insertOrderedList"?ie("ol"):e==="insertUnorderedList"?ie("ul"):e.startsWith("justify")?ot(e):le(e,t),e==="insertTable"&&Xe()},_e=e=>{const t=document.createElement("span");t.textContent="​",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),Q({x:r.left,y:r.bottom+window.scrollY}),L(a||[]),F(!0),q.current=e.cloneRange()},Fe=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[r]?o=o.childNodes[r]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const u=o.textContent||"",l=o===t?r:u.length,i=u.lastIndexOf("@",l-1);if(i!==-1){const v=document.createRange();return v.setStart(o,i),v.setEnd(o,l),v}}o=o.previousSibling}return null},Pe=e=>{var l;const t=window.getSelection();if(!t)return;const r=Fe();r?(t.removeAllRanges(),t.addRange(r)):q.current&&(t.removeAllRanges(),t.addRange(q.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.color="#007bff",o.style.display="inline",o.contentEditable="false",o.setAttribute("data-mention",e.value||e.name||"");try{const i=t.rangeCount?t.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(o);else{const p=document.createRange(),h=T();p.selectNodeContents(h),p.collapse(!1),p.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const f=document.createRange();f.setStartAfter(v),f.collapse(!0),t.removeAllRanges(),t.addRange(f)}catch(i){console.error("insertMention error:",i)}let u=Me([...oe,e]);G(u),O(u),F(!1),(l=T())==null||l.focus(),x()},qe=e=>{const t=T();if(!t)return;let r=null;N.current&&t.contains(N.current.startContainer)?r=N.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(r);const u=document.createElement("span");u.textContent=`{{${e.name}}}`,u.style.color="#007bff",u.style.display="inline",u.contentEditable="false",u.setAttribute("data-mention",e.value||e.name),r.insertNode(u);const l=document.createTextNode(" ");u.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),o.removeAllRanges(),o.addRange(i),N.current=i.cloneRange(),t.focus()},Be=e=>{e.forEach(t=>qe(t)),G(t=>{const r=[...t,...e],o=Array.from(new Map(r.map(u=>[u.name,u])).values());return O(o),o}),x()},Ie=()=>{const e=T();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(o=>{const u=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:u})}),r},Ve=e=>{var r,o,u;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),$(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),i=l!=null&&l.anchorNode?ce(l.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=i.parentElement,p=f==null?void 0:f.closest("li");if(p){f==null||f.removeChild(i);const h=document.createElement("p");h.innerHTML="<br />",(o=p.parentElement)==null||o.insertBefore(h,p.nextSibling);const b=document.createRange();b.setStart(h,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}else{const h=i.closest("ul, ol");if(h){const b=document.createElement("p");b.innerHTML="<br />",(u=h.parentElement)==null||u.insertBefore(b,h.nextSibling),h.removeChild(i);const z=document.createRange();z.setStart(b,0),z.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(z)}}x()}}},Ue=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.anchorNode;if($e(o))return;setTimeout(()=>{_e(r.getRangeAt(0)),ae(""),L(a),F(!0)},0);return}if(P){setTimeout(()=>se(),0);return}},$e=e=>{if(!e)return!1;let t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;t;){if(t.tagName==="TH")return!0;t=t.parentElement}return!1},se=()=>{if(x(),!P)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const r=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!r){F(!1);return}const o=r[1].toLowerCase();ae(o);const u=a.filter(l=>l.name.toLowerCase().includes(o));L(u)},We=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const r=new FileReader;r.onload=u=>{var z;const l=(z=u.target)==null?void 0:z.result;V();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const f=document.createElement("img");f.src=l,f.alt=t.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const p=T();if(!v||!p){p==null||p.appendChild(f);const be=document.createTextNode(" ");p==null||p.appendChild(be);const ee=document.createRange();ee.setStartAfter(be),ee.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ee),p==null||p.focus(),x(),e.target.value="";return}v.deleteContents(),v.insertNode(f);const h=document.createTextNode(" ");f.after(h);const b=document.createRange();b.setStartAfter(h),b.collapse(!0),i.removeAllRanges(),i.addRange(b),p.focus(),x(),e.target.value=""},r.readAsDataURL(t)},Ke=e=>{var u;V();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),o=document.createTextNode(e);r.insertNode(o),r.setStartAfter(o),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(u=T())==null||u.focus(),x()},Xe=()=>{V();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",m.table&&e.classList.add(m.table);const t=document.createElement("thead");m.thead&&t.classList.add(m.thead);const r=document.createElement("tbody");m.tbody&&r.classList.add(m.tbody);const o=document.createElement("tr");m.tr&&o.classList.add(m.tr);const u=document.createElement("tr");m.tr&&u.classList.add(m.tr);for(let v=0;v<2;v++){const f=document.createElement("th");f.textContent=`Header ${v+1}`,f.style.border="1px solid #999",f.style.padding="8px",f.style.position="relative",f.style.backgroundColor="lightgray",m.th&&f.classList.add(m.th);const p=document.createElement("td");p.textContent=`Row 1 Col ${v+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",m.td&&p.classList.add(m.td),W(f),W(p),o.appendChild(f),u.appendChild(p)}t.appendChild(o),r.appendChild(u),e.appendChild(t),e.appendChild(r),Je(e),ue(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;l.getRangeAt(0).insertNode(e),x()},ue=e=>{const t=document.createElement("div");Object.assign(t.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let r=0,o=0,u=0,l=0;t.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,o=i.clientY;const v=e.getBoundingClientRect();u=v.width,l=v.height;const f=h=>{const b=Math.max(100,u+(h.clientX-r)),z=Math.max(60,l+(h.clientY-o));e.style.width=`${b}px`,e.style.height=`${z}px`,x()},p=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),x()};document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)}),e.appendChild(t)},W=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Ye(e,t,r),e.appendChild(t),e.appendChild(r)},Ye=(e,t,r)=>{let o=0,u=0,l=0,i=0;t.addEventListener("mousedown",h=>{h.preventDefault(),o=h.clientX,l=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",p)}),r.addEventListener("mousedown",h=>{h.preventDefault(),u=h.clientY,i=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)});const v=h=>{const b=l+(h.clientX-o);e.style.width=`${Math.max(30,b)}px`,x()},f=h=>{const b=i+(h.clientY-u);e.style.height=`${Math.max(20,b)}px`,x()},p=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),x()}},Ze=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},de=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Qe=e=>{if(!k.cell)return;const t=k.cell.closest("table"),r=k.cell.cellIndex,o=k.cell.parentElement.rowIndex,u=l=>{const i=l.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=l.textContent||"",v.style.cssText=l.style.cssText,W(v),v};switch(e){case"insertRowAbove":{const l=t.rows[o],i=t.insertRow(o);Array.from(l.cells).forEach(v=>{i.appendChild(u(v))});break}case"insertRowBelow":{const l=t.rows[o],i=t.insertRow(o+1);Array.from(l.cells).forEach(v=>{i.appendChild(u(v))});break}case"insertColLeft":{Array.from(t.rows).forEach(l=>{const i=l.cells[r];l.insertBefore(u(i),i)});break}case"insertColRight":{Array.from(t.rows).forEach(l=>{const i=l.cells[r];l.insertBefore(u(i),i.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(l=>{l.cells[r]&&l.deleteCell(r)});break}x(),g(ne(te({},k),{visible:!1})),de()},Je=e=>{const t=e.querySelector("tbody");if(!t||t.querySelector("[data-hidden-table-start]"))return;const r=document.createElement("span");r.textContent="{{#arrayData}}",r.style.display="none",r.setAttribute("data-hidden-table-start","true"),t.insertBefore(r,t.firstChild);const o=document.createElement("span");o.textContent="{{/arrayData}}",o.style.display="none",o.setAttribute("data-hidden-table-end","true"),t.appendChild(o)},me=()=>{const e=T();if(!e)return D;const t=e.cloneNode(!0);return t.querySelectorAll("table div").forEach(r=>r.remove()),t.querySelectorAll(".rte-cell-highlight").forEach(r=>r.classList.remove("rte-cell-highlight")),t.innerHTML},Ge=()=>{B(),U.current=N.current,re({url:"",text:"",title:"",target:"_self"}),j(!0)},et=e=>{const t=window.getSelection();if(!t||!U.current)return;t.removeAllRanges(),t.addRange(U.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const o=document.createElement("a");o.href=r,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||r,o.title=e.title,o.target=e.target,o.contentEditable="true";const u=t.getRangeAt(0);u.deleteContents(),u.insertNode(o);const l=document.createTextNode(" ");o.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),t.removeAllRanges(),t.addRange(i),j(!1),x()},tt=e=>{const t=e.target;if(t.tagName==="A"){const r=t;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(r),U.current=o,re({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),j(!0)}},nt=()=>{const e=T();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&N.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(N.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const u=o.cloneContents(),l=document.createElement("div");l.appendChild(u);const i=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const h=i.currentNode,b=h.tagName.toUpperCase(),z=h.getAttribute&&h.getAttribute("data-mention")!==null;b!=="A"&&!z&&v.push(h)}for(let h=v.length-1;h>=0;h--){const b=v[h],z=b.parentNode;if(z){for(;b.firstChild;)z.insertBefore(b.firstChild,b);z.removeChild(b)}}l.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),o.deleteContents();const f=document.createDocumentFragment();for(;l.firstChild;)f.appendChild(l.firstChild);o.insertNode(f);const p=document.createRange();p.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),p.collapse(!0),r.removeAllRanges(),r.addRange(p),e.normalize(),x()},rt=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=t,r.querySelectorAll("br").forEach(u=>{u.replaceWith(`
2
- `)}),r.querySelectorAll("p, div, tr").forEach(u=>{u.insertAdjacentText("afterend",`
3
- `)}),r.querySelectorAll("table").forEach(u=>{u.insertAdjacentText("afterend",`
4
- `)}),((o=r.textContent)==null?void 0:o.replace(/\n{3,}/g,`
1
+ "use strict";var ct=Object.defineProperty,it=Object.defineProperties;var st=Object.getOwnPropertyDescriptors;var be=Object.getOwnPropertySymbols;var ut=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var Ce=(r,c,s)=>c in r?ct(r,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[c]=s,te=(r,c)=>{for(var s in c||(c={}))ut.call(c,s)&&Ce(r,s,c[s]);if(be)for(var s of be(c))dt.call(c,s)&&Ce(r,s,c[s]);return r},ne=(r,c)=>it(r,st(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),mt=require("react-dom");function ft(r){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const d=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(c,s,d.get?d:{enumerable:!0,get:()=>r[s]})}}return c.default=r,Object.freeze(c)}const gt=ft(t);window.React=gt;var Me={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Re=t.createContext&&t.createContext(Me),ht=["attr","size","title"];function pt(r,c){if(r==null)return{};var s=vt(r,c),d,m;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(r);for(m=0;m<y.length;m++)d=y[m],!(c.indexOf(d)>=0)&&Object.prototype.propertyIsEnumerable.call(r,d)&&(s[d]=r[d])}return s}function vt(r,c){if(r==null)return{};var s={};for(var d in r)if(Object.prototype.hasOwnProperty.call(r,d)){if(c.indexOf(d)>=0)continue;s[d]=r[d]}return s}function Y(){return Y=Object.assign?Object.assign.bind():function(r){for(var c=1;c<arguments.length;c++){var s=arguments[c];for(var d in s)Object.prototype.hasOwnProperty.call(s,d)&&(r[d]=s[d])}return r},Y.apply(this,arguments)}function Le(r,c){var s=Object.keys(r);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(r);c&&(d=d.filter(function(m){return Object.getOwnPropertyDescriptor(r,m).enumerable})),s.push.apply(s,d)}return s}function Z(r){for(var c=1;c<arguments.length;c++){var s=arguments[c]!=null?arguments[c]:{};c%2?Le(Object(s),!0).forEach(function(d){Et(r,d,s[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(s)):Le(Object(s)).forEach(function(d){Object.defineProperty(r,d,Object.getOwnPropertyDescriptor(s,d))})}return r}function Et(r,c,s){return c=yt(c),c in r?Object.defineProperty(r,c,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[c]=s,r}function yt(r){var c=wt(r,"string");return typeof c=="symbol"?c:c+""}function wt(r,c){if(typeof r!="object"||!r)return r;var s=r[Symbol.toPrimitive];if(s!==void 0){var d=s.call(r,c);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(r)}function ze(r){return r&&r.map((c,s)=>t.createElement(c.tag,Z({key:s},c.attr),ze(c.child)))}function M(r){return c=>t.createElement(bt,Y({attr:Z({},r.attr)},c),ze(r.child))}function bt(r){var c=s=>{var{attr:d,size:m,title:y}=r,C=pt(r,ht),R=m||s.size||"1em",E;return s.className&&(E=s.className),r.className&&(E=(E?E+" ":"")+r.className),t.createElement("svg",Y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,d,C,{className:E,style:Z(Z({color:r.color||s.color},s.style),r.style),height:R,width:R,xmlns:"http://www.w3.org/2000/svg"}),y&&t.createElement("title",null,y),r.children)};return Re!==void 0?t.createElement(Re.Consumer,null,s=>c(s)):c(Me)}function Ct(r){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(r)}function Rt(r){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(r)}function Lt(r){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(r)}function xt(r){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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"},child:[]}]})(r)}function St(r){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(r)}function Mt(r){return M({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(r)}function zt(r){return M({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(r)}function At(r){return M({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(r)}function Nt(r){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(r)}function kt(r){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(r)}function Tt(r){return M({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(r)}function Dt(r){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(r)}function Ot(r){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(r)}function jt(r){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(r)}function Ht(r){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(r)}const _t=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],Ae=({exec:r,saveSelection:c,handleFileChange:s,handleFontSizeChange:d,handleFontFamilyChange:m,insertEmoji:y,handleLink:C,removeFormatting:R,visibleActions:E,className:D,style:H})=>{var I,k;const z=t.useRef(null),j=t.useRef(null),L=t.useRef(null),[U,q]=t.useState(!1),[F,P]=t.useState({x:0,y:0});t.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&q(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const _=g=>{var O;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":r(w);break;case"insertImage":{(O=z.current)==null||O.click();break}default:console.warn("Unknown command:",w)}},Q=g=>{r("foreColor",g.target.value)},J=g=>{r("backColor",g.target.value)},[S,N]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const g=()=>{N({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.createElement("div",{className:`rte-toolbar ${D||""}`,style:H},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:_,className:S.bold?"rte-active":""},t.createElement(Mt,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:_,className:S.italic?"rte-active":""},t.createElement(At,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:_,className:S.underline?"rte-active":""},t.createElement(Ot,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:_,title:"UnorderedList",className:S.unorderedList?"rte-active":""},t.createElement(kt,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:_,className:S.orderedList?"rte-active":""},t.createElement(xt,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:C,className:S.link?"rte-active":""},t.createElement(Nt,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),c(),R()},className:S.removeFormat?"rte-active":""},t.createElement(Ht,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:_,className:S.image?"rte-active":""},t.createElement(Lt,null)),t.createElement("input",{type:"file",accept:"image/*",ref:z,style:{display:"none"},onChange:s}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),c();const w=g.currentTarget.getBoundingClientRect();P({x:w.left,y:w.bottom+8}),q(O=>!O)},className:S.emoji?"rte-active":""},t.createElement(Tt,null)),U&&mt.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:F.y,left:F.x}},_t.map((g,w)=>t.createElement("span",{key:w,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:O=>{O.preventDefault(),y(g),q(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),c(),(w=j.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((I=j.current)==null?void 0:I.value)||"#000",fontSize:"18px"},className:S.color?"rte-active":""},t.createElement(jt,null)),t.createElement("input",{ref:j,type:"color",defaultValue:"#000000",onChange:g=>{var w;Q(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),c(),(w=L.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((k=L.current)==null?void 0:k.value)||"#000",fontSize:"18px"},className:S.highlight?"rte-active":""},t.createElement(zt,null)),t.createElement("input",{ref:L,type:"color",onChange:g=>{var w;J(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>r("justifyLeft"),className:S.alignLeft?"rte-active":""},t.createElement(St,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>r("justifyCenter"),className:S.alignCenter?"rte-active":""},t.createElement(Ct,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>r("justifyRight"),className:S.alignRight?"rte-active":""},t.createElement(Rt,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>r("insertTable"),className:S.table?"rte-active":""},t.createElement(Dt,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:d},t.createElement("option",{value:"",disabled:!0},"Font Size"),t.createElement("option",{value:"2"},"Small "),t.createElement("option",{value:"3"},"Normal"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large")))},Pt=({show:r,position:c,filtered:s,insertMention:d,onClose:m,query:y})=>{const C=t.useRef(null);return t.useEffect(()=>{const R=E=>{C.current&&!C.current.contains(E.target)&&m()};return r&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[r,m]),r?t.createElement("ul",{ref:C,className:"rte-popup",style:{top:c.y,left:c.x}},s.length>0?s.map(({name:R,value:E})=>{const D=R.toLowerCase(),H=y.toLowerCase(),z=D.indexOf(H);let j=R;if(z!==-1&&y.length>0){const L=z+y.length;j=R.substring(0,z)+`<span class="rte-highlight">${R.substring(z,L)}</span>`+R.substring(L)}return t.createElement("li",{key:E,onMouseDown:L=>{L.preventDefault(),d({name:R,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:j},onMouseEnter:L=>L.currentTarget.style.background="#f0f0f0",onMouseLeave:L=>L.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function xe(r){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(r)}function X(r){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(r)}const Ft=({visible:r,x:c,y:s,onAction:d,onClose:m})=>{if(!r)return null;const y={top:s,left:c};return t.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:m},t.createElement("button",{onClick:()=>d("insertRowAbove")},t.createElement(X,null)," Insert row above"),t.createElement("button",{onClick:()=>d("insertRowBelow")},t.createElement(X,null)," Insert row below"),t.createElement("button",{onClick:()=>d("insertColLeft")},t.createElement(X,null)," Insert col left"),t.createElement("button",{onClick:()=>d("insertColRight")},t.createElement(X,null)," Insert col right"),t.createElement("button",{onClick:()=>d("deleteRow")},t.createElement(xe,null)," Delete row"),t.createElement("button",{onClick:()=>d("deleteCol")},t.createElement(xe,null)," Delete column"))},Ne=({html:r,className:c,style:s})=>{const d=y=>{const C=y.target;if(C.tagName==="A"){y.preventDefault();const R=C.href;R&&window.open(R,"_blank","noopener,noreferrer")}},m=y=>{let C=y.replace(/{{\s*(.*?)\s*}}/g,"$1");return C=C.replace(/#arrayData/g,""),C=C.replace(/\/arrayData/g,""),C};return t.createElement("div",{className:`rte-preview ${c||""}`,style:s,onClick:d,dangerouslySetInnerHTML:{__html:m(r)}})},It=({visible:r,linkData:c,onClose:s,onInsert:d})=>{const[m,y]=t.useState(""),[C,R]=t.useState(""),[E,D]=t.useState(""),[H,z]=t.useState("_self");if(t.useEffect(()=>{r?(y(c.url||""),R(c.text||""),D(c.title||""),z(c.target||"_self")):(y(""),R(""),D(""),z("_self"))},[r,c]),!r)return null;const j=()=>{d({url:m,text:C,title:E,target:H})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:s}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},m?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:m,onChange:L=>y(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:C,onChange:L=>R(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:L=>D(L.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:H,onChange:L=>z(L.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:s},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:j},"OK"))))};function Se(r){return Array.from(new Map(r.map(c=>[c.value,c])).values())}const Bt=({atSuggestions:r=[],showOutput:c=!1,showPreview:s=!1,toolbarConfig:d={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:m={},styles:y={},handleGetHtml:C=()=>{},onChange:R=()=>{},value:E,onMentionSelect:D=()=>{},handleAddAttributes:H=()=>{}})=>{var me,fe,ge,he,pe,ve,Ee,ye;const z=t.useRef(null),[j,L]=t.useState(E!=null&&E.length?E:" "),[U,q]=t.useState(""),[F,P]=t.useState(!1),[_,Q]=t.useState({x:0,y:0}),[J,S]=t.useState([]),N=t.useRef(null),I=t.useRef(null),[k,g]=t.useState({visible:!1,x:0,y:0}),[w,O]=t.useState(!1),$=t.useRef(null),[ke,re]=t.useState({url:"",text:"",title:"",target:"_self"}),Te={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(me=d.link)!=null?me:!1,image:(fe=d.image)!=null?fe:!1,emoji:(ge=d.emoji)!=null?ge:!1,table:(he=d.table)!=null?he:!1,color:(pe=d.color)!=null?pe:!1,fontFamily:(ve=d.fontFamily)!=null?ve:!1,fontSize:(Ee=d.fontSize)!=null?Ee:!1,highlight:(ye=d.fontSize)!=null?ye:!1},[De,ae]=t.useState(""),[oe,G]=t.useState([]),T=()=>z.current,x=()=>{const e=Oe();q(e),C==null||C(e);const n=at(e);R(n);const a=Ue(),o=Se(a);JSON.stringify(o)!==JSON.stringify(oe)&&(G(o),D(o))},Oe=()=>{const e=T();if(!e)return j;const n=e.cloneNode(!0);n.querySelectorAll("table div").forEach(o=>o.remove()),n.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let a=n.innerHTML;return a=je(a),a},je=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),B=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const a=e.getRangeAt(0);n.contains(a.startContainer)&&(N.current=a.cloneRange())},V=()=>{const e=window.getSelection();!e||!N.current||(e.removeAllRanges(),e.addRange(N.current))},le=(e,n)=>{const a=window.getSelection();a&&a.rangeCount>0&&(N.current=a.getRangeAt(0)),V(),document.execCommand(e,!1,n),x()};t.useEffect(()=>{const e=T();if(!e||!E)return;const n=He(E);e.innerHTML=n,x()},[]);const He=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{H&&H(e=>{Ve(e)})},[]),t.useEffect(()=>{const e=T();if(!e)return;e.querySelectorAll("table").forEach(a=>{ue(a),a.querySelectorAll("th, td").forEach(u=>K(u))})},[]);const ce=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},_e=e=>{let n=0,a=e.parentElement;for(;a;)(a.tagName==="UL"||a.tagName==="OL")&&n++,a=a.parentElement;return n},Pe=e=>{const n=e.querySelector("li"),a=n?_e(n):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${a>1?a:""}}}`,u=`{{/arrayData${a>1?a:""}}}`,l=document.createElement("span");l.textContent=o,l.style.display="none",l.setAttribute("data-hidden-array-start","true"),e.insertBefore(l,e.firstChild);const i=document.createElement("span");i.textContent=u,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},ie=e=>{var v;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const a=n.getRangeAt(0),o=ce(a.startContainer);let u,l;if(o){let f=o.querySelector(e);f||(f=document.createElement(e),f.style.margin="0",f.style.paddingLeft="20px",o.appendChild(f)),l=f,u=document.createElement("li"),u.textContent="​",l.appendChild(u)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const f=T();if(l=f==null?void 0:f.querySelector(`${e}:last-child`),!l)return;u=l.querySelector("li:last-child")}Pe(l);const i=document.createRange();i.setStart(u,0),i.collapse(!0),n.removeAllRanges(),n.addRange(i),(v=T())==null||v.focus(),x()},W=(e,n)=>{e==="insertOrderedList"?ie("ol"):e==="insertUnorderedList"?ie("ul"):e.startsWith("justify")?lt(e):le(e,n),e==="insertTable"&&Ze()},Fe=e=>{const n=document.createElement("span");n.textContent="​",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const a=n.getBoundingClientRect();n.remove(),Q({x:a.left,y:a.bottom+window.scrollY}),S(r||[]),P(!0),I.current=e.cloneRange()},Ie=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let a=e.anchorOffset;if(!n)return null;let o=n;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[a]?o=o.childNodes[a]:o=n.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const u=o.textContent||"",l=o===n?a:u.length,i=u.lastIndexOf("@",l-1);if(i!==-1){const v=document.createRange();return v.setStart(o,i),v.setEnd(o,l),v}}o=o.previousSibling}return null},Be=e=>{var l;const n=window.getSelection();if(!n)return;const a=Ie();a?(n.removeAllRanges(),n.addRange(a)):I.current&&(n.removeAllRanges(),n.addRange(I.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.contentEditable="false",o.setAttribute("data-mention",e.value||e.name||"");try{const i=n.rangeCount?n.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(o);else{const p=document.createRange(),h=T();p.selectNodeContents(h),p.collapse(!1),p.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const f=document.createRange();f.setStartAfter(v),f.collapse(!0),n.removeAllRanges(),n.addRange(f)}catch(i){console.error("insertMention error:",i)}let u=Se([...oe,e]);G(u),D(u),P(!1),(l=T())==null||l.focus(),x()},qe=e=>{const n=T();if(!n)return;let a=null;N.current&&n.contains(N.current.startContainer)?a=N.current.cloneRange():(a=document.createRange(),a.selectNodeContents(n),a.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(a);const u=document.createElement("span");u.textContent=`{{${e.name}}}`,u.style.display="inline",u.contentEditable="false",u.setAttribute("data-mention",e.value||e.name),a.insertNode(u);const l=document.createTextNode(" ");u.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),o.removeAllRanges(),o.addRange(i),N.current=i.cloneRange(),n.focus()},Ve=e=>{e.forEach(n=>qe(n)),G(n=>{const a=[...n,...e],o=Array.from(new Map(a.map(u=>[u.name,u])).values());return D(o),o}),x()},Ue=()=>{const e=T();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),a=[];return n.forEach(o=>{const u=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&a.push({name:i[1],value:u})}),a},$e=e=>{var a,o,u;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),W(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),i=l!=null&&l.anchorNode?ce(l.anchorNode):null;if(!i)return;if(((a=i.textContent)==null?void 0:a.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=i.parentElement,p=f==null?void 0:f.closest("li");if(p){f==null||f.removeChild(i);const h=document.createElement("p");h.innerHTML="<br />",(o=p.parentElement)==null||o.insertBefore(h,p.nextSibling);const b=document.createRange();b.setStart(h,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}else{const h=i.closest("ul, ol");if(h){const b=document.createElement("p");b.innerHTML="<br />",(u=h.parentElement)==null||u.insertBefore(b,h.nextSibling),h.removeChild(i);const A=document.createRange();A.setStart(b,0),A.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(A)}}x()}}},We=e=>{if(e.data==="@"){const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const o=a.anchorNode;if(Ke(o))return;setTimeout(()=>{Fe(a.getRangeAt(0)),ae(""),S(r),P(!0)},0);return}if(F){setTimeout(()=>se(),0);return}},Ke=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},se=()=>{if(x(),!F)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const a=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!a){P(!1);return}const o=a[1].toLowerCase();ae(o);const u=r.filter(l=>l.name.toLowerCase().includes(o));S(u)},Xe=e=>{var o;const n=(o=e.target.files)==null?void 0:o[0];if(!n)return;const a=new FileReader;a.onload=u=>{var A;const l=(A=u.target)==null?void 0:A.result;V();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const f=document.createElement("img");f.src=l,f.alt=n.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const p=T();if(!v||!p){p==null||p.appendChild(f);const we=document.createTextNode(" ");p==null||p.appendChild(we);const ee=document.createRange();ee.setStartAfter(we),ee.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ee),p==null||p.focus(),x(),e.target.value="";return}v.deleteContents(),v.insertNode(f);const h=document.createTextNode(" ");f.after(h);const b=document.createRange();b.setStartAfter(h),b.collapse(!0),i.removeAllRanges(),i.addRange(b),p.focus(),x(),e.target.value=""},a.readAsDataURL(n)},Ye=e=>{var u;V();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const a=n.getRangeAt(0),o=document.createTextNode(e);a.insertNode(o),a.setStartAfter(o),a.collapse(!0),n.removeAllRanges(),n.addRange(a),(u=T())==null||u.focus(),x()},Ze=()=>{V();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",m.table&&e.classList.add(m.table);const n=document.createElement("thead");m.thead&&n.classList.add(m.thead);const a=document.createElement("tbody");m.tbody&&a.classList.add(m.tbody);const o=document.createElement("tr");m.tr&&o.classList.add(m.tr);const u=document.createElement("tr");m.tr&&u.classList.add(m.tr);for(let v=0;v<2;v++){const f=document.createElement("th");f.textContent=`Header ${v+1}`,f.style.border="1px solid #999",f.style.padding="8px",f.style.position="relative",f.style.backgroundColor="lightgray",m.th&&f.classList.add(m.th);const p=document.createElement("td");p.textContent=`Row 1 Col ${v+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",m.td&&p.classList.add(m.td),K(f),K(p),o.appendChild(f),u.appendChild(p)}n.appendChild(o),a.appendChild(u),e.appendChild(n),e.appendChild(a),ue(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;l.getRangeAt(0).insertNode(e),x()},ue=e=>{const n=document.createElement("div");Object.assign(n.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let a=0,o=0,u=0,l=0;n.addEventListener("mousedown",i=>{i.preventDefault(),a=i.clientX,o=i.clientY;const v=e.getBoundingClientRect();u=v.width,l=v.height;const f=h=>{const b=Math.max(100,u+(h.clientX-a)),A=Math.max(60,l+(h.clientY-o));e.style.width=`${b}px`,e.style.height=`${A}px`,x()},p=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),x()};document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)}),e.appendChild(n)},K=e=>{const n=document.createElement("div"),a=document.createElement("div");Object.assign(n.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(a.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Qe(e,n,a),e.appendChild(n),e.appendChild(a)},Qe=(e,n,a)=>{let o=0,u=0,l=0,i=0;n.addEventListener("mousedown",h=>{h.preventDefault(),o=h.clientX,l=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",p)}),a.addEventListener("mousedown",h=>{h.preventDefault(),u=h.clientY,i=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)});const v=h=>{const b=l+(h.clientX-o);e.style.width=`${Math.max(30,b)}px`,x()},f=h=>{const b=i+(h.clientY-u);e.style.height=`${Math.max(20,b)}px`,x()},p=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),x()}},Je=e=>{const a=e.target.closest("td, th");a&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),a.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:a}))},de=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Ge=e=>{if(!k.cell)return;const n=k.cell.closest("table"),a=k.cell.cellIndex,o=k.cell.parentElement.rowIndex,u=l=>{const i=l.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=l.textContent||"",v.style.cssText=l.style.cssText,K(v),v};switch(e){case"insertRowAbove":{const l=n.rows[o],i=n.insertRow(o);Array.from(l.cells).forEach(v=>{i.appendChild(u(v))});break}case"insertRowBelow":{const l=n.rows[o],i=n.insertRow(o+1);Array.from(l.cells).forEach(v=>{i.appendChild(u(v))});break}case"insertColLeft":{Array.from(n.rows).forEach(l=>{const i=l.cells[a];l.insertBefore(u(i),i)});break}case"insertColRight":{Array.from(n.rows).forEach(l=>{const i=l.cells[a];l.insertBefore(u(i),i.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(o);break;case"deleteCol":Array.from(n.rows).forEach(l=>{l.cells[a]&&l.deleteCell(a)});break}x(),g(ne(te({},k),{visible:!1})),de()},et=()=>{B(),$.current=N.current,re({url:"",text:"",title:"",target:"_self"}),O(!0)},tt=e=>{const n=window.getSelection();if(!n||!$.current)return;n.removeAllRanges(),n.addRange($.current);let a=e.url.trim();/^https?:\/\//i.test(a)||(a="https://"+a);const o=document.createElement("a");o.href=a,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||a,o.title=e.title,o.target=e.target,o.contentEditable="true";const u=n.getRangeAt(0);u.deleteContents(),u.insertNode(o);const l=document.createTextNode(" ");o.after(l);const i=document.createRange();i.setStartAfter(l),i.collapse(!0),n.removeAllRanges(),n.addRange(i),O(!1),x()},nt=e=>{const n=e.target;if(n.tagName==="A"){const a=n;if(e.ctrlKey||e.metaKey){window.open(a.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(a),$.current=o,re({url:a.href,text:a.textContent||a.href,title:a.title,target:a.target}),O(!0)}},rt=()=>{const e=T();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&N.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(N.current)}const a=window.getSelection();if(!a||a.rangeCount===0)return;const o=a.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const u=o.cloneContents(),l=document.createElement("div");l.appendChild(u);const i=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const h=i.currentNode,b=h.tagName.toUpperCase(),A=h.getAttribute&&h.getAttribute("data-mention")!==null;b!=="A"&&!A&&v.push(h)}for(let h=v.length-1;h>=0;h--){const b=v[h],A=b.parentNode;if(A){for(;b.firstChild;)A.insertBefore(b.firstChild,b);A.removeChild(b)}}l.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),o.deleteContents();const f=document.createDocumentFragment();for(;l.firstChild;)f.appendChild(l.firstChild);o.insertNode(f);const p=document.createRange();p.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),p.collapse(!0),a.removeAllRanges(),a.addRange(p),e.normalize(),x()},at=e=>{var o;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const a=document.createElement("div");return a.innerHTML=n,a.querySelectorAll("br").forEach(u=>{u.replaceWith(`
2
+ `)}),a.querySelectorAll("p, div, tr").forEach(u=>{u.insertAdjacentText("afterend",`
3
+ `)}),a.querySelectorAll("table").forEach(u=>{u.insertAdjacentText("afterend",`
4
+ `)}),((o=a.textContent)==null?void 0:o.replace(/\n{3,}/g,`
5
5
 
6
- `).trim())||""};function at(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0),r=t.commonAncestorContainer,o=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(l=>{const i=document.createRange();return i.selectNodeContents(l),t.compareBoundaryPoints(Range.END_TO_START,i)<0&&t.compareBoundaryPoints(Range.START_TO_END,i)>0})}function ot(e){const t=at();if(t.length===0){le(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),t.forEach(o=>{o.style.textAlign=r}),x()}return n.createElement("div",{className:`rte-wrapper ${(m==null?void 0:m.wrapper)||""}`,style:y.wrapper},n.createElement("div",{style:{flex:1}},n.createElement(Ne,{exec:$,saveSelection:B,handleFileChange:We,handleFontSizeChange:e=>$("fontSize",e.target.value),handleFontFamilyChange:e=>$("fontName",e.target.value),insertEmoji:Ke,handleLink:Ge,removeFormatting:nt,visibleActions:Oe,className:m.toolbar,style:y.toolbar}),n.createElement("div",{ref:A,id:"rte-editor-body",className:`rte-editor ${(m==null?void 0:m.editor)||""}`,style:y.editor,contentEditable:!0,suppressContentEditableWarning:!0,onKeyUp:B,onMouseUp:B,onInput:()=>{se(),B()},onKeyDown:Ve,onBeforeInput:Ue,onContextMenu:Ze,onClick:e=>{tt(e),B()}}),n.createElement(_t,{show:P,position:_,filtered:J,insertMention:Pe,onClose:()=>F(!1),query:De}),c&&n.createElement("div",{className:`rte-output ${(m==null?void 0:m.output)||""}`,style:y.output},n.createElement("h4",null,"Output HTML:"),n.createElement("p",null,Z)),n.createElement(Ft,{visible:k.visible,x:k.x,y:k.y,onAction:Qe,onClose:()=>{g(ne(te({},k),{visible:!1})),de()}}),n.createElement(Pt,{visible:w,linkData:Te,onClose:()=>j(!1),onInsert:et})),s?n.createElement(ke,{className:m.preview,style:y.preview,html:me()}):null)};exports.RichTextEditor=qt;exports.RtePreview=ke;exports.RteToolbar=Ne;
6
+ `).trim())||""};function ot(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const n=e.getRangeAt(0),a=n.commonAncestorContainer,o=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(l=>{const i=document.createRange();return i.selectNodeContents(l),n.compareBoundaryPoints(Range.END_TO_START,i)<0&&n.compareBoundaryPoints(Range.START_TO_END,i)>0})}function lt(e){const n=ot();if(n.length===0){le(e);return}let a="left";e==="justifyCenter"&&(a="center"),e==="justifyRight"&&(a="right"),n.forEach(o=>{o.style.textAlign=a}),x()}return t.createElement("div",{className:`rte-wrapper ${(m==null?void 0:m.wrapper)||""}`,style:y.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(Ae,{exec:W,saveSelection:B,handleFileChange:Xe,handleFontSizeChange:e=>W("fontSize",e.target.value),handleFontFamilyChange:e=>W("fontName",e.target.value),insertEmoji:Ye,handleLink:et,removeFormatting:rt,visibleActions:Te,className:m.toolbar,style:y.toolbar}),t.createElement("div",{ref:z,id:"rte-editor-body",className:`rte-editor ${(m==null?void 0:m.editor)||""}`,style:y.editor,contentEditable:!0,suppressContentEditableWarning:!0,onKeyUp:B,onMouseUp:B,onInput:()=>{se(),B()},onKeyDown:$e,onBeforeInput:We,onContextMenu:Je,onClick:e=>{nt(e),B()}}),t.createElement(Pt,{show:F,position:_,filtered:J,insertMention:Be,onClose:()=>P(!1),query:De}),c&&t.createElement("div",{className:`rte-output ${(m==null?void 0:m.output)||""}`,style:y.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,U)),t.createElement(Ft,{visible:k.visible,x:k.x,y:k.y,onAction:Ge,onClose:()=>{g(ne(te({},k),{visible:!1})),de()}}),t.createElement(It,{visible:w,linkData:ke,onClose:()=>O(!1),onInsert:tt})),s?t.createElement(Ne,{className:m.preview,style:y.preview,html:U}):null)};exports.RichTextEditor=Bt;exports.RtePreview=Ne;exports.RteToolbar=Ae;
package/dist/index.umd.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(L,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(L=typeof globalThis!="undefined"?globalThis:L||self,t(L.RichTextEditor={},L.React,L.ReactDOM))})(this,(function(L,t,O){"use strict";var Ft=Object.defineProperty,Pt=Object.defineProperties;var qt=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,It=Object.prototype.propertyIsEnumerable;var De=(L,t,O)=>t in L?Ft(L,t,{enumerable:!0,configurable:!0,writable:!0,value:O}):L[t]=O,re=(L,t)=>{for(var O in t||(t={}))Bt.call(t,O)&&De(L,O,t[O]);if(Oe)for(var O of Oe(t))It.call(t,O)&&De(L,O,t[O]);return L},oe=(L,t)=>Pt(L,qt(t));function je(o){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const d in o)if(d!=="default"){const u=Object.getOwnPropertyDescriptor(o,d);Object.defineProperty(s,d,u.get?u:{enumerable:!0,get:()=>o[d]})}}return s.default=o,Object.freeze(s)}const He=je(t);window.React=He;var le={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ae=t.createContext&&t.createContext(le),_e=["attr","size","title"];function Fe(o,s){if(o==null)return{};var d=Pe(o,s),u,m;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(o);for(m=0;m<y.length;m++)u=y[m],!(s.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(o,u)&&(d[u]=o[u])}return d}function Pe(o,s){if(o==null)return{};var d={};for(var u in o)if(Object.prototype.hasOwnProperty.call(o,u)){if(s.indexOf(u)>=0)continue;d[u]=o[u]}return d}function W(){return W=Object.assign?Object.assign.bind():function(o){for(var s=1;s<arguments.length;s++){var d=arguments[s];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(o[u]=d[u])}return o},W.apply(this,arguments)}function ie(o,s){var d=Object.keys(o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(o);s&&(u=u.filter(function(m){return Object.getOwnPropertyDescriptor(o,m).enumerable})),d.push.apply(d,u)}return d}function K(o){for(var s=1;s<arguments.length;s++){var d=arguments[s]!=null?arguments[s]:{};s%2?ie(Object(d),!0).forEach(function(u){qe(o,u,d[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(d)):ie(Object(d)).forEach(function(u){Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(d,u))})}return o}function qe(o,s,d){return s=Be(s),s in o?Object.defineProperty(o,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):o[s]=d,o}function Be(o){var s=Ie(o,"string");return typeof s=="symbol"?s:s+""}function Ie(o,s){if(typeof o!="object"||!o)return o;var d=o[Symbol.toPrimitive];if(d!==void 0){var u=d.call(o,s);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(o)}function se(o){return o&&o.map((s,d)=>t.createElement(s.tag,K({key:d},s.attr),se(s.child)))}function z(o){return s=>t.createElement(Ve,W({attr:K({},o.attr)},s),se(o.child))}function Ve(o){var s=d=>{var{attr:u,size:m,title:y}=o,A=Fe(o,_e),b=m||d.size||"1em",E;return d.className&&(E=d.className),o.className&&(E=(E?E+" ":"")+o.className),t.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,u,A,{className:E,style:K(K({color:o.color||d.color},d.style),o.style),height:b,width:b,xmlns:"http://www.w3.org/2000/svg"}),y&&t.createElement("title",null,y),o.children)};return ae!==void 0?t.createElement(ae.Consumer,null,d=>s(d)):s(le)}function Ue(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(o)}function $e(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function Re(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function We(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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"},child:[]}]})(o)}function Ke(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Xe(o){return z({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function Ye(o){return z({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function Ze(o){return z({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function Qe(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(o)}function Je(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Ge(o){return z({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(o)}function et(o){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(o)}function tt(o){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function nt(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(o)}function rt(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(o)}const ot=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ce=({exec:o,saveSelection:s,handleFileChange:d,handleFontSizeChange:u,handleFontFamilyChange:m,insertEmoji:y,handleLink:A,removeFormatting:b,visibleActions:E,className:H,style:P})=>{var V,D;const N=t.useRef(null),_=t.useRef(null),x=t.useRef(null),[J,$]=t.useState(!1),[I,B]=t.useState({x:0,y:0});t.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&$(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const q=g=>{var F;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":o(w);break;case"insertImage":{(F=N.current)==null||F.click();break}default:console.warn("Unknown command:",w)}},G=g=>{o("foreColor",g.target.value)},ee=g=>{o("backColor",g.target.value)},[M,k]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const g=()=>{k({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.createElement("div",{className:`rte-toolbar ${H||""}`,style:P},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:q,className:M.bold?"rte-active":""},t.createElement(Xe,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:q,className:M.italic?"rte-active":""},t.createElement(Ze,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:q,className:M.underline?"rte-active":""},t.createElement(tt,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:q,title:"UnorderedList",className:M.unorderedList?"rte-active":""},t.createElement(Je,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:q,className:M.orderedList?"rte-active":""},t.createElement(We,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:A,className:M.link?"rte-active":""},t.createElement(Qe,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),s(),b()},className:M.removeFormat?"rte-active":""},t.createElement(rt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:q,className:M.image?"rte-active":""},t.createElement(Re,null)),t.createElement("input",{type:"file",accept:"image/*",ref:N,style:{display:"none"},onChange:d}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),s();const w=g.currentTarget.getBoundingClientRect();B({x:w.left,y:w.bottom+8}),$(F=>!F)},className:M.emoji?"rte-active":""},t.createElement(Ge,null)),J&&O.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:I.y,left:I.x}},ot.map((g,w)=>t.createElement("span",{key:w,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:F=>{F.preventDefault(),y(g),$(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),s(),(w=_.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=_.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:M.color?"rte-active":""},t.createElement(nt,null)),t.createElement("input",{ref:_,type:"color",defaultValue:"#000000",onChange:g=>{var w;G(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),s(),(w=x.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((D=x.current)==null?void 0:D.value)||"#000",fontSize:"18px"},className:M.highlight?"rte-active":""},t.createElement(Ye,null)),t.createElement("input",{ref:x,type:"color",onChange:g=>{var w;ee(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyLeft"),className:M.alignLeft?"rte-active":""},t.createElement(Ke,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyCenter"),className:M.alignCenter?"rte-active":""},t.createElement(Ue,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyRight"),className:M.alignRight?"rte-active":""},t.createElement($e,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertTable"),className:M.table?"rte-active":""},t.createElement(et,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:u},t.createElement("option",{value:"",disabled:!0},"Font Size"),t.createElement("option",{value:"2"},"Small "),t.createElement("option",{value:"3"},"Normal"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large")))},lt=({show:o,position:s,filtered:d,insertMention:u,onClose:m,query:y})=>{const A=t.useRef(null);return t.useEffect(()=>{const b=E=>{A.current&&!A.current.contains(E.target)&&m()};return o&&document.addEventListener("mousedown",b),()=>{document.removeEventListener("mousedown",b)}},[o,m]),o?t.createElement("ul",{ref:A,className:"rte-popup",style:{top:s.y,left:s.x}},d.length>0?d.map(({name:b,value:E})=>{const H=b.toLowerCase(),P=y.toLowerCase(),N=H.indexOf(P);let _=b;if(N!==-1&&y.length>0){const x=N+y.length;_=b.substring(0,N)+`<span class="rte-highlight">${b.substring(N,x)}</span>`+b.substring(x)}return t.createElement("li",{key:E,onMouseDown:x=>{x.preventDefault(),u({name:b,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:_},onMouseEnter:x=>x.currentTarget.style.background="#f0f0f0",onMouseLeave:x=>x.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ue(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function X(o){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(o)}const at=({visible:o,x:s,y:d,onAction:u,onClose:m})=>{if(!o)return null;const y={top:d,left:s};return t.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:m},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(X,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(X,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(X,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(X,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(ue,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(ue,null)," Delete column"))},de=({html:o,className:s,style:d})=>{const u=y=>{const A=y.target;if(A.tagName==="A"){y.preventDefault();const b=A.href;b&&window.open(b,"_blank","noopener,noreferrer")}},m=y=>y.replace(/{{\s*(.*?)\s*}}/g,"$1");return t.createElement("div",{className:`rte-preview ${s||""}`,style:d,onClick:u,dangerouslySetInnerHTML:{__html:m(o)}})},it=({visible:o,linkData:s,onClose:d,onInsert:u})=>{const[m,y]=t.useState(""),[A,b]=t.useState(""),[E,H]=t.useState(""),[P,N]=t.useState("_self");if(t.useEffect(()=>{o?(y(s.url||""),b(s.text||""),H(s.title||""),N(s.target||"_self")):(y(""),b(""),H(""),N("_self"))},[o,s]),!o)return null;const _=()=>{u({url:m,text:A,title:E,target:P})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},m?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:m,onChange:x=>y(x.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:A,onChange:x=>b(x.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:x=>H(x.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:P,onChange:x=>N(x.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:_},"OK"))))};function me(o){return Array.from(new Map(o.map(s=>[s.value,s])).values())}const st=({atSuggestions:o=[],showOutput:s=!1,showPreview:d=!1,toolbarConfig:u={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:m={},styles:y={},handleGetHtml:A=()=>{},onChange:b=()=>{},value:E,onMentionSelect:H=()=>{},handleAddAttributes:P=()=>{}})=>{var xe,Le,Se,Me,Ae,ze,Ne,Te;const N=t.useRef(null),[_,x]=t.useState(E!=null&&E.length?E:" "),[J,$]=t.useState(""),[I,B]=t.useState(!1),[q,G]=t.useState({x:0,y:0}),[ee,M]=t.useState([]),k=t.useRef(null),V=t.useRef(null),[D,g]=t.useState({visible:!1,x:0,y:0}),[w,F]=t.useState(!1),Y=t.useRef(null),[ct,fe]=t.useState({url:"",text:"",title:"",target:"_self"}),ut={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(xe=u.link)!=null?xe:!1,image:(Le=u.image)!=null?Le:!1,emoji:(Se=u.emoji)!=null?Se:!1,table:(Me=u.table)!=null?Me:!1,color:(Ae=u.color)!=null?Ae:!1,fontFamily:(ze=u.fontFamily)!=null?ze:!1,fontSize:(Ne=u.fontSize)!=null?Ne:!1,highlight:(Te=u.fontSize)!=null?Te:!1},[dt,ge]=t.useState(""),[he,te]=t.useState([]),j=()=>N.current,S=()=>{const e=be();$(e),A==null||A(e);const n=jt(e);b(n);const r=yt(),l=me(r);JSON.stringify(l)!==JSON.stringify(he)&&(te(l),H(l))},U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const r=e.getRangeAt(0);n.contains(r.startContainer)&&(k.current=r.cloneRange())},R=()=>{const e=window.getSelection();!e||!k.current||(e.removeAllRanges(),e.addRange(k.current))},pe=(e,n)=>{const r=window.getSelection();r&&r.rangeCount>0&&(k.current=r.getRangeAt(0)),R(),document.execCommand(e,!1,n),S()};t.useEffect(()=>{const e=j();e&&!e.innerHTML&&(e.innerHTML=_),S()},[]),t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{P&&P(e=>{Et(e)})},[]),t.useEffect(()=>{const e=j();if(!e)return;e.querySelectorAll("table").forEach(r=>{we(r),r.querySelectorAll("th, td").forEach(c=>Q(c))})},[]);const ve=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},mt=e=>{let n=0,r=e.parentElement;for(;r;)(r.tagName==="UL"||r.tagName==="OL")&&n++,r=r.parentElement;return n},ft=e=>{const n=e.querySelector("li"),r=n?mt(n):1;if(e.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${r>1?r:""}}}`,c=`{{/arrayData${r>1?r:""}}}`,a=document.createElement("span");a.textContent=l,a.style.display="none",a.setAttribute("data-hidden-array-start","true"),e.insertBefore(a,e.firstChild);const i=document.createElement("span");i.textContent=c,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},Ee=e=>{var v;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=ve(r.startContainer);let c,a;if(l){let f=l.querySelector(e);f||(f=document.createElement(e),f.style.margin="0",f.style.paddingLeft="20px",l.appendChild(f)),a=f,c=document.createElement("li"),c.textContent="​",a.appendChild(c)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const f=j();if(a=f==null?void 0:f.querySelector(`${e}:last-child`),!a)return;c=a.querySelector("li:last-child")}ft(a);const i=document.createRange();i.setStart(c,0),i.collapse(!0),n.removeAllRanges(),n.addRange(i),(v=j())==null||v.focus(),S()},Z=(e,n)=>{e==="insertOrderedList"?Ee("ol"):e==="insertUnorderedList"?Ee("ul"):e.startsWith("justify")?_t(e):pe(e,n),e==="insertTable"&&St()},gt=e=>{const n=document.createElement("span");n.textContent="​",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=n.getBoundingClientRect();n.remove(),G({x:r.left,y:r.bottom+window.scrollY}),M(o||[]),B(!0),V.current=e.cloneRange()},ht=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let r=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const c=l.textContent||"",a=l===n?r:c.length,i=c.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(l,i),v.setEnd(l,a),v}}l=l.previousSibling}return null},pt=e=>{var a;const n=window.getSelection();if(!n)return;const r=ht();r?(n.removeAllRanges(),n.addRange(r)):V.current&&(n.removeAllRanges(),n.addRange(V.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.color="#007bff",l.style.display="inline",l.contentEditable="false",l.setAttribute("data-mention",e.value||e.name||"");try{const i=n.rangeCount?n.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const p=document.createRange(),h=j();p.selectNodeContents(h),p.collapse(!1),p.insertNode(l)}const v=document.createTextNode(" ");l.after(v);const f=document.createRange();f.setStartAfter(v),f.collapse(!0),n.removeAllRanges(),n.addRange(f)}catch(i){console.error("insertMention error:",i)}let c=me([...he,e]);te(c),H(c),B(!1),(a=j())==null||a.focus(),S()},vt=e=>{const n=j();if(!n)return;let r=null;k.current&&n.contains(k.current.startContainer)?r=k.current.cloneRange():(r=document.createRange(),r.selectNodeContents(n),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const c=document.createElement("span");c.textContent=`{{${e.name}}}`,c.style.color="#007bff",c.style.display="inline",c.contentEditable="false",c.setAttribute("data-mention",e.value||e.name),r.insertNode(c);const a=document.createTextNode(" ");c.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),l.removeAllRanges(),l.addRange(i),k.current=i.cloneRange(),n.focus()},Et=e=>{e.forEach(n=>vt(n)),te(n=>{const r=[...n,...e],l=Array.from(new Map(r.map(c=>[c.name,c])).values());return H(l),l}),S()},yt=()=>{const e=j();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),r=[];return n.forEach(l=>{const c=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:c})}),r},wt=e=>{var r,l,c;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),Z(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?ve(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=i.parentElement,p=f==null?void 0:f.closest("li");if(p){f==null||f.removeChild(i);const h=document.createElement("p");h.innerHTML="<br />",(l=p.parentElement)==null||l.insertBefore(h,p.nextSibling);const C=document.createRange();C.setStart(h,0),C.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(C)}else{const h=i.closest("ul, ol");if(h){const C=document.createElement("p");C.innerHTML="<br />",(c=h.parentElement)==null||c.insertBefore(C,h.nextSibling),h.removeChild(i);const T=document.createRange();T.setStart(C,0),T.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(T)}}S()}}},Ct=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(bt(l))return;setTimeout(()=>{gt(r.getRangeAt(0)),ge(""),M(o),B(!0)},0);return}if(I){setTimeout(()=>ye(),0);return}},bt=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},ye=()=>{if(S(),!I)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const r=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!r){B(!1);return}const l=r[1].toLowerCase();ge(l);const c=o.filter(a=>a.name.toLowerCase().includes(l));M(c)},xt=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const r=new FileReader;r.onload=c=>{var T;const a=(T=c.target)==null?void 0:T.result;R();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const f=document.createElement("img");f.src=a,f.alt=n.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const p=j();if(!v||!p){p==null||p.appendChild(f);const ke=document.createTextNode(" ");p==null||p.appendChild(ke);const ne=document.createRange();ne.setStartAfter(ke),ne.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ne),p==null||p.focus(),S(),e.target.value="";return}v.deleteContents(),v.insertNode(f);const h=document.createTextNode(" ");f.after(h);const C=document.createRange();C.setStartAfter(h),C.collapse(!0),i.removeAllRanges(),i.addRange(C),p.focus(),S(),e.target.value=""},r.readAsDataURL(n)},Lt=e=>{var c;R();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r),(c=j())==null||c.focus(),S()},St=()=>{R();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",m.table&&e.classList.add(m.table);const n=document.createElement("thead");m.thead&&n.classList.add(m.thead);const r=document.createElement("tbody");m.tbody&&r.classList.add(m.tbody);const l=document.createElement("tr");m.tr&&l.classList.add(m.tr);const c=document.createElement("tr");m.tr&&c.classList.add(m.tr);for(let v=0;v<2;v++){const f=document.createElement("th");f.textContent=`Header ${v+1}`,f.style.border="1px solid #999",f.style.padding="8px",f.style.position="relative",f.style.backgroundColor="lightgray",m.th&&f.classList.add(m.th);const p=document.createElement("td");p.textContent=`Row 1 Col ${v+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",m.td&&p.classList.add(m.td),Q(f),Q(p),l.appendChild(f),c.appendChild(p)}n.appendChild(l),r.appendChild(c),e.appendChild(n),e.appendChild(r),Nt(e),we(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(e),S()},we=e=>{const n=document.createElement("div");Object.assign(n.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let r=0,l=0,c=0,a=0;n.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,l=i.clientY;const v=e.getBoundingClientRect();c=v.width,a=v.height;const f=h=>{const C=Math.max(100,c+(h.clientX-r)),T=Math.max(60,a+(h.clientY-l));e.style.width=`${C}px`,e.style.height=`${T}px`,S()},p=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),S()};document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)}),e.appendChild(n)},Q=e=>{const n=document.createElement("div"),r=document.createElement("div");Object.assign(n.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Mt(e,n,r),e.appendChild(n),e.appendChild(r)},Mt=(e,n,r)=>{let l=0,c=0,a=0,i=0;n.addEventListener("mousedown",h=>{h.preventDefault(),l=h.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",p)}),r.addEventListener("mousedown",h=>{h.preventDefault(),c=h.clientY,i=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)});const v=h=>{const C=a+(h.clientX-l);e.style.width=`${Math.max(30,C)}px`,S()},f=h=>{const C=i+(h.clientY-c);e.style.height=`${Math.max(20,C)}px`,S()},p=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),S()}},At=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},Ce=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},zt=e=>{if(!D.cell)return;const n=D.cell.closest("table"),r=D.cell.cellIndex,l=D.cell.parentElement.rowIndex,c=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=a.textContent||"",v.style.cssText=a.style.cssText,Q(v),v};switch(e){case"insertRowAbove":{const a=n.rows[l],i=n.insertRow(l);Array.from(a.cells).forEach(v=>{i.appendChild(c(v))});break}case"insertRowBelow":{const a=n.rows[l],i=n.insertRow(l+1);Array.from(a.cells).forEach(v=>{i.appendChild(c(v))});break}case"insertColLeft":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(c(i),i)});break}case"insertColRight":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(c(i),i.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}S(),g(oe(re({},D),{visible:!1})),Ce()},Nt=e=>{const n=e.querySelector("tbody");if(!n||n.querySelector("[data-hidden-table-start]"))return;const r=document.createElement("span");r.textContent="{{#arrayData}}",r.style.display="none",r.setAttribute("data-hidden-table-start","true"),n.insertBefore(r,n.firstChild);const l=document.createElement("span");l.textContent="{{/arrayData}}",l.style.display="none",l.setAttribute("data-hidden-table-end","true"),n.appendChild(l)},be=()=>{const e=j();if(!e)return _;const n=e.cloneNode(!0);return n.querySelectorAll("table div").forEach(r=>r.remove()),n.querySelectorAll(".rte-cell-highlight").forEach(r=>r.classList.remove("rte-cell-highlight")),n.innerHTML},Tt=()=>{U(),Y.current=k.current,fe({url:"",text:"",title:"",target:"_self"}),F(!0)},kt=e=>{const n=window.getSelection();if(!n||!Y.current)return;n.removeAllRanges(),n.addRange(Y.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const c=n.getRangeAt(0);c.deleteContents(),c.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),n.removeAllRanges(),n.addRange(i),F(!1),S()},Ot=e=>{const n=e.target;if(n.tagName==="A"){const r=n;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),Y.current=l,fe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),F(!0)}},Dt=()=>{const e=j();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&k.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(k.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);R(),document.execCommand("removeFormat",!1);const c=l.cloneContents(),a=document.createElement("div");a.appendChild(c);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const h=i.currentNode,C=h.tagName.toUpperCase(),T=h.getAttribute&&h.getAttribute("data-mention")!==null;C!=="A"&&!T&&v.push(h)}for(let h=v.length-1;h>=0;h--){const C=v[h],T=C.parentNode;if(T){for(;C.firstChild;)T.insertBefore(C.firstChild,C);T.removeChild(C)}}a.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;a.firstChild;)f.appendChild(a.firstChild);l.insertNode(f);const p=document.createRange();p.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),p.collapse(!0),r.removeAllRanges(),r.addRange(p),e.normalize(),S()},jt=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=n,r.querySelectorAll("br").forEach(c=>{c.replaceWith(`
1
+ (function(S,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(S=typeof globalThis!="undefined"?globalThis:S||self,t(S.RichTextEditor={},S.React,S.ReactDOM))})(this,(function(S,t,D){"use strict";var Ft=Object.defineProperty,It=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var ke=Object.getOwnPropertySymbols;var qt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var De=(S,t,D)=>t in S?Ft(S,t,{enumerable:!0,configurable:!0,writable:!0,value:D}):S[t]=D,re=(S,t)=>{for(var D in t||(t={}))qt.call(t,D)&&De(S,D,t[D]);if(ke)for(var D of ke(t))Vt.call(t,D)&&De(S,D,t[D]);return S},oe=(S,t)=>It(S,Bt(t));function Oe(o){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const d in o)if(d!=="default"){const u=Object.getOwnPropertyDescriptor(o,d);Object.defineProperty(s,d,u.get?u:{enumerable:!0,get:()=>o[d]})}}return s.default=o,Object.freeze(s)}const je=Oe(t);window.React=je;var le={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ae=t.createContext&&t.createContext(le),He=["attr","size","title"];function _e(o,s){if(o==null)return{};var d=Pe(o,s),u,m;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(o);for(m=0;m<y.length;m++)u=y[m],!(s.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(o,u)&&(d[u]=o[u])}return d}function Pe(o,s){if(o==null)return{};var d={};for(var u in o)if(Object.prototype.hasOwnProperty.call(o,u)){if(s.indexOf(u)>=0)continue;d[u]=o[u]}return d}function W(){return W=Object.assign?Object.assign.bind():function(o){for(var s=1;s<arguments.length;s++){var d=arguments[s];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(o[u]=d[u])}return o},W.apply(this,arguments)}function ie(o,s){var d=Object.keys(o);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(o);s&&(u=u.filter(function(m){return Object.getOwnPropertyDescriptor(o,m).enumerable})),d.push.apply(d,u)}return d}function K(o){for(var s=1;s<arguments.length;s++){var d=arguments[s]!=null?arguments[s]:{};s%2?ie(Object(d),!0).forEach(function(u){Fe(o,u,d[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(d)):ie(Object(d)).forEach(function(u){Object.defineProperty(o,u,Object.getOwnPropertyDescriptor(d,u))})}return o}function Fe(o,s,d){return s=Ie(s),s in o?Object.defineProperty(o,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):o[s]=d,o}function Ie(o){var s=Be(o,"string");return typeof s=="symbol"?s:s+""}function Be(o,s){if(typeof o!="object"||!o)return o;var d=o[Symbol.toPrimitive];if(d!==void 0){var u=d.call(o,s);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(o)}function se(o){return o&&o.map((s,d)=>t.createElement(s.tag,K({key:d},s.attr),se(s.child)))}function A(o){return s=>t.createElement(qe,W({attr:K({},o.attr)},s),se(o.child))}function qe(o){var s=d=>{var{attr:u,size:m,title:y}=o,C=_e(o,He),x=m||d.size||"1em",E;return d.className&&(E=d.className),o.className&&(E=(E?E+" ":"")+o.className),t.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,u,C,{className:E,style:K(K({color:o.color||d.color},d.style),o.style),height:x,width:x,xmlns:"http://www.w3.org/2000/svg"}),y&&t.createElement("title",null,y),o.children)};return ae!==void 0?t.createElement(ae.Consumer,null,d=>s(d)):s(le)}function Ve(o){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(o)}function Ue(o){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(o)}function $e(o){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(o)}function Re(o){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{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"},child:[]}]})(o)}function We(o){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Ke(o){return A({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(o)}function Xe(o){return A({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(o)}function Ye(o){return A({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(o)}function Ze(o){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(o)}function Qe(o){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function Je(o){return A({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(o)}function Ge(o){return A({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(o)}function et(o){return A({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(o)}function tt(o){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(o)}function nt(o){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(o)}const rt=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ce=({exec:o,saveSelection:s,handleFileChange:d,handleFontSizeChange:u,handleFontFamilyChange:m,insertEmoji:y,handleLink:C,removeFormatting:x,visibleActions:E,className:H,style:F})=>{var V,O;const N=t.useRef(null),P=t.useRef(null),L=t.useRef(null),[Y,$]=t.useState(!1),[q,B]=t.useState({x:0,y:0});t.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&$(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const I=g=>{var _;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":o(w);break;case"insertImage":{(_=N.current)==null||_.click();break}default:console.warn("Unknown command:",w)}},G=g=>{o("foreColor",g.target.value)},ee=g=>{o("backColor",g.target.value)},[z,k]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const g=()=>{k({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.createElement("div",{className:`rte-toolbar ${H||""}`,style:F},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:I,className:z.bold?"rte-active":""},t.createElement(Ke,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:I,className:z.italic?"rte-active":""},t.createElement(Ye,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:I,className:z.underline?"rte-active":""},t.createElement(et,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:I,title:"UnorderedList",className:z.unorderedList?"rte-active":""},t.createElement(Qe,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:I,className:z.orderedList?"rte-active":""},t.createElement(Re,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:C,className:z.link?"rte-active":""},t.createElement(Ze,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),s(),x()},className:z.removeFormat?"rte-active":""},t.createElement(nt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:I,className:z.image?"rte-active":""},t.createElement($e,null)),t.createElement("input",{type:"file",accept:"image/*",ref:N,style:{display:"none"},onChange:d}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),s();const w=g.currentTarget.getBoundingClientRect();B({x:w.left,y:w.bottom+8}),$(_=>!_)},className:z.emoji?"rte-active":""},t.createElement(Je,null)),Y&&D.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:q.y,left:q.x}},rt.map((g,w)=>t.createElement("span",{key:w,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:_=>{_.preventDefault(),y(g),$(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),s(),(w=P.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((V=P.current)==null?void 0:V.value)||"#000",fontSize:"18px"},className:z.color?"rte-active":""},t.createElement(tt,null)),t.createElement("input",{ref:P,type:"color",defaultValue:"#000000",onChange:g=>{var w;G(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),s(),(w=L.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((O=L.current)==null?void 0:O.value)||"#000",fontSize:"18px"},className:z.highlight?"rte-active":""},t.createElement(Xe,null)),t.createElement("input",{ref:L,type:"color",onChange:g=>{var w;ee(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyLeft"),className:z.alignLeft?"rte-active":""},t.createElement(We,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyCenter"),className:z.alignCenter?"rte-active":""},t.createElement(Ve,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyRight"),className:z.alignRight?"rte-active":""},t.createElement(Ue,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertTable"),className:z.table?"rte-active":""},t.createElement(Ge,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:u},t.createElement("option",{value:"",disabled:!0},"Font Size"),t.createElement("option",{value:"2"},"Small "),t.createElement("option",{value:"3"},"Normal"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large")))},ot=({show:o,position:s,filtered:d,insertMention:u,onClose:m,query:y})=>{const C=t.useRef(null);return t.useEffect(()=>{const x=E=>{C.current&&!C.current.contains(E.target)&&m()};return o&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[o,m]),o?t.createElement("ul",{ref:C,className:"rte-popup",style:{top:s.y,left:s.x}},d.length>0?d.map(({name:x,value:E})=>{const H=x.toLowerCase(),F=y.toLowerCase(),N=H.indexOf(F);let P=x;if(N!==-1&&y.length>0){const L=N+y.length;P=x.substring(0,N)+`<span class="rte-highlight">${x.substring(N,L)}</span>`+x.substring(L)}return t.createElement("li",{key:E,onMouseDown:L=>{L.preventDefault(),u({name:x,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:P},onMouseEnter:L=>L.currentTarget.style.background="#f0f0f0",onMouseLeave:L=>L.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ue(o){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(o)}function X(o){return A({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(o)}const lt=({visible:o,x:s,y:d,onAction:u,onClose:m})=>{if(!o)return null;const y={top:d,left:s};return t.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:m},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(X,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(X,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(X,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(X,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(ue,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(ue,null)," Delete column"))},de=({html:o,className:s,style:d})=>{const u=y=>{const C=y.target;if(C.tagName==="A"){y.preventDefault();const x=C.href;x&&window.open(x,"_blank","noopener,noreferrer")}},m=y=>{let C=y.replace(/{{\s*(.*?)\s*}}/g,"$1");return C=C.replace(/#arrayData/g,""),C=C.replace(/\/arrayData/g,""),C};return t.createElement("div",{className:`rte-preview ${s||""}`,style:d,onClick:u,dangerouslySetInnerHTML:{__html:m(o)}})},at=({visible:o,linkData:s,onClose:d,onInsert:u})=>{const[m,y]=t.useState(""),[C,x]=t.useState(""),[E,H]=t.useState(""),[F,N]=t.useState("_self");if(t.useEffect(()=>{o?(y(s.url||""),x(s.text||""),H(s.title||""),N(s.target||"_self")):(y(""),x(""),H(""),N("_self"))},[o,s]),!o)return null;const P=()=>{u({url:m,text:C,title:E,target:F})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},m?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:m,onChange:L=>y(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:C,onChange:L=>x(L.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:L=>H(L.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:F,onChange:L=>N(L.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:P},"OK"))))};function me(o){return Array.from(new Map(o.map(s=>[s.value,s])).values())}const it=({atSuggestions:o=[],showOutput:s=!1,showPreview:d=!1,toolbarConfig:u={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:m={},styles:y={},handleGetHtml:C=()=>{},onChange:x=()=>{},value:E,onMentionSelect:H=()=>{},handleAddAttributes:F=()=>{}})=>{var Ce,xe,Le,Se,Me,ze,Ae,Ne;const N=t.useRef(null),[P,L]=t.useState(E!=null&&E.length?E:" "),[Y,$]=t.useState(""),[q,B]=t.useState(!1),[I,G]=t.useState({x:0,y:0}),[ee,z]=t.useState([]),k=t.useRef(null),V=t.useRef(null),[O,g]=t.useState({visible:!1,x:0,y:0}),[w,_]=t.useState(!1),Z=t.useRef(null),[st,fe]=t.useState({url:"",text:"",title:"",target:"_self"}),ct={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(Ce=u.link)!=null?Ce:!1,image:(xe=u.image)!=null?xe:!1,emoji:(Le=u.emoji)!=null?Le:!1,table:(Se=u.table)!=null?Se:!1,color:(Me=u.color)!=null?Me:!1,fontFamily:(ze=u.fontFamily)!=null?ze:!1,fontSize:(Ae=u.fontSize)!=null?Ae:!1,highlight:(Ne=u.fontSize)!=null?Ne:!1},[ut,ge]=t.useState(""),[he,te]=t.useState([]),j=()=>N.current,M=()=>{const e=dt();$(e),C==null||C(e);const n=Ht(e);x(n);const r=bt(),l=me(r);JSON.stringify(l)!==JSON.stringify(he)&&(te(l),H(l))},dt=()=>{const e=j();if(!e)return P;const n=e.cloneNode(!0);n.querySelectorAll("table div").forEach(l=>l.remove()),n.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight"));let r=n.innerHTML;return r=mt(r),r},mt=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),U=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const n=document.getElementById("rte-editor-body");if(!n)return;const r=e.getRangeAt(0);n.contains(r.startContainer)&&(k.current=r.cloneRange())},R=()=>{const e=window.getSelection();!e||!k.current||(e.removeAllRanges(),e.addRange(k.current))},pe=(e,n)=>{const r=window.getSelection();r&&r.rangeCount>0&&(k.current=r.getRangeAt(0)),R(),document.execCommand(e,!1,n),M()};t.useEffect(()=>{const e=j();if(!e||!E)return;const n=ft(E);e.innerHTML=n,M()},[]);const ft=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{F&&F(e=>{wt(e)})},[]),t.useEffect(()=>{const e=j();if(!e)return;e.querySelectorAll("table").forEach(r=>{we(r),r.querySelectorAll("th, td").forEach(c=>J(c))})},[]);const ve=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},gt=e=>{let n=0,r=e.parentElement;for(;r;)(r.tagName==="UL"||r.tagName==="OL")&&n++,r=r.parentElement;return n},ht=e=>{const n=e.querySelector("li"),r=n?gt(n):1;if(e.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${r>1?r:""}}}`,c=`{{/arrayData${r>1?r:""}}}`,a=document.createElement("span");a.textContent=l,a.style.display="none",a.setAttribute("data-hidden-array-start","true"),e.insertBefore(a,e.firstChild);const i=document.createElement("span");i.textContent=c,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},Ee=e=>{var v;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=ve(r.startContainer);let c,a;if(l){let f=l.querySelector(e);f||(f=document.createElement(e),f.style.margin="0",f.style.paddingLeft="20px",l.appendChild(f)),a=f,c=document.createElement("li"),c.textContent="​",a.appendChild(c)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const f=j();if(a=f==null?void 0:f.querySelector(`${e}:last-child`),!a)return;c=a.querySelector("li:last-child")}ht(a);const i=document.createRange();i.setStart(c,0),i.collapse(!0),n.removeAllRanges(),n.addRange(i),(v=j())==null||v.focus(),M()},Q=(e,n)=>{e==="insertOrderedList"?Ee("ol"):e==="insertUnorderedList"?Ee("ul"):e.startsWith("justify")?Pt(e):pe(e,n),e==="insertTable"&&zt()},pt=e=>{const n=document.createElement("span");n.textContent="​",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const r=n.getBoundingClientRect();n.remove(),G({x:r.left,y:r.bottom+window.scrollY}),z(o||[]),B(!0),V.current=e.cloneRange()},vt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let r=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[r]?l=l.childNodes[r]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const c=l.textContent||"",a=l===n?r:c.length,i=c.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(l,i),v.setEnd(l,a),v}}l=l.previousSibling}return null},Et=e=>{var a;const n=window.getSelection();if(!n)return;const r=vt();r?(n.removeAllRanges(),n.addRange(r)):V.current&&(n.removeAllRanges(),n.addRange(V.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.display="inline",l.contentEditable="false",l.setAttribute("data-mention",e.value||e.name||"");try{const i=n.rangeCount?n.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const p=document.createRange(),h=j();p.selectNodeContents(h),p.collapse(!1),p.insertNode(l)}const v=document.createTextNode(" ");l.after(v);const f=document.createRange();f.setStartAfter(v),f.collapse(!0),n.removeAllRanges(),n.addRange(f)}catch(i){console.error("insertMention error:",i)}let c=me([...he,e]);te(c),H(c),B(!1),(a=j())==null||a.focus(),M()},yt=e=>{const n=j();if(!n)return;let r=null;k.current&&n.contains(k.current.startContainer)?r=k.current.cloneRange():(r=document.createRange(),r.selectNodeContents(n),r.collapse(!1));const l=window.getSelection();if(!l)return;l.removeAllRanges(),l.addRange(r);const c=document.createElement("span");c.textContent=`{{${e.name}}}`,c.style.display="inline",c.contentEditable="false",c.setAttribute("data-mention",e.value||e.name),r.insertNode(c);const a=document.createTextNode(" ");c.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),l.removeAllRanges(),l.addRange(i),k.current=i.cloneRange(),n.focus()},wt=e=>{e.forEach(n=>yt(n)),te(n=>{const r=[...n,...e],l=Array.from(new Map(r.map(c=>[c.name,c])).values());return H(l),l}),M()},bt=()=>{const e=j();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),r=[];return n.forEach(l=>{const c=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:c})}),r},Ct=e=>{var r,l,c;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),Q(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?ve(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=i.parentElement,p=f==null?void 0:f.closest("li");if(p){f==null||f.removeChild(i);const h=document.createElement("p");h.innerHTML="<br />",(l=p.parentElement)==null||l.insertBefore(h,p.nextSibling);const b=document.createRange();b.setStart(h,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(b)}else{const h=i.closest("ul, ol");if(h){const b=document.createElement("p");b.innerHTML="<br />",(c=h.parentElement)==null||c.insertBefore(b,h.nextSibling),h.removeChild(i);const T=document.createRange();T.setStart(b,0),T.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(T)}}M()}}},xt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const l=r.anchorNode;if(Lt(l))return;setTimeout(()=>{pt(r.getRangeAt(0)),ge(""),z(o),B(!0)},0);return}if(q){setTimeout(()=>ye(),0);return}},Lt=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},ye=()=>{if(M(),!q)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const r=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!r){B(!1);return}const l=r[1].toLowerCase();ge(l);const c=o.filter(a=>a.name.toLowerCase().includes(l));z(c)},St=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const r=new FileReader;r.onload=c=>{var T;const a=(T=c.target)==null?void 0:T.result;R();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const f=document.createElement("img");f.src=a,f.alt=n.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const p=j();if(!v||!p){p==null||p.appendChild(f);const Te=document.createTextNode(" ");p==null||p.appendChild(Te);const ne=document.createRange();ne.setStartAfter(Te),ne.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(ne),p==null||p.focus(),M(),e.target.value="";return}v.deleteContents(),v.insertNode(f);const h=document.createTextNode(" ");f.after(h);const b=document.createRange();b.setStartAfter(h),b.collapse(!0),i.removeAllRanges(),i.addRange(b),p.focus(),M(),e.target.value=""},r.readAsDataURL(n)},Mt=e=>{var c;R();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const r=n.getRangeAt(0),l=document.createTextNode(e);r.insertNode(l),r.setStartAfter(l),r.collapse(!0),n.removeAllRanges(),n.addRange(r),(c=j())==null||c.focus(),M()},zt=()=>{R();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",m.table&&e.classList.add(m.table);const n=document.createElement("thead");m.thead&&n.classList.add(m.thead);const r=document.createElement("tbody");m.tbody&&r.classList.add(m.tbody);const l=document.createElement("tr");m.tr&&l.classList.add(m.tr);const c=document.createElement("tr");m.tr&&c.classList.add(m.tr);for(let v=0;v<2;v++){const f=document.createElement("th");f.textContent=`Header ${v+1}`,f.style.border="1px solid #999",f.style.padding="8px",f.style.position="relative",f.style.backgroundColor="lightgray",m.th&&f.classList.add(m.th);const p=document.createElement("td");p.textContent=`Row 1 Col ${v+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",m.td&&p.classList.add(m.td),J(f),J(p),l.appendChild(f),c.appendChild(p)}n.appendChild(l),r.appendChild(c),e.appendChild(n),e.appendChild(r),we(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(e),M()},we=e=>{const n=document.createElement("div");Object.assign(n.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let r=0,l=0,c=0,a=0;n.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,l=i.clientY;const v=e.getBoundingClientRect();c=v.width,a=v.height;const f=h=>{const b=Math.max(100,c+(h.clientX-r)),T=Math.max(60,a+(h.clientY-l));e.style.width=`${b}px`,e.style.height=`${T}px`,M()},p=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),M()};document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)}),e.appendChild(n)},J=e=>{const n=document.createElement("div"),r=document.createElement("div");Object.assign(n.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),At(e,n,r),e.appendChild(n),e.appendChild(r)},At=(e,n,r)=>{let l=0,c=0,a=0,i=0;n.addEventListener("mousedown",h=>{h.preventDefault(),l=h.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",p)}),r.addEventListener("mousedown",h=>{h.preventDefault(),c=h.clientY,i=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)});const v=h=>{const b=a+(h.clientX-l);e.style.width=`${Math.max(30,b)}px`,M()},f=h=>{const b=i+(h.clientY-c);e.style.height=`${Math.max(20,b)}px`,M()},p=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),M()}},Nt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},be=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Tt=e=>{if(!O.cell)return;const n=O.cell.closest("table"),r=O.cell.cellIndex,l=O.cell.parentElement.rowIndex,c=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=a.textContent||"",v.style.cssText=a.style.cssText,J(v),v};switch(e){case"insertRowAbove":{const a=n.rows[l],i=n.insertRow(l);Array.from(a.cells).forEach(v=>{i.appendChild(c(v))});break}case"insertRowBelow":{const a=n.rows[l],i=n.insertRow(l+1);Array.from(a.cells).forEach(v=>{i.appendChild(c(v))});break}case"insertColLeft":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(c(i),i)});break}case"insertColRight":{Array.from(n.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(c(i),i.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}M(),g(oe(re({},O),{visible:!1})),be()},kt=()=>{U(),Z.current=k.current,fe({url:"",text:"",title:"",target:"_self"}),_(!0)},Dt=e=>{const n=window.getSelection();if(!n||!Z.current)return;n.removeAllRanges(),n.addRange(Z.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const l=document.createElement("a");l.href=r,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||r,l.title=e.title,l.target=e.target,l.contentEditable="true";const c=n.getRangeAt(0);c.deleteContents(),c.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),n.removeAllRanges(),n.addRange(i),_(!1),M()},Ot=e=>{const n=e.target;if(n.tagName==="A"){const r=n;if(e.ctrlKey||e.metaKey){window.open(r.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(r),Z.current=l,fe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),_(!0)}},jt=()=>{const e=j();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&k.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(k.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const l=r.getRangeAt(0);R(),document.execCommand("removeFormat",!1);const c=l.cloneContents(),a=document.createElement("div");a.appendChild(c);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const h=i.currentNode,b=h.tagName.toUpperCase(),T=h.getAttribute&&h.getAttribute("data-mention")!==null;b!=="A"&&!T&&v.push(h)}for(let h=v.length-1;h>=0;h--){const b=v[h],T=b.parentNode;if(T){for(;b.firstChild;)T.insertBefore(b.firstChild,b);T.removeChild(b)}}a.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;a.firstChild;)f.appendChild(a.firstChild);l.insertNode(f);const p=document.createRange();p.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),p.collapse(!0),r.removeAllRanges(),r.addRange(p),e.normalize(),M()},Ht=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const r=document.createElement("div");return r.innerHTML=n,r.querySelectorAll("br").forEach(c=>{c.replaceWith(`
2
2
  `)}),r.querySelectorAll("p, div, tr").forEach(c=>{c.insertAdjacentText("afterend",`
3
3
  `)}),r.querySelectorAll("table").forEach(c=>{c.insertAdjacentText("afterend",`
4
4
  `)}),((l=r.textContent)==null?void 0:l.replace(/\n{3,}/g,`
5
5
 
6
- `).trim())||""};function Ht(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const n=e.getRangeAt(0),r=n.commonAncestorContainer,l=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(l.querySelectorAll("td, th")).filter(a=>{const i=document.createRange();return i.selectNodeContents(a),n.compareBoundaryPoints(Range.END_TO_START,i)<0&&n.compareBoundaryPoints(Range.START_TO_END,i)>0})}function _t(e){const n=Ht();if(n.length===0){pe(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),n.forEach(l=>{l.style.textAlign=r}),S()}return t.createElement("div",{className:`rte-wrapper ${(m==null?void 0:m.wrapper)||""}`,style:y.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(ce,{exec:Z,saveSelection:U,handleFileChange:xt,handleFontSizeChange:e=>Z("fontSize",e.target.value),handleFontFamilyChange:e=>Z("fontName",e.target.value),insertEmoji:Lt,handleLink:Tt,removeFormatting:Dt,visibleActions:ut,className:m.toolbar,style:y.toolbar}),t.createElement("div",{ref:N,id:"rte-editor-body",className:`rte-editor ${(m==null?void 0:m.editor)||""}`,style:y.editor,contentEditable:!0,suppressContentEditableWarning:!0,onKeyUp:U,onMouseUp:U,onInput:()=>{ye(),U()},onKeyDown:wt,onBeforeInput:Ct,onContextMenu:At,onClick:e=>{Ot(e),U()}}),t.createElement(lt,{show:I,position:q,filtered:ee,insertMention:pt,onClose:()=>B(!1),query:dt}),s&&t.createElement("div",{className:`rte-output ${(m==null?void 0:m.output)||""}`,style:y.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,J)),t.createElement(at,{visible:D.visible,x:D.x,y:D.y,onAction:zt,onClose:()=>{g(oe(re({},D),{visible:!1})),Ce()}}),t.createElement(it,{visible:w,linkData:ct,onClose:()=>F(!1),onInsert:kt})),d?t.createElement(de,{className:m.preview,style:y.preview,html:be()}):null)};L.RichTextEditor=st,L.RtePreview=de,L.RteToolbar=ce,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
6
+ `).trim())||""};function _t(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const n=e.getRangeAt(0),r=n.commonAncestorContainer,l=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(l.querySelectorAll("td, th")).filter(a=>{const i=document.createRange();return i.selectNodeContents(a),n.compareBoundaryPoints(Range.END_TO_START,i)<0&&n.compareBoundaryPoints(Range.START_TO_END,i)>0})}function Pt(e){const n=_t();if(n.length===0){pe(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),n.forEach(l=>{l.style.textAlign=r}),M()}return t.createElement("div",{className:`rte-wrapper ${(m==null?void 0:m.wrapper)||""}`,style:y.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(ce,{exec:Q,saveSelection:U,handleFileChange:St,handleFontSizeChange:e=>Q("fontSize",e.target.value),handleFontFamilyChange:e=>Q("fontName",e.target.value),insertEmoji:Mt,handleLink:kt,removeFormatting:jt,visibleActions:ct,className:m.toolbar,style:y.toolbar}),t.createElement("div",{ref:N,id:"rte-editor-body",className:`rte-editor ${(m==null?void 0:m.editor)||""}`,style:y.editor,contentEditable:!0,suppressContentEditableWarning:!0,onKeyUp:U,onMouseUp:U,onInput:()=>{ye(),U()},onKeyDown:Ct,onBeforeInput:xt,onContextMenu:Nt,onClick:e=>{Ot(e),U()}}),t.createElement(ot,{show:q,position:I,filtered:ee,insertMention:Et,onClose:()=>B(!1),query:ut}),s&&t.createElement("div",{className:`rte-output ${(m==null?void 0:m.output)||""}`,style:y.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,Y)),t.createElement(lt,{visible:O.visible,x:O.x,y:O.y,onAction:Tt,onClose:()=>{g(oe(re({},O),{visible:!1})),be()}}),t.createElement(at,{visible:w,linkData:st,onClose:()=>_(!1),onInsert:Dt})),d?t.createElement(de,{className:m.preview,style:y.preview,html:Y}):null)};S.RichTextEditor=it,S.RtePreview=de,S.RteToolbar=ce,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryzeup/richtexteditor",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "A React Rich Text Editor component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",