scrivly
Version:
A powerful, feature-rich rich text editor for React with TypeScript support
1 lines โข 57.4 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");function n(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}"function"==typeof SuppressedError&&SuppressedError;const o=t=>{var o=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-align-center-icon lucide-align-center",viewBox:"0 0 24 24"},o,{children:e.jsx("path",{d:"M17 12H7M19 18H5M21 6H3"})}))},r=t=>{var o=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-align-justify-icon lucide-align-justify",viewBox:"0 0 24 24"},o,{children:e.jsx("path",{d:"M3 12h18M3 18h18M3 6h18"})}))},i=t=>{var o=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-align-left-icon lucide-align-left",viewBox:"0 0 24 24"},o,{children:e.jsx("path",{d:"M15 12H3M17 18H3M21 6H3"})}))},s=t=>{var o=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-align-right-icon lucide-align-right",viewBox:"0 0 24 24"},o,{children:e.jsx("path",{d:"M21 12H9M21 18H7M21 6H3"})}))},l=t=>{var o=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-bold-icon lucide-bold",viewBox:"0 0 24 24"},o,{children:e.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})}))},a=t=>{var o=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-square-check-big-icon lucide-square-check-big",viewBox:"0 0 24 24"},o,{children:[e.jsx("path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344"}),e.jsx("path",{d:"m9 11 3 3L22 4"})]}))},c=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-chevron-down-icon lucide-chevron-down",viewBox:"0 0 24 24",width:o,height:o},r,{children:e.jsx("path",{d:"m6 9 6 6 6-6"})}))},d=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-code-icon lucide-code",viewBox:"0 0 24 24"},r,{children:e.jsx("path",{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"})}))},u=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-eraser-icon lucide-eraser",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21M5.082 11.09l8.828 8.828"})})},h=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-file-code-icon lucide-file-code",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("path",{d:"m10 13-2 2 2 2"}),e.jsx("path",{d:"m14 17 2-2-2-2"})]}))},m=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-image-icon lucide-image",viewBox:"0 0 24 24"},r,{children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e.jsx("path",{d:"m21 15-5-5L5 21"})]}))},x=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-indent-icon lucide-indent",viewBox:"0 0 24 24"},r,{children:[e.jsx("polyline",{points:"3 8 7 12 3 16"}),e.jsx("line",{x1:"21",x2:"11",y1:"12",y2:"12"}),e.jsx("line",{x1:"21",x2:"11",y1:"6",y2:"6"}),e.jsx("line",{x1:"21",x2:"11",y1:"18",y2:"18"})]}))},p=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-italic-icon lucide-italic",viewBox:"0 0 24 24"},r,{children:[e.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),e.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),e.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]}))},g=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-link-icon lucide-link",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}))},v=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-list-icon lucide-list",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 12h.01M3 18h.01M3 6h.01M8 12h13M8 18h13M8 6h13"})})},b=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-list-ordered-icon lucide-list-ordered",viewBox:"0 0 24 24"},r,{children:[e.jsx("line",{x1:"10",x2:"21",y1:"6",y2:"6"}),e.jsx("line",{x1:"10",x2:"21",y1:"12",y2:"12"}),e.jsx("line",{x1:"10",x2:"21",y1:"18",y2:"18"}),e.jsx("path",{d:"M4 6h1v4"}),e.jsx("path",{d:"M4 10h2"}),e.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]}))},j=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-maximize-icon lucide-maximize",viewBox:"0 0 24 24"},r,{children:e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})}))},w=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-minimize-icon lucide-minimize",viewBox:"0 0 24 24"},r,{children:e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})}))},k=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-moon-icon lucide-moon",viewBox:"0 0 24 24"},r,{children:e.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9"})}))},y=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-outdent-icon lucide-outdent",viewBox:"0 0 24 24"},r,{children:[e.jsx("polyline",{points:"7 8 3 12 7 16"}),e.jsx("line",{x1:"21",x2:"11",y1:"12",y2:"12"}),e.jsx("line",{x1:"21",x2:"11",y1:"6",y2:"6"}),e.jsx("line",{x1:"21",x2:"11",y1:"18",y2:"18"})]}))},f=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-quote-icon lucide-quote",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2zM5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z"})})},C=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-rotate-ccw-icon lucide-rotate-ccw",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]}))},N=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-rotate-cw-icon lucide-rotate-cw",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e.jsx("path",{d:"M21 3v5h-5"})]}))},L=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-smile-icon lucide-smile",viewBox:"0 0 24 24"},r,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),e.jsx("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),e.jsx("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]}))},z=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-strikethrough-icon lucide-strikethrough",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4M14 12a4 4 0 0 1 0 8H6M4 12h16"})})},M=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-sun-icon lucide-sun",viewBox:"0 0 24 24"},r,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"5"}),e.jsx("line",{x1:"12",x2:"12",y1:"1",y2:"3"}),e.jsx("line",{x1:"12",x2:"12",y1:"21",y2:"23"}),e.jsx("line",{x1:"4.22",x2:"5.64",y1:"4.22",y2:"5.64"}),e.jsx("line",{x1:"18.36",x2:"19.78",y1:"18.36",y2:"19.78"}),e.jsx("line",{x1:"1",x2:"3",y1:"12",y2:"12"}),e.jsx("line",{x1:"21",x2:"23",y1:"12",y2:"12"}),e.jsx("line",{x1:"4.22",x2:"5.64",y1:"19.78",y2:"18.36"}),e.jsx("line",{x1:"18.36",x2:"19.78",y1:"5.64",y2:"4.22"})]}))},S=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-table-icon lucide-table",width:o,height:o,viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M12 3v18"}),e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),e.jsx("path",{d:"M3 9h18M3 15h18"})]})},F=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-type-icon lucide-type",viewBox:"0 0 24 24"},r,{children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",x2:"15",y1:"20",y2:"20"}),e.jsx("line",{x1:"12",x2:"12",y1:"4",y2:"20"})]}))},B=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-underline-icon lucide-underline",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),e.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]}))},E=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-video-icon lucide-video",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5"}),e.jsx("rect",{width:"14",height:"12",x:"2",y:"6",rx:"2"})]})},O=t=>{var{size:o=16}=t;return n(t,["size"]),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-x-icon lucide-x",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})},I=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-highlighter-icon lucide-highlighter",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),e.jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]}))},R=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-search-icon lucide-search",viewBox:"0 0 24 24"},r,{children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.3-4.3"})]}))},T=t=>{var{size:o=16}=t,r=n(t,["size"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-download-icon lucide-download",viewBox:"0 0 24 24"},r,{children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}))},H=({type:t,onColorSelect:n,onClose:o})=>e.jsx("div",{className:"modal-overlay",onClick:o,children:e.jsxs("div",{className:"color-picker-modal",onClick:e=>e.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"text"===t?"Text Color":"Background Color"}),e.jsx("button",{onClick:o,className:"close-button",children:e.jsx(O,{size:16})})]}),e.jsx("div",{className:"color-grid",children:["#000000","#333333","#666666","#999999","#CCCCCC","#FFFFFF","#FF0000","#FF6600","#FFCC00","#FFFF00","#CCFF00","#66FF00","#00FF00","#00FF66","#00FFCC","#00FFFF","#00CCFF","#0066FF","#0000FF","#6600FF","#CC00FF","#FF00FF","#FF00CC","#FF0066","#8B4513","#A0522D","#CD853F","#DEB887","#F4A460","#D2691E","#FF69B4","#FF1493","#DC143C","#B22222","#8B0000","#800000"].map(t=>e.jsx("button",{className:"color-swatch",style:{backgroundColor:t},onClick:()=>n(t),title:t},t))}),e.jsxs("div",{className:"custom-color",children:[e.jsx("label",{children:"Custom Color:"}),e.jsx("input",{type:"color",onChange:e=>n(e.target.value),className:"color-input"})]})]})}),W=({onEmojiSelect:t,onClose:n})=>e.jsx("div",{className:"modal-overlay",onClick:n,children:e.jsxs("div",{className:"emoji-picker-modal",onClick:e=>e.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Emoji"}),e.jsx("button",{onClick:n,className:"close-button",children:e.jsx(O,{size:16})})]}),e.jsx("div",{className:"emoji-categories",children:Object.entries({Smileys:["๐","๐","๐","๐","๐","๐
","๐","๐คฃ","๐","๐","๐","๐","๐","๐","๐","๐ฅฐ","๐","๐","๐","๐","๐","๐","๐","๐","๐คช","๐คจ","๐ง","๐ค","๐","๐คฉ","๐ฅณ"],Gestures:["๐","๐","๐","๐ค","๐ค","โ๏ธ","๐ค","๐ค","๐ค","๐ค","๐","๐","๐","๐","๐","โ๏ธ","๐","๐ค","๐๏ธ","โ","๐","๐","๐","๐คฒ","๐ค","๐"],Objects:["โค๏ธ","๐งก","๐","๐","๐","๐","๐ค","๐ค","๐ค","๐","โฃ๏ธ","๐","๐","๐","๐","๐","๐","๐","๐","โฎ๏ธ","โ๏ธ","โช๏ธ","๐๏ธ","โธ๏ธ","โก๏ธ","๐ฏ","๐","โฏ๏ธ","โฆ๏ธ"],Nature:["๐ฑ","๐ฟ","๐","๐พ","๐ต","๐ฒ","๐ณ","๐ด","๐ธ","๐บ","๐ป","๐น","๐ฅ","๐ท","๐","๐ผ","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐","โญ","๐"],Food:["๐","๐","๐","๐","๐","๐","๐","๐ซ","๐","๐","๐","๐ฅญ","๐","๐ฅฅ","๐ฅ","๐
","๐","๐ฅ","๐ฅฆ","๐ฅฌ","๐ฅ","๐ถ๏ธ","๐ซ","๐ฝ","๐ฅ","๐ซ","๐ง","๐ง
","๐ฅ","๐ "]}).map(([n,o])=>e.jsxs("div",{className:"emoji-category",children:[e.jsx("h4",{children:n}),e.jsx("div",{className:"emoji-grid",children:o.map(n=>e.jsx("button",{className:"emoji-button",onClick:()=>t(n),title:n,children:n},n))})]},n))})]})});var A={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};var U=(e,n)=>{const o=t.forwardRef(({color:o="currentColor",size:r=24,strokeWidth:i=2,absoluteStrokeWidth:s,children:l,...a},c)=>{return t.createElement("svg",{ref:c,...A,width:r,height:r,stroke:o,strokeWidth:s?24*Number(i)/Number(r):i,className:`lucide lucide-${d=e,d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,...a},[...n.map(([e,n])=>t.createElement(e,n)),...(Array.isArray(l)?l:[l])||[]]);var d});return o.displayName=`${e}`,o};const D=U("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),$=U("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),P=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),q=({isOpen:n,onClose:o,onSearch:r})=>{const[i,s]=t.useState(""),[l,a]=t.useState(""),[c,d]=t.useState(!1);return n?e.jsx("div",{className:"modal-overlay",onClick:o,children:e.jsxs("div",{className:"search-modal",onClick:e=>e.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-header",children:[e.jsx("h3",{children:c?"Find and Replace":"Find"}),e.jsx("button",{className:"close-button",onClick:o,"aria-label":"Close",children:e.jsx(O,{size:20})})]}),e.jsxs("form",{className:"search-modal-body",onSubmit:e=>{e.preventDefault(),r(i,c?l:void 0)},children:[e.jsxs("div",{className:"search-form",children:[e.jsxs("div",{className:"search-group",children:[e.jsx("label",{htmlFor:"search-term",children:"Find"}),e.jsx("input",{id:"search-term",type:"text",value:i,onChange:e=>s(e.target.value),placeholder:"Enter text to find...",autoFocus:!0})]}),c&&e.jsxs("div",{className:"search-group",children:[e.jsx("label",{htmlFor:"replace-term",children:"Replace with"}),e.jsx("input",{id:"replace-term",type:"text",value:l,onChange:e=>a(e.target.value),placeholder:"Enter replacement text..."})]})]}),e.jsxs("div",{className:"search-modal-footer",children:[e.jsx("button",{type:"button",className:"button secondary",onClick:()=>d(!c),children:c?"Find Only":"Replace Mode"}),e.jsx("button",{type:"button",className:"button secondary",onClick:()=>{s(""),a("")},children:"Clear"}),e.jsx("button",{type:"submit",className:"button primary",children:c?"Replace All":"Find"})]})]})]})}):null},V=({onCreateTable:n,onClose:o})=>{const[r,i]=t.useState(3),[s,l]=t.useState(3),[a,c]=t.useState([]),d=Array.from({length:r},(e,t)=>Array.from({length:s},(e,n)=>`${t}-${n}`));return e.jsx("div",{className:"modal-overlay",onClick:o,children:e.jsxs("div",{className:"modal-content",onClick:e=>e.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Table"}),e.jsx("button",{onClick:o,className:"close-button",children:e.jsx(O,{size:20})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Rows: ",r]}),e.jsx("input",{type:"range",min:"1",max:"10",value:r,onChange:e=>i(Number(e.target.value))})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Columns: ",s]}),e.jsx("input",{type:"range",min:"1",max:"10",value:s,onChange:e=>l(Number(e.target.value))})]}),e.jsx("div",{className:"table-preview",children:e.jsx("div",{className:"preview-grid",style:{display:"grid",gridTemplateColumns:`repeat(${s}, 1fr)`,gap:"2px",border:"1px solid #ccc",padding:"4px"},children:d.map(t=>t.map(t=>e.jsx("div",{className:"preview-cell",style:{border:"1px solid #ddd",padding:"8px",minHeight:"30px",backgroundColor:"#f9f9f9"}},t)))})})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{onClick:o,className:"button secondary",children:"Cancel"}),e.jsx("button",{onClick:()=>{n({rows:r,cols:s,data:a})},className:"button primary",children:"Create Table"})]})]})})},K=t=>{var{size:o=16,color:r="currentColor"}=t,i=n(t,["size","color"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i,{children:[e.jsx("path",{d:"M4 20h16"}),e.jsx("path",{d:"m6 16 6-12 6 12"}),e.jsx("path",{d:"M8 12h8"})]}))},G=t=>{var{size:o=16,color:r="currentColor"}=t,i=n(t,["size","color"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i,{children:[e.jsx("path",{d:"m19 11-8-8-8.6 8.6a2 2 0 0 0 0 2.8l5.2 5.2c.8.8 2 .8 2.8 0L19 11Z"}),e.jsx("path",{d:"m5 2 5 5"}),e.jsx("path",{d:"M2 13h15"}),e.jsx("path",{d:"M22 20a2 2 0 1 1-4 0c0-1.6 1.7-2.4 2-4 .3 1.6 2 2.4 2 4Z"})]}))},J=t=>{var{size:o=16,color:r="currentColor"}=t,i=n(t,["size","color"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i,{children:[e.jsx("path",{d:"m4 5 8 8"}),e.jsx("path",{d:"m12 5-8 8"}),e.jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]}))},Z=t=>{var{size:o=16,color:r="currentColor"}=t,i=n(t,["size","color"]);return e.jsxs("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},i,{children:[e.jsx("path",{d:"m4 19 8-8"}),e.jsx("path",{d:"m12 19-8-8"}),e.jsx("path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06"})]}))},Q=n=>{const{isActive:O,currentBlock:H,onAction:W,toolbarOptions:A,customTools:U=[],className:D="",canUndo:$=!1,canRedo:P=!1,isDarkMode:q=!1,isFullscreen:V=!1,onColorPicker:Q,onEmojiPicker:Y,activeDropdown:_,onDropdownChange:X,editorRef:ee}=n,te=t.useRef(null),ne=t.useRef(null),oe=t.useRef(null),re=async e=>{var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];n&&W("imageUpload",n),e.target&&(e.target.value="")},ie={bold:{icon:l,label:"Bold",shortcut:"Ctrl+B"},italic:{icon:p,label:"Italic",shortcut:"Ctrl+I"},underline:{icon:B,label:"Underline",shortcut:"Ctrl+U"},strikethrough:{icon:z,label:"Strikethrough"},subscript:{icon:J,label:"Subscript"},superscript:{icon:Z,label:"Superscript"},code:{icon:d,label:"Inline Code"},highlight:{icon:I,label:"Highlight Text"},blockquote:{icon:f,label:"Quote"},bulletList:{icon:v,label:"Bullet List"},numberList:{icon:b,label:"Numbered List"},checklist:{icon:a,label:"Checklist"},codeBlock:{icon:h,label:"Code Block"},table:{icon:S,label:"Insert Table"},link:{icon:g,label:"Insert Link",shortcut:"Ctrl+K"},image:{icon:m,label:"Insert Image"},video:{icon:E,label:"Insert Video"},emoji:{icon:L,label:"Insert Emoji"},search:{icon:R,label:"Find & Replace"},export:{icon:T,label:"Export Content"},alignLeft:{icon:i,label:"Align Left"},alignCenter:{icon:o,label:"Align Center"},alignRight:{icon:s,label:"Align Right"},alignJustify:{icon:r,label:"Justify"},indent:{icon:x,label:"Increase Indent"},outdent:{icon:y,label:"Decrease Indent"},undo:{icon:C,label:"Undo",shortcut:"Ctrl+Z"},redo:{icon:N,label:"Redo",shortcut:"Ctrl+Shift+Z"},clear:{icon:u,label:"Clear Formatting"},darkMode:{icon:q?M:k,label:q?"Light Mode":"Dark Mode"},fullscreen:{icon:V?w:j,label:V?"Exit Fullscreen":"Fullscreen"}},se=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"},{value:"blockquote",label:"Quote"},{value:"pre",label:"Code Block"}],le=["8px","10px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","64px"],ae=["Arial","Helvetica","Times New Roman","Courier New","Verdana","Georgia","Palatino","Garamond","Comic Sans MS","Trebuchet MS","Arial Black","Impact"],ce=U.reduce((e,t)=>{const n=t.group||"custom";return e[n]||(e[n]=[]),e[n].push(t),e},{}),de=[["undo","redo"],["bold","italic","underline","strikethrough","subscript","superscript","highlight"],["textColor","backgroundColor","fontSize","fontFamily"],["formatBlock"],["blockquote","code","codeBlock"],["bulletList","numberList","checklist"],["alignLeft","alignCenter","alignRight","alignJustify"],["indent","outdent"],["table","link","image","video","emoji"],["search","export"],["clear","darkMode","fullscreen"],...Object.keys(ce).map(e=>ce[e].map(e=>e.id))],ue=()=>e.jsxs("div",{className:"dropdown-container",style:{position:"relative"},children:[e.jsx("button",{className:"toolbar-button "+("image"===_?"active":""),onClick:()=>W("image"),"aria-label":"Insert Image",title:"Insert Image",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",background:"transparent",cursor:"pointer",color:"var(--text-secondary)",transition:"all 0.2s ease",position:"relative",border:"none"},children:e.jsx(m,{size:16})}),"image"===_&&e.jsxs("div",{className:"image-dropdown",style:{position:"absolute",top:"100%",left:"0",background:"var(--bg-primary)",border:"1px solid var(--border-color)",borderRadius:"4px",boxShadow:"var(--shadow-lg)",marginTop:"4px",zIndex:1e3,minWidth:"180px",padding:"4px"},children:[e.jsx("button",{className:"dropdown-item",onClick:()=>{te.current&&te.current.click(),null==X||X(null)},style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",border:"none",background:"transparent",color:"var(--text-primary)",textAlign:"left",cursor:"pointer",fontSize:"14px",transition:"all 0.2s ease",borderRadius:"4px"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-tertiary)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:e.jsx("span",{children:"Upload Image"})}),e.jsx("button",{className:"dropdown-item",onClick:()=>{W("imageUrl"),null==X||X(null)},style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",padding:"8px 12px",border:"none",background:"transparent",color:"var(--text-primary)",textAlign:"left",cursor:"pointer",fontSize:"14px",transition:"all 0.2s ease",borderRadius:"4px"},onMouseEnter:e=>{e.currentTarget.style.background="var(--bg-tertiary)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:e.jsx("span",{children:"Insert from URL"})})]}),e.jsx("input",{type:"file",ref:te,accept:"image/*",onChange:re,style:{display:"none"}})]}),he=(n,o,r,i)=>"textColor"===n||"backgroundColor"===n?(t=>{const n="textColor"===t?ne:oe,o="textColor"===t?"Text Color":"Background Color";return e.jsx("div",{className:"dropdown-container",style:{position:"relative"},children:e.jsx("button",{ref:n,className:"toolbar-button "+(O[t]?"active":""),onClick:()=>{null==Q||Q("textColor"===t?"text":"background")},"aria-label":o,title:o,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",background:"transparent",cursor:"pointer",color:"var(--text-secondary)",transition:"all 0.2s ease",position:"relative",border:"none"},children:"textColor"===t?e.jsx(K,{size:16}):e.jsx(G,{size:16})})},t)})(n):"image"===n?ue():e.jsx("button",{className:"toolbar-button "+(O[n]?"active":""),onClick:()=>W(n),"aria-label":r,title:`${r}${i?` (${i})`:""}`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"36px",height:"36px",background:"transparent",cursor:"pointer",color:"var(--text-secondary)",transition:"all 0.2s ease",position:"relative",border:"none"},children:o&&t.createElement(o,{size:16})},n),me=t=>{switch(t){case"formatBlock":return-1===A.indexOf("formatBlock")?null:e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{type:"button",className:"toolbar-button dropdown-trigger "+("formatBlock"===_?"active":""),onClick:()=>null==X?void 0:X("formatBlock"===_?null:"formatBlock"),title:"Text Format","aria-label":"Text Format","aria-expanded":"formatBlock"===_,"aria-haspopup":"true",children:[e.jsx(F,{size:16}),e.jsx(c,{size:12})]}),"formatBlock"===_&&e.jsx("div",{className:"dropdown-menu",children:se.map(t=>e.jsx("button",{type:"button",className:"dropdown-item "+(H===t.value?"active":""),onClick:()=>{W("formatBlock",t.value),null==X||X(null)},role:"menuitem",tabIndex:-1,children:t.label},t.value))})]},"formatBlock");case"fontSize":return-1===A.indexOf("fontSize")?null:e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontSize"===_?"active":""),onClick:()=>null==X?void 0:X("fontSize"===_?null:"fontSize"),title:"Font Size","aria-label":"Font Size","aria-expanded":"fontSize"===_,"aria-haspopup":"true",children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:"bold"},children:"A"}),e.jsx(c,{size:12})]}),"fontSize"===_&&e.jsx("div",{className:"dropdown-menu",children:le.map(t=>e.jsx("button",{type:"button",className:"dropdown-item",onClick:()=>{W("fontSize",t),null==X||X(null)},style:{fontSize:t},role:"menuitem",tabIndex:-1,children:t},t))})]},"fontSize");case"fontFamily":return-1===A.indexOf("fontFamily")?null:e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontFamily"===_?"active":""),onClick:()=>null==X?void 0:X("fontFamily"===_?null:"fontFamily"),title:"Font Family","aria-label":"Font Family","aria-expanded":"fontFamily"===_,"aria-haspopup":"true",children:[e.jsx("span",{style:{fontSize:"12px"},children:"Aa"}),e.jsx(c,{size:12})]}),"fontFamily"===_&&e.jsx("div",{className:"dropdown-menu",children:ae.map(t=>e.jsx("button",{type:"button",className:"dropdown-item",onClick:()=>{W("fontFamily",t),null==X||X(null)},style:{fontFamily:t},role:"menuitem",tabIndex:-1,children:t},t))})]},"fontFamily");case"textColor":return-1===A.indexOf("textColor")?null:e.jsx("button",{type:"button",className:"toolbar-button",onClick:()=>null==Q?void 0:Q("text"),title:"Text Color","aria-label":"Text Color",children:e.jsx(K,{size:16})},"textColor");case"backgroundColor":return-1===A.indexOf("backgroundColor")?null:e.jsx("button",{type:"button",className:"toolbar-button",onClick:()=>null==Q?void 0:Q("background"),title:"Background Color","aria-label":"Background Color",children:e.jsx(G,{size:16})},"backgroundColor");default:if(t in ie){const e=ie[t],n=e.icon;return he(t,n,e.label,"shortcut"in e?e.shortcut:void 0)}return null}};return e.jsx("div",{className:`scrivly-toolbar ${D}`,children:de.map((t,n)=>((t,n)=>{const o=t.map(me).filter(Boolean);return 0===o.length?null:e.jsx("div",{className:"toolbar-group",children:o},`group-${n}`)})(t,n))})},Y=({onInsertVideo:n,onClose:o})=>{const[r,i]=t.useState(""),[s,l]=t.useState(560),[a,c]=t.useState(315),[d,u]=t.useState(""),h=e=>e.includes("youtube.com")||e.includes("youtu.be")||e.includes("vimeo.com")||e.startsWith("http");return e.jsx("div",{className:"modal-overlay",onClick:o,children:e.jsxs("div",{className:"modal-content",onClick:e=>e.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:"Insert Video"}),e.jsx("button",{onClick:o,className:"close-button",children:e.jsx(O,{size:20})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Video URL *"}),e.jsx("input",{type:"url",value:r,onChange:e=>i(e.target.value),placeholder:"https://youtube.com/watch?v=... or https://vimeo.com/...",className:!h(r)&&r?"error":""}),e.jsx("small",{children:"Supports YouTube, Vimeo, and direct video URLs"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Title (optional)"}),e.jsx("input",{type:"text",value:d,onChange:e=>u(e.target.value),placeholder:"Video title"})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Width (px)"}),e.jsx("input",{type:"number",value:s,onChange:e=>l(Number(e.target.value)),min:"200",max:"1200"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Height (px)"}),e.jsx("input",{type:"number",value:a,onChange:e=>c(Number(e.target.value)),min:"150",max:"800"})]})]}),r&&h(r)&&e.jsxs("div",{className:"video-preview",children:[e.jsxs("p",{children:["Preview size: ",s," ร ",a,"px"]}),e.jsx("div",{style:{width:Math.min(s,400),height:Math.min(a,225),border:"2px dashed #ccc",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5"},children:"Video Preview"})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{onClick:o,className:"button secondary",children:"Cancel"}),e.jsx("button",{onClick:()=>{if(!r.trim())return;const e={url:r.trim(),width:s,height:a,title:d};n(e)},className:"button primary",disabled:!r.trim()||!h(r),children:"Insert Video"})]})]})})},_=({value:n="",onChange:o,onStateChange:r,toolbarOptions:i=["bold","italic","underline","strikethrough","code","textColor","backgroundColor","fontSize","fontFamily","formatBlock","blockquote","bulletList","numberList","checklist","table","link","image","video","emoji","alignLeft","alignCenter","alignRight","alignJustify","indent","outdent","lineHeight","codeBlock","undo","redo","clear","fullscreen","darkMode"],placeholder:s="Start writing something amazing...",className:l="",toolbarClassName:a="",contentClassName:c="",maxHeight:d="600px",minHeight:u="300px",readOnly:h=!1,darkMode:m=!1,onDarkModeChange:x,showWordCount:p=!0,showCharCount:g=!0,autoSave:v=!1,autoSaveInterval:b=5e3,spellCheck:j=!0,allowImageUpload:w=!1,onImageUpload:k})=>{const y=t.useRef(null),[f,C]=t.useState({}),[N,L]=t.useState("p"),[z,M]=t.useState([n]),[S,F]=t.useState(0),[B,E]=t.useState(0),[O,I]=t.useState(0),[R,T]=t.useState(m),[A,U]=t.useState(!1),[D,$]=t.useState(!1),[P,K]=t.useState(!1),[G,J]=t.useState(!1),[Z,_]=t.useState(null),[X,ee]=t.useState(!1);t.useState(null);const[te,ne]=t.useState(null),[oe,re]=t.useState(null),[ie,se]=t.useState({show:!1,x:0,y:0,element:null});t.useEffect(()=>{if(!v||!o)return;const e=setInterval(()=>{if(y.current){const e=y.current.innerHTML;o(e)}},b);return()=>clearInterval(e)},[v,b,o]),t.useEffect(()=>{T(m),document.documentElement.setAttribute("data-theme",m?"dark":"light")},[m]),t.useEffect(()=>{y.current&&n!==y.current.innerHTML&&(y.current.innerHTML=n,le())},[n]);const le=t.useCallback(()=>{if(!y.current)return;const e=y.current.textContent||"",t=e.trim().split(/\s+/).filter(e=>e.length>0);E(t.length),I(e.length)},[]),ae=t.useCallback(()=>{if(!y.current)return;const e=window.getSelection();if(!e||0===e.rangeCount)return;const t={};t.bold=document.queryCommandState("bold"),t.italic=document.queryCommandState("italic"),t.underline=document.queryCommandState("underline"),t.strikethrough=document.queryCommandState("strikeThrough"),t.subscript=document.queryCommandState("subscript"),t.superscript=document.queryCommandState("superscript"),t.alignLeft=document.queryCommandState("justifyLeft"),t.alignCenter=document.queryCommandState("justifyCenter"),t.alignRight=document.queryCommandState("justifyRight"),t.alignJustify=document.queryCommandState("justifyFull"),t.bulletList=document.queryCommandState("insertUnorderedList"),t.numberList=document.queryCommandState("insertOrderedList");const n=document.queryCommandValue("formatBlock").toLowerCase();L(n||"div");let o=e.getRangeAt(0).commonAncestorContainer;for(t.code=!1,t.codeBlock=!1,t.blockquote=!1;o&&o!==y.current;){if(o.nodeType===Node.ELEMENT_NODE){const e=o;"CODE"===e.tagName&&(t.code=!0),"PRE"===e.tagName&&(t.codeBlock=!0),"BLOCKQUOTE"===e.tagName&&(t.blockquote=!0)}o=o.parentNode}C(t)},[]),ce=t.useCallback(()=>{if(!y.current)return;const e=y.current.innerHTML;null==o||o(e),le(),ae(),M(t=>{const n=t.slice(0,S+1);return n.push(e),n.slice(-50)}),F(e=>e+1),null==r||r({content:e,activeFormats:new Set(Object.keys(f).filter(e=>f[e])),currentBlock:N,isDarkMode:R,isFullscreen:A})},[o,S,f,N,R,A,r,le,ae]),de=t.useCallback((e,t)=>{y.current&&(y.current.focus(),document.execCommand(e,!1,t),ae(),ce())},[ae,ce]),ue=t.useCallback(e=>{y.current&&(y.current.focus(),document.execCommand("insertHTML",!1,e),ce())},[ce]),he=t.useCallback(e=>{var t,n;const{rows:o,cols:r}=e;let i='<table class="scrivly-table" style="\n border-collapse: collapse; \n width: 100%; \n margin: 1rem 0; \n background: var(--bg-primary); \n border-radius: 6px; \n overflow: hidden; \n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n ">';for(let s=0;s<o;s++){i+="<tr>";for(let o=0;o<r;o++){const r=(null===(n=null===(t=e.data)||void 0===t?void 0:t[s])||void 0===n?void 0:n[o])||"";i+=0===s?`<th style="\n border: 1px solid var(--border-color); \n padding: 12px; \n min-width: 100px;\n background: var(--bg-tertiary);\n font-weight: 600;\n outline: none;\n " contenteditable="true">${r||`Header ${o+1}`}</th>`:`<td style="\n border: 1px solid var(--border-color); \n padding: 12px; \n min-width: 100px;\n outline: none;\n " contenteditable="true">${r}</td>`}i+="</tr>"}i+="</table>",ue(i),$(!1)},[ue]),me=t.useCallback(e=>{var t;const{url:n,width:o,height:r,title:i}=e;let s=n;if(n.includes("youtube.com")||n.includes("youtu.be")){s=`https://www.youtube.com/embed/${n.includes("youtube.com")?null===(t=n.split("v=")[1])||void 0===t?void 0:t.split("&")[0]:n.split("youtu.be/")[1]}`}else if(n.includes("vimeo.com")){s=`https://player.vimeo.com/video/${n.split("vimeo.com/")[1]}`}ue(`\n <div class="video-container" style="position: relative; margin: 1rem 0; resize: both; overflow: hidden; width: ${o}px; height: ${r}px; border: 2px dashed #ccc;">\n <iframe \n src="${s}" \n width="100%" \n height="100%" \n frameborder="0" \n allowfullscreen\n title="${i||"Video"}"\n style="display: block;">\n </iframe>\n <div class="resize-handle" style="position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; background: #666; cursor: se-resize;"></div>\n </div>\n `),K(!1)},[ue]),xe=t.useMemo(()=>({bold:()=>de("bold"),italic:()=>de("italic"),underline:()=>de("underline"),strikethrough:()=>de("strikeThrough"),subscript:()=>de("subscript"),superscript:()=>de("superscript"),code:()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(t.collapsed)return;const n=document.createElement("code");n.style.backgroundColor="#f1f5f9",n.style.padding="0.2rem 0.4rem",n.style.borderRadius="4px",n.style.fontFamily="monospace";try{t.surroundContents(n),ce()}catch(e){console.warn("Could not apply code formatting")}},highlight:()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(t.collapsed)return;const n=document.createElement("mark");n.style.backgroundColor="#fef08a",n.style.padding="0.1rem 0.2rem",n.style.borderRadius="3px";try{t.surroundContents(n),ce()}catch(e){console.warn("Could not apply highlight formatting")}},formatBlock:e=>de("formatBlock",e),blockquote:()=>de("formatBlock","blockquote"),bulletList:()=>de("insertUnorderedList"),numberList:()=>de("insertOrderedList"),checklist:()=>{ue('\n <ul style="list-style: none; padding-left: 0;">\n <li style="margin: 0.5rem 0;">\n <input type="checkbox" style="margin-right: 0.5rem;"> \n <span contenteditable="true">New task</span>\n </li>\n </ul>\n ')},codeBlock:()=>{ue('\n <pre style="background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 8px; overflow-x: auto; font-family: monospace;"><code contenteditable="true">// Your code here</code></pre>\n ')},alignLeft:()=>de("justifyLeft"),alignCenter:()=>de("justifyCenter"),alignRight:()=>de("justifyRight"),alignJustify:()=>de("justifyFull"),indent:()=>de("indent"),outdent:()=>de("outdent"),fontSize:e=>{de("fontSize","7"),de("fontName",e)},fontFamily:e=>de("fontName",e),textColor:e=>{_("text"===Z?null:"text")},backgroundColor:e=>{_("background"===Z?null:"background")},link:()=>{const e=prompt("Enter URL:");e&&de("createLink",e)},image:()=>{ne("image"===te?null:"image")},imageUrl:()=>{const e=prompt("Enter image URL:");if(e){ue(`\n <div class="image-container" style="position: relative; display: inline-block; margin: 1rem 0; resize: both; overflow: hidden; max-width: 100%;">\n <img src="${e}" alt="Image" style="width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px;" \n onload="this.parentElement.style.width = Math.min(this.naturalWidth, 600) + 'px'; this.parentElement.style.height = Math.min(this.naturalHeight, 400) + 'px';" />\n <div class="resize-handle" style="position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; background: #666; cursor: se-resize; opacity: 0; transition: opacity 0.2s;"></div>\n </div>\n `)}ne(null)},imageUpload:async e=>{if(w&&k)try{const t=await k(e);ue(`\n <div class="image-container" style="position: relative; display: inline-block; margin: 1rem 0; resize: both; overflow: hidden; max-width: 100%;">\n <img src="${t}" alt="Image" style="width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px;" \n onload="this.parentElement.style.width = Math.min(this.naturalWidth, 600) + 'px'; this.parentElement.style.height = Math.min(this.naturalHeight, 400) + 'px';" />\n <div class="resize-handle" style="position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; background: #666; cursor: se-resize; opacity: 0; transition: opacity 0.2s;"></div>\n </div>\n `)}catch(e){console.error("Image upload failed:",e),alert("Failed to upload image. Please try again.")}else{const t=URL.createObjectURL(e);ue(`\n <div class="image-container" style="position: relative; display: inline-block; margin: 1rem 0; resize: both; overflow: hidden; max-width: 100%;">\n <img src="${t}" alt="Image" style="width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px;" \n onload="this.parentElement.style.width = Math.min(this.naturalWidth, 600) + 'px'; this.parentElement.style.height = Math.min(this.naturalHeight, 400) + 'px';" />\n <div class="resize-handle" style="position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; background: #666; cursor: se-resize; opacity: 0; transition: opacity 0.2s;"></div>\n </div>\n `)}ne(null)},table:()=>$(!0),video:()=>K(!0),emoji:()=>ee(!0),clear:()=>de("removeFormat"),undo:()=>{if(S>0){const e=S-1,t=z[e];y.current&&(y.current.innerHTML=t,null==o||o(t),F(e),le())}},redo:()=>{if(S<z.length-1){const e=S+1,t=z[e];y.current&&(y.current.innerHTML=t,null==o||o(t),F(e),le())}},darkMode:()=>{const e=!R;T(e),null==x||x(e),document.documentElement.setAttribute("data-theme",e?"dark":"light")},fullscreen:()=>{U(!A)},search:()=>{J(!0)},export:()=>{if(y.current){const e=y.current.innerHTML,t=new Blob([e],{type:"text/html"}),n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download="scrivly-content.html",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}}}),[de,ue,ce,S,z,o,le,R,x,A,Z,te,w,k,ue]);t.useEffect(()=>{const e=()=>{document.activeElement===y.current&&ae()};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[ae]);const pe=t.useCallback(e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t),ce()},[ce]),ge=t.useCallback(e=>{var t;if(e.altKey)switch(e.key){case"t":e.preventDefault();const t=document.querySelector(".toolbar-button");t instanceof HTMLElement&&t.focus();break;case"e":e.preventDefault(),y.current&&y.current.focus()}if(e.ctrlKey||e.metaKey)switch(e.key){case"b":e.preventDefault(),xe.bold();break;case"i":e.preventDefault(),xe.italic();break;case"u":e.preventDefault(),xe.underline();break;case"z":e.preventDefault(),e.shiftKey?xe.redo():xe.undo();break;case"k":e.preventDefault(),xe.link();break;case"h":e.preventDefault(),xe.highlight();break;case"f":e.preventDefault(),xe.search()}if("Tab"===e.key&&!e.ctrlKey&&!e.metaKey){const n=window.getSelection();if(n&&n.rangeCount>0){const o=null===(t=n.getRangeAt(0).startContainer.parentElement)||void 0===t?void 0:t.closest("td, th");if(o)if(e.preventDefault(),e.shiftKey){const e=we(o);if(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!1),n.removeAllRanges(),n.addRange(t)}}else{const e=je(o);if(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!1),n.removeAllRanges(),n.addRange(t)}}}document.activeElement===y.current&&(e.preventDefault(),e.shiftKey?xe.outdent():xe.indent())}},[xe,y]),ve=t.useCallback((e,t)=>{var n,o;if(!t)return;const r=t.closest("table");if(!r)return;const i=t.closest("td, th"),s=t.closest("tr");switch(e){case"addRowAbove":if(s){const e=r.insertRow(s.rowIndex),t=s.cells.length;for(let n=0;n<t;n++){const t=e.insertCell();t.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px; outline: none;",t.contentEditable="true",t.innerHTML=" "}}break;case"addRowBelow":case"addRow":if(s){const e=r.insertRow(s.rowIndex+1),t=s.cells.length;for(let n=0;n<t;n++){const t=e.insertCell();t.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px; outline: none;",t.contentEditable="true",t.innerHTML=" "}}else{const e=r.insertRow(),t=(null===(n=r.rows[0])||void 0===n?void 0:n.cells.length)||1;for(let n=0;n<t;n++){const t=e.insertCell();t.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px; outline: none;",t.contentEditable="true",t.innerHTML=" "}}break;case"addColumnLeft":if(i&&s){const e=Array.from(s.cells).indexOf(i);Array.from(r.rows).forEach(t=>{const n=t.insertCell(e);n.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px; outline: none;",n.contentEditable="true",n.innerHTML=" "})}break;case"addColumnRight":case"addColumn":if(i&&s){const e=Array.from(s.cells).indexOf(i);Array.from(r.rows).forEach(t=>{const n=t.insertCell(e+1);n.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px; outline: none;",n.contentEditable="true",n.innerHTML=" "})}else Array.from(r.rows).forEach(e=>{const t=e.insertCell();t.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px; outline: none;",t.contentEditable="true",t.innerHTML=" "});break;case"deleteRow":s&&r.rows.length>1&&r.rows.length>1&&s.remove();break;case"deleteColumn":if(i&&s){const e=Array.from(s.cells).indexOf(i);(null===(o=r.rows[0])||void 0===o?void 0:o.cells.length)>1&&Array.from(r.rows).forEach(t=>{t.cells[e]&&t.deleteCell(e)})}break;case"deleteTable":confirm("Are you sure you want to delete this table?")&&r.remove()}if(ce(),r){r.querySelectorAll("td, th").forEach(e=>{e.style.transition="background-color 0.3s ease",e.style.backgroundColor="var(--accent-primary)",setTimeout(()=>{e.style.backgroundColor=""},300)})}},[ce]),be=t.useCallback(e=>{const t=e.target,n=t.closest("table");n&&(e.preventDefault(),re(n),se({show:!0,x:e.clientX,y:e.clientY,element:t}))},[]);t.useCallback(e=>{ie.element&&ve(e,ie.element),se({show:!1,x:0,y:0,element:null})},[ve,ie.element]),t.useEffect(()=>{const e=e=>{const t=e.target;t.closest(".dropdown-container")||ne(null),t.