scrivly
Version:
A powerful, feature-rich rich text editor for React with TypeScript support
1 lines โข 55.4 kB
JavaScript
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import o,{forwardRef as r,createElement as i,useState as l,useRef as a,useEffect as s,useCallback as c,useMemo as d}from"react";function u(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 h=t=>{var n=u(t,["size"]);return e("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"},n,{children:e("path",{d:"M17 12H7M19 18H5M21 6H3"})}))},m=t=>{var n=u(t,["size"]);return e("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"},n,{children:e("path",{d:"M3 12h18M3 18h18M3 6h18"})}))},p=t=>{var n=u(t,["size"]);return e("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"},n,{children:e("path",{d:"M15 12H3M17 18H3M21 6H3"})}))},g=t=>{var n=u(t,["size"]);return e("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"},n,{children:e("path",{d:"M21 12H9M21 18H7M21 6H3"})}))},v=t=>{var n=u(t,["size"]);return e("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"},n,{children:e("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"})}))},b=n=>{var o=u(n,["size"]);return t("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("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("path",{d:"m9 11 3 3L22 4"})]}))},w=t=>{var{size:n=16}=t,o=u(t,["size"]);return e("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:n,height:n},o,{children:e("path",{d:"m6 9 6 6 6-6"})}))},k=t=>{var{size:n=16}=t,o=u(t,["size"]);return e("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-code-icon lucide-code",viewBox:"0 0 24 24"},o,{children:e("path",{d:"M16 18l6-6-6-6M8 6l-6 6 6 6"})}))},x=t=>{var{size:n=16}=t;return u(t,["size"]),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-eraser-icon lucide-eraser",viewBox:"0 0 24 24",children:e("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"})})},y=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("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("polyline",{points:"14 2 14 8 20 8"}),e("path",{d:"m10 13-2 2 2 2"}),e("path",{d:"m14 17 2-2-2-2"})]}))},f=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),e("path",{d:"m21 15-5-5L5 21"})]}))},C=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("polyline",{points:"3 8 7 12 3 16"}),e("line",{x1:"21",x2:"11",y1:"12",y2:"12"}),e("line",{x1:"21",x2:"11",y1:"6",y2:"6"}),e("line",{x1:"21",x2:"11",y1:"18",y2:"18"})]}))},N=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),e("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),e("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]}))},L=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("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("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}))},z=t=>{var{size:n=16}=t;return u(t,["size"]),e("svg",{xmlns:"http://www.w3.org/2000/svg",height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-list-icon lucide-list",viewBox:"0 0 24 24",children:e("path",{d:"M3 12h.01M3 18h.01M3 6h.01M8 12h13M8 18h13M8 6h13"})})},j=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("line",{x1:"10",x2:"21",y1:"6",y2:"6"}),e("line",{x1:"10",x2:"21",y1:"12",y2:"12"}),e("line",{x1:"10",x2:"21",y1:"18",y2:"18"}),e("path",{d:"M4 6h1v4"}),e("path",{d:"M4 10h2"}),e("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]}))},M=t=>{var{size:n=16}=t,o=u(t,["size"]);return e("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-maximize-icon lucide-maximize",viewBox:"0 0 24 24"},o,{children:e("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"})}))},F=t=>{var{size:n=16}=t,o=u(t,["size"]);return e("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-minimize-icon lucide-minimize",viewBox:"0 0 24 24"},o,{children:e("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"})}))},B=t=>{var{size:n=16}=t,o=u(t,["size"]);return e("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-moon-icon lucide-moon",viewBox:"0 0 24 24"},o,{children:e("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9"})}))},O=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("polyline",{points:"7 8 3 12 7 16"}),e("line",{x1:"21",x2:"11",y1:"12",y2:"12"}),e("line",{x1:"21",x2:"11",y1:"6",y2:"6"}),e("line",{x1:"21",x2:"11",y1:"18",y2:"18"})]}))},S=t=>{var{size:n=16}=t;return u(t,["size"]),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-quote-icon lucide-quote",viewBox:"0 0 24 24",children:e("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"})})},E=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e("path",{d:"M3 3v5h5"})]}))},I=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("path",{d:"M21 12a9 9 0 1 1-9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),e("path",{d:"M21 3v5h-5"})]}))},R=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}),e("line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}),e("line",{x1:"15",x2:"15.01",y1:"9",y2:"9"})]}))},T=t=>{var{size:n=16}=t;return u(t,["size"]),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-strikethrough-icon lucide-strikethrough",viewBox:"0 0 24 24",children:e("path",{d:"M16 4H9a3 3 0 0 0-2.83 4M14 12a4 4 0 0 1 0 8H6M4 12h16"})})},H=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("circle",{cx:"12",cy:"12",r:"5"}),e("line",{x1:"12",x2:"12",y1:"1",y2:"3"}),e("line",{x1:"12",x2:"12",y1:"21",y2:"23"}),e("line",{x1:"4.22",x2:"5.64",y1:"4.22",y2:"5.64"}),e("line",{x1:"18.36",x2:"19.78",y1:"18.36",y2:"19.78"}),e("line",{x1:"1",x2:"3",y1:"12",y2:"12"}),e("line",{x1:"21",x2:"23",y1:"12",y2:"12"}),e("line",{x1:"4.22",x2:"5.64",y1:"19.78",y2:"18.36"}),e("line",{x1:"18.36",x2:"19.78",y1:"5.64",y2:"4.22"})]}))},W=n=>{var{size:o=16}=n;return u(n,["size"]),t("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("path",{d:"M12 3v18"}),e("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),e("path",{d:"M3 9h18M3 15h18"})]})},A=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("polyline",{points:"4 7 4 4 20 4 20 7"}),e("line",{x1:"9",x2:"15",y1:"20",y2:"20"}),e("line",{x1:"12",x2:"12",y1:"4",y2:"20"})]}))},U=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),e("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]}))},D=n=>{var{size:o=16}=n;return u(n,["size"]),t("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("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("rect",{width:"14",height:"12",x:"2",y:"6",rx:"2"})]})},$=t=>{var{size:n=16}=t;return u(t,["size"]),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:n,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",className:"lucide lucide-x-icon lucide-x",viewBox:"0 0 24 24",children:e("path",{d:"M18 6 6 18M6 6l12 12"})})},q=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("path",{d:"m9 11-6 6v3h9l3-3"}),e("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"})]}))},P=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("circle",{cx:"11",cy:"11",r:"8"}),e("path",{d:"m21 21-4.3-4.3"})]}))},V=n=>{var{size:o=16}=n,r=u(n,["size"]);return t("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("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e("polyline",{points:"7 10 12 15 17 10"}),e("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]}))},K=({type:n,onColorSelect:o,onClose:r})=>e("div",{className:"modal-overlay",onClick:r,children:t("div",{className:"color-picker-modal",onClick:e=>e.stopPropagation(),children:[t("div",{className:"modal-header",children:[e("h3",{children:"text"===n?"Text Color":"Background Color"}),e("button",{onClick:r,className:"close-button",children:e($,{size:16})})]}),e("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("button",{className:"color-swatch",style:{backgroundColor:t},onClick:()=>o(t),title:t},t))}),t("div",{className:"custom-color",children:[e("label",{children:"Custom Color:"}),e("input",{type:"color",onChange:e=>o(e.target.value),className:"color-input"})]})]})}),G=({onEmojiSelect:n,onClose:o})=>e("div",{className:"modal-overlay",onClick:o,children:t("div",{className:"emoji-picker-modal",onClick:e=>e.stopPropagation(),children:[t("div",{className:"modal-header",children:[e("h3",{children:"Insert Emoji"}),e("button",{onClick:o,className:"close-button",children:e($,{size:16})})]}),e("div",{className:"emoji-categories",children:Object.entries({Smileys:["๐","๐","๐","๐","๐","๐
","๐","๐คฃ","๐","๐","๐","๐","๐","๐","๐","๐ฅฐ","๐","๐","๐","๐","๐","๐","๐","๐","๐คช","๐คจ","๐ง","๐ค","๐","๐คฉ","๐ฅณ"],Gestures:["๐","๐","๐","๐ค","๐ค","โ๏ธ","๐ค","๐ค","๐ค","๐ค","๐","๐","๐","๐","๐","โ๏ธ","๐","๐ค","๐๏ธ","โ","๐","๐","๐","๐คฒ","๐ค","๐"],Objects:["โค๏ธ","๐งก","๐","๐","๐","๐","๐ค","๐ค","๐ค","๐","โฃ๏ธ","๐","๐","๐","๐","๐","๐","๐","๐","โฎ๏ธ","โ๏ธ","โช๏ธ","๐๏ธ","โธ๏ธ","โก๏ธ","๐ฏ","๐","โฏ๏ธ","โฆ๏ธ"],Nature:["๐ฑ","๐ฟ","๐","๐พ","๐ต","๐ฒ","๐ณ","๐ด","๐ธ","๐บ","๐ป","๐น","๐ฅ","๐ท","๐","๐ผ","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐","๐","โญ","๐"],Food:["๐","๐","๐","๐","๐","๐","๐","๐ซ","๐","๐","๐","๐ฅญ","๐","๐ฅฅ","๐ฅ","๐
","๐","๐ฅ","๐ฅฆ","๐ฅฌ","๐ฅ","๐ถ๏ธ","๐ซ","๐ฝ","๐ฅ","๐ซ","๐ง","๐ง
","๐ฅ","๐ "]}).map(([o,r])=>t("div",{className:"emoji-category",children:[e("h4",{children:o}),e("div",{className:"emoji-grid",children:r.map(t=>e("button",{className:"emoji-button",onClick:()=>n(t),title:t,children:t},t))})]},o))})]})});var J={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 Z=(e,t)=>{const n=r(({color:n="currentColor",size:o=24,strokeWidth:r=2,absoluteStrokeWidth:l,children:a,...s},c)=>{return i("svg",{ref:c,...J,width:o,height:o,stroke:n,strokeWidth:l?24*Number(r)/Number(o):r,className:`lucide lucide-${d=e,d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,...s},[...t.map(([e,t])=>i(e,t)),...(Array.isArray(a)?a:[a])||[]]);var d});return n.displayName=`${e}`,n};const Q=Z("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"}]]),Y=Z("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"}]]),X=Z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),_=({onInsertImage:o,onClose:r,allowUpload:i=!1,onImageUpload:a})=>{const[s,c]=l("url"),[d,u]=l(""),[h,m]=l(400),[p,g]=l(300),[v,b]=l(""),[w,k]=l(""),[x,y]=l(!1),[f,C]=l(""),N=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("div",{className:"modal-overlay",onClick:r,children:t("div",{className:"modal-content",onClick:e=>e.stopPropagation(),children:[t("div",{className:"modal-header",children:[e("h3",{children:"Insert Image"}),e("button",{onClick:r,className:"close-button",children:e(X,{size:20})})]}),t("div",{className:"modal-body",children:[i&&e("div",{className:"tab-container",children:t("div",{className:"tab-buttons",children:[t("button",{className:"tab-button "+("url"===s?"active":""),onClick:()=>c("url"),children:[e(Q,{size:16}),"URL"]}),t("button",{className:"tab-button "+("upload"===s?"active":""),onClick:()=>c("upload"),children:[e(Y,{size:16}),"Upload"]})]})}),"url"===s&&t(n,{children:[t("div",{className:"form-group",children:[e("label",{children:"Image URL *"}),e("input",{type:"url",value:d,onChange:e=>u(e.target.value),placeholder:"https://example.com/image.jpg",className:!N(d)&&d?"error":""}),e("small",{children:"Supports JPG, PNG, GIF, WebP, and SVG formats"})]}),t("div",{className:"form-group",children:[e("label",{children:"Alt Text"}),e("input",{type:"text",value:v,onChange:e=>b(e.target.value),placeholder:"Describe the image for accessibility"}),e("small",{children:"Important for screen readers and SEO"})]}),t("div",{className:"form-group",children:[e("label",{children:"Title (optional)"}),e("input",{type:"text",value:w,onChange:e=>k(e.target.value),placeholder:"Image title"})]}),t("div",{className:"form-row",children:[t("div",{className:"form-group",children:[e("label",{children:"Width (px)"}),e("input",{type:"number",value:h,onChange:e=>m(Number(e.target.value)),min:"50",max:"1200"})]}),t("div",{className:"form-group",children:[e("label",{children:"Height (px)"}),e("input",{type:"number",value:p,onChange:e=>g(Number(e.target.value)),min:"50",max:"800"})]})]}),d&&N(d)&&t("div",{className:"image-preview",children:[e("p",{children:"Preview:"}),e("div",{style:{width:Math.min(h,300),height:Math.min(p,200),border:"2px dashed #ccc",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5",borderRadius:"8px",overflow:"hidden"},children:e("img",{src:d||"/placeholder.svg",alt:v||"Preview",style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain"},onError:e=>{e.currentTarget.style.display="none",e.currentTarget.parentElement.innerHTML="โ Invalid image URL"}})})]})]}),"upload"===s&&i&&t("div",{className:"upload-section",children:[t("div",{className:"upload-area",children:[e("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&&a)if(n.type.startsWith("image/"))if(n.size>5242880)C("Image size must be less than 5MB");else{y(!0),C("");try{const e=await a(n);u(e),b(n.name.replace(/\.[^/.]+$/,"")),c("url")}catch(e){C(e instanceof Error?e.message:"Upload failed")}finally{y(!1)}}else C("Please select a valid image file")},disabled:x,className:"file-input",id:"image-upload"}),t("label",{htmlFor:"image-upload",className:"upload-label",children:[e(Y,{size:48}),e("h4",{children:x?"Uploading...":"Choose Image File"}),e("p",{children:"Or drag and drop an image here"}),e("small",{children:"Supports JPG, PNG, GIF, WebP (max 5MB)"})]})]}),f&&t("div",{className:"error-message",children:["โ ",f]}),x&&t("div",{className:"upload-progress",children:[e("div",{className:"progress-bar",children:e("div",{className:"progress-fill"})}),e("p",{children:"Uploading image..."})]})]})]}),t("div",{className:"modal-footer",children:[e("button",{onClick:r,className:"button secondary",children:"Cancel"}),e("button",{onClick:()=>{if(!d.trim())return;const e={url:d.trim(),width:h,height:p,alt:v.trim(),title:w.trim()};o(e)},className:"button primary",disabled:!d.trim()||!N(d)||x,children:"Insert Image"})]})]})})},ee=({isOpen:n,onClose:o,onSearch:r})=>{const[i,a]=l(""),[s,c]=l(""),[d,u]=l(!1);return n?e("div",{className:"modal-overlay",onClick:o,children:t("div",{className:"search-modal",onClick:e=>e.stopPropagation(),children:[t("div",{className:"search-modal-header",children:[e("h3",{children:d?"Find and Replace":"Find"}),e("button",{className:"close-button",onClick:o,"aria-label":"Close",children:e($,{size:20})})]}),t("form",{className:"search-modal-body",onSubmit:e=>{e.preventDefault(),r(i,d?s:void 0)},children:[t("div",{className:"search-form",children:[t("div",{className:"search-group",children:[e("label",{htmlFor:"search-term",children:"Find"}),e("input",{id:"search-term",type:"text",value:i,onChange:e=>a(e.target.value),placeholder:"Enter text to find...",autoFocus:!0})]}),d&&t("div",{className:"search-group",children:[e("label",{htmlFor:"replace-term",children:"Replace with"}),e("input",{id:"replace-term",type:"text",value:s,onChange:e=>c(e.target.value),placeholder:"Enter replacement text..."})]})]}),t("div",{className:"search-modal-footer",children:[e("button",{type:"button",className:"button secondary",onClick:()=>u(!d),children:d?"Find Only":"Replace Mode"}),e("button",{type:"button",className:"button secondary",onClick:()=>{a(""),c("")},children:"Clear"}),e("button",{type:"submit",className:"button primary",children:d?"Replace All":"Find"})]})]})]})}):null},te=({onCreateTable:n,onClose:o})=>{const[r,i]=l(3),[a,s]=l(3),[c,d]=l([]),u=Array.from({length:r},(e,t)=>Array.from({length:a},(e,n)=>`${t}-${n}`));return e("div",{className:"modal-overlay",onClick:o,children:t("div",{className:"modal-content",onClick:e=>e.stopPropagation(),children:[t("div",{className:"modal-header",children:[e("h3",{children:"Insert Table"}),e("button",{onClick:o,className:"close-button",children:e($,{size:20})})]}),t("div",{className:"modal-body",children:[t("div",{className:"form-group",children:[t("label",{children:["Rows: ",r]}),e("input",{type:"range",min:"1",max:"10",value:r,onChange:e=>i(Number(e.target.value))})]}),t("div",{className:"form-group",children:[t("label",{children:["Columns: ",a]}),e("input",{type:"range",min:"1",max:"10",value:a,onChange:e=>s(Number(e.target.value))})]}),e("div",{className:"table-preview",children:e("div",{className:"preview-grid",style:{display:"grid",gridTemplateColumns:`repeat(${a}, 1fr)`,gap:"2px",border:"1px solid #ccc",padding:"4px"},children:u.map(t=>t.map(t=>e("div",{className:"preview-cell",style:{border:"1px solid #ddd",padding:"8px",minHeight:"30px",backgroundColor:"#f9f9f9"}},t)))})})]}),t("div",{className:"modal-footer",children:[e("button",{onClick:o,className:"button secondary",children:"Cancel"}),e("button",{onClick:()=>{n({rows:r,cols:a,data:c})},className:"button primary",children:"Create Table"})]})]})})},ne=n=>{var{size:o=16,color:r="currentColor"}=n,i=u(n,["size","color"]);return t("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("path",{d:"M4 20h16"}),e("path",{d:"m6 16 6-12 6 12"}),e("path",{d:"M8 12h8"})]}))},oe=n=>{var{size:o=16,color:r="currentColor"}=n,i=u(n,["size","color"]);return t("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("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("path",{d:"m5 2 5 5"}),e("path",{d:"M2 13h15"}),e("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"})]}))},re=n=>{var{size:o=16,color:r="currentColor"}=n,i=u(n,["size","color"]);return t("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("path",{d:"m4 5 8 8"}),e("path",{d:"m12 5-8 8"}),e("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"})]}))},ie=n=>{var{size:o=16,color:r="currentColor"}=n,i=u(n,["size","color"]);return t("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("path",{d:"m4 19 8-8"}),e("path",{d:"m12 19-8-8"}),e("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"})]}))},le=n=>{const{isActive:r,currentBlock:i,onAction:l,toolbarOptions:s,customTools:c=[],className:d="",canUndo:u=!1,canRedo:$=!1,isDarkMode:K=!1,isFullscreen:G=!1,onColorPicker:J,onEmojiPicker:Z,activeDropdown:Q,onDropdownChange:Y,editorRef:X}=n,_=a(null),ee=a(null),te=a(null),le=async e=>{var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];n&&l("imageUpload",n),e.target&&(e.target.value="")},ae={bold:{icon:v,label:"Bold",shortcut:"Ctrl+B"},italic:{icon:N,label:"Italic",shortcut:"Ctrl+I"},underline:{icon:U,label:"Underline",shortcut:"Ctrl+U"},strikethrough:{icon:T,label:"Strikethrough"},subscript:{icon:re,label:"Subscript"},superscript:{icon:ie,label:"Superscript"},code:{icon:k,label:"Inline Code"},highlight:{icon:q,label:"Highlight Text"},blockquote:{icon:S,label:"Quote"},bulletList:{icon:z,label:"Bullet List"},numberList:{icon:j,label:"Numbered List"},checklist:{icon:b,label:"Checklist"},codeBlock:{icon:y,label:"Code Block"},table:{icon:W,label:"Insert Table"},link:{icon:L,label:"Insert Link",shortcut:"Ctrl+K"},image:{icon:f,label:"Insert Image"},video:{icon:D,label:"Insert Video"},emoji:{icon:R,label:"Insert Emoji"},search:{icon:P,label:"Find & Replace"},export:{icon:V,label:"Export Content"},alignLeft:{icon:p,label:"Align Left"},alignCenter:{icon:h,label:"Align Center"},alignRight:{icon:g,label:"Align Right"},alignJustify:{icon:m,label:"Justify"},indent:{icon:C,label:"Increase Indent"},outdent:{icon:O,label:"Decrease Indent"},undo:{icon:E,label:"Undo",shortcut:"Ctrl+Z"},redo:{icon:I,label:"Redo",shortcut:"Ctrl+Shift+Z"},clear:{icon:x,label:"Clear Formatting"},darkMode:{icon:K?H:B,label:K?"Light Mode":"Dark Mode"},fullscreen:{icon:G?F:M,label:G?"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"}],ce=["8px","10px","12px","14px","16px","18px","20px","24px","28px","32px","36px","48px","64px"],de=["Arial","Helvetica","Times New Roman","Courier New","Verdana","Georgia","Palatino","Garamond","Comic Sans MS","Trebuchet MS","Arial Black","Impact"],ue=c.reduce((e,t)=>{const n=t.group||"custom";return e[n]||(e[n]=[]),e[n].push(t),e},{}),he=[["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(ue).map(e=>ue[e].map(e=>e.id))],me=()=>t("div",{className:"dropdown-container",style:{position:"relative"},children:[e("button",{className:"toolbar-button "+("image"===Q?"active":""),onClick:()=>l("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(f,{size:16})}),"image"===Q&&t("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("button",{className:"dropdown-item",onClick:()=>{_.current&&_.current.click(),null==Y||Y(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("span",{children:"Upload Image"})}),e("button",{className:"dropdown-item",onClick:()=>{l("imageUrl"),null==Y||Y(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("span",{children:"Insert from URL"})})]}),e("input",{type:"file",ref:_,accept:"image/*",onChange:le,style:{display:"none"}})]}),pe=(t,n,i,a)=>"textColor"===t||"backgroundColor"===t?(t=>{const n="textColor"===t?"Text Color":"Background Color";return e("div",{className:"dropdown-container",style:{position:"relative"},children:e("button",{ref:"textColor"===t?ee:te,className:"toolbar-button "+(r[t]?"active":""),onClick:()=>{null==J||J("textColor"===t?"text":"background")},"aria-label":n,title:n,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("textColor"===t?ne:oe,{size:16})})},t)})(t):"image"===t?me():e("button",{className:"toolbar-button "+(r[t]?"active":""),onClick:()=>l(t),"aria-label":i,title:`${i}${a?` (${a})`:""}`,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:n&&o.createElement(n,{size:16})},t),ge=n=>{switch(n){case"formatBlock":return-1===s.indexOf("formatBlock")?null:t("div",{className:"dropdown-container",children:[t("button",{type:"button",className:"toolbar-button dropdown-trigger "+("formatBlock"===Q?"active":""),onClick:()=>null==Y?void 0:Y("formatBlock"===Q?null:"formatBlock"),title:"Text Format","aria-label":"Text Format","aria-expanded":"formatBlock"===Q,"aria-haspopup":"true",children:[e(A,{size:16}),e(w,{size:12})]}),"formatBlock"===Q&&e("div",{className:"dropdown-menu",children:se.map(t=>e("button",{type:"button",className:"dropdown-item "+(i===t.value?"active":""),onClick:()=>{l("formatBlock",t.value),null==Y||Y(null)},role:"menuitem",tabIndex:-1,children:t.label},t.value))})]},"formatBlock");case"fontSize":return-1===s.indexOf("fontSize")?null:t("div",{className:"dropdown-container",children:[t("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontSize"===Q?"active":""),onClick:()=>null==Y?void 0:Y("fontSize"===Q?null:"fontSize"),title:"Font Size","aria-label":"Font Size","aria-expanded":"fontSize"===Q,"aria-haspopup":"true",children:[e("span",{style:{fontSize:"12px",fontWeight:"bold"},children:"A"}),e(w,{size:12})]}),"fontSize"===Q&&e("div",{className:"dropdown-menu",children:ce.map(t=>e("button",{type:"button",className:"dropdown-item",onClick:()=>{l("fontSize",t),null==Y||Y(null)},style:{fontSize:t},role:"menuitem",tabIndex:-1,children:t},t))})]},"fontSize");case"fontFamily":return-1===s.indexOf("fontFamily")?null:t("div",{className:"dropdown-container",children:[t("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontFamily"===Q?"active":""),onClick:()=>null==Y?void 0:Y("fontFamily"===Q?null:"fontFamily"),title:"Font Family","aria-label":"Font Family","aria-expanded":"fontFamily"===Q,"aria-haspopup":"true",children:[e("span",{style:{fontSize:"12px"},children:"Aa"}),e(w,{size:12})]}),"fontFamily"===Q&&e("div",{className:"dropdown-menu",children:de.map(t=>e("button",{type:"button",className:"dropdown-item",onClick:()=>{l("fontFamily",t),null==Y||Y(null)},style:{fontFamily:t},role:"menuitem",tabIndex:-1,children:t},t))})]},"fontFamily");case"textColor":return-1===s.indexOf("textColor")?null:e("button",{type:"button",className:"toolbar-button",onClick:()=>null==J?void 0:J("text"),title:"Text Color","aria-label":"Text Color",children:e(ne,{size:16})},"textColor");case"backgroundColor":return-1===s.indexOf("backgroundColor")?null:e("button",{type:"button",className:"toolbar-button",onClick:()=>null==J?void 0:J("background"),title:"Background Color","aria-label":"Background Color",children:e(oe,{size:16})},"backgroundColor");default:if(n in ae){const e=ae[n],t=e.icon;return pe(n,t,e.label,"shortcut"in e?e.shortcut:void 0)}return null}};return e("div",{className:`scrivly-toolbar ${d}`,children:he.map((t,n)=>((t,n)=>{const o=t.map(ge).filter(Boolean);return 0===o.length?null:e("div",{className:"toolbar-group",children:o},`group-${n}`)})(t,n))})},ae=({onInsertVideo:n,onClose:o})=>{const[r,i]=l(""),[a,s]=l(560),[c,d]=l(315),[u,h]=l(""),m=e=>e.includes("youtube.com")||e.includes("youtu.be")||e.includes("vimeo.com")||e.startsWith("http");return e("div",{className:"modal-overlay",onClick:o,children:t("div",{className:"modal-content",onClick:e=>e.stopPropagation(),children:[t("div",{className:"modal-header",children:[e("h3",{children:"Insert Video"}),e("button",{onClick:o,className:"close-button",children:e($,{size:20})})]}),t("div",{className:"modal-body",children:[t("div",{className:"form-group",children:[e("label",{children:"Video URL *"}),e("input",{type:"url",value:r,onChange:e=>i(e.target.value),placeholder:"https://youtube.com/watch?v=... or https://vimeo.com/...",className:!m(r)&&r?"error":""}),e("small",{children:"Supports YouTube, Vimeo, and direct video URLs"})]}),t("div",{className:"form-group",children:[e("label",{children:"Title (optional)"}),e("input",{type:"text",value:u,onChange:e=>h(e.target.value),placeholder:"Video title"})]}),t("div",{className:"form-row",children:[t("div",{className:"form-group",children:[e("label",{children:"Width (px)"}),e("input",{type:"number",value:a,onChange:e=>s(Number(e.target.value)),min:"200",max:"1200"})]}),t("div",{className:"form-group",children:[e("label",{children:"Height (px)"}),e("input",{type:"number",value:c,onChange:e=>d(Number(e.target.value)),min:"150",max:"800"})]})]}),r&&m(r)&&t("div",{className:"video-preview",children:[t("p",{children:["Preview size: ",a," ร ",c,"px"]}),e("div",{style:{width:Math.min(a,400),height:Math.min(c,225),border:"2px dashed #ccc",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f5f5f5"},children:"Video Preview"})]})]}),t("div",{className:"modal-footer",children:[e("button",{onClick:o,className:"button secondary",children:"Cancel"}),e("button",{onClick:()=>{if(!r.trim())return;const e={url:r.trim(),width:a,height:c,title:u};n(e)},className:"button primary",disabled:!r.trim()||!m(r),children:"Insert Video"})]})]})})},se=({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:u="Start writing something amazing...",className:h="",toolbarClassName:m="",contentClassName:p="",maxHeight:g="600px",minHeight:v="300px",readOnly:b=!1,darkMode:w=!1,onDarkModeChange:k,showWordCount:x=!0,showCharCount:y=!0,autoSave:f=!1,autoSaveInterval:C=5e3,spellCheck:N=!0,allowImageUpload:L=!1,onImageUpload:z})=>{const j=a(null),[M,F]=l({}),[B,O]=l("p"),[S,E]=l([n]),[I,R]=l(0),[T,H]=l(0),[W,A]=l(0),[U,D]=l(w),[$,q]=l(!1),[P,V]=l(!1),[J,Z]=l(!1),[Q,Y]=l(!1),[X,_]=l(null),[ne,oe]=l(!1);l(null);const[re,ie]=l(null),[se,ce]=l(null),[de,ue]=l({show:!1,x:0,y:0,element:null});s(()=>{if(!f||!o)return;const e=setInterval(()=>{if(j.current){const e=j.current.innerHTML;o(e)}},C);return()=>clearInterval(e)},[f,C,o]),s(()=>{D(w),document.documentElement.setAttribute("data-theme",w?"dark":"light")},[w]),s(()=>{j.current&&n!==j.current.innerHTML&&(j.current.innerHTML=n,he())},[n]);const he=c(()=>{if(!j.current)return;const e=j.current.textContent||"",t=e.trim().split(/\s+/).filter(e=>e.length>0);H(t.length),A(e.length)},[]),me=c(()=>{if(!j.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();O(n||"div");let o=e.getRangeAt(0).commonAncestorContainer;for(t.code=!1,t.codeBlock=!1,t.blockquote=!1;o&&o!==j.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}F(t)},[]),pe=c(()=>{if(!j.current)return;const e=j.current.innerHTML;null==o||o(e),he(),me(),E(t=>{const n=t.slice(0,I+1);return n.push(e),n.slice(-50)}),R(e=>e+1),null==r||r({content:e,activeFormats:new Set(Object.keys(M).filter(e=>M[e])),currentBlock:B,isDarkMode:U,isFullscreen:$})},[o,I,M,B,U,$,r,he,me]),ge=c((e,t)=>{j.current&&(j.current.focus(),document.execCommand(e,!1,t),me(),pe())},[me,pe]),ve=c(e=>{j.current&&(j.current.focus(),document.execCommand("insertHTML",!1,e),pe())},[pe]),be=c(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 l=0;l<o;l++){i+="<tr>";for(let o=0;o<r;o++){const r=(null===(n=null===(t=e.data)||void 0===t?void 0:t[l])||void 0===n?void 0:n[o])||"";i+=0===l?`<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>",ve(i),V(!1)},[ve]),we=c(e=>{var t;const{url:n,width:o,height:r,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]}`}ve(`\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="${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 `),Z(!1)},[ve]),ke=d(()=>({bold:()=>ge("bold"),italic:()=>ge("italic"),underline:()=>ge("underline"),strikethrough:()=>ge("strikeThrough"),subscript:()=>ge("subscript"),superscript:()=>ge("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),pe()}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),pe()}catch(e){console.warn("Could not apply highlight formatting")}},formatBlock:e=>ge("formatBlock",e),blockquote:()=>ge("formatBlock","blockquote"),bulletList:()=>ge("insertUnorderedList"),numberList:()=>ge("insertOrderedList"),checklist:()=>{ve('\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:()=>{ve('\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:()=>ge("justifyLeft"),alignCenter:()=>ge("justifyCenter"),alignRight:()=>ge("justifyRight"),alignJustify:()=>ge("justifyFull"),indent:()=>ge("indent"),outdent:()=>ge("outdent"),fontSize:e=>{ge("fontSize","7"),ge("fontName",e)},fontFamily:e=>ge("fontName",e),textColor:e=>{_("text"===X?null:"text")},backgroundColor:e=>{_("background"===X?null:"background")},link:()=>{const e=prompt("Enter URL:");e&&ge("createLink",e)},image:()=>{ie("image"===re?null:"image")},imageUrl:()=>{const e=prompt("Enter image URL:");if(e){ve(`\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 `)}ie(null)},imageUpload:async e=>{if(L&&z)try{const t=await z(e);ve(`\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);ve(`\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 `)}ie(null)},table:()=>V(!0),video:()=>Z(!0),emoji:()=>oe(!0),clear:()=>ge("removeFormat"),undo:()=>{if(I>0){const e=I-1,t=S[e];j.current&&(j.current.innerHTML=t,null==o||o(t),R(e),he())}},redo:()=>{if(I<S.length-1){const e=I+1,t=S[e];j.current&&(j.current.innerHTML=t,null==o||o(t),R(e),he())}},darkMode:()=>{const e=!U;D(e),null==k||k(e),document.documentElement.setAttribute("data-theme",e?"dark":"light")},fullscreen:()=>{q(!$)},search:()=>{Y(!0)},export:()=>{if(j.current){const e=j.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)}}}),[ge,ve,pe,I,S,o,he,U,k,$,X,re,L,z,ve]);s(()=>{const e=()=>{document.activeElement===j.current&&me()};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[me]);const xe=c(e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t),pe()},[pe]),ye=c(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(),j.current&&j.current.focus()}if(e.ctrlKey||e.metaKey)switch(e.key){case"b":e.preventDefault(),ke.bold();break;case"i":e.preventDefault(),ke.italic();break;case"u":e.preventDefault(),ke.underline();break;case"z":e.preventDefault(),e.shiftKey?ke.redo():ke.undo();break;case"k":e.preventDefault(),ke.link();break;case"h":e.preventDefault(),ke.highlight();break;case"f":e.preventDefault(),ke.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=Le(o);if(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!1),n.removeAllRanges(),n.addRange(t)}}else{const e=Ne(o);if(e){const t=document.createRange();t.selectNodeContents(e),t.collapse(!1),n.removeAllRanges(),n.addRange(t)}}}document.activeElement===j.current&&(e.preventDefault(),e.shiftKey?ke.outdent():ke.indent())}},[ke,j]),fe=c((e,t)=>{var n,o;if(!t)return;const r=t.closest("table");if(!r)return;const i=t.closest("td, th"),l=t.closest("tr");