scrivly
Version:
A powerful, feature-rich rich text editor for React with TypeScript support
3 lines (2 loc) • 45.3 kB
JavaScript
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{forwardRef as o,createElement as i,useState as l,useRef as r,useEffect as a,useCallback as s,useMemo as c}from"react";function d(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 i=0;for(o=Object.getOwnPropertySymbols(e);i<o.length;i++)t.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}"function"==typeof SuppressedError&&SuppressedError;const u=t=>{var n=d(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"})}))},h=t=>{var n=d(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"})}))},m=t=>{var n=d(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"})}))},p=t=>{var n=d(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"})}))},g=t=>{var n=d(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"})}))},v=n=>{var o=d(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"})]}))},b=t=>{var{size:n=16}=t,o=d(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"})}))},w=t=>{var{size:n=16}=t,o=d(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"})}))},k=t=>{var{size:n=16}=t;return d(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,i=d(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"},i,{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"})]}))},x=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},f=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},C=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},N=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},L=t=>{var{size:n=16}=t;return d(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"})})},z=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},j=t=>{var{size:n=16}=t,o=d(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"})}))},M=t=>{var{size:n=16}=t,o=d(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"})}))},F=t=>{var{size:n=16}=t,o=d(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"})}))},B=n=>{var{size:o=16}=n,i=d(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"},i,{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=n=>{var{size:o=16}=n;return d(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-palette-icon lucide-palette",viewBox:"0 0 24 24",children:[e("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("circle",{cx:"13.5",cy:"6.5",r:"0.5",fill:"currentColor"}),e("circle",{cx:"17.5",cy:"10.5",r:"0.5",fill:"currentColor"}),e("circle",{cx:"6.5",cy:"12.5",r:"0.5",fill:"currentColor"}),e("circle",{cx:"8.5",cy:"7.5",r:"0.5",fill:"currentColor"})]})},O=t=>{var{size:n=16}=t;return d(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"})})},H=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},W=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},E=n=>{var{size:o=16}=n,i=d(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"},i,{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 d(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"})})},I=n=>{var{size:o=16}=n,i=d(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-subscript-icon lucide-subscript",viewBox:"0 0 24 24"},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-2s1.5.5 1.5 2Z"})]}))},R=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},A=n=>{var{size:o=16}=n,i=d(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-superscript-icon lucide-superscript",viewBox:"0 0 24 24"},i,{children:[e("path",{d:"m4 19 8-8"}),e("path",{d:"m12 19 8-8"}),e("path",{d:"M20 7h-4c0-1.5.44-2 1.5-2s1.5.5 1.5 2Z"})]}))},D=n=>{var{size:o=16}=n;return d(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"})]})},q=n=>{var{size:o=16}=n,i=d(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"},i,{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"})]}))},P=n=>{var{size:o=16}=n,i=d(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"},i,{children:[e("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),e("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]}))},$=n=>{var{size:o=16}=n;return d(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"})]})},U=t=>{var{size:n=16}=t;return d(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"})})},V=({type:n,onColorSelect:o,onClose:i})=>e("div",{className:"modal-overlay",onClick:i,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:i,className:"close-button",children:e(U,{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(U,{size:16})})]}),e("div",{className:"emoji-categories",children:Object.entries({Smileys:["😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😌","😍","🥰","😘","😗","😙","😚","😋","😛","😝","😜","🤪","🤨","🧐","🤓","😎","🤩","🥳"],Gestures:["👍","👎","👌","🤌","🤏","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","🖕","👇","☝️","👋","🤚","🖐️","✋","🖖","👏","🙌","🤲","🤝","🙏"],Objects:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","💟","☮️","✝️","☪️","🕉️","☸️","✡️","🔯","🕎","☯️","☦️"],Nature:["🌱","🌿","🍀","🌾","🌵","🌲","🌳","🌴","🌸","🌺","🌻","🌹","🥀","🌷","💐","🌼","🌙","🌛","🌜","🌚","🌕","🌖","🌗","🌘","🌑","🌒","🌓","🌔","⭐","🌟"],Food:["🍎","🍊","🍋","🍌","🍉","🍇","🍓","🫐","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🫑","🌽","🥕","🫒","🧄","🧅","🥔","🍠"]}).map(([o,i])=>t("div",{className:"emoji-category",children:[e("h4",{children:o}),e("div",{className:"emoji-grid",children:i.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 K=(e,t)=>{const n=o(({color:n="currentColor",size:o=24,strokeWidth:l=2,absoluteStrokeWidth:r,children:a,...s},c)=>{return i("svg",{ref:c,...J,width:o,height:o,stroke:n,strokeWidth:r?24*Number(l)/Number(o):l,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 Z=K("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"}]]),Q=K("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"}]]),Y=K("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),X=({onInsertImage:o,onClose:i,allowUpload:r=!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(""),[y,x]=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:i,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:i,className:"close-button",children:e(Y,{size:20})})]}),t("div",{className:"modal-body",children:[r&&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(Z,{size:16}),"URL"]}),t("button",{className:"tab-button "+("upload"===s?"active":""),onClick:()=>c("upload"),children:[e(Q,{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&&r&&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{x(!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{x(!1)}}else C("Please select a valid image file")},disabled:y,className:"file-input",id:"image-upload"}),t("label",{htmlFor:"image-upload",className:"upload-label",children:[e(Q,{size:48}),e("h4",{children:y?"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]}),y&&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:i,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)||y,children:"Insert Image"})]})]})})},_=({onCreateTable:n,onClose:o})=>{const[i,r]=l(3),[a,s]=l(3),[c,d]=l([]),u=Array.from({length:i},(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(U,{size:20})})]}),t("div",{className:"modal-body",children:[t("div",{className:"form-group",children:[t("label",{children:["Rows: ",i]}),e("input",{type:"range",min:"1",max:"10",value:i,onChange:e=>r(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:i,cols:a,data:c})},className:"button primary",children:"Create Table"})]})]})})},ee=({isActive:n,currentBlock:o,onAction:i,toolbarOptions:l,customTools:r=[],className:a="",canUndo:s=!1,canRedo:c=!1,isDarkMode:d=!1,isFullscreen:U=!1,onColorPicker:V,onEmojiPicker:G,activeDropdown:J,onDropdownChange:K,editorRef:Z})=>{const Q={bold:{icon:g,label:"Bold",shortcut:"Ctrl+B"},italic:{icon:C,label:"Italic",shortcut:"Ctrl+I"},underline:{icon:P,label:"Underline",shortcut:"Ctrl+U"},strikethrough:{icon:T,label:"Strikethrough"},subscript:{icon:I,label:"Subscript"},superscript:{icon:A,label:"Superscript"},code:{icon:w,label:"Inline Code"},blockquote:{icon:O,label:"Quote"},bulletList:{icon:L,label:"Bullet List"},numberList:{icon:z,label:"Numbered List"},checklist:{icon:v,label:"Checklist"},codeBlock:{icon:y,label:"Code Block"},table:{icon:D,label:"Insert Table"},link:{icon:N,label:"Insert Link",shortcut:"Ctrl+K"},image:{icon:x,label:"Insert Image"},video:{icon:$,label:"Insert Video"},emoji:{icon:E,label:"Insert Emoji"},alignLeft:{icon:m,label:"Align Left"},alignCenter:{icon:u,label:"Align Center"},alignRight:{icon:p,label:"Align Right"},alignJustify:{icon:h,label:"Justify"},indent:{icon:f,label:"Increase Indent"},outdent:{icon:B,label:"Decrease Indent"},undo:{icon:H,label:"Undo",shortcut:"Ctrl+Z"},redo:{icon:W,label:"Redo",shortcut:"Ctrl+Shift+Z"},clear:{icon:k,label:"Clear Formatting"},darkMode:{icon:d?R:F,label:d?"Light Mode":"Dark Mode"},fullscreen:{icon:U?M:j,label:U?"Exit Fullscreen":"Fullscreen"}},Y=[{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"}],X=["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"],ee=r.reduce((e,t)=>{const n=t.group||"custom";return e[n]||(e[n]=[]),e[n].push(t),e},{}),te=[["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(ee).map(e=>ee[e].map(e=>e.id))],ne=a=>{switch(a){case"formatBlock":return l.includes("formatBlock")?t("div",{className:"dropdown-container",children:[t("button",{type:"button",className:"toolbar-button dropdown-trigger "+("formatBlock"===J?"active":""),onClick:()=>null==K?void 0:K("formatBlock"===J?null:"formatBlock"),title:"Text Format",children:[e(q,{size:16}),e(b,{size:12})]}),"formatBlock"===J&&e("div",{className:"dropdown-menu",children:Y.map(t=>e("button",{type:"button",className:"dropdown-item "+(o===t.value?"active":""),onClick:()=>{i("formatBlock",t.value),null==K||K(null)},children:t.label},t.value))})]},"formatBlock"):null;case"fontSize":return l.includes("fontSize")?t("div",{className:"dropdown-container",children:[t("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontSize"===J?"active":""),onClick:()=>null==K?void 0:K("fontSize"===J?null:"fontSize"),title:"Font Size",children:[e("span",{style:{fontSize:"12px",fontWeight:"bold"},children:"A"}),e(b,{size:12})]}),"fontSize"===J&&e("div",{className:"dropdown-menu",children:X.map(t=>e("button",{type:"button",className:"dropdown-item",onClick:()=>{i("fontSize",t),null==K||K(null)},style:{fontSize:t},children:t},t))})]},"fontSize"):null;case"fontFamily":return l.includes("fontFamily")?t("div",{className:"dropdown-container",children:[t("button",{type:"button",className:"toolbar-button dropdown-trigger "+("fontFamily"===J?"active":""),onClick:()=>null==K?void 0:K("fontFamily"===J?null:"fontFamily"),title:"Font Family",children:[e("span",{style:{fontSize:"12px"},children:"Aa"}),e(b,{size:12})]}),"fontFamily"===J&&e("div",{className:"dropdown-menu",children:_.map(t=>e("button",{type:"button",className:"dropdown-item",onClick:()=>{i("fontFamily",t),null==K||K(null)},style:{fontFamily:t},children:t},t))})]},"fontFamily"):null;case"textColor":return l.includes("textColor")?t("button",{type:"button",className:"toolbar-button color-button",onClick:()=>null==V?void 0:V("text"),title:"Text Color",children:[e(S,{size:16}),e("div",{className:"color-indicator text-color"})]},"textColor"):null;case"backgroundColor":return l.includes("backgroundColor")?e("button",{type:"button",className:"toolbar-button color-button",onClick:()=>null==V?void 0:V("background"),title:"Background Color",children:t("div",{style:{position:"relative"},children:[e(S,{size:16}),e("div",{className:"color-indicator bg-color"})]})},"backgroundColor"):null;default:return(t=>{if(!l.includes(t)&&"customTool"!==t)return null;const o=r.find(e=>e.id===t);if(o){const t=o.icon,l=n[o.id];return e("button",{type:"button",className:"toolbar-button "+(l?"active":""),onClick:()=>i(o.id),title:o.tooltip,children:e(t,{size:16})},o.id)}const a=Q[t];if(!a)return null;const d=a.icon,u=n[t],h="undo"===t&&!s||"redo"===t&&!c;return e("button",{type:"button",className:`toolbar-button ${u?"active":""} ${h?"disabled":""}`,onClick:()=>!h&&i(t),title:a.shortcut?`${a.label} (${a.shortcut})`:a.label,disabled:h,children:e(d,{size:16})},t)})(a)}};return e("div",{className:`scrivly-toolbar ${a}`,children:te.map(t=>{const n=t.map(ne).filter(Boolean);return 0===n.length?null:e("div",{className:"toolbar-group",children:n},t.join("-"))})})},te=({onInsertVideo:n,onClose:o})=>{const[i,r]=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(U,{size:20})})]}),t("div",{className:"modal-body",children:[t("div",{className:"form-group",children:[e("label",{children:"Video URL *"}),e("input",{type:"url",value:i,onChange:e=>r(e.target.value),placeholder:"https://youtube.com/watch?v=... or https://vimeo.com/...",className:!m(i)&&i?"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"})]})]}),i&&m(i)&&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(!i.trim())return;const e={url:i.trim(),width:a,height:c,title:u};n(e)},className:"button primary",disabled:!i.trim()||!m(i),children:"Insert Video"})]})]})})},ne=({value:n="",onChange:o,onStateChange:i,toolbarOptions:d=["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:y=!0,showCharCount:x=!0,autoSave:f=!1,autoSaveInterval:C=5e3,spellCheck:N=!0})=>{const L=r(null),[z,j]=l({}),[M,F]=l("p"),[B,S]=l([n]),[O,H]=l(0),[W,E]=l(0),[T,I]=l(0),[R,A]=l(w),[D,q]=l(!1),[P,$]=l(!1),[U,J]=l(!1),[K,Z]=l(null),[Q,Y]=l(!1);l(null);const[X,ne]=l(null),[oe,ie]=l(null),[le,re]=l({show:!1,x:0,y:0,element:null});a(()=>{if(!f||!o)return;const e=setInterval(()=>{if(L.current){const e=L.current.innerHTML;o(e)}},C);return()=>clearInterval(e)},[f,C,o]),a(()=>{A(w),document.documentElement.setAttribute("data-theme",w?"dark":"light")},[w]),a(()=>{L.current&&n!==L.current.innerHTML&&(L.current.innerHTML=n,ae())},[n]);const ae=s(()=>{if(!L.current)return;const e=L.current.textContent||"",t=e.trim().split(/\s+/).filter(e=>e.length>0);E(t.length),I(e.length)},[]),se=s(()=>{if(!L.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();F(n||"div");let o=e.getRangeAt(0).commonAncestorContainer;for(t.code=!1,t.codeBlock=!1,t.blockquote=!1;o&&o!==L.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}j(t)},[]),ce=s(()=>{if(!L.current)return;const e=L.current.innerHTML;null==o||o(e),ae(),se(),S(t=>{const n=t.slice(0,O+1);return n.push(e),n.slice(-50)}),H(e=>e+1),null==i||i({content:e,activeFormats:new Set(Object.keys(z).filter(e=>z[e])),currentBlock:M,isDarkMode:R,isFullscreen:D})},[o,O,z,M,R,D,i,ae,se]),de=s((e,t)=>{L.current&&(L.current.focus(),document.execCommand(e,!1,t),se(),ce())},[se,ce]),ue=s(e=>{L.current&&(L.current.focus(),document.execCommand("insertHTML",!1,e),ce())},[ce]),he=s(e=>{var t,n;const{rows:o,cols:i}=e;let l='<table class="editor-table" style="border-collapse: collapse; width: 100%; margin: 1rem 0;">';for(let r=0;r<o;r++){l+="<tr>";for(let o=0;o<i;o++){l+=`<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[r])||void 0===n?void 0:n[o])||""}</td>`}l+="</tr>"}l+="</table>",ue(l),$(!1)},[ue]),me=s(e=>{var t;const{url:n,width:o,height:i,title:l}=e;let r=n;if(n.includes("youtube.com")||n.includes("youtu.be")){r=`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")){r=`https://player.vimeo.com/video/${n.split("vimeo.com/")[1]}`}ue(`\n <div class="video-container" style="position: relative; margin: 1rem 0; resize: both; overflow: hidden; width: ${o}px; height: ${i}px; border: 2px dashed #ccc;">\n <iframe \n src="${r}" \n width="100%" \n height="100%" \n frameborder="0" \n allowfullscreen\n title="${l||"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 `),J(!1)},[ue]),pe=c(()=>({bold:()=>de("bold"),italic:()=>de("italic"),underline:()=>de("underline"),strikethrough:()=>de("strikeThrough"),subscript:()=>de("subscript"),superscript:()=>de("superscript"),code:()=>{const e=window.getSelection();if(!e||0===e.rangeCount)return;const t=e.getRangeAt(0);if(t.collapsed)return;const n=document.createElement("code");n.style.backgroundColor="#f1f5f9",n.style.padding="0.2rem 0.4rem",n.style.borderRadius="4px",n.style.fontFamily="monospace";try{t.surroundContents(n),ce()}catch(e){console.warn("Could not apply code formatting")}},formatBlock:e=>de("formatBlock",e),blockquote:()=>de("formatBlock","blockquote"),bulletList:()=>de("insertUnorderedList"),numberList:()=>de("insertOrderedList"),checklist:()=>{ue('\n <ul style="list-style: none; padding-left: 0;">\n <li style="margin: 0.5rem 0;">\n <input type="checkbox" style="margin-right: 0.5rem;"> \n <span contenteditable="true">New task</span>\n </li>\n </ul>\n ')},codeBlock:()=>{ue('\n <pre style="background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 8px; overflow-x: auto; font-family: monospace;"><code contenteditable="true">// Your code here</code></pre>\n ')},alignLeft:()=>de("justifyLeft"),alignCenter:()=>de("justifyCenter"),alignRight:()=>de("justifyRight"),alignJustify:()=>de("justifyFull"),indent:()=>de("indent"),outdent:()=>de("outdent"),fontSize:e=>{de("fontSize","7"),de("fontName",e)},fontFamily:e=>de("fontName",e),textColor:e=>de("foreColor",e),backgroundColor:e=>de("backColor",e),link:()=>{const e=prompt("Enter URL:");e&&de("createLink",e)},image:()=>{const e=prompt("Enter image URL:");if(e){ue(`\n <div class="image-container" style="position: relative; display: inline-block; margin: 1rem 0; resize: both; overflow: hidden; max-width: 100%;">\n <img src="${e}" alt="Image" style="width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 8px;" \n onload="this.parentElement.style.width = Math.min(this.naturalWidth, 600) + 'px'; this.parentElement.style.height = Math.min(this.naturalHeight, 400) + 'px';" />\n <div class="resize-handle" style="position: absolute; bottom: 0; right: 0; width: 20px; height: 20px; background: #666; cursor: se-resize; opacity: 0; transition: opacity 0.2s;"></div>\n </div>\n `)}},table:()=>$(!0),video:()=>J(!0),emoji:()=>Y(!0),clear:()=>de("removeFormat"),undo:()=>{if(O>0){const e=O-1,t=B[e];L.current&&(L.current.innerHTML=t,null==o||o(t),H(e),ae())}},redo:()=>{if(O<B.length-1){const e=O+1,t=B[e];L.current&&(L.current.innerHTML=t,null==o||o(t),H(e),ae())}},darkMode:()=>{const e=!R;A(e),null==k||k(e),document.documentElement.setAttribute("data-theme",e?"dark":"light")},fullscreen:()=>{q(!D)}}),[de,ue,ce,O,B,o,ae,R,k,D]);a(()=>{const e=()=>{document.activeElement===L.current&&se()};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[se]);const ge=s(e=>{e.preventDefault();const t=e.clipboardData.getData("text/plain");document.execCommand("insertText",!1,t),ce()},[ce]),ve=s(e=>{if(e.ctrlKey||e.metaKey)switch(e.key){case"b":e.preventDefault(),pe.bold();break;case"i":e.preventDefault(),pe.italic();break;case"u":e.preventDefault(),pe.underline();break;case"z":e.preventDefault(),e.shiftKey?pe.redo():pe.undo();break;case"k":e.preventDefault(),pe.link()}},[pe]),be=s((e,t)=>{var n,o;if(!t)return;const i=t.closest("table");if(!i)return;const l=t.closest("td, th"),r=t.closest("tr");switch(e){case"addRowAbove":if(r){const e=i.insertRow(r.rowIndex),t=r.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(r){const e=i.insertRow(r.rowIndex+1),t=r.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=i.insertRow(),t=(null===(n=i.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(l){const e=Array.from(r.cells).indexOf(l);Array.from(i.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(l){const e=Array.from(r.cells).indexOf(l);Array.from(i.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(i.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":r&&i.rows.length>1&&r.remove();break;case"deleteColumn":if(l){const e=Array.from(r.cells).indexOf(l);(null===(o=i.rows[0])||void 0===o?void 0:o.cells.length)>1&&Array.from(i.rows).forEach(t=>{t.cells[e]&&t.deleteCell(e)})}}ce();i.querySelectorAll("td, th").forEach(e=>{e.style.transition="background-color 0.3s ease",e.style.backgroundColor="var(--accent-primary)",setTimeout(()=>{e.style.backgroundColor=""},300)})},[ce]),we=s(e=>{const t=e.target,n=t.closest("table");n&&(e.preventDefault(),ie(n),re({show:!0,x:e.clientX,y:e.clientY,element:t}))},[]);return a(()=>{const e=e=>{const t=e.target;t.closest(".dropdown-container")||ne(null),t.closest(".table-context-menu")||t.closest("table")||re({show:!1,x:0,y:0,element:null}),t.closest(".modal-content")||t.closest(".color-picker-modal")||t.closest(".emoji-picker-modal")||(Z(null),Y(!1))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),t("div",{className:`scrivly-editor ${h} ${R?"dark":""} ${D?"fullscreen":""}`,children:[e(ee,{isActive:z,currentBlock:M,onAction:(e,t)=>{"function"==typeof pe[e]&&pe[e](t)},toolbarOptions:d,className:m,canUndo:O>0,canRedo:O<B.length-1,isDarkMode:R,isFullscreen:D,onColorPicker:e=>Z(e),onEmojiPicker:()=>Y(!0),activeDropdown:X,onDropdownChange:ne}),e("div",{className:"scrivly-editor-container",style:{maxHeight:D?"100vh":g,minHeight:v},children:e("div",{ref:L,contentEditable:!b,className:`scrivly-editor-content ${p}`,onInput:ce,onPaste:ge,onKeyDown:ve,onContextMenu:we,"data-placeholder":u,spellCheck:N,suppressContentEditableWarning:!0})}),(y||x||le.show)&&t("div",{className:"scrivly-editor-footer",children:[t("div",{className:"scrivly-editor-stats",children:[y&&t("span",{children:[W," words"]}),x&&t("span",{children:[T," characters"]})]}),oe&&e("div",{className:"table-info",children:e("span",{children:"Table selected - Right-click for options"})})]}),le.show&&e("div",{className:"table-context-menu",style:{position:"fixed",top:le.y,left:le.x,zIndex:1e4},children:t("div",{className:"context-menu-content",children:[e("button",{className:"context-menu-item",onClick:()=>{be("addRowAbove",le.element),re({show:!1,x:0,y:0,element:null})},children:"➕ Add Row Above"}),e("button",{className:"context-menu-item",onClick:()=>{be("addRowBelow",le.element),re({show:!1,x:0,y:0,element:null})},children:"➕ Add Row Below"}),e("button",{className:"context-menu-item",onClick:()=>{be("addColumnLeft",le.element),re({show:!1,x:0,y:0,element:null})},children:"➕ Add Column Left"}),e("button",{className:"context-menu-item",onClick:()=>{be("addColumnRight",le.element),re({show:!1,x:0,y:0,element:null})},children:"➕ Add Column Right"}),e("div",{className:"context-menu-divider"}),e("button",{className:"context-menu-item danger",onClick:()=>{be("deleteRow",le.element),re({show:!1,x:0,y:0,element:null})},children:"🗑️ Delete Row"}),e("button",{className:"context-menu-item danger",onClick:()=>{be("deleteColumn",le.element),re({show:!1,x:0,y:0,element:null})},children:"🗑️ Delete Column"}),e("button",{className:"context-menu-item danger",onClick:()=>{confirm("Are you sure you want to delete this table?")&&(null==oe||oe.remove(),ce()),re({show:!1,x:0,y:0,element:null})},children:"🗑️ Delete Table"})]})}),P&&e(_,{onCreateTable:he,onClose:()=>$(!1)}),U&&e(te,{onInsertVideo:me,onClose:()=>J(!1)}),K&&e(V,{type:K,onColorSelect:e=>{"text"===K?pe.textColor(e):pe.backgroundColor(e),Z(null)},onClose:()=>Z(null)}),Q&&e(G,{onEmojiSelect:e=>{ue(e),Y(!1)},onClose:()=>Y(!1)})]})};export{V as ColorPicker,G as EmojiPicker,X as ImageModal,ne as ScrivlyEditor,_ as TableModal,ee as Toolbar,te as VideoModal,ne as default};
//# sourceMappingURL=index.esm.js.map