New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

textcrafter

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textcrafter - npm Package Compare versions

Comparing version 1.0.0-beta.8 to 1.0.0-beta.9

2

dist/index.cjs.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const t=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-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"})),l=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),n=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),a=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 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 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"})),o=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"})),c=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),r=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})),s=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"})),i=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"})),m=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M48.5 224L40 224c-13.3 0-24-10.7-24-24L16 72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8L48.5 224z"})),u=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M463.5 224l8.5 0c13.3 0 24-10.7 24-24l0-128c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8l119.5 0z"})),d=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 256l0-96 160 0 0 96L64 256zm0 64l160 0 0 96L64 416l0-96zm224 96l0-96 160 0 0 96-160 0zM448 256l-160 0 0-96 160 0 0 96zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32z"})),g=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 576 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M290.7 57.4L57.4 290.7c-25 25-25 65.5 0 90.5l80 80c12 12 28.3 18.7 45.3 18.7L288 480l9.4 0L512 480c17.7 0 32-14.3 32-32s-14.3-32-32-32l-124.1 0L518.6 285.3c25-25 25-65.5 0-90.5L381.3 57.4c-25-25-65.5-25-90.5 0zM297.4 416l-9.4 0-105.4 0-80-80L227.3 211.3 364.7 348.7 297.4 416z"})),p="padding: 8px;text-align: center;border: 1px solid #ddd;min-width: 80px;",h=`${p} background-color: #f1f1f1;font-weight: bold;`,b=({onTableCreate:t})=>{const[l,n]=e.useState(0),[a,o]=e.useState(0),c=()=>{t(l+1,a+1)};return e.createElement("div",{className:"table-selector"},[...new Array(8)].map(((t,r)=>e.createElement("div",{key:`row-${r}`,className:"table-selector-row"},[...new Array(8)].map(((t,s)=>e.createElement("div",{key:`col-${s}`,className:"table-selector-cell "+(r<=l&&s<=a?"highlighted":""),onMouseEnter:()=>((e,t)=>{n(e),o(t)})(r,s),onClick:c})))))),e.createElement("div",{className:"table-selector-label"},l+1," x ",a+1))},E=({onCommand:E})=>{const[w,v]=e.useState({}),L=(e,t)=>{let l;return function(...n){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,n)),t)}},y=()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);const l={},n=(e,t)=>{for(;e&&e!==document.body;){if(e.tagName===t)return!0;e=e.parentNode}return!1};l.bold=n(t,"B")||n(t,"STRONG")||"700"===window.getComputedStyle(t).fontWeight,l.italic=n(t,"I")||n(t,"EM")||"italic"===window.getComputedStyle(t).fontStyle,l.underline=n(t,"U")||window.getComputedStyle(t).textDecorationLine.includes("underline"),l.strikeThrough=n(t,"S")||n(t,"STRIKE")||window.getComputedStyle(t).textDecorationLine.includes("line-through");const a=window.getComputedStyle(t).textAlign;l.justifyLeft="left"===a,l.justifyCenter="center"===a,l.justifyRight="right"===a,l.justifyFull="justify"===a,l.insertUnorderedList=n(t,"UL"),l.insertOrderedList=n(t,"OL"),v(l)};return e.useEffect((()=>{const e=L(y,200);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),e.createElement("div",{id:"toolbar",className:"toolbar",onClick:e=>e.stopPropagation()},e.createElement("div",{id:"font-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),E("fontName",e.target.value)}},e.createElement("option",{value:""},"Font Family"),e.createElement("option",{value:"Arial"},"Arial"),e.createElement("option",{value:"Courier New"},"Courier New"),e.createElement("option",{value:"Georgia"},"Georgia"),e.createElement("option",{value:"Tahoma"},"Tahoma"),e.createElement("option",{value:"Times New Roman"},"T New Roman"),e.createElement("option",{value:"Verdana"},"Verdana")),e.createElement("select",{onChange:e=>{e.preventDefault(),E("fontSize",e.target.value)}},e.createElement("option",{value:""},"Font Size"),e.createElement("option",{value:"1"},"Tiny"),e.createElement("option",{value:"2"},"Small"),e.createElement("option",{value:"3"},"Regular"),e.createElement("option",{value:"4"},"Medium"),e.createElement("option",{value:"5"},"Large"),e.createElement("option",{value:"6"},"E.Large"),e.createElement("option",{value:"7"},"Huge"))),e.createElement("div",{id:"text-formatting-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("bold"),style:{fontWeight:"700"},className:w.bold?"active":"","aria-label":"Bold"},"B"),e.createElement("button",{type:"button",onClick:()=>E("italic"),className:w.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),e.createElement("button",{type:"button",onClick:()=>E("underline"),className:w.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),e.createElement("button",{type:"button",onClick:()=>E("strikeThrough"),className:w.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),e.createElement("button",{type:"button",onClick:()=>E("removeFormat"),title:"Clear Formatting"},e.createElement(g,{className:"button-icon"}))),e.createElement("div",{id:"color-group",className:"toolbar-group"},e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),E("foreColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Text Color"}),e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),E("backColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Background Color"})),e.createElement("div",{id:"alignment-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("justifyLeft"),className:w.justifyLeft?"active":""},e.createElement(t,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("justifyCenter"),className:w.justifyCenter?"active":""},e.createElement(l,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("justifyRight"),className:w.justifyRight?"active":""},e.createElement(n,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("justifyFull"),className:w.justifyFull?"active":""},e.createElement(a,{className:"button-icon"}))),e.createElement("div",{id:"list-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("insertUnorderedList"),className:w.insertUnorderedList?"active":""},e.createElement(o,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("insertOrderedList"),className:w.insertOrderedList?"active":""},e.createElement(c,{className:"button-icon"}))),e.createElement("div",{id:"table",className:"toolbar-group"},e.createElement("button",{type:"button",className:"table-selector-button"},e.createElement(d,{className:"button-icon"})),e.createElement("div",{className:"table-selector-container"},e.createElement("div",{className:"table-selector-show"},e.createElement(b,{onTableCreate:(e,t)=>{E("insertHTML",((e,t)=>{let l='<div style="overflow-x: auto; max-width: 100%;"><table id="editor-custom-table" style="width: 100%; border-collapse: collapse; margin: 10px 0;"><thead><tr>';for(let e=0;e<t;e++)l+=`<th style="${h}">Header ${e+1}</th>`;l+="</tr></thead><tbody>";for(let n=0;n<e-1;n++){l+="<tr>";for(let e=0;e<t;e++)l+=`<td style="${p}">Cell ${n+1}-${e+1}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})(e,t))}}),e.createElement("div",{className:"table-option-button"},e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e){const t=e.insertRow(-1);for(let l=0;l<e.rows[0].cells.length;l++){const e=t.insertCell(l);e.innerHTML="New Cell",e.classList.add("table-cell")}}})(),value:"addRow"},"Add Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++){const l=e.rows[t].insertCell(-1);l.innerHTML="New Cell",l.classList.add("table-cell")}})(),value:"addColumn"},"Add Column"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++)e.rows[t].cells.length>1&&e.rows[t].deleteCell(-1)})(),value:"removeColumn"},"Remove Column"),e.createElement("button",{type:"button",onClick:()=>E("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),e.createElement("div",{id:"link-image-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("createLink",prompt("Enter the URL:","https://")||"")},e.createElement(r,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("unlink")},e.createElement(s,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("insertImage",prompt("Enter the image URL:","https://")||"")},e.createElement(i,{className:"button-icon"}))),e.createElement("div",{id:"block-style-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),E("formatBlock",e.target.value)}},e.createElement("option",{value:"p"},"Normal Text"),e.createElement("option",{value:"h1"},"Heading 1"),e.createElement("option",{value:"h2"},"Heading 2"),e.createElement("option",{value:"h3"},"Heading 3"),e.createElement("option",{value:"blockquote"},"Blockquote"),e.createElement("option",{value:"pre"},"Code Block"))),e.createElement("div",{id:"symbol",className:"toolbar-group"},e.createElement("button",{type:"button",className:"symbol-selector-button"},"Symbols"),e.createElement("div",{className:"symbol-selector-container"},e.createElement("div",{className:"symbol-selector-show"},e.createElement("div",{className:"symbol-option-button"},e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&copy;")},"©"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&euro;")},"€"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&trade;")},"™"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&#10077;")},"❝"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&#10078;")},"❞"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&#10003;")},"✓"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","😊")},"😊"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","👍")},"👍"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","🎉")},"🎉"))))),e.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("undo")},e.createElement(m,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("redo")},e.createElement(u,{className:"button-icon"}))))},w=({value:t,onChange:l})=>{const n=e.useRef(null),a=(e,t)=>{if(t)if(t.includes('<table id="editor-custom-table"'))e.innerHTML+=t;else{const e=window.getSelection(),l=null==e?void 0:e.getRangeAt(0);if(l){l.deleteContents();const n=l.createContextualFragment(t);l.insertNode(n);const a=document.createRange();a.setStartAfter(n.lastChild),a.collapse(!0),null==e||e.removeAllRanges(),null==e||e.addRange(a)}}},o=(e,t)=>{document.execCommand(e);const l=window.getSelection(),n=null==l?void 0:l.getRangeAt(0),a=null==n?void 0:n.commonAncestorContainer.parentElement;!a||"UL"!==a.tagName&&"OL"!==a.tagName||a.setAttribute("style",`list-style-position: inside; list-style-type: ${t};`)};return e.useEffect((()=>{n.current&&n.current.innerHTML!==t&&(n.current.innerHTML=t)}),[t]),e.createElement("div",{id:"editor-container",className:"editor-canvas",onClick:e=>{e.target.closest(".toolbar")&&(e.preventDefault(),e.stopPropagation())}},e.createElement(E,{onCommand:(e,t)=>{const c=n.current;if(c)try{switch(e){case"createLink":t&&document.execCommand("createLink",!1,t);break;case"insertImage":t&&document.execCommand("insertImage",!1,t);break;case"formatBlock":t&&document.execCommand("formatBlock",!1,t);break;case"insertHTML":a(c,t);break;case"insertUnorderedList":o(e,"disc");break;case"insertOrderedList":o(e,"decimal");break;default:document.execCommand(e,!1,t||"")}c.focus(),l(c.innerHTML)}catch(e){console.error("Error applying command:",e)}}}),e.createElement("div",{id:"content-area",ref:n,contentEditable:!0,onDrop:e=>{e.preventDefault();Array.from(e.dataTransfer.files).forEach((e=>{const t=new FileReader;t.onload=e=>{var t,a,o;const c=document.createElement("img");c.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(a=n.current)||void 0===a||a.appendChild(c),l((null===(o=n.current)||void 0===o?void 0:o.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:e=>{e.preventDefault(),n.current&&l(n.current.innerHTML)}}))};exports.Editor=w,exports.Toolbar=E,exports.default=w;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const t=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-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"})),l=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),n=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),a=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 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 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"})),o=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"})),c=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),r=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})),s=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"})),i=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"})),m=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M48.5 224L40 224c-13.3 0-24-10.7-24-24L16 72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8L48.5 224z"})),u=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M463.5 224l8.5 0c13.3 0 24-10.7 24-24l0-128c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8l119.5 0z"})),d=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 256l0-96 160 0 0 96L64 256zm0 64l160 0 0 96L64 416l0-96zm224 96l0-96 160 0 0 96-160 0zM448 256l-160 0 0-96 160 0 0 96zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32z"})),g=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 576 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M290.7 57.4L57.4 290.7c-25 25-25 65.5 0 90.5l80 80c12 12 28.3 18.7 45.3 18.7L288 480l9.4 0L512 480c17.7 0 32-14.3 32-32s-14.3-32-32-32l-124.1 0L518.6 285.3c25-25 25-65.5 0-90.5L381.3 57.4c-25-25-65.5-25-90.5 0zM297.4 416l-9.4 0-105.4 0-80-80L227.3 211.3 364.7 348.7 297.4 416z"})),p="padding: 8px;text-align: center;border: 1px solid #ddd;min-width: 80px;",h=`${p} background-color: #f1f1f1;font-weight: bold;`,b=({onTableCreate:t})=>{const[l,n]=e.useState(0),[a,o]=e.useState(0),c=()=>{t(l+1,a+1)};return e.createElement("div",{className:"table-selector"},[...new Array(8)].map(((t,r)=>e.createElement("div",{key:`row-${r}`,className:"table-selector-row"},[...new Array(8)].map(((t,s)=>e.createElement("div",{key:`col-${s}`,className:"table-selector-cell "+(r<=l&&s<=a?"highlighted":""),onMouseEnter:()=>((e,t)=>{n(e),o(t)})(r,s),onClick:c})))))),e.createElement("div",{className:"table-selector-label"},l+1," x ",a+1))},E=({onCommand:E})=>{const[w,v]=e.useState({}),L=(e,t)=>{let l;return function(...n){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,n)),t)}},y=()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);const l={},n=(e,t)=>{for(;e&&e!==document.body;){if(e.tagName===t)return!0;e=e.parentNode}return!1};l.bold=n(t,"B")||n(t,"STRONG")||"700"===window.getComputedStyle(t).fontWeight,l.italic=n(t,"I")||n(t,"EM")||"italic"===window.getComputedStyle(t).fontStyle,l.underline=n(t,"U")||window.getComputedStyle(t).textDecorationLine.includes("underline"),l.strikeThrough=n(t,"S")||n(t,"STRIKE")||window.getComputedStyle(t).textDecorationLine.includes("line-through");const a=window.getComputedStyle(t).textAlign;l.justifyLeft="left"===a,l.justifyCenter="center"===a,l.justifyRight="right"===a,l.justifyFull="justify"===a,l.insertUnorderedList=n(t,"UL"),l.insertOrderedList=n(t,"OL"),v(l)};return e.useEffect((()=>{const e=L(y,200);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),e.createElement("div",{id:"toolbar",className:"toolbar",onClick:e=>e.stopPropagation()},e.createElement("div",{id:"font-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),E("fontName",e.target.value)}},e.createElement("option",{value:""},"Font Family"),e.createElement("option",{value:"Arial"},"Arial"),e.createElement("option",{value:"Courier New"},"Courier New"),e.createElement("option",{value:"Georgia"},"Georgia"),e.createElement("option",{value:"Tahoma"},"Tahoma"),e.createElement("option",{value:"Times New Roman"},"T New Roman"),e.createElement("option",{value:"Verdana"},"Verdana")),e.createElement("select",{onChange:e=>{e.preventDefault(),E("fontSize",e.target.value)}},e.createElement("option",{value:""},"Font Size"),e.createElement("option",{value:"1"},"Tiny"),e.createElement("option",{value:"2"},"Small"),e.createElement("option",{value:"3"},"Regular"),e.createElement("option",{value:"4"},"Medium"),e.createElement("option",{value:"5"},"Large"),e.createElement("option",{value:"6"},"E.Large"),e.createElement("option",{value:"7"},"Huge"))),e.createElement("div",{id:"text-formatting-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("bold"),style:{fontWeight:"700"},className:w.bold?"active":"","aria-label":"Bold"},"B"),e.createElement("button",{type:"button",onClick:()=>E("italic"),className:w.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),e.createElement("button",{type:"button",onClick:()=>E("underline"),className:w.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),e.createElement("button",{type:"button",onClick:()=>E("strikeThrough"),className:w.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),e.createElement("button",{type:"button",onClick:()=>E("removeFormat"),title:"Clear Formatting"},e.createElement(g,{className:"button-icon"}))),e.createElement("div",{id:"color-group",className:"toolbar-group"},e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),E("foreColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Text Color"}),e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),E("backColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Background Color"})),e.createElement("div",{id:"alignment-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("justifyLeft"),className:w.justifyLeft?"active":""},e.createElement(t,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("justifyCenter"),className:w.justifyCenter?"active":""},e.createElement(l,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("justifyRight"),className:w.justifyRight?"active":""},e.createElement(n,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("justifyFull"),className:w.justifyFull?"active":""},e.createElement(a,{className:"button-icon"}))),e.createElement("div",{id:"list-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("insertUnorderedList"),className:w.insertUnorderedList?"active":""},e.createElement(o,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("insertOrderedList"),className:w.insertOrderedList?"active":""},e.createElement(c,{className:"button-icon"}))),e.createElement("div",{id:"table",className:"toolbar-group"},e.createElement("button",{type:"button",className:"table-selector-button"},e.createElement(d,{className:"button-icon"})),e.createElement("div",{className:"table-selector-container"},e.createElement("div",{className:"table-selector-show"},e.createElement(b,{onTableCreate:(e,t)=>{E("insertHTML",((e,t)=>{let l='<div style="overflow-x: auto; max-width: 100%;"><table id="editor-custom-table" style="width: 100%; border-collapse: collapse; margin: 10px 0;"><thead><tr>';for(let e=0;e<t;e++)l+=`<th style="${h}">Header ${e+1}</th>`;l+="</tr></thead><tbody>";for(let n=0;n<e-1;n++){l+="<tr>";for(let e=0;e<t;e++)l+=`<td style="${p}">Cell ${n+1}-${e+1}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})(e,t))}}),e.createElement("div",{className:"table-option-button"},e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e){const t=e.insertRow(-1);for(let l=0;l<e.rows[0].cells.length;l++){const e=t.insertCell(l);e.innerHTML="New Cell",e.classList.add("table-cell")}}})(),value:"addRow"},"Add Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++){const l=e.rows[t].insertCell(-1);l.innerHTML="New Cell",l.classList.add("table-cell")}})(),value:"addColumn"},"Add Column"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++)e.rows[t].cells.length>1&&e.rows[t].deleteCell(-1)})(),value:"removeColumn"},"Remove Column"),e.createElement("button",{type:"button",onClick:()=>E("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),e.createElement("div",{id:"link-image-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("createLink",prompt("Enter the URL:","https://")||"")},e.createElement(r,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("unlink")},e.createElement(s,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("insertImage",prompt("Enter the image URL:","https://")||"")},e.createElement(i,{className:"button-icon"}))),e.createElement("div",{id:"block-style-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),E("formatBlock",e.target.value)}},e.createElement("option",{value:"p"},"Normal Text"),e.createElement("option",{value:"h1"},"Heading 1"),e.createElement("option",{value:"h2"},"Heading 2"),e.createElement("option",{value:"h3"},"Heading 3"),e.createElement("option",{value:"blockquote"},"Blockquote"),e.createElement("option",{value:"pre"},"Code Block"))),e.createElement("div",{id:"symbol",className:"toolbar-group"},e.createElement("button",{type:"button",className:"symbol-selector-button"},"Symbols"),e.createElement("div",{className:"symbol-selector-container"},e.createElement("div",{className:"symbol-selector-show"},e.createElement("div",{className:"symbol-option-button"},e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&copy;")},"©"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&euro;")},"€"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&trade;")},"™"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&#10077;")},"❝"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&#10078;")},"❞"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","&#10003;")},"✓"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","😊")},"😊"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","👍")},"👍"),e.createElement("button",{type:"button",onClick:()=>E("insertHTML","🎉")},"🎉"))))),e.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>E("undo")},e.createElement(m,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>E("redo")},e.createElement(u,{className:"button-icon"}))))},w=({value:t,onChange:l})=>{const n=e.useRef(null),a=(e,t)=>{if(t)if(t.includes('<table id="editor-custom-table"'))e.innerHTML+=t;else{const e=window.getSelection(),l=null==e?void 0:e.getRangeAt(0);if(l){l.deleteContents();const n=l.createContextualFragment(t);l.insertNode(n);const a=document.createRange();a.setStartAfter(n.lastChild),a.collapse(!0),null==e||e.removeAllRanges(),null==e||e.addRange(a)}}},o=(e,t)=>{document.execCommand(e);const l=window.getSelection(),n=null==l?void 0:l.getRangeAt(0);let a=n&&(null==n?void 0:n.commonAncestorContainer);for(;a&&"UL"!==a.tagName&&"OL"!==a.tagName;)a=a.parentElement;!a||"UL"!==a.tagName&&"OL"!==a.tagName||a.setAttribute("style",`list-style-position: inside; list-style-type: ${t};`)};return e.useEffect((()=>{n.current&&n.current.innerHTML!==t&&(n.current.innerHTML=t)}),[t]),e.createElement("div",{id:"editor-container",className:"editor-canvas",onClick:e=>{e.target.closest(".toolbar")&&(e.preventDefault(),e.stopPropagation())}},e.createElement(E,{onCommand:(e,t)=>{const c=n.current;if(c)try{switch(e){case"createLink":t&&document.execCommand("createLink",!1,t);break;case"insertImage":t&&document.execCommand("insertImage",!1,t);break;case"formatBlock":t&&document.execCommand("formatBlock",!1,t);break;case"insertHTML":a(c,t);break;case"insertUnorderedList":o(e,"disc");break;case"insertOrderedList":o(e,"decimal");break;default:document.execCommand(e,!1,t||"")}c.focus(),l(c.innerHTML)}catch(e){console.error("Error applying command:",e)}}}),e.createElement("div",{id:"content-area",ref:n,contentEditable:!0,onDrop:e=>{e.preventDefault();Array.from(e.dataTransfer.files).forEach((e=>{const t=new FileReader;t.onload=e=>{var t,a,o;const c=document.createElement("img");c.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(a=n.current)||void 0===a||a.appendChild(c),l((null===(o=n.current)||void 0===o?void 0:o.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:e=>{e.preventDefault(),n.current&&l(n.current.innerHTML)}}))};exports.Editor=w,exports.Toolbar=E,exports.default=w;

