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

textcrafter

Package Overview
Dependencies
Maintainers
1
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.1 to 1.0.0-beta.2

2

dist/index.cjs.js

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

"use strict";var e=require("react");const t=({className:t,width:l=24,height:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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"})),n=({className:t,width:l=24,height:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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"})),o=({className:t,width:l=24,height:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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:c=24})=>e.createElement("svg",{className:t,width:l,height:c,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"})),h=({onTableCreate:t})=>{const[l,c]=e.useState(0),[a,n]=e.useState(0),o=()=>{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)=>{c(e),n(t)})(r,s),onClick:o})))))),e.createElement("div",{className:"table-selector-label"},l+1," x ",a+1))},E=({onCommand:E})=>{const[w,v]=e.useState({}),b=(e,t)=>{let l;return function(...c){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,c)),t)}},p=()=>{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={},c=(e,t)=>{for(;e&&e!==document.body;){if(e.tagName===t)return!0;e=e.parentNode}return!1};l.bold=c(t,"B")||c(t,"STRONG")||"700"===window.getComputedStyle(t).fontWeight,l.italic=c(t,"I")||c(t,"EM")||"italic"===window.getComputedStyle(t).fontStyle,l.underline=c(t,"U")||window.getComputedStyle(t).textDecorationLine.includes("underline"),l.strikeThrough=c(t,"S")||c(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=c(t,"UL"),l.insertOrderedList=c(t,"OL"),v(l)};return e.useEffect((()=>{const e=b(p,100);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),e.createElement("div",{id:"toolbar",className:"toolbar"},e.createElement("div",{id:"font-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>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("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",{onClick:()=>E("bold"),style:{fontWeight:"700"},className:w.bold?"active":"","aria-label":"Bold"},"B"),e.createElement("button",{onClick:()=>E("italic"),className:w.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),e.createElement("button",{onClick:()=>E("underline"),className:w.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),e.createElement("button",{onClick:()=>E("strikeThrough"),className:w.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),e.createElement("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("foreColor",e.target.value),title:"Text Color"}),e.createElement("input",{type:"color",onChange:e=>E("backColor",e.target.value),title:"Background Color"})),e.createElement("div",{id:"alignment-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>E("justifyLeft"),className:w.justifyLeft?"active":""},e.createElement(t,{className:"button-icon"})),e.createElement("button",{onClick:()=>E("justifyCenter"),className:w.justifyCenter?"active":""},e.createElement(l,{className:"button-icon"})),e.createElement("button",{onClick:()=>E("justifyRight"),className:w.justifyRight?"active":""},e.createElement(c,{className:"button-icon"})),e.createElement("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",{onClick:()=>E("insertUnorderedList"),className:w.insertUnorderedList?"active":""},e.createElement(n,{className:"button-icon"})),e.createElement("button",{onClick:()=>E("insertOrderedList"),className:w.insertOrderedList?"active":""},e.createElement(o,{className:"button-icon"}))),e.createElement("div",{id:"table",className:"toolbar-group"},e.createElement("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(h,{onTableCreate:(e,t)=>{E("insertHTML",((e,t)=>{console.log({rows:e,cols:t});let l='<table id="editor-custom-table" class="custom-table" border="1">';for(let c=0;c<e;c++){l+="<tr>";for(let e=0;e<t;e++)l+='<td class="table-cell">Cell</td>';l+="</tr>"}return l+="</table>",l})(e,t))}}),e.createElement("div",{className:"table-option-button"},e.createElement("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",{onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),e.createElement("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",{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",{onClick:()=>E("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),e.createElement("div",{id:"link-image-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>E("createLink",prompt("Enter the URL:","https://")||"")},e.createElement(r,{className:"button-icon"})),e.createElement("button",{onClick:()=>E("unlink")},e.createElement(s,{className:"button-icon"})),e.createElement("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("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",{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",{onClick:()=>E("insertHTML","&copy;")},"©"),e.createElement("button",{onClick:()=>E("insertHTML","&euro;")},"€"),e.createElement("button",{onClick:()=>E("insertHTML","&trade;")},"™"),e.createElement("button",{onClick:()=>E("insertHTML","&#10077;")},"❝"),e.createElement("button",{onClick:()=>E("insertHTML","&#10078;")},"❞"),e.createElement("button",{onClick:()=>E("insertHTML","&#10003;")},"✓"),e.createElement("button",{onClick:()=>E("insertHTML","😊")},"😊"),e.createElement("button",{onClick:()=>E("insertHTML","👍")},"👍"),e.createElement("button",{onClick:()=>E("insertHTML","🎉")},"🎉"))))),e.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>E("undo")},e.createElement(m,{className:"button-icon"})),e.createElement("button",{onClick:()=>E("redo")},e.createElement(u,{className:"button-icon"}))))};exports.Editor=({value:t,onChange:l})=>{const c=e.useRef(null);return e.useEffect((()=>{c.current&&c.current.innerHTML!==t&&(c.current.innerHTML=t)}),[t]),e.createElement("div",{id:"editor-container",className:"editor-canvas"},e.createElement(E,{onCommand:(e,t)=>{const a=c.current;a&&("createLink"===e&&t?document.execCommand("createLink",!1,t):"insertImage"===e&&t?document.execCommand("insertImage",!1,t):"formatBlock"===e&&t?document.execCommand("formatBlock",!1,t):"insertHTML"===e&&t?a.innerHTML+=t:document.execCommand(e,!1,t||""),a.focus(),c.current&&l(c.current.innerHTML))}}),e.createElement("div",{id:"content-area",ref:c,contentEditable:!0,onDrop:e=>{e.preventDefault();Array.from(e.dataTransfer.files).forEach((e=>{const t=new FileReader;t.onload=e=>{var t,a,n;const o=document.createElement("img");o.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(a=c.current)||void 0===a||a.appendChild(o),l((null===(n=c.current)||void 0===n?void 0:n.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:()=>{c.current&&l(c.current.innerHTML)}}))},exports.Toolbar=E;
"use strict";var e=require("react");const t=({className:t,width:l=24,height:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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"})),a=({className:t,width:l=24,height:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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"})),n=({className:t,width:l=24,height:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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"})),c=({className:t,width:l=24,height:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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"})),o=({className:t,width:l=24,height:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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"})),h=({className:t,width:l=24,height:a=24})=>e.createElement("svg",{className:t,width:l,height:a,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"})),g="padding: 8px;text-align: center;border: 1px solid #ddd;min-width: 80px;",E=`${g}background-color: #f1f1f1;font-weight: bold;`,w=({onTableCreate:t})=>{const[l,a]=e.useState(0),[n,c]=e.useState(0),o=()=>{t(l+1,n+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<=n?"highlighted":""),onMouseEnter:()=>((e,t)=>{a(e),c(t)})(r,s),onClick:o})))))),e.createElement("div",{className:"table-selector-label"},l+1," x ",n+1))},v=({onCommand:v})=>{const[p,b]=e.useState({}),L=(e,t)=>{let l;return function(...a){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,a)),t)}},C=()=>{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={},a=(e,t)=>{for(;e&&e!==document.body;){if(e.tagName===t)return!0;e=e.parentNode}return!1};l.bold=a(t,"B")||a(t,"STRONG")||"700"===window.getComputedStyle(t).fontWeight,l.italic=a(t,"I")||a(t,"EM")||"italic"===window.getComputedStyle(t).fontStyle,l.underline=a(t,"U")||window.getComputedStyle(t).textDecorationLine.includes("underline"),l.strikeThrough=a(t,"S")||a(t,"STRIKE")||window.getComputedStyle(t).textDecorationLine.includes("line-through");const n=window.getComputedStyle(t).textAlign;l.justifyLeft="left"===n,l.justifyCenter="center"===n,l.justifyRight="right"===n,l.justifyFull="justify"===n,l.insertUnorderedList=a(t,"UL"),l.insertOrderedList=a(t,"OL"),b(l)};return e.useEffect((()=>{const e=L(C,100);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),e.createElement("div",{id:"toolbar",className:"toolbar"},e.createElement("div",{id:"font-group",className:"toolbar-group"},e.createElement("select",{onChange:e=>v("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=>v("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",{onClick:()=>v("bold"),style:{fontWeight:"700"},className:p.bold?"active":"","aria-label":"Bold"},"B"),e.createElement("button",{onClick:()=>v("italic"),className:p.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),e.createElement("button",{onClick:()=>v("underline"),className:p.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),e.createElement("button",{onClick:()=>v("strikeThrough"),className:p.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),e.createElement("button",{onClick:()=>v("removeFormat"),title:"Clear Formatting"},e.createElement(h,{className:"button-icon"}))),e.createElement("div",{id:"color-group",className:"toolbar-group"},e.createElement("input",{type:"color",onChange:e=>v("foreColor",e.target.value),title:"Text Color"}),e.createElement("input",{type:"color",onChange:e=>v("backColor",e.target.value),title:"Background Color"})),e.createElement("div",{id:"alignment-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>v("justifyLeft"),className:p.justifyLeft?"active":""},e.createElement(t,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("justifyCenter"),className:p.justifyCenter?"active":""},e.createElement(l,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("justifyRight"),className:p.justifyRight?"active":""},e.createElement(a,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("justifyFull"),className:p.justifyFull?"active":""},e.createElement(n,{className:"button-icon"}))),e.createElement("div",{id:"list-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>v("insertUnorderedList"),className:p.insertUnorderedList?"active":""},e.createElement(c,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("insertOrderedList"),className:p.insertOrderedList?"active":""},e.createElement(o,{className:"button-icon"}))),e.createElement("div",{id:"table",className:"toolbar-group"},e.createElement("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(w,{onTableCreate:(e,t)=>{v("insertHTML",((e,t)=>{let l='<div style="overflow-x: auto; max-width: 100%;"><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 a=0;a<e-1;a++){l+="<tr>";for(let e=0;e<t;e++)l+=`<td style="${g}">Cell ${a+1}-${e+1}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})(e,t))}}),e.createElement("div",{className:"table-option-button"},e.createElement("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",{onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),e.createElement("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",{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",{onClick:()=>v("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),e.createElement("div",{id:"link-image-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>v("createLink",prompt("Enter the URL:","https://")||"")},e.createElement(r,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("unlink")},e.createElement(s,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("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=>v("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",{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",{onClick:()=>v("insertHTML","&copy;")},"©"),e.createElement("button",{onClick:()=>v("insertHTML","&euro;")},"€"),e.createElement("button",{onClick:()=>v("insertHTML","&trade;")},"™"),e.createElement("button",{onClick:()=>v("insertHTML","&#10077;")},"❝"),e.createElement("button",{onClick:()=>v("insertHTML","&#10078;")},"❞"),e.createElement("button",{onClick:()=>v("insertHTML","&#10003;")},"✓"),e.createElement("button",{onClick:()=>v("insertHTML","😊")},"😊"),e.createElement("button",{onClick:()=>v("insertHTML","👍")},"👍"),e.createElement("button",{onClick:()=>v("insertHTML","🎉")},"🎉"))))),e.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},e.createElement("button",{onClick:()=>v("undo")},e.createElement(m,{className:"button-icon"})),e.createElement("button",{onClick:()=>v("redo")},e.createElement(u,{className:"button-icon"}))))};exports.Editor=({value:t,onChange:l})=>{const a=e.useRef(null);return e.useEffect((()=>{a.current&&a.current.innerHTML!==t&&(a.current.innerHTML=t)}),[t]),e.createElement("div",{id:"editor-container",className:"editor-canvas"},e.createElement(v,{onCommand:(e,t)=>{const n=a.current;n&&("createLink"===e&&t?document.execCommand("createLink",!1,t):"insertImage"===e&&t?document.execCommand("insertImage",!1,t):"formatBlock"===e&&t?document.execCommand("formatBlock",!1,t):"insertHTML"===e&&t?n.innerHTML+=t:document.execCommand(e,!1,t||""),n.focus(),a.current&&l(a.current.innerHTML))}}),e.createElement("div",{id:"content-area",ref:a,contentEditable:!0,onDrop:e=>{e.preventDefault();Array.from(e.dataTransfer.files).forEach((e=>{const t=new FileReader;t.onload=e=>{var t,n,c;const o=document.createElement("img");o.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(n=a.current)||void 0===n||n.appendChild(o),l((null===(c=a.current)||void 0===c?void 0:c.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:()=>{a.current&&l(a.current.innerHTML)}}))},exports.Toolbar=v;

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TextCrafter={},e.React)}(this,(function(e,t){"use strict";const l=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),n=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),r=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),s=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),i=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),m=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),u=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),d=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),h=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 576 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),E=({onTableCreate:e})=>{const[l,n]=t.useState(0),[c,a]=t.useState(0),o=()=>{e(l+1,c+1)};return t.createElement("div",{className:"table-selector"},[...new Array(8)].map(((e,r)=>t.createElement("div",{key:`row-${r}`,className:"table-selector-row"},[...new Array(8)].map(((e,s)=>t.createElement("div",{key:`col-${s}`,className:"table-selector-cell "+(r<=l&&s<=c?"highlighted":""),onMouseEnter:()=>((e,t)=>{n(e),a(t)})(r,s),onClick:o})))))),t.createElement("div",{className:"table-selector-label"},l+1," x ",c+1))},w=({onCommand:e})=>{const[w,v]=t.useState({}),b=(e,t)=>{let l;return function(...n){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,n)),t)}},p=()=>{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 c=window.getComputedStyle(t).textAlign;l.justifyLeft="left"===c,l.justifyCenter="center"===c,l.justifyRight="right"===c,l.justifyFull="justify"===c,l.insertUnorderedList=n(t,"UL"),l.insertOrderedList=n(t,"OL"),v(l)};return t.useEffect((()=>{const e=b(p,100);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),t.createElement("div",{id:"toolbar",className:"toolbar"},t.createElement("div",{id:"font-group",className:"toolbar-group"},t.createElement("select",{onChange:t=>e("fontName",t.target.value)},t.createElement("option",{value:""},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Tahoma"},"Tahoma"),t.createElement("option",{value:"Times New Roman"},"T New Roman"),t.createElement("option",{value:"Verdana"},"Verdana")),t.createElement("select",{onChange:t=>e("fontSize",t.target.value)},t.createElement("option",{value:""},"Font Size"),t.createElement("option",{value:"1"},"Tiny"),t.createElement("option",{value:"2"},"Small"),t.createElement("option",{value:"3"},"Regular"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large"),t.createElement("option",{value:"6"},"E.Large"),t.createElement("option",{value:"7"},"Huge"))),t.createElement("div",{id:"text-formatting-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("bold"),style:{fontWeight:"700"},className:w.bold?"active":"","aria-label":"Bold"},"B"),t.createElement("button",{onClick:()=>e("italic"),className:w.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),t.createElement("button",{onClick:()=>e("underline"),className:w.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),t.createElement("button",{onClick:()=>e("strikeThrough"),className:w.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),t.createElement("button",{onClick:()=>e("removeFormat"),title:"Clear Formatting"},t.createElement(g,{className:"button-icon"}))),t.createElement("div",{id:"color-group",className:"toolbar-group"},t.createElement("input",{type:"color",onChange:t=>e("foreColor",t.target.value),title:"Text Color"}),t.createElement("input",{type:"color",onChange:t=>e("backColor",t.target.value),title:"Background Color"})),t.createElement("div",{id:"alignment-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("justifyLeft"),className:w.justifyLeft?"active":""},t.createElement(l,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("justifyCenter"),className:w.justifyCenter?"active":""},t.createElement(n,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("justifyRight"),className:w.justifyRight?"active":""},t.createElement(c,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("justifyFull"),className:w.justifyFull?"active":""},t.createElement(a,{className:"button-icon"}))),t.createElement("div",{id:"list-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("insertUnorderedList"),className:w.insertUnorderedList?"active":""},t.createElement(o,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("insertOrderedList"),className:w.insertOrderedList?"active":""},t.createElement(r,{className:"button-icon"}))),t.createElement("div",{id:"table",className:"toolbar-group"},t.createElement("button",{className:"table-selector-button"},t.createElement(h,{className:"button-icon"})),t.createElement("div",{className:"table-selector-container"},t.createElement("div",{className:"table-selector-show"},t.createElement(E,{onTableCreate:(t,l)=>{e("insertHTML",((e,t)=>{console.log({rows:e,cols:t});let l='<table id="editor-custom-table" class="custom-table" border="1">';for(let n=0;n<e;n++){l+="<tr>";for(let e=0;e<t;e++)l+='<td class="table-cell">Cell</td>';l+="</tr>"}return l+="</table>",l})(t,l))}}),t.createElement("div",{className:"table-option-button"},t.createElement("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"),t.createElement("button",{onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),t.createElement("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"),t.createElement("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"),t.createElement("button",{onClick:()=>e("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),t.createElement("div",{id:"link-image-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("createLink",prompt("Enter the URL:","https://")||"")},t.createElement(s,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("unlink")},t.createElement(i,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("insertImage",prompt("Enter the image URL:","https://")||"")},t.createElement(m,{className:"button-icon"}))),t.createElement("div",{id:"block-style-group",className:"toolbar-group"},t.createElement("select",{onChange:t=>e("formatBlock",t.target.value)},t.createElement("option",{value:"p"},"Normal Text"),t.createElement("option",{value:"h1"},"Heading 1"),t.createElement("option",{value:"h2"},"Heading 2"),t.createElement("option",{value:"h3"},"Heading 3"),t.createElement("option",{value:"blockquote"},"Blockquote"),t.createElement("option",{value:"pre"},"Code Block"))),t.createElement("div",{id:"symbol",className:"toolbar-group"},t.createElement("button",{className:"symbol-selector-button"},"Symbols"),t.createElement("div",{className:"symbol-selector-container"},t.createElement("div",{className:"symbol-selector-show"},t.createElement("div",{className:"symbol-option-button"},t.createElement("button",{onClick:()=>e("insertHTML","&copy;")},"©"),t.createElement("button",{onClick:()=>e("insertHTML","&euro;")},"€"),t.createElement("button",{onClick:()=>e("insertHTML","&trade;")},"™"),t.createElement("button",{onClick:()=>e("insertHTML","&#10077;")},"❝"),t.createElement("button",{onClick:()=>e("insertHTML","&#10078;")},"❞"),t.createElement("button",{onClick:()=>e("insertHTML","&#10003;")},"✓"),t.createElement("button",{onClick:()=>e("insertHTML","😊")},"😊"),t.createElement("button",{onClick:()=>e("insertHTML","👍")},"👍"),t.createElement("button",{onClick:()=>e("insertHTML","🎉")},"🎉"))))),t.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("undo")},t.createElement(u,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("redo")},t.createElement(d,{className:"button-icon"}))))};e.Editor=({value:e,onChange:l})=>{const n=t.useRef(null);return t.useEffect((()=>{n.current&&n.current.innerHTML!==e&&(n.current.innerHTML=e)}),[e]),t.createElement("div",{id:"editor-container",className:"editor-canvas"},t.createElement(w,{onCommand:(e,t)=>{const c=n.current;c&&("createLink"===e&&t?document.execCommand("createLink",!1,t):"insertImage"===e&&t?document.execCommand("insertImage",!1,t):"formatBlock"===e&&t?document.execCommand("formatBlock",!1,t):"insertHTML"===e&&t?c.innerHTML+=t:document.execCommand(e,!1,t||""),c.focus(),n.current&&l(n.current.innerHTML))}}),t.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,c,a;const o=document.createElement("img");o.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(c=n.current)||void 0===c||c.appendChild(o),l((null===(a=n.current)||void 0===a?void 0:a.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:()=>{n.current&&l(n.current.innerHTML)}}))},e.Toolbar=w}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TextCrafter={},e.React)}(this,(function(e,t){"use strict";const l=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),n=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),a=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),c=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 448 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),r=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),s=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),i=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 640 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),m=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),d=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),h=({className:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},t.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:e,width:l=24,height:n=24})=>t.createElement("svg",{className:e,width:l,height:n,viewBox:"0 0 576 512",xmlns:"http://www.w3.org/2000/svg"},t.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"})),E="padding: 8px;text-align: center;border: 1px solid #ddd;min-width: 80px;",w=`${E}background-color: #f1f1f1;font-weight: bold;`,v=({onTableCreate:e})=>{const[l,n]=t.useState(0),[a,c]=t.useState(0),o=()=>{e(l+1,a+1)};return t.createElement("div",{className:"table-selector"},[...new Array(8)].map(((e,r)=>t.createElement("div",{key:`row-${r}`,className:"table-selector-row"},[...new Array(8)].map(((e,s)=>t.createElement("div",{key:`col-${s}`,className:"table-selector-cell "+(r<=l&&s<=a?"highlighted":""),onMouseEnter:()=>((e,t)=>{n(e),c(t)})(r,s),onClick:o})))))),t.createElement("div",{className:"table-selector-label"},l+1," x ",a+1))},p=({onCommand:e})=>{const[p,b]=t.useState({}),L=(e,t)=>{let l;return function(...n){clearTimeout(l),l=window.setTimeout((()=>e.apply(this,n)),t)}},C=()=>{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"),b(l)};return t.useEffect((()=>{const e=L(C,100);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)}),[]),t.createElement("div",{id:"toolbar",className:"toolbar"},t.createElement("div",{id:"font-group",className:"toolbar-group"},t.createElement("select",{onChange:t=>e("fontName",t.target.value)},t.createElement("option",{value:""},"Font Family"),t.createElement("option",{value:"Arial"},"Arial"),t.createElement("option",{value:"Courier New"},"Courier New"),t.createElement("option",{value:"Georgia"},"Georgia"),t.createElement("option",{value:"Tahoma"},"Tahoma"),t.createElement("option",{value:"Times New Roman"},"T New Roman"),t.createElement("option",{value:"Verdana"},"Verdana")),t.createElement("select",{onChange:t=>e("fontSize",t.target.value)},t.createElement("option",{value:""},"Font Size"),t.createElement("option",{value:"1"},"Tiny"),t.createElement("option",{value:"2"},"Small"),t.createElement("option",{value:"3"},"Regular"),t.createElement("option",{value:"4"},"Medium"),t.createElement("option",{value:"5"},"Large"),t.createElement("option",{value:"6"},"E.Large"),t.createElement("option",{value:"7"},"Huge"))),t.createElement("div",{id:"text-formatting-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("bold"),style:{fontWeight:"700"},className:p.bold?"active":"","aria-label":"Bold"},"B"),t.createElement("button",{onClick:()=>e("italic"),className:p.italic?"active":"",style:{fontStyle:"italic"},"aria-label":"Italic"},"I"),t.createElement("button",{onClick:()=>e("underline"),className:p.underline?"active":"",style:{textDecoration:"underline"},"aria-label":"Underline"},"U"),t.createElement("button",{onClick:()=>e("strikeThrough"),className:p.strikeThrough?"active":"",style:{textDecoration:"line-through"}},"abc"),t.createElement("button",{onClick:()=>e("removeFormat"),title:"Clear Formatting"},t.createElement(g,{className:"button-icon"}))),t.createElement("div",{id:"color-group",className:"toolbar-group"},t.createElement("input",{type:"color",onChange:t=>e("foreColor",t.target.value),title:"Text Color"}),t.createElement("input",{type:"color",onChange:t=>e("backColor",t.target.value),title:"Background Color"})),t.createElement("div",{id:"alignment-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("justifyLeft"),className:p.justifyLeft?"active":""},t.createElement(l,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("justifyCenter"),className:p.justifyCenter?"active":""},t.createElement(n,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("justifyRight"),className:p.justifyRight?"active":""},t.createElement(a,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("justifyFull"),className:p.justifyFull?"active":""},t.createElement(c,{className:"button-icon"}))),t.createElement("div",{id:"list-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("insertUnorderedList"),className:p.insertUnorderedList?"active":""},t.createElement(o,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("insertOrderedList"),className:p.insertOrderedList?"active":""},t.createElement(r,{className:"button-icon"}))),t.createElement("div",{id:"table",className:"toolbar-group"},t.createElement("button",{className:"table-selector-button"},t.createElement(h,{className:"button-icon"})),t.createElement("div",{className:"table-selector-container"},t.createElement("div",{className:"table-selector-show"},t.createElement(v,{onTableCreate:(t,l)=>{e("insertHTML",((e,t)=>{let l='<div style="overflow-x: auto; max-width: 100%;"><table style="width: 100%; border-collapse: collapse; margin: 10px 0;"><thead><tr>';for(let e=0;e<t;e++)l+=`<th style="${w}">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="${E}">Cell ${n+1}-${e+1}</td>`;l+="</tr>"}return l+="</tbody></table></div>",l})(t,l))}}),t.createElement("div",{className:"table-option-button"},t.createElement("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"),t.createElement("button",{onClick:()=>(()=>{const e=document.getElementById("editor-custom-table");e&&e.rows.length>1&&e.deleteRow(-1)})(),value:"removeRow"},"Remove Row"),t.createElement("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"),t.createElement("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"),t.createElement("button",{onClick:()=>e("insertHorizontalRule"),value:"horizontalLine"},"Horizontal Line"))))),t.createElement("div",{id:"link-image-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("createLink",prompt("Enter the URL:","https://")||"")},t.createElement(s,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("unlink")},t.createElement(i,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("insertImage",prompt("Enter the image URL:","https://")||"")},t.createElement(m,{className:"button-icon"}))),t.createElement("div",{id:"block-style-group",className:"toolbar-group"},t.createElement("select",{onChange:t=>e("formatBlock",t.target.value)},t.createElement("option",{value:"p"},"Normal Text"),t.createElement("option",{value:"h1"},"Heading 1"),t.createElement("option",{value:"h2"},"Heading 2"),t.createElement("option",{value:"h3"},"Heading 3"),t.createElement("option",{value:"blockquote"},"Blockquote"),t.createElement("option",{value:"pre"},"Code Block"))),t.createElement("div",{id:"symbol",className:"toolbar-group"},t.createElement("button",{className:"symbol-selector-button"},"Symbols"),t.createElement("div",{className:"symbol-selector-container"},t.createElement("div",{className:"symbol-selector-show"},t.createElement("div",{className:"symbol-option-button"},t.createElement("button",{onClick:()=>e("insertHTML","&copy;")},"©"),t.createElement("button",{onClick:()=>e("insertHTML","&euro;")},"€"),t.createElement("button",{onClick:()=>e("insertHTML","&trade;")},"™"),t.createElement("button",{onClick:()=>e("insertHTML","&#10077;")},"❝"),t.createElement("button",{onClick:()=>e("insertHTML","&#10078;")},"❞"),t.createElement("button",{onClick:()=>e("insertHTML","&#10003;")},"✓"),t.createElement("button",{onClick:()=>e("insertHTML","😊")},"😊"),t.createElement("button",{onClick:()=>e("insertHTML","👍")},"👍"),t.createElement("button",{onClick:()=>e("insertHTML","🎉")},"🎉"))))),t.createElement("div",{id:"undo-redo-group",className:"toolbar-group"},t.createElement("button",{onClick:()=>e("undo")},t.createElement(d,{className:"button-icon"})),t.createElement("button",{onClick:()=>e("redo")},t.createElement(u,{className:"button-icon"}))))};e.Editor=({value:e,onChange:l})=>{const n=t.useRef(null);return t.useEffect((()=>{n.current&&n.current.innerHTML!==e&&(n.current.innerHTML=e)}),[e]),t.createElement("div",{id:"editor-container",className:"editor-canvas"},t.createElement(p,{onCommand:(e,t)=>{const a=n.current;a&&("createLink"===e&&t?document.execCommand("createLink",!1,t):"insertImage"===e&&t?document.execCommand("insertImage",!1,t):"formatBlock"===e&&t?document.execCommand("formatBlock",!1,t):"insertHTML"===e&&t?a.innerHTML+=t:document.execCommand(e,!1,t||""),a.focus(),n.current&&l(n.current.innerHTML))}}),t.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,c;const o=document.createElement("img");o.src=null===(t=e.target)||void 0===t?void 0:t.result,null===(a=n.current)||void 0===a||a.appendChild(o),l((null===(c=n.current)||void 0===c?void 0:c.innerHTML)||"")},t.readAsDataURL(e)}))},onDragOver:e=>e.preventDefault(),onInput:()=>{n.current&&l(n.current.innerHTML)}}))},e.Toolbar=p}));
{
"name": "textcrafter",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"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.",

---
# TextCrfter
# TextCrafter
A flexible and customizable text editor built for React, supporting both rich text formatting and HTML elements like tables, lists, links, and images. Ideal for use in React and Next.js (App and Page) applications. Compatible with both JavaScript and TypeScript projects. Easily installable via npm or Yarn.
**TextCrafter** is a powerful, flexible, and customizable rich text editor designed for React applications. It supports a wide range of text formatting and HTML elements, including tables, lists, links, and images. Built with compatibility in mind, TextCrafter is ideal for React and Next.js (App and Page) applications and is compatible with both JavaScript and TypeScript projects. Installation is quick and easy via npm or Yarn.
## Features
---
- **Rich Text Formatting:** Bold, Italic, Underline, Strikethrough, Font Family, Font Size
- **Text Alignment:** Left, Center, Right, Justify
- **Lists:** Unordered and Ordered Lists
- **Tables:** Add, Remove Rows and Columns
- **Links & Images:** Insert Links and Images (via URLs)
- **Undo & Redo** functionality
- **Customizable Toolbar:** Easily extend and style the toolbar
- **Cross-compatible:** Works in React, Next.js, TypeScript, and JavaScript
- **Drag and Drop Image Upload:** Easily insert images into the editor
## Key Features
- **Rich Text Formatting**: Bold, italic, underline, strikethrough, custom font families, and font sizes.
- **Text Alignment**: Align text left, center, right, or justify.
- **Lists**: Support for unordered and ordered lists.
- **Tables**: Easily add or remove rows and columns.
- **Links & Images**: Insert links and images (via URLs).
- **Undo & Redo**: Restore previous actions quickly.
- **Customizable Toolbar**: Extend and style the toolbar to match your design.
- **Cross-Compatible**: Compatible with React, Next.js, TypeScript, and JavaScript.
- **Drag-and-Drop Image Upload**: Drag images directly into the editor for easy insertion.
---
## Installation
### Using npm:
To install TextCrafter, choose your preferred package manager:
### npm
```bash

@@ -26,3 +33,3 @@ npm install textcrafter

### Using Yarn:
### Yarn
```bash

@@ -32,129 +39,145 @@ yarn add textcrafter

## Usage
---
## Getting Started
### Basic Setup for React
1. Import the `Style` of the Editor and Toolbar in your App component.
1. **Import the Editor Styles**
Import the editor's default stylesheet into your main app component to apply necessary styles.
```tsx
import 'textcrafter/dist/styles.min.css';
```tsx
import 'textcrafter/dist/styles.min.css';
```
```
2. **Implement the Editor Component**
Import and use the `Editor` component within your React component.
```tsx
import React, { useState } from 'react';
import { Editor } from 'textcrafter';
2. Import the `Editor` component in your React component.
const MyEditor = () => {
const [editorContent, setEditorContent] = useState('<p>Start editing...</p>');
```tsx
import React, { useState } from 'react';
import { Editor } from 'textcrafter';
const handleEditorChange = (content: string) => {
setEditorContent(content);
};
const MyEditor = () => {
const [editorContent, setEditorContent] = useState('<p>Start editing...</p>');
return (
<div>
<Editor value={editorContent} onChange={handleEditorChange} />
</div>
);
};
const handleEditorChange = (content: string) => {
setEditorContent(content);
};
export default MyEditor;
```
return (
<div>
<Editor value={editorContent} onChange={handleEditorChange} />
</div>
);
};
---
export default MyEditor;
```
### Using TextCrafter with Next.js
### Integrating with Next.js
#### For App Router (Next.js 13+ with React Server Components)
If you're using Next.js, the editor can be used both in the App and Page directories.
1. **Import Styles**
Import the editor styles in your root layout to apply them globally.
For App (with React Server Components in Next 13+):
```tsx
import 'textcrafter/dist/styles.min.css';
```
1. Import the `Style` of the Editor and Toolbar in your RootLayout.
2. **Add the Editor Component in Page Components**
Use the `Editor` component in your page-level components.
```tsx
import 'textcrafter/dist/styles.min.css';
```tsx
import React, { useState } from 'react';
import { Editor } from 'textcrafter';
```
const PageComponent = () => {
const [editorContent, setEditorContent] = useState('<p>Edit here...</p>');
2. Import the `Editor` component in your page component
const handleEditorChange = (content: string) => {
setEditorContent(content);
};
```tsx
import React, { useState } from 'react';
import { Editor } from 'textcrafter';
return (
<div>
<Editor value={editorContent} onChange={handleEditorChange} />
</div>
);
};
const PageComponent = () => {
const [editorContent, setEditorContent] = useState('<p>Edit here...</p>');
export default PageComponent;
```
const handleEditorChange = (content: string) => {
setEditorContent(content);
};
#### For Page Router (Traditional Next.js Routing)
return (
<div>
<Editor value={editorContent} onChange={handleEditorChange} />
</div>
);
};
1. **Import Styles in the _app Component**
Include the editor styles in the `_app.js` or `_app.tsx` file.
export default PageComponent;
```
```tsx
import 'textcrafter/dist/styles.min.css';
```
For Page (traditional routing in Next.js):
2. **Add the Editor Component in Page Components**
1. Import the `Style` of the Editor and Toolbar in your _app component.
```tsx
import React, { useState } from 'react';
import { Editor } from 'textcrafter';
```tsx
import 'textcrafter/dist/styles.min.css';
const HomePage = () => {
const [editorContent, setEditorContent] = useState('<p>Edit here...</p>');
```
const handleEditorChange = (content: string) => {
setEditorContent(content);
};
2. Import the `Editor` component in your page component
return (
<div>
<Editor value={editorContent} onChange={handleEditorChange} />
</div>
);
};
```tsx
// pages/index.tsx or pages/somepage.tsx
import React, { useState } from 'react';
import { Editor } from 'textcrafter';
export default HomePage;
```
const HomePage = () => {
const [editorContent, setEditorContent] = useState('<p>Edit here...</p>');
---
const handleEditorChange = (content: string) => {
setEditorContent(content);
};
## Configuration
return (
<div>
<Editor value={editorContent} onChange={handleEditorChange} />
</div>
);
};
TextCrafter offers extensive configuration options to customize the editor to fit your project’s requirements:
export default HomePage;
```
- **Font Family**: Choose from fonts like Arial, Courier New, Times New Roman, etc.
- **Font Size**: Select font sizes ranging from Tiny to Huge.
- **Text Formatting**: Toggle bold, italic, underline, and strikethrough.
- **Text Alignment**: Align text to the left, center, right, or fully justify it.
- **Lists**: Add ordered and unordered lists for organized content.
- **Tables**: Insert and configure tables with customizable rows and columns.
## Configuration
---
The toolbar offers a range of options that can be customized for your use case.
- **Font Family:** Customize the font family with options like Arial, Courier New, Times New Roman, etc.
- **Font Size:** Adjust the font size with options from Tiny to Huge.
- **Text Formatting:** Toggle bold, italic, underline, and strikethrough.
- **Text Alignment:** Align text to the left, center, right, or justify it.
- **Insert Lists:** Add ordered or unordered lists.
- **Table Insertion:** Easily add tables with customizable rows and columns.
## Styling
You can customize the editor's appearance by modifying the included CSS styles or by adding your own custom styles.
You can easily modify TextCrafter’s appearance by updating the provided CSS or adding custom styles. The toolbar and editor areas are designed for straightforward customization, allowing you to style them to fit your application’s theme.
### Example Styling:
---
## Contributing
Contributions are welcome! Please fork the repository, make your changes, and submit a pull request.
Contributions are highly welcome! To contribute:
1. Fork this repository.
2. Make your changes in a new branch.
3. Submit a pull request, and our team will review it promptly.
---
## License
This package is licensed under the MIT License.
TextCrafter is licensed under the MIT License. See [LICENSE](./LICENSE) for more details.
---
TextCrafter combines rich functionality with ease of use, providing a smooth editing experience in any React or Next.js application. Happy coding!

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