@ryzeup/richtexteditor 1.0.5 â 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +542 -570
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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");var Ee={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ge=t.createContext&&t.createContext(Ee),Ye=["attr","size","title"];function Ze(n,c){if(n==null)return{};var i=Qe(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 Qe(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){Je(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 Je(n,c,i){return c=Ge(c),c in n?Object.defineProperty(n,c,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[c]=i,n}function Ge(n){var c=et(n,"string");return typeof c=="symbol"?c:c+""}function et(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 we(n){return n&&n.map((c,i)=>t.createElement(c.tag,U({key:i},c.attr),we(c.child)))}function M(n){return c=>t.createElement(tt,$({attr:U({},n.attr)},c),we(n.child))}function tt(n){var c=i=>{var{attr:u,size:v,title:y}=n,x=Ze(n,Ye),R=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,x,{className:E,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(Ee)}function nt(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 rt(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 ot(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 at(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 lt(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 ct(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 it(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 st(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 ut(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 dt(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 mt(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 ht(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 ft(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 gt(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 pt(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 vt=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],ye=({exec:n,saveSelection:c,handleFileChange:i,handleFontSizeChange:u,handleFontFamilyChange:v,insertEmoji:y,handleLink:x,removeFormatting:R,visibleActions:E,className:O,style:A})=>{var _,P;const L=t.useRef(null),T=t.useRef(null),C=t.useRef(null),[q,H]=t.useState(!1);t.useEffect(()=>{const m=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&H(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const z=m=>{var I;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":{(I=L.current)==null||I.click();break}default:console.warn("Unknown command:",w)}},j=m=>{n("foreColor",m.target.value)},N=m=>{n("backColor",m.target.value)};return t.createElement("div",{className:`rte-toolbar ${O||""}`,style:A},E.bold&&t.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:z},t.createElement(ct,null)),E.italic&&t.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:z},t.createElement(st,null)),E.underline&&t.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:z},t.createElement(ft,null)),E.unorderedList&&t.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:z,title:"UnorderedList"},t.createElement(dt,null)),E.orderedList&&t.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:z},t.createElement(at,null)),E.link&&t.createElement("button",{"data-command":"createLink",title:"Link",onClick:x},t.createElement(ut,null)),E.removeFormat&&t.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),c(),R()}},t.createElement(pt,null)),E.image&&t.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:z},t.createElement(ot,null)),t.createElement("input",{type:"file",accept:"image/*",ref:L,style:{display:"none"},onChange:i}),E.emoji&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Emoji",onMouseDown:m=>{m.preventDefault(),c(),H(w=>!w)}},t.createElement(mt,null)),q&&t.createElement("div",{className:"rte-emoji-popup"},vt.map(m=>t.createElement("span",{key:m,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:w=>{w.preventDefault(),y(m),H(!1)}},m)))),E.color&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Text Color",onMouseDown:m=>{var w;m.preventDefault(),c(),(w=T.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((_=T.current)==null?void 0:_.value)||"#000",fontSize:"18px"}},t.createElement(gt,null)),t.createElement("input",{ref:T,type:"color",defaultValue:"#000000",onChange:m=>{var w;j(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&&t.createElement("div",{style:{position:"relative"}},t.createElement("button",{title:"Highlight",onMouseDown:m=>{var w;m.preventDefault(),c(),(w=C.current)==null||w.click()},style:{display:"flex",alignItems:"center",justifyContent:"center",color:((P=C.current)==null?void 0:P.value)||"#000",fontSize:"18px"}},t.createElement(it,null)),t.createElement("input",{ref:C,type:"color",onChange:m=>{var w;N(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&&t.createElement(t.Fragment,null,t.createElement("button",{title:"Align Left",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyLeft")},t.createElement(lt,null)),t.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyCenter")},t.createElement(nt,null)),t.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyRight")},t.createElement(rt,null))),E.table&&t.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>n("insertTable")},t.createElement(ht,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")))},Et=({show:n,position:c,filtered:i,insertMention:u,onClose:v,query:y})=>{const x=t.useRef(null);return t.useEffect(()=>{const R=E=>{x.current&&!x.current.contains(E.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:E})=>{const O=R.toLowerCase(),A=y.toLowerCase(),L=O.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:E,onMouseDown:C=>{C.preventDefault(),u({key:R,value:E})},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 wt=({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}})},yt=({visible:n,linkData:c,onClose:i,onInsert:u})=>{const[v,y]=t.useState(""),[x,R]=t.useState(""),[E,O]=t.useState(""),[A,L]=t.useState("_self");if(t.useEffect(()=>{n?(y(c.url||""),R(c.text||""),O(c.title||""),L(c.target||"_self")):(y(""),R(""),O(""),L("_self"))},[n,c]),!n)return null;const T=()=>{u({url:v,text:x,title:E,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:E,onChange:C=>O(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"))))},bt=({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),[E,O]=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}),[P,m]=t.useState(!1),w=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(""),D=()=>R.current,S=()=>{var r,o;O((o=(r=D())==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))},F=()=>{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)),F(),document.execCommand(e,!1,r),S()};t.useEffect(()=>{const e=D();e&&!e.innerHTML&&(e.innerHTML=E),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=D();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=D())==null||g.focus(),S()},B=(e,r)=>{e==="insertOrderedList"?ee("ol"):e==="insertUnorderedList"?ee("ul"):xe(e,r),e==="insertTable"&&Oe()},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=D();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=D())==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;F();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=D();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)},De=e=>{var h;F();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=D())==null||h.focus(),S()},Oe=()=>{F();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),Pe(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"))},Fe=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()},Pe=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=D();if(!e)return E;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(),w.current=z.current,Z({url:"",text:"",title:"",target:"_self"}),m(!0)},Be=e=>{const r=window.getSelection();if(!r||!w.current)return;r.removeAllRanges(),r.addRange(w.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),w.current=a,Z({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),m(!0)}},$e=()=>{const e=D();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);F(),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:De,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(Et,{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,E)),t.createElement(wt,{visible:N.visible,x:N.x,y:N.y,onAction:Fe,onClose:()=>{_(Y(X({},N),{visible:!1})),ne()}}),t.createElement(yt,{visible:P,linkData:I,onClose:()=>m(!1),onInsert:Be})),i?t.createElement(be,{className:v.preview,style:y.preview,html:re()}):null)};exports.RichTextEditor=bt;exports.RtePreview=be;exports.RteToolbar=ye;
|
|
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;
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 Et=Object.defineProperty,wt=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var be=Object.getOwnPropertySymbols;var bt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable;var Ce=(L,e,T)=>e in L?Et(L,e,{enumerable:!0,configurable:!0,writable:!0,value:T}):L[e]=T,J=(L,e)=>{for(var T in e||(e={}))bt.call(e,T)&&Ce(L,T,e[T]);if(be)for(var T of be(e))Ct.call(e,T)&&Ce(L,T,e[T]);return L},G=(L,e)=>wt(L,yt(e));var T={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},R=e.createContext&&e.createContext(T),xe=["attr","size","title"];function Le(n,i){if(n==null)return{};var u=Me(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 Me(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 $(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?$(Object(u),!0).forEach(function(c){Se(n,c,u[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(u)):$(Object(u)).forEach(function(c){Object.defineProperty(n,c,Object.getOwnPropertyDescriptor(u,c))})}return n}function Se(n,i,u){return i=ze(i),i in n?Object.defineProperty(n,i,{value:u,enumerable:!0,configurable:!0,writable:!0}):n[i]=u,n}function ze(n){var i=ke(n,"string");return typeof i=="symbol"?i:i+""}function ke(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 ee(n){return n&&n.map((i,u)=>e.createElement(i.tag,U({key:u},i.attr),ee(i.child)))}function M(n){return i=>e.createElement(Ne,V({attr:U({},n.attr)},i),ee(n.child))}function Ne(n){var i=u=>{var{attr:c,size:v,title:y}=n,S=Le(n,xe),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 R!==void 0?e.createElement(R.Consumer,null,u=>i(u)):i(T)}function Ae(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 Te(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 De(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 Oe(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 He(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 _e(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 je(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 Fe(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 Pe(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 Ie(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 Be(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 Ve(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 Ue(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 qe(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 We(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 Ke=["đ","đ","đ","đ¤Ŗ","đ","đ","đ
","đ","đ","đ","đ","đ","đ","đĸ","đ","đĄ","đ¤","đ","đ","đĨ°","đ¤Š","đ¤","đ´","đ","đŦ","đ¤¤","đļâđĢī¸","đˇ","đ¤","đ¤","đ¤ ","đ","đģ","đ","đ¤","đļ","đą","đŧ","đ¸","đĻ","đˇ","đĩ","đ°","đ¯","đĻ","đŽ","đ","đ","â","đ","đĨ","đ§","âī¸","âĄ","âī¸","đ¸","đš","đ","đ","đŠ","đ","đ","đ","đ","đ","đ","đĨ","đĨ","đ","đ","đ","đ","đļ","đĩ","đ","âŊ","đ","đ¸","đ","đšī¸","đ","đ¤","đī¸","â","đ","đ","đ","đ","đ¤","đ¤","â","đ","đ¤","đ¤","âī¸","đ","đ","đ","đ","đ¤","đ¤","đ¤","đ","đ","đ","âī¸","đ
","đ¤˛","đ","đĢļ","đ"],te=({exec:n,saveSelection:i,handleFileChange:u,handleFontSizeChange:c,handleFontFamilyChange:v,insertEmoji:y,handleLink:S,removeFormatting:x,visibleActions:E,className:j,style:O})=>{var P,W;const z=e.useRef(null),H=e.useRef(null),C=e.useRef(null),[Y,F]=e.useState(!1);e.useEffect(()=>{const m=w=>{!w.target.closest(".rte-emoji-popup")&&!w.target.closest("button[title='Emoji']")&&F(!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)},D=m=>{n("backColor",m.target.value)};return e.createElement("div",{className:`rte-toolbar ${j||""}`,style:O},E.bold&&e.createElement("button",{"data-command":"bold",title:"Bold",onMouseDown:N},e.createElement(_e,null)),E.italic&&e.createElement("button",{"data-command":"italic",title:"Italic",onMouseDown:N},e.createElement(Fe,null)),E.underline&&e.createElement("button",{"data-command":"underline",title:"Underline",onMouseDown:N},e.createElement(Ue,null)),E.unorderedList&&e.createElement("button",{"data-command":"insertUnorderedList",onMouseDown:N,title:"UnorderedList"},e.createElement(Ie,null)),E.orderedList&&e.createElement("button",{"data-command":"insertOrderedList",title:"OrderedList",onMouseDown:N},e.createElement(Oe,null)),E.link&&e.createElement("button",{"data-command":"createLink",title:"Link",onClick:S},e.createElement(Pe,null)),E.removeFormat&&e.createElement("button",{"data-command":"Remove format",title:"removeFormat",onMouseDown:m=>{m.preventDefault(),i(),x()}},e.createElement(We,null)),E.image&&e.createElement("button",{"data-command":"insertImage",title:"Image",onMouseDown:N},e.createElement(De,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(),F(w=>!w)}},e.createElement(Be,null)),Y&&e.createElement("div",{className:"rte-emoji-popup"},Ke.map(m=>e.createElement("span",{key:m,style:{fontSize:"20px",cursor:"pointer",textAlign:"center"},onMouseDown:w=>{w.preventDefault(),y(m),F(!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:((P=H.current)==null?void 0:P.value)||"#000",fontSize:"18px"}},e.createElement(qe,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(je,null)),e.createElement("input",{ref:C,type:"color",onChange:m=>{var w;D(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(He,null)),e.createElement("button",{title:"Align Center",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyCenter")},e.createElement(Ae,null)),e.createElement("button",{title:"Align Right",onMouseDown:m=>m.preventDefault(),onClick:()=>n("justifyRight")},e.createElement(Te,null))),E.table&&e.createElement("button",{title:"Insert Table",onMouseDown:m=>m.preventDefault(),onClick:()=>n("insertTable")},e.createElement(Ve,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")))},Xe=({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(),O=y.toLowerCase(),z=j.indexOf(O);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 ne(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 Ye=({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(ne,null)," Delete row"),e.createElement("button",{onClick:()=>c("deleteCol")},e.createElement(ne,null)," Delete column"))},re=({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}})},Ze=({visible:n,linkData:i,onClose:u,onInsert:c})=>{const[v,y]=e.useState(""),[S,x]=e.useState(""),[E,j]=e.useState(""),[O,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:O})};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:O,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"))))},Qe=({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 me,he,fe,ge,pe,ve,Ee,we;const x=e.useRef(null),[E,j]=e.useState("<p>Always bet on Prime!</p>"),[O,z]=e.useState(!1),[H,C]=e.useState({x:0,y:0}),[Y,F]=e.useState([]),N=e.useRef(null),I=e.useRef(null),[D,P]=e.useState({visible:!1,x:0,y:0}),[W,m]=e.useState(!1),w=e.useRef(null),[K,oe]=e.useState({url:"",text:"",title:"",target:"_self"}),Je={bold:!0,italic:!0,underline:!0,removeFormat:!0,unorderedList:!0,orderedList:!0,align:!0,link:(me=c.link)!=null?me:!1,image:(he=c.image)!=null?he:!1,emoji:(fe=c.emoji)!=null?fe:!1,table:(ge=c.table)!=null?ge:!1,color:(pe=c.color)!=null?pe:!1,fontFamily:(ve=c.fontFamily)!=null?ve:!1,fontSize:(Ee=c.fontSize)!=null?Ee:!1,highlight:(we=c.fontSize)!=null?we:!1},[Ge,le]=e.useState(""),_=()=>x.current,k=()=>{var r,o;j((o=(r=_())==null?void 0:r.innerHTML)!=null?o:"");const t=de();S==null||S(t)},ae=()=>{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))},Re=(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 ie=t=>{for(;t&&t.nodeName!=="LI";)t=t.parentNode;return t},$e=t=>{let r=0,o=t.parentElement;for(;o;)(o.tagName==="UL"||o.tagName==="OL")&&r++,o=o.parentElement;return r},et=t=>{const r=t.querySelector("li"),o=r?$e(r):1;if(t.querySelector("[data-hidden-array-start]"))return;const l=`{{#arrayData${o>1?o:""}}}`,h=`{{/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=h,s.style.display="none",s.setAttribute("data-hidden-array-end","true"),t.appendChild(s)},se=t=>{var g;const r=window.getSelection();if(!(r!=null&&r.rangeCount))return;const o=r.getRangeAt(0),l=ie(o.startContainer);let h,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,h=document.createElement("li"),h.textContent="â",a.appendChild(h)}else{document.execCommand(t==="ul"?"insertUnorderedList":"insertOrderedList");const d=_();if(a=d==null?void 0:d.querySelector(`${t}:last-child`),!a)return;h=a.querySelector("li:last-child")}et(a);const s=document.createRange();s.setStart(h,0),s.collapse(!0),r.removeAllRanges(),r.addRange(s),(g=_())==null||g.focus(),k()},X=(t,r)=>{t==="insertOrderedList"?se("ol"):t==="insertUnorderedList"?se("ul"):Re(t,r),t==="insertTable"&&st()},tt=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}),F(n||[]),z(!0),I.current=t.cloneRange()},nt=()=>{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 h=l.textContent||"",a=l===r?o:h.length,s=h.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},rt=t=>{var h;const r=window.getSelection();if(!r)return;const o=nt();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),(h=_())==null||h.focus(),k()},ot=t=>{var o,l,h;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?ie(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 f=document.createElement("p");f.innerHTML="<br />",(l=p.parentElement)==null||l.insertBefore(f,p.nextSibling);const b=document.createRange();b.setStart(f,0),b.collapse(!0),a==null||a.removeAllRanges(),a==null||a.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 A=document.createRange();A.setStart(b,0),A.collapse(!0),a==null||a.removeAllRanges(),a==null||a.addRange(A)}}k()}}},lt=t=>{if(t.data==="@"){const o=window.getSelection();if(!(o!=null&&o.rangeCount))return;setTimeout(()=>{tt(o.getRangeAt(0)),le(""),F(n),z(!0)},0);return}if(O){setTimeout(()=>ce(),0);return}},ce=()=>{if(k(),!O)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();le(l);const h=n.filter(a=>a.key.toLowerCase().includes(l));F(h)},at=t=>{var l;const r=(l=t.target.files)==null?void 0:l[0];if(!r)return;const o=new FileReader;o.onload=h=>{var A;const a=(A=h.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 ye=document.createTextNode(" ");p==null||p.appendChild(ye);const Q=document.createRange();Q.setStartAfter(ye),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 f=document.createTextNode(" ");d.after(f);const b=document.createRange();b.setStartAfter(f),b.collapse(!0),s.removeAllRanges(),s.addRange(b),p.focus(),k(),t.target.value=""},o.readAsDataURL(r)},it=t=>{var h;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),(h=_())==null||h.focus(),k()},st=()=>{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"),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",Z(d),Z(p),l.appendChild(d),h.appendChild(p)}r.appendChild(l),o.appendChild(h),t.appendChild(r),t.appendChild(o),ht(t),ct(t);const a=window.getSelection();if(!(a!=null&&a.rangeCount))return;a.getRangeAt(0).insertNode(t),k()},ct=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,h=0,a=0;r.addEventListener("mousedown",s=>{s.preventDefault(),o=s.clientX,l=s.clientY;const g=t.getBoundingClientRect();h=g.width,a=g.height;const d=f=>{const b=Math.max(100,h+(f.clientX-o)),A=Math.max(60,a+(f.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"}),ut(t,r,o),t.appendChild(r),t.appendChild(o)},ut=(t,r,o)=>{let l=0,h=0,a=0,s=0;r.addEventListener("mousedown",f=>{f.preventDefault(),l=f.clientX,a=t.offsetWidth,document.addEventListener("mousemove",g),document.addEventListener("mouseup",p)}),o.addEventListener("mousedown",f=>{f.preventDefault(),h=f.clientY,s=t.offsetHeight,document.addEventListener("mousemove",d),document.addEventListener("mouseup",p)});const g=f=>{const b=a+(f.clientX-l);t.style.width=`${Math.max(30,b)}px`},d=f=>{const b=s+(f.clientY-h);t.style.height=`${Math.max(20,b)}px`},p=()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",p)}},dt=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"),P({visible:!0,x:t.clientX,y:t.clientY,cell:o}))},ue=()=>{document.querySelectorAll(".rte-cell-highlight").forEach(t=>t.classList.remove("rte-cell-highlight"))},mt=t=>{if(!D.cell)return;const r=D.cell.closest("table"),o=D.cell.cellIndex,l=D.cell.parentElement.rowIndex,h=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(h(g))});break}case"insertRowBelow":{const a=r.rows[l],s=r.insertRow(l+1);Array.from(a.cells).forEach(g=>{s.appendChild(h(g))});break}case"insertColLeft":{Array.from(r.rows).forEach(a=>{const s=a.cells[o];a.insertBefore(h(s),s)});break}case"insertColRight":{Array.from(r.rows).forEach(a=>{const s=a.cells[o];a.insertBefore(h(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(),P(G(J({},D),{visible:!1})),ue()},ht=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)},de=()=>{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},ft=()=>{ae(),w.current=N.current,oe({url:"",text:"",title:"",target:"_self"}),m(!0)},gt=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 h=r.getRangeAt(0);h.deleteContents(),h.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()},pt=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,oe({url:o.href,text:o.textContent||o.href,title:o.title,target:o.target}),m(!0)}},vt=()=>{const t=_();if(!t)return;const r=window.getSelection();if((!r||r.rangeCount===0)&&N.current){const f=window.getSelection();f==null||f.removeAllRanges(),f==null||f.addRange(N.current)}const o=window.getSelection();if(!o||o.rangeCount===0)return;const l=o.getRangeAt(0);B(),document.execCommand("removeFormat",!1);const h=l.cloneContents(),a=document.createElement("div");a.appendChild(h);const s=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,null),g=[];for(;s.nextNode();){const f=s.currentNode,b=f.tagName.toUpperCase(),A=f.getAttribute&&f.getAttribute("data-mention")!==null;b!=="A"&&!A&&g.push(f)}for(let f=g.length-1;f>=0;f--){const b=g[f],A=b.parentNode;if(A){for(;b.firstChild;)A.insertBefore(b.firstChild,b);A.removeChild(b)}}a.querySelectorAll("[style]").forEach(f=>f.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(te,{exec:X,saveSelection:ae,handleFileChange:at,handleFontSizeChange:t=>X("fontSize",t.target.value),handleFontFamilyChange:t=>X("fontName",t.target.value),insertEmoji:it,handleLink:ft,removeFormatting:vt,visibleActions:Je,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:ce,onKeyDown:ot,onBeforeInput:lt,onContextMenu:dt,onClick:pt}),e.createElement(Xe,{show:O,position:H,filtered:Y,insertMention:rt,onClose:()=>z(!1),query:Ge}),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(Ye,{visible:D.visible,x:D.x,y:D.y,onAction:mt,onClose:()=>{P(G(J({},D),{visible:!1})),ue()}}),e.createElement(Ze,{visible:W,linkData:K,onClose:()=>m(!1),onInsert:gt})),u?e.createElement(re,{className:v.preview,style:y.preview,html:de()}):null)};L.RichTextEditor=Qe,L.RtePreview=re,L.RteToolbar=te,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
|
|
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"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ryzeup/richtexteditor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "A React Rich Text Editor component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -40,18 +40,19 @@
|
|
|
40
40
|
"react-icons": "^5.5.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@babel/preset-react": "^7.28.5",
|
|
43
44
|
"@eslint/js": "^9.36.0",
|
|
44
45
|
"@types/node": "^24.6.0",
|
|
45
46
|
"@types/react": "^19.1.16",
|
|
46
47
|
"@types/react-dom": "^19.1.9",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.45.0",
|
|
49
|
+
"@typescript-eslint/parser": "^8.45.0",
|
|
47
50
|
"@vitejs/plugin-react": "^5.0.4",
|
|
48
51
|
"eslint": "^9.36.0",
|
|
49
52
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
50
53
|
"eslint-plugin-react-refresh": "^0.4.22",
|
|
51
54
|
"globals": "^16.4.0",
|
|
52
55
|
"typescript": "~5.9.3",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^8.45.0",
|
|
54
|
-
"@typescript-eslint/parser": "^8.45.0",
|
|
55
56
|
"vite": "^7.1.7"
|
|
56
57
|
}
|
|
57
58
|
}
|