scrivly
Version:
A powerful, feature-rich rich text editor for React with TypeScript support
3 lines (2 loc) • 47 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 s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]])}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"})}))},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-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"})}))},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-align-right-icon lucide-align-right",viewBox:"0 0 24 24"},o,{children:e.jsx("path",{d:"M21 12H9M21 18H7M21 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-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,s=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},s,{children:e.jsx("path",{d:"m6 9 6 6 6-6"})}))},d=t=>{var{size:o=16}=t,s=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"},s,{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,s=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"},s,{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,s=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"},s,{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,s=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"},s,{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,s=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"},s,{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,s=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"},s,{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"})})},j=t=>{var{size:o=16}=t,s=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"},s,{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"})]}))},b=t=>{var{size:o=16}=t,s=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"},s,{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,s=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"},s,{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,s=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"},s,{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,s=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"},s,{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.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-palette-icon lucide-palette",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),e.jsx("circle",{cx:"13.5",cy:"6.5",r:"0.5",fill:"currentColor"}),e.jsx("circle",{cx:"17.5",cy:"10.5",r:"0.5",fill:"currentColor"}),e.jsx("circle",{cx:"6.5",cy:"12.5",r:"0.5",fill:"currentColor"}),e.jsx("circle",{cx:"8.5",cy:"7.5",r:"0.5",fill:"currentColor"})]})},C=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"})})},N=t=>{var{size:o=16}=t,s=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"},s,{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"})]}))},L=t=>{var{size:o=16}=t,s=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"},s,{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"})]}))},z=t=>{var{size:o=16}=t,s=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"},s,{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"})]}))},M=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"})})},S=t=>{var{size:o=16}=t,s=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-subscript-icon lucide-subscript",viewBox:"0 0 24 24"},s,{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-2s1.5.5 1.5 2Z"})]}))},F=t=>{var{size:o=16}=t,s=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"},s,{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"})]}))},B=t=>{var{size:o=16}=t,s=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-superscript-icon lucide-superscript",viewBox:"0 0 24 24"},s,{children:[e.jsx("path",{d:"m4 19 8-8"}),e.jsx("path",{d:"m12 19 8-8"}),e.jsx("path",{d:"M20 7h-4c0-1.5.44-2 1.5-2s1.5.5 1.5 2Z"})]}))},E=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"})]})},O=t=>{var{size:o=16}=t,s=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"},s,{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"})]}))},H=t=>{var{size:o=16}=t,s=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"},s,{children:[e.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),e.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]}))},T=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"})]})},W=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=({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(W,{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"})]})]})}),R=({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(W,{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 D=(e,n)=>{const o=t.forwardRef(({color:o="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,children:r,...a},c)=>{return t.createElement("svg",{ref:c,...A,width:s,height:s,stroke:o,strokeWidth:l?24*Number(i)/Number(s):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(r)?r:[r])||[]]);var d});return o.displayName=`${e}`,o};const q=D("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"}]]),P=D("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"}]]),$=D("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),V=({onCreateTable:n,onClose:o})=>{const[s,i]=t.useState(3),[l,r]=t.useState(3),[a,c]=t.useState([]),d=Array.from({length:s},(e,t)=>Array.from({length:l},(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(W,{size:20})})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Rows: ",s]}),e.jsx("input",{type:"range",min:"1",max:"10",value:s,onChange:e=>i(Number(e.target.value))})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Columns: ",l]}),e.jsx("input",{type:"range",min:"1",max:"10",value:l,onChange:e=>r(Number(e.target.value))})]}),e.jsx("div",{className:"table-preview",children:e.jsx("div",{className:"preview-grid",style:{display:"grid",gridTemplateColumns:`repeat(${l}, 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:s,cols:l,data:a})},className:"button primary",children:"Create Table"})]})]})})},U=({isActive:t,currentBlock:n,onAction:W,toolbarOptions:I,customTools:R=[],className:A="",canUndo:D=!1,canRedo:q=!1,isDarkMode:P=!1,isFullscreen:$=!1,onColorPicker:V,onEmojiPicker:U,activeDropdown:G,onDropdownChange:J,editorRef:K})=>{const Z={bold:{icon:r,label:"Bold",shortcut:"Ctrl+B"},italic:{icon:p,label:"Italic",shortcut:"Ctrl+I"},underline:{icon:H,label:"Underline",shortcut:"Ctrl+U"},strikethrough:{icon:M,label:"Strikethrough"},subscript:{icon:S,label:"Subscript"},superscript:{icon:B,label:"Superscript"},code:{icon:d,label:"Inline Code"},blockquote:{icon:C,label:"Quote"},bulletList:{icon:v,label:"Bullet List"},numberList:{icon:j,label:"Numbered List"},checklist:{icon:a,label:"Checklist"},codeBlock:{icon:h,label:"Code Block"},table:{icon:E,label:"Insert Table"},link:{icon:g,label:"Insert Link",shortcut:"Ctrl+K"},image:{icon:m,label:"Insert Image"},video:{icon:T,label:"Insert Video"},emoji:{icon:z,label:"Insert Emoji"},alignLeft:{icon:i,label:"Align Left"},alignCenter:{icon:o,label:"Align Center"},alignRight:{icon:l,label:"Align Right"},alignJustify:{icon:s,label:"Justify"},indent:{icon:x,label:"Increase Indent"},outdent:{icon:y,label:"Decrease Indent"},undo:{icon:N,label:"Undo",shortcut:"Ctrl+Z"},redo:{icon:L,label:"Redo",shortcut:"Ctrl+Shift+Z"},clear:{icon:u,label:"Clear Formatting"},darkMode:{icon:P?F:k,label:P?"Light Mode":"Dark Mode"},fullscreen:{icon:$?w:b,label:$?"Exit Fullscreen":"Fullscreen"}},Q=[{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"}],Y=["8px","10px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","64px"],_=["Arial","Helvetica","Times New Roman","Courier New","Verdana","Georgia","Palatino","Garamond","Comic Sans MS","Trebuchet MS","Arial Black","Impact"],X=R.reduce((e,t)=>{const n=t.group||"custom";return e[n]||(e[n]=[]),e[n].push(t),e},{}),ee=[["undo","redo"],["bold","italic","underline","strikethrough","subscript","superscript"],["textColor","backgroundColor","fontSize","fontFamily"],["formatBlock"],["blockquote","code","codeBlock"],["bulletList","numberList","checklist"],["alignLeft","alignCenter","alignRight","alignJustify"],["indent","outdent"],["table","link","image","video","emoji"],["clear","darkMode","fullscreen"],...Object.keys(X).map(e=>X[e].map(e=>e.id))],te=o=>{switch(o){case"formatBlock":return I.includes("formatBlock")?e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{type:"button",className:"toolbar-button dropdown-trigger "+("formatBlock"===G?"active":""),onClick:()=>null==J?void 0:J("formatBlock"===G?null:"formatBlock"),title:"Text Format",children:[e.jsx(O,{size:16}),e.jsx(c,{size:12})]}),"formatBlock"===G&&e.jsx("div",{className:"dropdown-menu",children:Q.map(t=>e.jsx("button",{type:"button",className:"dropdown-item "+(n===t.value?"active":""),onClick:()=>{W("formatBlock",t.value),null==J||J(null)},children:t.label},t.value))})]},"formatBlock"):null;case"fontSize":return I.includes("fontSize")?e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontSize"===G?"active":""),onClick:()=>null==J?void 0:J("fontSize"===G?null:"fontSize"),title:"Font Size",children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:"bold"},children:"A"}),e.jsx(c,{size:12})]}),"fontSize"===G&&e.jsx("div",{className:"dropdown-menu",children:Y.map(t=>e.jsx("button",{type:"button",className:"dropdown-item",onClick:()=>{W("fontSize",t),null==J||J(null)},style:{fontSize:t},children:t},t))})]},"fontSize"):null;case"fontFamily":return I.includes("fontFamily")?e.jsxs("div",{className:"dropdown-container",children:[e.jsxs("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontFamily"===G?"active":""),onClick:()=>null==J?void 0:J("fontFamily"===G?null:"fontFamily"),title:"Font Family",children:[e.jsx("span",{style:{fontSize:"12px"},children:"Aa"}),e.jsx(c,{size:12})]}),"fontFamily"===G&&e.jsx("div",{className:"dropdown-menu",children:_.map(t=>e.jsx("button",{type:"button",className:"dropdown-item",onClick:()=>{W("fontFamily",t),null==J||J(null)},style:{fontFamily:t},children:t},t))})]},"fontFamily"):null;case"textColor":return I.includes("textColor")?e.jsxs("button",{type:"button",className:"toolbar-button color-button",onClick:()=>null==V?void 0:V("text"),title:"Text Color",children:[e.jsx(f,{size:16}),e.jsx("div",{className:"color-indicator text-color"})]},"textColor"):null;case"backgroundColor":return I.includes("backgroundColor")?e.jsx("button",{type:"button",className:"toolbar-button color-button",onClick:()=>null==V?void 0:V("background"),title:"Background Color",children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(f,{size:16}),e.jsx("div",{className:"color-indicator bg-color"})]})},"backgroundColor"):null;default:return(n=>{if(!I.includes(n)&&"customTool"!==n)return null;const o=R.find(e=>e.id===n);if(o){const n=o.icon,s=t[o.id];return e.jsx("button",{type:"button",className:"toolbar-button "+(s?"active":""),onClick:()=>W(o.id),title:o.tooltip,children:e.jsx(n,{size:16})},o.id)}const s=Z[n];if(!s)return null;const i=s.icon,l=t[n],r="undo"===n&&!D||"redo"===n&&!q;return e.jsx("button",{type:"button",className:`toolbar-button ${l?"active":""} ${r?"disabled":""}`,onClick:()=>!r&&W(n),title:s.shortcut?`${s.label} (${s.shortcut})`:s.label,disabled:r,children:e.jsx(i,{size:16})},n)})(o)}};return e.jsx("div",{className:`scrivly-toolbar ${A}`,children:ee.map(t=>{const n=t.map(te).filter(Boolean);return 0===n.length?null:e.jsx("div",{className:"toolbar-group",children:n},t.join("-"))})})},G=({onInsertVideo:n,onClose:o})=>{const[s,i]=t.useState(""),[l,r]=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(W,{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:s,onChange:e=>i(e.target.value),placeholder:"https://youtube.com/watch?v=... or https://vimeo.com/...",className:!h(s)&&s?"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:l,onChange:e=>r(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"})]})]}),s&&h(s)&&e.jsxs("div",{className:"video-preview",children:[e.jsxs("p",{children:["Preview size: ",l," × ",a,"px"]}),e.jsx("div",{style:{width:Math.min(l,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(!s.trim())return;const e={url:s.trim(),width:l,height:a,title:d};n(e)},className:"button primary",disabled:!s.trim()||!h(s),children:"Insert Video"})]})]})})},J=({value:n="",onChange:o,onStateChange:s,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:l="Start writing something amazing...",className:r="",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:j=5e3,spellCheck:b=!0})=>{const w=t.useRef(null),[k,y]=t.useState({}),[f,C]=t.useState("p"),[N,L]=t.useState([n]),[z,M]=t.useState(0),[S,F]=t.useState(0),[B,E]=t.useState(0),[O,H]=t.useState(m),[T,W]=t.useState(!1),[A,D]=t.useState(!1),[q,P]=t.useState(!1),[$,J]=t.useState(null),[K,Z]=t.useState(!1);t.useState(null);const[Q,Y]=t.useState(null),[_,X]=t.useState(null),[ee,te]=t.useState({show:!1,x:0,y:0,element:null});t.useEffect(()=>{if(!v||!o)return;const e=setInterval(()=>{if(w.current){const e=w.current.innerHTML;o(e)}},j);return()=>clearInterval(e)},[v,j,o]),t.useEffect(()=>{H(m),document.documentElement.setAttribute("data-theme",m?"dark":"light")},[m]),t.useEffect(()=>{w.current&&n!==w.current.innerHTML&&(w.current.innerHTML=n,ne())},[n]);const ne=t.useCallback(()=>{if(!w.current)return;const e=w.current.textContent||"",t=e.trim().split(/\s+/).filter(e=>e.length>0);F(t.length),E(e.length)},[]),oe=t.useCallback(()=>{if(!w.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();C(n||"div");let o=e.getRangeAt(0).commonAncestorContainer;for(t.code=!1,t.codeBlock=!1,t.blockquote=!1;o&&o!==w.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}y(t)},[]),se=t.useCallback(()=>{if(!w.current)return;const e=w.current.innerHTML;null==o||o(e),ne(),oe(),L(t=>{const n=t.slice(0,z+1);return n.push(e),n.slice(-50)}),M(e=>e+1),null==s||s({content:e,activeFormats:new Set(Object.keys(k).filter(e=>k[e])),currentBlock:f,isDarkMode:O,isFullscreen:T})},[o,z,k,f,O,T,s,ne,oe]),ie=t.useCallback((e,t)=>{w.current&&(w.current.focus(),document.execCommand(e,!1,t),oe(),se())},[oe,se]),le=t.useCallback(e=>{w.current&&(w.current.focus(),document.execCommand("insertHTML",!1,e),se())},[se]),re=t.useCallback(e=>{var t,n;const{rows:o,cols:s}=e;let i='<table class="editor-table" style="border-collapse: collapse; width: 100%; margin: 1rem 0;">';for(let l=0;l<o;l++){i+="<tr>";for(let o=0;o<s;o++){i+=`<td style="border: 1px solid #ccc; padding: 8px; min-width: 100px;" contenteditable="true">${(null===(n=null===(t=e.data)||void 0===t?void 0:t[l])||void 0===n?void 0:n[o])||""}</td>`}i+="</tr>"}i+="</table>",le(i),D(!1)},[le]),ae=t.useCallback(e=>{var t;const{url:n,width:o,height:s,title:i}=e;let l=n;if(n.includes("youtube.com")||n.includes("youtu.be")){l=`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")){l=`https://player.vimeo.com/video/${n.split("vimeo.com/")[1]}`}le(`\n <div class="video-container" style="position: relative; margin: 1rem 0; resize: both; overflow: hidden; width: ${o}px; height: ${s}px; border: 2px dashed #ccc;">\n <iframe \n src="${l}" \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 `),P(!1)},[le]),ce=t.useMemo(()=>({bold:()=>ie("bold"),italic:()=>ie("italic"),underline:()=>ie("underline"),strikethrough:()=>ie("strikeThrough"),subscript:()=>ie("subscript"),superscript:()=>ie("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),se()}catch(e){console.warn("Could not apply code formatting")}},formatBlock:e=>ie("formatBlock",e),blockquote:()=>ie("formatBlock","blockquote"),bulletList:()=>ie("insertUnorderedList"),numberList:()=>ie("insertOrderedList"),checklist:()=>{le('\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:()=>{le('\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:()=>ie("justifyLeft"),alignCenter:()=>ie("justifyCenter"),alignRight:()=>ie("justifyRight"),alignJustify:()=>ie("justifyFull"),indent:()=>ie("indent"),outdent:()=>ie("outdent"),fontSize:e=>{ie("fontSize","7"),ie("fontName",e)},fontFamily:e=>ie("fontName",e),textColor:e=>ie("foreColor",e),backgroundColor:e=>ie("backColor",e),link:()=>{const e=prompt("Enter URL:");e&&ie("createLink",e)},image:()=>{const e=prompt("Enter image URL:");if(e){le(`\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 `)}},table:()=>D(!0),video:()=>P(!0),emoji:()=>Z(!0),clear:()=>ie("removeFormat"),undo:()=>{if(z>0){const e=z-1,t=N[e];w.current&&(w.current.innerHTML=t,null==o||o(t),M(e),ne())}},redo:()=>{if(z<N.length-1){const e=z+1,t=N[e];w.current&&(w.current.innerHTML=t,null==o||o(t),M(e),ne())}},darkMode:()=>{const e=!O;H(e),null==x||x(e),document.documentElement.setAttribute("data-theme",e?"dark":"light")},fullscreen:()=>{W(!T)}}),[ie,le,se,z,N,o,ne,O,x,T]);t.useEffect(()=>{const e=()=>{document.activeElement===w.current&&oe()};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[oe]);const de=t.useCallback(e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t),se()},[se]),ue=t.useCallback(e=>{if(e.ctrlKey||e.metaKey)switch(e.key){case"b":e.preventDefault(),ce.bold();break;case"i":e.preventDefault(),ce.italic();break;case"u":e.preventDefault(),ce.underline();break;case"z":e.preventDefault(),e.shiftKey?ce.redo():ce.undo();break;case"k":e.preventDefault(),ce.link()}},[ce]),he=t.useCallback((e,t)=>{var n,o;if(!t)return;const s=t.closest("table");if(!s)return;const i=t.closest("td, th"),l=t.closest("tr");switch(e){case"addRowAbove":if(l){const e=s.insertRow(l.rowIndex),t=l.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;",t.contentEditable="true",t.innerHTML=" "}}break;case"addRowBelow":case"addRow":if(l){const e=s.insertRow(l.rowIndex+1),t=l.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;",t.contentEditable="true",t.innerHTML=" "}}else{const e=s.insertRow(),t=(null===(n=s.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;",t.contentEditable="true",t.innerHTML=" "}}break;case"addColumnLeft":if(i){const e=Array.from(l.cells).indexOf(i);Array.from(s.rows).forEach(t=>{const n=t.insertCell(e);n.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px;",n.contentEditable="true",n.innerHTML=" "})}break;case"addColumnRight":case"addColumn":if(i){const e=Array.from(l.cells).indexOf(i);Array.from(s.rows).forEach(t=>{const n=t.insertCell(e+1);n.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px;",n.contentEditable="true",n.innerHTML=" "})}else Array.from(s.rows).forEach(e=>{const t=e.insertCell();t.style.cssText="border: 1px solid var(--border-color); padding: 12px; min-width: 100px;",t.contentEditable="true",t.innerHTML=" "});break;case"deleteRow":l&&s.rows.length>1&&l.remove();break;case"deleteColumn":if(i){const e=Array.from(l.cells).indexOf(i);(null===(o=s.rows[0])||void 0===o?void 0:o.cells.length)>1&&Array.from(s.rows).forEach(t=>{t.cells[e]&&t.deleteCell(e)})}}se();s.querySelectorAll("td, th").forEach(e=>{e.style.transition="background-color 0.3s ease",e.style.backgroundColor="var(--accent-primary)",setTimeout(()=>{e.style.backgroundColor=""},300)})},[se]),me=t.useCallback(e=>{const t=e.target,n=t.closest("table");n&&(e.preventDefault(),X(n),te({show:!0,x:e.clientX,y:e.clientY,element:t}))},[]);return t.useEffect(()=>{const e=e=>{const t=e.target;t.closest(".dropdown-container")||Y(null),t.closest(".table-context-menu")||t.closest("table")||te({show:!1,x:0,y:0,element:null}),t.closest(".modal-content")||t.closest(".color-picker-modal")||t.closest(".emoji-picker-modal")||(J(null),Z(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),e.jsxs("div",{className:`scrivly-editor ${r} ${O?"dark":""} ${T?"fullscreen":""}`,children:[e.jsx(U,{isActive:k,currentBlock:f,onAction:(e,t)=>{"function"==typeof ce[e]&&ce[e](t)},toolbarOptions:i,className:a,canUndo:z>0,canRedo:z<N.length-1,isDarkMode:O,isFullscreen:T,onColorPicker:e=>J(e),onEmojiPicker:()=>Z(!0),activeDropdown:Q,onDropdownChange:Y}),e.jsx("div",{className:"scrivly-editor-container",style:{maxHeight:T?"100vh":d,minHeight:u},children:e.jsx("div",{ref:w,contentEditable:!h,className:`scrivly-editor-content ${c}`,onInput:se,onPaste:de,onKeyDown:ue,onContextMenu:me,"data-placeholder":l,spellCheck:b,suppressContentEditableWarning:!0})}),(p||g||ee.show)&&e.jsxs("div",{className:"scrivly-editor-footer",children:[e.jsxs("div",{className:"scrivly-editor-stats",children:[p&&e.jsxs("span",{children:[S," words"]}),g&&e.jsxs("span",{children:[B," characters"]})]}),_&&e.jsx("div",{className:"table-info",children:e.jsx("span",{children:"Table selected - Right-click for options"})})]}),ee.show&&e.jsx("div",{className:"table-context-menu",style:{position:"fixed",top:ee.y,left:ee.x,zIndex:1e4},children:e.jsxs("div",{className:"context-menu-content",children:[e.jsx("button",{className:"context-menu-item",onClick:()=>{he("addRowAbove",ee.element),te({show:!1,x:0,y:0,element:null})},children:"➕ Add Row Above"}),e.jsx("button",{className:"context-menu-item",onClick:()=>{he("addRowBelow",ee.element),te({show:!1,x:0,y:0,element:null})},children:"➕ Add Row Below"}),e.jsx("button",{className:"context-menu-item",onClick:()=>{he("addColumnLeft",ee.element),te({show:!1,x:0,y:0,element:null})},children:"➕ Add Column Left"}),e.jsx("button",{className:"context-menu-item",onClick:()=>{he("addColumnRight",ee.element),te({show:!1,x:0,y:0,element:null})},children:"➕ Add Column Right"}),e.jsx("div",{className:"context-menu-divider"}),e.jsx("button",{className:"context-menu-item danger",onClick:()=>{he("deleteRow",ee.element),te({show:!1,x:0,y:0,element:null})},children:"🗑️ Delete Row"}),e.jsx("button",{className:"context-menu-item danger",onClick:()=>{he("deleteColumn",ee.element),te({show:!1,x:0,y:0,element:null})},children:"🗑️ Delete Column"}),e.jsx("button",{className:"context-menu-item danger",onClick:()=>{confirm("Are you sure you want to delete this table?")&&(null==_||_.remove(),se()),te({show:!1,x:0,y:0,element:null})},children:"🗑️ Delete Table"})]})}),A&&e.jsx(V,{onCreateTable:re,onClose:()=>D(!1)}),q&&e.jsx(G,{onInsertVideo:ae,onClose:()=>P(!1)}),$&&e.jsx(I,{type:$,onColorSelect:e=>{"text"===$?ce.textColor(e):ce.backgroundColor(e),J(null)},onClose:()=>J(null)}),K&&e.jsx(R,{onEmojiSelect:e=>{le(e),Z(!1)},onClose:()=>Z(!1)})]})};exports.ColorPicker=I,exports.EmojiPicker=R,exports.ImageModal=({onInsertImage:n,onClose:o,allowUpload:s=!1,onImageUpload:i})=>{const[l,r]=t.useState("url"),[a,c]=t.useState(""),[d,u]=t.useState(400),[h,m]=t.useState(300),[x,p]=t.useState(""),[g,v]=t.useState(""),[j,b]=t.useState(!1),[w,k]=t.useState(""),y=e=>{try{return new URL(e),e.match(/\.(jpg|jpeg|png|gif|webp|svg)$/i)||e.includes("data:image/")}catch(e){return!1}};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 Image"}),e.jsx("button",{onClick:o,className:"close-button",children:e.jsx($,{size:20})})]}),e.jsxs("div",{className:"modal-body",children:[s&&e.jsx("div",{className:"tab-container",children:e.jsxs("div",{className:"tab-buttons",children:[e.jsxs("button",{className:"tab-button "+("url"===l?"active":""),onClick:()=>r("url"),children:[e.jsx(q,{size:16}),"URL"]}),e.jsxs("button",{className:"tab-button "+("upload"===l?"active":""),onClick:()=>r("upload"),children:[e.jsx(P,{size:16}),"Upload"]})]})}),"url"===l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Image URL *"}),e.jsx("input",{type:"url",value:a,onChange:e=>c(e.target.value),placeholder:"https://example.com/image.jpg",className:!y(a)&&a?"error":""}),e.jsx("small",{children:"Supports JPG, PNG, GIF, WebP, and SVG formats"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Alt Text"}),e.jsx("input",{type:"text",value:x,onChange:e=>p(e.target.value),placeholder:"Describe the image for accessibility"}),e.jsx("small",{children:"Important for screen readers and SEO"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Title (optional)"}),e.jsx("input",{type:"text",value:g,onChange:e=>v(e.target.value),placeholder:"Image 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:d,onChange:e=>u(Number(e.target.value)),min:"50",max:"1200"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Height (px)"}),e.jsx("input",{type:"number",value:h,onChange:e=>m(Number(e.target.value)),min:"50",max:"800"})]})]}),a&&y(a)&&e.jsxs("div",{className:"image-preview",children:[e.jsx("p",{children:"Preview:"}),e.jsx("div",{style:{width:Math.min(d,300),height:Math.min(h,200),border:"2px dashed #ccc",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",borderRadius:"8px",overflow:"hidden"},children:e.jsx("img",{src:a||"/placeholder.svg",alt:x||"Preview",style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none",e.currentTarget.parentElement.innerHTML="❌ Invalid image URL"}})})]})]}),"upload"===l&&s&&e.jsxs("div",{className:"upload-section",children:[e.jsxs("div",{className:"upload-area",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:async e=>{var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(n&&i)if(n.type.startsWith("image/"))if(n.size>5242880)k("Image size must be less than 5MB");else{b(!0),k("");try{const e=await i(n);c(e),p(n.name.replace(/\.[^/.]+$/,"")),r("url")}catch(e){k(e instanceof Error?e.message:"Upload failed")}finally{b(!1)}}else k("Please select a valid image file")},disabled:j,className:"file-input",id:"image-upload"}),e.jsxs("label",{htmlFor:"image-upload",className:"upload-label",children:[e.jsx(P,{size:48}),e.jsx("h4",{children:j?"Uploading...":"Choose Image File"}),e.jsx("p",{children:"Or drag and drop an image here"}),e.jsx("small",{children:"Supports JPG, PNG, GIF, WebP (max 5MB)"})]})]}),w&&e.jsxs("div",{className:"error-message",children:["❌ ",w]}),j&&e.jsxs("div",{className:"upload-progress",children:[e.jsx("div",{className:"progress-bar",children:e.jsx("div",{className:"progress-fill"})}),e.jsx("p",{children:"Uploading image..."})]})]})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{onClick:o,className:"button secondary",children:"Cancel"}),e.jsx("button",{onClick:()=>{if(!a.trim())return;const e={url:a.trim(),width:d,height:h,alt:x.trim(),title:g.trim()};n(e)},className:"button primary",disabled:!a.trim()||!y(a)||j,children:"Insert Image"})]})]})})},exports.ScrivlyEditor=J,exports.TableModal=V,exports.Toolbar=U,exports.VideoModal=G,exports.default=J;
//# sourceMappingURL=index.js.map