@ryzeup/richtexteditor 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1,6 @@
1
- "use strict";var Ue=Object.defineProperty,qe=Object.defineProperties;var We=Object.getOwnPropertyDescriptors;var he=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,Xe=Object.prototype.propertyIsEnumerable;var fe=(n,c,i)=>c in n?Ue(n,c,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[c]=i,X=(n,c)=>{for(var i in c||(c={}))Ke.call(c,i)&&fe(n,i,c[i]);if(he)for(var i of he(c))Xe.call(c,i)&&fe(n,i,c[i]);return n},Y=(n,c)=>qe(n,We(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function Ye(n){const c=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(c,i,u.get?u:{enumerable:!0,get:()=>n[i]})}}return c.default=n,Object.freeze(c)}const Ze=Ye(t);window.React=Ze;var we={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ge=t.createContext&&t.createContext(we),Qe=["attr","size","title"];function Je(n,c){if(n==null)return{};var i=Ge(n,c),u,v;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(n);for(v=0;v<y.length;v++)u=y[v],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(n,u)&&(i[u]=n[u])}return i}function Ge(n,c){if(n==null)return{};var i={};for(var u in n)if(Object.prototype.hasOwnProperty.call(n,u)){if(c.indexOf(u)>=0)continue;i[u]=n[u]}return i}function $(){return $=Object.assign?Object.assign.bind():function(n){for(var c=1;c<arguments.length;c++){var i=arguments[c];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(n[u]=i[u])}return n},$.apply(this,arguments)}function pe(n,c){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(n);c&&(u=u.filter(function(v){return Object.getOwnPropertyDescriptor(n,v).enumerable})),i.push.apply(i,u)}return i}function U(n){for(var c=1;c<arguments.length;c++){var i=arguments[c]!=null?arguments[c]:{};c%2?pe(Object(i),!0).forEach(function(u){et(n,u,i[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):pe(Object(i)).forEach(function(u){Object.defineProperty(n,u,Object.getOwnPropertyDescriptor(i,u))})}return n}function et(n,c,i){return c=tt(c),c in n?Object.defineProperty(n,c,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[c]=i,n}function tt(n){var c=nt(n,"string");return typeof c=="symbol"?c:c+""}function nt(n,c){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var u=i.call(n,c);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(n)}function Ee(n){return n&&n.map((c,i)=>t.createElement(c.tag,U({key:i},c.attr),Ee(c.child)))}function M(n){return c=>t.createElement(rt,$({attr:U({},n.attr)},c),Ee(n.child))}function rt(n){var c=i=>{var{attr:u,size:v,title:y}=n,x=Je(n,Qe),R=v||i.size||"1em",w;return i.className&&(w=i.className),n.className&&(w=(w?w+" ":"")+n.className),t.createElement("svg",$({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,u,x,{className:w,style:U(U({color:n.color||i.color},i.style),n.style),height:R,width:R,xmlns:"http://www.w3.org/2000/svg"}),y&&t.createElement("title",null,y),n.children)};return ge!==void 0?t.createElement(ge.Consumer,null,i=>c(i)):c(we)}function ot(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 at(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 lt(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 ct(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 it(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 st(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 ut(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 dt(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 mt(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 ht(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 ft(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 gt(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 pt(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 vt(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 wt(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 Et=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ye=({exec:n,saveSelection:c,handleFileChange:i,handleFontSizeChange:u,handleFontFamilyChange:v,insertEmoji:y,handleLink:x,removeFormatting:R,visibleActions:w,className:D,style:A})=>{var _,F;const L=t.useRef(null),T=t.useRef(null),C=t.useRef(null),[q,H]=t.useState(!1);t.useEffect(()=>{const m=E=>{!E.target.closest(".rte-emoji-popup")&&!E.target.closest("button[title='Emoji']")&&H(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const z=m=>{var I;m.preventDefault();const E=m.currentTarget.dataset.command;if(E)switch(E){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(E);break;case"insertImage":{(I=L.current)==null||I.click();break}default:console.warn("Unknown command:",E)}},j=m=>{n("foreColor",m.target.value)},N=m=>{n("backColor",m.target.value)};return t.createElement("div",{className:`rte-toolbar ${D||""}`,style:A},w.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:z},t.createElement(st,null)),w.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:z},t.createElement(dt,null)),w.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:z},t.createElement(pt,null)),w.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:z,title:"UnorderedList"},t.createElement(ht,null)),w.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:z},t.createElement(ct,null)),w.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:x},t.createElement(mt,null)),w.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),c(),R()}},t.createElement(wt,null)),w.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:z},t.createElement(lt,null)),t.createElement("input",{type:"file",accept:"image/*",ref:L,style:{display:"none"},onChange:i}),w.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),c(),H(E=>!E)}},t.createElement(ft,null)),q&&t.createElement("div",{className:"rte-emoji-popup"},Et.map(m=>t.createElement("span",{key:m,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:E=>{E.preventDefault(),y(m),H(!1)}},m)))),w.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:m=>{var E;m.preventDefault(),c(),(E=T.current)==null||E.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((_=T.current)==null?void 0:_.value)||"#000",fontSize:"18px"}},t.createElement(vt,null)),t.createElement("input",{ref:T,type:"color",defaultValue:"#000000",onChange:m=>{var E;j(m),((E=m.target.parentElement)==null?void 0:E.querySelector("button")).style.color=m.target.value},style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),w.highlight&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:m=>{var E;m.preventDefault(),c(),(E=C.current)==null||E.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((F=C.current)==null?void 0:F.value)||"#000",fontSize:"18px"}},t.createElement(ut,null)),t.createElement("input",{ref:C,type:"color",onChange:m=>{var E;N(m),((E=m.target.parentElement)==null?void 0:E.querySelector("button")).style.color=m.target.value},defaultValue:"#000000",style:{position:"absolute",opacity:0,width:0,height:0,pointerEvents:"none"}})),w.align&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyLeft")},t.createElement(it,null)),t.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyCenter")},t.createElement(ot,null)),t.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyRight")},t.createElement(at,null))),w.table&&t.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>n("insertTable")},t.createElement(gt,null)),w.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),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")),w.fontSize&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),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")))},yt=({show:n,position:c,filtered:i,insertMention:u,onClose:v,query:y})=>{const x=t.useRef(null);return t.useEffect(()=>{const R=w=>{x.current&&!x.current.contains(w.target)&&v()};return n&&document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},[n,v]),n?t.createElement("ul",{ref:x,className:"rte-popup",style:{top:c.y,left:c.x}},i.length>0?i.map(({key:R,value:w})=>{const D=R.toLowerCase(),A=y.toLowerCase(),L=D.indexOf(A);let T=R;if(L!==-1&&y.length>0){const C=L+y.length;T=R.substring(0,L)+`<span class="rte-highlight">${R.substring(L,C)}</span>`+R.substring(C)}return t.createElement("li",{key:w,onMouseDown:C=>{C.preventDefault(),u({key:R,value:w})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:T},onMouseEnter:C=>C.currentTarget.style.background="#f0f0f0",onMouseLeave:C=>C.currentTarget.style.background="#fff"})}):t.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function ve(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 V(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 bt=({visible:n,x:c,y:i,onAction:u,onClose:v})=>{if(!n)return null;const y={top:i,left:c};return t.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:v},t.createElement("button",{onClick:()=>u("insertRowAbove")},t.createElement(V,null)," Insert row above"),t.createElement("button",{onClick:()=>u("insertRowBelow")},t.createElement(V,null)," Insert row below"),t.createElement("button",{onClick:()=>u("insertColLeft")},t.createElement(V,null)," Insert col left"),t.createElement("button",{onClick:()=>u("insertColRight")},t.createElement(V,null)," Insert col right"),t.createElement("button",{onClick:()=>u("deleteRow")},t.createElement(ve,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(ve,null)," Delete column"))},be=({html:n,className:c,style:i})=>{const u=v=>{const y=v.target;if(y.tagName==="A"){v.preventDefault();const x=y.href;x&&window.open(x,"_blank","noopener,noreferrer")}};return React.createElement("div",{className:`rte-preview ${c||""}`,style:i,onClick:u,dangerouslySetInnerHTML:{__html:n}})},Ct=({visible:n,linkData:c,onClose:i,onInsert:u})=>{const[v,y]=t.useState(""),[x,R]=t.useState(""),[w,D]=t.useState(""),[A,L]=t.useState("_self");if(t.useEffect(()=>{n?(y(c.url||""),R(c.text||""),D(c.title||""),L(c.target||"_self")):(y(""),R(""),D(""),L("_self"))},[n,c]),!n)return null;const T=()=>{u({url:v,text:x,title:w,target:A})};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:C=>y(C.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:x,onChange:C=>R(C.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:w,onChange:C=>D(C.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:A,onChange:C=>L(C.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"))))},Rt=({atSuggestions:n=[],showOutput:c=!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:x=()=>{}})=>{var oe,ae,le,ce,ie,se,ue,de;const R=t.useRef(null),[w,D]=t.useState("<p>Always bet on Prime!</p>"),[A,L]=t.useState(!1),[T,C]=t.useState({x:0,y:0}),[q,H]=t.useState([]),z=t.useRef(null),j=t.useRef(null),[N,_]=t.useState({visible:!1,x:0,y:0}),[F,m]=t.useState(!1),E=t.useRef(null),[I,Z]=t.useState({url:"",text:"",title:"",target:"_self"}),Ce={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(oe=u.link)!=null?oe:!1,image:(ae=u.image)!=null?ae:!1,emoji:(le=u.emoji)!=null?le:!1,table:(ce=u.table)!=null?ce:!1,color:(ie=u.color)!=null?ie:!1,fontFamily:(se=u.fontFamily)!=null?se:!1,fontSize:(ue=u.fontSize)!=null?ue:!1,highlight:(de=u.fontSize)!=null?de:!1},[Re,Q]=t.useState(""),O=()=>R.current,S=()=>{var r,o;D((o=(r=O())==null?void 0:r.innerHTML)!=null?o:"");const e=re();x==null||x(e)},J=()=>{const e=window.getSelection();e!=null&&e.rangeCount&&(z.current=e.getRangeAt(0))},P=()=>{const e=window.getSelection();e&&z.current&&(e.removeAllRanges(),e.addRange(z.current))},xe=(e,r)=>{const o=window.getSelection();o&&o.rangeCount>0&&(z.current=o.getRangeAt(0)),P(),document.execCommand(e,!1,r),S()};t.useEffect(()=>{const e=O();e&&!e.innerHTML&&(e.innerHTML=w),S()},[]),t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]);const G=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Le=e=>{let r=0,o=e.parentElement;for(;o;)(o.tagName==="UL"||o.tagName==="OL")&&r++,o=o.parentElement;return r},Me=e=>{const r=e.querySelector("li"),o=r?Le(r):1;if(e.querySelector("[data-hidden-array-start]"))return;const a=`{{#arrayData${o>1?o:""}}}`,h=`{{/arrayData${o>1?o:""}}}`,l=document.createElement("span");l.textContent=a,l.style.display="none",l.setAttribute("data-hidden-array-start","true"),e.insertBefore(l,e.firstChild);const s=document.createElement("span");s.textContent=h,s.style.display="none",s.setAttribute("data-hidden-array-end","true"),e.appendChild(s)},ee=e=>{var g;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),a=G(o.startContainer);let h,l;if(a){let d=a.querySelector(e);d||(d=document.createElement(e),d.style.margin="0",d.style.paddingLeft="20px",a.appendChild(d)),l=d,h=document.createElement("li"),h.textContent="​",l.appendChild(h)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const d=O();if(l=d==null?void 0:d.querySelector(`${e}:last-child`),!l)return;h=l.querySelector("li:last-child")}Me(l);const s=document.createRange();s.setStart(h,0),s.collapse(!0),r.removeAllRanges(),r.addRange(s),(g=O())==null||g.focus(),S()},B=(e,r)=>{e==="insertOrderedList"?ee("ol"):e==="insertUnorderedList"?ee("ul"):xe(e,r),e==="insertTable"&&De()},Se=e=>{const r=document.createElement("span");r.textContent="​",e.insertNode(r),e.setStartAfter(r),e.collapse(!0);const o=r.getBoundingClientRect();r.remove(),C({x:o.left,y:o.bottom+window.scrollY}),H(n||[]),L(!0),j.current=e.cloneRange()},ze=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.anchorNode;let o=e.anchorOffset;if(!r)return null;let a=r;for(a.nodeType!==Node.TEXT_NODE&&(a.childNodes&&a.childNodes[o]?a=a.childNodes[o]:a=r.previousSibling);a;){if(a.nodeType===Node.TEXT_NODE){const h=a.textContent||"",l=a===r?o:h.length,s=h.lastIndexOf("@",l-1);if(s!==-1){const g=document.createRange();return g.setStart(a,s),g.setEnd(a,l),g}}a=a.previousSibling}return null},ke=e=>{var h;const r=window.getSelection();if(!r)return;const o=ze();o?(r.removeAllRanges(),r.addRange(o)):j.current&&(r.removeAllRanges(),r.addRange(j.current));const a=document.createElement("span");a.textContent=`{{${e.key}}}`,a.style.color="#007bff",a.style.display="inline",a.contentEditable="false",a.setAttribute("data-mention",e.value||e.key||"");try{const l=r.rangeCount?r.getRangeAt(0):null;if(l)l.deleteContents(),l.insertNode(a);else{const d=document.createRange(),p=O();d.selectNodeContents(p),d.collapse(!1),d.insertNode(a)}const s=document.createTextNode(" ");a.after(s);const g=document.createRange();g.setStartAfter(s),g.collapse(!0),r.removeAllRanges(),r.addRange(g)}catch(l){console.error("insertMention error:",l)}L(!1),(h=O())==null||h.focus(),S()},Ne=e=>{var o,a,h;const r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&["b","i","u"].includes(r)&&(e.preventDefault(),B(r==="b"?"bold":r==="i"?"italic":r==="u"?"underline":"")),e.shiftKey&&e.key==="2"&&e.preventDefault(),e.key==="Enter"){const l=window.getSelection(),s=l!=null&&l.anchorNode?G(l.anchorNode):null;if(!s)return;if(((o=s.textContent)==null?void 0:o.replace(/\u200B/g,"").trim())===""){e.preventDefault();const d=s.parentElement,p=d==null?void 0:d.closest("li");if(p){d==null||d.removeChild(s);const f=document.createElement("p");f.innerHTML="<br />",(a=p.parentElement)==null||a.insertBefore(f,p.nextSibling);const b=document.createRange();b.setStart(f,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}else{const f=s.closest("ul, ol");if(f){const b=document.createElement("p");b.innerHTML="<br />",(h=f.parentElement)==null||h.insertBefore(b,f.nextSibling),f.removeChild(s);const k=document.createRange();k.setStart(b,0),k.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(k)}}S()}}},Ae=e=>{if(e.data==="@"){const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;setTimeout(()=>{Se(o.getRangeAt(0)),Q(""),H(n),L(!0)},0);return}if(A){setTimeout(()=>te(),0);return}},te=()=>{if(S(),!A)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const o=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!o){L(!1);return}const a=o[1].toLowerCase();Q(a);const h=n.filter(l=>l.key.toLowerCase().includes(a));H(h)},Te=e=>{var a;const r=(a=e.target.files)==null?void 0:a[0];if(!r)return;const o=new FileReader;o.onload=h=>{var k;const l=(k=h.target)==null?void 0:k.result;P();const s=window.getSelection();let g=s&&s.rangeCount?s.getRangeAt(0):null;const d=document.createElement("img");d.src=l,d.alt=r.name||"image",d.className="rte-inserted-image",d.contentEditable="true";const p=O();if(!g||!p){p==null||p.appendChild(d);const me=document.createTextNode(" ");p==null||p.appendChild(me);const K=document.createRange();K.setStartAfter(me),K.collapse(!0),s==null||s.removeAllRanges(),s==null||s.addRange(K),p==null||p.focus(),S(),e.target.value="";return}g.deleteContents(),g.insertNode(d);const f=document.createTextNode(" ");d.after(f);const b=document.createRange();b.setStartAfter(f),b.collapse(!0),s.removeAllRanges(),s.addRange(b),p.focus(),S(),e.target.value=""},o.readAsDataURL(r)},Oe=e=>{var h;P();const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),a=document.createTextNode(e);o.insertNode(a),o.setStartAfter(a),o.collapse(!0),r.removeAllRanges(),r.addRange(o),(h=O())==null||h.focus(),S()},De=()=>{P();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"),o=document.createElement("tbody"),a=document.createElement("tr"),h=document.createElement("tr");for(let g=0;g<2;g++){const d=document.createElement("th");d.textContent=`Header ${g+1}`,d.style.border="1px solid #999",d.style.padding="8px",d.style.position="relative";const p=document.createElement("td");p.textContent=`Row 1 Col ${g+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",W(d),W(p),a.appendChild(d),h.appendChild(p)}r.appendChild(a),o.appendChild(h),e.appendChild(r),e.appendChild(o),Fe(e),He(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;l.getRangeAt(0).insertNode(e),S()},He=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 o=0,a=0,h=0,l=0;r.addEventListener("mousedown",s=>{s.preventDefault(),o=s.clientX,a=s.clientY;const g=e.getBoundingClientRect();h=g.width,l=g.height;const d=f=>{const b=Math.max(100,h+(f.clientX-o)),k=Math.max(60,l+(f.clientY-a));e.style.width=`${b}px`,e.style.height=`${k}px`,S()},p=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p),S()};document.addEventListener("mousemove",d),document.addEventListener("mouseup",p)}),e.appendChild(r)},W=e=>{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"}),_e(e,r,o),e.appendChild(r),e.appendChild(o)},_e=(e,r,o)=>{let a=0,h=0,l=0,s=0;r.addEventListener("mousedown",f=>{f.preventDefault(),a=f.clientX,l=e.offsetWidth,document.addEventListener("mousemove",g),document.addEventListener("mouseup",p)}),o.addEventListener("mousedown",f=>{f.preventDefault(),h=f.clientY,s=e.offsetHeight,document.addEventListener("mousemove",d),document.addEventListener("mouseup",p)});const g=f=>{const b=l+(f.clientX-a);e.style.width=`${Math.max(30,b)}px`},d=f=>{const b=s+(f.clientY-h);e.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p)}},je=e=>{const o=e.target.closest("td, th");o&&(e.preventDefault(),document.querySelectorAll(".rte-cell-highlight").forEach(a=>a.classList.remove("rte-cell-highlight")),o.classList.add("rte-cell-highlight"),_({visible:!0,x:e.clientX,y:e.clientY,cell:o}))},ne=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Pe=e=>{if(!N.cell)return;const r=N.cell.closest("table"),o=N.cell.cellIndex,a=N.cell.parentElement.rowIndex,h=l=>{const s=l.tagName.toLowerCase(),g=document.createElement(s);return g.textContent=l.textContent||"",g.style.cssText=l.style.cssText,W(g),g};switch(e){case"insertRowAbove":{const l=r.rows[a],s=r.insertRow(a);Array.from(l.cells).forEach(g=>{s.appendChild(h(g))});break}case"insertRowBelow":{const l=r.rows[a],s=r.insertRow(a+1);Array.from(l.cells).forEach(g=>{s.appendChild(h(g))});break}case"insertColLeft":{Array.from(r.rows).forEach(l=>{const s=l.cells[o];l.insertBefore(h(s),s)});break}case"insertColRight":{Array.from(r.rows).forEach(l=>{const s=l.cells[o];l.insertBefore(h(s),s.nextSibling)});break}case"deleteRow":r.rows.length>1&&r.deleteRow(a);break;case"deleteCol":Array.from(r.rows).forEach(l=>{l.cells[o]&&l.deleteCell(o)});break}S(),_(Y(X({},N),{visible:!1})),ne()},Fe=e=>{const r=e.querySelector("tbody");if(!r||r.querySelector("[data-hidden-table-start]"))return;const o=document.createElement("span");o.textContent="{{#tableData}}",o.style.display="none",o.setAttribute("data-hidden-table-start","true"),r.insertBefore(o,r.firstChild);const a=document.createElement("span");a.textContent="{{/tableData}}",a.style.display="none",a.setAttribute("data-hidden-table-end","true"),r.appendChild(a)},re=()=>{const e=O();if(!e)return w;const r=e.cloneNode(!0);return r.querySelectorAll(".rte-cell-highlight").forEach(o=>{o.classList.remove("rte-cell-highlight")}),r.querySelectorAll("div").forEach(o=>{(o.style.cursor==="col-resize"||o.style.cursor==="row-resize"||o.style.cursor==="nwse-resize")&&o.remove()}),r.innerHTML},Ie=()=>{J(),E.current=z.current,Z({url:"",text:"",title:"",target:"_self"}),m(!0)},Be=e=>{const r=window.getSelection();if(!r||!E.current)return;r.removeAllRanges(),r.addRange(E.current);let o=e.url.trim();/^https?:\/\//i.test(o)||(o="https://"+o);const a=document.createElement("a");a.href=o,a.style.cursor="pointer",a.style.outline="none",a.textContent=e.text||o,a.title=e.title,a.target=e.target,a.contentEditable="true";const h=r.getRangeAt(0);h.deleteContents(),h.insertNode(a);const l=document.createTextNode(" ");a.after(l);const s=document.createRange();s.setStartAfter(l),s.collapse(!0),r.removeAllRanges(),r.addRange(s),m(!1),S()},Ve=e=>{const r=e.target;if(r.tagName==="A"){const o=r;if(e.ctrlKey||e.metaKey){window.open(o.href,"_blank","noopener,noreferrer");return}e.preventDefault();const a=document.createRange();a.selectNode(o),E.current=a,Z({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),m(!0)}},$e=()=>{const e=O();if(!e)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&z.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(z.current)}const o=window.getSelection();if(!o||o.rangeCount===0)return;const a=o.getRangeAt(0);P(),document.execCommand("removeFormat",!1);const h=a.cloneContents(),l=document.createElement("div");l.appendChild(h);const s=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),g=[];for(;s.nextNode();){const f=s.currentNode,b=f.tagName.toUpperCase(),k=f.getAttribute&&f.getAttribute("data-mention")!==null;b!=="A"&&!k&&g.push(f)}for(let f=g.length-1;f>=0;f--){const b=g[f],k=b.parentNode;if(k){for(;b.firstChild;)k.insertBefore(b.firstChild,b);k.removeChild(b)}}l.querySelectorAll("[style]").forEach(f=>f.removeAttribute("style")),a.deleteContents();const d=document.createDocumentFragment();for(;l.firstChild;)d.appendChild(l.firstChild);a.insertNode(d);const p=document.createRange();p.setStartAfter(a.endContainer.nodeType===Node.TEXT_NODE?a.endContainer:a.startContainer),p.collapse(!0),o.removeAllRanges(),o.addRange(p),e.normalize(),S()};return t.createElement("div",{className:`rte-wrapper ${(v==null?void 0:v.wrapper)||""}`,style:y.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(ye,{exec:B,saveSelection:J,handleFileChange:Te,handleFontSizeChange:e=>B("fontSize",e.target.value),handleFontFamilyChange:e=>B("fontName",e.target.value),insertEmoji:Oe,handleLink:Ie,removeFormatting:$e,visibleActions:Ce,className:v.toolbar,style:y.toolbar}),t.createElement("div",{ref:R,className:`rte-editor ${(v==null?void 0:v.editor)||""}`,style:y.editor,contentEditable:!0,suppressContentEditableWarning:!0,onInput:te,onKeyDown:Ne,onBeforeInput:Ae,onContextMenu:je,onClick:Ve}),t.createElement(yt,{show:A,position:T,filtered:q,insertMention:ke,onClose:()=>L(!1),query:Re}),c&&t.createElement("div",{className:`rte-output ${(v==null?void 0:v.output)||""}`,style:y.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,w)),t.createElement(bt,{visible:N.visible,x:N.x,y:N.y,onAction:Pe,onClose:()=>{_(Y(X({},N),{visible:!1})),ne()}}),t.createElement(Ct,{visible:F,linkData:I,onClose:()=>m(!1),onInsert:Be})),i?t.createElement(be,{className:v.preview,style:y.preview,html:re()}):null)};exports.RichTextEditor=Rt;exports.RtePreview=be;exports.RteToolbar=ye;
1
+ "use strict";var We=Object.defineProperty,Ke=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var ge=Object.getOwnPropertySymbols;var Ye=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var he=(n,c,i)=>c in n?We(n,c,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[c]=i,Z=(n,c)=>{for(var i in c||(c={}))Ye.call(c,i)&&he(n,i,c[i]);if(ge)for(var i of ge(c))Ze.call(c,i)&&he(n,i,c[i]);return n},Q=(n,c)=>Ke(n,Xe(c));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function Qe(n){const c=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(c,i,u.get?u:{enumerable:!0,get:()=>n[i]})}}return c.default=n,Object.freeze(c)}const Je=Qe(t);window.React=Je;var we={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},pe=t.createContext&&t.createContext(we),Ge=["attr","size","title"];function et(n,c){if(n==null)return{};var i=tt(n,c),u,v;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(n);for(v=0;v<w.length;v++)u=w[v],!(c.indexOf(u)>=0)&&Object.prototype.propertyIsEnumerable.call(n,u)&&(i[u]=n[u])}return i}function tt(n,c){if(n==null)return{};var i={};for(var u in n)if(Object.prototype.hasOwnProperty.call(n,u)){if(c.indexOf(u)>=0)continue;i[u]=n[u]}return i}function $(){return $=Object.assign?Object.assign.bind():function(n){for(var c=1;c<arguments.length;c++){var i=arguments[c];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(n[u]=i[u])}return n},$.apply(this,arguments)}function ve(n,c){var i=Object.keys(n);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(n);c&&(u=u.filter(function(v){return Object.getOwnPropertyDescriptor(n,v).enumerable})),i.push.apply(i,u)}return i}function W(n){for(var c=1;c<arguments.length;c++){var i=arguments[c]!=null?arguments[c]:{};c%2?ve(Object(i),!0).forEach(function(u){nt(n,u,i[u])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):ve(Object(i)).forEach(function(u){Object.defineProperty(n,u,Object.getOwnPropertyDescriptor(i,u))})}return n}function nt(n,c,i){return c=rt(c),c in n?Object.defineProperty(n,c,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[c]=i,n}function rt(n){var c=at(n,"string");return typeof c=="symbol"?c:c+""}function at(n,c){if(typeof n!="object"||!n)return n;var i=n[Symbol.toPrimitive];if(i!==void 0){var u=i.call(n,c);if(typeof u!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(n)}function ye(n){return n&&n.map((c,i)=>t.createElement(c.tag,W({key:i},c.attr),ye(c.child)))}function S(n){return c=>t.createElement(ot,$({attr:W({},n.attr)},c),ye(n.child))}function ot(n){var c=i=>{var{attr:u,size:v,title:w}=n,L=et(n,Ge),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"}),w&&t.createElement("title",null,w),n.children)};return pe!==void 0?t.createElement(pe.Consumer,null,i=>c(i)):c(we)}function lt(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 ct(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 it(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 st(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 ut(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 dt(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 mt(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 ft(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 gt(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 ht(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 pt(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 vt(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 Et(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 wt(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 yt(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 Ct=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],Ce=({exec:n,saveSelection:c,handleFileChange:i,handleFontSizeChange:u,handleFontFamilyChange:v,insertEmoji:w,handleLink:L,removeFormatting:x,visibleActions:E,className:A,style:j})=>{var q,H;const M=t.useRef(null),N=t.useRef(null),R=t.useRef(null),[K,_]=t.useState(!1);t.useEffect(()=>{const f=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&_(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const T=f=>{var I;f.preventDefault();const C=f.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(C);break;case"insertImage":{(I=M.current)==null||I.click();break}default:console.warn("Unknown command:",C)}},D=f=>{n("foreColor",f.target.value)},F=f=>{n("backColor",f.target.value)},[y,P]=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 f=()=>{P({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",f),()=>document.removeEventListener("selectionchange",f)},[]),t.createElement("div",{className:`rte-toolbar ${A||""}`,style:j},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:T,className:y.bold?"rte-active":""},t.createElement(dt,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:T,className:y.italic?"rte-active":""},t.createElement(ft,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:T,className:y.underline?"rte-active":""},t.createElement(Et,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:T,title:"UnorderedList",className:y.unorderedList?"rte-active":""},t.createElement(ht,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:T,className:y.orderedList?"rte-active":""},t.createElement(st,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:L,className:y.link?"rte-active":""},t.createElement(gt,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:f=>{f.preventDefault(),c(),x()},className:y.removeFormat?"rte-active":""},t.createElement(yt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:T,className:y.image?"rte-active":""},t.createElement(it,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:f=>{f.preventDefault(),c(),_(C=>!C)},className:y.emoji?"rte-active":""},t.createElement(pt,null)),K&&t.createElement("div",{className:"rte-emoji-popup"},Ct.map(f=>t.createElement("span",{key:f,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:C=>{C.preventDefault(),w(f),_(!1)}},f)))),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:f=>{var C;f.preventDefault(),c(),(C=N.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((q=N.current)==null?void 0:q.value)||"#000",fontSize:"18px"},className:y.color?"rte-active":""},t.createElement(wt,null)),t.createElement("input",{ref:N,type:"color",defaultValue:"#000000",onChange:f=>{var C;D(f),((C=f.target.parentElement)==null?void 0:C.querySelector("button")).style.color=f.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:f=>{var C;f.preventDefault(),c(),(C=R.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((H=R.current)==null?void 0:H.value)||"#000",fontSize:"18px"},className:y.highlight?"rte-active":""},t.createElement(mt,null)),t.createElement("input",{ref:R,type:"color",onChange:f=>{var C;F(f),((C=f.target.parentElement)==null?void 0:C.querySelector("button")).style.color=f.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:f=>f.preventDefault(),onClick:()=>n("justifyLeft"),className:y.alignLeft?"rte-active":""},t.createElement(ut,null)),t.createElement("button",{title:"Align Center",onMouseDown:f=>f.preventDefault(),onClick:()=>n("justifyCenter"),className:y.alignCenter?"rte-active":""},t.createElement(lt,null)),t.createElement("button",{title:"Align Right",onMouseDown:f=>f.preventDefault(),onClick:()=>n("justifyRight"),className:y.alignRight?"rte-active":""},t.createElement(ct,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:f=>f.preventDefault(),onClick:()=>n("insertTable"),className:y.table?"rte-active":""},t.createElement(vt,null)),E.fontFamily&&t.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>c(),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:()=>c(),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")))},bt=({show:n,position:c,filtered:i,insertMention:u,onClose:v,query:w})=>{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:c.y,left:c.x}},i.length>0?i.map(({key:x,value:E})=>{const A=x.toLowerCase(),j=w.toLowerCase(),M=A.indexOf(j);let N=x;if(M!==-1&&w.length>0){const R=M+w.length;N=x.substring(0,M)+`<span class="rte-highlight">${x.substring(M,R)}</span>`+x.substring(R)}return t.createElement("li",{key:E,onMouseDown:R=>{R.preventDefault(),u({key:x,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:N},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 Ee(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 Rt=({visible:n,x:c,y:i,onAction:u,onClose:v})=>{if(!n)return null;const w={top:i,left:c};return t.createElement("div",{style:w,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(Ee,null)," Delete row"),t.createElement("button",{onClick:()=>u("deleteCol")},t.createElement(Ee,null)," Delete column"))},be=({html:n,className:c,style:i})=>{const u=v=>{const w=v.target;if(w.tagName==="A"){v.preventDefault();const L=w.href;L&&window.open(L,"_blank","noopener,noreferrer")}};return t.createElement("div",{className:`rte-preview ${c||""}`,style:i,onClick:u,dangerouslySetInnerHTML:{__html:n}})},xt=({visible:n,linkData:c,onClose:i,onInsert:u})=>{const[v,w]=t.useState(""),[L,x]=t.useState(""),[E,A]=t.useState(""),[j,M]=t.useState("_self");if(t.useEffect(()=>{n?(w(c.url||""),x(c.text||""),A(c.title||""),M(c.target||"_self")):(w(""),x(""),A(""),M("_self"))},[n,c]),!n)return null;const N=()=>{u({url:v,text:L,title:E,target:j})};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:R=>w(R.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:L,onChange:R=>x(R.target.value)}),t.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:R=>A(R.target.value)}),t.createElement("select",{className:"rte-link-modal__select",value:j,onChange:R=>M(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:i},"Cancel"),t.createElement("button",{className:"rte-link-modal__btn rte-link-modal__btn--ok",onClick:N},"OK"))))},Lt=({atSuggestions:n=[],showOutput:c=!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:w={},handleGetHtml:L=()=>{},onChange:x=()=>{}})=>{var oe,le,ce,ie,se,ue,de,me;const E=t.useRef(null),[A,j]=t.useState("<p>Hello!</p>"),[M,N]=t.useState(!1),[R,K]=t.useState({x:0,y:0}),[_,T]=t.useState([]),D=t.useRef(null),F=t.useRef(null),[y,P]=t.useState({visible:!1,x:0,y:0}),[q,H]=t.useState(!1),f=t.useRef(null),[C,I]=t.useState({url:"",text:"",title:"",target:"_self"}),Re={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(oe=u.link)!=null?oe:!1,image:(le=u.image)!=null?le:!1,emoji:(ce=u.emoji)!=null?ce:!1,table:(ie=u.table)!=null?ie:!1,color:(se=u.color)!=null?se:!1,fontFamily:(ue=u.fontFamily)!=null?ue:!1,fontSize:(de=u.fontSize)!=null?de:!1,highlight:(me=u.fontSize)!=null?me:!1},[xe,J]=t.useState(""),O=()=>E.current,z=()=>{const e=ae();j(e),L==null||L(e);const r=$e(e);x(r)},G=()=>{const e=window.getSelection();e!=null&&e.rangeCount&&(D.current=e.getRangeAt(0))},B=()=>{const e=window.getSelection();e&&D.current&&(e.removeAllRanges(),e.addRange(D.current))},Le=(e,r)=>{const a=window.getSelection();a&&a.rangeCount>0&&(D.current=a.getRangeAt(0)),B(),document.execCommand(e,!1,r),z()};t.useEffect(()=>{const e=O();e&&!e.innerHTML&&(e.innerHTML=A),z()},[]),t.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]);const ee=e=>{for(;e&&e.nodeName!=="LI";)e=e.parentNode;return e},Se=e=>{let r=0,a=e.parentElement;for(;a;)(a.tagName==="UL"||a.tagName==="OL")&&r++,a=a.parentElement;return r},Me=e=>{const r=e.querySelector("li"),a=r?Se(r):1;if(e.querySelector("[data-hidden-array-start]"))return;const o=`{{#arrayData${a>1?a:""}}}`,d=`{{/arrayData${a>1?a:""}}}`,l=document.createElement("span");l.textContent=o,l.style.display="none",l.setAttribute("data-hidden-array-start","true"),e.insertBefore(l,e.firstChild);const s=document.createElement("span");s.textContent=d,s.style.display="none",s.setAttribute("data-hidden-array-end","true"),e.appendChild(s)},te=e=>{var h;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const a=r.getRangeAt(0),o=ee(a.startContainer);let d,l;if(o){let m=o.querySelector(e);m||(m=document.createElement(e),m.style.margin="0",m.style.paddingLeft="20px",o.appendChild(m)),l=m,d=document.createElement("li"),d.textContent="​",l.appendChild(d)}else{document.execCommand(e==="ul"?"insertUnorderedList":"insertOrderedList");const m=O();if(l=m==null?void 0:m.querySelector(`${e}:last-child`),!l)return;d=l.querySelector("li:last-child")}Me(l);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"?te("ol"):e==="insertUnorderedList"?te("ul"):Le(e,r),e==="insertTable"&&je()},ze=e=>{const r=document.createElement("span");r.textContent="​",e.insertNode(r),e.setStartAfter(r),e.collapse(!0);const a=r.getBoundingClientRect();r.remove(),K({x:a.left,y:a.bottom+window.scrollY}),T(n||[]),N(!0),F.current=e.cloneRange()},Ne=()=>{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||"",l=o===r?a:d.length,s=d.lastIndexOf("@",l-1);if(s!==-1){const h=document.createRange();return h.setStart(o,s),h.setEnd(o,l),h}}o=o.previousSibling}return null},ke=e=>{var d;const r=window.getSelection();if(!r)return;const a=Ne();a?(r.removeAllRanges(),r.addRange(a)):F.current&&(r.removeAllRanges(),r.addRange(F.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 l=r.rangeCount?r.getRangeAt(0):null;if(l)l.deleteContents(),l.insertNode(o);else{const m=document.createRange(),p=O();m.selectNodeContents(p),m.collapse(!1),m.insertNode(o)}const s=document.createTextNode(" ");o.after(s);const h=document.createRange();h.setStartAfter(s),h.collapse(!0),r.removeAllRanges(),r.addRange(h)}catch(l){console.error("insertMention error:",l)}N(!1),(d=O())==null||d.focus(),z()},Ae=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 l=window.getSelection(),s=l!=null&&l.anchorNode?ee(l.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 g=document.createElement("p");g.innerHTML="<br />",(o=p.parentElement)==null||o.insertBefore(g,p.nextSibling);const b=document.createRange();b.setStart(g,0),b.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(b)}else{const g=s.closest("ul, ol");if(g){const b=document.createElement("p");b.innerHTML="<br />",(d=g.parentElement)==null||d.insertBefore(b,g.nextSibling),g.removeChild(s);const k=document.createRange();k.setStart(b,0),k.collapse(!0),l==null||l.removeAllRanges(),l==null||l.addRange(k)}}z()}}},Te=e=>{if(e.data==="@"){const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;setTimeout(()=>{ze(a.getRangeAt(0)),J(""),T(n),N(!0)},0);return}if(M){setTimeout(()=>ne(),0);return}},ne=()=>{if(z(),!M)return;const e=window.getSelection();if(!e||!e.anchorNode)return;const a=(e.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!a){N(!1);return}const o=a[1].toLowerCase();J(o);const d=n.filter(l=>l.key.toLowerCase().includes(o));T(d)},De=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 l=(k=d.target)==null?void 0:k.result;B();const s=window.getSelection();let h=s&&s.rangeCount?s.getRangeAt(0):null;const m=document.createElement("img");m.src=l,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 fe=document.createTextNode(" ");p==null||p.appendChild(fe);const Y=document.createRange();Y.setStartAfter(fe),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 g=document.createTextNode(" ");m.after(g);const b=document.createRange();b.setStartAfter(g),b.collapse(!0),s.removeAllRanges(),s.addRange(b),p.focus(),z(),e.target.value=""},a.readAsDataURL(r)},Oe=e=>{var d;B();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()},je=()=>{B();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),Ie(e),He(e);const l=window.getSelection();if(!(l!=null&&l.rangeCount))return;l.getRangeAt(0).insertNode(e),z()},He=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,l=0;r.addEventListener("mousedown",s=>{s.preventDefault(),a=s.clientX,o=s.clientY;const h=e.getBoundingClientRect();d=h.width,l=h.height;const m=g=>{const b=Math.max(100,d+(g.clientX-a)),k=Math.max(60,l+(g.clientY-o));e.style.width=`${b}px`,e.style.height=`${k}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"}),_e(e,r,a),e.appendChild(r),e.appendChild(a)},_e=(e,r,a)=>{let o=0,d=0,l=0,s=0;r.addEventListener("mousedown",g=>{g.preventDefault(),o=g.clientX,l=e.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)}),a.addEventListener("mousedown",g=>{g.preventDefault(),d=g.clientY,s=e.offsetHeight,document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)});const h=g=>{const b=l+(g.clientX-o);e.style.width=`${Math.max(30,b)}px`},m=g=>{const b=s+(g.clientY-d);e.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)}},Fe=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}))},re=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(e=>e.classList.remove("rte-cell-highlight"))},Pe=e=>{if(!y.cell)return;const r=y.cell.closest("table"),a=y.cell.cellIndex,o=y.cell.parentElement.rowIndex,d=l=>{const s=l.tagName.toLowerCase(),h=document.createElement(s);return h.textContent=l.textContent||"",h.style.cssText=l.style.cssText,X(h),h};switch(e){case"insertRowAbove":{const l=r.rows[o],s=r.insertRow(o);Array.from(l.cells).forEach(h=>{s.appendChild(d(h))});break}case"insertRowBelow":{const l=r.rows[o],s=r.insertRow(o+1);Array.from(l.cells).forEach(h=>{s.appendChild(d(h))});break}case"insertColLeft":{Array.from(r.rows).forEach(l=>{const s=l.cells[a];l.insertBefore(d(s),s)});break}case"insertColRight":{Array.from(r.rows).forEach(l=>{const s=l.cells[a];l.insertBefore(d(s),s.nextSibling)});break}case"deleteRow":r.rows.length>1&&r.deleteRow(o);break;case"deleteCol":Array.from(r.rows).forEach(l=>{l.cells[a]&&l.deleteCell(a)});break}z(),P(Q(Z({},y),{visible:!1})),re()},Ie=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)},ae=()=>{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},Be=()=>{G(),f.current=D.current,I({url:"",text:"",title:"",target:"_self"}),H(!0)},qe=e=>{const r=window.getSelection();if(!r||!f.current)return;r.removeAllRanges(),r.addRange(f.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 l=document.createTextNode(" ");o.after(l);const s=document.createRange();s.setStartAfter(l),s.collapse(!0),r.removeAllRanges(),r.addRange(s),H(!1),z()},Ve=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),f.current=o,I({url:a.href,text:a.textContent||a.href,title:a.title,target:a.target}),H(!0)}},Ue=()=>{const e=O();if(!e)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&D.current){const g=window.getSelection();g==null||g.removeAllRanges(),g==null||g.addRange(D.current)}const a=window.getSelection();if(!a||a.rangeCount===0)return;const o=a.getRangeAt(0);B(),document.execCommand("removeFormat",!1);const d=o.cloneContents(),l=document.createElement("div");l.appendChild(d);const s=document.createTreeWalker(l,NodeFilter.SHOW_ELEMENT,null),h=[];for(;s.nextNode();){const g=s.currentNode,b=g.tagName.toUpperCase(),k=g.getAttribute&&g.getAttribute("data-mention")!==null;b!=="A"&&!k&&h.push(g)}for(let g=h.length-1;g>=0;g--){const b=h[g],k=b.parentNode;if(k){for(;b.firstChild;)k.insertBefore(b.firstChild,b);k.removeChild(b)}}l.querySelectorAll("[style]").forEach(g=>g.removeAttribute("style")),o.deleteContents();const m=document.createDocumentFragment();for(;l.firstChild;)m.appendChild(l.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()},$e=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
+ `)}),a.querySelectorAll("p, div, tr").forEach(d=>{d.insertAdjacentText("afterend",`
3
+ `)}),a.querySelectorAll("table").forEach(d=>{d.insertAdjacentText("afterend",`
4
+ `)}),((o=a.textContent)==null?void 0:o.replace(/\n{3,}/g,`
5
+
6
+ `).trim())||""};return t.createElement("div",{className:`rte-wrapper ${(v==null?void 0:v.wrapper)||""}`,style:w.wrapper},t.createElement("div",{style:{flex:1}},t.createElement(Ce,{exec:V,saveSelection:G,handleFileChange:De,handleFontSizeChange:e=>V("fontSize",e.target.value),handleFontFamilyChange:e=>V("fontName",e.target.value),insertEmoji:Oe,handleLink:Be,removeFormatting:Ue,visibleActions:Re,className:v.toolbar,style:w.toolbar}),t.createElement("div",{ref:E,className:`rte-editor ${(v==null?void 0:v.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onInput:ne,onKeyDown:Ae,onBeforeInput:Te,onContextMenu:Fe,onClick:Ve}),t.createElement(bt,{show:M,position:R,filtered:_,insertMention:ke,onClose:()=>N(!1),query:xe}),c&&t.createElement("div",{className:`rte-output ${(v==null?void 0:v.output)||""}`,style:w.output},t.createElement("h4",null,"Output HTML:"),t.createElement("p",null,A)),t.createElement(Rt,{visible:y.visible,x:y.x,y:y.y,onAction:Pe,onClose:()=>{P(Q(Z({},y),{visible:!1})),re()}}),t.createElement(xt,{visible:q,linkData:C,onClose:()=>H(!1),onInsert:qe})),i?t.createElement(be,{className:v.preview,style:w.preview,html:ae()}):null)};exports.RichTextEditor=Lt;exports.RtePreview=be;exports.RteToolbar=Ce;
package/dist/index.umd.js CHANGED
@@ -1 +1,6 @@
1
- (function(L,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],e):(L=typeof globalThis!="undefined"?globalThis:L||self,e(L.RichTextEditor={},L.React))})(this,(function(L,e){"use strict";var yt=Object.defineProperty,bt=Object.defineProperties;var Ct=Object.getOwnPropertyDescriptors;var Ce=Object.getOwnPropertySymbols;var xt=Object.prototype.hasOwnProperty,Lt=Object.prototype.propertyIsEnumerable;var xe=(L,e,T)=>e in L?yt(L,e,{enumerable:!0,configurable:!0,writable:!0,value:T}):L[e]=T,J=(L,e)=>{for(var T in e||(e={}))xt.call(e,T)&&xe(L,T,e[T]);if(Ce)for(var T of Ce(e))Lt.call(e,T)&&xe(L,T,e[T]);return L},R=(L,e)=>bt(L,Ct(e));function T(n){const i=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(i,u,c.get?c:{enumerable:!0,get:()=>n[u]})}}return i.default=n,Object.freeze(i)}const Le=T(e);window.React=Le;var G={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},$=e.createContext&&e.createContext(G),Me=["attr","size","title"];function Se(n,i){if(n==null)return{};var u=ze(n,i),c,v;if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(n);for(v=0;v<y.length;v++)c=y[v],!(i.indexOf(c)>=0)&&Object.prototype.propertyIsEnumerable.call(n,c)&&(u[c]=n[c])}return u}function ze(n,i){if(n==null)return{};var u={};for(var c in n)if(Object.prototype.hasOwnProperty.call(n,c)){if(i.indexOf(c)>=0)continue;u[c]=n[c]}return u}function V(){return V=Object.assign?Object.assign.bind():function(n){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(n[c]=u[c])}return n},V.apply(this,arguments)}function ee(n,i){var u=Object.keys(n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(n);i&&(c=c.filter(function(v){return Object.getOwnPropertyDescriptor(n,v).enumerable})),u.push.apply(u,c)}return u}function U(n){for(var i=1;i<arguments.length;i++){var u=arguments[i]!=null?arguments[i]:{};i%2?ee(Object(u),!0).forEach(function(c){ke(n,c,u[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(u)):ee(Object(u)).forEach(function(c){Object.defineProperty(n,c,Object.getOwnPropertyDescriptor(u,c))})}return n}function ke(n,i,u){return i=Ne(i),i in n?Object.defineProperty(n,i,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[i]=u,n}function Ne(n){var i=Ae(n,"string");return typeof i=="symbol"?i:i+""}function Ae(n,i){if(typeof n!="object"||!n)return n;var u=n[Symbol.toPrimitive];if(u!==void 0){var c=u.call(n,i);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}function te(n){return n&&n.map((i,u)=>e.createElement(i.tag,U({key:u},i.attr),te(i.child)))}function M(n){return i=>e.createElement(Te,V({attr:U({},n.attr)},i),te(n.child))}function Te(n){var i=u=>{var{attr:c,size:v,title:y}=n,S=Se(n,Me),x=v||u.size||"1em",E;return u.className&&(E=u.className),n.className&&(E=(E?E+" ":"")+n.className),e.createElement("svg",V({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,c,S,{className:E,style:U(U({color:n.color||u.color},u.style),n.style),height:x,width:x,xmlns:"http://www.w3.org/2000/svg"}),y&&e.createElement("title",null,y),n.children)};return $!==void 0?e.createElement($.Consumer,null,u=>i(u)):i(G)}function Oe(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 De(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 He(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 _e(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 je(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 Pe(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 Fe(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 Ie(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 Be(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 Ve(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 Ue(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 qe(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 We(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 Ke(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 Xe(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 Ye=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],ne=({exec:n,saveSelection:i,handleFileChange:u,handleFontSizeChange:c,handleFontFamilyChange:v,insertEmoji:y,handleLink:S,removeFormatting:x,visibleActions:E,className:j,style:D})=>{var F,W;const z=e.useRef(null),H=e.useRef(null),C=e.useRef(null),[Y,P]=e.useState(!1);e.useEffect(()=>{const m=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&P(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const N=m=>{var K;m.preventDefault();const w=m.currentTarget.dataset.command;if(w)switch(w){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(w);break;case"insertImage":{(K=z.current)==null||K.click();break}default:console.warn("Unknown command:",w)}},I=m=>{n("foreColor",m.target.value)},O=m=>{n("backColor",m.target.value)};return e.createElement("div",{className:`rte-toolbar ${j||""}`,style:D},E.bold&&e.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:N},e.createElement(Pe,null)),E.italic&&e.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:N},e.createElement(Ie,null)),E.underline&&e.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:N},e.createElement(We,null)),E.unorderedList&&e.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:N,title:"UnorderedList"},e.createElement(Ve,null)),E.orderedList&&e.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:N},e.createElement(_e,null)),E.link&&e.createElement("button",{"data-command":"createLink",title:"Link",onClick:S},e.createElement(Be,null)),E.removeFormat&&e.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),i(),x()}},e.createElement(Xe,null)),E.image&&e.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:N},e.createElement(He,null)),e.createElement("input",{type:"file",accept:"image/*",ref:z,style:{display:"none"},onChange:u}),E.emoji&&e.createElement("div",{style:{position:"relative"}},e.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),i(),P(w=>!w)}},e.createElement(Ue,null)),Y&&e.createElement("div",{className:"rte-emoji-popup"},Ye.map(m=>e.createElement("span",{key:m,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:w=>{w.preventDefault(),y(m),P(!1)}},m)))),E.color&&e.createElement("div",{style:{position:"relative"}},e.createElement("button",{title:"Text Color",onMouseDown:m=>{var w;m.preventDefault(),i(),(w=H.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((F=H.current)==null?void 0:F.value)||"#000",fontSize:"18px"}},e.createElement(Ke,null)),e.createElement("input",{ref:H,type:"color",defaultValue:"#000000",onChange:m=>{var w;I(m),((w=m.target.parentElement)==null?void 0:w.querySelector("button")).style.color=m.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:m=>{var w;m.preventDefault(),i(),(w=C.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((W=C.current)==null?void 0:W.value)||"#000",fontSize:"18px"}},e.createElement(Fe,null)),e.createElement("input",{ref:C,type:"color",onChange:m=>{var w;O(m),((w=m.target.parentElement)==null?void 0:w.querySelector("button")).style.color=m.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:m=>m.preventDefault(),onClick:()=>n("justifyLeft")},e.createElement(je,null)),e.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyCenter")},e.createElement(Oe,null)),e.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyRight")},e.createElement(De,null))),E.table&&e.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>n("insertTable")},e.createElement(qe,null)),E.fontFamily&&e.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>i(),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:()=>i(),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")))},Ze=({show:n,position:i,filtered:u,insertMention:c,onClose:v,query:y})=>{const S=e.useRef(null);return e.useEffect(()=>{const x=E=>{S.current&&!S.current.contains(E.target)&&v()};return n&&document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[n,v]),n?e.createElement("ul",{ref:S,className:"rte-popup",style:{top:i.y,left:i.x}},u.length>0?u.map(({key:x,value:E})=>{const j=x.toLowerCase(),D=y.toLowerCase(),z=j.indexOf(D);let H=x;if(z!==-1&&y.length>0){const C=z+y.length;H=x.substring(0,z)+`<span class="rte-highlight">${x.substring(z,C)}</span>`+x.substring(C)}return e.createElement("li",{key:E,onMouseDown:C=>{C.preventDefault(),c({key:x,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:H},onMouseEnter:C=>C.currentTarget.style.background="#f0f0f0",onMouseLeave:C=>C.currentTarget.style.background="#fff"})}):e.createElement("li",{style:{padding:"6px 12px",color:"#999"}},"No matches")):null};function re(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 q(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 Qe=({visible:n,x:i,y:u,onAction:c,onClose:v})=>{if(!n)return null;const y={top:u,left:i};return e.createElement("div",{style:y,className:"rte-table-menu",onMouseLeave:v},e.createElement("button",{onClick:()=>c("insertRowAbove")},e.createElement(q,null)," Insert row above"),e.createElement("button",{onClick:()=>c("insertRowBelow")},e.createElement(q,null)," Insert row below"),e.createElement("button",{onClick:()=>c("insertColLeft")},e.createElement(q,null)," Insert col left"),e.createElement("button",{onClick:()=>c("insertColRight")},e.createElement(q,null)," Insert col right"),e.createElement("button",{onClick:()=>c("deleteRow")},e.createElement(re,null)," Delete row"),e.createElement("button",{onClick:()=>c("deleteCol")},e.createElement(re,null)," Delete column"))},oe=({html:n,className:i,style:u})=>{const c=v=>{const y=v.target;if(y.tagName==="A"){v.preventDefault();const S=y.href;S&&window.open(S,"_blank","noopener,noreferrer")}};return React.createElement("div",{className:`rte-preview ${i||""}`,style:u,onClick:c,dangerouslySetInnerHTML:{__html:n}})},Je=({visible:n,linkData:i,onClose:u,onInsert:c})=>{const[v,y]=e.useState(""),[S,x]=e.useState(""),[E,j]=e.useState(""),[D,z]=e.useState("_self");if(e.useEffect(()=>{n?(y(i.url||""),x(i.text||""),j(i.title||""),z(i.target||"_self")):(y(""),x(""),j(""),z("_self"))},[n,i]),!n)return null;const H=()=>{c({url:v,text:S,title:E,target:D})};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:C=>y(C.target.value)}),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:S,onChange:C=>x(C.target.value)}),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:C=>j(C.target.value)}),e.createElement("select",{className:"rte-link-modal__select",value:D,onChange:C=>z(C.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:H},"OK"))))},Re=({atSuggestions:n=[],showOutput:i=!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:S=()=>{}})=>{var fe,he,ge,pe,ve,Ee,we,ye;const x=e.useRef(null),[E,j]=e.useState("<p>Always bet on Prime!</p>"),[D,z]=e.useState(!1),[H,C]=e.useState({x:0,y:0}),[Y,P]=e.useState([]),N=e.useRef(null),I=e.useRef(null),[O,F]=e.useState({visible:!1,x:0,y:0}),[W,m]=e.useState(!1),w=e.useRef(null),[K,le]=e.useState({url:"",text:"",title:"",target:"_self"}),Ge={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(fe=c.link)!=null?fe:!1,image:(he=c.image)!=null?he:!1,emoji:(ge=c.emoji)!=null?ge:!1,table:(pe=c.table)!=null?pe:!1,color:(ve=c.color)!=null?ve:!1,fontFamily:(Ee=c.fontFamily)!=null?Ee:!1,fontSize:(we=c.fontSize)!=null?we:!1,highlight:(ye=c.fontSize)!=null?ye:!1},[$e,ae]=e.useState(""),_=()=>x.current,k=()=>{var r,o;j((o=(r=_())==null?void 0:r.innerHTML)!=null?o:"");const t=me();S==null||S(t)},ie=()=>{const t=window.getSelection();t!=null&&t.rangeCount&&(N.current=t.getRangeAt(0))},B=()=>{const t=window.getSelection();t&&N.current&&(t.removeAllRanges(),t.addRange(N.current))},et=(t,r)=>{const o=window.getSelection();o&&o.rangeCount>0&&(N.current=o.getRangeAt(0)),B(),document.execCommand(t,!1,r),k()};e.useEffect(()=>{const t=_();t&&!t.innerHTML&&(t.innerHTML=E),k()},[]),e.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]);const se=t=>{for(;t&&t.nodeName!=="LI";)t=t.parentNode;return t},tt=t=>{let r=0,o=t.parentElement;for(;o;)(o.tagName==="UL"||o.tagName==="OL")&&r++,o=o.parentElement;return r},nt=t=>{const r=t.querySelector("li"),o=r?tt(r):1;if(t.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${o>1?o:""}}}`,f=`{{/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 s=document.createElement("span");s.textContent=f,s.style.display="none",s.setAttribute("data-hidden-array-end","true"),t.appendChild(s)},ce=t=>{var g;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),l=se(o.startContainer);let f,a;if(l){let d=l.querySelector(t);d||(d=document.createElement(t),d.style.margin="0",d.style.paddingLeft="20px",l.appendChild(d)),a=d,f=document.createElement("li"),f.textContent="​",a.appendChild(f)}else{document.execCommand(t==="ul"?"insertUnorderedList":"insertOrderedList");const d=_();if(a=d==null?void 0:d.querySelector(`${t}:last-child`),!a)return;f=a.querySelector("li:last-child")}nt(a);const s=document.createRange();s.setStart(f,0),s.collapse(!0),r.removeAllRanges(),r.addRange(s),(g=_())==null||g.focus(),k()},X=(t,r)=>{t==="insertOrderedList"?ce("ol"):t==="insertUnorderedList"?ce("ul"):et(t,r),t==="insertTable"&&ut()},rt=t=>{const r=document.createElement("span");r.textContent="​",t.insertNode(r),t.setStartAfter(r),t.collapse(!0);const o=r.getBoundingClientRect();r.remove(),C({x:o.left,y:o.bottom+window.scrollY}),P(n||[]),z(!0),I.current=t.cloneRange()},ot=()=>{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 f=l.textContent||"",a=l===r?o:f.length,s=f.lastIndexOf("@",a-1);if(s!==-1){const g=document.createRange();return g.setStart(l,s),g.setEnd(l,a),g}}l=l.previousSibling}return null},lt=t=>{var f;const r=window.getSelection();if(!r)return;const o=ot();o?(r.removeAllRanges(),r.addRange(o)):I.current&&(r.removeAllRanges(),r.addRange(I.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 a=r.rangeCount?r.getRangeAt(0):null;if(a)a.deleteContents(),a.insertNode(l);else{const d=document.createRange(),p=_();d.selectNodeContents(p),d.collapse(!1),d.insertNode(l)}const s=document.createTextNode(" ");l.after(s);const g=document.createRange();g.setStartAfter(s),g.collapse(!0),r.removeAllRanges(),r.addRange(g)}catch(a){console.error("insertMention error:",a)}z(!1),(f=_())==null||f.focus(),k()},at=t=>{var o,l,f;const r=t.key.toLowerCase();if((t.ctrlKey||t.metaKey)&&["b","i","u"].includes(r)&&(t.preventDefault(),X(r==="b"?"bold":r==="i"?"italic":r==="u"?"underline":"")),t.shiftKey&&t.key==="2"&&t.preventDefault(),t.key==="Enter"){const a=window.getSelection(),s=a!=null&&a.anchorNode?se(a.anchorNode):null;if(!s)return;if(((o=s.textContent)==null?void 0:o.replace(/\u200B/g,"").trim())===""){t.preventDefault();const d=s.parentElement,p=d==null?void 0:d.closest("li");if(p){d==null||d.removeChild(s);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=s.closest("ul, ol");if(h){const b=document.createElement("p");b.innerHTML="<br />",(f=h.parentElement)==null||f.insertBefore(b,h.nextSibling),h.removeChild(s);const A=document.createRange();A.setStart(b,0),A.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(A)}}k()}}},it=t=>{if(t.data==="@"){const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;setTimeout(()=>{rt(o.getRangeAt(0)),ae(""),P(n),z(!0)},0);return}if(D){setTimeout(()=>ue(),0);return}},ue=()=>{if(k(),!D)return;const t=window.getSelection();if(!t||!t.anchorNode)return;const o=(t.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!o){z(!1);return}const l=o[1].toLowerCase();ae(l);const f=n.filter(a=>a.key.toLowerCase().includes(l));P(f)},st=t=>{var l;const r=(l=t.target.files)==null?void 0:l[0];if(!r)return;const o=new FileReader;o.onload=f=>{var A;const a=(A=f.target)==null?void 0:A.result;B();const s=window.getSelection();let g=s&&s.rangeCount?s.getRangeAt(0):null;const d=document.createElement("img");d.src=a,d.alt=r.name||"image",d.className="rte-inserted-image",d.contentEditable="true";const p=_();if(!g||!p){p==null||p.appendChild(d);const be=document.createTextNode(" ");p==null||p.appendChild(be);const Q=document.createRange();Q.setStartAfter(be),Q.collapse(!0),s==null||s.removeAllRanges(),s==null||s.addRange(Q),p==null||p.focus(),k(),t.target.value="";return}g.deleteContents(),g.insertNode(d);const h=document.createTextNode(" ");d.after(h);const b=document.createRange();b.setStartAfter(h),b.collapse(!0),s.removeAllRanges(),s.addRange(b),p.focus(),k(),t.target.value=""},o.readAsDataURL(r)},ct=t=>{var f;B();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),(f=_())==null||f.focus(),k()},ut=()=>{B();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"),f=document.createElement("tr");for(let g=0;g<2;g++){const d=document.createElement("th");d.textContent=`Header ${g+1}`,d.style.border="1px solid #999",d.style.padding="8px",d.style.position="relative";const p=document.createElement("td");p.textContent=`Row 1 Col ${g+1}`,p.style.border="1px solid #999",p.style.padding="8px",p.style.position="relative",Z(d),Z(p),l.appendChild(d),f.appendChild(p)}r.appendChild(l),o.appendChild(f),t.appendChild(r),t.appendChild(o),gt(t),dt(t);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(t),k()},dt=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,f=0,a=0;r.addEventListener("mousedown",s=>{s.preventDefault(),o=s.clientX,l=s.clientY;const g=t.getBoundingClientRect();f=g.width,a=g.height;const d=h=>{const b=Math.max(100,f+(h.clientX-o)),A=Math.max(60,a+(h.clientY-l));t.style.width=`${b}px`,t.style.height=`${A}px`,k()},p=()=>{document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p),k()};document.addEventListener("mousemove",d),document.addEventListener("mouseup",p)}),t.appendChild(r)},Z=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"}),mt(t,r,o),t.appendChild(r),t.appendChild(o)},mt=(t,r,o)=>{let l=0,f=0,a=0,s=0;r.addEventListener("mousedown",h=>{h.preventDefault(),l=h.clientX,a=t.offsetWidth,document.addEventListener("mousemove",g),document.addEventListener("mouseup",p)}),o.addEventListener("mousedown",h=>{h.preventDefault(),f=h.clientY,s=t.offsetHeight,document.addEventListener("mousemove",d),document.addEventListener("mouseup",p)});const g=h=>{const b=a+(h.clientX-l);t.style.width=`${Math.max(30,b)}px`},d=h=>{const b=s+(h.clientY-f);t.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p)}},ft=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"),F({visible:!0,x:t.clientX,y:t.clientY,cell:o}))},de=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(t=>t.classList.remove("rte-cell-highlight"))},ht=t=>{if(!O.cell)return;const r=O.cell.closest("table"),o=O.cell.cellIndex,l=O.cell.parentElement.rowIndex,f=a=>{const s=a.tagName.toLowerCase(),g=document.createElement(s);return g.textContent=a.textContent||"",g.style.cssText=a.style.cssText,Z(g),g};switch(t){case"insertRowAbove":{const a=r.rows[l],s=r.insertRow(l);Array.from(a.cells).forEach(g=>{s.appendChild(f(g))});break}case"insertRowBelow":{const a=r.rows[l],s=r.insertRow(l+1);Array.from(a.cells).forEach(g=>{s.appendChild(f(g))});break}case"insertColLeft":{Array.from(r.rows).forEach(a=>{const s=a.cells[o];a.insertBefore(f(s),s)});break}case"insertColRight":{Array.from(r.rows).forEach(a=>{const s=a.cells[o];a.insertBefore(f(s),s.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(),F(R(J({},O),{visible:!1})),de()},gt=t=>{const r=t.querySelector("tbody");if(!r||r.querySelector("[data-hidden-table-start]"))return;const o=document.createElement("span");o.textContent="{{#tableData}}",o.style.display="none",o.setAttribute("data-hidden-table-start","true"),r.insertBefore(o,r.firstChild);const l=document.createElement("span");l.textContent="{{/tableData}}",l.style.display="none",l.setAttribute("data-hidden-table-end","true"),r.appendChild(l)},me=()=>{const t=_();if(!t)return E;const r=t.cloneNode(!0);return r.querySelectorAll(".rte-cell-highlight").forEach(o=>{o.classList.remove("rte-cell-highlight")}),r.querySelectorAll("div").forEach(o=>{(o.style.cursor==="col-resize"||o.style.cursor==="row-resize"||o.style.cursor==="nwse-resize")&&o.remove()}),r.innerHTML},pt=()=>{ie(),w.current=N.current,le({url:"",text:"",title:"",target:"_self"}),m(!0)},vt=t=>{const r=window.getSelection();if(!r||!w.current)return;r.removeAllRanges(),r.addRange(w.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 f=r.getRangeAt(0);f.deleteContents(),f.insertNode(l);const a=document.createTextNode(" ");l.after(a);const s=document.createRange();s.setStartAfter(a),s.collapse(!0),r.removeAllRanges(),r.addRange(s),m(!1),k()},Et=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),w.current=l,le({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),m(!0)}},wt=()=>{const t=_();if(!t)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&N.current){const h=window.getSelection();h==null||h.removeAllRanges(),h==null||h.addRange(N.current)}const o=window.getSelection();if(!o||o.rangeCount===0)return;const l=o.getRangeAt(0);B(),document.execCommand("removeFormat",!1);const f=l.cloneContents(),a=document.createElement("div");a.appendChild(f);const s=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),g=[];for(;s.nextNode();){const h=s.currentNode,b=h.tagName.toUpperCase(),A=h.getAttribute&&h.getAttribute("data-mention")!==null;b!=="A"&&!A&&g.push(h)}for(let h=g.length-1;h>=0;h--){const b=g[h],A=b.parentNode;if(A){for(;b.firstChild;)A.insertBefore(b.firstChild,b);A.removeChild(b)}}a.querySelectorAll("[style]").forEach(h=>h.removeAttribute("style")),l.deleteContents();const d=document.createDocumentFragment();for(;a.firstChild;)d.appendChild(a.firstChild);l.insertNode(d);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()};return e.createElement("div",{className:`rte-wrapper ${(v==null?void 0:v.wrapper)||""}`,style:y.wrapper},e.createElement("div",{style:{flex:1}},e.createElement(ne,{exec:X,saveSelection:ie,handleFileChange:st,handleFontSizeChange:t=>X("fontSize",t.target.value),handleFontFamilyChange:t=>X("fontName",t.target.value),insertEmoji:ct,handleLink:pt,removeFormatting:wt,visibleActions:Ge,className:v.toolbar,style:y.toolbar}),e.createElement("div",{ref:x,className:`rte-editor ${(v==null?void 0:v.editor)||""}`,style:y.editor,contentEditable:!0,suppressContentEditableWarning:!0,onInput:ue,onKeyDown:at,onBeforeInput:it,onContextMenu:ft,onClick:Et}),e.createElement(Ze,{show:D,position:H,filtered:Y,insertMention:lt,onClose:()=>z(!1),query:$e}),i&&e.createElement("div",{className:`rte-output ${(v==null?void 0:v.output)||""}`,style:y.output},e.createElement("h4",null,"Output HTML:"),e.createElement("p",null,E)),e.createElement(Qe,{visible:O.visible,x:O.x,y:O.y,onAction:ht,onClose:()=>{F(R(J({},O),{visible:!1})),de()}}),e.createElement(Je,{visible:W,linkData:K,onClose:()=>m(!1),onInsert:vt})),u?e.createElement(oe,{className:v.preview,style:y.preview,html:me()}):null)};L.RichTextEditor=Re,L.RtePreview=oe,L.RteToolbar=ne,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
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 bt=Object.defineProperty,xt=Object.defineProperties;var Lt=Object.getOwnPropertyDescriptors;var xe=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable;var Le=(S,e,D)=>e in S?bt(S,e,{enumerable:!0,configurable:!0,writable:!0,value:D}):S[e]=D,R=(S,e)=>{for(var D in e||(e={}))St.call(e,D)&&Le(S,D,e[D]);if(xe)for(var D of xe(e))Mt.call(e,D)&&Le(S,D,e[D]);return S},G=(S,e)=>xt(S,Lt(e));function D(n){const i=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(i,u,c.get?c:{enumerable:!0,get:()=>n[u]})}}return i.default=n,Object.freeze(i)}const Se=D(e);window.React=Se;var ee={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},te=e.createContext&&e.createContext(ee),Me=["attr","size","title"];function ze(n,i){if(n==null)return{};var u=Ne(n,i),c,v;if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(n);for(v=0;v<w.length;v++)c=w[v],!(i.indexOf(c)>=0)&&Object.prototype.propertyIsEnumerable.call(n,c)&&(u[c]=n[c])}return u}function Ne(n,i){if(n==null)return{};var u={};for(var c in n)if(Object.prototype.hasOwnProperty.call(n,c)){if(i.indexOf(c)>=0)continue;u[c]=n[c]}return u}function $(){return $=Object.assign?Object.assign.bind():function(n){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(n[c]=u[c])}return n},$.apply(this,arguments)}function ne(n,i){var u=Object.keys(n);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(n);i&&(c=c.filter(function(v){return Object.getOwnPropertyDescriptor(n,v).enumerable})),u.push.apply(u,c)}return u}function W(n){for(var i=1;i<arguments.length;i++){var u=arguments[i]!=null?arguments[i]:{};i%2?ne(Object(u),!0).forEach(function(c){ke(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 ke(n,i,u){return i=Te(i),i in n?Object.defineProperty(n,i,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[i]=u,n}function Te(n){var i=Ae(n,"string");return typeof i=="symbol"?i:i+""}function Ae(n,i){if(typeof n!="object"||!n)return n;var u=n[Symbol.toPrimitive];if(u!==void 0){var c=u.call(n,i);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}function re(n){return n&&n.map((i,u)=>e.createElement(i.tag,W({key:u},i.attr),re(i.child)))}function M(n){return i=>e.createElement(De,$({attr:W({},n.attr)},i),re(n.child))}function De(n){var i=u=>{var{attr:c,size:v,title:w}=n,z=ze(n,Me),L=v||u.size||"1em",E;return u.className&&(E=u.className),n.className&&(E=(E?E+" ":"")+n.className),e.createElement("svg",$({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},u.attr,c,z,{className:E,style:W(W({color:n.color||u.color},u.style),n.style),height:L,width:L,xmlns:"http://www.w3.org/2000/svg"}),w&&e.createElement("title",null,w),n.children)};return te!==void 0?e.createElement(te.Consumer,null,u=>i(u)):i(ee)}function Oe(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 je(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 He(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 _e(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 Fe(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 Pe(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 Ie(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 Be(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 qe(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 Ve(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 Ue(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 $e(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 We(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 Ke(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 Xe(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 Ye=["😀","😁","😂","đŸ¤Ŗ","😃","😄","😅","😉","😊","😍","😘","😜","😎","đŸ˜ĸ","😭","😡","🤔","🙄","😇","đŸĨ°","🤩","🤗","😴","😋","đŸ˜Ŧ","🤤","đŸ˜ļ‍đŸŒĢī¸","😷","🤕","🤑","🤠","😈","đŸ‘ģ","💀","🤖","đŸļ","🐱","đŸŧ","🐸","đŸĻ„","🐷","đŸĩ","🐰","đŸ¯","đŸĻ","🐮","🌞","🌙","⭐","🌈","đŸ”Ĩ","💧","â„ī¸","⚡","â˜€ī¸","🌸","🌹","🍎","🍕","🍩","🍔","🍟","🍇","🍉","🍓","🍒","đŸĨ­","đŸĨ‘","🎉","🎂","🎁","🎈","đŸŽļ","đŸŽĩ","🏆","âšŊ","🏀","🏸","🏏","đŸ•šī¸","👋","🤚","đŸ–ī¸","✋","🖖","👍","👎","👌","🤌","🤏","✊","👊","🤛","🤜","â˜ī¸","👆","👇","👈","👉","🤟","🤘","🤙","🙌","👏","🙏","âœī¸","💅","🤲","👏","đŸĢļ","👐"],oe=({exec:n,saveSelection:i,handleFileChange:u,handleFontSizeChange:c,handleFontFamilyChange:v,insertEmoji:w,handleLink:z,removeFormatting:L,visibleActions:E,className:O,style:F})=>{var X,P;const N=e.useRef(null),T=e.useRef(null),x=e.useRef(null),[Z,I]=e.useState(!1);e.useEffect(()=>{const f=C=>{!C.target.closest(".rte-emoji-popup")&&!C.target.closest("button[title='Emoji']")&&I(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const j=f=>{var V;f.preventDefault();const C=f.currentTarget.dataset.command;if(C)switch(C){case"bold":case"italic":case"underline":case"insertUnorderedList":case"insertOrderedList":case"removeFormat":n(C);break;case"insertImage":{(V=N.current)==null||V.click();break}default:console.warn("Unknown command:",C)}},H=f=>{n("foreColor",f.target.value)},B=f=>{n("backColor",f.target.value)},[y,q]=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 f=()=>{q({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",f),()=>document.removeEventListener("selectionchange",f)},[]),e.createElement("div",{className:`rte-toolbar ${O||""}`,style:F},E.bold&&e.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:j,className:y.bold?"rte-active":""},e.createElement(Pe,null)),E.italic&&e.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:j,className:y.italic?"rte-active":""},e.createElement(Be,null)),E.underline&&e.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:j,className:y.underline?"rte-active":""},e.createElement(We,null)),E.unorderedList&&e.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:j,title:"UnorderedList",className:y.unorderedList?"rte-active":""},e.createElement(Ve,null)),E.orderedList&&e.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:j,className:y.orderedList?"rte-active":""},e.createElement(_e,null)),E.link&&e.createElement("button",{"data-command":"createLink",title:"Link",onClick:z,className:y.link?"rte-active":""},e.createElement(qe,null)),E.removeFormat&&e.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:f=>{f.preventDefault(),i(),L()},className:y.removeFormat?"rte-active":""},e.createElement(Xe,null)),E.image&&e.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:j,className:y.image?"rte-active":""},e.createElement(He,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:f=>{f.preventDefault(),i(),I(C=>!C)},className:y.emoji?"rte-active":""},e.createElement(Ue,null)),Z&&e.createElement("div",{className:"rte-emoji-popup"},Ye.map(f=>e.createElement("span",{key:f,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:C=>{C.preventDefault(),w(f),I(!1)}},f)))),E.color&&e.createElement("div",{style:{position:"relative"}},e.createElement("button",{title:"Text Color",onMouseDown:f=>{var C;f.preventDefault(),i(),(C=T.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((X=T.current)==null?void 0:X.value)||"#000",fontSize:"18px"},className:y.color?"rte-active":""},e.createElement(Ke,null)),e.createElement("input",{ref:T,type:"color",defaultValue:"#000000",onChange:f=>{var C;H(f),((C=f.target.parentElement)==null?void 0:C.querySelector("button")).style.color=f.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:f=>{var C;f.preventDefault(),i(),(C=x.current)==null||C.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((P=x.current)==null?void 0:P.value)||"#000",fontSize:"18px"},className:y.highlight?"rte-active":""},e.createElement(Ie,null)),e.createElement("input",{ref:x,type:"color",onChange:f=>{var C;B(f),((C=f.target.parentElement)==null?void 0:C.querySelector("button")).style.color=f.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:f=>f.preventDefault(),onClick:()=>n("justifyLeft"),className:y.alignLeft?"rte-active":""},e.createElement(Fe,null)),e.createElement("button",{title:"Align Center",onMouseDown:f=>f.preventDefault(),onClick:()=>n("justifyCenter"),className:y.alignCenter?"rte-active":""},e.createElement(Oe,null)),e.createElement("button",{title:"Align Right",onMouseDown:f=>f.preventDefault(),onClick:()=>n("justifyRight"),className:y.alignRight?"rte-active":""},e.createElement(je,null))),E.table&&e.createElement("button",{title:"Insert Table",onMouseDown:f=>f.preventDefault(),onClick:()=>n("insertTable"),className:y.table?"rte-active":""},e.createElement($e,null)),E.fontFamily&&e.createElement("select",{className:"rte-dropdown",defaultValue:"",onMouseDown:()=>i(),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:()=>i(),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")))},Ze=({show:n,position:i,filtered:u,insertMention:c,onClose:v,query:w})=>{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:i.y,left:i.x}},u.length>0?u.map(({key:L,value:E})=>{const O=L.toLowerCase(),F=w.toLowerCase(),N=O.indexOf(F);let T=L;if(N!==-1&&w.length>0){const x=N+w.length;T=L.substring(0,N)+`<span class="rte-highlight">${L.substring(N,x)}</span>`+L.substring(x)}return e.createElement("li",{key:E,onMouseDown:x=>{x.preventDefault(),c({key:L,value:E})},style:{padding:"6px 12px",cursor:"pointer",fontSize:"14px"},dangerouslySetInnerHTML:{__html:T},onMouseEnter:x=>x.currentTarget.style.background="#f0f0f0",onMouseLeave:x=>x.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 K(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 Qe=({visible:n,x:i,y:u,onAction:c,onClose:v})=>{if(!n)return null;const w={top:u,left:i};return e.createElement("div",{style:w,className:"rte-table-menu",onMouseLeave:v},e.createElement("button",{onClick:()=>c("insertRowAbove")},e.createElement(K,null)," Insert row above"),e.createElement("button",{onClick:()=>c("insertRowBelow")},e.createElement(K,null)," Insert row below"),e.createElement("button",{onClick:()=>c("insertColLeft")},e.createElement(K,null)," Insert col left"),e.createElement("button",{onClick:()=>c("insertColRight")},e.createElement(K,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:i,style:u})=>{const c=v=>{const w=v.target;if(w.tagName==="A"){v.preventDefault();const z=w.href;z&&window.open(z,"_blank","noopener,noreferrer")}};return e.createElement("div",{className:`rte-preview ${i||""}`,style:u,onClick:c,dangerouslySetInnerHTML:{__html:n}})},Je=({visible:n,linkData:i,onClose:u,onInsert:c})=>{const[v,w]=e.useState(""),[z,L]=e.useState(""),[E,O]=e.useState(""),[F,N]=e.useState("_self");if(e.useEffect(()=>{n?(w(i.url||""),L(i.text||""),O(i.title||""),N(i.target||"_self")):(w(""),L(""),O(""),N("_self"))},[n,i]),!n)return null;const T=()=>{c({url:v,text:z,title:E,target:F})};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:x=>w(x.target.value)}),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Text to Display",value:z,onChange:x=>L(x.target.value)}),e.createElement("input",{type:"text",className:"rte-link-modal__input",placeholder:"Title",value:E,onChange:x=>O(x.target.value)}),e.createElement("select",{className:"rte-link-modal__select",value:F,onChange:x=>N(x.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:T},"OK"))))},Re=({atSuggestions:n=[],showOutput:i=!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:w={},handleGetHtml:z=()=>{},onChange:L=()=>{}})=>{var ge,he,pe,ve,Ee,we,ye,Ce;const E=e.useRef(null),[O,F]=e.useState("<p>Hello!</p>"),[N,T]=e.useState(!1),[x,Z]=e.useState({x:0,y:0}),[I,j]=e.useState([]),H=e.useRef(null),B=e.useRef(null),[y,q]=e.useState({visible:!1,x:0,y:0}),[X,P]=e.useState(!1),f=e.useRef(null),[C,V]=e.useState({url:"",text:"",title:"",target:"_self"}),Ge={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(ge=c.link)!=null?ge:!1,image:(he=c.image)!=null?he:!1,emoji:(pe=c.emoji)!=null?pe:!1,table:(ve=c.table)!=null?ve:!1,color:(Ee=c.color)!=null?Ee:!1,fontFamily:(we=c.fontFamily)!=null?we:!1,fontSize:(ye=c.fontSize)!=null?ye:!1,highlight:(Ce=c.fontSize)!=null?Ce:!1},[et,ie]=e.useState(""),_=()=>E.current,k=()=>{const t=fe();F(t),z==null||z(t);const r=Ct(t);L(r)},se=()=>{const t=window.getSelection();t!=null&&t.rangeCount&&(H.current=t.getRangeAt(0))},U=()=>{const t=window.getSelection();t&&H.current&&(t.removeAllRanges(),t.addRange(H.current))},tt=(t,r)=>{const o=window.getSelection();o&&o.rangeCount>0&&(H.current=o.getRangeAt(0)),U(),document.execCommand(t,!1,r),k()};e.useEffect(()=>{const t=_();t&&!t.innerHTML&&(t.innerHTML=O),k()},[]),e.useEffect(()=>()=>{document.removeEventListener("mousemove",null),document.removeEventListener("mouseup",null)},[]);const ce=t=>{for(;t&&t.nodeName!=="LI";)t=t.parentNode;return t},nt=t=>{let r=0,o=t.parentElement;for(;o;)(o.tagName==="UL"||o.tagName==="OL")&&r++,o=o.parentElement;return r},rt=t=>{const r=t.querySelector("li"),o=r?nt(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 s=document.createElement("span");s.textContent=d,s.style.display="none",s.setAttribute("data-hidden-array-end","true"),t.appendChild(s)},ue=t=>{var h;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),l=ce(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=_();if(a=m==null?void 0:m.querySelector(`${t}:last-child`),!a)return;d=a.querySelector("li:last-child")}rt(a);const s=document.createRange();s.setStart(d,0),s.collapse(!0),r.removeAllRanges(),r.addRange(s),(h=_())==null||h.focus(),k()},Y=(t,r)=>{t==="insertOrderedList"?ue("ol"):t==="insertUnorderedList"?ue("ul"):tt(t,r),t==="insertTable"&&dt()},ot=t=>{const r=document.createElement("span");r.textContent="​",t.insertNode(r),t.setStartAfter(r),t.collapse(!0);const o=r.getBoundingClientRect();r.remove(),Z({x:o.left,y:o.bottom+window.scrollY}),j(n||[]),T(!0),B.current=t.cloneRange()},lt=()=>{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,s=d.lastIndexOf("@",a-1);if(s!==-1){const h=document.createRange();return h.setStart(l,s),h.setEnd(l,a),h}}l=l.previousSibling}return null},at=t=>{var d;const r=window.getSelection();if(!r)return;const o=lt();o?(r.removeAllRanges(),r.addRange(o)):B.current&&(r.removeAllRanges(),r.addRange(B.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 a=r.rangeCount?r.getRangeAt(0):null;if(a)a.deleteContents(),a.insertNode(l);else{const m=document.createRange(),p=_();m.selectNodeContents(p),m.collapse(!1),m.insertNode(l)}const s=document.createTextNode(" ");l.after(s);const h=document.createRange();h.setStartAfter(s),h.collapse(!0),r.removeAllRanges(),r.addRange(h)}catch(a){console.error("insertMention error:",a)}T(!1),(d=_())==null||d.focus(),k()},it=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(),s=a!=null&&a.anchorNode?ce(a.anchorNode):null;if(!s)return;if(((o=s.textContent)==null?void 0:o.replace(/\u200B/g,"").trim())===""){t.preventDefault();const m=s.parentElement,p=m==null?void 0:m.closest("li");if(p){m==null||m.removeChild(s);const g=document.createElement("p");g.innerHTML="<br />",(l=p.parentElement)==null||l.insertBefore(g,p.nextSibling);const b=document.createRange();b.setStart(g,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(b)}else{const g=s.closest("ul, ol");if(g){const b=document.createElement("p");b.innerHTML="<br />",(d=g.parentElement)==null||d.insertBefore(b,g.nextSibling),g.removeChild(s);const A=document.createRange();A.setStart(b,0),A.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(A)}}k()}}},st=t=>{if(t.data==="@"){const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;setTimeout(()=>{ot(o.getRangeAt(0)),ie(""),j(n),T(!0)},0);return}if(N){setTimeout(()=>de(),0);return}},de=()=>{if(k(),!N)return;const t=window.getSelection();if(!t||!t.anchorNode)return;const o=(t.anchorNode.textContent||"").match(/@([a-zA-Z0-9_]*)$/);if(!o){T(!1);return}const l=o[1].toLowerCase();ie(l);const d=n.filter(a=>a.key.toLowerCase().includes(l));j(d)},ct=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;U();const s=window.getSelection();let h=s&&s.rangeCount?s.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=_();if(!h||!p){p==null||p.appendChild(m);const be=document.createTextNode(" ");p==null||p.appendChild(be);const J=document.createRange();J.setStartAfter(be),J.collapse(!0),s==null||s.removeAllRanges(),s==null||s.addRange(J),p==null||p.focus(),k(),t.target.value="";return}h.deleteContents(),h.insertNode(m);const g=document.createTextNode(" ");m.after(g);const b=document.createRange();b.setStartAfter(g),b.collapse(!0),s.removeAllRanges(),s.addRange(b),p.focus(),k(),t.target.value=""},o.readAsDataURL(r)},ut=t=>{var d;U();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=_())==null||d.focus(),k()},dt=()=>{U();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),pt(t),mt(t);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(t),k()},mt=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",s=>{s.preventDefault(),o=s.clientX,l=s.clientY;const h=t.getBoundingClientRect();d=h.width,a=h.height;const m=g=>{const b=Math.max(100,d+(g.clientX-o)),A=Math.max(60,a+(g.clientY-l));t.style.width=`${b}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"}),ft(t,r,o),t.appendChild(r),t.appendChild(o)},ft=(t,r,o)=>{let l=0,d=0,a=0,s=0;r.addEventListener("mousedown",g=>{g.preventDefault(),l=g.clientX,a=t.offsetWidth,document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)}),o.addEventListener("mousedown",g=>{g.preventDefault(),d=g.clientY,s=t.offsetHeight,document.addEventListener("mousemove",m),document.addEventListener("mouseup",p)});const h=g=>{const b=a+(g.clientX-l);t.style.width=`${Math.max(30,b)}px`},m=g=>{const b=s+(g.clientY-d);t.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",p)}},gt=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"),q({visible:!0,x:t.clientX,y:t.clientY,cell:o}))},me=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(t=>t.classList.remove("rte-cell-highlight"))},ht=t=>{if(!y.cell)return;const r=y.cell.closest("table"),o=y.cell.cellIndex,l=y.cell.parentElement.rowIndex,d=a=>{const s=a.tagName.toLowerCase(),h=document.createElement(s);return h.textContent=a.textContent||"",h.style.cssText=a.style.cssText,Q(h),h};switch(t){case"insertRowAbove":{const a=r.rows[l],s=r.insertRow(l);Array.from(a.cells).forEach(h=>{s.appendChild(d(h))});break}case"insertRowBelow":{const a=r.rows[l],s=r.insertRow(l+1);Array.from(a.cells).forEach(h=>{s.appendChild(d(h))});break}case"insertColLeft":{Array.from(r.rows).forEach(a=>{const s=a.cells[o];a.insertBefore(d(s),s)});break}case"insertColRight":{Array.from(r.rows).forEach(a=>{const s=a.cells[o];a.insertBefore(d(s),s.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(),q(G(R({},y),{visible:!1})),me()},pt=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)},fe=()=>{const t=_();if(!t)return O;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},vt=()=>{se(),f.current=H.current,V({url:"",text:"",title:"",target:"_self"}),P(!0)},Et=t=>{const r=window.getSelection();if(!r||!f.current)return;r.removeAllRanges(),r.addRange(f.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 s=document.createRange();s.setStartAfter(a),s.collapse(!0),r.removeAllRanges(),r.addRange(s),P(!1),k()},wt=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),f.current=l,V({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),P(!0)}},yt=()=>{const t=_();if(!t)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&H.current){const g=window.getSelection();g==null||g.removeAllRanges(),g==null||g.addRange(H.current)}const o=window.getSelection();if(!o||o.rangeCount===0)return;const l=o.getRangeAt(0);U(),document.execCommand("removeFormat",!1);const d=l.cloneContents(),a=document.createElement("div");a.appendChild(d);const s=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),h=[];for(;s.nextNode();){const g=s.currentNode,b=g.tagName.toUpperCase(),A=g.getAttribute&&g.getAttribute("data-mention")!==null;b!=="A"&&!A&&h.push(g)}for(let g=h.length-1;g>=0;g--){const b=h[g],A=b.parentNode;if(A){for(;b.firstChild;)A.insertBefore(b.firstChild,b);A.removeChild(b)}}a.querySelectorAll("[style]").forEach(g=>g.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()},Ct=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(d=>{d.insertAdjacentText("afterend",`
3
+ `)}),o.querySelectorAll("table").forEach(d=>{d.insertAdjacentText("afterend",`
4
+ `)}),((l=o.textContent)==null?void 0:l.replace(/\n{3,}/g,`
5
+
6
+ `).trim())||""};return e.createElement("div",{className:`rte-wrapper ${(v==null?void 0:v.wrapper)||""}`,style:w.wrapper},e.createElement("div",{style:{flex:1}},e.createElement(oe,{exec:Y,saveSelection:se,handleFileChange:ct,handleFontSizeChange:t=>Y("fontSize",t.target.value),handleFontFamilyChange:t=>Y("fontName",t.target.value),insertEmoji:ut,handleLink:vt,removeFormatting:yt,visibleActions:Ge,className:v.toolbar,style:w.toolbar}),e.createElement("div",{ref:E,className:`rte-editor ${(v==null?void 0:v.editor)||""}`,style:w.editor,contentEditable:!0,suppressContentEditableWarning:!0,onInput:de,onKeyDown:it,onBeforeInput:st,onContextMenu:gt,onClick:wt}),e.createElement(Ze,{show:N,position:x,filtered:I,insertMention:at,onClose:()=>T(!1),query:et}),i&&e.createElement("div",{className:`rte-output ${(v==null?void 0:v.output)||""}`,style:w.output},e.createElement("h4",null,"Output HTML:"),e.createElement("p",null,O)),e.createElement(Qe,{visible:y.visible,x:y.x,y:y.y,onAction:ht,onClose:()=>{q(G(R({},y),{visible:!1})),me()}}),e.createElement(Je,{visible:X,linkData:C,onClose:()=>P(!1),onInsert:Et})),u?e.createElement(ae,{className:v.preview,style:w.preview,html:fe()}):null)};S.RichTextEditor=Re,S.RtePreview=ae,S.RteToolbar=oe,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
@@ -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}.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}table{border-collapse:collapse;width:100%;border:1px solid #ccc}th,td{border:1px solid #ccc;background:#fff;padding:6px;min-width:60px;position:relative}th{background-color:#d3d3d3}th div,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:absolute;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:absolute;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}
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:absolute;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}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryzeup/richtexteditor",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A React Rich Text Editor component",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
package/dist/vite.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>