@ryzeup/richtexteditor 1.0.24 â 1.0.26
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.es.js +834 -773
- package/dist/index.js +4 -5
- package/dist/index.umd.js +5 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";var dt=Object.defineProperty,ut=Object.defineProperties;var mt=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var ft=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable;var xe=(a,i,d)=>i in a?dt(a,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[i]=d,ae=(a,i)=>{for(var d in i||(i={}))ft.call(i,d)&&xe(a,d,i[d]);if(Re)for(var d of Re(i))gt.call(i,d)&&xe(a,d,i[d]);return a},oe=(a,i)=>ut(a,mt(i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),ht=require("react-dom");function pt(a){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const d in a)if(d!=="default"){const m=Object.getOwnPropertyDescriptor(a,d);Object.defineProperty(i,d,m.get?m:{enumerable:!0,get:()=>a[d]})}}return i.default=a,Object.freeze(i)}const vt=pt(r);window.React=vt;var ze={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Se=r.createContext&&r.createContext(ze),yt=["attr","size","title"];function Et(a,i){if(a==null)return{};var d=wt(a,i),m,y;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(a);for(y=0;y<w.length;y++)m=w[y],!(i.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(d[m]=a[m])}return d}function wt(a,i){if(a==null)return{};var d={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(i.indexOf(m)>=0)continue;d[m]=a[m]}return d}function Y(){return Y=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var d=arguments[i];for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(a[m]=d[m])}return a},Y.apply(this,arguments)}function Le(a,i){var d=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);i&&(m=m.filter(function(y){return Object.getOwnPropertyDescriptor(a,y).enumerable})),d.push.apply(d,m)}return d}function Z(a){for(var i=1;i<arguments.length;i++){var d=arguments[i]!=null?arguments[i]:{};i%2?Le(Object(d),!0).forEach(function(m){Ct(a,m,d[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(d)):Le(Object(d)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(d,m))})}return a}function Ct(a,i,d){return i=bt(i),i in a?Object.defineProperty(a,i,{value:d,enumerable:!0,configurable:!0,writable:!0}):a[i]=d,a}function bt(a){var i=Rt(a,"string");return typeof i=="symbol"?i:i+""}function Rt(a,i){if(typeof a!="object"||!a)return a;var d=a[Symbol.toPrimitive];if(d!==void 0){var m=d.call(a,i);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(a)}function ke(a){return a&&a.map((i,d)=>r.createElement(i.tag,Z({key:d},i.attr),ke(i.child)))}function k(a){return i=>r.createElement(xt,Y({attr:Z({},a.attr)},i),ke(a.child))}function xt(a){var i=d=>{var{attr:m,size:y,title:w}=a,R=Et(a,yt),M=y||d.size||"1em",E;return d.className&&(E=d.className),a.className&&(E=(E?E+" ":"")+a.className),r.createElement("svg",Y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,m,R,{className:E,style:Z(Z({color:a.color||d.color},d.style),a.style),height:M,width:M,xmlns:"http://www.w3.org/2000/svg"}),w&&r.createElement("title",null,w),a.children)};return Se!==void 0?r.createElement(Se.Consumer,null,d=>i(d)):i(ze)}function St(a){return k({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 Lt(a){return k({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 At(a){return k({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 Mt(a){return k({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 zt(a){return k({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 kt(a){return k({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 Nt(a){return k({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 Tt(a){return k({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 Dt(a){return k({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 Ot(a){return k({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 Ht(a){return k({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 jt(a){return k({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 _t(a){return k({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 Ft(a){return k({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 Pt(a){return k({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 It=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],Ne=({exec:a,saveSelection:i,handleFileChange:d,handleFontSizeChange:m,handleFontFamilyChange:y,insertEmoji:w,handleLink:R,removeFormatting:M,visibleActions:E,className:x,style:S})=>{var B,O;const A=r.useRef(null),F=r.useRef(null),N=r.useRef(null),[P,I]=r.useState(!1),[_,H]=r.useState({x:0,y:0});r.useEffect(()=>{const h=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&I(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const q=h=>{var j;h.preventDefault();const C=h.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":a(C);break;case"insertImage":{(j=A.current)==null||j.click();break}default:console.warn("Unknown command:",C)}},W=h=>{a("foreColor",h.target.value)},Q=h=>{a("backColor",h.target.value)},[z,T]=r.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 r.useEffect(()=>{const h=()=>{T({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",h),()=>document.removeEventListener("selectionchange",h)},[]),r.createElement("div",{className:`rte-toolbar ${x||""}`,style:S},E.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:q,className:z.bold?"rte-active":""},r.createElement(kt,null)),E.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:q,className:z.italic?"rte-active":""},r.createElement(Tt,null)),E.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:q,className:z.underline?"rte-active":""},r.createElement(_t,null)),E.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:q,title:"UnorderedList",className:z.unorderedList?"rte-active":""},r.createElement(Ot,null)),E.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:q,className:z.orderedList?"rte-active":""},r.createElement(Mt,null)),E.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:R,className:z.link?"rte-active":""},r.createElement(Dt,null)),E.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:h=>{h.preventDefault(),i(),M()},className:z.removeFormat?"rte-active":""},r.createElement(Pt,null)),E.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:q,className:z.image?"rte-active":""},r.createElement(At,null)),r.createElement("input",{type:"file",accept:"image/*",ref:A,style:{display:"none"},onChange:d}),E.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:h=>{h.preventDefault(),i();const C=h.currentTarget.getBoundingClientRect();H({x:C.left,y:C.bottom+8}),I(j=>!j)},className:z.emoji?"rte-active":""},r.createElement(Ht,null)),P&&ht.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:_.y,left:_.x}},It.map((h,C)=>r.createElement("span",{key:C,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:j=>{j.preventDefault(),w(h),I(!1)}},h))),document.body)),E.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:h=>{var C;h.preventDefault(),i(),(C=F.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((B=F.current)==null?void 0:B.value)||"#000",fontSize:"18px"},className:z.color?"rte-active":""},r.createElement(Ft,null)),r.createElement("input",{ref:F,type:"color",defaultValue:"#000000",onChange:h=>{var C;W(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:h=>{var C;h.preventDefault(),i(),(C=N.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((O=N.current)==null?void 0:O.value)||"#000",fontSize:"18px"},className:z.highlight?"rte-active":""},r.createElement(Nt,null)),r.createElement("input",{ref:N,type:"color",onChange:h=>{var C;Q(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyLeft"),className:z.alignLeft?"rte-active":""},r.createElement(zt,null)),r.createElement("button",{title:"Align Center",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyCenter"),className:z.alignCenter?"rte-active":""},r.createElement(St,null)),r.createElement("button",{title:"Align Right",onMouseDown:h=>h.preventDefault(),onClick:()=>a("justifyRight"),className:z.alignRight?"rte-active":""},r.createElement(Lt,null))),E.table&&r.createElement("button",{title:"Insert Table",onMouseDown:h=>h.preventDefault(),onClick:()=>a("insertTable"),className:z.table?"rte-active":""},r.createElement(jt,null)),E.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:y},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>i(),onChange:m},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(h,C)=>10+C).map(h=>r.createElement("option",{key:h,value:h},h,"px"))))},qt=({show:a,position:i,filtered:d,insertMention:m,onClose:y,query:w})=>{const R=r.useRef(null),[M,E]=r.useState(0);return r.useEffect(()=>{a&&E(0)},[a]),r.useEffect(()=>{const x=S=>{R.current&&!R.current.contains(S.target)&&y()};return a&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[a,y]),r.useEffect(()=>{if(!a)return;const x=S=>{if(!(!a||d.length===0)&&(S.key==="ArrowDown"&&(S.preventDefault(),E(A=>Math.min(A+1,d.length-1))),S.key==="ArrowUp"&&(S.preventDefault(),E(A=>Math.max(A-1,0))),S.key==="Enter")){S.preventDefault();const A=d[M];A&&m(A)}};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[a,d,M]),r.useEffect(()=>{if(!R.current)return;const S=R.current.querySelectorAll("li")[M];S&&S.scrollIntoView({block:"nearest",behavior:"smooth"})},[M]),a?r.createElement("ul",{ref:R,className:"rte-popup",style:{top:i.y,left:i.x}},d.length>0?d.map(({name:x,value:S},A)=>{const F=x.toLowerCase(),N=w.toLowerCase(),P=F.indexOf(N);let I=x;if(P!==-1&&w.length>0){const _=P+w.length;I=x.substring(0,P)+`<span class="rte-highlight">${x.substring(P,_)}</span>`+x.substring(_)}return r.createElement("li",{key:S,onMouseDown:_=>{_.preventDefault(),m({name:x,value:S})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:A===M?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:I},onMouseEnter:()=>E(A)})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function Ae(a){return k({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 X(a){return k({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 Bt=({visible:a,x:i,y:d,onAction:m,onClose:y})=>{if(!a)return null;const w={top:d,left:i};return r.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:y},r.createElement("button",{onClick:()=>m("insertRowAbove")},r.createElement(X,null)," Insert row above"),r.createElement("button",{onClick:()=>m("insertRowBelow")},r.createElement(X,null)," Insert row below"),r.createElement("button",{onClick:()=>m("insertColLeft")},r.createElement(X,null)," Insert col left"),r.createElement("button",{onClick:()=>m("insertColRight")},r.createElement(X,null)," Insert col right"),r.createElement("button",{onClick:()=>m("deleteRow")},r.createElement(Ae,null)," Delete row"),r.createElement("button",{onClick:()=>m("deleteCol")},r.createElement(Ae,null)," Delete column"))},Te=({html:a,className:i,style:d})=>{const m=w=>{const R=w.target;if(R.tagName==="A"){w.preventDefault();const M=R.href;M&&window.open(M,"_blank","noopener,noreferrer")}},y=w=>{let R=w.replace(/{{\s*(.*?)\s*}}/g,(M,E)=>`<span style="color: blue">${E}</span>`);return R=R.replace(/#arrayData/g,""),R=R.replace(/\/arrayData/g,""),R};return r.createElement("div",{className:`rte-preview ${i||""}`,style:d,onClick:m,dangerouslySetInnerHTML:{__html:y(a)}})},Vt=({visible:a,linkData:i,onClose:d,onInsert:m})=>{const[y,w]=r.useState(""),[R,M]=r.useState(""),[E,x]=r.useState(""),[S,A]=r.useState("_self");if(r.useEffect(()=>{a?(w(i.url||""),M(i.text||""),x(i.title||""),A(i.target||"_self")):(w(""),M(""),x(""),A("_self"))},[a,i]),!a)return null;const F=()=>{m({url:y,text:R,title:E,target:S})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},y?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:y,onChange:N=>w(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:R,onChange:N=>M(N.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:N=>x(N.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:S,onChange:N=>A(N.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:F},"OK"))))};function Me(a){const i=new Map;return a.forEach(d=>{i.set(d.name,d.value)}),Array.from(i.entries()).map(([d,m])=>({name:d,value:m}))}const Ut=({atSuggestions:a=[],showOutput:i=!1,showPreview:d=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:y={},styles:w={},handleGetHtml:R=()=>{},onChange:M=()=>{},value:E,onMentionSelect:x=()=>{},handleAddAttributes:S=()=>{}})=>{var ge,he,pe,ve,ye,Ee,we,Ce;const A=r.useRef(null),[F,N]=r.useState(E!=null&&E.length?E:" "),[P,I]=r.useState(""),[_,H]=r.useState(!1),[q,W]=r.useState({x:0,y:0}),[Q,z]=r.useState([]),T=r.useRef(null),B=r.useRef(null),[O,h]=r.useState({visible:!1,x:0,y:0}),[C,j]=r.useState(!1),K=r.useRef(null),[De,le]=r.useState({url:"",text:"",title:"",target:"_self"}),Oe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ge=m.link)!=null?ge:!1,image:(he=m.image)!=null?he:!1,emoji:(pe=m.emoji)!=null?pe:!1,table:(ve=m.table)!=null?ve:!1,color:(ye=m.color)!=null?ye:!1,fontFamily:(Ee=m.fontFamily)!=null?Ee:!1,fontSize:(we=m.fontSize)!=null?we:!1,highlight:(Ce=m.fontSize)!=null?Ce:!1},[He,J]=r.useState(""),[ce,G]=r.useState([]),D=()=>A.current,L=()=>{const e=je(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;t||(n=`<div style="font-size:12px">${e}</div>`),n=n.replace(/<(ul|ol)([^>]*)>/g,(c,p,v)=>/data-hidden-array-start/.test(c)?c:`<${p}${v}>
|
|
2
|
-
<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`),n=n.replace(/<\/(ul|ol)>/g,(c,p)=>/data-hidden-array-end/.test(c)?c:`<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span></${p}>`),I(n),R==null||R(n);const o=rt(e);M(o);const s=Ue(),l=Me(s);JSON.stringify(l)!==JSON.stringify(ce)&&(G(l),x(l))},je=()=>{const e=D();if(!e)return F;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=_e(n),n},_e=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),V=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(T.current=n.cloneRange())},U=()=>{const e=window.getSelection();!e||!T.current||(e.removeAllRanges(),e.addRange(T.current))},ie=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(T.current=n.getRangeAt(0)),U(),document.execCommand(e,!1,t),L()};r.useEffect(()=>{const e=D();if(!e||!E)return;const t=Fe(E);e.innerHTML=t,L()},[]);const Fe=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{S&&S(e=>{Ve(e)})},[]),r.useEffect(()=>{const e=D();if(!e)return;e.querySelectorAll("table").forEach(n=>{n.hasAttribute("data-has-resize-handle")||(ne(n),n.querySelectorAll("th, td").forEach(s=>$(s)))})},[]);const se=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},de=e=>{var p;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=se(n.startContainer);let s,l;if(o){let v=o.querySelector(e);v||(v=document.createElement(e),v.style.margin="0",v.style.paddingLeft="20px",o.appendChild(v)),l=v,s=document.createElement("li"),s.textContent="â",l.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const v=D();if(l=v==null?void 0:v.querySelector(`${e}:last-child`),!l)return;s=l.querySelector("li:last-child")}const c=document.createRange();c.setStart(s,0),c.collapse(!0),t.removeAllRanges(),t.addRange(c),(p=D())==null||p.focus(),L()},ee=(e,t)=>{e==="insertOrderedList"?de("ol"):e==="insertUnorderedList"?de("ul"):e.startsWith("justify")?ot(e):ie(e,t),e==="insertTable"&&Ye()},Pe=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),W({x:n.left,y:n.bottom+window.scrollY}),z(a||[]),H(!0),B.current=e.cloneRange()},Ie=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const s=o.textContent||"",l=o===t?n:s.length,c=s.lastIndexOf("@",l-1);if(c!==-1){const p=document.createRange();return p.setStart(o,c),p.setEnd(o,l),p}}o=o.previousSibling}return null},qe=e=>{var l;const t=window.getSelection();if(!t)return;const n=Ie();n?(t.removeAllRanges(),t.addRange(n)):B.current&&(t.removeAllRanges(),t.addRange(B.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const c=t.rangeCount?t.getRangeAt(0):null;if(c)c.deleteContents(),c.insertNode(o);else{const f=document.createRange(),u=D();f.selectNodeContents(u),f.collapse(!1),f.insertNode(o)}const p=document.createTextNode(" ");o.after(p);const v=document.createRange();v.setStartAfter(p),v.collapse(!0),t.removeAllRanges(),t.addRange(v)}catch(c){console.error("insertMention error:",c)}let s=Me([...ce,e]);G(s),x(s),H(!1),(l=D())==null||l.focus(),L()},Be=e=>{const t=D();if(!t)return;let n=null;T.current&&t.contains(T.current.startContainer)?n=T.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),n.insertNode(s);const l=document.createTextNode(" ");s.after(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),o.removeAllRanges(),o.addRange(c),T.current=c.cloneRange(),t.focus()},Ve=e=>{e.forEach(t=>Be(t)),G(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(s=>[s.name,s])).values());return x(o),o}),L()},Ue=()=>{const e=D();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",c=(o.textContent||"").match(/{{(.+?)}}/);c&&n.push({name:c[1],value:s})}),n},$e=e=>{var n,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ee(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),c=l!=null&&l.anchorNode?se(l.anchorNode):null;if(!c)return;if(((n=c.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const v=c.parentElement,f=v==null?void 0:v.closest("li");if(f){v==null||v.removeChild(c);const u=document.createElement("p");u.innerHTML="<br />",(o=f.parentElement)==null||o.insertBefore(u,f.nextSibling);const g=document.createRange();g.setStart(u,0),g.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(g)}else{const u=c.closest("ul, ol");if(u){const g=document.createElement("p");g.innerHTML="<br />",(s=u.parentElement)==null||s.insertBefore(g,u.nextSibling),u.removeChild(c);const b=document.createRange();b.setStart(g,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}}L()}}if(t==="backspace"||t==="delete"){const l=window.getSelection();if(!l||l.rangeCount===0)return;const c=l.getRangeAt(0);if(c.cloneContents().querySelector("table")){console.log("Deleting full table...");return}if(c.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},We=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(te(o))return;setTimeout(()=>{Pe(n.getRangeAt(0)),J(""),z(a),H(!0)},0);return}if(_){setTimeout(()=>ue(),0);return}},te=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},ue=()=>{L();const e=window.getSelection();if(!e||!e.anchorNode)return;if(te(e.anchorNode)){H(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const n=t.match(/@([^\n]*)$/);if(!n){H(!1);return}const o=n[1].trim().toLowerCase();J(o);const s=a.filter(l=>l.name.toLowerCase().includes(o));s.length>0?(z(s),H(!0)):H(!1)},Ke=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=s=>{var b;const l=(b=s.target)==null?void 0:b.result;U();const c=window.getSelection();let p=c&&c.rangeCount?c.getRangeAt(0):null;const v=document.createElement("img");v.src=l,v.alt=t.name||"image",v.className="rte-inserted-image",v.contentEditable="true";const f=D();if(!p||!f){f==null||f.appendChild(v);const be=document.createTextNode(" ");f==null||f.appendChild(be);const re=document.createRange();re.setStartAfter(be),re.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(re),f==null||f.focus(),L(),e.target.value="";return}p.deleteContents(),p.insertNode(v);const u=document.createTextNode(" ");v.after(u);const g=document.createRange();g.setStartAfter(u),g.collapse(!0),c.removeAllRanges(),c.addRange(g),f.focus(),L(),e.target.value=""},n.readAsDataURL(t)},Xe=e=>{var s;U();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(s=D())==null||s.focus(),L()},Ye=()=>{var f;st(),U();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",e.style.textAlign="center",y.table&&e.classList.add(y.table);const t=document.createElement("thead");y.thead&&t.classList.add(y.thead);const n=document.createElement("tbody");y.tbody&&n.classList.add(y.tbody);const o=document.createElement("tr");y.tr&&o.classList.add(y.tr);const s=document.createElement("tr");y.tr&&s.classList.add(y.tr);for(let u=0;u<2;u++){const g=document.createElement("th");g.textContent="",g.style.border="1px solid #999",g.style.padding="4px",g.style.position="relative",g.style.backgroundColor="lightgray",g.style.height="20px",y.th&&g.classList.add(y.th);const b=document.createElement("td");b.textContent="",b.style.border="1px solid #999",b.style.padding="4px",b.style.position="relative",b.style.backgroundColor="#fff",b.style.height="20px",y.td&&b.classList.add(y.td),$(g),$(b),o.appendChild(g),s.appendChild(b)}t.appendChild(o),n.appendChild(s),e.appendChild(t),e.appendChild(n),ne(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const c=l.getRangeAt(0);c.collapse(!1),c.insertNode(e);const p=document.createElement("p");p.innerHTML="<br/>",e.after(p);const v=document.createRange();v.setStart(p,0),v.collapse(!0),l.removeAllRanges(),l.addRange(v),(f=D())==null||f.focus(),L()},ne=e=>{if(e.dataset.hasResizeHandle==="true")return;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"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let n=0,o=0,s=0,l=0;t.addEventListener("mousedown",c=>{c.preventDefault(),n=c.clientX,o=c.clientY;const p=e.getBoundingClientRect();s=p.width,l=p.height;const v=u=>{const g=Math.max(100,s+(u.clientX-n)),b=Math.max(20,l+(u.clientY-o));e.style.width=`${g}px`,e.style.height=`${b}px`,L()},f=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",f),L()};document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)}),e.appendChild(t)},$=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",n.classList.add("rte-resize-handle"),Ze(e,t,n),e.appendChild(t),e.appendChild(n)},Ze=(e,t,n)=>{let o=0,s=0,l=0,c=0;t.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,l=e.offsetWidth,document.addEventListener("mousemove",p),document.addEventListener("mouseup",f)}),n.addEventListener("mousedown",u=>{u.preventDefault(),s=u.clientY,c=e.offsetHeight,document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)});const p=u=>{const g=l+(u.clientX-o);e.style.width=`${Math.max(30,g)}px`,L()},v=u=>{const g=c+(u.clientY-s);e.style.height=`${Math.max(20,g)}px`,L()},f=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",f),L()}},Qe=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),h({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},me=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Je=e=>{if(!O.cell)return;const t=O.cell.closest("table"),n=O.cell.cellIndex,o=O.cell.parentElement.rowIndex,s=l=>{const c=l.tagName.toLowerCase(),p=document.createElement(c);return p.textContent="",p.style.cssText=l.style.cssText,$(p),p};switch(e){case"insertRowAbove":{const l=t.rows[o],c=t.insertRow(o);Array.from(l.cells).forEach(p=>{c.appendChild(s(p))});break}case"insertRowBelow":{const l=t.rows[o],c=t.insertRow(o+1);Array.from(l.cells).forEach(p=>{c.appendChild(s(p))});break}case"insertColLeft":{Array.from(t.rows).forEach(l=>{const c=l.cells[n];l.insertBefore(s(c),c)});break}case"insertColRight":{Array.from(t.rows).forEach(l=>{const c=l.cells[n];l.insertBefore(s(c),c.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(l=>{l.cells[n]&&l.deleteCell(n)});break}L(),h(oe(ae({},O),{visible:!1})),me()},Ge=()=>{V(),K.current=T.current,le({url:"",text:"",title:"",target:"_self"}),j(!0)},et=e=>{const t=window.getSelection();if(!t||!K.current)return;t.removeAllRanges(),t.addRange(K.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");o.href=n,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||n,o.title=e.title,o.target=e.target,o.contentEditable="true";const s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const l=document.createTextNode(" ");o.after(l);const c=document.createRange();c.setStartAfter(l),c.collapse(!0),t.removeAllRanges(),t.addRange(c),j(!1),L()},tt=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),K.current=o,le({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),j(!0)}},nt=()=>{const e=D();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&T.current){const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(T.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);U(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),l=document.createElement("div");l.appendChild(s);const c=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),p=[];for(;c.nextNode();){const u=c.currentNode,g=u.tagName.toUpperCase(),b=u.getAttribute&&u.getAttribute("data-mention")!==null;g!=="A"&&!b&&p.push(u)}for(let u=p.length-1;u>=0;u--){const g=p[u],b=g.parentNode;if(b){for(;g.firstChild;)b.insertBefore(g.firstChild,g);b.removeChild(g)}}l.querySelectorAll("[style]").forEach(u=>u.removeAttribute("style")),o.deleteContents();const v=document.createDocumentFragment();for(;l.firstChild;)v.appendChild(l.firstChild);o.insertNode(v);const f=document.createRange();f.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),f.collapse(!0),n.removeAllRanges(),n.addRange(f),e.normalize(),L()},rt=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(s=>{s.replaceWith(`
|
|
3
|
-
`)}),n.querySelectorAll("
|
|
4
|
-
`)}),n.querySelectorAll("table").forEach(s=>{s.insertAdjacentText("afterend",`
|
|
1
|
+
"use strict";var ht=Object.defineProperty,pt=Object.defineProperties;var vt=Object.getOwnPropertyDescriptors;var Ae=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var Te=(a,c,u)=>c in a?ht(a,c,{enumerable:!0,configurable:!0,writable:!0,value:u}):a[c]=u,oe=(a,c)=>{for(var u in c||(c={}))yt.call(c,u)&&Te(a,u,c[u]);if(Ae)for(var u of Ae(c))Et.call(c,u)&&Te(a,u,c[u]);return a},le=(a,c)=>pt(a,vt(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),wt=require("react-dom");function Ct(a){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const u in a)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(a,u);Object.defineProperty(c,u,m.get?m:{enumerable:!0,get:()=>a[u]})}}return c.default=a,Object.freeze(c)}const bt=Ct(r);window.React=bt;var Oe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ne=r.createContext&&r.createContext(Oe),Lt=["attr","size","title"];function Rt(a,c){if(a==null)return{};var u=St(a,c),m,p;if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(a);for(p=0;p<C.length;p++)m=C[p],!(c.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(a,m)&&(u[m]=a[m])}return u}function St(a,c){if(a==null)return{};var u={};for(var m in a)if(Object.prototype.hasOwnProperty.call(a,m)){if(c.indexOf(m)>=0)continue;u[m]=a[m]}return u}function Y(){return Y=Object.assign?Object.assign.bind():function(a){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(a[m]=u[m])}return a},Y.apply(this,arguments)}function ke(a,c){var u=Object.keys(a);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(a);c&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(a,p).enumerable})),u.push.apply(u,m)}return u}function Q(a){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?ke(Object(u),!0).forEach(function(m){xt(a,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(u)):ke(Object(u)).forEach(function(m){Object.defineProperty(a,m,Object.getOwnPropertyDescriptor(u,m))})}return a}function xt(a,c,u){return c=Mt(c),c in a?Object.defineProperty(a,c,{value:u,enumerable:!0,configurable:!0,writable:!0}):a[c]=u,a}function Mt(a){var c=At(a,"string");return typeof c=="symbol"?c:c+""}function At(a,c){if(typeof a!="object"||!a)return a;var u=a[Symbol.toPrimitive];if(u!==void 0){var m=u.call(a,c);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(a)}function He(a){return a&&a.map((c,u)=>r.createElement(c.tag,Q({key:u},c.attr),He(c.child)))}function N(a){return c=>r.createElement(Tt,Y({attr:Q({},a.attr)},c),He(a.child))}function Tt(a){var c=u=>{var{attr:m,size:p,title:C}=a,L=Rt(a,Lt),T=p||u.size||"1em",E;return u.className&&(E=u.className),a.className&&(E=(E?E+" ":"")+a.className),r.createElement("svg",Y({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,L,{className:E,style:Q(Q({color:a.color||u.color},u.style),a.style),height:T,width:T,xmlns:"http://www.w3.org/2000/svg"}),C&&r.createElement("title",null,C),a.children)};return Ne!==void 0?r.createElement(Ne.Consumer,null,u=>c(u)):c(Oe)}function Nt(a){return N({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 kt(a){return N({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 zt(a){return N({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 Dt(a){return N({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 Ot(a){return N({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 Ht(a){return N({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 jt(a){return N({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 _t(a){return N({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 Pt(a){return N({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 Ft(a){return N({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 It(a){return N({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 qt(a){return N({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 Bt(a){return N({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(a)}function Ut(a){return N({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(a)}function Vt(a){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(a)}function $t(a){return N({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(a)}function Wt(a){return N({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 Zt(a){return N({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 Xt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],je=({exec:a,saveSelection:c,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:C,handleLink:L,removeFormatting:T,visibleActions:E,className:R,style:x})=>{var U,H;const M=r.useRef(null),I=r.useRef(null),k=r.useRef(null),[q,B]=r.useState(!1),[P,j]=r.useState({x:0,y:0});r.useEffect(()=>{const g=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&B(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const F=g=>{var _;g.preventDefault();const b=g.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":a(b);break;case"insertImage":{(_=M.current)==null||_.click();break}default:console.warn("Unknown command:",b)}},Z=g=>{a("foreColor",g.target.value)},J=g=>{a("backColor",g.target.value)},[S,z]=r.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 r.useEffect(()=>{const g=()=>{z({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)},[]),r.createElement("div",{className:`rte-toolbar ${R||""}`,style:x},E.bold&&r.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:F,className:S.bold?"rte-active":""},r.createElement(Ht,null)),E.italic&&r.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:F,className:S.italic?"rte-active":""},r.createElement(_t,null)),E.underline&&r.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:F,className:S.underline?"rte-active":""},r.createElement(qt,null)),E.unorderedList&&r.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:F,title:"UnorderedList",className:S.unorderedList?"rte-active":""},r.createElement(Ut,null)),E.staticUnorderedList&&r.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:F,title:"StaticUnorderedList",className:S.unorderedList?"rte-active":""},r.createElement(Ft,null)),E.orderedList&&r.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:F,className:S.orderedList?"rte-active":"",style:{fontSize:"medium"}},r.createElement(Bt,null)),E.staticOrderedList&&r.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:F,className:S.orderedList?"rte-active":""},r.createElement(Dt,null)),E.link&&r.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:S.link?"rte-active":""},r.createElement(Pt,null)),E.removeFormat&&r.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),c(),T()},className:S.removeFormat?"rte-active":""},r.createElement(Zt,null)),E.image&&r.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:F,className:S.image?"rte-active":""},r.createElement(zt,null)),r.createElement("input",{type:"file",accept:"image/*",ref:M,style:{display:"none"},onChange:u}),E.emoji&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),c();const b=g.currentTarget.getBoundingClientRect();j({x:b.left,y:b.bottom+8}),B(_=>!_)},className:S.emoji?"rte-active":""},r.createElement(It,null)),q&&wt.createPortal(r.createElement("div",{className:"rte-emoji-popup",style:{top:P.y,left:P.x}},Xt.map((g,b)=>r.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:_=>{_.preventDefault(),C(g),B(!1)}},g))),document.body)),E.color&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Text Color",onMouseDown:g=>{var b;g.preventDefault(),c(),(b=I.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((U=I.current)==null?void 0:U.value)||"#000",fontSize:"18px"},className:S.color?"rte-active":""},r.createElement(Wt,null)),r.createElement("input",{ref:I,type:"color",defaultValue:"#000000",onChange:g=>{var b;Z(g),((b=g.target.parentElement)==null?void 0:b.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&r.createElement("div",{style:{position:"relative"}},r.createElement("button",{title:"Highlight",onMouseDown:g=>{var b;g.preventDefault(),c(),(b=k.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((H=k.current)==null?void 0:H.value)||"#000",fontSize:"18px"},className:S.highlight?"rte-active":""},r.createElement(jt,null)),r.createElement("input",{ref:k,type:"color",onChange:g=>{var b;J(g),((b=g.target.parentElement)==null?void 0:b.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&r.createElement(r.Fragment,null,r.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyLeft"),className:S.alignLeft?"rte-active":""},r.createElement(Ot,null)),r.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyCenter"),className:S.alignCenter?"rte-active":""},r.createElement(Nt,null)),r.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>a("justifyRight"),className:S.alignRight?"rte-active":""},r.createElement(kt,null))),E.table&&r.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},r.createElement(Vt,null)),E.table&&r.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>a("insertStaticTable"),className:S.table?"rte-active":"",style:{fontSize:"medium"}},r.createElement($t,null)),E.fontFamily&&r.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:p},r.createElement("option",{value:"",disabled:!0},"Font Family"),r.createElement("option",{value:"Arial"},"Arial"),r.createElement("option",{value:"Georgia"},"Georgia"),r.createElement("option",{value:"Times New Roman"},"Times New Roman"),r.createElement("option",{value:"Courier New"},"Courier New"),r.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&r.createElement("select",{className:"rte-dropdown rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},r.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,b)=>10+b).map(g=>r.createElement("option",{key:g,value:g},g,"px"))))},Kt=({show:a,position:c,filtered:u,insertMention:m,onClose:p,query:C})=>{const L=r.useRef(null),[T,E]=r.useState(0);return r.useEffect(()=>{a&&E(0)},[a]),r.useEffect(()=>{const R=x=>{L.current&&!L.current.contains(x.target)&&p()};return a&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[a,p]),r.useEffect(()=>{if(!a)return;const R=x=>{if(!(!a||u.length===0)&&(x.key==="ArrowDown"&&(x.preventDefault(),E(M=>Math.min(M+1,u.length-1))),x.key==="ArrowUp"&&(x.preventDefault(),E(M=>Math.max(M-1,0))),x.key==="Enter")){x.preventDefault();const M=u[T];M&&m(M)}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[a,u,T]),r.useEffect(()=>{if(!L.current)return;const x=L.current.querySelectorAll("li")[T];x&&x.scrollIntoView({block:"nearest",behavior:"smooth"})},[T]),a?r.createElement("ul",{ref:L,className:"rte-popup",style:{top:c.y,left:c.x}},u.length>0?u.map(({name:R,value:x},M)=>{const I=R.toLowerCase(),k=C.toLowerCase(),q=I.indexOf(k);let B=R;if(q!==-1&&C.length>0){const P=q+C.length;B=R.substring(0,q)+`<span class="rte-highlight">${R.substring(q,P)}</span>`+R.substring(P)}return r.createElement("li",{key:x,onMouseDown:P=>{P.preventDefault(),m({name:R,value:x})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:M===T?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:B},onMouseEnter:()=>E(M)})}):r.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ze(a){return N({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 N({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 Yt=({visible:a,x:c,y:u,onAction:m,onClose:p})=>{if(!a)return null;const C={top:u,left:c};return r.createElement("div",{style:C,className:"rte-table-menu",onMouseLeave:p},r.createElement("button",{onClick:()=>m("insertRowAbove")},r.createElement(K,null)," Insert row above"),r.createElement("button",{onClick:()=>m("insertRowBelow")},r.createElement(K,null)," Insert row below"),r.createElement("button",{onClick:()=>m("insertColLeft")},r.createElement(K,null)," Insert col left"),r.createElement("button",{onClick:()=>m("insertColRight")},r.createElement(K,null)," Insert col right"),r.createElement("button",{onClick:()=>m("deleteRow")},r.createElement(ze,null)," Delete row"),r.createElement("button",{onClick:()=>m("deleteCol")},r.createElement(ze,null)," Delete column"))},_e=({html:a,className:c,style:u})=>{const m=C=>{const L=C.target;if(L.tagName==="A"){C.preventDefault();const T=L.href;T&&window.open(T,"_blank","noopener,noreferrer")}},p=C=>{let L=C.replace(/{{\s*(.*?)\s*}}/g,(T,E)=>`<span style="color: blue">${E}</span>`);return L=L.replace(/#arrayData/g,""),L=L.replace(/\/arrayData/g,""),L};return r.createElement("div",{className:`rte-preview ${c||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:p(a)}})},Qt=({visible:a,linkData:c,onClose:u,onInsert:m})=>{const[p,C]=r.useState(""),[L,T]=r.useState(""),[E,R]=r.useState(""),[x,M]=r.useState("_self");if(r.useEffect(()=>{a?(C(c.url||""),T(c.text||""),R(c.title||""),M(c.target||"_self")):(C(""),T(""),R(""),M("_self"))},[a,c]),!a)return null;const I=()=>{m({url:p,text:L,title:E,target:x})};return r.createElement(r.Fragment,null,r.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),r.createElement("div",{className:"rte-link-modal"},r.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:k=>C(k.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:k=>T(k.target.value)}),r.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:k=>R(k.target.value)}),r.createElement("select",{className:"rte-link-modal__select",value:x,onChange:k=>M(k.target.value)},r.createElement("option",{value:"_self"},"Same tab"),r.createElement("option",{value:"_blank"},"New tab")),r.createElement("div",{className:"rte-link-modal__actions"},r.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),r.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:I},"OK"))))};function De(a){const c=new Map;return a.forEach(u=>{c.set(u.name,u.value)}),Array.from(c.entries()).map(([u,m])=>({name:u,value:m}))}const Jt=({atSuggestions:a=[],showOutput:c=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:p={},styles:C={},handleGetHtml:L=()=>{},onChange:T=()=>{},value:E,onMentionSelect:R=()=>{},handleAddAttributes:x=()=>{}})=>{var pe,ve,ye,Ee,we,Ce,be,Le,Re,Se,xe,Me;const M=r.useRef(null),[I,k]=r.useState(E!=null&&E.length?E:" "),[q,B]=r.useState(""),[P,j]=r.useState(!1),[F,Z]=r.useState({x:0,y:0}),[J,S]=r.useState([]),z=r.useRef(null),U=r.useRef(null),[H,g]=r.useState({visible:!1,x:0,y:0}),[b,_]=r.useState(!1),X=r.useRef(null),[Pe,ie]=r.useState({url:"",text:"",title:"",target:"_self"}),Fe={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(pe=m.unorderedList)!=null?pe:!0,orderedList:(ve=m.orderedList)!=null?ve:!0,staticUnorderedList:(ye=m.staticUnorderedList)!=null?ye:!0,staticOrderedList:(Ee=m.staticOrderedList)!=null?Ee:!0,align:!0,link:(we=m.link)!=null?we:!1,image:(Ce=m.image)!=null?Ce:!1,emoji:(be=m.emoji)!=null?be:!1,table:(Le=m.table)!=null?Le:!1,color:(Re=m.color)!=null?Re:!1,fontFamily:(Se=m.fontFamily)!=null?Se:!1,fontSize:(xe=m.fontSize)!=null?xe:!1,highlight:(Me=m.fontSize)!=null?Me:!1},[Ie,G]=r.useState(""),[ce,ee]=r.useState([]),O=()=>M.current,A=()=>{const e=qe(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let n=e;t||(n=`<div style="font-size:12px">${e}</div>`),n=n.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(l,h,y)=>{if(/list-type=["']static["']/.test(y)||l.includes("data-hidden-array-start")||l.includes("data-hidden-array-end"))return l;const f=`<${h}${y}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',v='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',w=`</${h}>`,D=l.replace(new RegExp(`^${f}`),"").replace(new RegExp(`${w}$`),"");return`${f}${s}${D}${v}${w}`}),B(n),L==null||L(n);const o=it(e);T(o);const d=Ke(),i=De(d);JSON.stringify(i)!==JSON.stringify(ce)&&(ee(i),R(i))},qe=()=>{const e=O();if(!e)return I;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let n=t.innerHTML;return n=Be(n),n},Be=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(n=>{n.getAttribute("table-type")==="static"||(n.innerHTML=`{{#arrayData}}${n.innerHTML}{{/arrayData}}`)}),t.innerHTML},V=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=document.getElementById("rte-editor-body");if(!t)return;const n=e.getRangeAt(0);t.contains(n.startContainer)&&(z.current=n.cloneRange())},$=()=>{const e=window.getSelection();!e||!z.current||(e.removeAllRanges(),e.addRange(z.current))},se=(e,t)=>{const n=window.getSelection();n&&n.rangeCount>0&&(z.current=n.getRangeAt(0)),$(),document.execCommand(e,!1,t),A()};r.useEffect(()=>{const e=O();if(!e||!E)return;const t=Ue(E);e.innerHTML=t,A()},[]);const Ue=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");r.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),r.useEffect(()=>{x&&x(e=>{Xe(e)})},[]),r.useEffect(()=>{const e=O();if(!e)return;e.querySelectorAll("table").forEach(n=>{n.hasAttribute("data-has-resize-handle")||(re(n),n.querySelectorAll("th, td").forEach(d=>W(d)))})},[]);const de=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ue=(e,t)=>{var f;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.getRangeAt(0),d=de(o.startContainer);let i,l;const h=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(d){let s=d.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",d.appendChild(s)),l=s,i=document.createElement("li"),i.textContent="â",l.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=O();if(l=s==null?void 0:s.querySelector(`${e}:last-child`),!l)return;h&&l.setAttribute("list-type","static"),i=l.querySelector("li:last-child")}const y=document.createRange();y.setStart(i,0),y.collapse(!0),n.removeAllRanges(),n.addRange(y),(f=O())==null||f.focus(),A()},te=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?ue("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?ue("ul",e):e.startsWith("justify")?st(e):se(e,t),e==="insertTable"&&fe(),e==="insertStaticTable"&&fe("insertStaticTable")},Ve=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const n=t.getBoundingClientRect();t.remove(),Z({x:n.left,y:n.bottom+window.scrollY}),S(a||[]),j(!0),U.current=e.cloneRange()},$e=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let n=e.anchorOffset;if(!t)return null;let o=t;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[n]?o=o.childNodes[n]:o=t.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const d=o.textContent||"",i=o===t?n:d.length,l=d.lastIndexOf("@",i-1);if(l!==-1){const h=document.createRange();return h.setStart(o,l),h.setEnd(o,i),h}}o=o.previousSibling}return null},We=e=>{var i;const t=window.getSelection();if(!t)return;const n=$e();n?(t.removeAllRanges(),t.addRange(n)):U.current&&(t.removeAllRanges(),t.addRange(U.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",o.setAttribute("data-mention",e.value||e.name||"");try{const l=t.rangeCount?t.getRangeAt(0):null;if(l)l.deleteContents(),l.insertNode(o);else{const f=document.createRange(),s=O();f.selectNodeContents(s),f.collapse(!1),f.insertNode(o)}const h=document.createTextNode(" ");o.after(h);const y=document.createRange();y.setStartAfter(h),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(l){console.error("insertMention error:",l)}let d=De([...ce,e]);ee(d),R(d),j(!1),(i=O())==null||i.focus(),A()},Ze=e=>{const t=O();if(!t)return;let n=null;z.current&&t.contains(z.current.startContainer)?n=z.current.cloneRange():(n=document.createRange(),n.selectNodeContents(t),n.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(n);const d=document.createElement("span");d.textContent=`{{${e.name}}}`,d.style.display="inline",d.setAttribute("data-mention",e.value||e.name),n.insertNode(d);const i=document.createTextNode(" ");d.after(i);const l=document.createRange();l.setStartAfter(i),l.collapse(!0),o.removeAllRanges(),o.addRange(l),z.current=l.cloneRange(),t.focus()},Xe=e=>{e.forEach(t=>Ze(t)),ee(t=>{const n=[...t,...e],o=Array.from(new Map(n.map(d=>[d.name,d])).values());return R(o),o}),A()},Ke=()=>{const e=O();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),n=[];return t.forEach(o=>{const d=o.getAttribute("data-mention")||"",l=(o.textContent||"").match(/{{(.+?)}}/);l&&n.push({name:l[1],value:d})}),n},Ye=e=>{var n,o,d;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),te(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),l=i!=null&&i.anchorNode?de(i.anchorNode):null;if(!l)return;if(((n=l.textContent)==null?void 0:n.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=l.parentElement,f=y==null?void 0:y.closest("li");if(f){y==null||y.removeChild(l);const s=document.createElement("p");s.innerHTML="<br />",(o=f.parentElement)==null||o.insertBefore(s,f.nextSibling);const v=document.createRange();v.setStart(s,0),v.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(v)}else{const s=l.closest("ul, ol");if(s){const v=document.createElement("p");v.innerHTML="<br />",(d=s.parentElement)==null||d.insertBefore(v,s.nextSibling),s.removeChild(l);const w=document.createRange();w.setStart(v,0),w.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(w)}}A()}}if(t==="backspace"||t==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const l=i.getRangeAt(0);if(l.cloneContents().querySelector("table"))return;if(l.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},Qe=e=>{if(e.data==="@"){const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.anchorNode;if(ne(o))return;setTimeout(()=>{Ve(n.getRangeAt(0)),G(""),S(a),j(!0)},0);return}if(P){setTimeout(()=>me(),0);return}},ne=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},me=()=>{A();const e=window.getSelection();if(!e||!e.anchorNode)return;if(ne(e.anchorNode)){j(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const n=t.match(/@([^\n]*)$/);if(!n){j(!1);return}const o=n[1].trim().toLowerCase();G(o);const d=a.filter(i=>i.name.toLowerCase().includes(o));d.length>0?(S(d),j(!0)):j(!1)},Je=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const n=new FileReader;n.onload=d=>{var w;const i=(w=d.target)==null?void 0:w.result;$();const l=window.getSelection();let h=l&&l.rangeCount?l.getRangeAt(0):null;const y=document.createElement("img");y.src=i,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const f=O();if(!h||!f){f==null||f.appendChild(y);const D=document.createTextNode(" ");f==null||f.appendChild(D);const ae=document.createRange();ae.setStartAfter(D),ae.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(ae),f==null||f.focus(),A(),e.target.value="";return}h.deleteContents(),h.insertNode(y);const s=document.createTextNode(" ");y.after(s);const v=document.createRange();v.setStartAfter(s),v.collapse(!0),l.removeAllRanges(),l.addRange(v),f.focus(),A(),e.target.value=""},n.readAsDataURL(t)},Ge=e=>{var d;$();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const n=t.getRangeAt(0),o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),(d=O())==null||d.focus(),A()},fe=e=>{var s;ft(),$();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="100%",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",p.table&&t.classList.add(p.table);const n=document.createElement("thead");p.thead&&n.classList.add(p.thead);const o=document.createElement("tbody");p.tbody&&o.classList.add(p.tbody),e==="insertStaticTable"&&o.setAttribute("table-type","static");const d=document.createElement("tr");p.tr&&d.classList.add(p.tr);const i=document.createElement("tr");p.tr&&i.classList.add(p.tr);for(let v=0;v<2;v++){const w=document.createElement("th");w.textContent="",w.style.border="1px solid #999",w.style.padding="4px",w.style.position="relative",w.style.backgroundColor="lightgray",w.style.height="20px",p.th&&w.classList.add(p.th);const D=document.createElement("td");D.textContent="",D.style.border="1px solid #999",D.style.padding="4px",D.style.position="relative",D.style.backgroundColor="#fff",D.style.height="20px",p.td&&D.classList.add(p.td),W(w),W(D),d.appendChild(w),i.appendChild(D)}n.appendChild(d),o.appendChild(i),t.appendChild(n),t.appendChild(o),re(t);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const h=l.getRangeAt(0);h.collapse(!1),h.insertNode(t);const y=document.createElement("p");y.innerHTML="<br/>",t.after(y);const f=document.createRange();f.setStart(y,0),f.collapse(!0),l.removeAllRanges(),l.addRange(f),(s=O())==null||s.focus(),A()},re=e=>{if(e.dataset.hasResizeHandle==="true")return;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"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let n=0,o=0,d=0,i=0;t.addEventListener("mousedown",l=>{l.preventDefault(),n=l.clientX,o=l.clientY;const h=e.getBoundingClientRect();d=h.width,i=h.height;const y=s=>{const v=Math.max(100,d+(s.clientX-n)),w=Math.max(20,i+(s.clientY-o));e.style.width=`${v}px`,e.style.height=`${w}px`,A()},f=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),A()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}),e.appendChild(t)},W=e=>{const t=document.createElement("div"),n=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(n.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),n.contentEditable="false",n.classList.add("rte-resize-handle"),et(e,t,n),e.appendChild(t),e.appendChild(n)},et=(e,t,n)=>{let o=0,d=0,i=0,l=0;t.addEventListener("mousedown",s=>{s.preventDefault(),o=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)}),n.addEventListener("mousedown",s=>{s.preventDefault(),d=s.clientY,l=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)});const h=s=>{const v=i+(s.clientX-o);e.style.width=`${Math.max(30,v)}px`,A()},y=s=>{const v=l+(s.clientY-d);e.style.height=`${Math.max(20,v)}px`,A()},f=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),A()}},tt=e=>{const n=e.target.closest("td, th");n&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:n}))},ge=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},nt=e=>{if(!H.cell)return;const t=H.cell.closest("table"),n=H.cell.cellIndex,o=H.cell.parentElement.rowIndex,d=i=>{const l=i.tagName.toLowerCase(),h=document.createElement(l);return h.textContent="",h.style.cssText=i.style.cssText,W(h),h};switch(e){case"insertRowAbove":{const i=t.rows[o],l=t.insertRow(o);Array.from(i.cells).forEach(h=>{l.appendChild(d(h))});break}case"insertRowBelow":{const i=t.rows[o],l=t.insertRow(o+1);Array.from(i.cells).forEach(h=>{l.appendChild(d(h))});break}case"insertColLeft":{Array.from(t.rows).forEach(i=>{const l=i.cells[n];i.insertBefore(d(l),l)});break}case"insertColRight":{Array.from(t.rows).forEach(i=>{const l=i.cells[n];i.insertBefore(d(l),l.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(i=>{i.cells[n]&&i.deleteCell(n)});break}A(),g(le(oe({},H),{visible:!1})),ge()},rt=()=>{V(),X.current=z.current,ie({url:"",text:"",title:"",target:"_self"}),_(!0)},at=e=>{const t=window.getSelection();if(!t||!X.current)return;t.removeAllRanges(),t.addRange(X.current);let n=e.url.trim();/^https?:\/\//i.test(n)||(n="https://"+n);const o=document.createElement("a");o.href=n,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||n,o.title=e.title,o.target=e.target,o.contentEditable="true";const d=t.getRangeAt(0);d.deleteContents(),d.insertNode(o);const i=document.createTextNode(" ");o.after(i);const l=document.createRange();l.setStartAfter(i),l.collapse(!0),t.removeAllRanges(),t.addRange(l),_(!1),A()},ot=e=>{const t=e.target;if(t.tagName==="A"){const n=t;if(e.ctrlKey||e.metaKey){window.open(n.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(n),X.current=o,ie({url:n.href,text:n.textContent||n.href,title:n.title,target:n.target}),_(!0)}},lt=()=>{const e=O();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&z.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(z.current)}const n=window.getSelection();if(!n||n.rangeCount===0)return;const o=n.getRangeAt(0);$(),document.execCommand("removeFormat",!1);const d=o.cloneContents(),i=document.createElement("div");i.appendChild(d);const l=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),h=[];for(;l.nextNode();){const s=l.currentNode,v=s.tagName.toUpperCase(),w=s.getAttribute&&s.getAttribute("data-mention")!==null;v!=="A"&&!w&&h.push(s)}for(let s=h.length-1;s>=0;s--){const v=h[s],w=v.parentNode;if(w){for(;v.firstChild;)w.insertBefore(v.firstChild,v);w.removeChild(v)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),o.deleteContents();const y=document.createDocumentFragment();for(;i.firstChild;)y.appendChild(i.firstChild);o.insertNode(y);const f=document.createRange();f.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),f.collapse(!0),n.removeAllRanges(),n.addRange(f),e.normalize(),A()},it=e=>{var o;let t=e;t=t.replace(/{{#arrayData\d*}}/g,""),t=t.replace(/{{\/arrayData\d*}}/g,"");const n=document.createElement("div");return n.innerHTML=t,n.querySelectorAll("br").forEach(d=>{d.replaceWith(`
|
|
2
|
+
`)}),n.querySelectorAll("p, div, tr").forEach(d=>{d.insertAdjacentText("afterend",`
|
|
3
|
+
`)}),n.querySelectorAll("table").forEach(d=>{d.insertAdjacentText("afterend",`
|
|
5
4
|
`)}),((o=n.textContent)==null?void 0:o.replace(/\n{3,}/g,`
|
|
6
5
|
|
|
7
|
-
`).trim())||""};function
|
|
6
|
+
`).trim())||""};function ct(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let i=t.startContainer,l=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;const h=l==null?void 0:l.closest("td, th");return h?[h]:[]}const n=t.commonAncestorContainer,o=n.nodeType===Node.ELEMENT_NODE?n:n.parentElement;return Array.from(o.querySelectorAll("td, th")).filter(i=>{const l=document.createRange();return l.selectNodeContents(i),t.compareBoundaryPoints(Range.END_TO_START,l)<0&&t.compareBoundaryPoints(Range.START_TO_END,l)>0})}function st(e){const t=ct();if(t.length===0){se(e);return}let n="left";e==="justifyCenter"&&(n="center"),e==="justifyRight"&&(n="right"),t.forEach(o=>{o.style.textAlign=n}),A()}const dt=e=>{e.preventDefault();const t=e.clipboardData.items;for(let f=0;f<t.length;f++){const s=t[f];if(s.kind==="file"&&s.type.startsWith("image/"))return;s.kind==="string"&&s.getAsString(v=>{/<img\s/i.test(v)})}const n=e.clipboardData.getData("text/html")||"";if(!n)return;const o=document.createElement("div");o.innerHTML=n;const d=f=>{f.style.borderCollapse="collapse",f.style.width="100%",f.style.border="1px solid #ccc",f.style.margin="8px 0",f.style.position="relative",f.style.textAlign="center",f.querySelectorAll("th").forEach(s=>{const v=s;v.style.border="1px solid #999",v.style.padding="4px",v.style.position="relative",v.style.backgroundColor="lightgray",v.style.height="20px"}),f.querySelectorAll("td").forEach(s=>{const v=s;v.style.border="1px solid #999",v.style.padding="4px",v.style.position="relative",v.style.backgroundColor="#fff",v.style.height="20px"})};o.querySelectorAll("table").forEach(f=>d(f));const i=window.getSelection();if(!i||!i.rangeCount)return;const l=i.getRangeAt(0);l.deleteContents();const h=document.createDocumentFragment();for(;o.firstChild;)h.appendChild(o.firstChild);l.insertNode(h),l.collapse(!1),i.removeAllRanges(),i.addRange(l);const y=M.current;y&&(y.querySelectorAll("table").forEach(f=>{const s=f;s.hasAttribute("data-has-resize-handle")||(re(s),s.querySelectorAll("th, td").forEach(v=>{const w=v;w.dataset.hasResizeHandles||W(w)}))}),A())},ut=e=>{$();const t=window.getSelection();if(!t||!t.rangeCount)return;const n=t.getRangeAt(0),o=document.createElement("span");o.style.fontSize=`${e}px`,o.appendChild(n.extractContents()),n.insertNode(o);const d=document.createRange();d.setStartAfter(o),d.collapse(!0),t.removeAllRanges(),t.addRange(d),A()},mt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(ne(t)||t.nodeType!==Node.TEXT_NODE)return null;const n=t.textContent||"",o=e.anchorOffset,d=n.lastIndexOf("@",o-1);if(d===-1)return null;const i=n.substring(d+1,o);if(i.includes(" ")||i.includes("Â "))return null;const l=document.createRange();return l.setStart(t,d),l.setEnd(t,o),{range:l,query:i}},he=()=>{const e=mt();if(!e)return;const{range:t,query:n}=e,o=document.createElement("span");o.textContent="â",t.insertNode(o);const d=o.getBoundingClientRect();o.remove(),Z({x:d.left,y:d.bottom+window.scrollY}),G(n.toLowerCase());const i=a.filter(l=>l.name.toLowerCase().includes(n.toLowerCase()));S(i),j(!0),U.current=t.cloneRange()};function ft(){const e=M.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n),z.current=n.cloneRange()}const gt=e=>{const t=e.target;if(!t||!(t.textContent||"").match(/{{([\s\S]+?)}}/)||!M.current)return;let i=t.firstChild;if((!i||i.nodeType!==Node.TEXT_NODE)&&(i=t.childNodes[0]),!i||i.nodeType!==Node.TEXT_NODE)return;const l=i.textContent||"",h=l.indexOf("{{"),y=l.indexOf("}}");if(h===-1||y===-1)return;const f=window.getSelection();if(!f)return;const s=document.createRange();s.setStart(i,h),s.setEnd(i,y+2),f.removeAllRanges(),f.addRange(s)};return r.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:C.wrapper},r.createElement("div",{style:{flex:1}},r.createElement(je,{exec:te,saveSelection:V,handleFileChange:Je,handleFontSizeChange:e=>ut(e.target.value),handleFontFamilyChange:e=>te("fontName",e.target.value),insertEmoji:Ge,handleLink:rt,removeFormatting:lt,visibleActions:Fe,className:p.toolbar,style:C.toolbar}),r.createElement("div",{ref:M,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:C.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:dt,onKeyUp:()=>{V(),he()},onMouseUp:V,onInput:()=>{me(),V()},onKeyDown:Ye,onBeforeInput:Qe,onContextMenu:tt,onClick:e=>{ot(e),V(),he()},onDoubleClick:gt}),r.createElement(Kt,{show:P,position:F,filtered:J,insertMention:We,onClose:()=>j(!1),query:Ie}),c&&r.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:C.output},r.createElement("h4",null,"Output HTML:"),r.createElement("p",null,q)),r.createElement(Yt,{visible:H.visible,x:H.x,y:H.y,onAction:nt,onClose:()=>{g(le(oe({},H),{visible:!1})),ge()}}),r.createElement(Qt,{visible:b,linkData:Pe,onClose:()=>_(!1),onInsert:at})),u?r.createElement(_e,{className:p.preview,style:C.preview,html:q}):null)};exports.RichTextEditor=Jt;exports.RtePreview=_e;exports.RteToolbar=je;
|
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
(function(z,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(z=typeof globalThis!="undefined"?globalThis:z||self,n(z.RichTextEditor={},z.React,z.ReactDOM))})(this,(function(z,n,j){"use strict";var Bt=Object.defineProperty,Rt=Object.defineProperties;var Vt=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var He=(z,n,j)=>n in z?Bt(z,n,{enumerable:!0,configurable:!0,writable:!0,value:j}):z[n]=j,ae=(z,n)=>{for(var j in n||(n={}))Ut.call(n,j)&&He(z,j,n[j]);if(Oe)for(var j of Oe(n))$t.call(n,j)&&He(z,j,n[j]);return z},ie=(z,n)=>Rt(z,Vt(n));function je(l){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const d in l)if(d!=="default"){const m=Object.getOwnPropertyDescriptor(l,d);Object.defineProperty(c,d,m.get?m:{enumerable:!0,get:()=>l[d]})}}return c.default=l,Object.freeze(c)}const _e=je(n);window.React=_e;var se={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ce=n.createContext&&n.createContext(se),Fe=["attr","size","title"];function Pe(l,c){if(l==null)return{};var d=Ie(l,c),m,y;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(l);for(y=0;y<w.length;y++)m=w[y],!(c.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(l,m)&&(d[m]=l[m])}return d}function Ie(l,c){if(l==null)return{};var d={};for(var m in l)if(Object.prototype.hasOwnProperty.call(l,m)){if(c.indexOf(m)>=0)continue;d[m]=l[m]}return d}function X(){return X=Object.assign?Object.assign.bind():function(l){for(var c=1;c<arguments.length;c++){var d=arguments[c];for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(l[m]=d[m])}return l},X.apply(this,arguments)}function de(l,c){var d=Object.keys(l);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(l);c&&(m=m.filter(function(y){return Object.getOwnPropertyDescriptor(l,y).enumerable})),d.push.apply(d,m)}return d}function Y(l){for(var c=1;c<arguments.length;c++){var d=arguments[c]!=null?arguments[c]:{};c%2?de(Object(d),!0).forEach(function(m){qe(l,m,d[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(d)):de(Object(d)).forEach(function(m){Object.defineProperty(l,m,Object.getOwnPropertyDescriptor(d,m))})}return l}function qe(l,c,d){return c=Be(c),c in l?Object.defineProperty(l,c,{value:d,enumerable:!0,configurable:!0,writable:!0}):l[c]=d,l}function Be(l){var c=Re(l,"string");return typeof c=="symbol"?c:c+""}function Re(l,c){if(typeof l!="object"||!l)return l;var d=l[Symbol.toPrimitive];if(d!==void 0){var m=d.call(l,c);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(l)}function ue(l){return l&&l.map((c,d)=>n.createElement(c.tag,Y({key:d},c.attr),ue(c.child)))}function T(l){return c=>n.createElement(Ve,X({attr:Y({},l.attr)},c),ue(l.child))}function Ve(l){var c=d=>{var{attr:m,size:y,title:w}=l,x=Pe(l,Fe),k=y||d.size||"1em",E;return d.className&&(E=d.className),l.className&&(E=(E?E+" ":"")+l.className),n.createElement("svg",X({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,m,x,{className:E,style:Y(Y({color:l.color||d.color},d.style),l.style),height:k,width:k,xmlns:"http://www.w3.org/2000/svg"}),w&&n.createElement("title",null,w),l.children)};return ce!==void 0?n.createElement(ce.Consumer,null,d=>c(d)):c(se)}function Ue(l){return T({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:[]}]})(l)}function $e(l){return T({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:[]}]})(l)}function We(l){return T({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:[]}]})(l)}function Ke(l){return T({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:[]}]})(l)}function Xe(l){return T({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:[]}]})(l)}function Ye(l){return T({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:[]}]})(l)}function Ze(l){return T({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:[]}]})(l)}function Qe(l){return T({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:[]}]})(l)}function Je(l){return T({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:[]}]})(l)}function Ge(l){return T({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:[]}]})(l)}function et(l){return T({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:[]}]})(l)}function tt(l){return T({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:[]}]})(l)}function nt(l){return T({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:[]}]})(l)}function rt(l){return T({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:[]}]})(l)}function ot(l){return T({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:[]}]})(l)}const lt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],me=({exec:l,saveSelection:c,handleFileChange:d,handleFontSizeChange:m,handleFontFamilyChange:y,insertEmoji:w,handleLink:x,removeFormatting:k,visibleActions:E,className:S,style:L})=>{var U,_;const M=n.useRef(null),q=n.useRef(null),D=n.useRef(null),[B,R]=n.useState(!1),[I,F]=n.useState({x:0,y:0});n.useEffect(()=>{const h=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&R(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const V=h=>{var P;h.preventDefault();const C=h.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":l(C);break;case"insertImage":{(P=M.current)==null||P.click();break}default:console.warn("Unknown command:",C)}},Q=h=>{l("foreColor",h.target.value)},G=h=>{l("backColor",h.target.value)},[N,O]=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 h=()=>{O({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",h),()=>document.removeEventListener("selectionchange",h)},[]),n.createElement("div",{className:`rte-toolbar ${S||""}`,style:L},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:V,className:N.bold?"rte-active":""},n.createElement(Ye,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:V,className:N.italic?"rte-active":""},n.createElement(Qe,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:V,className:N.underline?"rte-active":""},n.createElement(nt,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:V,title:"UnorderedList",className:N.unorderedList?"rte-active":""},n.createElement(Ge,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:V,className:N.orderedList?"rte-active":""},n.createElement(Ke,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:x,className:N.link?"rte-active":""},n.createElement(Je,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:h=>{h.preventDefault(),c(),k()},className:N.removeFormat?"rte-active":""},n.createElement(ot,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:V,className:N.image?"rte-active":""},n.createElement(We,null)),n.createElement("input",{type:"file",accept:"image/*",ref:M,style:{display:"none"},onChange:d}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:h=>{h.preventDefault(),c();const C=h.currentTarget.getBoundingClientRect();F({x:C.left,y:C.bottom+8}),R(P=>!P)},className:N.emoji?"rte-active":""},n.createElement(et,null)),B&&j.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:I.y,left:I.x}},lt.map((h,C)=>n.createElement("span",{key:C,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:P=>{P.preventDefault(),w(h),R(!1)}},h))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:h=>{var C;h.preventDefault(),c(),(C=q.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((U=q.current)==null?void 0:U.value)||"#000",fontSize:"18px"},className:N.color?"rte-active":""},n.createElement(rt,null)),n.createElement("input",{ref:q,type:"color",defaultValue:"#000000",onChange:h=>{var C;Q(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.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:h=>{var C;h.preventDefault(),c(),(C=D.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((_=D.current)==null?void 0:_.value)||"#000",fontSize:"18px"},className:N.highlight?"rte-active":""},n.createElement(Ze,null)),n.createElement("input",{ref:D,type:"color",onChange:h=>{var C;G(h),((C=h.target.parentElement)==null?void 0:C.querySelector("button")).style.color=h.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:h=>h.preventDefault(),onClick:()=>l("justifyLeft"),className:N.alignLeft?"rte-active":""},n.createElement(Xe,null)),n.createElement("button",{title:"Align Center",onMouseDown:h=>h.preventDefault(),onClick:()=>l("justifyCenter"),className:N.alignCenter?"rte-active":""},n.createElement(Ue,null)),n.createElement("button",{title:"Align Right",onMouseDown:h=>h.preventDefault(),onClick:()=>l("justifyRight"),className:N.alignRight?"rte-active":""},n.createElement($e,null))),E.table&&n.createElement("button",{title:"Insert Table",onMouseDown:h=>h.preventDefault(),onClick:()=>l("insertTable"),className:N.table?"rte-active":""},n.createElement(tt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:y},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 rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>c(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(h,C)=>10+C).map(h=>n.createElement("option",{key:h,value:h},h,"px"))))},at=({show:l,position:c,filtered:d,insertMention:m,onClose:y,query:w})=>{const x=n.useRef(null),[k,E]=n.useState(0);return n.useEffect(()=>{l&&E(0)},[l]),n.useEffect(()=>{const S=L=>{x.current&&!x.current.contains(L.target)&&y()};return l&&document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[l,y]),n.useEffect(()=>{if(!l)return;const S=L=>{if(!(!l||d.length===0)&&(L.key==="ArrowDown"&&(L.preventDefault(),E(M=>Math.min(M+1,d.length-1))),L.key==="ArrowUp"&&(L.preventDefault(),E(M=>Math.max(M-1,0))),L.key==="Enter")){L.preventDefault();const M=d[k];M&&m(M)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[l,d,k]),n.useEffect(()=>{if(!x.current)return;const L=x.current.querySelectorAll("li")[k];L&&L.scrollIntoView({block:"nearest",behavior:"smooth"})},[k]),l?n.createElement("ul",{ref:x,className:"rte-popup",style:{top:c.y,left:c.x}},d.length>0?d.map(({name:S,value:L},M)=>{const q=S.toLowerCase(),D=w.toLowerCase(),B=q.indexOf(D);let R=S;if(B!==-1&&w.length>0){const I=B+w.length;R=S.substring(0,B)+`<span class="rte-highlight">${S.substring(B,I)}</span>`+S.substring(I)}return n.createElement("li",{key:L,onMouseDown:I=>{I.preventDefault(),m({name:S,value:L})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:M===k?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:R},onMouseEnter:()=>E(M)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function fe(l){return T({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:[]}]}]}]})(l)}function Z(l){return T({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:[]}]}]}]})(l)}const it=({visible:l,x:c,y:d,onAction:m,onClose:y})=>{if(!l)return null;const w={top:d,left:c};return n.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:y},n.createElement("button",{onClick:()=>m("insertRowAbove")},n.createElement(Z,null)," Insert row above"),n.createElement("button",{onClick:()=>m("insertRowBelow")},n.createElement(Z,null)," Insert row below"),n.createElement("button",{onClick:()=>m("insertColLeft")},n.createElement(Z,null)," Insert col left"),n.createElement("button",{onClick:()=>m("insertColRight")},n.createElement(Z,null)," Insert col right"),n.createElement("button",{onClick:()=>m("deleteRow")},n.createElement(fe,null)," Delete row"),n.createElement("button",{onClick:()=>m("deleteCol")},n.createElement(fe,null)," Delete column"))},ge=({html:l,className:c,style:d})=>{const m=w=>{const x=w.target;if(x.tagName==="A"){w.preventDefault();const k=x.href;k&&window.open(k,"_blank","noopener,noreferrer")}},y=w=>{let x=w.replace(/{{\s*(.*?)\s*}}/g,(k,E)=>`<span style="color: blue">${E}</span>`);return x=x.replace(/#arrayData/g,""),x=x.replace(/\/arrayData/g,""),x};return n.createElement("div",{className:`rte-preview ${c||""}`,style:d,onClick:m,dangerouslySetInnerHTML:{__html:y(l)}})},st=({visible:l,linkData:c,onClose:d,onInsert:m})=>{const[y,w]=n.useState(""),[x,k]=n.useState(""),[E,S]=n.useState(""),[L,M]=n.useState("_self");if(n.useEffect(()=>{l?(w(c.url||""),k(c.text||""),S(c.title||""),M(c.target||"_self")):(w(""),k(""),S(""),M("_self"))},[l,c]),!l)return null;const q=()=>{m({url:y,text:x,title:E,target:L})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},y?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:y,onChange:D=>w(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:x,onChange:D=>k(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:D=>S(D.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:L,onChange:D=>M(D.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:d},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:q},"OK"))))};function he(l){const c=new Map;return l.forEach(d=>{c.set(d.name,d.value)}),Array.from(c.entries()).map(([d,m])=>({name:d,value:m}))}const ct=({atSuggestions:l=[],showOutput:c=!1,showPreview:d=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:y={},styles:w={},handleGetHtml:x=()=>{},onChange:k=()=>{},value:E,onMentionSelect:S=()=>{},handleAddAttributes:L=()=>{}})=>{var Se,Le,Ae,Me,ze,ke,Ne,Te;const M=n.useRef(null),[q,D]=n.useState(E!=null&&E.length?E:" "),[B,R]=n.useState(""),[I,F]=n.useState(!1),[V,Q]=n.useState({x:0,y:0}),[G,N]=n.useState([]),O=n.useRef(null),U=n.useRef(null),[_,h]=n.useState({visible:!1,x:0,y:0}),[C,P]=n.useState(!1),J=n.useRef(null),[dt,pe]=n.useState({url:"",text:"",title:"",target:"_self"}),ut={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(Se=m.link)!=null?Se:!1,image:(Le=m.image)!=null?Le:!1,emoji:(Ae=m.emoji)!=null?Ae:!1,table:(Me=m.table)!=null?Me:!1,color:(ze=m.color)!=null?ze:!1,fontFamily:(ke=m.fontFamily)!=null?ke:!1,fontSize:(Ne=m.fontSize)!=null?Ne:!1,highlight:(Te=m.fontSize)!=null?Te:!1},[mt,ee]=n.useState(""),[ve,te]=n.useState([]),H=()=>M.current,A=()=>{const e=ft(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size:12px">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>/g,(i,p,v)=>/data-hidden-array-start/.test(i)?i:`<${p}${v}>
|
|
2
|
-
<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>`),r=r.replace(/<\/(ul|ol)>/g,(i,p)=>/data-hidden-array-end/.test(i)?i:`<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span></${p}>`),R(r),x==null||x(r);const o=Ht(e);k(o);const s=Ct(),a=he(s);JSON.stringify(a)!==JSON.stringify(ve)&&(te(a),S(a))},ft=()=>{const e=H();if(!e)return q;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(o=>o.remove()),t.querySelectorAll("table").forEach(o=>{o.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight"));let r=t.innerHTML;return r=gt(r),r},gt=e=>e.replace(/<tbody[^>]*>/g,"<tbody>{{#arrayData}}").replace(/<\/tbody>/g,"{{/arrayData}}</tbody>"),$=()=>{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)&&(O.current=r.cloneRange())},W=()=>{const e=window.getSelection();!e||!O.current||(e.removeAllRanges(),e.addRange(O.current))},ye=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(O.current=r.getRangeAt(0)),W(),document.execCommand(e,!1,t),A()};n.useEffect(()=>{const e=H();if(!e||!E)return;const t=ht(E);e.innerHTML=t,A()},[]);const ht=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{L&&L(e=>{wt(e)})},[]),n.useEffect(()=>{const e=H();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(oe(r),r.querySelectorAll("th, td").forEach(s=>K(s)))})},[]);const Ee=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},we=e=>{var p;const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),o=Ee(r.startContainer);let s,a;if(o){let v=o.querySelector(e);v||(v=document.createElement(e),v.style.margin="0",v.style.paddingLeft="20px",o.appendChild(v)),a=v,s=document.createElement("li"),s.textContent="â",a.appendChild(s)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const v=H();if(a=v==null?void 0:v.querySelector(`${e}:last-child`),!a)return;s=a.querySelector("li:last-child")}const i=document.createRange();i.setStart(s,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),(p=H())==null||p.focus(),A()},ne=(e,t)=>{e==="insertOrderedList"?we("ol"):e==="insertUnorderedList"?we("ul"):e.startsWith("justify")?_t(e):ye(e,t),e==="insertTable"&&At()},pt=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}),N(l||[]),F(!0),U.current=e.cloneRange()},vt=()=>{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 s=o.textContent||"",a=o===t?r:s.length,i=s.lastIndexOf("@",a-1);if(i!==-1){const p=document.createRange();return p.setStart(o,i),p.setEnd(o,a),p}}o=o.previousSibling}return null},yt=e=>{var a;const t=window.getSelection();if(!t)return;const r=vt();r?(t.removeAllRanges(),t.addRange(r)):U.current&&(t.removeAllRanges(),t.addRange(U.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.display="inline",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 f=document.createRange(),u=H();f.selectNodeContents(u),f.collapse(!1),f.insertNode(o)}const p=document.createTextNode(" ");o.after(p);const v=document.createRange();v.setStartAfter(p),v.collapse(!0),t.removeAllRanges(),t.addRange(v)}catch(i){console.error("insertMention error:",i)}let s=he([...ve,e]);te(s),S(s),F(!1),(a=H())==null||a.focus(),A()},Et=e=>{const t=H();if(!t)return;let r=null;O.current&&t.contains(O.current.startContainer)?r=O.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const o=window.getSelection();if(!o)return;o.removeAllRanges(),o.addRange(r);const s=document.createElement("span");s.textContent=`{{${e.name}}}`,s.style.display="inline",s.setAttribute("data-mention",e.value||e.name),r.insertNode(s);const a=document.createTextNode(" ");s.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),o.removeAllRanges(),o.addRange(i),O.current=i.cloneRange(),t.focus()},wt=e=>{e.forEach(t=>Et(t)),te(t=>{const r=[...t,...e],o=Array.from(new Map(r.map(s=>[s.name,s])).values());return S(o),o}),A()},Ct=()=>{const e=H();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(o=>{const s=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&r.push({name:i[1],value:s})}),r},bt=e=>{var r,o,s;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),ne(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?Ee(a.anchorNode):null;if(!i)return;if(((r=i.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const v=i.parentElement,f=v==null?void 0:v.closest("li");if(f){v==null||v.removeChild(i);const u=document.createElement("p");u.innerHTML="<br />",(o=f.parentElement)==null||o.insertBefore(u,f.nextSibling);const g=document.createRange();g.setStart(u,0),g.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(g)}else{const u=i.closest("ul, ol");if(u){const g=document.createElement("p");g.innerHTML="<br />",(s=u.parentElement)==null||s.insertBefore(g,u.nextSibling),u.removeChild(i);const b=document.createRange();b.setStart(g,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(b)}}A()}}if(t==="backspace"||t==="delete"){const a=window.getSelection();if(!a||a.rangeCount===0)return;const i=a.getRangeAt(0);if(i.cloneContents().querySelector("table")){console.log("Deleting full table...");return}if(i.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},xt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.anchorNode;if(re(o))return;setTimeout(()=>{pt(r.getRangeAt(0)),ee(""),N(l),F(!0)},0);return}if(I){setTimeout(()=>Ce(),0);return}},re=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},Ce=()=>{A();const e=window.getSelection();if(!e||!e.anchorNode)return;if(re(e.anchorNode)){F(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){F(!1);return}const o=r[1].trim().toLowerCase();ee(o);const s=l.filter(a=>a.name.toLowerCase().includes(o));s.length>0?(N(s),F(!0)):F(!1)},St=e=>{var o;const t=(o=e.target.files)==null?void 0:o[0];if(!t)return;const r=new FileReader;r.onload=s=>{var b;const a=(b=s.target)==null?void 0:b.result;W();const i=window.getSelection();let p=i&&i.rangeCount?i.getRangeAt(0):null;const v=document.createElement("img");v.src=a,v.alt=t.name||"image",v.className="rte-inserted-image",v.contentEditable="true";const f=H();if(!p||!f){f==null||f.appendChild(v);const De=document.createTextNode(" ");f==null||f.appendChild(De);const le=document.createRange();le.setStartAfter(De),le.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(le),f==null||f.focus(),A(),e.target.value="";return}p.deleteContents(),p.insertNode(v);const u=document.createTextNode(" ");v.after(u);const g=document.createRange();g.setStartAfter(u),g.collapse(!0),i.removeAllRanges(),i.addRange(g),f.focus(),A(),e.target.value=""},r.readAsDataURL(t)},Lt=e=>{var s;W();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),(s=H())==null||s.focus(),A()},At=()=>{var f;qt(),W();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",e.style.textAlign="center",y.table&&e.classList.add(y.table);const t=document.createElement("thead");y.thead&&t.classList.add(y.thead);const r=document.createElement("tbody");y.tbody&&r.classList.add(y.tbody);const o=document.createElement("tr");y.tr&&o.classList.add(y.tr);const s=document.createElement("tr");y.tr&&s.classList.add(y.tr);for(let u=0;u<2;u++){const g=document.createElement("th");g.textContent="",g.style.border="1px solid #999",g.style.padding="4px",g.style.position="relative",g.style.backgroundColor="lightgray",g.style.height="20px",y.th&&g.classList.add(y.th);const b=document.createElement("td");b.textContent="",b.style.border="1px solid #999",b.style.padding="4px",b.style.position="relative",b.style.backgroundColor="#fff",b.style.height="20px",y.td&&b.classList.add(y.td),K(g),K(b),o.appendChild(g),s.appendChild(b)}t.appendChild(o),r.appendChild(s),e.appendChild(t),e.appendChild(r),oe(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const i=a.getRangeAt(0);i.collapse(!1),i.insertNode(e);const p=document.createElement("p");p.innerHTML="<br/>",e.after(p);const v=document.createRange();v.setStart(p,0),v.collapse(!0),a.removeAllRanges(),a.addRange(v),(f=H())==null||f.focus(),A()},oe=e=>{if(e.dataset.hasResizeHandle==="true")return;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"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let r=0,o=0,s=0,a=0;t.addEventListener("mousedown",i=>{i.preventDefault(),r=i.clientX,o=i.clientY;const p=e.getBoundingClientRect();s=p.width,a=p.height;const v=u=>{const g=Math.max(100,s+(u.clientX-r)),b=Math.max(20,a+(u.clientY-o));e.style.width=`${g}px`,e.style.height=`${b}px`,A()},f=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",f),A()};document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)}),e.appendChild(t)},K=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",r.classList.add("rte-resize-handle"),Mt(e,t,r),e.appendChild(t),e.appendChild(r)},Mt=(e,t,r)=>{let o=0,s=0,a=0,i=0;t.addEventListener("mousedown",u=>{u.preventDefault(),o=u.clientX,a=e.offsetWidth,document.addEventListener("mousemove",p),document.addEventListener("mouseup",f)}),r.addEventListener("mousedown",u=>{u.preventDefault(),s=u.clientY,i=e.offsetHeight,document.addEventListener("mousemove",v),document.addEventListener("mouseup",f)});const p=u=>{const g=a+(u.clientX-o);e.style.width=`${Math.max(30,g)}px`,A()},v=u=>{const g=i+(u.clientY-s);e.style.height=`${Math.max(20,g)}px`,A()},f=()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",f),A()}},zt=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"),h({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},be=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},kt=e=>{if(!_.cell)return;const t=_.cell.closest("table"),r=_.cell.cellIndex,o=_.cell.parentElement.rowIndex,s=a=>{const i=a.tagName.toLowerCase(),p=document.createElement(i);return p.textContent="",p.style.cssText=a.style.cssText,K(p),p};switch(e){case"insertRowAbove":{const a=t.rows[o],i=t.insertRow(o);Array.from(a.cells).forEach(p=>{i.appendChild(s(p))});break}case"insertRowBelow":{const a=t.rows[o],i=t.insertRow(o+1);Array.from(a.cells).forEach(p=>{i.appendChild(s(p))});break}case"insertColLeft":{Array.from(t.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i)});break}case"insertColRight":{Array.from(t.rows).forEach(a=>{const i=a.cells[r];a.insertBefore(s(i),i.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(o);break;case"deleteCol":Array.from(t.rows).forEach(a=>{a.cells[r]&&a.deleteCell(r)});break}A(),h(ie(ae({},_),{visible:!1})),be()},Nt=()=>{$(),J.current=O.current,pe({url:"",text:"",title:"",target:"_self"}),P(!0)},Tt=e=>{const t=window.getSelection();if(!t||!J.current)return;t.removeAllRanges(),t.addRange(J.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 s=t.getRangeAt(0);s.deleteContents(),s.insertNode(o);const a=document.createTextNode(" ");o.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),t.removeAllRanges(),t.addRange(i),P(!1),A()},Dt=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),J.current=o,pe({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),P(!0)}},Ot=()=>{const e=H();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&O.current){const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(O.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);W(),document.execCommand("removeFormat",!1);const s=o.cloneContents(),a=document.createElement("div");a.appendChild(s);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),p=[];for(;i.nextNode();){const u=i.currentNode,g=u.tagName.toUpperCase(),b=u.getAttribute&&u.getAttribute("data-mention")!==null;g!=="A"&&!b&&p.push(u)}for(let u=p.length-1;u>=0;u--){const g=p[u],b=g.parentNode;if(b){for(;g.firstChild;)b.insertBefore(g.firstChild,g);b.removeChild(g)}}a.querySelectorAll("[style]").forEach(u=>u.removeAttribute("style")),o.deleteContents();const v=document.createDocumentFragment();for(;a.firstChild;)v.appendChild(a.firstChild);o.insertNode(v);const f=document.createRange();f.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),f.collapse(!0),r.removeAllRanges(),r.addRange(f),e.normalize(),A()},Ht=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(s=>{s.replaceWith(`
|
|
3
|
-
`)}),r.querySelectorAll("
|
|
4
|
-
`)}),r.
|
|
5
|
-
`)}),((o=r.textContent)==null?void 0:o.replace(/\n{3,}/g,`
|
|
1
|
+
(function(N,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],n):(N=typeof globalThis!="undefined"?globalThis:N||self,n(N.RichTextEditor={},N.React,N.ReactDOM))})(this,(function(N,n,_){"use strict";var Kt=Object.defineProperty,Yt=Object.defineProperties;var Qt=Object.getOwnPropertyDescriptors;var Fe=Object.getOwnPropertySymbols;var Jt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Ie=(N,n,_)=>n in N?Kt(N,n,{enumerable:!0,configurable:!0,writable:!0,value:_}):N[n]=_,ie=(N,n)=>{for(var _ in n||(n={}))Jt.call(n,_)&&Ie(N,_,n[_]);if(Fe)for(var _ of Fe(n))Gt.call(n,_)&&Ie(N,_,n[_]);return N},se=(N,n)=>Yt(N,Qt(n));function qe(o){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const u in o)if(u!=="default"){const m=Object.getOwnPropertyDescriptor(o,u);Object.defineProperty(d,u,m.get?m:{enumerable:!0,get:()=>o[u]})}}return d.default=o,Object.freeze(d)}const Be=qe(n);window.React=Be;var ce={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},de=n.createContext&&n.createContext(ce),Re=["attr","size","title"];function Ue(o,d){if(o==null)return{};var u=Ve(o,d),m,p;if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(o);for(p=0;p<C.length;p++)m=C[p],!(d.indexOf(m)>=0)&&Object.prototype.propertyIsEnumerable.call(o,m)&&(u[m]=o[m])}return u}function Ve(o,d){if(o==null)return{};var u={};for(var m in o)if(Object.prototype.hasOwnProperty.call(o,m)){if(d.indexOf(m)>=0)continue;u[m]=o[m]}return u}function K(){return K=Object.assign?Object.assign.bind():function(o){for(var d=1;d<arguments.length;d++){var u=arguments[d];for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&(o[m]=u[m])}return o},K.apply(this,arguments)}function ue(o,d){var u=Object.keys(o);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(o);d&&(m=m.filter(function(p){return Object.getOwnPropertyDescriptor(o,p).enumerable})),u.push.apply(u,m)}return u}function Y(o){for(var d=1;d<arguments.length;d++){var u=arguments[d]!=null?arguments[d]:{};d%2?ue(Object(u),!0).forEach(function(m){$e(o,m,u[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(u)):ue(Object(u)).forEach(function(m){Object.defineProperty(o,m,Object.getOwnPropertyDescriptor(u,m))})}return o}function $e(o,d,u){return d=We(d),d in o?Object.defineProperty(o,d,{value:u,enumerable:!0,configurable:!0,writable:!0}):o[d]=u,o}function We(o){var d=Ze(o,"string");return typeof d=="symbol"?d:d+""}function Ze(o,d){if(typeof o!="object"||!o)return o;var u=o[Symbol.toPrimitive];if(u!==void 0){var m=u.call(o,d);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(o)}function me(o){return o&&o.map((d,u)=>n.createElement(d.tag,Y({key:u},d.attr),me(d.child)))}function k(o){return d=>n.createElement(Xe,K({attr:Y({},o.attr)},d),me(o.child))}function Xe(o){var d=u=>{var{attr:m,size:p,title:C}=o,L=Ue(o,Re),z=p||u.size||"1em",E;return u.className&&(E=u.className),o.className&&(E=(E?E+" ":"")+o.className),n.createElement("svg",K({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,m,L,{className:E,style:Y(Y({color:o.color||u.color},u.style),o.style),height:z,width:z,xmlns:"http://www.w3.org/2000/svg"}),C&&n.createElement("title",null,C),o.children)};return de!==void 0?n.createElement(de.Consumer,null,u=>d(u)):d(ce)}function Ke(o){return k({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 Ye(o){return k({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 Qe(o){return k({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 Je(o){return k({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 Ge(o){return k({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 et(o){return k({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 tt(o){return k({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 nt(o){return k({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 rt(o){return k({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 ot(o){return k({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 at(o){return k({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 lt(o){return k({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 it(o){return k({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM56.84,75.58a8,8,0,0,1,3.58-10.74l16-8A8,8,0,0,1,88,64v48a8,8,0,0,1-16,0V76.94l-4.42,2.22A8,8,0,0,1,56.84,75.58ZM92,180a8,8,0,0,1,0,16H68a8,8,0,0,1-6.4-12.8l21.67-28.89A3.92,3.92,0,0,0,84,152a4,4,0,0,0-7.77-1.33,8,8,0,0,1-15.09-5.34,20,20,0,1,1,35,18.53L84,180Zm100,4H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Zm0-48H120a8,8,0,0,1,0-16h72a8,8,0,0,1,0,16Z"},child:[]}]})(o)}function st(o){return k({attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 18H9V20H2V18ZM2 11H11V13H2V11ZM2 4H22V6H2V4ZM20.674 13.0251L21.8301 12.634L22.8301 14.366L21.914 15.1711C21.9704 15.4386 22 15.7158 22 16C22 16.2842 21.9704 16.5614 21.914 16.8289L22.8301 17.634L21.8301 19.366L20.674 18.9749C20.2635 19.3441 19.7763 19.6295 19.2391 19.8044L19 21H17L16.7609 19.8044C16.2237 19.6295 15.7365 19.3441 15.326 18.9749L14.1699 19.366L13.1699 17.634L14.086 16.8289C14.0296 16.5614 14 16.2842 14 16C14 15.7158 14.0296 15.4386 14.086 15.1711L13.1699 14.366L14.1699 12.634L15.326 13.0251C15.7365 12.6559 16.2237 12.3705 16.7609 12.1956L17 11H19L19.2391 12.1956C19.7763 12.3705 20.2635 12.6559 20.674 13.0251ZM18 17C18.5523 17 19 16.5523 19 16C19 15.4477 18.5523 15 18 15C17.4477 15 17 15.4477 17 16C17 16.5523 17.4477 17 18 17Z"},child:[]}]})(o)}function ct(o){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 21h-7a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]},{tag:"path",attr:{d:"M19.001 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M19.001 15.5v1.5"},child:[]},{tag:"path",attr:{d:"M19.001 21v1.5"},child:[]},{tag:"path",attr:{d:"M22.032 17.25l-1.299 .75"},child:[]},{tag:"path",attr:{d:"M17.27 20l-1.3 .75"},child:[]},{tag:"path",attr:{d:"M15.97 17.25l1.3 .75"},child:[]},{tag:"path",attr:{d:"M20.733 20l1.3 .75"},child:[]}]})(o)}function dt(o){return k({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14z"},child:[]},{tag:"path",attr:{d:"M3 10h18"},child:[]},{tag:"path",attr:{d:"M10 3v18"},child:[]}]})(o)}function ut(o){return k({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 mt(o){return k({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 ft=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],fe=({exec:o,saveSelection:d,handleFileChange:u,handleFontSizeChange:m,handleFontFamilyChange:p,insertEmoji:C,handleLink:L,removeFormatting:z,visibleActions:E,className:S,style:M})=>{var $,P;const A=n.useRef(null),R=n.useRef(null),D=n.useRef(null),[U,V]=n.useState(!1),[q,F]=n.useState({x:0,y:0});n.useEffect(()=>{const g=b=>{!b.target.closest(".rte-emoji-popup")&&!b.target.closest("button[title='Emoji']")&&V(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const B=g=>{var I;g.preventDefault();const b=g.currentTarget.dataset.command;if(b)switch(b){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertStaticUnorderedList":case"insertOrderedList":case"insertStaticOrderedList":case"removeFormat":o(b);break;case"insertImage":{(I=A.current)==null||I.click();break}default:console.warn("Unknown command:",b)}},J=g=>{o("foreColor",g.target.value)},ee=g=>{o("backColor",g.target.value)},[x,O]=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=()=>{O({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 ${S||""}`,style:M},E.bold&&n.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:B,className:x.bold?"rte-active":""},n.createElement(et,null)),E.italic&&n.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:B,className:x.italic?"rte-active":""},n.createElement(nt,null)),E.underline&&n.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:B,className:x.underline?"rte-active":""},n.createElement(lt,null)),E.unorderedList&&n.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:B,title:"UnorderedList",className:x.unorderedList?"rte-active":""},n.createElement(st,null)),E.staticUnorderedList&&n.createElement("button",{"data-command":"insertStaticUnorderedList",onMouseDown:B,title:"StaticUnorderedList",className:x.unorderedList?"rte-active":""},n.createElement(ot,null)),E.orderedList&&n.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:B,className:x.orderedList?"rte-active":"",style:{fontSize:"medium"}},n.createElement(it,null)),E.staticOrderedList&&n.createElement("button",{"data-command":"insertStaticOrderedList",title:"StaticOrderedList",onMouseDown:B,className:x.orderedList?"rte-active":""},n.createElement(Je,null)),E.link&&n.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:x.link?"rte-active":""},n.createElement(rt,null)),E.removeFormat&&n.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),d(),z()},className:x.removeFormat?"rte-active":""},n.createElement(mt,null)),E.image&&n.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:B,className:x.image?"rte-active":""},n.createElement(Qe,null)),n.createElement("input",{type:"file",accept:"image/*",ref:A,style:{display:"none"},onChange:u}),E.emoji&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),d();const b=g.currentTarget.getBoundingClientRect();F({x:b.left,y:b.bottom+8}),V(I=>!I)},className:x.emoji?"rte-active":""},n.createElement(at,null)),U&&_.createPortal(n.createElement("div",{className:"rte-emoji-popup",style:{top:q.y,left:q.x}},ft.map((g,b)=>n.createElement("span",{key:b,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:I=>{I.preventDefault(),C(g),V(!1)}},g))),document.body)),E.color&&n.createElement("div",{style:{position:"relative"}},n.createElement("button",{title:"Text Color",onMouseDown:g=>{var b;g.preventDefault(),d(),(b=R.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:(($=R.current)==null?void 0:$.value)||"#000",fontSize:"18px"},className:x.color?"rte-active":""},n.createElement(ut,null)),n.createElement("input",{ref:R,type:"color",defaultValue:"#000000",onChange:g=>{var b;J(g),((b=g.target.parentElement)==null?void 0:b.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 b;g.preventDefault(),d(),(b=D.current)==null||b.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((P=D.current)==null?void 0:P.value)||"#000",fontSize:"18px"},className:x.highlight?"rte-active":""},n.createElement(tt,null)),n.createElement("input",{ref:D,type:"color",onChange:g=>{var b;ee(g),((b=g.target.parentElement)==null?void 0:b.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:()=>o("justifyLeft"),className:x.alignLeft?"rte-active":""},n.createElement(Ge,null)),n.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyCenter"),className:x.alignCenter?"rte-active":""},n.createElement(Ke,null)),n.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>o("justifyRight"),className:x.alignRight?"rte-active":""},n.createElement(Ye,null))),E.table&&n.createElement("button",{title:"Insert Dynamic Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertTable"),className:x.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(ct,null)),E.table&&n.createElement("button",{title:"Insert Static Table",onMouseDown:g=>g.preventDefault(),onClick:()=>o("insertStaticTable"),className:x.table?"rte-active":"",style:{fontSize:"medium"}},n.createElement(dt,null)),E.fontFamily&&n.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:p},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 rte-fontsize-dropdown",defaultValue:"",onMouseDown:()=>d(),onChange:m},n.createElement("option",{value:"",disabled:!0},"Font Size"),Array.from({length:16},(g,b)=>10+b).map(g=>n.createElement("option",{key:g,value:g},g,"px"))))},gt=({show:o,position:d,filtered:u,insertMention:m,onClose:p,query:C})=>{const L=n.useRef(null),[z,E]=n.useState(0);return n.useEffect(()=>{o&&E(0)},[o]),n.useEffect(()=>{const S=M=>{L.current&&!L.current.contains(M.target)&&p()};return o&&document.addEventListener("mousedown",S),()=>{document.removeEventListener("mousedown",S)}},[o,p]),n.useEffect(()=>{if(!o)return;const S=M=>{if(!(!o||u.length===0)&&(M.key==="ArrowDown"&&(M.preventDefault(),E(A=>Math.min(A+1,u.length-1))),M.key==="ArrowUp"&&(M.preventDefault(),E(A=>Math.max(A-1,0))),M.key==="Enter")){M.preventDefault();const A=u[z];A&&m(A)}};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[o,u,z]),n.useEffect(()=>{if(!L.current)return;const M=L.current.querySelectorAll("li")[z];M&&M.scrollIntoView({block:"nearest",behavior:"smooth"})},[z]),o?n.createElement("ul",{ref:L,className:"rte-popup",style:{top:d.y,left:d.x}},u.length>0?u.map(({name:S,value:M},A)=>{const R=S.toLowerCase(),D=C.toLowerCase(),U=R.indexOf(D);let V=S;if(U!==-1&&C.length>0){const q=U+C.length;V=S.substring(0,U)+`<span class="rte-highlight">${S.substring(U,q)}</span>`+S.substring(q)}return n.createElement("li",{key:M,onMouseDown:q=>{q.preventDefault(),m({name:S,value:M})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px",background:A===z?"#dce8ff":"white"},dangerouslySetInnerHTML:{__html:V},onMouseEnter:()=>E(A)})}):n.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ge(o){return k({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 Q(o){return k({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 ht=({visible:o,x:d,y:u,onAction:m,onClose:p})=>{if(!o)return null;const C={top:u,left:d};return n.createElement("div",{style:C,className:"rte-table-menu",onMouseLeave:p},n.createElement("button",{onClick:()=>m("insertRowAbove")},n.createElement(Q,null)," Insert row above"),n.createElement("button",{onClick:()=>m("insertRowBelow")},n.createElement(Q,null)," Insert row below"),n.createElement("button",{onClick:()=>m("insertColLeft")},n.createElement(Q,null)," Insert col left"),n.createElement("button",{onClick:()=>m("insertColRight")},n.createElement(Q,null)," Insert col right"),n.createElement("button",{onClick:()=>m("deleteRow")},n.createElement(ge,null)," Delete row"),n.createElement("button",{onClick:()=>m("deleteCol")},n.createElement(ge,null)," Delete column"))},he=({html:o,className:d,style:u})=>{const m=C=>{const L=C.target;if(L.tagName==="A"){C.preventDefault();const z=L.href;z&&window.open(z,"_blank","noopener,noreferrer")}},p=C=>{let L=C.replace(/{{\s*(.*?)\s*}}/g,(z,E)=>`<span style="color: blue">${E}</span>`);return L=L.replace(/#arrayData/g,""),L=L.replace(/\/arrayData/g,""),L};return n.createElement("div",{className:`rte-preview ${d||""}`,style:u,onClick:m,dangerouslySetInnerHTML:{__html:p(o)}})},pt=({visible:o,linkData:d,onClose:u,onInsert:m})=>{const[p,C]=n.useState(""),[L,z]=n.useState(""),[E,S]=n.useState(""),[M,A]=n.useState("_self");if(n.useEffect(()=>{o?(C(d.url||""),z(d.text||""),S(d.title||""),A(d.target||"_self")):(C(""),z(""),S(""),A("_self"))},[o,d]),!o)return null;const R=()=>{m({url:p,text:L,title:E,target:M})};return n.createElement(n.Fragment,null,n.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),n.createElement("div",{className:"rte-link-modal"},n.createElement("h4",{className:"rte-link-modal__title"},p?"Edit Link":"Insert Link"),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:p,onChange:D=>C(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:D=>z(D.target.value)}),n.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:D=>S(D.target.value)}),n.createElement("select",{className:"rte-link-modal__select",value:M,onChange:D=>A(D.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:u},"Cancel"),n.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:R},"OK"))))};function pe(o){const d=new Map;return o.forEach(u=>{d.set(u.name,u.value)}),Array.from(d.entries()).map(([u,m])=>({name:u,value:m}))}const vt=({atSuggestions:o=[],showOutput:d=!1,showPreview:u=!1,toolbarConfig:m={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1,unorderedList:!1,orderedList:!1,staticUnorderedList:!1,staticOrderedList:!1},classNames:p={},styles:C={},handleGetHtml:L=()=>{},onChange:z=()=>{},value:E,onMentionSelect:S=()=>{},handleAddAttributes:M=()=>{}})=>{var Me,Ae,Te,Ne,ke,ze,De,Oe,He,je,_e,Pe;const A=n.useRef(null),[R,D]=n.useState(E!=null&&E.length?E:" "),[U,V]=n.useState(""),[q,F]=n.useState(!1),[B,J]=n.useState({x:0,y:0}),[ee,x]=n.useState([]),O=n.useRef(null),$=n.useRef(null),[P,g]=n.useState({visible:!1,x:0,y:0}),[b,I]=n.useState(!1),G=n.useRef(null),[yt,ve]=n.useState({url:"",text:"",title:"",target:"_self"}),Et={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:(Me=m.unorderedList)!=null?Me:!0,orderedList:(Ae=m.orderedList)!=null?Ae:!0,staticUnorderedList:(Te=m.staticUnorderedList)!=null?Te:!0,staticOrderedList:(Ne=m.staticOrderedList)!=null?Ne:!0,align:!0,link:(ke=m.link)!=null?ke:!1,image:(ze=m.image)!=null?ze:!1,emoji:(De=m.emoji)!=null?De:!1,table:(Oe=m.table)!=null?Oe:!1,color:(He=m.color)!=null?He:!1,fontFamily:(je=m.fontFamily)!=null?je:!1,fontSize:(_e=m.fontSize)!=null?_e:!1,highlight:(Pe=m.fontSize)!=null?Pe:!1},[wt,te]=n.useState(""),[ye,ne]=n.useState([]),j=()=>A.current,T=()=>{const e=Ct(),t=/^<div[^>]*style=["'][^"']*font-size\s*:\s*\d+px[^"']*["'][^>]*>/.test(e.trim());let r=e;t||(r=`<div style="font-size:12px">${e}</div>`),r=r.replace(/<(ul|ol)([^>]*)>[\s\S]*?<\/\1>/g,(l,h,y)=>{if(/list-type=["']static["']/.test(y)||l.includes("data-hidden-array-start")||l.includes("data-hidden-array-end"))return l;const f=`<${h}${y}>`,s='<span data-hidden-array-start="true" style="display:none">{{#arrayData}}</span>',v='<span data-hidden-array-end="true" style="display:none">{{/arrayData}}</span>',w=`</${h}>`,H=l.replace(new RegExp(`^${f}`),"").replace(new RegExp(`${w}$`),"");return`${f}${s}${H}${v}${w}`}),V(r),L==null||L(r);const a=Bt(e);z(a);const c=Nt(),i=pe(c);JSON.stringify(i)!==JSON.stringify(ye)&&(ne(i),S(i))},Ct=()=>{const e=j();if(!e)return R;const t=e.cloneNode(!0);t.querySelectorAll("table div").forEach(a=>a.remove()),t.querySelectorAll("table").forEach(a=>{a.removeAttribute("data-has-resize-handle")}),t.querySelectorAll(".rte-cell-highlight").forEach(a=>a.classList.remove("rte-cell-highlight"));let r=t.innerHTML;return r=bt(r),r},bt=e=>{const t=document.createElement("div");return t.innerHTML=e,t.querySelectorAll("tbody").forEach(r=>{r.getAttribute("table-type")==="static"||(r.innerHTML=`{{#arrayData}}${r.innerHTML}{{/arrayData}}`)}),t.innerHTML},W=()=>{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)&&(O.current=r.cloneRange())},Z=()=>{const e=window.getSelection();!e||!O.current||(e.removeAllRanges(),e.addRange(O.current))},Ee=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(O.current=r.getRangeAt(0)),Z(),document.execCommand(e,!1,t),T()};n.useEffect(()=>{const e=j();if(!e||!E)return;const t=Lt(E);e.innerHTML=t,T()},[]);const Lt=e=>e.replace(/<span[^>]*data-hidden-table-start[^>]*>.*?<\/span>/g,"").replace(/<span[^>]*data-hidden-table-end[^>]*>.*?<\/span>/g,"").replace(/{{#arrayData}}/g,"").replace(/{{\/arrayData}}/g,"");n.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),n.useEffect(()=>{M&&M(e=>{Tt(e)})},[]),n.useEffect(()=>{const e=j();if(!e)return;e.querySelectorAll("table").forEach(r=>{r.hasAttribute("data-has-resize-handle")||(ae(r),r.querySelectorAll("th, td").forEach(c=>X(c)))})},[]);const we=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Ce=(e,t)=>{var f;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.getRangeAt(0),c=we(a.startContainer);let i,l;const h=t==="insertStaticUnorderedList"||t==="insertStaticOrderedList";if(c){let s=c.querySelector(e);s||(s=document.createElement(e),s.style.margin="0",s.style.paddingLeft="20px",c.appendChild(s)),l=s,i=document.createElement("li"),i.textContent="â",l.appendChild(i)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const s=j();if(l=s==null?void 0:s.querySelector(`${e}:last-child`),!l)return;h&&l.setAttribute("list-type","static"),i=l.querySelector("li:last-child")}const y=document.createRange();y.setStart(i,0),y.collapse(!0),r.removeAllRanges(),r.addRange(y),(f=j())==null||f.focus(),T()},re=(e,t)=>{e==="insertOrderedList"||e==="insertStaticOrderedList"?Ce("ol",e):e==="insertUnorderedList"||e==="insertStaticUnorderedList"?Ce("ul",e):e.startsWith("justify")?Ut(e):Ee(e,t),e==="insertTable"&&Le(),e==="insertStaticTable"&&Le("insertStaticTable")},St=e=>{const t=document.createElement("span");t.textContent="â",e.insertNode(t),e.setStartAfter(t),e.collapse(!0);const r=t.getBoundingClientRect();t.remove(),J({x:r.left,y:r.bottom+window.scrollY}),x(o||[]),F(!0),$.current=e.cloneRange()},xt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;let r=e.anchorOffset;if(!t)return null;let a=t;for(a.nodeType!==Node.TEXT_NODE&&(a.childNodes&&a.childNodes[r]?a=a.childNodes[r]:a=t.previousSibling);a;){if(a.nodeType===Node.TEXT_NODE){const c=a.textContent||"",i=a===t?r:c.length,l=c.lastIndexOf("@",i-1);if(l!==-1){const h=document.createRange();return h.setStart(a,l),h.setEnd(a,i),h}}a=a.previousSibling}return null},Mt=e=>{var i;const t=window.getSelection();if(!t)return;const r=xt();r?(t.removeAllRanges(),t.addRange(r)):$.current&&(t.removeAllRanges(),t.addRange($.current));const a=document.createElement("span");a.textContent=`{{${e.name}}}`,a.style.display="inline",a.setAttribute("data-mention",e.value||e.name||"");try{const l=t.rangeCount?t.getRangeAt(0):null;if(l)l.deleteContents(),l.insertNode(a);else{const f=document.createRange(),s=j();f.selectNodeContents(s),f.collapse(!1),f.insertNode(a)}const h=document.createTextNode(" ");a.after(h);const y=document.createRange();y.setStartAfter(h),y.collapse(!0),t.removeAllRanges(),t.addRange(y)}catch(l){console.error("insertMention error:",l)}let c=pe([...ye,e]);ne(c),S(c),F(!1),(i=j())==null||i.focus(),T()},At=e=>{const t=j();if(!t)return;let r=null;O.current&&t.contains(O.current.startContainer)?r=O.current.cloneRange():(r=document.createRange(),r.selectNodeContents(t),r.collapse(!1));const a=window.getSelection();if(!a)return;a.removeAllRanges(),a.addRange(r);const c=document.createElement("span");c.textContent=`{{${e.name}}}`,c.style.display="inline",c.setAttribute("data-mention",e.value||e.name),r.insertNode(c);const i=document.createTextNode(" ");c.after(i);const l=document.createRange();l.setStartAfter(i),l.collapse(!0),a.removeAllRanges(),a.addRange(l),O.current=l.cloneRange(),t.focus()},Tt=e=>{e.forEach(t=>At(t)),ne(t=>{const r=[...t,...e],a=Array.from(new Map(r.map(c=>[c.name,c])).values());return S(a),a}),T()},Nt=()=>{const e=j();if(!e)return[];const t=e.querySelectorAll("span[data-mention]"),r=[];return t.forEach(a=>{const c=a.getAttribute("data-mention")||"",l=(a.textContent||"").match(/{{(.+?)}}/);l&&r.push({name:l[1],value:c})}),r},kt=e=>{var r,a,c;const t=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(t)&&(e.preventDefault(),re(t==="b"?"bold":t==="i"?"italic":t==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const i=window.getSelection(),l=i!=null&&i.anchorNode?we(i.anchorNode):null;if(!l)return;if(((r=l.textContent)==null?void 0:r.replace(/\u200B/g,"").trim())===""){e.preventDefault();const y=l.parentElement,f=y==null?void 0:y.closest("li");if(f){y==null||y.removeChild(l);const s=document.createElement("p");s.innerHTML="<br />",(a=f.parentElement)==null||a.insertBefore(s,f.nextSibling);const v=document.createRange();v.setStart(s,0),v.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(v)}else{const s=l.closest("ul, ol");if(s){const v=document.createElement("p");v.innerHTML="<br />",(c=s.parentElement)==null||c.insertBefore(v,s.nextSibling),s.removeChild(l);const w=document.createRange();w.setStart(v,0),w.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(w)}}T()}}if(t==="backspace"||t==="delete"){const i=window.getSelection();if(!i||i.rangeCount===0)return;const l=i.getRangeAt(0);if(l.cloneContents().querySelector("table"))return;if(l.cloneContents().querySelectorAll(".rte-resize-handle").length>0){e.preventDefault(),e.stopPropagation();return}}},zt=e=>{if(e.data==="@"){const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.anchorNode;if(oe(a))return;setTimeout(()=>{St(r.getRangeAt(0)),te(""),x(o),F(!0)},0);return}if(q){setTimeout(()=>be(),0);return}},oe=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},be=()=>{T();const e=window.getSelection();if(!e||!e.anchorNode)return;if(oe(e.anchorNode)){F(!1);return}let t=e.anchorNode.textContent||"";t=t.replace(/\u00A0/g," ");const r=t.match(/@([^\n]*)$/);if(!r){F(!1);return}const a=r[1].trim().toLowerCase();te(a);const c=o.filter(i=>i.name.toLowerCase().includes(a));c.length>0?(x(c),F(!0)):F(!1)},Dt=e=>{var a;const t=(a=e.target.files)==null?void 0:a[0];if(!t)return;const r=new FileReader;r.onload=c=>{var w;const i=(w=c.target)==null?void 0:w.result;Z();const l=window.getSelection();let h=l&&l.rangeCount?l.getRangeAt(0):null;const y=document.createElement("img");y.src=i,y.alt=t.name||"image",y.className="rte-inserted-image",y.contentEditable="true";const f=j();if(!h||!f){f==null||f.appendChild(y);const H=document.createTextNode(" ");f==null||f.appendChild(H);const le=document.createRange();le.setStartAfter(H),le.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(le),f==null||f.focus(),T(),e.target.value="";return}h.deleteContents(),h.insertNode(y);const s=document.createTextNode(" ");y.after(s);const v=document.createRange();v.setStartAfter(s),v.collapse(!0),l.removeAllRanges(),l.addRange(v),f.focus(),T(),e.target.value=""},r.readAsDataURL(t)},Ot=e=>{var c;Z();const t=window.getSelection();if(!(t!=null&&t.rangeCount))return;const r=t.getRangeAt(0),a=document.createTextNode(e);r.insertNode(a),r.setStartAfter(a),r.collapse(!0),t.removeAllRanges(),t.addRange(r),(c=j())==null||c.focus(),T()},Le=e=>{var s;Zt(),Z();const t=document.createElement("table");t.style.borderCollapse="collapse",t.style.width="100%",t.style.border="1px solid #ccc",t.style.margin="8px 0",t.style.position="relative",t.style.textAlign="center",p.table&&t.classList.add(p.table);const r=document.createElement("thead");p.thead&&r.classList.add(p.thead);const a=document.createElement("tbody");p.tbody&&a.classList.add(p.tbody),e==="insertStaticTable"&&a.setAttribute("table-type","static");const c=document.createElement("tr");p.tr&&c.classList.add(p.tr);const i=document.createElement("tr");p.tr&&i.classList.add(p.tr);for(let v=0;v<2;v++){const w=document.createElement("th");w.textContent="",w.style.border="1px solid #999",w.style.padding="4px",w.style.position="relative",w.style.backgroundColor="lightgray",w.style.height="20px",p.th&&w.classList.add(p.th);const H=document.createElement("td");H.textContent="",H.style.border="1px solid #999",H.style.padding="4px",H.style.position="relative",H.style.backgroundColor="#fff",H.style.height="20px",p.td&&H.classList.add(p.td),X(w),X(H),c.appendChild(w),i.appendChild(H)}r.appendChild(c),a.appendChild(i),t.appendChild(r),t.appendChild(a),ae(t);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;const h=l.getRangeAt(0);h.collapse(!1),h.insertNode(t);const y=document.createElement("p");y.innerHTML="<br/>",t.after(y);const f=document.createRange();f.setStart(y,0),f.collapse(!0),l.removeAllRanges(),l.addRange(f),(s=j())==null||s.focus(),T()},ae=e=>{if(e.dataset.hasResizeHandle==="true")return;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"}),t.contentEditable="false",t.dataset.hasResizeHandle="true",t.classList.add("rte-resize-handle");let r=0,a=0,c=0,i=0;t.addEventListener("mousedown",l=>{l.preventDefault(),r=l.clientX,a=l.clientY;const h=e.getBoundingClientRect();c=h.width,i=h.height;const y=s=>{const v=Math.max(100,c+(s.clientX-r)),w=Math.max(20,i+(s.clientY-a));e.style.width=`${v}px`,e.style.height=`${w}px`,T()},f=()=>{document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),T()};document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)}),e.appendChild(t)},X=e=>{const t=document.createElement("div"),r=document.createElement("div");Object.assign(t.style,{position:"absolute",right:"0",top:"0",width:"4px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),t.contentEditable="false",t.classList.add("rte-resize-handle"),Object.assign(r.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"4px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10",MozUserSelect:"none",msUserSelect:"none",pointerEvents:"auto"}),r.contentEditable="false",r.classList.add("rte-resize-handle"),Ht(e,t,r),e.appendChild(t),e.appendChild(r)},Ht=(e,t,r)=>{let a=0,c=0,i=0,l=0;t.addEventListener("mousedown",s=>{s.preventDefault(),a=s.clientX,i=e.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",f)}),r.addEventListener("mousedown",s=>{s.preventDefault(),c=s.clientY,l=e.offsetHeight,document.addEventListener("mousemove",y),document.addEventListener("mouseup",f)});const h=s=>{const v=i+(s.clientX-a);e.style.width=`${Math.max(30,v)}px`,T()},y=s=>{const v=l+(s.clientY-c);e.style.height=`${Math.max(20,v)}px`,T()},f=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",f),T()}},jt=e=>{const r=e.target.closest("td, th");r&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(a=>a.classList.remove("rte-cell-highlight")),r.classList.add("rte-cell-highlight"),g({visible:!0,x:e.clientX,y:e.clientY,cell:r}))},Se=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},_t=e=>{if(!P.cell)return;const t=P.cell.closest("table"),r=P.cell.cellIndex,a=P.cell.parentElement.rowIndex,c=i=>{const l=i.tagName.toLowerCase(),h=document.createElement(l);return h.textContent="",h.style.cssText=i.style.cssText,X(h),h};switch(e){case"insertRowAbove":{const i=t.rows[a],l=t.insertRow(a);Array.from(i.cells).forEach(h=>{l.appendChild(c(h))});break}case"insertRowBelow":{const i=t.rows[a],l=t.insertRow(a+1);Array.from(i.cells).forEach(h=>{l.appendChild(c(h))});break}case"insertColLeft":{Array.from(t.rows).forEach(i=>{const l=i.cells[r];i.insertBefore(c(l),l)});break}case"insertColRight":{Array.from(t.rows).forEach(i=>{const l=i.cells[r];i.insertBefore(c(l),l.nextSibling)});break}case"deleteRow":t.rows.length>1&&t.deleteRow(a);break;case"deleteCol":Array.from(t.rows).forEach(i=>{i.cells[r]&&i.deleteCell(r)});break}T(),g(se(ie({},P),{visible:!1})),Se()},Pt=()=>{W(),G.current=O.current,ve({url:"",text:"",title:"",target:"_self"}),I(!0)},Ft=e=>{const t=window.getSelection();if(!t||!G.current)return;t.removeAllRanges(),t.addRange(G.current);let r=e.url.trim();/^https?:\/\//i.test(r)||(r="https://"+r);const a=document.createElement("a");a.href=r,a.style.cursor="pointer",a.style.outline="none",a.textContent=e.text||r,a.title=e.title,a.target=e.target,a.contentEditable="true";const c=t.getRangeAt(0);c.deleteContents(),c.insertNode(a);const i=document.createTextNode(" ");a.after(i);const l=document.createRange();l.setStartAfter(i),l.collapse(!0),t.removeAllRanges(),t.addRange(l),I(!1),T()},It=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 a=document.createRange();a.selectNode(r),G.current=a,ve({url:r.href,text:r.textContent||r.href,title:r.title,target:r.target}),I(!0)}},qt=()=>{const e=j();if(!e)return;const t=window.getSelection();if((!t||t.rangeCount===0)&&O.current){const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(O.current)}const r=window.getSelection();if(!r||r.rangeCount===0)return;const a=r.getRangeAt(0);Z(),document.execCommand("removeFormat",!1);const c=a.cloneContents(),i=document.createElement("div");i.appendChild(c);const l=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,null),h=[];for(;l.nextNode();){const s=l.currentNode,v=s.tagName.toUpperCase(),w=s.getAttribute&&s.getAttribute("data-mention")!==null;v!=="A"&&!w&&h.push(s)}for(let s=h.length-1;s>=0;s--){const v=h[s],w=v.parentNode;if(w){for(;v.firstChild;)w.insertBefore(v.firstChild,v);w.removeChild(v)}}i.querySelectorAll("[style]").forEach(s=>s.removeAttribute("style")),a.deleteContents();const y=document.createDocumentFragment();for(;i.firstChild;)y.appendChild(i.firstChild);a.insertNode(y);const f=document.createRange();f.setStartAfter(a.endContainer.nodeType===Node.TEXT_NODE?a.endContainer:a.startContainer),f.collapse(!0),r.removeAllRanges(),r.addRange(f),e.normalize(),T()},Bt=e=>{var a;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(c=>{c.replaceWith(`
|
|
2
|
+
`)}),r.querySelectorAll("p, div, tr").forEach(c=>{c.insertAdjacentText("afterend",`
|
|
3
|
+
`)}),r.querySelectorAll("table").forEach(c=>{c.insertAdjacentText("afterend",`
|
|
4
|
+
`)}),((a=r.textContent)==null?void 0:a.replace(/\n{3,}/g,`
|
|
6
5
|
|
|
7
|
-
`).trim())||""};function
|
|
6
|
+
`).trim())||""};function Rt(){const e=window.getSelection();if(!e||e.rangeCount===0)return[];const t=e.getRangeAt(0);if(t.collapsed){let i=t.startContainer,l=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement;const h=l==null?void 0:l.closest("td, th");return h?[h]:[]}const r=t.commonAncestorContainer,a=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;return Array.from(a.querySelectorAll("td, th")).filter(i=>{const l=document.createRange();return l.selectNodeContents(i),t.compareBoundaryPoints(Range.END_TO_START,l)<0&&t.compareBoundaryPoints(Range.START_TO_END,l)>0})}function Ut(e){const t=Rt();if(t.length===0){Ee(e);return}let r="left";e==="justifyCenter"&&(r="center"),e==="justifyRight"&&(r="right"),t.forEach(a=>{a.style.textAlign=r}),T()}const Vt=e=>{e.preventDefault();const t=e.clipboardData.items;for(let f=0;f<t.length;f++){const s=t[f];if(s.kind==="file"&&s.type.startsWith("image/"))return;s.kind==="string"&&s.getAsString(v=>{/<img\s/i.test(v)})}const r=e.clipboardData.getData("text/html")||"";if(!r)return;const a=document.createElement("div");a.innerHTML=r;const c=f=>{f.style.borderCollapse="collapse",f.style.width="100%",f.style.border="1px solid #ccc",f.style.margin="8px 0",f.style.position="relative",f.style.textAlign="center",f.querySelectorAll("th").forEach(s=>{const v=s;v.style.border="1px solid #999",v.style.padding="4px",v.style.position="relative",v.style.backgroundColor="lightgray",v.style.height="20px"}),f.querySelectorAll("td").forEach(s=>{const v=s;v.style.border="1px solid #999",v.style.padding="4px",v.style.position="relative",v.style.backgroundColor="#fff",v.style.height="20px"})};a.querySelectorAll("table").forEach(f=>c(f));const i=window.getSelection();if(!i||!i.rangeCount)return;const l=i.getRangeAt(0);l.deleteContents();const h=document.createDocumentFragment();for(;a.firstChild;)h.appendChild(a.firstChild);l.insertNode(h),l.collapse(!1),i.removeAllRanges(),i.addRange(l);const y=A.current;y&&(y.querySelectorAll("table").forEach(f=>{const s=f;s.hasAttribute("data-has-resize-handle")||(ae(s),s.querySelectorAll("th, td").forEach(v=>{const w=v;w.dataset.hasResizeHandles||X(w)}))}),T())},$t=e=>{Z();const t=window.getSelection();if(!t||!t.rangeCount)return;const r=t.getRangeAt(0),a=document.createElement("span");a.style.fontSize=`${e}px`,a.appendChild(r.extractContents()),r.insertNode(a);const c=document.createRange();c.setStartAfter(a),c.collapse(!0),t.removeAllRanges(),t.addRange(c),T()},Wt=()=>{const e=window.getSelection();if(!e||!e.anchorNode)return null;const t=e.anchorNode;if(oe(t)||t.nodeType!==Node.TEXT_NODE)return null;const r=t.textContent||"",a=e.anchorOffset,c=r.lastIndexOf("@",a-1);if(c===-1)return null;const i=r.substring(c+1,a);if(i.includes(" ")||i.includes("Â "))return null;const l=document.createRange();return l.setStart(t,c),l.setEnd(t,a),{range:l,query:i}},xe=()=>{const e=Wt();if(!e)return;const{range:t,query:r}=e,a=document.createElement("span");a.textContent="â",t.insertNode(a);const c=a.getBoundingClientRect();a.remove(),J({x:c.left,y:c.bottom+window.scrollY}),te(r.toLowerCase());const i=o.filter(l=>l.name.toLowerCase().includes(r.toLowerCase()));x(i),F(!0),$.current=t.cloneRange()};function Zt(){const e=A.current;if(!e)return;const t=window.getSelection();if(!t||t.rangeCount>0&&e.contains(t.anchorNode))return;const r=document.createRange();r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r),O.current=r.cloneRange()}const Xt=e=>{const t=e.target;if(!t||!(t.textContent||"").match(/{{([\s\S]+?)}}/)||!A.current)return;let i=t.firstChild;if((!i||i.nodeType!==Node.TEXT_NODE)&&(i=t.childNodes[0]),!i||i.nodeType!==Node.TEXT_NODE)return;const l=i.textContent||"",h=l.indexOf("{{"),y=l.indexOf("}}");if(h===-1||y===-1)return;const f=window.getSelection();if(!f)return;const s=document.createRange();s.setStart(i,h),s.setEnd(i,y+2),f.removeAllRanges(),f.addRange(s)};return n.createElement("div",{className:`rte-wrapper ${(p==null?void 0:p.wrapper)||""}`,style:C.wrapper},n.createElement("div",{style:{flex:1}},n.createElement(fe,{exec:re,saveSelection:W,handleFileChange:Dt,handleFontSizeChange:e=>$t(e.target.value),handleFontFamilyChange:e=>re("fontName",e.target.value),insertEmoji:Ot,handleLink:Pt,removeFormatting:qt,visibleActions:Et,className:p.toolbar,style:C.toolbar}),n.createElement("div",{ref:A,id:"rte-editor-body",className:`rte-editor ${(p==null?void 0:p.editor)||""}`,style:C.editor,contentEditable:!0,suppressContentEditableWarning:!0,onPaste:Vt,onKeyUp:()=>{W(),xe()},onMouseUp:W,onInput:()=>{be(),W()},onKeyDown:kt,onBeforeInput:zt,onContextMenu:jt,onClick:e=>{It(e),W(),xe()},onDoubleClick:Xt}),n.createElement(gt,{show:q,position:B,filtered:ee,insertMention:Mt,onClose:()=>F(!1),query:wt}),d&&n.createElement("div",{className:`rte-output ${(p==null?void 0:p.output)||""}`,style:C.output},n.createElement("h4",null,"Output HTML:"),n.createElement("p",null,U)),n.createElement(ht,{visible:P.visible,x:P.x,y:P.y,onAction:_t,onClose:()=>{g(se(ie({},P),{visible:!1})),Se()}}),n.createElement(pt,{visible:b,linkData:yt,onClose:()=>I(!1),onInsert:Ft})),u?n.createElement(he,{className:p.preview,style:C.preview,html:U}):null)};N.RichTextEditor=vt,N.RtePreview=he,N.RteToolbar=fe,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})}));
|