@@ -1,1 +0,1 @@

import e,{useState as t,useEffect as l,useRef as n}from"react";const a=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-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"})),o=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),c=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),r=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 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 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"})),s=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"})),i=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),m=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})),u=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"})),d=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"})),g=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M48.5 224L40 224c-13.3 0-24-10.7-24-24L16 72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8L48.5 224z"})),h=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M463.5 224l8.5 0c13.3 0 24-10.7 24-24l0-128c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8l119.5 0z"})),p=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 256l0-96 160 0 0 96L64 256zm0 64l160 0 0 96L64 416l0-96zm224 96l0-96 160 0 0 96-160 0zM448 256l-160 0 0-96 160 0 0 96zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32z"})),b=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 576 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M290.7 57.4L57.4 290.7c-25 25-25 65.5 0 90.5l80 80c12 12 28.3 18.7 45.3 18.7L288 480l9.4 0L512 480c17.7 0 32-14.3 32-32s-14.3-32-32-32l-124.1 0L518.6 285.3c25-25 25-65.5 0-90.5L381.3 57.4c-25-25-65.5-25-90.5 0zM297.4 416l-9.4 0-105.4 0-80-80L227.3 211.3 364.7 348.7 297.4 416z"})),w="padding: 8px;text-align: center;border: 1px solid #ddd;min-width: 80px;",E=`${w} background-color: #f1f1f1;font-weight: bold;`,v=({onTableCreate:l})=>{const[n,a]=t(0),[o,c]=t(0),r=()=>{l(n+1,o+1)};return e.createElement("div",{className:"table-selector"},[...new Array(8)].map(((t,l)=>e.createElement("div",{key:`row-${l}`,className:"table-selector-row"},[...new Array(8)].map(((t,s)=>e.createElement("div",{key:`col-${s}`,className:"table-selector-cell "+(l<=n&&s<=o?"highlighted":""),onMouseEnter:()=>((e,t)=>{a(e),c(t)})(l,s),onClick:r})))))),e.createElement("div",{className:"table-selector-label"},n+1," x ",o+1))},L=({onCommand:n})=>{const[L,C]=t({}),y=(e,t)=>{let l;return function(...n){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,n)),t)}},N=()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);const l={},n=(e,t)=>{for(;e&&e!==document.body;){if(e.tagName===t)return!0;e=e.parentNode}return!1};l.bold=n(t,"B")||n(t,"STRONG")||"700"===window.getComputedStyle(t).fontWeight,l.italic=n(t,"I")||n(t,"EM")||"italic"===window.getComputedStyle(t).fontStyle,l.underline=n(t,"U")||window.getComputedStyle(t).textDecorationLine.includes("underline"),l.strikeThrough=n(t,"S")||n(t,"STRIKE")||window.getComputedStyle(t).textDecorationLine.includes("line-through");const a=window.getComputedStyle(t).textAlign;l.justifyLeft="left"===a,l.justifyCenter="center"===a,l.justifyRight="right"===a,l.justifyFull="justify"===a,l.insertUnorderedList=n(t,"UL"),l.insertOrderedList=n(t,"OL"),C(l)};return l((()=>{const e=y(N,200);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),e.createElement("div",{id:"toolbar",className:"toolbar",onClick:e=>e.stopPropagation()},e.createElement("div",{id:"font-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),n("fontName",e.target.value)}},e.createElement("option",{value:""},"Font Family"),e.createElement("option",{value:"Arial"},"Arial"),e.createElement("option",{value:"Courier New"},"Courier New"),e.createElement("option",{value:"Georgia"},"Georgia"),e.createElement("option",{value:"Tahoma"},"Tahoma"),e.createElement("option",{value:"Times New Roman"},"T New Roman"),e.createElement("option",{value:"Verdana"},"Verdana")),e.createElement("select",{onChange:e=>{e.preventDefault(),n("fontSize",e.target.value)}},e.createElement("option",{value:""},"Font Size"),e.createElement("option",{value:"1"},"Tiny"),e.createElement("option",{value:"2"},"Small"),e.createElement("option",{value:"3"},"Regular"),e.createElement("option",{value:"4"},"Medium"),e.createElement("option",{value:"5"},"Large"),e.createElement("option",{value:"6"},"E.Large"),e.createElement("option",{value:"7"},"Huge"))),e.createElement("div",{id:"text-formatting-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("bold"),style:{fontWeight:"700"},className:L.bold?"active":"","aria-label":"Bold"},"B"),e.createElement("button",{type:"button",onClick:()=>n("italic"),className:L.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),e.createElement("button",{type:"button",onClick:()=>n("underline"),className:L.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),e.createElement("button",{type:"button",onClick:()=>n("strikeThrough"),className:L.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),e.createElement("button",{type:"button",onClick:()=>n("removeFormat"),title:"Clear Formatting"},e.createElement(b,{className:"button-icon"}))),e.createElement("div",{id:"color-group",className:"toolbar-group"},e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),n("foreColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Text Color"}),e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),n("backColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Background Color"})),e.createElement("div",{id:"alignment-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("justifyLeft"),className:L.justifyLeft?"active":""},e.createElement(a,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("justifyCenter"),className:L.justifyCenter?"active":""},e.createElement(o,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("justifyRight"),className:L.justifyRight?"active":""},e.createElement(c,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("justifyFull"),className:L.justifyFull?"active":""},e.createElement(r,{className:"button-icon"}))),e.createElement("div",{id:"list-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("insertUnorderedList"),className:L.insertUnorderedList?"active":""},e.createElement(s,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("insertOrderedList"),className:L.insertOrderedList?"active":""},e.createElement(i,{className:"button-icon"}))),e.createElement("div",{id:"table",className:"toolbar-group"},e.createElement("button",{type:"button",className:"table-selector-button"},e.createElement(p,{className:"button-icon"})),e.createElement("div",{className:"table-selector-container"},e.createElement("div",{className:"table-selector-show"},e.createElement(v,{onTableCreate:(e,t)=>{n("insertHTML",((e,t)=>{let l='<div style="overflow-x: auto; max-width: 100%;"><table id="editor-custom-table" style="width: 100%; border-collapse: collapse; margin: 10px 0;"><thead><tr>';for(let e=0;e<t;e++)l+=`<th style="${E}">Header ${e+1}</th>`;l+="</tr></thead><tbody>";for(let n=0;n<e-1;n++){l+="<tr>";for(let e=0;e<t;e++)l+=`<td style="${w}">Cell ${n+1}-${e+1}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})(e,t))}}),e.createElement("div",{className:"table-option-button"},e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e){const t=e.insertRow(-1);for(let l=0;l<e.rows[0].cells.length;l++){const e=t.insertCell(l);e.innerHTML="New Cell",e.classList.add("table-cell")}}})(),value:"addRow"},"Add Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++){const l=e.rows[t].insertCell(-1);l.innerHTML="New Cell",l.classList.add("table-cell")}})(),value:"addColumn"},"Add Column"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++)e.rows[t].cells.length>1&&e.rows[t].deleteCell(-1)})(),value:"removeColumn"},"Remove Column"),e.createElement("button",{type:"button",onClick:()=>n("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),e.createElement("div",{id:"link-image-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("createLink",prompt("Enter the URL:","https://")||"")},e.createElement(m,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("unlink")},e.createElement(u,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("insertImage",prompt("Enter the image URL:","https://")||"")},e.createElement(d,{className:"button-icon"}))),e.createElement("div",{id:"block-style-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),n("formatBlock",e.target.value)}},e.createElement("option",{value:"p"},"Normal Text"),e.createElement("option",{value:"h1"},"Heading 1"),e.createElement("option",{value:"h2"},"Heading 2"),e.createElement("option",{value:"h3"},"Heading 3"),e.createElement("option",{value:"blockquote"},"Blockquote"),e.createElement("option",{value:"pre"},"Code Block"))),e.createElement("div",{id:"symbol",className:"toolbar-group"},e.createElement("button",{type:"button",className:"symbol-selector-button"},"Symbols"),e.createElement("div",{className:"symbol-selector-container"},e.createElement("div",{className:"symbol-selector-show"},e.createElement("div",{className:"symbol-option-button"},e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&copy;")},"©"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&euro;")},"€"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&trade;")},"™"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&#10077;")},"❝"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&#10078;")},"❞"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&#10003;")},"✓"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","😊")},"😊"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","👍")},"👍"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","🎉")},"🎉"))))),e.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("undo")},e.createElement(g,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("redo")},e.createElement(h,{className:"button-icon"}))))},C=({value:t,onChange:a})=>{const o=n(null),c=(e,t)=>{if(t)if(t.includes('<table id="editor-custom-table"'))e.innerHTML+=t;else{const e=window.getSelection(),l=null==e?void 0:e.getRangeAt(0);if(l){l.deleteContents();const n=l.createContextualFragment(t);l.insertNode(n);const a=document.createRange();a.setStartAfter(n.lastChild),a.collapse(!0),null==e||e.removeAllRanges(),null==e||e.addRange(a)}}},r=(e,t)=>{document.execCommand(e);const l=window.getSelection(),n=null==l?void 0:l.getRangeAt(0),a=null==n?void 0:n.commonAncestorContainer.parentElement;!a||"UL"!==a.tagName&&"OL"!==a.tagName||a.setAttribute("style",`list-style-position: inside; list-style-type: ${t};`)};return l((()=>{o.current&&o.current.innerHTML!==t&&(o.current.innerHTML=t)}),[t]),e.createElement("div",{id:"editor-container",className:"editor-canvas",onClick:e=>{e.target.closest(".toolbar")&&(e.preventDefault(),e.stopPropagation())}},e.createElement(L,{onCommand:(e,t)=>{const l=o.current;if(l)try{switch(e){case"createLink":t&&document.execCommand("createLink",!1,t);break;case"insertImage":t&&document.execCommand("insertImage",!1,t);break;case"formatBlock":t&&document.execCommand("formatBlock",!1,t);break;case"insertHTML":c(l,t);break;case"insertUnorderedList":r(e,"disc");break;case"insertOrderedList":r(e,"decimal");break;default:document.execCommand(e,!1,t||"")}l.focus(),a(l.innerHTML)}catch(e){console.error("Error applying command:",e)}}}),e.createElement("div",{id:"content-area",ref:o,contentEditable:!0,onDrop:e=>{e.preventDefault();Array.from(e.dataTransfer.files).forEach((e=>{const t=new FileReader;t.onload=e=>{var t,l,n;const c=document.createElement("img");c.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(l=o.current)||void 0===l||l.appendChild(c),a((null===(n=o.current)||void 0===n?void 0:n.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:e=>{e.preventDefault(),o.current&&a(o.current.innerHTML)}}))};export{C as Editor,L as Toolbar,C as default};
import e,{useState as t,useEffect as l,useRef as n}from"react";const a=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-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"})),o=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),c=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),r=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 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 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"})),s=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"})),i=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{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"})),m=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"})),u=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"})),d=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"})),g=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M48.5 224L40 224c-13.3 0-24-10.7-24-24L16 72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8L48.5 224z"})),h=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M463.5 224l8.5 0c13.3 0 24-10.7 24-24l0-128c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8l119.5 0z"})),p=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M64 256l0-96 160 0 0 96L64 256zm0 64l160 0 0 96L64 416l0-96zm224 96l0-96 160 0 0 96-160 0zM448 256l-160 0 0-96 160 0 0 96zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32z"})),b=({className:t,width:l=24,height:n=24})=>e.createElement("svg",{className:t,width:l,height:n,viewBox:"0 0 576 512",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M290.7 57.4L57.4 290.7c-25 25-25 65.5 0 90.5l80 80c12 12 28.3 18.7 45.3 18.7L288 480l9.4 0L512 480c17.7 0 32-14.3 32-32s-14.3-32-32-32l-124.1 0L518.6 285.3c25-25 25-65.5 0-90.5L381.3 57.4c-25-25-65.5-25-90.5 0zM297.4 416l-9.4 0-105.4 0-80-80L227.3 211.3 364.7 348.7 297.4 416z"})),w="padding: 8px;text-align: center;border: 1px solid #ddd;min-width: 80px;",E=`${w} background-color: #f1f1f1;font-weight: bold;`,v=({onTableCreate:l})=>{const[n,a]=t(0),[o,c]=t(0),r=()=>{l(n+1,o+1)};return e.createElement("div",{className:"table-selector"},[...new Array(8)].map(((t,l)=>e.createElement("div",{key:`row-${l}`,className:"table-selector-row"},[...new Array(8)].map(((t,s)=>e.createElement("div",{key:`col-${s}`,className:"table-selector-cell "+(l<=n&&s<=o?"highlighted":""),onMouseEnter:()=>((e,t)=>{a(e),c(t)})(l,s),onClick:r})))))),e.createElement("div",{className:"table-selector-label"},n+1," x ",o+1))},L=({onCommand:n})=>{const[L,C]=t({}),y=(e,t)=>{let l;return function(...n){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,n)),t)}},N=()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;let t=e.getRangeAt(0).startContainer;t.nodeType===Node.TEXT_NODE&&(t=t.parentElement);const l={},n=(e,t)=>{for(;e&&e!==document.body;){if(e.tagName===t)return!0;e=e.parentNode}return!1};l.bold=n(t,"B")||n(t,"STRONG")||"700"===window.getComputedStyle(t).fontWeight,l.italic=n(t,"I")||n(t,"EM")||"italic"===window.getComputedStyle(t).fontStyle,l.underline=n(t,"U")||window.getComputedStyle(t).textDecorationLine.includes("underline"),l.strikeThrough=n(t,"S")||n(t,"STRIKE")||window.getComputedStyle(t).textDecorationLine.includes("line-through");const a=window.getComputedStyle(t).textAlign;l.justifyLeft="left"===a,l.justifyCenter="center"===a,l.justifyRight="right"===a,l.justifyFull="justify"===a,l.insertUnorderedList=n(t,"UL"),l.insertOrderedList=n(t,"OL"),C(l)};return l((()=>{const e=y(N,200);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),e.createElement("div",{id:"toolbar",className:"toolbar",onClick:e=>e.stopPropagation()},e.createElement("div",{id:"font-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),n("fontName",e.target.value)}},e.createElement("option",{value:""},"Font Family"),e.createElement("option",{value:"Arial"},"Arial"),e.createElement("option",{value:"Courier New"},"Courier New"),e.createElement("option",{value:"Georgia"},"Georgia"),e.createElement("option",{value:"Tahoma"},"Tahoma"),e.createElement("option",{value:"Times New Roman"},"T New Roman"),e.createElement("option",{value:"Verdana"},"Verdana")),e.createElement("select",{onChange:e=>{e.preventDefault(),n("fontSize",e.target.value)}},e.createElement("option",{value:""},"Font Size"),e.createElement("option",{value:"1"},"Tiny"),e.createElement("option",{value:"2"},"Small"),e.createElement("option",{value:"3"},"Regular"),e.createElement("option",{value:"4"},"Medium"),e.createElement("option",{value:"5"},"Large"),e.createElement("option",{value:"6"},"E.Large"),e.createElement("option",{value:"7"},"Huge"))),e.createElement("div",{id:"text-formatting-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("bold"),style:{fontWeight:"700"},className:L.bold?"active":"","aria-label":"Bold"},"B"),e.createElement("button",{type:"button",onClick:()=>n("italic"),className:L.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),e.createElement("button",{type:"button",onClick:()=>n("underline"),className:L.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),e.createElement("button",{type:"button",onClick:()=>n("strikeThrough"),className:L.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),e.createElement("button",{type:"button",onClick:()=>n("removeFormat"),title:"Clear Formatting"},e.createElement(b,{className:"button-icon"}))),e.createElement("div",{id:"color-group",className:"toolbar-group"},e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),n("foreColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Text Color"}),e.createElement("input",{type:"color",onChange:e=>{e.preventDefault(),e.stopPropagation(),n("backColor",e.target.value)},onMouseDown:e=>e.preventDefault(),title:"Background Color"})),e.createElement("div",{id:"alignment-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("justifyLeft"),className:L.justifyLeft?"active":""},e.createElement(a,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("justifyCenter"),className:L.justifyCenter?"active":""},e.createElement(o,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("justifyRight"),className:L.justifyRight?"active":""},e.createElement(c,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("justifyFull"),className:L.justifyFull?"active":""},e.createElement(r,{className:"button-icon"}))),e.createElement("div",{id:"list-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("insertUnorderedList"),className:L.insertUnorderedList?"active":""},e.createElement(s,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("insertOrderedList"),className:L.insertOrderedList?"active":""},e.createElement(i,{className:"button-icon"}))),e.createElement("div",{id:"table",className:"toolbar-group"},e.createElement("button",{type:"button",className:"table-selector-button"},e.createElement(p,{className:"button-icon"})),e.createElement("div",{className:"table-selector-container"},e.createElement("div",{className:"table-selector-show"},e.createElement(v,{onTableCreate:(e,t)=>{n("insertHTML",((e,t)=>{let l='<div style="overflow-x: auto; max-width: 100%;"><table id="editor-custom-table" style="width: 100%; border-collapse: collapse; margin: 10px 0;"><thead><tr>';for(let e=0;e<t;e++)l+=`<th style="${E}">Header ${e+1}</th>`;l+="</tr></thead><tbody>";for(let n=0;n<e-1;n++){l+="<tr>";for(let e=0;e<t;e++)l+=`<td style="${w}">Cell ${n+1}-${e+1}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})(e,t))}}),e.createElement("div",{className:"table-option-button"},e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e){const t=e.insertRow(-1);for(let l=0;l<e.rows[0].cells.length;l++){const e=t.insertCell(l);e.innerHTML="New Cell",e.classList.add("table-cell")}}})(),value:"addRow"},"Add Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++){const l=e.rows[t].insertCell(-1);l.innerHTML="New Cell",l.classList.add("table-cell")}})(),value:"addColumn"},"Add Column"),e.createElement("button",{type:"button",onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");if(e)for(let t=0;t<e.rows.length;t++)e.rows[t].cells.length>1&&e.rows[t].deleteCell(-1)})(),value:"removeColumn"},"Remove Column"),e.createElement("button",{type:"button",onClick:()=>n("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),e.createElement("div",{id:"link-image-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("createLink",prompt("Enter the URL:","https://")||"")},e.createElement(m,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("unlink")},e.createElement(u,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("insertImage",prompt("Enter the image URL:","https://")||"")},e.createElement(d,{className:"button-icon"}))),e.createElement("div",{id:"block-style-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>{e.preventDefault(),n("formatBlock",e.target.value)}},e.createElement("option",{value:"p"},"Normal Text"),e.createElement("option",{value:"h1"},"Heading 1"),e.createElement("option",{value:"h2"},"Heading 2"),e.createElement("option",{value:"h3"},"Heading 3"),e.createElement("option",{value:"blockquote"},"Blockquote"),e.createElement("option",{value:"pre"},"Code Block"))),e.createElement("div",{id:"symbol",className:"toolbar-group"},e.createElement("button",{type:"button",className:"symbol-selector-button"},"Symbols"),e.createElement("div",{className:"symbol-selector-container"},e.createElement("div",{className:"symbol-selector-show"},e.createElement("div",{className:"symbol-option-button"},e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&copy;")},"©"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&euro;")},"€"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&trade;")},"™"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&#10077;")},"❝"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&#10078;")},"❞"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","&#10003;")},"✓"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","😊")},"😊"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","👍")},"👍"),e.createElement("button",{type:"button",onClick:()=>n("insertHTML","🎉")},"🎉"))))),e.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},e.createElement("button",{type:"button",onClick:()=>n("undo")},e.createElement(g,{className:"button-icon"})),e.createElement("button",{type:"button",onClick:()=>n("redo")},e.createElement(h,{className:"button-icon"}))))},C=({value:t,onChange:a})=>{const o=n(null),c=(e,t)=>{if(t)if(t.includes('<table id="editor-custom-table"'))e.innerHTML+=t;else{const e=window.getSelection(),l=null==e?void 0:e.getRangeAt(0);if(l){l.deleteContents();const n=l.createContextualFragment(t);l.insertNode(n);const a=document.createRange();a.setStartAfter(n.lastChild),a.collapse(!0),null==e||e.removeAllRanges(),null==e||e.addRange(a)}}},r=(e,t)=>{document.execCommand(e);const l=window.getSelection(),n=null==l?void 0:l.getRangeAt(0);let a=n&&(null==n?void 0:n.commonAncestorContainer);for(;a&&"UL"!==a.tagName&&"OL"!==a.tagName;)a=a.parentElement;!a||"UL"!==a.tagName&&"OL"!==a.tagName||a.setAttribute("style",`list-style-position: inside; list-style-type: ${t};`)};return l((()=>{o.current&&o.current.innerHTML!==t&&(o.current.innerHTML=t)}),[t]),e.createElement("div",{id:"editor-container",className:"editor-canvas",onClick:e=>{e.target.closest(".toolbar")&&(e.preventDefault(),e.stopPropagation())}},e.createElement(L,{onCommand:(e,t)=>{const l=o.current;if(l)try{switch(e){case"createLink":t&&document.execCommand("createLink",!1,t);break;case"insertImage":t&&document.execCommand("insertImage",!1,t);break;case"formatBlock":t&&document.execCommand("formatBlock",!1,t);break;case"insertHTML":c(l,t);break;case"insertUnorderedList":r(e,"disc");break;case"insertOrderedList":r(e,"decimal");break;default:document.execCommand(e,!1,t||"")}l.focus(),a(l.innerHTML)}catch(e){console.error("Error applying command:",e)}}}),e.createElement("div",{id:"content-area",ref:o,contentEditable:!0,onDrop:e=>{e.preventDefault();Array.from(e.dataTransfer.files).forEach((e=>{const t=new FileReader;t.onload=e=>{var t,l,n;const c=document.createElement("img");c.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(l=o.current)||void 0===l||l.appendChild(c),a((null===(n=o.current)||void 0===n?void 0:n.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:e=>{e.preventDefault(),o.current&&a(o.current.innerHTML)}}))};export{C as Editor,L as Toolbar,C as default};
{
"name": "textcrafter",
"version": "1.0.0-beta.8",
"version": "1.0.0-beta.9",
"type": "module",

@@ -5,0 +5,0 @@ "description": "TextCrafter: A modern, customizable rich text editor for React. Supports rich formatting, media embedding and real-time collaboration. Ideal for content creators.",

@@ -0,0 +0,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc