@ryzeup/richtexteditor 1.0.8 â 1.0.10
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 +707 -650
- package/dist/index.js +2 -2
- package/dist/index.umd.js +4 -4
- package/dist/richtexteditor.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";var Qe=Object.defineProperty,Je=Object.defineProperties;var Ge=Object.getOwnPropertyDescriptors;var ve=Object.getOwnPropertySymbols;var et=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var Ee=(n,l,i)=>l in n?Qe(n,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[l]=i,Z=(n,l)=>{for(var i in l||(l={}))et.call(l,i)&&Ee(n,i,l[i]);if(ve)for(var i of ve(l))tt.call(l,i)&&Ee(n,i,l[i]);return n},Q=(n,l)=>Je(n,Ge(l));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function nt(n){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const i in n)if(i!=="default"){const u=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(l,i,u.get?u:{enumerable:!0,get:()=>n[i]})}}return l.default=n,Object.freeze(l)}const rt=nt(t);window.React=rt;var be={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},we=t.createContext&&t.createContext(be),at=["attr","size","title"];function ot(n,l){if(n==null)return{};var i=lt(n,l),u,v;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(n);for(v=0;v<y.length;v++)u=y[v],!(l.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(n,u)&&(i[u]=n[u])}return i}function lt(n,l){if(n==null)return{};var i={};for(var u in n)if(Object.prototype.hasOwnProperty.call(n,u)){if(l.indexOf(u)>=0)continue;i[u]=n[u]}return i}function $(){return $=Object.assign?Object.assign.bind():function(n){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(n[u]=i[u])}return n},$.apply(this,arguments)}function ye(n,l){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(n);l&&(u=u.filter(function(v){return Object.getOwnPropertyDescriptor(n,v).enumerable})),i.push.apply(i,u)}return i}function W(n){for(var l=1;l<arguments.length;l++){var i=arguments[l]!=null?arguments[l]:{};l%2?ye(Object(i),!0).forEach(function(u){ct(n,u,i[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):ye(Object(i)).forEach(function(u){Object.defineProperty(n,u,Object.getOwnPropertyDescriptor(i,u))})}return n}function ct(n,l,i){return l=it(l),l in n?Object.defineProperty(n,l,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[l]=i,n}function it(n){var l=st(n,"string");return typeof l=="symbol"?l:l+""}function st(n,l){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var u=i.call(n,l);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(n)}function Re(n){return n&&n.map((l,i)=>t.createElement(l.tag,W({key:i},l.attr),Re(l.child)))}function S(n){return l=>t.createElement(ut,$({attr:W({},n.attr)},l),Re(n.child))}function ut(n){var l=i=>{var{attr:u,size:v,title:y}=n,L=ot(n,at),x=v||i.size||"1em",E;return i.className&&(E=i.className),n.className&&(E=(E?E+" ":"")+n.className),t.createElement("svg",$({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,u,L,{className:E,style:W(W({color:n.color||i.color},i.style),n.style),height:x,width:x,xmlns:"http://www.w3.org/2000/svg"}),y&&t.createElement("title",null,y),n.children)};return we!==void 0?t.createElement(we.Consumer,null,i=>l(i)):l(be)}function dt(n){return S({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:[]}]})(n)}function mt(n){return S({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:[]}]})(n)}function ft(n){return S({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:[]}]})(n)}function gt(n){return S({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:[]}]})(n)}function ht(n){return S({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:[]}]})(n)}function pt(n){return S({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:[]}]})(n)}function vt(n){return S({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:[]}]})(n)}function Et(n){return S({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:[]}]})(n)}function wt(n){return S({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:[]}]})(n)}function yt(n){return S({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:[]}]})(n)}function Ct(n){return S({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:[]}]})(n)}function bt(n){return S({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:[]}]})(n)}function Rt(n){return S({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:[]}]})(n)}function xt(n){return S({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:[]}]})(n)}function Lt(n){return S({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:[]}]})(n)}const St=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],xe=({exec:n,saveSelection:l,handleFileChange:i,handleFontSizeChange:u,handleFontFamilyChange:v,insertEmoji:y,handleLink:L,removeFormatting:x,visibleActions:E,className:A,style:D})=>{var k,F;const M=t.useRef(null),T=t.useRef(null),b=t.useRef(null),[H,P]=t.useState(!1);t.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&P(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const j=g=>{var _;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(w);break;case"insertImage":{(_=M.current)==null||_.click();break}default:console.warn("Unknown command:",w)}},K=g=>{n("foreColor",g.target.value)},I=g=>{n("backColor",g.target.value)},[R,B]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const g=()=>{B({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.createElement("div",{className:`rte-toolbar ${A||""}`,style:D},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:j,className:R.bold?"rte-active":""},t.createElement(pt,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:j,className:R.italic?"rte-active":""},t.createElement(Et,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:j,className:R.underline?"rte-active":""},t.createElement(Rt,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:j,title:"UnorderedList",className:R.unorderedList?"rte-active":""},t.createElement(yt,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:j,className:R.orderedList?"rte-active":""},t.createElement(gt,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:R.link?"rte-active":""},t.createElement(wt,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),l(),x()},className:R.removeFormat?"rte-active":""},t.createElement(Lt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:j,className:R.image?"rte-active":""},t.createElement(ft,null)),t.createElement("input",{type:"file",accept:"image/*",ref:M,style:{display:"none"},onChange:i}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),l(),P(w=>!w)},className:R.emoji?"rte-active":""},t.createElement(Ct,null)),H&&t.createElement("div",{className:"rte-emoji-popup"},St.map(g=>t.createElement("span",{key:g,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:w=>{w.preventDefault(),y(g),P(!1)}},g)))),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),l(),(w=T.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((k=T.current)==null?void 0:k.value)||"#000",fontSize:"18px"},className:R.color?"rte-active":""},t.createElement(xt,null)),t.createElement("input",{ref:T,type:"color",defaultValue:"#000000",onChange:g=>{var w;K(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),l(),(w=b.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((F=b.current)==null?void 0:F.value)||"#000",fontSize:"18px"},className:R.highlight?"rte-active":""},t.createElement(vt,null)),t.createElement("input",{ref:b,type:"color",onChange:g=>{var w;I(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyLeft"),className:R.alignLeft?"rte-active":""},t.createElement(ht,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyCenter"),className:R.alignCenter?"rte-active":""},t.createElement(dt,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyRight"),className:R.alignRight?"rte-active":""},t.createElement(mt,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>n("insertTable"),className:R.table?"rte-active":""},t.createElement(bt,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>l(),onChange:v},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>l(),onChange:u},t.createElement("option",{value:"",disabled:!0},"Font Size"),t.createElement("option",{value:"2"},"Small "),t.createElement("option",{value:"3"},"Normal"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large")))},Mt=({show:n,position:l,filtered:i,insertMention:u,onClose:v,query:y})=>{const L=t.useRef(null);return t.useEffect(()=>{const x=E=>{L.current&&!L.current.contains(E.target)&&v()};return n&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[n,v]),n?t.createElement("ul",{ref:L,className:"rte-popup",style:{top:l.y,left:l.x}},i.length>0?i.map(({key:x,value:E})=>{const A=x.toLowerCase(),D=y.toLowerCase(),M=A.indexOf(D);let T=x;if(M!==-1&&y.length>0){const b=M+y.length;T=x.substring(0,M)+`<span class="rte-highlight">${x.substring(M,b)}</span>`+x.substring(b)}return t.createElement("li",{key:E,onMouseDown:b=>{b.preventDefault(),u({key:x,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:T},onMouseEnter:b=>b.currentTarget.style.background="#f0f0f0",onMouseLeave:b=>b.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function Ce(n){return S({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:[]}]}]}]})(n)}function U(n){return S({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:[]}]}]}]})(n)}const zt=({visible:n,x:l,y:i,onAction:u,onClose:v})=>{if(!n)return null;const y={top:i,left:l};return t.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:v},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(U,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(U,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(U,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(U,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(Ce,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(Ce,null)," Delete column"))},Le=({html:n,className:l,style:i})=>{const u=v=>{const y=v.target;if(y.tagName==="A"){v.preventDefault();const L=y.href;L&&window.open(L,"_blank","noopener,noreferrer")}};return t.createElement("div",{className:`rte-preview ${l||""}`,style:i,onClick:u,dangerouslySetInnerHTML:{__html:n}})},Nt=({visible:n,linkData:l,onClose:i,onInsert:u})=>{const[v,y]=t.useState(""),[L,x]=t.useState(""),[E,A]=t.useState(""),[D,M]=t.useState("_self");if(t.useEffect(()=>{n?(y(l.url||""),x(l.text||""),A(l.title||""),M(l.target||"_self")):(y(""),x(""),A(""),M("_self"))},[n,l]),!n)return null;const T=()=>{u({url:v,text:L,title:E,target:D})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:i}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},v?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:v,onChange:b=>y(b.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:b=>x(b.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:b=>A(b.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:D,onChange:b=>M(b.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:i},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:T},"OK"))))},kt=({atSuggestions:n=[],showOutput:l=!1,showPreview:i=!1,toolbarConfig:u={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:v={},styles:y={},handleGetHtml:L=()=>{},onChange:x=()=>{},value:E,onMentionSelect:A=()=>{}})=>{var ie,se,ue,de,me,fe,ge,he;const D=t.useRef(null),[M,T]=t.useState(E!=null&&E.length?E:" "),[b,H]=t.useState(!1),[P,j]=t.useState({x:0,y:0}),[K,I]=t.useState([]),R=t.useRef(null),B=t.useRef(null),[k,F]=t.useState({visible:!1,x:0,y:0}),[g,w]=t.useState(!1),_=t.useRef(null),[Se,J]=t.useState({url:"",text:"",title:"",target:"_self"}),Me={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ie=u.link)!=null?ie:!1,image:(se=u.image)!=null?se:!1,emoji:(ue=u.emoji)!=null?ue:!1,table:(de=u.table)!=null?de:!1,color:(me=u.color)!=null?me:!1,fontFamily:(fe=u.fontFamily)!=null?fe:!1,fontSize:(ge=u.fontSize)!=null?ge:!1,highlight:(he=u.fontSize)!=null?he:!1},[ze,G]=t.useState(""),[ee,te]=t.useState([]),O=()=>D.current,z=()=>{const e=ce();T(e),L==null||L(e);const r=Ze(e);x(r);const a=je();JSON.stringify(a)!==JSON.stringify(ee)&&(te(a),A(a))},ne=()=>{const e=window.getSelection();e!=null&&e.rangeCount&&(R.current=e.getRangeAt(0))},q=()=>{const e=window.getSelection();e&&R.current&&(e.removeAllRanges(),e.addRange(R.current))},Ne=(e,r)=>{const a=window.getSelection();a&&a.rangeCount>0&&(R.current=a.getRangeAt(0)),q(),document.execCommand(e,!1,r),z()};t.useEffect(()=>{const e=O();e&&!e.innerHTML&&(e.innerHTML=M),z()},[]),t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]);const re=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ke=e=>{let r=0,a=e.parentElement;for(;a;)(a.tagName==="UL"||a.tagName==="OL")&&r++,a=a.parentElement;return r},Ae=e=>{const r=e.querySelector("li"),a=r?ke(r):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${a>1?a:""}}}`,d=`{{/arrayData${a>1?a:""}}}`,c=document.createElement("span");c.textContent=o,c.style.display="none",c.setAttribute("data-hidden-array-start","true"),e.insertBefore(c,e.firstChild);const s=document.createElement("span");s.textContent=d,s.style.display="none",s.setAttribute("data-hidden-array-end","true"),e.appendChild(s)},ae=e=>{var h;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.getRangeAt(0),o=re(a.startContainer);let d,c;if(o){let m=o.querySelector(e);m||(m=document.createElement(e),m.style.margin="0",m.style.paddingLeft="20px",o.appendChild(m)),c=m,d=document.createElement("li"),d.textContent="â",c.appendChild(d)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const m=O();if(c=m==null?void 0:m.querySelector(`${e}:last-child`),!c)return;d=c.querySelector("li:last-child")}Ae(c);const s=document.createRange();s.setStart(d,0),s.collapse(!0),r.removeAllRanges(),r.addRange(s),(h=O())==null||h.focus(),z()},V=(e,r)=>{e==="insertOrderedList"?ae("ol"):e==="insertUnorderedList"?ae("ul"):Ne(e,r),e==="insertTable"&&Ie()},Te=e=>{const r=document.createElement("span");r.textContent="â",e.insertNode(r),e.setStartAfter(r),e.collapse(!0);const a=r.getBoundingClientRect();r.remove(),j({x:a.left,y:a.bottom+window.scrollY}),I(n||[]),H(!0),B.current=e.cloneRange()},Oe=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.anchorNode;let a=e.anchorOffset;if(!r)return null;let o=r;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[a]?o=o.childNodes[a]:o=r.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const d=o.textContent||"",c=o===r?a:d.length,s=d.lastIndexOf("@",c-1);if(s!==-1){const h=document.createRange();return h.setStart(o,s),h.setEnd(o,c),h}}o=o.previousSibling}return null},De=e=>{var c;const r=window.getSelection();if(!r)return;const a=Oe();a?(r.removeAllRanges(),r.addRange(a)):B.current&&(r.removeAllRanges(),r.addRange(B.current));const o=document.createElement("span");o.textContent=`{{${e.key}}}`,o.style.color="#007bff",o.style.display="inline",o.contentEditable="false",o.setAttribute("data-mention",e.value||e.key||"");try{const s=r.rangeCount?r.getRangeAt(0):null;if(s)s.deleteContents(),s.insertNode(o);else{const p=document.createRange(),f=O();p.selectNodeContents(f),p.collapse(!1),p.insertNode(o)}const h=document.createTextNode(" ");o.after(h);const m=document.createRange();m.setStartAfter(h),m.collapse(!0),r.removeAllRanges(),r.addRange(m)}catch(s){console.error("insertMention error:",s)}let d=[...ee,e];te(d),A(d),H(!1),(c=O())==null||c.focus(),z()},je=()=>{const e=O();if(!e)return[];const r=e.querySelectorAll("span[data-mention]"),a=[];return r.forEach(o=>{const d=o.getAttribute("data-mention")||"",s=(o.textContent||"").match(/{{(.+?)}}/);s&&a.push({key:s[1],value:d})}),a},He=e=>{var a,o,d;const r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(r)&&(e.preventDefault(),V(r==="b"?"bold":r==="i"?"italic":r==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const c=window.getSelection(),s=c!=null&&c.anchorNode?re(c.anchorNode):null;if(!s)return;if(((a=s.textContent)==null?void 0:a.replace(/\u200B/g,"").trim())===""){e.preventDefault();const m=s.parentElement,p=m==null?void 0:m.closest("li");if(p){m==null||m.removeChild(s);const f=document.createElement("p");f.innerHTML="<br />",(o=p.parentElement)==null||o.insertBefore(f,p.nextSibling);const C=document.createRange();C.setStart(f,0),C.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(C)}else{const f=s.closest("ul, ol");if(f){const C=document.createElement("p");C.innerHTML="<br />",(d=f.parentElement)==null||d.insertBefore(C,f.nextSibling),f.removeChild(s);const N=document.createRange();N.setStart(C,0),N.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(N)}}z()}}},_e=e=>{if(e.data==="@"){const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;setTimeout(()=>{Te(a.getRangeAt(0)),G(""),I(n),H(!0)},0);return}if(b){setTimeout(()=>oe(),0);return}},oe=()=>{if(z(),!b)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const a=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!a){H(!1);return}const o=a[1].toLowerCase();G(o);const d=n.filter(c=>c.key.toLowerCase().includes(o));I(d)},Fe=e=>{var o;const r=(o=e.target.files)==null?void 0:o[0];if(!r)return;const a=new FileReader;a.onload=d=>{var N;const c=(N=d.target)==null?void 0:N.result;q();const s=window.getSelection();let h=s&&s.rangeCount?s.getRangeAt(0):null;const m=document.createElement("img");m.src=c,m.alt=r.name||"image",m.className="rte-inserted-image",m.contentEditable="true";const p=O();if(!h||!p){p==null||p.appendChild(m);const pe=document.createTextNode(" ");p==null||p.appendChild(pe);const Y=document.createRange();Y.setStartAfter(pe),Y.collapse(!0),s==null||s.removeAllRanges(),s==null||s.addRange(Y),p==null||p.focus(),z(),e.target.value="";return}h.deleteContents(),h.insertNode(m);const f=document.createTextNode(" ");m.after(f);const C=document.createRange();C.setStartAfter(f),C.collapse(!0),s.removeAllRanges(),s.addRange(C),p.focus(),z(),e.target.value=""},a.readAsDataURL(r)},Pe=e=>{var d;q();const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.getRangeAt(0),o=document.createTextNode(e);a.insertNode(o),a.setStartAfter(o),a.collapse(!0),r.removeAllRanges(),r.addRange(a),(d=O())==null||d.focus(),z()},Ie=()=>{q();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";const r=document.createElement("thead"),a=document.createElement("tbody"),o=document.createElement("tr"),d=document.createElement("tr");for(let h=0;h<2;h++){const m=document.createElement("th");m.textContent=`Header ${h+1}`,m.style.border="1px solid #999",m.style.padding="8px",m.style.position="relative",m.style.backgroundColor="lightgray";const p=document.createElement("td");p.textContent=`Row 1 Col ${h+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",X(m),X(p),o.appendChild(m),d.appendChild(p)}r.appendChild(o),a.appendChild(d),e.appendChild(r),e.appendChild(a),$e(e),Be(e);const c=window.getSelection();if(!(c!=null&&c.rangeCount))return;c.getRangeAt(0).insertNode(e),z()},Be=e=>{const r=document.createElement("div");Object.assign(r.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let a=0,o=0,d=0,c=0;r.addEventListener("mousedown",s=>{s.preventDefault(),a=s.clientX,o=s.clientY;const h=e.getBoundingClientRect();d=h.width,c=h.height;const m=f=>{const C=Math.max(100,d+(f.clientX-a)),N=Math.max(60,c+(f.clientY-o));e.style.width=`${C}px`,e.style.height=`${N}px`,z()},p=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p),z()};document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)}),e.appendChild(r)},X=e=>{const r=document.createElement("div"),a=document.createElement("div");Object.assign(r.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(a.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),qe(e,r,a),e.appendChild(r),e.appendChild(a)},qe=(e,r,a)=>{let o=0,d=0,c=0,s=0;r.addEventListener("mousedown",f=>{f.preventDefault(),o=f.clientX,c=e.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)}),a.addEventListener("mousedown",f=>{f.preventDefault(),d=f.clientY,s=e.offsetHeight,document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)});const h=f=>{const C=c+(f.clientX-o);e.style.width=`${Math.max(30,C)}px`},m=f=>{const C=s+(f.clientY-d);e.style.height=`${Math.max(20,C)}px`},p=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)}},Ve=e=>{const a=e.target.closest("td, th");a&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),a.classList.add("rte-cell-highlight"),F({visible:!0,x:e.clientX,y:e.clientY,cell:a}))},le=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Ue=e=>{if(!k.cell)return;const r=k.cell.closest("table"),a=k.cell.cellIndex,o=k.cell.parentElement.rowIndex,d=c=>{const s=c.tagName.toLowerCase(),h=document.createElement(s);return h.textContent=c.textContent||"",h.style.cssText=c.style.cssText,X(h),h};switch(e){case"insertRowAbove":{const c=r.rows[o],s=r.insertRow(o);Array.from(c.cells).forEach(h=>{s.appendChild(d(h))});break}case"insertRowBelow":{const c=r.rows[o],s=r.insertRow(o+1);Array.from(c.cells).forEach(h=>{s.appendChild(d(h))});break}case"insertColLeft":{Array.from(r.rows).forEach(c=>{const s=c.cells[a];c.insertBefore(d(s),s)});break}case"insertColRight":{Array.from(r.rows).forEach(c=>{const s=c.cells[a];c.insertBefore(d(s),s.nextSibling)});break}case"deleteRow":r.rows.length>1&&r.deleteRow(o);break;case"deleteCol":Array.from(r.rows).forEach(c=>{c.cells[a]&&c.deleteCell(a)});break}z(),F(Q(Z({},k),{visible:!1})),le()},$e=e=>{const r=e.querySelector("tbody");if(!r||r.querySelector("[data-hidden-table-start]"))return;const a=document.createElement("span");a.textContent="{{#arrayData}}",a.style.display="none",a.setAttribute("data-hidden-table-start","true"),r.insertBefore(a,r.firstChild);const o=document.createElement("span");o.textContent="{{/arrayData}}",o.style.display="none",o.setAttribute("data-hidden-table-end","true"),r.appendChild(o)},ce=()=>{const e=O();if(!e)return M;const r=e.cloneNode(!0);return r.querySelectorAll("table div").forEach(a=>a.remove()),r.querySelectorAll(".rte-cell-highlight").forEach(a=>a.classList.remove("rte-cell-highlight")),r.innerHTML},We=()=>{ne(),_.current=R.current,J({url:"",text:"",title:"",target:"_self"}),w(!0)},Ke=e=>{const r=window.getSelection();if(!r||!_.current)return;r.removeAllRanges(),r.addRange(_.current);let a=e.url.trim();/^https?:\/\//i.test(a)||(a="https://"+a);const o=document.createElement("a");o.href=a,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||a,o.title=e.title,o.target=e.target,o.contentEditable="true";const d=r.getRangeAt(0);d.deleteContents(),d.insertNode(o);const c=document.createTextNode(" ");o.after(c);const s=document.createRange();s.setStartAfter(c),s.collapse(!0),r.removeAllRanges(),r.addRange(s),w(!1),z()},Xe=e=>{const r=e.target;if(r.tagName==="A"){const a=r;if(e.ctrlKey||e.metaKey){window.open(a.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(a),_.current=o,J({url:a.href,text:a.textContent||a.href,title:a.title,target:a.target}),w(!0)}},Ye=()=>{const e=O();if(!e)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&R.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(R.current)}const a=window.getSelection();if(!a||a.rangeCount===0)return;const o=a.getRangeAt(0);q(),document.execCommand("removeFormat",!1);const d=o.cloneContents(),c=document.createElement("div");c.appendChild(d);const s=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,null),h=[];for(;s.nextNode();){const f=s.currentNode,C=f.tagName.toUpperCase(),N=f.getAttribute&&f.getAttribute("data-mention")!==null;C!=="A"&&!N&&h.push(f)}for(let f=h.length-1;f>=0;f--){const C=h[f],N=C.parentNode;if(N){for(;C.firstChild;)N.insertBefore(C.firstChild,C);N.removeChild(C)}}c.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),o.deleteContents();const m=document.createDocumentFragment();for(;c.firstChild;)m.appendChild(c.firstChild);o.insertNode(m);const p=document.createRange();p.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),p.collapse(!0),a.removeAllRanges(),a.addRange(p),e.normalize(),z()},Ze=e=>{var o;let r=e;r=r.replace(/{{#arrayData\d*}}/g,""),r=r.replace(/{{\/arrayData\d*}}/g,"");const a=document.createElement("div");return a.innerHTML=r,a.querySelectorAll("br").forEach(d=>{d.replaceWith(`
|
|
1
|
+
"use strict";var nt=Object.defineProperty,rt=Object.defineProperties;var at=Object.getOwnPropertyDescriptors;var ye=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var we=(n,l,s)=>l in n?nt(n,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[l]=s,ee=(n,l)=>{for(var s in l||(l={}))ot.call(l,s)&&we(n,s,l[s]);if(ye)for(var s of ye(l))lt.call(l,s)&&we(n,s,l[s]);return n},te=(n,l)=>rt(n,at(l));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),ct=require("react-dom");function it(n){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const u=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(l,s,u.get?u:{enumerable:!0,get:()=>n[s]})}}return l.default=n,Object.freeze(l)}const st=it(t);window.React=st;var Le={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},be=t.createContext&&t.createContext(Le),ut=["attr","size","title"];function dt(n,l){if(n==null)return{};var s=mt(n,l),u,m;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(n);for(m=0;m<w.length;m++)u=w[m],!(l.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(n,u)&&(s[u]=n[u])}return s}function mt(n,l){if(n==null)return{};var s={};for(var u in n)if(Object.prototype.hasOwnProperty.call(n,u)){if(l.indexOf(u)>=0)continue;s[u]=n[u]}return s}function K(){return K=Object.assign?Object.assign.bind():function(n){for(var l=1;l<arguments.length;l++){var s=arguments[l];for(var u in s)Object.prototype.hasOwnProperty.call(s,u)&&(n[u]=s[u])}return n},K.apply(this,arguments)}function Ce(n,l){var s=Object.keys(n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(n);l&&(u=u.filter(function(m){return Object.getOwnPropertyDescriptor(n,m).enumerable})),s.push.apply(s,u)}return s}function X(n){for(var l=1;l<arguments.length;l++){var s=arguments[l]!=null?arguments[l]:{};l%2?Ce(Object(s),!0).forEach(function(u){ft(n,u,s[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(s)):Ce(Object(s)).forEach(function(u){Object.defineProperty(n,u,Object.getOwnPropertyDescriptor(s,u))})}return n}function ft(n,l,s){return l=gt(l),l in n?Object.defineProperty(n,l,{value:s,enumerable:!0,configurable:!0,writable:!0}):n[l]=s,n}function gt(n){var l=ht(n,"string");return typeof l=="symbol"?l:l+""}function ht(n,l){if(typeof n!="object"||!n)return n;var s=n[Symbol.toPrimitive];if(s!==void 0){var u=s.call(n,l);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(n)}function Se(n){return n&&n.map((l,s)=>t.createElement(l.tag,X({key:s},l.attr),Se(l.child)))}function S(n){return l=>t.createElement(pt,K({attr:X({},n.attr)},l),Se(n.child))}function pt(n){var l=s=>{var{attr:u,size:m,title:w}=n,L=dt(n,ut),C=m||s.size||"1em",E;return s.className&&(E=s.className),n.className&&(E=(E?E+" ":"")+n.className),t.createElement("svg",K({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},s.attr,u,L,{className:E,style:X(X({color:n.color||s.color},s.style),n.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),w&&t.createElement("title",null,w),n.children)};return be!==void 0?t.createElement(be.Consumer,null,s=>l(s)):l(Le)}function vt(n){return S({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:[]}]})(n)}function Et(n){return S({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:[]}]})(n)}function yt(n){return S({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:[]}]})(n)}function wt(n){return S({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:[]}]})(n)}function bt(n){return S({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:[]}]})(n)}function Ct(n){return S({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:[]}]})(n)}function Rt(n){return S({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:[]}]})(n)}function xt(n){return S({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:[]}]})(n)}function Lt(n){return S({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:[]}]})(n)}function St(n){return S({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:[]}]})(n)}function Mt(n){return S({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:[]}]})(n)}function zt(n){return S({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:[]}]})(n)}function kt(n){return S({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:[]}]})(n)}function At(n){return S({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:[]}]})(n)}function Nt(n){return S({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:[]}]})(n)}const Tt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],Me=({exec:n,saveSelection:l,handleFileChange:s,handleFontSizeChange:u,handleFontFamilyChange:m,insertEmoji:w,handleLink:L,removeFormatting:C,visibleActions:E,className:N,style:D})=>{var P,$;const z=t.useRef(null),A=t.useRef(null),R=t.useRef(null),[q,j]=t.useState(!1),[V,Y]=t.useState({x:0,y:0});t.useEffect(()=>{const g=y=>{!y.target.closest(".rte-emoji-popup")&&!y.target.closest("button[title='Emoji']")&&j(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const _=g=>{var F;g.preventDefault();const y=g.currentTarget.dataset.command;if(y)switch(y){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(y);break;case"insertImage":{(F=z.current)==null||F.click();break}default:console.warn("Unknown command:",y)}},B=g=>{n("foreColor",g.target.value)},H=g=>{n("backColor",g.target.value)},[x,T]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const g=()=>{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",g),()=>document.removeEventListener("selectionchange",g)},[]),t.createElement("div",{className:`rte-toolbar ${N||""}`,style:D},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:_,className:x.bold?"rte-active":""},t.createElement(Ct,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:_,className:x.italic?"rte-active":""},t.createElement(xt,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:_,className:x.underline?"rte-active":""},t.createElement(kt,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:_,title:"UnorderedList",className:x.unorderedList?"rte-active":""},t.createElement(St,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:_,className:x.orderedList?"rte-active":""},t.createElement(wt,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:x.link?"rte-active":""},t.createElement(Lt,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),l(),C()},className:x.removeFormat?"rte-active":""},t.createElement(Nt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:_,className:x.image?"rte-active":""},t.createElement(yt,null)),t.createElement("input",{type:"file",accept:"image/*",ref:z,style:{display:"none"},onChange:s}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),l();const y=g.currentTarget.getBoundingClientRect();Y({x:y.left,y:y.bottom+8}),j(F=>!F)},className:x.emoji?"rte-active":""},t.createElement(Mt,null)),q&&ct.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:V.y,left:V.x}},Tt.map((g,y)=>t.createElement("span",{key:y,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:F=>{F.preventDefault(),w(g),j(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var y;g.preventDefault(),l(),(y=A.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((P=A.current)==null?void 0:P.value)||"#000",fontSize:"18px"},className:x.color?"rte-active":""},t.createElement(At,null)),t.createElement("input",{ref:A,type:"color",defaultValue:"#000000",onChange:g=>{var y;B(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var y;g.preventDefault(),l(),(y=R.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:(($=R.current)==null?void 0:$.value)||"#000",fontSize:"18px"},className:x.highlight?"rte-active":""},t.createElement(Rt,null)),t.createElement("input",{ref:R,type:"color",onChange:g=>{var y;H(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyLeft"),className:x.alignLeft?"rte-active":""},t.createElement(bt,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyCenter"),className:x.alignCenter?"rte-active":""},t.createElement(vt,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyRight"),className:x.alignRight?"rte-active":""},t.createElement(Et,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>n("insertTable"),className:x.table?"rte-active":""},t.createElement(zt,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>l(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>l(),onChange:u},t.createElement("option",{value:"",disabled:!0},"Font Size"),t.createElement("option",{value:"2"},"Small "),t.createElement("option",{value:"3"},"Normal"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large")))},Ot=({show:n,position:l,filtered:s,insertMention:u,onClose:m,query:w})=>{const L=t.useRef(null);return t.useEffect(()=>{const C=E=>{L.current&&!L.current.contains(E.target)&&m()};return n&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[n,m]),n?t.createElement("ul",{ref:L,className:"rte-popup",style:{top:l.y,left:l.x}},s.length>0?s.map(({name:C,value:E})=>{const N=C.toLowerCase(),D=w.toLowerCase(),z=N.indexOf(D);let A=C;if(z!==-1&&w.length>0){const R=z+w.length;A=C.substring(0,z)+`<span class="rte-highlight">${C.substring(z,R)}</span>`+C.substring(R)}return t.createElement("li",{key:E,onMouseDown:R=>{R.preventDefault(),u({name:C,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:A},onMouseEnter:R=>R.currentTarget.style.background="#f0f0f0",onMouseLeave:R=>R.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function Re(n){return S({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:[]}]}]}]})(n)}function W(n){return S({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:[]}]}]}]})(n)}const Dt=({visible:n,x:l,y:s,onAction:u,onClose:m})=>{if(!n)return null;const w={top:s,left:l};return t.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:m},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(W,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(W,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(W,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(W,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(Re,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(Re,null)," Delete column"))},ze=({html:n,className:l,style:s})=>{const u=w=>{const L=w.target;if(L.tagName==="A"){w.preventDefault();const C=L.href;C&&window.open(C,"_blank","noopener,noreferrer")}},m=w=>w.replace(/{{\s*(.*?)\s*}}/g,"$1");return t.createElement("div",{className:`rte-preview ${l||""}`,style:s,onClick:u,dangerouslySetInnerHTML:{__html:m(n)}})},jt=({visible:n,linkData:l,onClose:s,onInsert:u})=>{const[m,w]=t.useState(""),[L,C]=t.useState(""),[E,N]=t.useState(""),[D,z]=t.useState("_self");if(t.useEffect(()=>{n?(w(l.url||""),C(l.text||""),N(l.title||""),z(l.target||"_self")):(w(""),C(""),N(""),z("_self"))},[n,l]),!n)return null;const A=()=>{u({url:m,text:L,title:E,target:D})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:s}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},m?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:m,onChange:R=>w(R.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:R=>C(R.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:R=>N(R.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:D,onChange:R=>z(R.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:s},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:A},"OK"))))};function xe(n){return Array.from(new Map(n.map(l=>[l.value,l])).values())}const Ht=({atSuggestions:n=[],showOutput:l=!1,showPreview:s=!1,toolbarConfig:u={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:m={},styles:w={},handleGetHtml:L=()=>{},onChange:C=()=>{},value:E,onMentionSelect:N=()=>{},handleAddAttributes:D=()=>{}})=>{var ue,de,me,fe,ge,he,pe,ve;const z=t.useRef(null),[A,R]=t.useState(E!=null&&E.length?E:" "),[q,j]=t.useState(!1),[V,Y]=t.useState({x:0,y:0}),[_,B]=t.useState([]),H=t.useRef(null),x=t.useRef(null),[T,P]=t.useState({visible:!1,x:0,y:0}),[$,g]=t.useState(!1),y=t.useRef(null),[F,ne]=t.useState({url:"",text:"",title:"",target:"_self"}),ke={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ue=u.link)!=null?ue:!1,image:(de=u.image)!=null?de:!1,emoji:(me=u.emoji)!=null?me:!1,table:(fe=u.table)!=null?fe:!1,color:(ge=u.color)!=null?ge:!1,fontFamily:(he=u.fontFamily)!=null?he:!1,fontSize:(pe=u.fontSize)!=null?pe:!1,highlight:(ve=u.fontSize)!=null?ve:!1},[Ae,re]=t.useState(""),[Z,Q]=t.useState([]),O=()=>z.current,M=()=>{const e=se();R(e),L==null||L(e);const r=tt(e);C(r);const a=Pe(),o=xe(a);JSON.stringify(o)!==JSON.stringify(Z)&&(Q(o),N(o))},ae=()=>{const e=window.getSelection();e!=null&&e.rangeCount&&(H.current=e.getRangeAt(0))},I=()=>{const e=window.getSelection();e&&H.current&&(e.removeAllRanges(),e.addRange(H.current))},Ne=(e,r)=>{const a=window.getSelection();a&&a.rangeCount>0&&(H.current=a.getRangeAt(0)),I(),document.execCommand(e,!1,r),M()};t.useEffect(()=>{const e=O();e&&!e.innerHTML&&(e.innerHTML=A),M()},[]),t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{D&&D(e=>{Fe(e)})},[]);const oe=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Te=e=>{let r=0,a=e.parentElement;for(;a;)(a.tagName==="UL"||a.tagName==="OL")&&r++,a=a.parentElement;return r},Oe=e=>{const r=e.querySelector("li"),a=r?Te(r):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${a>1?a:""}}}`,d=`{{/arrayData${a>1?a:""}}}`,c=document.createElement("span");c.textContent=o,c.style.display="none",c.setAttribute("data-hidden-array-start","true"),e.insertBefore(c,e.firstChild);const i=document.createElement("span");i.textContent=d,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},le=e=>{var v;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.getRangeAt(0),o=oe(a.startContainer);let d,c;if(o){let f=o.querySelector(e);f||(f=document.createElement(e),f.style.margin="0",f.style.paddingLeft="20px",o.appendChild(f)),c=f,d=document.createElement("li"),d.textContent="â",c.appendChild(d)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const f=O();if(c=f==null?void 0:f.querySelector(`${e}:last-child`),!c)return;d=c.querySelector("li:last-child")}Oe(c);const i=document.createRange();i.setStart(d,0),i.collapse(!0),r.removeAllRanges(),r.addRange(i),(v=O())==null||v.focus(),M()},U=(e,r)=>{e==="insertOrderedList"?le("ol"):e==="insertUnorderedList"?le("ul"):Ne(e,r),e==="insertTable"&&Ue()},De=e=>{const r=document.createElement("span");r.textContent="â",e.insertNode(r),e.setStartAfter(r),e.collapse(!0);const a=r.getBoundingClientRect();r.remove(),Y({x:a.left,y:a.bottom+window.scrollY}),B(n||[]),j(!0),x.current=e.cloneRange()},je=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.anchorNode;let a=e.anchorOffset;if(!r)return null;let o=r;for(o.nodeType!==Node.TEXT_NODE&&(o.childNodes&&o.childNodes[a]?o=o.childNodes[a]:o=r.previousSibling);o;){if(o.nodeType===Node.TEXT_NODE){const d=o.textContent||"",c=o===r?a:d.length,i=d.lastIndexOf("@",c-1);if(i!==-1){const v=document.createRange();return v.setStart(o,i),v.setEnd(o,c),v}}o=o.previousSibling}return null},He=e=>{var c;const r=window.getSelection();if(!r)return;const a=je();a?(r.removeAllRanges(),r.addRange(a)):x.current&&(r.removeAllRanges(),r.addRange(x.current));const o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.color="#007bff",o.style.display="inline",o.contentEditable="false",o.setAttribute("data-mention",e.value||e.name||"");try{const i=r.rangeCount?r.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(o);else{const p=document.createRange(),h=O();p.selectNodeContents(h),p.collapse(!1),p.insertNode(o)}const v=document.createTextNode(" ");o.after(v);const f=document.createRange();f.setStartAfter(v),f.collapse(!0),r.removeAllRanges(),r.addRange(f)}catch(i){console.error("insertMention error:",i)}let d=xe([...Z,e]);Q(d),N(d),j(!1),(c=O())==null||c.focus(),M()},_e=e=>{var i;I();const r=window.getSelection();if(!r||!r.rangeCount)return;const a=r.getRangeAt(0),o=document.createElement("span");o.textContent=`{{${e.name}}}`,o.style.color="#007bff",o.style.display="inline",o.contentEditable="false",o.setAttribute("data-mention",e.value||e.name),a.insertNode(o);const d=document.createTextNode(" ");o.after(d);const c=document.createRange();c.setStartAfter(d),c.collapse(!0),r.removeAllRanges(),r.addRange(c),(i=O())==null||i.focus()},Fe=e=>{e.forEach(o=>_e(o));const r=[...Z,...e],a=Array.from(new Map(r.map(o=>[o.name,o])).values());Q(a),N(a),M()},Pe=()=>{const e=O();if(!e)return[];const r=e.querySelectorAll("span[data-mention]"),a=[];return r.forEach(o=>{const d=o.getAttribute("data-mention")||"",i=(o.textContent||"").match(/{{(.+?)}}/);i&&a.push({name:i[1],value:d})}),a},Ie=e=>{var a,o,d;const r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(r)&&(e.preventDefault(),U(r==="b"?"bold":r==="i"?"italic":r==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const c=window.getSelection(),i=c!=null&&c.anchorNode?oe(c.anchorNode):null;if(!i)return;if(((a=i.textContent)==null?void 0:a.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=i.parentElement,p=f==null?void 0:f.closest("li");if(p){f==null||f.removeChild(i);const h=document.createElement("p");h.innerHTML="<br />",(o=p.parentElement)==null||o.insertBefore(h,p.nextSibling);const b=document.createRange();b.setStart(h,0),b.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(b)}else{const h=i.closest("ul, ol");if(h){const b=document.createElement("p");b.innerHTML="<br />",(d=h.parentElement)==null||d.insertBefore(b,h.nextSibling),h.removeChild(i);const k=document.createRange();k.setStart(b,0),k.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(k)}}M()}}},qe=e=>{if(e.data==="@"){const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;const o=a.anchorNode;if(Be(o))return;setTimeout(()=>{De(a.getRangeAt(0)),re(""),B(n),j(!0)},0);return}if(q){setTimeout(()=>ce(),0);return}},Be=e=>{if(!e)return!1;let r=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;r;){if(r.tagName==="TH")return!0;r=r.parentElement}return!1},ce=()=>{if(M(),!q)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const a=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!a){j(!1);return}const o=a[1].toLowerCase();re(o);const d=n.filter(c=>c.name.toLowerCase().includes(o));B(d)},Ve=e=>{var o;const r=(o=e.target.files)==null?void 0:o[0];if(!r)return;const a=new FileReader;a.onload=d=>{var k;const c=(k=d.target)==null?void 0:k.result;I();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const f=document.createElement("img");f.src=c,f.alt=r.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const p=O();if(!v||!p){p==null||p.appendChild(f);const Ee=document.createTextNode(" ");p==null||p.appendChild(Ee);const G=document.createRange();G.setStartAfter(Ee),G.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(G),p==null||p.focus(),M(),e.target.value="";return}v.deleteContents(),v.insertNode(f);const h=document.createTextNode(" ");f.after(h);const b=document.createRange();b.setStartAfter(h),b.collapse(!0),i.removeAllRanges(),i.addRange(b),p.focus(),M(),e.target.value=""},a.readAsDataURL(r)},$e=e=>{var d;I();const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.getRangeAt(0),o=document.createTextNode(e);a.insertNode(o),a.setStartAfter(o),a.collapse(!0),r.removeAllRanges(),r.addRange(a),(d=O())==null||d.focus(),M()},Ue=()=>{I();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",m.table&&e.classList.add(m.table);const r=document.createElement("thead");m.thead&&r.classList.add(m.thead);const a=document.createElement("tbody");m.tbody&&a.classList.add(m.tbody);const o=document.createElement("tr");m.tr&&o.classList.add(m.tr);const d=document.createElement("tr");m.tr&&d.classList.add(m.tr);for(let v=0;v<2;v++){const f=document.createElement("th");f.textContent=`Header ${v+1}`,f.style.border="1px solid #999",f.style.padding="8px",f.style.position="relative",f.style.backgroundColor="lightgray",m.th&&f.classList.add(m.th);const p=document.createElement("td");p.textContent=`Row 1 Col ${v+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",m.td&&p.classList.add(m.td),J(f),J(p),o.appendChild(f),d.appendChild(p)}r.appendChild(o),a.appendChild(d),e.appendChild(r),e.appendChild(a),Ze(e),We(e);const c=window.getSelection();if(!(c!=null&&c.rangeCount))return;c.getRangeAt(0).insertNode(e),M()},We=e=>{const r=document.createElement("div");Object.assign(r.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let a=0,o=0,d=0,c=0;r.addEventListener("mousedown",i=>{i.preventDefault(),a=i.clientX,o=i.clientY;const v=e.getBoundingClientRect();d=v.width,c=v.height;const f=h=>{const b=Math.max(100,d+(h.clientX-a)),k=Math.max(60,c+(h.clientY-o));e.style.width=`${b}px`,e.style.height=`${k}px`,M()},p=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),M()};document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)}),e.appendChild(r)},J=e=>{const r=document.createElement("div"),a=document.createElement("div");Object.assign(r.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(a.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Ke(e,r,a),e.appendChild(r),e.appendChild(a)},Ke=(e,r,a)=>{let o=0,d=0,c=0,i=0;r.addEventListener("mousedown",h=>{h.preventDefault(),o=h.clientX,c=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",p)}),a.addEventListener("mousedown",h=>{h.preventDefault(),d=h.clientY,i=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)});const v=h=>{const b=c+(h.clientX-o);e.style.width=`${Math.max(30,b)}px`},f=h=>{const b=i+(h.clientY-d);e.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)}},Xe=e=>{const a=e.target.closest("td, th");a&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),a.classList.add("rte-cell-highlight"),P({visible:!0,x:e.clientX,y:e.clientY,cell:a}))},ie=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Ye=e=>{if(!T.cell)return;const r=T.cell.closest("table"),a=T.cell.cellIndex,o=T.cell.parentElement.rowIndex,d=c=>{const i=c.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=c.textContent||"",v.style.cssText=c.style.cssText,J(v),v};switch(e){case"insertRowAbove":{const c=r.rows[o],i=r.insertRow(o);Array.from(c.cells).forEach(v=>{i.appendChild(d(v))});break}case"insertRowBelow":{const c=r.rows[o],i=r.insertRow(o+1);Array.from(c.cells).forEach(v=>{i.appendChild(d(v))});break}case"insertColLeft":{Array.from(r.rows).forEach(c=>{const i=c.cells[a];c.insertBefore(d(i),i)});break}case"insertColRight":{Array.from(r.rows).forEach(c=>{const i=c.cells[a];c.insertBefore(d(i),i.nextSibling)});break}case"deleteRow":r.rows.length>1&&r.deleteRow(o);break;case"deleteCol":Array.from(r.rows).forEach(c=>{c.cells[a]&&c.deleteCell(a)});break}M(),P(te(ee({},T),{visible:!1})),ie()},Ze=e=>{const r=e.querySelector("tbody");if(!r||r.querySelector("[data-hidden-table-start]"))return;const a=document.createElement("span");a.textContent="{{#arrayData}}",a.style.display="none",a.setAttribute("data-hidden-table-start","true"),r.insertBefore(a,r.firstChild);const o=document.createElement("span");o.textContent="{{/arrayData}}",o.style.display="none",o.setAttribute("data-hidden-table-end","true"),r.appendChild(o)},se=()=>{const e=O();if(!e)return A;const r=e.cloneNode(!0);return r.querySelectorAll("table div").forEach(a=>a.remove()),r.querySelectorAll(".rte-cell-highlight").forEach(a=>a.classList.remove("rte-cell-highlight")),r.innerHTML},Qe=()=>{ae(),y.current=H.current,ne({url:"",text:"",title:"",target:"_self"}),g(!0)},Je=e=>{const r=window.getSelection();if(!r||!y.current)return;r.removeAllRanges(),r.addRange(y.current);let a=e.url.trim();/^https?:\/\//i.test(a)||(a="https://"+a);const o=document.createElement("a");o.href=a,o.style.cursor="pointer",o.style.outline="none",o.textContent=e.text||a,o.title=e.title,o.target=e.target,o.contentEditable="true";const d=r.getRangeAt(0);d.deleteContents(),d.insertNode(o);const c=document.createTextNode(" ");o.after(c);const i=document.createRange();i.setStartAfter(c),i.collapse(!0),r.removeAllRanges(),r.addRange(i),g(!1),M()},Ge=e=>{const r=e.target;if(r.tagName==="A"){const a=r;if(e.ctrlKey||e.metaKey){window.open(a.href,"_blank","noopener,noreferrer");return}e.preventDefault();const o=document.createRange();o.selectNode(a),y.current=o,ne({url:a.href,text:a.textContent||a.href,title:a.title,target:a.target}),g(!0)}},et=()=>{const e=O();if(!e)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&H.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(H.current)}const a=window.getSelection();if(!a||a.rangeCount===0)return;const o=a.getRangeAt(0);I(),document.execCommand("removeFormat",!1);const d=o.cloneContents(),c=document.createElement("div");c.appendChild(d);const i=document.createTreeWalker(c,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const h=i.currentNode,b=h.tagName.toUpperCase(),k=h.getAttribute&&h.getAttribute("data-mention")!==null;b!=="A"&&!k&&v.push(h)}for(let h=v.length-1;h>=0;h--){const b=v[h],k=b.parentNode;if(k){for(;b.firstChild;)k.insertBefore(b.firstChild,b);k.removeChild(b)}}c.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),o.deleteContents();const f=document.createDocumentFragment();for(;c.firstChild;)f.appendChild(c.firstChild);o.insertNode(f);const p=document.createRange();p.setStartAfter(o.endContainer.nodeType===Node.TEXT_NODE?o.endContainer:o.startContainer),p.collapse(!0),a.removeAllRanges(),a.addRange(p),e.normalize(),M()},tt=e=>{var o;let r=e;r=r.replace(/{{#arrayData\d*}}/g,""),r=r.replace(/{{\/arrayData\d*}}/g,"");const a=document.createElement("div");return a.innerHTML=r,a.querySelectorAll("br").forEach(d=>{d.replaceWith(`
|
|
2
2
|
`)}),a.querySelectorAll("p, div, tr").forEach(d=>{d.insertAdjacentText("afterend",`
|
|
3
3
|
`)}),a.querySelectorAll("table").forEach(d=>{d.insertAdjacentText("afterend",`
|
|
4
4
|
`)}),((o=a.textContent)==null?void 0:o.replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim())||""};return t.createElement("div",{className:`rte-wrapper ${(
|
|
6
|
+
`).trim())||""};return t.createElement("div",{className:`rte-wrapper ${(m==null?void 0:m.wrapper)||""}`,style:w.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(Me,{exec:U,saveSelection:ae,handleFileChange:Ve,handleFontSizeChange:e=>U("fontSize",e.target.value),handleFontFamilyChange:e=>U("fontName",e.target.value),insertEmoji:$e,handleLink:Qe,removeFormatting:et,visibleActions:ke,className:m.toolbar,style:w.toolbar}),t.createElement("div",{ref:z,className:`rte-editor ${(m==null?void 0:m.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onInput:ce,onKeyDown:Ie,onBeforeInput:qe,onContextMenu:Xe,onClick:Ge}),t.createElement(Ot,{show:q,position:V,filtered:_,insertMention:He,onClose:()=>j(!1),query:Ae}),l&&t.createElement("div",{className:`rte-output ${(m==null?void 0:m.output)||""}`,style:w.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,A)),t.createElement(Dt,{visible:T.visible,x:T.x,y:T.y,onAction:Ye,onClose:()=>{P(te(ee({},T),{visible:!1})),ie()}}),t.createElement(jt,{visible:$,linkData:F,onClose:()=>g(!1),onInsert:Je})),s?t.createElement(ze,{className:m.preview,style:w.preview,html:se()}):null)};exports.RichTextEditor=Ht;exports.RtePreview=ze;exports.RteToolbar=Me;
|
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(S,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],e):(S=typeof globalThis!="undefined"?globalThis:S||self,e(S.RichTextEditor={},S.React))})(this,(function(S,e){"use strict";var zt=Object.defineProperty,Nt=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var Me=Object.getOwnPropertySymbols;var At=Object.prototype.hasOwnProperty,Tt=Object.prototype.propertyIsEnumerable;var ze=(S,e,T)=>e in S?zt(S,e,{enumerable:!0,configurable:!0,writable:!0,value:T}):S[e]=T,G=(S,e)=>{for(var T in e||(e={}))At.call(e,T)&&ze(S,T,e[T]);if(Me)for(var T of Me(e))Tt.call(e,T)&&ze(S,T,e[T]);return S},R=(S,e)=>Nt(S,kt(e));function T(n){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const u in n)if(u!=="default"){const c=Object.getOwnPropertyDescriptor(n,u);Object.defineProperty(s,u,c.get?c:{enumerable:!0,get:()=>n[u]})}}return s.default=n,Object.freeze(s)}const Ne=T(e);window.React=Ne;var ee={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},te=e.createContext&&e.createContext(ee),ke=["attr","size","title"];function Ae(n,s){if(n==null)return{};var u=Te(n,s),c,v;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(n);for(v=0;v<y.length;v++)c=y[v],!(s.indexOf(c)>=0)&&Object.prototype.propertyIsEnumerable.call(n,c)&&(u[c]=n[c])}return u}function Te(n,s){if(n==null)return{};var u={};for(var c in n)if(Object.prototype.hasOwnProperty.call(n,c)){if(s.indexOf(c)>=0)continue;u[c]=n[c]}return u}function W(){return W=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var u=arguments[s];for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(n[c]=u[c])}return n},W.apply(this,arguments)}function ne(n,s){var u=Object.keys(n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(n);s&&(c=c.filter(function(v){return Object.getOwnPropertyDescriptor(n,v).enumerable})),u.push.apply(u,c)}return u}function K(n){for(var s=1;s<arguments.length;s++){var u=arguments[s]!=null?arguments[s]:{};s%2?ne(Object(u),!0).forEach(function(c){Oe(n,c,u[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(u)):ne(Object(u)).forEach(function(c){Object.defineProperty(n,c,Object.getOwnPropertyDescriptor(u,c))})}return n}function Oe(n,s,u){return s=De(s),s in n?Object.defineProperty(n,s,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[s]=u,n}function De(n){var s=je(n,"string");return typeof s=="symbol"?s:s+""}function je(n,s){if(typeof n!="object"||!n)return n;var u=n[Symbol.toPrimitive];if(u!==void 0){var c=u.call(n,s);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(n)}function re(n){return n&&n.map((s,u)=>e.createElement(s.tag,K({key:u},s.attr),re(s.child)))}function M(n){return s=>e.createElement(He,W({attr:K({},n.attr)},s),re(n.child))}function He(n){var s=u=>{var{attr:c,size:v,title:y}=n,z=Ae(n,ke),L=v||u.size||"1em",E;return u.className&&(E=u.className),n.className&&(E=(E?E+" ":"")+n.className),e.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,c,z,{className:E,style:K(K({color:n.color||u.color},u.style),n.style),height:L,width:L,xmlns:"http://www.w3.org/2000/svg"}),y&&e.createElement("title",null,y),n.children)};return te!==void 0?e.createElement(te.Consumer,null,u=>s(u)):s(ee)}function _e(n){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(n)}function Fe(n){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(n)}function Pe(n){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(n)}function Ie(n){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(n)}function Be(n){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(n)}function qe(n){return M({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(n)}function Ve(n){return M({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(n)}function Ue(n){return M({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(n)}function $e(n){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function We(n){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(n)}function Ke(n){return M({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(n)}function Xe(n){return M({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(n)}function Ye(n){return M({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(n)}function Ze(n){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(n)}function Qe(n){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(n)}const Je=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],oe=({exec:n,saveSelection:s,handleFileChange:u,handleFontSizeChange:c,handleFontFamilyChange:v,insertEmoji:y,handleLink:z,removeFormatting:L,visibleActions:E,className:D,style:_})=>{var O,B;const N=e.useRef(null),j=e.useRef(null),b=e.useRef(null),[P,q]=e.useState(!1);e.useEffect(()=>{const g=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&q(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const F=g=>{var I;g.preventDefault();const w=g.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(w);break;case"insertImage":{(I=N.current)==null||I.click();break}default:console.warn("Unknown command:",w)}},Z=g=>{n("foreColor",g.target.value)},V=g=>{n("backColor",g.target.value)},[x,U]=e.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 e.useEffect(()=>{const g=()=>{U({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)},[]),e.createElement("div",{className:`rte-toolbar ${D||""}`,style:_},E.bold&&e.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:F,className:x.bold?"rte-active":""},e.createElement(qe,null)),E.italic&&e.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:F,className:x.italic?"rte-active":""},e.createElement(Ue,null)),E.underline&&e.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:F,className:x.underline?"rte-active":""},e.createElement(Ye,null)),E.unorderedList&&e.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:F,title:"UnorderedList",className:x.unorderedList?"rte-active":""},e.createElement(We,null)),E.orderedList&&e.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:F,className:x.orderedList?"rte-active":""},e.createElement(Ie,null)),E.link&&e.createElement("button",{"data-command":"createLink",title:"Link",onClick:z,className:x.link?"rte-active":""},e.createElement($e,null)),E.removeFormat&&e.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),s(),L()},className:x.removeFormat?"rte-active":""},e.createElement(Qe,null)),E.image&&e.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:F,className:x.image?"rte-active":""},e.createElement(Pe,null)),e.createElement("input",{type:"file",accept:"image/*",ref:N,style:{display:"none"},onChange:u}),E.emoji&&e.createElement("div",{style:{position:"relative"}},e.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),s(),q(w=>!w)},className:x.emoji?"rte-active":""},e.createElement(Ke,null)),P&&e.createElement("div",{className:"rte-emoji-popup"},Je.map(g=>e.createElement("span",{key:g,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:w=>{w.preventDefault(),y(g),q(!1)}},g)))),E.color&&e.createElement("div",{style:{position:"relative"}},e.createElement("button",{title:"Text Color",onMouseDown:g=>{var w;g.preventDefault(),s(),(w=j.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((O=j.current)==null?void 0:O.value)||"#000",fontSize:"18px"},className:x.color?"rte-active":""},e.createElement(Ze,null)),e.createElement("input",{ref:j,type:"color",defaultValue:"#000000",onChange:g=>{var w;Z(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&e.createElement("div",{style:{position:"relative"}},e.createElement("button",{title:"Highlight",onMouseDown:g=>{var w;g.preventDefault(),s(),(w=b.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((B=b.current)==null?void 0:B.value)||"#000",fontSize:"18px"},className:x.highlight?"rte-active":""},e.createElement(Ve,null)),e.createElement("input",{ref:b,type:"color",onChange:g=>{var w;V(g),((w=g.target.parentElement)==null?void 0:w.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&e.createElement(e.Fragment,null,e.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyLeft"),className:x.alignLeft?"rte-active":""},e.createElement(Be,null)),e.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyCenter"),className:x.alignCenter?"rte-active":""},e.createElement(_e,null)),e.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>n("justifyRight"),className:x.alignRight?"rte-active":""},e.createElement(Fe,null))),E.table&&e.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>n("insertTable"),className:x.table?"rte-active":""},e.createElement(Xe,null)),E.fontFamily&&e.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:v},e.createElement("option",{value:"",disabled:!0},"Font Family"),e.createElement("option",{value:"Arial"},"Arial"),e.createElement("option",{value:"Georgia"},"Georgia"),e.createElement("option",{value:"Times New Roman"},"Times New Roman"),e.createElement("option",{value:"Courier New"},"Courier New"),e.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&e.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:c},e.createElement("option",{value:"",disabled:!0},"Font Size"),e.createElement("option",{value:"2"},"Small "),e.createElement("option",{value:"3"},"Normal"),e.createElement("option",{value:"4"},"Medium"),e.createElement("option",{value:"5"},"Large")))},Ge=({show:n,position:s,filtered:u,insertMention:c,onClose:v,query:y})=>{const z=e.useRef(null);return e.useEffect(()=>{const L=E=>{z.current&&!z.current.contains(E.target)&&v()};return n&&document.addEventListener("mousedown",L),()=>{document.removeEventListener("mousedown",L)}},[n,v]),n?e.createElement("ul",{ref:z,className:"rte-popup",style:{top:s.y,left:s.x}},u.length>0?u.map(({key:L,value:E})=>{const D=L.toLowerCase(),_=y.toLowerCase(),N=D.indexOf(_);let j=L;if(N!==-1&&y.length>0){const b=N+y.length;j=L.substring(0,N)+`<span class="rte-highlight">${L.substring(N,b)}</span>`+L.substring(b)}return e.createElement("li",{key:E,onMouseDown:b=>{b.preventDefault(),c({key:L,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:j},onMouseEnter:b=>b.currentTarget.style.background="#f0f0f0",onMouseLeave:b=>b.currentTarget.style.background="#fff"})}):e.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function le(n){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(n)}function X(n){return M({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(n)}const Re=({visible:n,x:s,y:u,onAction:c,onClose:v})=>{if(!n)return null;const y={top:u,left:s};return e.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:v},e.createElement("button",{onClick:()=>c("insertRowAbove")},e.createElement(X,null)," Insert row above"),e.createElement("button",{onClick:()=>c("insertRowBelow")},e.createElement(X,null)," Insert row below"),e.createElement("button",{onClick:()=>c("insertColLeft")},e.createElement(X,null)," Insert col left"),e.createElement("button",{onClick:()=>c("insertColRight")},e.createElement(X,null)," Insert col right"),e.createElement("button",{onClick:()=>c("deleteRow")},e.createElement(le,null)," Delete row"),e.createElement("button",{onClick:()=>c("deleteCol")},e.createElement(le,null)," Delete column"))},ae=({html:n,className:s,style:u})=>{const c=v=>{const y=v.target;if(y.tagName==="A"){v.preventDefault();const z=y.href;z&&window.open(z,"_blank","noopener,noreferrer")}};return e.createElement("div",{className:`rte-preview ${s||""}`,style:u,onClick:c,dangerouslySetInnerHTML:{__html:n}})},et=({visible:n,linkData:s,onClose:u,onInsert:c})=>{const[v,y]=e.useState(""),[z,L]=e.useState(""),[E,D]=e.useState(""),[_,N]=e.useState("_self");if(e.useEffect(()=>{n?(y(s.url||""),L(s.text||""),D(s.title||""),N(s.target||"_self")):(y(""),L(""),D(""),N("_self"))},[n,s]),!n)return null;const j=()=>{c({url:v,text:z,title:E,target:_})};return e.createElement(e.Fragment,null,e.createElement("div",{className:"rte-link-modal-overlay",onClick:u}),e.createElement("div",{className:"rte-link-modal"},e.createElement("h4",{className:"rte-link-modal__title"},v?"Edit Link":"Insert Link"),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:v,onChange:b=>y(b.target.value)}),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:z,onChange:b=>L(b.target.value)}),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:b=>D(b.target.value)}),e.createElement("select",{className:"rte-link-modal__select",value:_,onChange:b=>N(b.target.value)},e.createElement("option",{value:"_self"},"Same tab"),e.createElement("option",{value:"_blank"},"New tab")),e.createElement("div",{className:"rte-link-modal__actions"},e.createElement("button",{className:"rte-link-modal__btn",onClick:u},"Cancel"),e.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:j},"OK"))))},tt=({atSuggestions:n=[],showOutput:s=!1,showPreview:u=!1,toolbarConfig:c={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:v={},styles:y={},handleGetHtml:z=()=>{},onChange:L=()=>{},value:E,onMentionSelect:D=()=>{}})=>{var ve,Ee,we,ye,Ce,be,xe,Le;const _=e.useRef(null),[N,j]=e.useState(E!=null&&E.length?E:" "),[b,P]=e.useState(!1),[q,F]=e.useState({x:0,y:0}),[Z,V]=e.useState([]),x=e.useRef(null),U=e.useRef(null),[O,B]=e.useState({visible:!1,x:0,y:0}),[g,w]=e.useState(!1),I=e.useRef(null),[nt,ie]=e.useState({url:"",text:"",title:"",target:"_self"}),rt={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ve=c.link)!=null?ve:!1,image:(Ee=c.image)!=null?Ee:!1,emoji:(we=c.emoji)!=null?we:!1,table:(ye=c.table)!=null?ye:!1,color:(Ce=c.color)!=null?Ce:!1,fontFamily:(be=c.fontFamily)!=null?be:!1,fontSize:(xe=c.fontSize)!=null?xe:!1,highlight:(Le=c.fontSize)!=null?Le:!1},[ot,se]=e.useState(""),[ce,ue]=e.useState([]),H=()=>_.current,k=()=>{const t=pe();j(t),z==null||z(t);const r=Mt(t);L(r);const o=dt();JSON.stringify(o)!==JSON.stringify(ce)&&(ue(o),D(o))},de=()=>{const t=window.getSelection();t!=null&&t.rangeCount&&(x.current=t.getRangeAt(0))},$=()=>{const t=window.getSelection();t&&x.current&&(t.removeAllRanges(),t.addRange(x.current))},lt=(t,r)=>{const o=window.getSelection();o&&o.rangeCount>0&&(x.current=o.getRangeAt(0)),$(),document.execCommand(t,!1,r),k()};e.useEffect(()=>{const t=H();t&&!t.innerHTML&&(t.innerHTML=N),k()},[]),e.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]);const me=t=>{for(;t&&t.nodeName!=="LI";)t=t.parentNode;return t},at=t=>{let r=0,o=t.parentElement;for(;o;)(o.tagName==="UL"||o.tagName==="OL")&&r++,o=o.parentElement;return r},it=t=>{const r=t.querySelector("li"),o=r?at(r):1;if(t.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${o>1?o:""}}}`,d=`{{/arrayData${o>1?o:""}}}`,a=document.createElement("span");a.textContent=l,a.style.display="none",a.setAttribute("data-hidden-array-start","true"),t.insertBefore(a,t.firstChild);const i=document.createElement("span");i.textContent=d,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),t.appendChild(i)},fe=t=>{var h;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),l=me(o.startContainer);let d,a;if(l){let m=l.querySelector(t);m||(m=document.createElement(t),m.style.margin="0",m.style.paddingLeft="20px",l.appendChild(m)),a=m,d=document.createElement("li"),d.textContent="â",a.appendChild(d)}else{document.execCommand(t==="ul"?"insertUnorderedList":"insertOrderedList");const m=H();if(a=m==null?void 0:m.querySelector(`${t}:last-child`),!a)return;d=a.querySelector("li:last-child")}it(a);const i=document.createRange();i.setStart(d,0),i.collapse(!0),r.removeAllRanges(),r.addRange(i),(h=H())==null||h.focus(),k()},Y=(t,r)=>{t==="insertOrderedList"?fe("ol"):t==="insertUnorderedList"?fe("ul"):lt(t,r),t==="insertTable"&&pt()},st=t=>{const r=document.createElement("span");r.textContent="â",t.insertNode(r),t.setStartAfter(r),t.collapse(!0);const o=r.getBoundingClientRect();r.remove(),F({x:o.left,y:o.bottom+window.scrollY}),V(n||[]),P(!0),U.current=t.cloneRange()},ct=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.anchorNode;let o=t.anchorOffset;if(!r)return null;let l=r;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[o]?l=l.childNodes[o]:l=r.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const d=l.textContent||"",a=l===r?o:d.length,i=d.lastIndexOf("@",a-1);if(i!==-1){const h=document.createRange();return h.setStart(l,i),h.setEnd(l,a),h}}l=l.previousSibling}return null},ut=t=>{var a;const r=window.getSelection();if(!r)return;const o=ct();o?(r.removeAllRanges(),r.addRange(o)):U.current&&(r.removeAllRanges(),r.addRange(U.current));const l=document.createElement("span");l.textContent=`{{${t.key}}}`,l.style.color="#007bff",l.style.display="inline",l.contentEditable="false",l.setAttribute("data-mention",t.value||t.key||"");try{const i=r.rangeCount?r.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const p=document.createRange(),f=H();p.selectNodeContents(f),p.collapse(!1),p.insertNode(l)}const h=document.createTextNode(" ");l.after(h);const m=document.createRange();m.setStartAfter(h),m.collapse(!0),r.removeAllRanges(),r.addRange(m)}catch(i){console.error("insertMention error:",i)}let d=[...ce,t];ue(d),D(d),P(!1),(a=H())==null||a.focus(),k()},dt=()=>{const t=H();if(!t)return[];const r=t.querySelectorAll("span[data-mention]"),o=[];return r.forEach(l=>{const d=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&o.push({key:i[1],value:d})}),o},mt=t=>{var o,l,d;const r=t.key.toLowerCase();if((t.ctrlKey||t.metaKey)&&["b","i","u"].includes(r)&&(t.preventDefault(),Y(r==="b"?"bold":r==="i"?"italic":r==="u"?"underline":"")),t.shiftKey&&t.key==="2"&&t.preventDefault(),t.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?me(a.anchorNode):null;if(!i)return;if(((o=i.textContent)==null?void 0:o.replace(/\u200B/g,"").trim())===""){t.preventDefault();const m=i.parentElement,p=m==null?void 0:m.closest("li");if(p){m==null||m.removeChild(i);const f=document.createElement("p");f.innerHTML="<br />",(l=p.parentElement)==null||l.insertBefore(f,p.nextSibling);const C=document.createRange();C.setStart(f,0),C.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(C)}else{const f=i.closest("ul, ol");if(f){const C=document.createElement("p");C.innerHTML="<br />",(d=f.parentElement)==null||d.insertBefore(C,f.nextSibling),f.removeChild(i);const A=document.createRange();A.setStart(C,0),A.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(A)}}k()}}},ft=t=>{if(t.data==="@"){const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;setTimeout(()=>{st(o.getRangeAt(0)),se(""),V(n),P(!0)},0);return}if(b){setTimeout(()=>ge(),0);return}},ge=()=>{if(k(),!b)return;const t=window.getSelection();if(!t||!t.anchorNode)return;const o=(t.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!o){P(!1);return}const l=o[1].toLowerCase();se(l);const d=n.filter(a=>a.key.toLowerCase().includes(l));V(d)},gt=t=>{var l;const r=(l=t.target.files)==null?void 0:l[0];if(!r)return;const o=new FileReader;o.onload=d=>{var A;const a=(A=d.target)==null?void 0:A.result;$();const i=window.getSelection();let h=i&&i.rangeCount?i.getRangeAt(0):null;const m=document.createElement("img");m.src=a,m.alt=r.name||"image",m.className="rte-inserted-image",m.contentEditable="true";const p=H();if(!h||!p){p==null||p.appendChild(m);const Se=document.createTextNode(" ");p==null||p.appendChild(Se);const J=document.createRange();J.setStartAfter(Se),J.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(J),p==null||p.focus(),k(),t.target.value="";return}h.deleteContents(),h.insertNode(m);const f=document.createTextNode(" ");m.after(f);const C=document.createRange();C.setStartAfter(f),C.collapse(!0),i.removeAllRanges(),i.addRange(C),p.focus(),k(),t.target.value=""},o.readAsDataURL(r)},ht=t=>{var d;$();const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),l=document.createTextNode(t);o.insertNode(l),o.setStartAfter(l),o.collapse(!0),r.removeAllRanges(),r.addRange(o),(d=H())==null||d.focus(),k()},pt=()=>{$();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";const r=document.createElement("thead"),o=document.createElement("tbody"),l=document.createElement("tr"),d=document.createElement("tr");for(let h=0;h<2;h++){const m=document.createElement("th");m.textContent=`Header ${h+1}`,m.style.border="1px solid #999",m.style.padding="8px",m.style.position="relative",m.style.backgroundColor="lightgray";const p=document.createElement("td");p.textContent=`Row 1 Col ${h+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",Q(m),Q(p),l.appendChild(m),d.appendChild(p)}r.appendChild(l),o.appendChild(d),t.appendChild(r),t.appendChild(o),Ct(t),vt(t);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(t),k()},vt=t=>{const r=document.createElement("div");Object.assign(r.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let o=0,l=0,d=0,a=0;r.addEventListener("mousedown",i=>{i.preventDefault(),o=i.clientX,l=i.clientY;const h=t.getBoundingClientRect();d=h.width,a=h.height;const m=f=>{const C=Math.max(100,d+(f.clientX-o)),A=Math.max(60,a+(f.clientY-l));t.style.width=`${C}px`,t.style.height=`${A}px`,k()},p=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p),k()};document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)}),t.appendChild(r)},Q=t=>{const r=document.createElement("div"),o=document.createElement("div");Object.assign(r.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(o.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Et(t,r,o),t.appendChild(r),t.appendChild(o)},Et=(t,r,o)=>{let l=0,d=0,a=0,i=0;r.addEventListener("mousedown",f=>{f.preventDefault(),l=f.clientX,a=t.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)}),o.addEventListener("mousedown",f=>{f.preventDefault(),d=f.clientY,i=t.offsetHeight,document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)});const h=f=>{const C=a+(f.clientX-l);t.style.width=`${Math.max(30,C)}px`},m=f=>{const C=i+(f.clientY-d);t.style.height=`${Math.max(20,C)}px`},p=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)}},wt=t=>{const o=t.target.closest("td, th");o&&(t.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),o.classList.add("rte-cell-highlight"),B({visible:!0,x:t.clientX,y:t.clientY,cell:o}))},he=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(t=>t.classList.remove("rte-cell-highlight"))},yt=t=>{if(!O.cell)return;const r=O.cell.closest("table"),o=O.cell.cellIndex,l=O.cell.parentElement.rowIndex,d=a=>{const i=a.tagName.toLowerCase(),h=document.createElement(i);return h.textContent=a.textContent||"",h.style.cssText=a.style.cssText,Q(h),h};switch(t){case"insertRowAbove":{const a=r.rows[l],i=r.insertRow(l);Array.from(a.cells).forEach(h=>{i.appendChild(d(h))});break}case"insertRowBelow":{const a=r.rows[l],i=r.insertRow(l+1);Array.from(a.cells).forEach(h=>{i.appendChild(d(h))});break}case"insertColLeft":{Array.from(r.rows).forEach(a=>{const i=a.cells[o];a.insertBefore(d(i),i)});break}case"insertColRight":{Array.from(r.rows).forEach(a=>{const i=a.cells[o];a.insertBefore(d(i),i.nextSibling)});break}case"deleteRow":r.rows.length>1&&r.deleteRow(l);break;case"deleteCol":Array.from(r.rows).forEach(a=>{a.cells[o]&&a.deleteCell(o)});break}k(),B(R(G({},O),{visible:!1})),he()},Ct=t=>{const r=t.querySelector("tbody");if(!r||r.querySelector("[data-hidden-table-start]"))return;const o=document.createElement("span");o.textContent="{{#arrayData}}",o.style.display="none",o.setAttribute("data-hidden-table-start","true"),r.insertBefore(o,r.firstChild);const l=document.createElement("span");l.textContent="{{/arrayData}}",l.style.display="none",l.setAttribute("data-hidden-table-end","true"),r.appendChild(l)},pe=()=>{const t=H();if(!t)return N;const r=t.cloneNode(!0);return r.querySelectorAll("table div").forEach(o=>o.remove()),r.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),r.innerHTML},bt=()=>{de(),I.current=x.current,ie({url:"",text:"",title:"",target:"_self"}),w(!0)},xt=t=>{const r=window.getSelection();if(!r||!I.current)return;r.removeAllRanges(),r.addRange(I.current);let o=t.url.trim();/^https?:\/\//i.test(o)||(o="https://"+o);const l=document.createElement("a");l.href=o,l.style.cursor="pointer",l.style.outline="none",l.textContent=t.text||o,l.title=t.title,l.target=t.target,l.contentEditable="true";const d=r.getRangeAt(0);d.deleteContents(),d.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),r.removeAllRanges(),r.addRange(i),w(!1),k()},Lt=t=>{const r=t.target;if(r.tagName==="A"){const o=r;if(t.ctrlKey||t.metaKey){window.open(o.href,"_blank","noopener,noreferrer");return}t.preventDefault();const l=document.createRange();l.selectNode(o),I.current=l,ie({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),w(!0)}},St=()=>{const t=H();if(!t)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&x.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(x.current)}const o=window.getSelection();if(!o||o.rangeCount===0)return;const l=o.getRangeAt(0);$(),document.execCommand("removeFormat",!1);const d=l.cloneContents(),a=document.createElement("div");a.appendChild(d);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),h=[];for(;i.nextNode();){const f=i.currentNode,C=f.tagName.toUpperCase(),A=f.getAttribute&&f.getAttribute("data-mention")!==null;C!=="A"&&!A&&h.push(f)}for(let f=h.length-1;f>=0;f--){const C=h[f],A=C.parentNode;if(A){for(;C.firstChild;)A.insertBefore(C.firstChild,C);A.removeChild(C)}}a.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),l.deleteContents();const m=document.createDocumentFragment();for(;a.firstChild;)m.appendChild(a.firstChild);l.insertNode(m);const p=document.createRange();p.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),p.collapse(!0),o.removeAllRanges(),o.addRange(p),t.normalize(),k()},Mt=t=>{var l;let r=t;r=r.replace(/{{#arrayData\d*}}/g,""),r=r.replace(/{{\/arrayData\d*}}/g,"");const o=document.createElement("div");return o.innerHTML=r,o.querySelectorAll("br").forEach(d=>{d.replaceWith(`
|
|
2
|
-
`)}),o.querySelectorAll("p, div, tr").forEach(
|
|
3
|
-
`)}),o.querySelectorAll("table").forEach(
|
|
1
|
+
(function(L,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],t):(L=typeof globalThis!="undefined"?globalThis:L||self,t(L.RichTextEditor={},L.React,L.ReactDOM))})(this,(function(L,t,T){"use strict";var Dt=Object.defineProperty,jt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var Ae=Object.getOwnPropertySymbols;var _t=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var Ne=(L,t,T)=>t in L?Dt(L,t,{enumerable:!0,configurable:!0,writable:!0,value:T}):L[t]=T,ne=(L,t)=>{for(var T in t||(t={}))_t.call(t,T)&&Ne(L,T,t[T]);if(Ae)for(var T of Ae(t))Ft.call(t,T)&&Ne(L,T,t[T]);return L},re=(L,t)=>jt(L,Ht(t));function Te(r){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const d in r)if(d!=="default"){const c=Object.getOwnPropertyDescriptor(r,d);Object.defineProperty(s,d,c.get?c:{enumerable:!0,get:()=>r[d]})}}return s.default=r,Object.freeze(s)}const Oe=Te(t);window.React=Oe;var oe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},le=t.createContext&&t.createContext(oe),De=["attr","size","title"];function je(r,s){if(r==null)return{};var d=He(r,s),c,m;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(r);for(m=0;m<w.length;m++)c=w[m],!(s.indexOf(c)>=0)&&Object.prototype.propertyIsEnumerable.call(r,c)&&(d[c]=r[c])}return d}function He(r,s){if(r==null)return{};var d={};for(var c in r)if(Object.prototype.hasOwnProperty.call(r,c)){if(s.indexOf(c)>=0)continue;d[c]=r[c]}return d}function W(){return W=Object.assign?Object.assign.bind():function(r){for(var s=1;s<arguments.length;s++){var d=arguments[s];for(var c in d)Object.prototype.hasOwnProperty.call(d,c)&&(r[c]=d[c])}return r},W.apply(this,arguments)}function ae(r,s){var d=Object.keys(r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);s&&(c=c.filter(function(m){return Object.getOwnPropertyDescriptor(r,m).enumerable})),d.push.apply(d,c)}return d}function K(r){for(var s=1;s<arguments.length;s++){var d=arguments[s]!=null?arguments[s]:{};s%2?ae(Object(d),!0).forEach(function(c){_e(r,c,d[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(d)):ae(Object(d)).forEach(function(c){Object.defineProperty(r,c,Object.getOwnPropertyDescriptor(d,c))})}return r}function _e(r,s,d){return s=Fe(s),s in r?Object.defineProperty(r,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):r[s]=d,r}function Fe(r){var s=Pe(r,"string");return typeof s=="symbol"?s:s+""}function Pe(r,s){if(typeof r!="object"||!r)return r;var d=r[Symbol.toPrimitive];if(d!==void 0){var c=d.call(r,s);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(r)}function ie(r){return r&&r.map((s,d)=>t.createElement(s.tag,K({key:d},s.attr),ie(s.child)))}function z(r){return s=>t.createElement(Ie,W({attr:K({},r.attr)},s),ie(r.child))}function Ie(r){var s=d=>{var{attr:c,size:m,title:w}=r,M=je(r,De),C=m||d.size||"1em",E;return d.className&&(E=d.className),r.className&&(E=(E?E+" ":"")+r.className),t.createElement("svg",W({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},d.attr,c,M,{className:E,style:K(K({color:r.color||d.color},d.style),r.style),height:C,width:C,xmlns:"http://www.w3.org/2000/svg"}),w&&t.createElement("title",null,w),r.children)};return le!==void 0?t.createElement(le.Consumer,null,d=>s(d)):s(oe)}function qe(r){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},child:[]}]})(r)}function Be(r){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},child:[]}]})(r)}function Ve(r){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM323.8 202.5c-4.5-6.6-11.9-10.5-19.8-10.5s-15.4 3.9-19.8 10.5l-87 127.6L170.7 297c-4.6-5.7-11.5-9-18.7-9s-14.2 3.3-18.7 9l-64 80c-5.8 7.2-6.9 17.1-2.9 25.4s12.4 13.6 21.6 13.6l96 0 32 0 208 0c8.9 0 17.1-4.9 21.2-12.8s3.6-17.4-1.4-24.7l-120-176zM112 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"},child:[]}]})(r)}function $e(r){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"},child:[]}]})(r)}function Ue(r){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12.83 352h262.34A12.82 12.82 0 0 0 288 339.17v-38.34A12.82 12.82 0 0 0 275.17 288H12.83A12.82 12.82 0 0 0 0 300.83v38.34A12.82 12.82 0 0 0 12.83 352zm0-256h262.34A12.82 12.82 0 0 0 288 83.17V44.83A12.82 12.82 0 0 0 275.17 32H12.83A12.82 12.82 0 0 0 0 44.83v38.34A12.82 12.82 0 0 0 12.83 96zM432 160H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0 256H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(r)}function We(r){return z({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M333.49 238a122 122 0 0 0 27-65.21C367.87 96.49 308 32 233.42 32H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h31.87v288H34a16 16 0 0 0-16 16v48a16 16 0 0 0 16 16h209.32c70.8 0 134.14-51.75 141-122.4 4.74-48.45-16.39-92.06-50.83-119.6zM145.66 112h87.76a48 48 0 0 1 0 96h-87.76zm87.76 288h-87.76V288h87.76a56 56 0 0 1 0 112z"},child:[]}]})(r)}function Ke(r){return z({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M0 479.98L99.92 512l35.45-35.45-67.04-67.04L0 479.98zm124.61-240.01a36.592 36.592 0 0 0-10.79 38.1l13.05 42.83-50.93 50.94 96.23 96.23 50.86-50.86 42.74 13.08c13.73 4.2 28.65-.01 38.15-10.78l35.55-41.64-173.34-173.34-41.52 35.44zm403.31-160.7l-63.2-63.2c-20.49-20.49-53.38-21.52-75.12-2.35L190.55 183.68l169.77 169.78L530.27 154.4c19.18-21.74 18.15-54.63-2.35-75.13z"},child:[]}]})(r)}function Xe(r){return z({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M320 48v32a16 16 0 0 1-16 16h-62.76l-80 320H208a16 16 0 0 1 16 16v32a16 16 0 0 1-16 16H16a16 16 0 0 1-16-16v-32a16 16 0 0 1 16-16h62.76l80-320H112a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h192a16 16 0 0 1 16 16z"},child:[]}]})(r)}function Ye(r){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(r)}function Ze(r){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M80 368H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm0-320H16A16 16 0 0 0 0 64v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16zm0 160H16a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h64a16 16 0 0 0 16-16v-64a16 16 0 0 0-16-16zm416 176H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(r)}function Re(r){return z({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(r)}function Qe(r){return z({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z"},child:[]}]})(r)}function Je(r){return z({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 64h32v160c0 88.22 71.78 160 160 160s160-71.78 160-160V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H272a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h32v160a80 80 0 0 1-160 0V64h32a16 16 0 0 0 16-16V16a16 16 0 0 0-16-16H32a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16zm400 384H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(r)}function Ge(r){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M2 20h20v4H2v-4zm3.49-3h2.42l1.27-3.58h5.65L16.09 17h2.42L13.25 3h-2.5L5.49 17zm4.42-5.61 2.03-5.79h.12l2.03 5.79H9.91z"},child:[]}]})(r)}function et(r){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V5H6.39l3 3h1.83l-.55 1.28 2.09 2.1L14.21 8zM3.41 4.86 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21l1.41-1.41z"},child:[]}]})(r)}const tt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],se=({exec:r,saveSelection:s,handleFileChange:d,handleFontSizeChange:c,handleFontFamilyChange:m,insertEmoji:w,handleLink:M,removeFormatting:C,visibleActions:E,className:D,style:_})=>{var B,Z;const A=t.useRef(null),O=t.useRef(null),x=t.useRef(null),[$,F]=t.useState(!1),[Y,Q]=t.useState({x:0,y:0});t.useEffect(()=>{const g=y=>{!y.target.closest(".rte-emoji-popup")&&!y.target.closest("button[title='Emoji']")&&F(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]);const I=g=>{var q;g.preventDefault();const y=g.currentTarget.dataset.command;if(y)switch(y){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":r(y);break;case"insertImage":{(q=A.current)==null||q.click();break}default:console.warn("Unknown command:",y)}},U=g=>{r("foreColor",g.target.value)},P=g=>{r("backColor",g.target.value)},[S,j]=t.useState({bold:!1,italic:!1,underline:!1,unorderedList:!1,orderedList:!1,alignLeft:!1,alignCenter:!1,alignRight:!1,removeFormat:!1,link:!1,image:!1,emoji:!1,table:!1,color:!1,highlight:!1});return t.useEffect(()=>{const g=()=>{j({bold:document.queryCommandState("bold"),italic:document.queryCommandState("italic"),underline:document.queryCommandState("underline"),unorderedList:document.queryCommandState("insertUnorderedList"),orderedList:document.queryCommandState("insertOrderedList"),alignLeft:document.queryCommandState("justifyLeft"),alignCenter:document.queryCommandState("justifyCenter"),alignRight:document.queryCommandState("justifyRight"),removeFormat:document.queryCommandState("removeFormat"),link:document.queryCommandState("createLink"),image:document.queryCommandState("insertImage"),emoji:document.queryCommandState("insertEmoji"),table:document.queryCommandState("insertTable"),color:document.queryCommandState("foreColor"),highlight:document.queryCommandState("backColor")})};return document.addEventListener("selectionchange",g),()=>document.removeEventListener("selectionchange",g)},[]),t.createElement("div",{className:`rte-toolbar ${D||""}`,style:_},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:I,className:S.bold?"rte-active":""},t.createElement(We,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:I,className:S.italic?"rte-active":""},t.createElement(Xe,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:I,className:S.underline?"rte-active":""},t.createElement(Je,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:I,title:"UnorderedList",className:S.unorderedList?"rte-active":""},t.createElement(Ze,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:I,className:S.orderedList?"rte-active":""},t.createElement($e,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:M,className:S.link?"rte-active":""},t.createElement(Ye,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:g=>{g.preventDefault(),s(),C()},className:S.removeFormat?"rte-active":""},t.createElement(et,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:I,className:S.image?"rte-active":""},t.createElement(Ve,null)),t.createElement("input",{type:"file",accept:"image/*",ref:A,style:{display:"none"},onChange:d}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:g=>{g.preventDefault(),s();const y=g.currentTarget.getBoundingClientRect();Q({x:y.left,y:y.bottom+8}),F(q=>!q)},className:S.emoji?"rte-active":""},t.createElement(Re,null)),$&&T.createPortal(t.createElement("div",{className:"rte-emoji-popup",style:{top:Y.y,left:Y.x}},tt.map((g,y)=>t.createElement("span",{key:y,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:q=>{q.preventDefault(),w(g),F(!1)}},g))),document.body)),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:g=>{var y;g.preventDefault(),s(),(y=O.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((B=O.current)==null?void 0:B.value)||"#000",fontSize:"18px"},className:S.color?"rte-active":""},t.createElement(Ge,null)),t.createElement("input",{ref:O,type:"color",defaultValue:"#000000",onChange:g=>{var y;U(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:g=>{var y;g.preventDefault(),s(),(y=x.current)==null||y.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((Z=x.current)==null?void 0:Z.value)||"#000",fontSize:"18px"},className:S.highlight?"rte-active":""},t.createElement(Ke,null)),t.createElement("input",{ref:x,type:"color",onChange:g=>{var y;P(g),((y=g.target.parentElement)==null?void 0:y.querySelector("button")).style.color=g.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),E.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:g=>g.preventDefault(),onClick:()=>r("justifyLeft"),className:S.alignLeft?"rte-active":""},t.createElement(Ue,null)),t.createElement("button",{title:"Align Center",onMouseDown:g=>g.preventDefault(),onClick:()=>r("justifyCenter"),className:S.alignCenter?"rte-active":""},t.createElement(qe,null)),t.createElement("button",{title:"Align Right",onMouseDown:g=>g.preventDefault(),onClick:()=>r("justifyRight"),className:S.alignRight?"rte-active":""},t.createElement(Be,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:g=>g.preventDefault(),onClick:()=>r("insertTable"),className:S.table?"rte-active":""},t.createElement(Qe,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:m},t.createElement("option",{value:"",disabled:!0},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Times New Roman"},"Times New Roman"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Verdana"},"Verdana")),E.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>s(),onChange:c},t.createElement("option",{value:"",disabled:!0},"Font Size"),t.createElement("option",{value:"2"},"Small "),t.createElement("option",{value:"3"},"Normal"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large")))},nt=({show:r,position:s,filtered:d,insertMention:c,onClose:m,query:w})=>{const M=t.useRef(null);return t.useEffect(()=>{const C=E=>{M.current&&!M.current.contains(E.target)&&m()};return r&&document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},[r,m]),r?t.createElement("ul",{ref:M,className:"rte-popup",style:{top:s.y,left:s.x}},d.length>0?d.map(({name:C,value:E})=>{const D=C.toLowerCase(),_=w.toLowerCase(),A=D.indexOf(_);let O=C;if(A!==-1&&w.length>0){const x=A+w.length;O=C.substring(0,A)+`<span class="rte-highlight">${C.substring(A,x)}</span>`+C.substring(x)}return t.createElement("li",{key:E,onMouseDown:x=>{x.preventDefault(),c({name:C,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:O},onMouseEnter:x=>x.currentTarget.style.background="#f0f0f0",onMouseLeave:x=>x.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ce(r){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Minus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,11.5h0a.5.5,0,0,1,0,1H9a.5.5,0,0,1,0-1Z"},child:[]},{tag:"path",attr:{d:"M12,21.934A9.933,9.933,0,1,1,21.932,12,9.945,9.945,0,0,1,12,21.934ZM12,3.068A8.933,8.933,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.068Z"},child:[]}]}]}]})(r)}function X(r){return z({attr:{viewBox:"0 0 24 24"},child:[{tag:"g",attr:{id:"Circle_Plus"},child:[{tag:"g",attr:{},child:[{tag:"path",attr:{d:"M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z"},child:[]},{tag:"path",attr:{d:"M12,21.932A9.934,9.934,0,1,1,21.932,12,9.944,9.944,0,0,1,12,21.932ZM12,3.065A8.934,8.934,0,1,0,20.932,12,8.944,8.944,0,0,0,12,3.065Z"},child:[]}]}]}]})(r)}const rt=({visible:r,x:s,y:d,onAction:c,onClose:m})=>{if(!r)return null;const w={top:d,left:s};return t.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:m},t.createElement("button",{onClick:()=>c("insertRowAbove")},t.createElement(X,null)," Insert row above"),t.createElement("button",{onClick:()=>c("insertRowBelow")},t.createElement(X,null)," Insert row below"),t.createElement("button",{onClick:()=>c("insertColLeft")},t.createElement(X,null)," Insert col left"),t.createElement("button",{onClick:()=>c("insertColRight")},t.createElement(X,null)," Insert col right"),t.createElement("button",{onClick:()=>c("deleteRow")},t.createElement(ce,null)," Delete row"),t.createElement("button",{onClick:()=>c("deleteCol")},t.createElement(ce,null)," Delete column"))},de=({html:r,className:s,style:d})=>{const c=w=>{const M=w.target;if(M.tagName==="A"){w.preventDefault();const C=M.href;C&&window.open(C,"_blank","noopener,noreferrer")}},m=w=>w.replace(/{{\s*(.*?)\s*}}/g,"$1");return t.createElement("div",{className:`rte-preview ${s||""}`,style:d,onClick:c,dangerouslySetInnerHTML:{__html:m(r)}})},ot=({visible:r,linkData:s,onClose:d,onInsert:c})=>{const[m,w]=t.useState(""),[M,C]=t.useState(""),[E,D]=t.useState(""),[_,A]=t.useState("_self");if(t.useEffect(()=>{r?(w(s.url||""),C(s.text||""),D(s.title||""),A(s.target||"_self")):(w(""),C(""),D(""),A("_self"))},[r,s]),!r)return null;const O=()=>{c({url:m,text:M,title:E,target:_})};return t.createElement(t.Fragment,null,t.createElement("div",{className:"rte-link-modal-overlay",onClick:d}),t.createElement("div",{className:"rte-link-modal"},t.createElement("h4",{className:"rte-link-modal__title"},m?"Edit Link":"Insert Link"),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"URL",value:m,onChange:x=>w(x.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:M,onChange:x=>C(x.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:x=>D(x.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:_,onChange:x=>A(x.target.value)},t.createElement("option",{value:"_self"},"Same tab"),t.createElement("option",{value:"_blank"},"New tab")),t.createElement("div",{className:"rte-link-modal__actions"},t.createElement("button",{className:"rte-link-modal__btn",onClick:d},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:O},"OK"))))};function ue(r){return Array.from(new Map(r.map(s=>[s.value,s])).values())}const lt=({atSuggestions:r=[],showOutput:s=!1,showPreview:d=!1,toolbarConfig:c={link:!1,image:!1,emoji:!1,table:!1,color:!1,fontFamily:!1,fontSize:!1,highlight:!1},classNames:m={},styles:w={},handleGetHtml:M=()=>{},onChange:C=()=>{},value:E,onMentionSelect:D=()=>{},handleAddAttributes:_=()=>{}})=>{var we,be,Ce,xe,Le,Se,Me,ze;const A=t.useRef(null),[O,x]=t.useState(E!=null&&E.length?E:" "),[$,F]=t.useState(!1),[Y,Q]=t.useState({x:0,y:0}),[I,U]=t.useState([]),P=t.useRef(null),S=t.useRef(null),[j,B]=t.useState({visible:!1,x:0,y:0}),[Z,g]=t.useState(!1),y=t.useRef(null),[q,me]=t.useState({url:"",text:"",title:"",target:"_self"}),at={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(we=c.link)!=null?we:!1,image:(be=c.image)!=null?be:!1,emoji:(Ce=c.emoji)!=null?Ce:!1,table:(xe=c.table)!=null?xe:!1,color:(Le=c.color)!=null?Le:!1,fontFamily:(Se=c.fontFamily)!=null?Se:!1,fontSize:(Me=c.fontSize)!=null?Me:!1,highlight:(ze=c.fontSize)!=null?ze:!1},[it,fe]=t.useState(""),[J,G]=t.useState([]),H=()=>A.current,k=()=>{const e=ye();x(e),M==null||M(e);const n=Ot(e);C(n);const o=pt(),l=ue(o);JSON.stringify(l)!==JSON.stringify(J)&&(G(l),D(l))},ge=()=>{const e=window.getSelection();e!=null&&e.rangeCount&&(P.current=e.getRangeAt(0))},V=()=>{const e=window.getSelection();e&&P.current&&(e.removeAllRanges(),e.addRange(P.current))},st=(e,n)=>{const o=window.getSelection();o&&o.rangeCount>0&&(P.current=o.getRangeAt(0)),V(),document.execCommand(e,!1,n),k()};t.useEffect(()=>{const e=H();e&&!e.innerHTML&&(e.innerHTML=O),k()},[]),t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]),t.useEffect(()=>{_&&_(e=>{ht(e)})},[]);const he=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},ct=e=>{let n=0,o=e.parentElement;for(;o;)(o.tagName==="UL"||o.tagName==="OL")&&n++,o=o.parentElement;return n},dt=e=>{const n=e.querySelector("li"),o=n?ct(n):1;if(e.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${o>1?o:""}}}`,u=`{{/arrayData${o>1?o:""}}}`,a=document.createElement("span");a.textContent=l,a.style.display="none",a.setAttribute("data-hidden-array-start","true"),e.insertBefore(a,e.firstChild);const i=document.createElement("span");i.textContent=u,i.style.display="none",i.setAttribute("data-hidden-array-end","true"),e.appendChild(i)},pe=e=>{var v;const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.getRangeAt(0),l=he(o.startContainer);let u,a;if(l){let f=l.querySelector(e);f||(f=document.createElement(e),f.style.margin="0",f.style.paddingLeft="20px",l.appendChild(f)),a=f,u=document.createElement("li"),u.textContent="â",a.appendChild(u)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const f=H();if(a=f==null?void 0:f.querySelector(`${e}:last-child`),!a)return;u=a.querySelector("li:last-child")}dt(a);const i=document.createRange();i.setStart(u,0),i.collapse(!0),n.removeAllRanges(),n.addRange(i),(v=H())==null||v.focus(),k()},R=(e,n)=>{e==="insertOrderedList"?pe("ol"):e==="insertUnorderedList"?pe("ul"):st(e,n),e==="insertTable"&&Ct()},ut=e=>{const n=document.createElement("span");n.textContent="â",e.insertNode(n),e.setStartAfter(n),e.collapse(!0);const o=n.getBoundingClientRect();n.remove(),Q({x:o.left,y:o.bottom+window.scrollY}),U(r||[]),F(!0),S.current=e.cloneRange()},mt=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.anchorNode;let o=e.anchorOffset;if(!n)return null;let l=n;for(l.nodeType!==Node.TEXT_NODE&&(l.childNodes&&l.childNodes[o]?l=l.childNodes[o]:l=n.previousSibling);l;){if(l.nodeType===Node.TEXT_NODE){const u=l.textContent||"",a=l===n?o:u.length,i=u.lastIndexOf("@",a-1);if(i!==-1){const v=document.createRange();return v.setStart(l,i),v.setEnd(l,a),v}}l=l.previousSibling}return null},ft=e=>{var a;const n=window.getSelection();if(!n)return;const o=mt();o?(n.removeAllRanges(),n.addRange(o)):S.current&&(n.removeAllRanges(),n.addRange(S.current));const l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.color="#007bff",l.style.display="inline",l.contentEditable="false",l.setAttribute("data-mention",e.value||e.name||"");try{const i=n.rangeCount?n.getRangeAt(0):null;if(i)i.deleteContents(),i.insertNode(l);else{const p=document.createRange(),h=H();p.selectNodeContents(h),p.collapse(!1),p.insertNode(l)}const v=document.createTextNode(" ");l.after(v);const f=document.createRange();f.setStartAfter(v),f.collapse(!0),n.removeAllRanges(),n.addRange(f)}catch(i){console.error("insertMention error:",i)}let u=ue([...J,e]);G(u),D(u),F(!1),(a=H())==null||a.focus(),k()},gt=e=>{var i;V();const n=window.getSelection();if(!n||!n.rangeCount)return;const o=n.getRangeAt(0),l=document.createElement("span");l.textContent=`{{${e.name}}}`,l.style.color="#007bff",l.style.display="inline",l.contentEditable="false",l.setAttribute("data-mention",e.value||e.name),o.insertNode(l);const u=document.createTextNode(" ");l.after(u);const a=document.createRange();a.setStartAfter(u),a.collapse(!0),n.removeAllRanges(),n.addRange(a),(i=H())==null||i.focus()},ht=e=>{e.forEach(l=>gt(l));const n=[...J,...e],o=Array.from(new Map(n.map(l=>[l.name,l])).values());G(o),D(o),k()},pt=()=>{const e=H();if(!e)return[];const n=e.querySelectorAll("span[data-mention]"),o=[];return n.forEach(l=>{const u=l.getAttribute("data-mention")||"",i=(l.textContent||"").match(/{{(.+?)}}/);i&&o.push({name:i[1],value:u})}),o},vt=e=>{var o,l,u;const n=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(n)&&(e.preventDefault(),R(n==="b"?"bold":n==="i"?"italic":n==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const a=window.getSelection(),i=a!=null&&a.anchorNode?he(a.anchorNode):null;if(!i)return;if(((o=i.textContent)==null?void 0:o.replace(/\u200B/g,"").trim())===""){e.preventDefault();const f=i.parentElement,p=f==null?void 0:f.closest("li");if(p){f==null||f.removeChild(i);const h=document.createElement("p");h.innerHTML="<br />",(l=p.parentElement)==null||l.insertBefore(h,p.nextSibling);const b=document.createRange();b.setStart(h,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(b)}else{const h=i.closest("ul, ol");if(h){const b=document.createElement("p");b.innerHTML="<br />",(u=h.parentElement)==null||u.insertBefore(b,h.nextSibling),h.removeChild(i);const N=document.createRange();N.setStart(b,0),N.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(N)}}k()}}},Et=e=>{if(e.data==="@"){const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;const l=o.anchorNode;if(yt(l))return;setTimeout(()=>{ut(o.getRangeAt(0)),fe(""),U(r),F(!0)},0);return}if($){setTimeout(()=>ve(),0);return}},yt=e=>{if(!e)return!1;let n=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;for(;n;){if(n.tagName==="TH")return!0;n=n.parentElement}return!1},ve=()=>{if(k(),!$)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const o=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!o){F(!1);return}const l=o[1].toLowerCase();fe(l);const u=r.filter(a=>a.name.toLowerCase().includes(l));U(u)},wt=e=>{var l;const n=(l=e.target.files)==null?void 0:l[0];if(!n)return;const o=new FileReader;o.onload=u=>{var N;const a=(N=u.target)==null?void 0:N.result;V();const i=window.getSelection();let v=i&&i.rangeCount?i.getRangeAt(0):null;const f=document.createElement("img");f.src=a,f.alt=n.name||"image",f.className="rte-inserted-image",f.contentEditable="true";const p=H();if(!v||!p){p==null||p.appendChild(f);const ke=document.createTextNode(" ");p==null||p.appendChild(ke);const te=document.createRange();te.setStartAfter(ke),te.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(te),p==null||p.focus(),k(),e.target.value="";return}v.deleteContents(),v.insertNode(f);const h=document.createTextNode(" ");f.after(h);const b=document.createRange();b.setStartAfter(h),b.collapse(!0),i.removeAllRanges(),i.addRange(b),p.focus(),k(),e.target.value=""},o.readAsDataURL(n)},bt=e=>{var u;V();const n=window.getSelection();if(!(n!=null&&n.rangeCount))return;const o=n.getRangeAt(0),l=document.createTextNode(e);o.insertNode(l),o.setStartAfter(l),o.collapse(!0),n.removeAllRanges(),n.addRange(o),(u=H())==null||u.focus(),k()},Ct=()=>{V();const e=document.createElement("table");e.style.borderCollapse="collapse",e.style.width="100%",e.style.border="1px solid #ccc",e.style.margin="8px 0",e.style.position="relative",m.table&&e.classList.add(m.table);const n=document.createElement("thead");m.thead&&n.classList.add(m.thead);const o=document.createElement("tbody");m.tbody&&o.classList.add(m.tbody);const l=document.createElement("tr");m.tr&&l.classList.add(m.tr);const u=document.createElement("tr");m.tr&&u.classList.add(m.tr);for(let v=0;v<2;v++){const f=document.createElement("th");f.textContent=`Header ${v+1}`,f.style.border="1px solid #999",f.style.padding="8px",f.style.position="relative",f.style.backgroundColor="lightgray",m.th&&f.classList.add(m.th);const p=document.createElement("td");p.textContent=`Row 1 Col ${v+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",p.style.backgroundColor="#fff",m.td&&p.classList.add(m.td),ee(f),ee(p),l.appendChild(f),u.appendChild(p)}n.appendChild(l),o.appendChild(u),e.appendChild(n),e.appendChild(o),zt(e),xt(e);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(e),k()},xt=e=>{const n=document.createElement("div");Object.assign(n.style,{position:"absolute",width:"14px",height:"14px",right:"0",bottom:"0",background:"rgba(0,0,0,0.25)",cursor:"nwse-resize",zIndex:"20",borderRadius:"2px"});let o=0,l=0,u=0,a=0;n.addEventListener("mousedown",i=>{i.preventDefault(),o=i.clientX,l=i.clientY;const v=e.getBoundingClientRect();u=v.width,a=v.height;const f=h=>{const b=Math.max(100,u+(h.clientX-o)),N=Math.max(60,a+(h.clientY-l));e.style.width=`${b}px`,e.style.height=`${N}px`,k()},p=()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p),k()};document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)}),e.appendChild(n)},ee=e=>{const n=document.createElement("div"),o=document.createElement("div");Object.assign(n.style,{position:"absolute",right:"0",top:"0",width:"6px",height:"100%",cursor:"col-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Object.assign(o.style,{position:"absolute",bottom:"0",left:"0",width:"100%",height:"6px",cursor:"row-resize",background:"rgba(0,0,0,0.15)",zIndex:"10"}),Lt(e,n,o),e.appendChild(n),e.appendChild(o)},Lt=(e,n,o)=>{let l=0,u=0,a=0,i=0;n.addEventListener("mousedown",h=>{h.preventDefault(),l=h.clientX,a=e.offsetWidth,document.addEventListener("mousemove",v),document.addEventListener("mouseup",p)}),o.addEventListener("mousedown",h=>{h.preventDefault(),u=h.clientY,i=e.offsetHeight,document.addEventListener("mousemove",f),document.addEventListener("mouseup",p)});const v=h=>{const b=a+(h.clientX-l);e.style.width=`${Math.max(30,b)}px`},f=h=>{const b=i+(h.clientY-u);e.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",p)}},St=e=>{const o=e.target.closest("td, th");o&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(l=>l.classList.remove("rte-cell-highlight")),o.classList.add("rte-cell-highlight"),B({visible:!0,x:e.clientX,y:e.clientY,cell:o}))},Ee=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Mt=e=>{if(!j.cell)return;const n=j.cell.closest("table"),o=j.cell.cellIndex,l=j.cell.parentElement.rowIndex,u=a=>{const i=a.tagName.toLowerCase(),v=document.createElement(i);return v.textContent=a.textContent||"",v.style.cssText=a.style.cssText,ee(v),v};switch(e){case"insertRowAbove":{const a=n.rows[l],i=n.insertRow(l);Array.from(a.cells).forEach(v=>{i.appendChild(u(v))});break}case"insertRowBelow":{const a=n.rows[l],i=n.insertRow(l+1);Array.from(a.cells).forEach(v=>{i.appendChild(u(v))});break}case"insertColLeft":{Array.from(n.rows).forEach(a=>{const i=a.cells[o];a.insertBefore(u(i),i)});break}case"insertColRight":{Array.from(n.rows).forEach(a=>{const i=a.cells[o];a.insertBefore(u(i),i.nextSibling)});break}case"deleteRow":n.rows.length>1&&n.deleteRow(l);break;case"deleteCol":Array.from(n.rows).forEach(a=>{a.cells[o]&&a.deleteCell(o)});break}k(),B(re(ne({},j),{visible:!1})),Ee()},zt=e=>{const n=e.querySelector("tbody");if(!n||n.querySelector("[data-hidden-table-start]"))return;const o=document.createElement("span");o.textContent="{{#arrayData}}",o.style.display="none",o.setAttribute("data-hidden-table-start","true"),n.insertBefore(o,n.firstChild);const l=document.createElement("span");l.textContent="{{/arrayData}}",l.style.display="none",l.setAttribute("data-hidden-table-end","true"),n.appendChild(l)},ye=()=>{const e=H();if(!e)return O;const n=e.cloneNode(!0);return n.querySelectorAll("table div").forEach(o=>o.remove()),n.querySelectorAll(".rte-cell-highlight").forEach(o=>o.classList.remove("rte-cell-highlight")),n.innerHTML},kt=()=>{ge(),y.current=P.current,me({url:"",text:"",title:"",target:"_self"}),g(!0)},At=e=>{const n=window.getSelection();if(!n||!y.current)return;n.removeAllRanges(),n.addRange(y.current);let o=e.url.trim();/^https?:\/\//i.test(o)||(o="https://"+o);const l=document.createElement("a");l.href=o,l.style.cursor="pointer",l.style.outline="none",l.textContent=e.text||o,l.title=e.title,l.target=e.target,l.contentEditable="true";const u=n.getRangeAt(0);u.deleteContents(),u.insertNode(l);const a=document.createTextNode(" ");l.after(a);const i=document.createRange();i.setStartAfter(a),i.collapse(!0),n.removeAllRanges(),n.addRange(i),g(!1),k()},Nt=e=>{const n=e.target;if(n.tagName==="A"){const o=n;if(e.ctrlKey||e.metaKey){window.open(o.href,"_blank","noopener,noreferrer");return}e.preventDefault();const l=document.createRange();l.selectNode(o),y.current=l,me({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),g(!0)}},Tt=()=>{const e=H();if(!e)return;const n=window.getSelection();if((!n||n.rangeCount===0)&&P.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(P.current)}const o=window.getSelection();if(!o||o.rangeCount===0)return;const l=o.getRangeAt(0);V(),document.execCommand("removeFormat",!1);const u=l.cloneContents(),a=document.createElement("div");a.appendChild(u);const i=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),v=[];for(;i.nextNode();){const h=i.currentNode,b=h.tagName.toUpperCase(),N=h.getAttribute&&h.getAttribute("data-mention")!==null;b!=="A"&&!N&&v.push(h)}for(let h=v.length-1;h>=0;h--){const b=v[h],N=b.parentNode;if(N){for(;b.firstChild;)N.insertBefore(b.firstChild,b);N.removeChild(b)}}a.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),l.deleteContents();const f=document.createDocumentFragment();for(;a.firstChild;)f.appendChild(a.firstChild);l.insertNode(f);const p=document.createRange();p.setStartAfter(l.endContainer.nodeType===Node.TEXT_NODE?l.endContainer:l.startContainer),p.collapse(!0),o.removeAllRanges(),o.addRange(p),e.normalize(),k()},Ot=e=>{var l;let n=e;n=n.replace(/{{#arrayData\d*}}/g,""),n=n.replace(/{{\/arrayData\d*}}/g,"");const o=document.createElement("div");return o.innerHTML=n,o.querySelectorAll("br").forEach(u=>{u.replaceWith(`
|
|
2
|
+
`)}),o.querySelectorAll("p, div, tr").forEach(u=>{u.insertAdjacentText("afterend",`
|
|
3
|
+
`)}),o.querySelectorAll("table").forEach(u=>{u.insertAdjacentText("afterend",`
|
|
4
4
|
`)}),((l=o.textContent)==null?void 0:l.replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim())||""};return
|
|
6
|
+
`).trim())||""};return t.createElement("div",{className:`rte-wrapper ${(m==null?void 0:m.wrapper)||""}`,style:w.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(se,{exec:R,saveSelection:ge,handleFileChange:wt,handleFontSizeChange:e=>R("fontSize",e.target.value),handleFontFamilyChange:e=>R("fontName",e.target.value),insertEmoji:bt,handleLink:kt,removeFormatting:Tt,visibleActions:at,className:m.toolbar,style:w.toolbar}),t.createElement("div",{ref:A,className:`rte-editor ${(m==null?void 0:m.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onInput:ve,onKeyDown:vt,onBeforeInput:Et,onContextMenu:St,onClick:Nt}),t.createElement(nt,{show:$,position:Y,filtered:I,insertMention:ft,onClose:()=>F(!1),query:it}),s&&t.createElement("div",{className:`rte-output ${(m==null?void 0:m.output)||""}`,style:w.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,O)),t.createElement(rt,{visible:j.visible,x:j.x,y:j.y,onAction:Mt,onClose:()=>{B(re(ne({},j),{visible:!1})),Ee()}}),t.createElement(ot,{visible:Z,linkData:q,onClose:()=>g(!1),onInsert:At})),d?t.createElement(de,{className:m.preview,style:w.preview,html:ye()}):null)};L.RichTextEditor=lt,L.RtePreview=de,L.RteToolbar=se,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/richtexteditor.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*{box-sizing:border-box;margin:0}.rte-wrapper{font-family:Inter,system-ui,sans-serif;display:flex;flex-grow:1;flex-direction:row;min-height:400px;min-width:400px;gap:12px;padding:12px;background:#fff;overflow:hidden}.rte-wrapper>div:first-child{display:flex;flex-direction:column;flex:2;min-width:0;min-height:0;gap:8px;overflow:hidden}.rte-toolbar{position:static!important;overflow:visible!important;flex-shrink:0;display:flex;flex-wrap:wrap;align-items:center;gap:10px;background:#fafafa;padding:8px;border:1px solid #eee;border-radius:6px;overflow-y:auto;max-height:140px;user-select:none}.rte-dropdown{padding:4px 8px;border-radius:4px;border:1px solid #ccc;font-size:12px;background:#fff;cursor:pointer;width:110px}.rte-toolbar button{padding:6px;border:1px solid transparent;background:none;cursor:pointer}.rte-toolbar button:hover{color:#00f}.rte-toolbar button[title=Emoji]{color:#ff0;fill:#000;background:none;font-size:18px;display:inline-flex;align-items:center;justify-content:center;border:none}.rte-toolbar button[title=Emoji] svg{background-color:#000;border-radius:50%;display:block}.rte-toolbar button[title=removeFormat]{font-size:16px}.rte-toolbar *{user-select:none;pointer-events:auto}.rte-editor{flex:1 1 auto;min-height:0;padding:12px;outline:none;border:1px solid lightgray;border-radius:4px;background:#fff;overflow-y:auto}.rte-output{flex-shrink:0;height:20%;background:#f7f7f7;border:1px solid lightgray;border-radius:4px;padding:10px;overflow-y:auto;min-height:100px}.rte-output h4{margin-bottom:6px;font-size:14px}.rte-preview{flex:1;border:1px solid #ccc;border-radius:4px;background:#fff;padding:10px;overflow-y:auto;min-width:200px;min-height:200px}.rte-editor table,.rte-preview table{border-collapse:collapse;width:100%}.rte-editor th,.rte-editor td,.rte-preview th,.rte-preview td{border:1px solid #ccc;background:#fff;padding:6px;min-width:60px;position:relative}.rte-editor th,.rte-preview th{background-color:#d3d3d3}.rte-th div,.rte-td div{border:none!important;background:transparent!important;padding:0;margin:0}.rte-cell-highlight{outline:2px solid #007bff;outline-offset:-2px;background-color:#007bff1a;z-index:2}.rte-popup{position:fixed;padding:4px 0;background-color:#fff;border:1px solid lightgray;border-radius:4px;box-shadow:0 2px 6px #0000001a;list-style:none;margin:0;z-index:1000;max-height:250px;overflow-y:auto;width:fit-content}.rte-emoji-popup{position:
|
|
1
|
+
*{box-sizing:border-box;margin:0}.rte-wrapper{font-family:Inter,system-ui,sans-serif;display:flex;flex-grow:1;flex-direction:row;min-height:400px;min-width:400px;gap:12px;padding:12px;background:#fff;overflow:hidden}.rte-wrapper>div:first-child{display:flex;flex-direction:column;flex:2;min-width:0;min-height:0;gap:8px;overflow:hidden}.rte-toolbar{position:static!important;overflow:visible!important;flex-shrink:0;display:flex;flex-wrap:wrap;align-items:center;gap:10px;background:#fafafa;padding:8px;border:1px solid #eee;border-radius:6px;overflow-y:auto;max-height:140px;user-select:none}.rte-dropdown{padding:4px 8px;border-radius:4px;border:1px solid #ccc;font-size:12px;background:#fff;cursor:pointer;width:110px}.rte-toolbar button{padding:6px;border:1px solid transparent;background:none;cursor:pointer}.rte-toolbar button:hover{color:#00f}.rte-toolbar button[title=Emoji]{color:#ff0;fill:#000;background:none;font-size:18px;display:inline-flex;align-items:center;justify-content:center;border:none}.rte-toolbar button[title=Emoji] svg{background-color:#000;border-radius:50%;display:block}.rte-toolbar button[title=removeFormat]{font-size:16px}.rte-toolbar *{user-select:none;pointer-events:auto}.rte-editor{flex:1 1 auto;min-height:0;padding:12px;outline:none;border:1px solid lightgray;border-radius:4px;background:#fff;overflow-y:auto}.rte-output{flex-shrink:0;height:20%;background:#f7f7f7;border:1px solid lightgray;border-radius:4px;padding:10px;overflow-y:auto;min-height:100px}.rte-output h4{margin-bottom:6px;font-size:14px}.rte-preview{flex:1;border:1px solid #ccc;border-radius:4px;background:#fff;padding:10px;overflow-y:auto;min-width:200px;min-height:200px}.rte-editor table,.rte-preview table{border-collapse:collapse;width:100%}.rte-editor th,.rte-editor td,.rte-preview th,.rte-preview td{border:1px solid #ccc;background:#fff;padding:6px;min-width:60px;position:relative}.rte-editor th,.rte-preview th{background-color:#d3d3d3}.rte-th div,.rte-td div{border:none!important;background:transparent!important;padding:0;margin:0}.rte-cell-highlight{outline:2px solid #007bff;outline-offset:-2px;background-color:#007bff1a;z-index:2}.rte-popup{position:fixed;padding:4px 0;background-color:#fff;border:1px solid lightgray;border-radius:4px;box-shadow:0 2px 6px #0000001a;list-style:none;margin:0;z-index:1000;max-height:250px;overflow-y:auto;width:fit-content}.rte-emoji-popup{position:fixed;top:130%;left:25%;background:#fff;border:1px solid #ccc;border-radius:8px;padding:8px;width:260px;height:200px;overflow-y:auto;display:grid;grid-template-columns:repeat(6,1fr);gap:4px;z-index:10000;box-shadow:0 4px 8px #00000026}.rte-table-menu{position:absolute;display:flex;flex-direction:column;align-items:baseline;gap:4px;background:#fff;border:1px solid #ccc;box-shadow:0 2px 6px #00000026;z-index:999;padding:4px}.rte-table-menu button{display:flex;align-items:end;gap:4px;padding:6px;border:1px solid transparent;background:none;cursor:pointer}.rte-table-menu button:hover{color:#00f}.rte-link-modal-overlay{position:fixed;top:0;left:0;width:100vw;height:100vh;background:#0006;z-index:9999;backdrop-filter:blur(1px)}.rte-link-modal{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#fff;border:1px solid #ccc;border-radius:6px;box-shadow:0 4px 8px #0003;padding:16px;width:320px;z-index:10000;animation:fadeIn .2s ease-in-out}.rte-link-modal__title{margin-bottom:8px;font-size:16px;font-weight:600;text-align:center}.rte-link-modal__input,.rte-link-modal__select{width:100%;padding:6px 8px;margin-bottom:8px;border:1px solid #ccc;border-radius:4px;font-size:14px}.rte-link-modal__input:focus,.rte-link-modal__select:focus{border-color:#007bff;outline:none}.rte-link-modal__actions{display:flex;justify-content:flex-end;gap:8px}.rte-link-modal__btn{padding:6px 12px;border:none;border-radius:4px;font-size:14px;cursor:pointer}.rte-link-modal__btn:hover{opacity:.9}.rte-link-modal__btn--ok{background:#007bff;color:#fff}@keyframes fadeIn{0%{opacity:0;transform:translate(-50%,-48%)}to{opacity:1;transform:translate(-50%,-50%)}}.rte-toolbar{border:1px solid #e0e0e0;transition:box-shadow .2s ease}.rte-toolbar button:hover{background:#eef3ff;border-radius:6px;color:#007bff;transform:translateY(-2px);transition:all .2s ease}.rte-editor{border:1px solid #ddd;border-radius:2px;background:#fcfcfc;padding:16px;line-height:1.6;font-size:15px;transition:all .2s ease}.rte-editor:focus{border-color:#007bff;background:#fff}.rte-output{border:1px solid #e5e8ec;font-family:monospace;font-size:13px;color:#333}.rte-preview{background:#fff;border:1px solid #e5e5e5;border-radius:10px;box-shadow:0 2px 6px #0000000d;padding:16px}.rte-emoji-popup{background:#fff;box-shadow:0 4px 12px #00000026;padding:10px;width:280px;grid-template-columns:repeat(7,1fr);gap:6px}.rte-emoji-popup span{font-size:22px;cursor:pointer;transition:transform .15s ease}.rte-emoji-popup span:hover{transform:scale(1.3)}.rte-inserted-image{max-width:100%;height:200px;width:fit-content;object-fit:cover;border-radius:6px;display:inline-block;vertical-align:middle;box-shadow:0 1px 4px #0000000f;transition:box-shadow .15s ease,transform .15s ease;cursor:pointer;position:relative}.rte-inserted-image:hover{box-shadow:0 4px 14px #0000001f;transform:translateY(-1px)}.rte-highlight{color:#007bff;font-weight:700;font-weight:600}.rte-active{background:#dce8ff!important;border-radius:4px!important}
|