@yoopta/themes-shadcn 6.0.0 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  import { type PluginElementRenderProps } from '@yoopta/editor';
2
- export declare const EmbedElement: ({ element, attributes, children, blockId }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const EmbedElement: ({ element, attributes, children, blockId }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element | null;
3
3
  //# sourceMappingURL=embed-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embed-element.d.ts","sourceRoot":"","sources":["../../../../src/embed/elements/embed/embed-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAUvF,eAAO,MAAM,YAAY,+CAAgD,wBAAwB,4CA2FhG,CAAC"}
1
+ {"version":3,"file":"embed-element.d.ts","sourceRoot":"","sources":["../../../../src/embed/elements/embed/embed-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAUvF,eAAO,MAAM,YAAY,+CAAgD,wBAAwB,mDA8FhG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"embed-render.d.ts","sourceRoot":"","sources":["../../../../src/embed/elements/embed/embed-render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,iBAAiB,CAAC;IAChC,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,mGASrB,KAAK,4CA0NP,CAAC"}
1
+ {"version":3,"file":"embed-render.d.ts","sourceRoot":"","sources":["../../../../src/embed/elements/embed/embed-render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,iBAAiB,CAAC;IAChC,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,mGASrB,KAAK,4CA4KP,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export declare const EmbedUI: {
2
2
  embed: {
3
- render: ({ element, attributes, children, blockId }: import("@yoopta/editor/dist/plugins/types").PluginElementExtendRenderProps) => import("react/jsx-runtime").JSX.Element;
3
+ render: ({ element, attributes, children, blockId }: import("@yoopta/editor/dist/plugins/types").PluginElementExtendRenderProps) => import("react/jsx-runtime").JSX.Element | null;
4
4
  };
5
5
  };
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/embed.js CHANGED
@@ -1,10 +1,10 @@
1
- import{a as e}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as i,Fragment as n}from"react/jsx-runtime";import{useState as s,useLayoutEffect as r,useRef as a,useEffect as l,useCallback as o}from"react";import{useElementSelected as c,useBlockSelected as d,useYooptaEditor as m,useYooptaPluginOptions as h,Elements as p,Blocks as u}from"@yoopta/editor";import{detectProvider as g,getSupportedProviders as b,isEmbedUrl as f,parseEmbedUrl as v,calculateEmbedDimensions as y}from"@yoopta/embed";import{Editor as w,Element as x}from"slate";import{B as j}from"./chunks/button-7aec29d6.js";import{I as k}from"./chunks/input-b2431223.js";import{c as N}from"./chunks/utils-3345eade.js";import{L as O,A as C,a as E,b as z,R}from"./chunks/index-87b75648.js";import{c as I}from"./chunks/createLucideIcon-8605f860.js";import{C as U}from"./chunks/code-d31bdce0.js";import{P as D}from"./chunks/play-998f23d2.js";import{u as S,F as P,T as L,a as M,b as H,c as W,R as A}from"./chunks/tooltip-65b9c3a0.js";import{C as T,c as F}from"./chunks/index-0bca29df.js";import{S as B}from"./chunks/separator-219dc1f7.js";import{E as Y}from"./chunks/external-link-1579dd7f.js";import{T as $}from"./chunks/trash-2-f36597ff.js";import{o as q,f as V,s as K,b as _}from"./chunks/index-23c7fb16.js";import"react-dom";import"./chunks/index-17323747.js";import"./chunks/index-91a5b8d5.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-23db6fea.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-1674c2c8.js";import"./chunks/index-a5cba5f7.js";import"./chunks/index-70f4e709.js";
1
+ import{a as e}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as n,Fragment as i}from"react/jsx-runtime";import{useState as s,useLayoutEffect as r,useRef as a,useEffect as l,useCallback as o}from"react";import{useElementSelected as c,useBlockSelected as d,useYooptaEditor as m,useYooptaPluginOptions as h,Elements as p,Blocks as u}from"@yoopta/editor";import{detectProvider as g,getSupportedProviders as b,isEmbedUrl as v,parseEmbedUrl as f,calculateEmbedDimensions as y}from"@yoopta/embed";import{Editor as x,Element as j}from"slate";import{B as w}from"./chunks/button-7aec29d6.js";import{I as k}from"./chunks/input-b2431223.js";import{c as N}from"./chunks/utils-3345eade.js";import{L as O,A as C,a as R,b as E,R as z}from"./chunks/index-87b75648.js";import{c as I}from"./chunks/createLucideIcon-8605f860.js";import{C as U}from"./chunks/code-d31bdce0.js";import{P as D}from"./chunks/play-998f23d2.js";import{u as P,F as L,T as S,a as A,b as H,c as W,R as _}from"./chunks/tooltip-65b9c3a0.js";import{C as F,c as T}from"./chunks/index-0bca29df.js";import{S as B}from"./chunks/separator-219dc1f7.js";import{E as M}from"./chunks/external-link-1579dd7f.js";import{T as Y}from"./chunks/trash-2-f36597ff.js";import{o as $,f as q,s as V,b as G}from"./chunks/index-23c7fb16.js";import"react-dom";import"./chunks/index-17323747.js";import"./chunks/index-91a5b8d5.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-23db6fea.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-1674c2c8.js";import"./chunks/index-a5cba5f7.js";import"./chunks/index-70f4e709.js";
2
2
  /**
3
3
  * @license lucide-react v0.294.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
- */const J=I("Map",[["polygon",{points:"3 6 9 3 15 6 21 3 21 18 15 21 9 18 3 21",key:"ok2ie8"}],["line",{x1:"9",x2:"9",y1:"3",y2:"18",key:"w34qz5"}],["line",{x1:"15",x2:"15",y1:"6",y2:"21",key:"volv9a"}]]),G=I("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),Q=e=>{switch(e){case"youtube":case"vimeo":case"dailymotion":case"wistia":case"loom":return i(D,{className:"h-3 w-3"});case"spotify":case"soundcloud":return i(G,{className:"h-3 w-3"});case"codepen":case"codesandbox":return i(U,{className:"h-3 w-3"});case"google-maps":return i(J,{className:"h-3 w-3"});default:return i(O,{className:"h-3 w-3"})}},X=({name:e,type:i})=>t("span",Object.assign({className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:[Q(i),e]})),Z=({onInsertUrl:e})=>{const[n,r]=s(""),[a,l]=s(!1),[o,c]=s(null),d=()=>{n.trim()&&(e(n.trim()),r(""),l(!1),c(null))};return t("div",Object.assign({className:"space-y-3"},{children:[t("div",Object.assign({className:"space-y-2"},{children:[i(k,{placeholder:"Paste a URL to embed (YouTube, Vimeo, Twitter, Spotify, etc.)",value:n,onChange:e=>(e=>{var t;if(r(e),e.trim()){const i=f(e.trim());if(l(i),i){const i=g(e.trim()),n=b().find(e=>e.type===i);c(null!==(t=null==n?void 0:n.name)&&void 0!==t?t:null)}else c(null)}else l(!1),c(null)})(e.target.value),onKeyDown:e=>{"Enter"===e.key&&n.trim()&&a&&(e.preventDefault(),d())},className:"h-10"}),n.trim()&&i("div",Object.assign({className:"text-xs text-muted-foreground"},{children:a?t("span",Object.assign({className:"flex items-center gap-1.5 text-green-600 dark:text-green-400"},{children:[Q(g(n.trim())),o," detected"]})):i("span",Object.assign({className:"text-destructive"},{children:"Unsupported URL. Try YouTube, Vimeo, Twitter, Spotify, Figma, CodePen, etc."}))}))]})),i(j,Object.assign({className:"w-full",onClick:d,disabled:!n.trim()||!a},{children:a?`Embed ${o}`:"Embed content"}))]}))},ee=()=>{const e=b().filter(e=>"unknown"!==e.type);return t("div",Object.assign({className:"mt-4 space-y-2"},{children:[i("p",Object.assign({className:"text-xs text-muted-foreground text-center"},{children:"Supported providers:"})),t("div",Object.assign({className:"flex flex-wrap gap-1.5 justify-center"},{children:[e.slice(0,8).map(e=>i(X,{name:e.name,type:e.type},e.type)),e.length>8&&t("span",Object.assign({className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:["+",e.length-8," more"]}))]}))]}))},te=({onInsertUrl:e,className:n,attributes:s,children:r})=>t("div",Object.assign({className:N("mt-2 relative rounded-lg border bg-background overflow-hidden",n)},s,{contentEditable:!1},{children:[t("div",Object.assign({className:"p-6"},{children:[t("div",Object.assign({className:"flex flex-col items-center gap-4"},{children:[i("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:i(O,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[i("p",Object.assign({className:"text-sm font-medium"},{children:"Embed content"})),i("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Paste a URL from supported platforms"}))]}))]})),i("div",Object.assign({className:"mt-6 max-w-md mx-auto"},{children:i(Z,{onInsertUrl:e})})),i(ee,{})]})),r]})),ie=({referenceRef:e,elementProps:a,onUpdate:l,onReplace:o,onDelete:c,onCopy:d})=>{var m;const[h,p]=s(!1),[u,g]=s(!1),b=a.provider&&a.provider.type,f="alignment"in a,{refs:v,floatingStyles:y}=S({placement:"top-end",strategy:"absolute",middleware:[q(8),V({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),K({padding:10})],whileElementsMounted:_});r(()=>{const t=e.current;t&&(v.setReference(t),g(!0))},[e,v]),r(()=>{if(u){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[u]);return u?i(P,{children:i("div",Object.assign({ref:v.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:N("pointer-events-auto","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",h?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:y},{children:t(L,Object.assign({delayDuration:0},{children:[f&&t("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"left"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"left"})},{children:i(C,{className:"h-4 w-4"})}))})),i(W,{children:"Align left"})]}),t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"center"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"center"})},{children:i(E,{className:"h-4 w-4"})}))})),i(W,{children:"Align center"})]}),t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"right"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"right"})},{children:i(z,{className:"h-4 w-4"})}))})),i(W,{children:"Align right"})]})]})),t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o},{children:i(A,{className:"h-4 w-4"})}))})),i(W,{children:"Replace"})]}),b&&(null===(m=a.provider)||void 0===m?void 0:m.url)&&t(n,{children:[t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;d?d():(null===(e=a.provider)||void 0===e?void 0:e.url)&&F(a.provider.url)}},{children:i(T,{className:"h-4 w-4"})}))})),i(W,{children:"Copy URL"})]}),t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;(null===(e=a.provider)||void 0===e?void 0:e.url)&&window.open(a.provider.url,"_blank")}},{children:i(Y,{className:"h-4 w-4"})}))})),i(W,{children:"Open in new tab"})]})]}),i(B,{orientation:"vertical",className:"h-4"}),t(M,{children:[i(H,Object.assign({asChild:!0},{children:i(j,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:c},{children:i($,{className:"h-4 w-4"})}))})),i(W,{children:"Delete"})]})]}))}))}):null},ne=({blockId:n,attributes:r,children:o,elementProps:h,onUpdate:p,onDelete:u,onReplace:g,pluginOptions:b})=>{var f,v,y,w,x;const[j,k]=s(h.sizes||{width:650,height:400}),{isElementSelected:O}=c(),C=d({blockId:n}),E=O&&C,z=a(null),I=m(),[U,D]=s(()=>{var e,t;const i=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||650,n=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:i;return{maxWidth:"number"==typeof n?n:i,maxHeight:800}});l(()=>{const e=()=>{var e,t;const i=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||650,n=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:i;D({maxWidth:"number"==typeof n?n:i,maxHeight:800})};e();const t=new ResizeObserver(e);return I.refElement&&t.observe(I.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[I,b]);const S=(e,t)=>{const i=e=>"number"==typeof e?e:parseInt(String(e).replace(/[^\d]/g,""),10),n=i(e.width),s=i(e.height),r=i(t.width),a=i(t.height);if(n<=r&&s<=a)return{width:n,height:s};const l=n/r,o=s/a,c=Math.max(l,o),d=Math.round(n/c),m=Math.round(s/c);return{width:Math.min(d,r),height:Math.min(m,a)}},P=h.provider,L=null!==(f=null==P?void 0:P.embedUrl)&&void 0!==f?f:"",M={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(v=h.alignment)&&void 0!==v?v:"center"];return t("div",Object.assign({},r,{className:N("group/embed mt-2 relative transition-all w-full flex",M)},{children:[t("div",Object.assign({className:"relative",contentEditable:!1},{children:[i(R,Object.assign({ref:e=>{(null==e?void 0:e.resizableElement)&&e.resizableElement instanceof HTMLElement&&(z.current=e.resizableElement)},style:{position:"relative",outline:E?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:E?"hsl(var(--primary))":"none"},size:{width:"number"==typeof j.width?j.width:parseInt(String(j.width),10),height:"number"==typeof j.height?j.height:parseInt(String(j.height),10)},onResize:(e,t,i)=>{const n=parseInt(i.style.width,10),s=parseInt(i.style.height,10),r=S({width:n,height:s},{width:U.maxWidth,height:U.maxHeight});k(r)},onResizeStop:(e,t,i)=>{const n=parseInt(i.style.width,10),s=parseInt(i.style.height,10),r=S({width:n,height:s},{width:U.maxWidth,height:U.maxHeight});p({sizes:r})},lockAspectRatio:!0,minWidth:200,minHeight:150,maxWidth:U.maxWidth,maxHeight:U.maxHeight,enableResizing:!!E&&{bottom:!1,bottomLeft:!1,bottomRight:!1,left:!0,right:!0,top:!1,topLeft:!1,topRight:!1},disableDragging:!0,resizeHandleStyles:{left:{width:"auto",height:"40px",left:"-5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"},right:{width:"auto",height:"40px",right:"-5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"}},resizeHandleComponent:{left:i("div",{className:"h-10 w-2 rounded-full border border-primary bg-primary shadow-sm"}),right:i("div",{className:"h-10 w-2 rounded-full border border-primary bg-primary shadow-sm"})},className:N("rounded-sm overflow-hidden")},{children:i("iframe",{title:null!==(w=null===(y=null==P?void 0:P.meta)||void 0===y?void 0:y.title)&&void 0!==w?w:`Embedded content from ${null!==(x=null==P?void 0:P.type)&&void 0!==x?x:"unknown"}`,src:L,width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full",style:{aspectRatio:`${j.width} / ${j.height}`}})})),E&&i(ie,{referenceRef:z,elementProps:h,onUpdate:p,onReplace:g,onDelete:u,onCopy:()=>e(void 0,void 0,void 0,function*(){if(null==P?void 0:P.url)try{const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(P.url)}catch(e){}})})]})),o]}))},se={embed:{render:({element:t,attributes:n,children:s,blockId:r})=>{var a;const l=m(),c=h("Embed"),d=o(e=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),e)})},[l,r,t.props]),g=o(()=>e(void 0,void 0,void 0,function*(){const e=u.getBlockSlate(l,{id:r});if(!e)return;const i=p.getElementPath(l,{blockId:r,element:t});if(!i)return;const n=i?w.parent(e,i):void 0;n&&x.isElement(n[0])&&!w.isEditor(n[0])?p.deleteElement(l,{blockId:r,type:"embed",path:i}):u.deleteBlock(l,{blockId:r,focus:!0})}),[l,r,t]),b=o(()=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),{provider:null})})},[l,r,t.props]),f=o(t=>e(void 0,void 0,void 0,function*(){var e;const i=v(t);if(i){const t=null!==(e=null==c?void 0:c.maxWidth)&&void 0!==e?e:650,{width:n,height:s}=y(i.type,t);d({provider:i,sizes:{width:n,height:s}})}}),[d,c]),j=t;return(null===(a=j.props)||void 0===a?void 0:a.provider)?i(ne,Object.assign({blockId:r,elementId:t.id,onUpdate:d,onDelete:g,attributes:n,onReplace:b,elementProps:j.props,pluginOptions:c},{children:s})):i(te,Object.assign({onInsertUrl:f,attributes:n},{children:s}))}}};
7
+ */const K=I("Map",[["polygon",{points:"3 6 9 3 15 6 21 3 21 18 15 21 9 18 3 21",key:"ok2ie8"}],["line",{x1:"9",x2:"9",y1:"3",y2:"18",key:"w34qz5"}],["line",{x1:"15",x2:"15",y1:"6",y2:"21",key:"volv9a"}]]),J=I("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),Q=e=>{switch(e){case"youtube":case"vimeo":case"dailymotion":case"wistia":case"loom":return n(D,{className:"h-3 w-3"});case"spotify":case"soundcloud":return n(J,{className:"h-3 w-3"});case"codepen":case"codesandbox":return n(U,{className:"h-3 w-3"});case"google-maps":return n(K,{className:"h-3 w-3"});default:return n(O,{className:"h-3 w-3"})}},X=({name:e,type:n})=>t("span",Object.assign({className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:[Q(n),e]})),Z=({onInsertUrl:e})=>{const[i,r]=s(""),[a,l]=s(!1),[o,c]=s(null),d=()=>{i.trim()&&(e(i.trim()),r(""),l(!1),c(null))};return t("div",Object.assign({className:"space-y-3"},{children:[t("div",Object.assign({className:"space-y-2"},{children:[n(k,{placeholder:"Paste a URL to embed (YouTube, Vimeo, Twitter, Spotify, etc.)",value:i,onChange:e=>(e=>{var t;if(r(e),e.trim()){const n=v(e.trim());if(l(n),n){const n=g(e.trim()),i=b().find(e=>e.type===n);c(null!==(t=null==i?void 0:i.name)&&void 0!==t?t:null)}else c(null)}else l(!1),c(null)})(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&a&&(e.preventDefault(),d())},className:"h-10"}),i.trim()&&n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:a?t("span",Object.assign({className:"flex items-center gap-1.5 text-green-600 dark:text-green-400"},{children:[Q(g(i.trim())),o," detected"]})):n("span",Object.assign({className:"text-destructive"},{children:"Unsupported URL. Try YouTube, Vimeo, Twitter, Spotify, Figma, CodePen, etc."}))}))]})),n(w,Object.assign({className:"w-full",onClick:d,disabled:!i.trim()||!a},{children:a?`Embed ${o}`:"Embed content"}))]}))},ee=()=>{const e=b().filter(e=>"unknown"!==e.type);return t("div",Object.assign({className:"mt-4 space-y-2"},{children:[n("p",Object.assign({className:"text-xs text-muted-foreground text-center"},{children:"Supported providers:"})),t("div",Object.assign({className:"flex flex-wrap gap-1.5 justify-center"},{children:[e.slice(0,8).map(e=>n(X,{name:e.name,type:e.type},e.type)),e.length>8&&t("span",Object.assign({className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:["+",e.length-8," more"]}))]}))]}))},te=({onInsertUrl:e,className:i,attributes:s,children:r})=>t("div",Object.assign({className:N("mt-2 relative rounded-lg border bg-background overflow-hidden",i)},s,{contentEditable:!1},{children:[t("div",Object.assign({className:"p-6"},{children:[t("div",Object.assign({className:"flex flex-col items-center gap-4"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n(O,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Embed content"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Paste a URL from supported platforms"}))]}))]})),n("div",Object.assign({className:"mt-6 max-w-md mx-auto"},{children:n(Z,{onInsertUrl:e})})),n(ee,{})]})),r]})),ne=({referenceRef:e,elementProps:a,onUpdate:l,onReplace:o,onDelete:c,onCopy:d})=>{var m;const[h,p]=s(!1),[u,g]=s(!1),b=a.provider&&a.provider.type,v="alignment"in a,{refs:f,floatingStyles:y}=P({placement:"top-end",strategy:"absolute",middleware:[$(8),q({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),V({padding:10})],whileElementsMounted:G});r(()=>{const t=e.current;t&&(f.setReference(t),g(!0))},[e,f]),r(()=>{if(u){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[u]);return u?n(L,{children:n("div",Object.assign({ref:f.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:N("pointer-events-auto","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",h?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:y},{children:t(S,Object.assign({delayDuration:0},{children:[v&&t("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"left"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"left"})},{children:n(C,{className:"h-4 w-4"})}))})),n(W,{children:"Align left"})]}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"center"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"center"})},{children:n(R,{className:"h-4 w-4"})}))})),n(W,{children:"Align center"})]}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"right"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"right"})},{children:n(E,{className:"h-4 w-4"})}))})),n(W,{children:"Align right"})]})]})),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o},{children:n(_,{className:"h-4 w-4"})}))})),n(W,{children:"Replace"})]}),b&&(null===(m=a.provider)||void 0===m?void 0:m.url)&&t(i,{children:[t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;d?d():(null===(e=a.provider)||void 0===e?void 0:e.url)&&T(a.provider.url)}},{children:n(F,{className:"h-4 w-4"})}))})),n(W,{children:"Copy URL"})]}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;(null===(e=a.provider)||void 0===e?void 0:e.url)&&window.open(a.provider.url,"_blank")}},{children:n(M,{className:"h-4 w-4"})}))})),n(W,{children:"Open in new tab"})]})]}),n(B,{orientation:"vertical",className:"h-4"}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:c},{children:n(Y,{className:"h-4 w-4"})}))})),n(W,{children:"Delete"})]})]}))}))}):null},ie=({blockId:i,attributes:r,children:o,elementProps:h,onUpdate:p,onDelete:u,onReplace:g,pluginOptions:b})=>{var v,f,y,x,j;const[w,k]=s(h.sizes),{isElementSelected:O}=c(),C=d({blockId:i}),R=O&&C,E=a(null),I=m(),[U,D]=s(()=>{var e,t;const n=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,i=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:n;return{maxWidth:"number"==typeof i?i:n,maxHeight:0}});l(()=>{const e=()=>{var e,t;const n=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,i=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:n;D({maxWidth:"number"==typeof i?i:n,maxHeight:0})};e();const t=new ResizeObserver(e);return I.refElement&&t.observe(I.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[I,b]);const P=h.provider,L=null!==(v=null==P?void 0:P.embedUrl)&&void 0!==v?v:"",S={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(f=h.alignment)&&void 0!==f?f:"center"];return t("div",Object.assign({},r,{className:N("group/embed mt-4 relative transition-all w-full flex",S)},{children:[t("div",Object.assign({className:"relative",contentEditable:!1,ref:E},{children:[n(z,Object.assign({style:{position:"relative",outline:R?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:R?"hsl(var(--primary))":"none",padding:2},onResize:(e,t,n)=>{const i=parseInt(n.style.width,10),s=parseInt(n.style.height,10);k({width:i,height:s})},onResizeStop:(e,t,n)=>{const i=parseInt(n.style.width,10),s=parseInt(n.style.height,10);p({sizes:{width:i,height:s}})},lockAspectRatio:!0,minWidth:200,minHeight:150,maxWidth:U.maxWidth-8||void 0,maxHeight:U.maxHeight||void 0,enableResizing:!!R&&{bottom:!1,bottomLeft:!1,bottomRight:!1,left:!0,right:!0,top:!1,topLeft:!1,topRight:!1},disableDragging:!0,resizeHandleStyles:{left:{width:"auto",height:"40px",left:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"},right:{width:"auto",height:"40px",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"}},resizeHandleComponent:{left:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"}),right:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"})},className:N("rounded-sm overflow-hidden")},{children:n("iframe",{title:null!==(x=null===(y=null==P?void 0:P.meta)||void 0===y?void 0:y.title)&&void 0!==x?x:`Embedded content from ${null!==(j=null==P?void 0:P.type)&&void 0!==j?j:"unknown"}`,src:L,width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full",style:{aspectRatio:`${w.width} / ${w.height}`}})})),R&&n(ne,{referenceRef:E,elementProps:h,onUpdate:p,onReplace:g,onDelete:u,onCopy:()=>e(void 0,void 0,void 0,function*(){if(null==P?void 0:P.url)try{const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(P.url)}catch(e){}})})]})),o]}))},se={embed:{render:({element:t,attributes:i,children:s,blockId:r})=>{var a;const l=m(),c=h("Embed"),d=o(e=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),e)})},[l,r,t.props]),g=o(()=>e(void 0,void 0,void 0,function*(){const e=u.getBlockSlate(l,{id:r});if(!e)return;const n=p.getElementPath(l,{blockId:r,element:t});if(!n)return;const i=n?x.parent(e,n):void 0;i&&j.isElement(i[0])&&!x.isEditor(i[0])?p.deleteElement(l,{blockId:r,type:"embed",path:n}):u.deleteBlock(l,{blockId:r,focus:!0})}),[l,r,t]),b=o(()=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),{provider:null})})},[l,r,t.props]),v=o(t=>e(void 0,void 0,void 0,function*(){var e;const n=f(t);if(n){const t=null!==(e=null==c?void 0:c.maxWidth)&&void 0!==e?e:650,{width:i,height:s}=y(n.type,t);d({provider:n,sizes:{width:i,height:s}})}}),[d,c]),w=t;return(null===(a=w.props)||void 0===a?void 0:a.provider)?n(ie,Object.assign({blockId:r,elementId:t.id,onUpdate:d,onDelete:g,attributes:i,onReplace:b,elementProps:w.props,pluginOptions:c},{children:s})):l.readOnly?null:n(te,Object.assign({onInsertUrl:v,attributes:i},{children:s}))}}};
8
8
  /**
9
9
  * @license lucide-react v0.294.0 - ISC
10
10
  *
@@ -1,3 +1,3 @@
1
1
  import { type PluginElementRenderProps } from '@yoopta/editor';
2
- export declare const FileElement: ({ element, attributes, children, blockId }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const FileElement: ({ element, attributes, children, blockId }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element | null;
3
3
  //# sourceMappingURL=file-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-element.d.ts","sourceRoot":"","sources":["../../../../src/file/elements/file/file-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAUvF,eAAO,MAAM,WAAW,+CAAgD,wBAAwB,4CA4G/F,CAAC"}
1
+ {"version":3,"file":"file-element.d.ts","sourceRoot":"","sources":["../../../../src/file/elements/file/file-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAUvF,eAAO,MAAM,WAAW,+CAAgD,wBAAwB,mDAuH/F,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export declare const FileUI: {
2
2
  file: {
3
- render: ({ element, attributes, children, blockId }: import("@yoopta/editor/dist/plugins/types").PluginElementExtendRenderProps) => import("react/jsx-runtime").JSX.Element;
3
+ render: ({ element, attributes, children, blockId }: import("@yoopta/editor/dist/plugins/types").PluginElementExtendRenderProps) => import("react/jsx-runtime").JSX.Element | null;
4
4
  };
5
5
  };
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/file.js CHANGED
@@ -1,10 +1,10 @@
1
- import{a as e}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as a,Fragment as n}from"react/jsx-runtime";import{useRef as s,useState as i,useLayoutEffect as r,useCallback as l}from"react";import{useElementSelected as o,useBlockSelected as c,useYooptaEditor as d,useYooptaPluginOptions as p,Elements as m,Blocks as h}from"@yoopta/editor";import{getFileType as g,formatFileSize as u,useFileUpload as b,useFileDelete as k}from"@yoopta/file";import{Editor as f,Element as y}from"slate";import{B as v}from"./chunks/button-7aec29d6.js";import{c as x}from"./chunks/utils-3345eade.js";import{L as j,U as w,D as N}from"./chunks/upload-b1dd210d.js";import{c as O}from"./chunks/createLucideIcon-8605f860.js";import{F as C}from"./chunks/file-text-ad3e3ebb.js";import{C as M}from"./chunks/code-d31bdce0.js";import{u as z,F as D,T as F,a as E,b as I,R,c as L}from"./chunks/tooltip-65b9c3a0.js";import{C as P,c as U}from"./chunks/index-0bca29df.js";import{E as V}from"./chunks/external-link-1579dd7f.js";import{T as H}from"./chunks/trash-2-f36597ff.js";import{o as A,f as B,s as S,b as T}from"./chunks/index-23c7fb16.js";import"react-dom";import"./chunks/index-17323747.js";import"./chunks/index-91a5b8d5.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-23db6fea.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-1674c2c8.js";import"./chunks/index-70f4e709.js";
1
+ import{a as e}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as a,Fragment as n}from"react/jsx-runtime";import{useRef as s,useState as r,useLayoutEffect as l,useCallback as i}from"react";import{useElementSelected as o,useBlockSelected as c,useYooptaEditor as d,useYooptaPluginOptions as p,Elements as m,Blocks as h}from"@yoopta/editor";import{getFileType as g,formatFileSize as u,useFileUpload as b,useFileDelete as k}from"@yoopta/file";import{Editor as f,Element as y}from"slate";import{B as v}from"./chunks/button-7aec29d6.js";import{c as x}from"./chunks/utils-3345eade.js";import{L as j,U as w,D as O}from"./chunks/upload-b1dd210d.js";import{c as N}from"./chunks/createLucideIcon-8605f860.js";import{F as C}from"./chunks/file-text-ad3e3ebb.js";import{C as M}from"./chunks/code-d31bdce0.js";import{u as z,F as D,T as F,a as E,b as I,R,c as L}from"./chunks/tooltip-65b9c3a0.js";import{C as P,c as U}from"./chunks/index-0bca29df.js";import{E as V}from"./chunks/external-link-1579dd7f.js";import{T as H}from"./chunks/trash-2-f36597ff.js";import{o as A,f as B,s as S,b as T}from"./chunks/index-23c7fb16.js";import"react-dom";import"./chunks/index-17323747.js";import"./chunks/index-91a5b8d5.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-23db6fea.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-1674c2c8.js";import"./chunks/index-70f4e709.js";
2
2
  /**
3
3
  * @license lucide-react v0.294.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
- */const $=O("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),q=O("FileAudio",[["path",{d:"M17.5 22h.5c.5 0 1-.2 1.4-.6.4-.4.6-.9.6-1.4V7.5L14.5 2H6c-.5 0-1 .2-1.4.6C4.2 3 4 3.5 4 4v3",key:"1013sb"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M10 20v-1a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0Z",key:"gqt63y"}],["path",{d:"M6 20v-1a2 2 0 1 0-4 0v1a2 2 0 1 0 4 0Z",key:"cf7lqx"}],["path",{d:"M2 19v-3a6 6 0 0 1 12 0v3",key:"1acxgf"}]]),Z=O("FileImage",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["circle",{cx:"10",cy:"13",r:"2",key:"6v46hv"}],["path",{d:"m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22",key:"17vly1"}]]),_=O("FileSpreadsheet",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M14 17h2",key:"10kma7"}]]),G=O("FileVideo",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]),K=O("File",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]),J=O("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),Q=({progress:e})=>a("div",Object.assign({className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-4 bg-background/95 backdrop-blur-sm p-6 rounded-lg border"},{children:a("div",Object.assign({className:"w-full max-w-md space-y-4"},{children:t("div",Object.assign({className:"space-y-2"},{children:[t("div",Object.assign({className:"flex items-center justify-between text-sm"},{children:[a("span",Object.assign({className:"font-medium"},{children:"Uploading file..."})),t("span",Object.assign({className:"text-muted-foreground"},{children:[e.percentage,"%"]}))]})),a("div",Object.assign({className:"h-2 w-full overflow-hidden rounded-full bg-muted"},{children:a("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${e.percentage}%`}})})),t("div",Object.assign({className:"flex items-center justify-between text-xs text-muted-foreground"},{children:[t("span",{children:[(e.loaded/1024/1024).toFixed(2)," MB / ",(e.total/1024/1024).toFixed(2)," MB"]}),a(j,{className:"h-3.5 w-3.5 animate-spin"})]}))]}))}))})),W=({onUpload:e,accept:n})=>{const i=s(null);return t("div",Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[a("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:a(K,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[a("p",Object.assign({className:"text-sm font-medium"},{children:"Upload a file"})),a("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Click to select a file"}))]})),t(v,Object.assign({onClick:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.click()},variant:"default",className:"gap-2"},{children:[a(w,{className:"h-4 w-4"}),"Choose file"]})),a("input",{ref:i,type:"file",accept:n,onChange:e,className:"hidden"})]}))},X=({onUpload:e,className:n,attributes:s,children:i,progress:r,loading:l,accept:o})=>{const c=l&&r;return t("div",Object.assign({className:x("mt-2 relative rounded-lg border bg-background overflow-hidden",n)},s,{contentEditable:!1},{children:[a(W,{onUpload:e,accept:o}),c&&r&&a(Q,{progress:r}),i]}))},Y={pdf:{icon:C,color:"text-red-600 dark:text-red-400",bgColor:"bg-red-100 dark:bg-red-900/30"},document:{icon:C,color:"text-blue-600 dark:text-blue-400",bgColor:"bg-blue-100 dark:bg-blue-900/30"},spreadsheet:{icon:_,color:"text-green-600 dark:text-green-400",bgColor:"bg-green-100 dark:bg-green-900/30"},presentation:{icon:J,color:"text-orange-600 dark:text-orange-400",bgColor:"bg-orange-100 dark:bg-orange-900/30"},image:{icon:Z,color:"text-purple-600 dark:text-purple-400",bgColor:"bg-purple-100 dark:bg-purple-900/30"},video:{icon:G,color:"text-pink-600 dark:text-pink-400",bgColor:"bg-pink-100 dark:bg-pink-900/30"},audio:{icon:q,color:"text-yellow-600 dark:text-yellow-400",bgColor:"bg-yellow-100 dark:bg-yellow-900/30"},archive:{icon:$,color:"text-amber-600 dark:text-amber-400",bgColor:"bg-amber-100 dark:bg-amber-900/30"},code:{icon:M,color:"text-cyan-600 dark:text-cyan-400",bgColor:"bg-cyan-100 dark:bg-cyan-900/30"},text:{icon:C,color:"text-gray-600 dark:text-gray-400",bgColor:"bg-gray-100 dark:bg-gray-800/50"},unknown:{icon:K,color:"text-muted-foreground",bgColor:"bg-muted"}},ee=({fileType:e,className:t})=>{var n;const s=(null!==(n=Y[e])&&void 0!==n?n:Y.unknown).icon;return a(s,{className:t})},te=({referenceRef:e,elementProps:s,onReplace:l,onDelete:o,onDownload:c})=>{const[d,p]=i(!1),[m,h]=i(!1),{refs:g,floatingStyles:u}=z({placement:"top-end",strategy:"absolute",middleware:[A(8),B({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),S({padding:10})],whileElementsMounted:T});r(()=>{const t=e.current;t&&(g.setReference(t),h(!0))},[e,g]),r(()=>{if(m){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[m]);return m?a(D,{children:a("div",Object.assign({ref:g.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:x("pointer-events-auto z-50","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",d?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:u},{children:t(F,Object.assign({delayDuration:0},{children:[t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:l},{children:a(R,{className:"h-4 w-4"})}))})),a(L,{children:"Replace"})]}),s.src&&t(n,{children:[t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;if(c)c();else if(s.src){const t=document.createElement("a");t.href=s.src,t.download=null!==(e=s.name)&&void 0!==e?e:`file-${Date.now()}`,t.click()}}},{children:a(N,{className:"h-4 w-4"})}))})),a(L,{children:"Download"})]}),t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{s.src&&U(s.src)}},{children:a(P,{className:"h-4 w-4"})}))})),a(L,{children:"Copy URL"})]}),t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{s.src&&window.open(s.src,"_blank")}},{children:a(V,{className:"h-4 w-4"})}))})),a(L,{children:"Open in new tab"})]})]}),t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:o},{children:a(H,{className:"h-4 w-4"})}))})),a(L,{children:"Delete"})]})]}))}))}):null},ae=({blockId:e,attributes:n,children:i,elementProps:r,onDelete:l,onReplace:d})=>{const{isElementSelected:p}=o(),m=c({blockId:e}),h=p&&m,b=s(null),{name:k,format:f,size:y,src:j}=r,w=f?`${k}.${f}`:null!=k?k:"Untitled file",O=g(w),C=(e=>{var t;return null!==(t=Y[e])&&void 0!==t?t:Y.unknown})(O),M=()=>{if(!j)return;const e=document.createElement("a");e.href=j,e.download=w,e.click()};return t("div",Object.assign({},n,{className:"group/file mt-2 relative transition-all w-full"},{children:[t("div",Object.assign({className:"relative",contentEditable:!1},{children:[t("div",Object.assign({ref:b,className:x("flex items-center gap-3 p-3 rounded-lg border bg-card transition-all","hover:bg-accent/50",h&&"ring-2 ring-primary ring-offset-2")},{children:[a("div",Object.assign({className:x("flex-shrink-0 rounded-lg p-2.5",C.bgColor)},{children:a(ee,{fileType:O,className:x("h-5 w-5",C.color)})})),t("div",Object.assign({className:"flex-1 min-w-0"},{children:[a("p",Object.assign({className:"text-sm font-medium truncate"},{children:w})),a("p",Object.assign({className:"text-xs text-muted-foreground"},{children:u(y)}))]})),j&&a(v,Object.assign({variant:"ghost",size:"icon",className:"flex-shrink-0 h-8 w-8 opacity-0 group-hover/file:opacity-100 transition-opacity",onClick:M},{children:a(N,{className:"h-4 w-4"})}))]})),h&&a(te,{referenceRef:b,elementProps:r,onReplace:d,onDelete:l,onDownload:M})]})),i]}))},ne={file:{render:({element:t,attributes:n,children:s,blockId:i})=>{const r=d(),o=p("File"),{upload:c,progress:g,loading:u}=b(o.upload),{deleteFile:v}=k(o.delete),x=l(e=>{m.updateElement(r,{blockId:i,type:"file",props:Object.assign(Object.assign({},t.props),e)})},[r,i,t.props]),j=l(()=>e(void 0,void 0,void 0,function*(){yield v(t);const e=h.getBlockSlate(r,{id:i});if(!e)return;const a=m.getElementPath(r,{blockId:i,element:t});if(!a)return;const n=a?f.parent(e,a):void 0;n&&y.isElement(n[0])&&!f.isEditor(n[0])?m.deleteElement(r,{blockId:i,type:"file",path:a}):h.deleteBlock(r,{blockId:i,focus:!0})}),[r,i,t,v]),w=l(()=>{m.updateElement(r,{blockId:i,type:"file",props:Object.assign(Object.assign({},t.props),{id:null,src:null,name:null,size:null,format:null})})},[r,i,t.props]),N=l(t=>e(void 0,void 0,void 0,function*(){var e,a,n;const s=null===(e=t.target.files)||void 0===e?void 0:e[0];if(!s)return;const i=yield c(s);let r=null!==(a=i.name)&&void 0!==a?a:s.name,l=null;const o=r.lastIndexOf(".");o>0&&(l=r.slice(o+1),r=r.slice(0,o)),x({id:i.id,src:i.url,name:r,size:null!==(n=i.size)&&void 0!==n?n:s.size,format:l})}),[c,x]);return t.props.src?a(ae,Object.assign({blockId:i,onDelete:j,attributes:n,onReplace:w,elementProps:t.props},{children:s})):a(X,Object.assign({onUpload:N,progress:g,loading:u,accept:o.accept,attributes:n},{children:s}))}}};
7
+ */const $=N("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),q=N("FileAudio",[["path",{d:"M17.5 22h.5c.5 0 1-.2 1.4-.6.4-.4.6-.9.6-1.4V7.5L14.5 2H6c-.5 0-1 .2-1.4.6C4.2 3 4 3.5 4 4v3",key:"1013sb"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M10 20v-1a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0Z",key:"gqt63y"}],["path",{d:"M6 20v-1a2 2 0 1 0-4 0v1a2 2 0 1 0 4 0Z",key:"cf7lqx"}],["path",{d:"M2 19v-3a6 6 0 0 1 12 0v3",key:"1acxgf"}]]),Z=N("FileImage",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["circle",{cx:"10",cy:"13",r:"2",key:"6v46hv"}],["path",{d:"m20 17-1.09-1.09a2 2 0 0 0-2.82 0L10 22",key:"17vly1"}]]),_=N("FileSpreadsheet",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M14 17h2",key:"10kma7"}]]),G=N("FileVideo",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}],["path",{d:"m10 11 5 3-5 3v-6Z",key:"7ntvm4"}]]),J=N("File",[["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",key:"1nnpy2"}],["polyline",{points:"14 2 14 8 20 8",key:"1ew0cm"}]]),K=N("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),Q=({progress:e})=>a("div",Object.assign({className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-4 bg-background/95 backdrop-blur-sm p-6 rounded-lg border"},{children:a("div",Object.assign({className:"w-full max-w-md space-y-4"},{children:t("div",Object.assign({className:"space-y-2"},{children:[t("div",Object.assign({className:"flex items-center justify-between text-sm"},{children:[a("span",Object.assign({className:"font-medium"},{children:"Uploading file..."})),t("span",Object.assign({className:"text-muted-foreground"},{children:[e.percentage,"%"]}))]})),a("div",Object.assign({className:"h-2 w-full overflow-hidden rounded-full bg-muted"},{children:a("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${e.percentage}%`}})})),t("div",Object.assign({className:"flex items-center justify-between text-xs text-muted-foreground"},{children:[t("span",{children:[(e.loaded/1024/1024).toFixed(2)," MB / ",(e.total/1024/1024).toFixed(2)," MB"]}),a(j,{className:"h-3.5 w-3.5 animate-spin"})]}))]}))}))})),W=({onUpload:e,accept:n})=>{const r=s(null);return t("div",Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[a("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:a(J,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[a("p",Object.assign({className:"text-sm font-medium"},{children:"Upload a file"})),a("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Click to select a file"}))]})),t(v,Object.assign({onClick:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.click()},variant:"default",className:"gap-2"},{children:[a(w,{className:"h-4 w-4"}),"Choose file"]})),a("input",{ref:r,type:"file",accept:n,onChange:e,className:"hidden"})]}))},X=({onUpload:e,className:n,attributes:s,children:r,progress:l,loading:i,accept:o})=>{const c=i&&l;return t("div",Object.assign({className:x("mt-2 relative rounded-lg border bg-background overflow-hidden",n)},s,{contentEditable:!1},{children:[a(W,{onUpload:e,accept:o}),c&&l&&a(Q,{progress:l}),r]}))},Y={pdf:{icon:C,color:"text-red-600 dark:text-red-400",bgColor:"bg-red-100 dark:bg-red-900/30"},document:{icon:C,color:"text-blue-600 dark:text-blue-400",bgColor:"bg-blue-100 dark:bg-blue-900/30"},spreadsheet:{icon:_,color:"text-green-600 dark:text-green-400",bgColor:"bg-green-100 dark:bg-green-900/30"},presentation:{icon:K,color:"text-orange-600 dark:text-orange-400",bgColor:"bg-orange-100 dark:bg-orange-900/30"},image:{icon:Z,color:"text-purple-600 dark:text-purple-400",bgColor:"bg-purple-100 dark:bg-purple-900/30"},video:{icon:G,color:"text-pink-600 dark:text-pink-400",bgColor:"bg-pink-100 dark:bg-pink-900/30"},audio:{icon:q,color:"text-yellow-600 dark:text-yellow-400",bgColor:"bg-yellow-100 dark:bg-yellow-900/30"},archive:{icon:$,color:"text-amber-600 dark:text-amber-400",bgColor:"bg-amber-100 dark:bg-amber-900/30"},code:{icon:M,color:"text-cyan-600 dark:text-cyan-400",bgColor:"bg-cyan-100 dark:bg-cyan-900/30"},text:{icon:C,color:"text-gray-600 dark:text-gray-400",bgColor:"bg-gray-100 dark:bg-gray-800/50"},unknown:{icon:J,color:"text-muted-foreground",bgColor:"bg-muted"}},ee=({fileType:e,className:t})=>{var n;const s=(null!==(n=Y[e])&&void 0!==n?n:Y.unknown).icon;return a(s,{className:t})},te=({referenceRef:e,elementProps:s,onReplace:i,onDelete:o,onDownload:c})=>{const[d,p]=r(!1),[m,h]=r(!1),{refs:g,floatingStyles:u}=z({placement:"top-end",strategy:"absolute",middleware:[A(8),B({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),S({padding:10})],whileElementsMounted:T});l(()=>{const t=e.current;t&&(g.setReference(t),h(!0))},[e,g]),l(()=>{if(m){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[m]);return m?a(D,{children:a("div",Object.assign({ref:g.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:x("pointer-events-auto z-50","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",d?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:u},{children:t(F,Object.assign({delayDuration:0},{children:[t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:i},{children:a(R,{className:"h-4 w-4"})}))})),a(L,{children:"Replace"})]}),s.src&&t(n,{children:[t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;if(c)c();else if(s.src){const t=document.createElement("a");t.href=s.src,t.download=null!==(e=s.name)&&void 0!==e?e:`file-${Date.now()}`,t.click()}}},{children:a(O,{className:"h-4 w-4"})}))})),a(L,{children:"Download"})]}),t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{s.src&&U(s.src)}},{children:a(P,{className:"h-4 w-4"})}))})),a(L,{children:"Copy URL"})]}),t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{s.src&&window.open(s.src,"_blank")}},{children:a(V,{className:"h-4 w-4"})}))})),a(L,{children:"Open in new tab"})]})]}),t(E,{children:[a(I,Object.assign({asChild:!0},{children:a(v,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:o},{children:a(H,{className:"h-4 w-4"})}))})),a(L,{children:"Delete"})]})]}))}))}):null},ae=({blockId:e,attributes:n,children:r,elementProps:l,onDelete:i,onReplace:d})=>{const{isElementSelected:p}=o(),m=c({blockId:e}),h=p&&m,b=s(null),{name:k,format:f,size:y,src:j}=l,w=f?`${k}.${f}`:null!=k?k:"Untitled file",N=g(w),C=(e=>{var t;return null!==(t=Y[e])&&void 0!==t?t:Y.unknown})(N),M=()=>{if(!j)return;const e=document.createElement("a");e.href=j,e.download=w,e.click()};return t("div",Object.assign({},n,{className:"group/file mt-2 relative transition-all w-full"},{children:[t("div",Object.assign({className:"relative",contentEditable:!1},{children:[t("div",Object.assign({ref:b,className:x("flex items-center gap-3 p-3 rounded-lg border bg-card transition-all","hover:bg-accent/50",h&&"ring-2 ring-primary ring-offset-2")},{children:[a("div",Object.assign({className:x("flex-shrink-0 rounded-lg p-2.5",C.bgColor)},{children:a(ee,{fileType:N,className:x("h-5 w-5",C.color)})})),t("div",Object.assign({className:"flex-1 min-w-0"},{children:[a("p",Object.assign({className:"text-sm font-medium truncate"},{children:w})),a("p",Object.assign({className:"text-xs text-muted-foreground"},{children:u(y)}))]})),j&&a(v,Object.assign({variant:"ghost",size:"icon",className:"flex-shrink-0 h-8 w-8 opacity-0 group-hover/file:opacity-100 transition-opacity",onClick:M},{children:a(O,{className:"h-4 w-4"})}))]})),h&&a(te,{referenceRef:b,elementProps:l,onReplace:d,onDelete:i,onDownload:M})]})),r]}))},ne={file:{render:({element:t,attributes:n,children:s,blockId:r})=>{const l=d(),o=p("File"),{upload:c,progress:g,loading:u}=b(o.upload),{deleteFile:v}=k(o.delete),x=i(e=>{m.updateElement(l,{blockId:r,type:"file",props:Object.assign(Object.assign({},t.props),e)})},[l,r,t.props]),j=i(()=>e(void 0,void 0,void 0,function*(){if(l.readOnly)return null;yield v(t);const e=h.getBlockSlate(l,{id:r});if(!e)return;const a=m.getElementPath(l,{blockId:r,element:t});if(!a)return;const n=a?f.parent(e,a):void 0;n&&y.isElement(n[0])&&!f.isEditor(n[0])?m.deleteElement(l,{blockId:r,type:"file",path:a}):h.deleteBlock(l,{blockId:r,focus:!0})}),[l,r,t,v]),w=i(()=>{if(l.readOnly)return null;m.updateElement(l,{blockId:r,type:"file",props:Object.assign(Object.assign({},t.props),{id:null,src:null,name:null,size:null,format:null})})},[l,r,t.props]),O=i(t=>e(void 0,void 0,void 0,function*(){var e,a,n;if(l.readOnly)return null;const s=null===(e=t.target.files)||void 0===e?void 0:e[0];if(!s)return;const r=yield c(s);let i=null!==(a=r.name)&&void 0!==a?a:s.name,o=null;const d=i.lastIndexOf(".");d>0&&(o=i.slice(d+1),i=i.slice(0,d)),x({id:r.id,src:r.url,name:i,size:null!==(n=r.size)&&void 0!==n?n:s.size,format:o})}),[c,x,l.readOnly]);return t.props.src?a(ae,Object.assign({blockId:r,onDelete:j,attributes:n,onReplace:w,elementProps:t.props},{children:s})):l.readOnly?null:a(X,Object.assign({onUpload:O,progress:g,loading:u,accept:o.accept,attributes:n},{children:s}))}}};
8
8
  /**
9
9
  * @license lucide-react v0.294.0 - ISC
10
10
  *
@@ -1,3 +1,3 @@
1
1
  import { type PluginElementRenderProps } from '@yoopta/editor';
2
- export declare const ImageElement: ({ element, attributes, children, blockId, }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ImageElement: ({ element, attributes, children, blockId, }: PluginElementRenderProps) => import("react/jsx-runtime").JSX.Element | null;
3
3
  //# sourceMappingURL=image-element.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-element.d.ts","sourceRoot":"","sources":["../../../../src/image/elements/image/image-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAevF,eAAO,MAAM,YAAY,gDAKtB,wBAAwB,4CAwG1B,CAAC"}
1
+ {"version":3,"file":"image-element.d.ts","sourceRoot":"","sources":["../../../../src/image/elements/image/image-element.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,wBAAwB,EAA0B,MAAM,gBAAgB,CAAC;AAevF,eAAO,MAAM,YAAY,gDAKtB,wBAAwB,mDA4G1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"image-render.d.ts","sourceRoot":"","sources":["../../../../src/image/elements/image/image-render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAMxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,iBAAiB,CAAC;IAChC,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,mGASrB,KAAK,4CA2PP,CAAC"}
1
+ {"version":3,"file":"image-render.d.ts","sourceRoot":"","sources":["../../../../src/image/elements/image/image-render.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAMxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACtD,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,EAAE,iBAAiB,CAAC;IAChC,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,WAAW,mGASrB,KAAK,4CAgNP,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export declare const ImageUI: {
2
2
  image: {
3
- render: ({ element, attributes, children, blockId, }: import("@yoopta/editor/dist/plugins/types").PluginElementExtendRenderProps) => import("react/jsx-runtime").JSX.Element;
3
+ render: ({ element, attributes, children, blockId, }: import("@yoopta/editor/dist/plugins/types").PluginElementExtendRenderProps) => import("react/jsx-runtime").JSX.Element | null;
4
4
  };
5
5
  };
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/image.js CHANGED
@@ -1,7 +1,7 @@
1
- import{_ as e,a as t}from"./chunks/_tslib-35bb891d.js";import{jsx as n,jsxs as i,Fragment as a}from"react/jsx-runtime";import*as s from"react";import{useRef as r,useState as o,useLayoutEffect as l,useEffect as c,useCallback as d}from"react";import{useElementSelected as m,useBlockSelected as h,useYooptaEditor as u,useYooptaPluginOptions as g,Elements as p,Blocks as f}from"@yoopta/editor";import{useImageUpload as b,useImageDelete as v,useImagePreview as w}from"@yoopta/image";import{Editor as x,Element as j}from"slate";import{B as y}from"./chunks/button-7aec29d6.js";import{a as N,T as O,c as k,b as S}from"./chunks/tabs-294764a6.js";import{I}from"./chunks/input-b2431223.js";import{c as C}from"./chunks/utils-3345eade.js";import{a as R,b as D,c as E,T as z,u as P,F as U,R as A}from"./chunks/tooltip-65b9c3a0.js";import{L as M,U as H,D as F}from"./chunks/upload-b1dd210d.js";import{L as _,A as L,a as B,b as K,R as V}from"./chunks/index-87b75648.js";import{S as W}from"./chunks/sparkles-ae42eae3.js";import{c as T}from"./chunks/createLucideIcon-8605f860.js";import{C as $,c as Y}from"./chunks/index-0bca29df.js";import{L as G}from"./chunks/label-21d46c31.js";import{P as X,a as q,b as J}from"./chunks/popover-8e6ee2ab.js";import{u as Q,S as Z,a as ee,b as te,c as ne,e as ie,d as ae}from"./chunks/select-a8bcd8b5.js";import{S as se}from"./chunks/separator-219dc1f7.js";import{c as re}from"./chunks/index-056e5c06.js";import{c as oe,a as le,P as ce}from"./chunks/index-17323747.js";import{u as de}from"./chunks/index-91a5b8d5.js";import{u as me}from"./chunks/index-ff0e3962.js";import{u as he}from"./chunks/index-13505606.js";import{e as ue,o as ge,f as pe,s as fe,b as be}from"./chunks/index-23c7fb16.js";import{c as ve}from"./chunks/index-f85dae42.js";import{S as we}from"./chunks/settings-2-84fe63d9.js";import{T as xe}from"./chunks/trash-2-f36597ff.js";import"./chunks/index-ba3032f8.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-70f4e709.js";import"./chunks/index-23db6fea.js";import"react-dom";import"./chunks/index-1674c2c8.js";import"./chunks/index-a5cba5f7.js";import"./chunks/Combination-575d4475.js";import"./chunks/chevron-down-28dfb290.js";import"./chunks/check-06bd6a78.js";import"./chunks/chevron-up-9a13532e.js";
1
+ import{_ as e,a as t}from"./chunks/_tslib-35bb891d.js";import{jsx as n,jsxs as i,Fragment as a}from"react/jsx-runtime";import*as s from"react";import{useRef as r,useState as o,useLayoutEffect as l,useEffect as c,useCallback as d}from"react";import{useElementSelected as m,useBlockSelected as h,useYooptaEditor as u,useYooptaPluginOptions as g,Elements as p,Blocks as f}from"@yoopta/editor";import{useImageUpload as b,useImageDelete as v,useImagePreview as w}from"@yoopta/image";import{Editor as x,Element as j}from"slate";import{B as y}from"./chunks/button-7aec29d6.js";import{a as N,T as O,c as k,b as S}from"./chunks/tabs-294764a6.js";import{I}from"./chunks/input-b2431223.js";import{a as C,b as R,c as D,T as E,u as z,F as P,R as U}from"./chunks/tooltip-65b9c3a0.js";import{c as A}from"./chunks/utils-3345eade.js";import{L as _,U as H,D as M}from"./chunks/upload-b1dd210d.js";import{L as F,A as L,a as B,b as K,R as V}from"./chunks/index-87b75648.js";import{S as W}from"./chunks/sparkles-ae42eae3.js";import{c as T}from"./chunks/createLucideIcon-8605f860.js";import{C as $,c as Y}from"./chunks/index-0bca29df.js";import{L as G}from"./chunks/label-21d46c31.js";import{P as X,a as q,b as J}from"./chunks/popover-8e6ee2ab.js";import{u as Q,S as Z,a as ee,b as te,c as ne,e as ie,d as ae}from"./chunks/select-a8bcd8b5.js";import{S as se}from"./chunks/separator-219dc1f7.js";import{c as re}from"./chunks/index-056e5c06.js";import{c as oe,a as le,P as ce}from"./chunks/index-17323747.js";import{u as de}from"./chunks/index-91a5b8d5.js";import{u as me}from"./chunks/index-ff0e3962.js";import{u as he}from"./chunks/index-13505606.js";import{e as ue,o as ge,f as pe,s as fe,b as be}from"./chunks/index-23c7fb16.js";import{c as ve}from"./chunks/index-f85dae42.js";import{S as we}from"./chunks/settings-2-84fe63d9.js";import{T as xe}from"./chunks/trash-2-f36597ff.js";import"./chunks/index-ba3032f8.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-70f4e709.js";import"./chunks/index-23db6fea.js";import"react-dom";import"./chunks/index-1674c2c8.js";import"./chunks/index-a5cba5f7.js";import"./chunks/Combination-575d4475.js";import"./chunks/chevron-down-28dfb290.js";import"./chunks/check-06bd6a78.js";import"./chunks/chevron-up-9a13532e.js";
2
2
  /**
3
3
  * @license lucide-react v0.294.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
- */const je=T("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),ye=({onInsertFromUnsplash:e})=>n(N,Object.assign({value:"unsplash",className:"mt-4"},{children:i("div",Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n("svg",Object.assign({className:"h-6 w-6",viewBox:"0 0 32 32",fill:"currentColor"},{children:n("path",{d:"M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z"})}))})),i("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Browse free photos"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Powered by Unsplash"}))]})),n(y,Object.assign({onClick:e},{children:"Browse photos"}))]}))})),Ne=({preview:e})=>n("div",Object.assign({className:"absolute inset-0 overflow-hidden",style:{width:e.width,height:e.height}},{children:n("img",{src:e.url,alt:"Preview",className:"h-full w-full object-cover object-center",style:{width:e.width,height:e.height},draggable:!1})})),Oe=({progress:e})=>n("div",Object.assign({className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-4 bg-black/70 backdrop-blur-sm p-6"},{children:n("div",Object.assign({className:"w-full max-w-md space-y-4"},{children:i("div",Object.assign({className:"space-y-2"},{children:[i("div",Object.assign({className:"flex items-center justify-between text-sm"},{children:[n("span",Object.assign({className:"font-medium text-white"},{children:"Uploading..."})),i("span",Object.assign({className:"text-white/80"},{children:[e.percentage,"%"]}))]})),n("div",Object.assign({className:"h-2 w-full overflow-hidden rounded-full bg-white/20"},{children:n("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${e.percentage}%`}})})),i("div",Object.assign({className:"flex items-center justify-between text-xs text-white/60"},{children:[i("span",{children:[(e.loaded/1024/1024).toFixed(2)," MB /"," ",(e.total/1024/1024).toFixed(2)," MB"]}),n(M,{className:"h-3.5 w-3.5 animate-spin"})]}))]}))}))})),ke=({onUpload:e,hasPreview:t})=>{const a=r(null);return i("div",t?Object.assign({className:"flex flex-col items-center justify-center gap-4 py-8"},{children:[i("div",Object.assign({className:"text-center space-y-2"},{children:[n("p",Object.assign({className:"text-sm font-medium text-white"},{children:"Image preview"})),n("p",Object.assign({className:"text-xs text-white/80"},{children:"Uploading your image..."}))]})),n("input",{ref:a,type:"file",accept:"image/*",onChange:e,className:"hidden"})]}):Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n(je,{className:"h-6 w-6 text-muted-foreground"})})),i("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Upload an image"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Click or drag and drop"}))]})),n(y,Object.assign({onClick:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.click()}},{children:"Choose file"})),n("input",{ref:a,type:"file",accept:"image/*",onChange:e,className:"hidden"})]}))},Se=({onInsertUrl:e})=>{const[t,a]=o(""),s=()=>{t.trim()&&(e(t.trim()),a(""))};return i("div",Object.assign({className:"mt-4 space-y-3"},{children:[n(I,{placeholder:"Paste image URL...",value:t,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&t.trim()&&s()}}),n(y,Object.assign({className:"w-full",onClick:s,disabled:!t.trim()},{children:"Embed image"}))]}))},Ie=({onInsertFromAI:e})=>{const[t,s]=o(""),[r,l]=o(!1),c=()=>{t.trim()&&!r&&(l(!0),e(t.trim()),l(!1),s(""))};return i("div",Object.assign({className:"mt-4 space-y-3"},{children:[i("div",Object.assign({className:"space-y-2"},{children:[n(I,{placeholder:"Describe the image...",value:t,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&c()},disabled:r}),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:'Example: "A sunset over mountains with dramatic clouds”'}))]})),n(y,Object.assign({className:"w-full gap-2",onClick:c,disabled:!t.trim()||r},{children:i(a,r?{children:[n(M,{className:"h-4 w-4 animate-spin"}),"Generating..."]}:{children:[n(W,{className:"h-4 w-4"}),"Generate image"]})}))]}))},Ce=({onUpload:e,onInsertUrl:t,onInsertFromUnsplash:a,onInsertFromAI:s,hasPreview:r})=>n("div",Object.assign({className:C("relative p-4",r&&"min-h-[300px] flex flex-col")},{children:i(O,Object.assign({defaultValue:"upload",className:"w-full"},{children:[i(k,Object.assign({className:C("grid w-full grid-cols-4",r&&"bg-background/80 backdrop-blur-sm")},{children:[i(S,Object.assign({value:"upload",className:"gap-1.5"},{children:[n(H,{className:"h-3.5 w-3.5"}),"Upload"]})),i(R,{children:[n(D,Object.assign({asChild:!0},{children:i(S,Object.assign({value:"link",disabled:!0,className:"gap-1.5"},{children:[n(_,{className:"h-3.5 w-3.5"}),"Link"]}))})),n(E,{children:"Link is not available yet"})]}),a&&i(R,{children:[n(D,Object.assign({asChild:!0},{children:i(S,Object.assign({value:"unsplash",disabled:!0,className:"gap-1.5"},{children:[n("svg",Object.assign({className:"h-3.5 w-3.5",viewBox:"0 0 32 32",fill:"currentColor"},{children:n("path",{d:"M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z"})})),"Unsplash"]}))})),n(E,{children:"Unsplash is not available yet"})]}),s&&i(R,{children:[n(D,Object.assign({asChild:!0},{children:i(S,Object.assign({value:"ai",disabled:!0,className:"gap-1.5"},{children:[n(W,{className:"h-3.5 w-3.5"}),"AI"]}))})),n(E,{children:"AI is not available yet"})]})]})),n(N,Object.assign({value:"upload",className:"mt-4"},{children:n(ke,{onUpload:e,hasPreview:r})})),n(N,Object.assign({value:"link",d:!0},{children:n(Se,{onInsertUrl:t})})),a&&n(ye,{onInsertFromUnsplash:a}),s&&n(N,Object.assign({value:"ai"},{children:n(Ie,{onInsertFromAI:s})}))]}))})),Re=({onUpload:e,onInsertUrl:t,onInsertFromUnsplash:a,onInsertFromAI:s,className:r,attributes:o,children:l,preview:c,progress:d,loading:m})=>{const h=null!==c&&!!c.url,u=m&&d;return i("div",Object.assign({className:C("mt-2 relative rounded-lg border bg-background overflow-hidden",h&&"min-h-[300px]",r)},o,{contentEditable:!1},{children:[h&&n(Ne,{preview:c}),!h&&n(Ce,{onUpload:e,onInsertUrl:t,onInsertFromUnsplash:a,onInsertFromAI:s,hasPreview:h}),u&&d&&n(Oe,{progress:d}),l]}))};var De=["PageUp","PageDown"],Ee=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ze={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Pe="Slider",[Ue,Ae,Me]=ve(Pe),[He,Fe]=oe(Pe,[Me]),[_e,Le]=He(Pe),Be=s.forwardRef((e,t)=>{const{name:i,min:a=0,max:r=100,step:o=1,orientation:l="horizontal",disabled:c=!1,minStepsBetweenThumbs:d=0,defaultValue:m=[a],value:h,onValueChange:u=()=>{},onValueCommit:g=()=>{},inverted:p=!1,form:f,...b}=e,v=s.useRef(new Set),w=s.useRef(0),x="horizontal"===l?We:Te,[j=[],y]=me({prop:h,defaultProp:m,onChange:e=>{const t=[...v.current];t[w.current]?.focus(),u(e)}}),N=s.useRef(j);function O(e,t,{commit:n}={commit:!1}){const i=function(e){return(String(e).split(".")[1]||"").length}(o),s=function(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}(Math.round((e-a)/o)*o+a,i),l=re(s,[a,r]);y((e=[])=>{const i=function(e=[],t,n){const i=[...e];return i[n]=t,i.sort((e,t)=>e-t)}(e,l,t);if(function(e,t){if(t>0){const n=function(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}(e);return Math.min(...n)>=t}return!0}(i,d*o)){w.current=i.indexOf(l);const t=String(i)!==String(e);return t&&n&&g(i),t?i:e}return e})}return n(_e,{scope:e.__scopeSlider,name:i,disabled:c,min:a,max:r,valueIndexToChangeRef:w,thumbs:v.current,values:j,orientation:l,form:f,children:n(Ue.Provider,{scope:e.__scopeSlider,children:n(Ue.Slot,{scope:e.__scopeSlider,children:n(x,{"aria-disabled":c,"data-disabled":c?"":void 0,...b,ref:t,onPointerDown:le(b.onPointerDown,()=>{c||(N.current=j)}),min:a,max:r,inverted:p,onSlideStart:c?void 0:function(e){const t=function(e,t){if(1===e.length)return 0;const n=e.map(e=>Math.abs(e-t)),i=Math.min(...n);return n.indexOf(i)}(j,e);O(e,t)},onSlideMove:c?void 0:function(e){O(e,w.current)},onSlideEnd:c?void 0:function(){const e=N.current[w.current];j[w.current]!==e&&g(j)},onHomeKeyDown:()=>!c&&O(a,0,{commit:!0}),onEndKeyDown:()=>!c&&O(r,j.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!c){const n=De.includes(e.key)||e.shiftKey&&Ee.includes(e.key)?10:1,i=w.current;O(j[i]+o*n*t,i,{commit:!0})}}})})})})});Be.displayName=Pe;var[Ke,Ve]=He(Pe,{startEdge:"left",endEdge:"right",size:"width",direction:1}),We=s.forwardRef((e,t)=>{const{min:i,max:a,dir:r,inverted:o,onSlideStart:l,onSlideMove:c,onSlideEnd:d,onStepKeyDown:m,...h}=e,[u,g]=s.useState(null),p=de(t,e=>g(e)),f=s.useRef(void 0),b=he(r),v="ltr"===b,w=v&&!o||!v&&o;function x(e){const t=f.current||u.getBoundingClientRect(),n=nt([0,t.width],w?[i,a]:[a,i]);return f.current=t,n(e-t.left)}return n(Ke,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:n($e,{dir:b,"data-orientation":"horizontal",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{const t=x(e.clientX);l?.(t)},onSlideMove:e=>{const t=x(e.clientX);c?.(t)},onSlideEnd:()=>{f.current=void 0,d?.()},onStepKeyDown:e=>{const t=ze[w?"from-left":"from-right"].includes(e.key);m?.({event:e,direction:t?-1:1})}})})}),Te=s.forwardRef((e,t)=>{const{min:i,max:a,inverted:r,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...m}=e,h=s.useRef(null),u=de(t,h),g=s.useRef(void 0),p=!r;function f(e){const t=g.current||h.current.getBoundingClientRect(),n=nt([0,t.height],p?[a,i]:[i,a]);return g.current=t,n(e-t.top)}return n(Ke,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:n($e,{"data-orientation":"vertical",...m,ref:u,style:{...m.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{const t=f(e.clientY);o?.(t)},onSlideMove:e=>{const t=f(e.clientY);l?.(t)},onSlideEnd:()=>{g.current=void 0,c?.()},onStepKeyDown:e=>{const t=ze[p?"from-bottom":"from-top"].includes(e.key);d?.({event:e,direction:t?-1:1})}})})}),$e=s.forwardRef((e,t)=>{const{__scopeSlider:i,onSlideStart:a,onSlideMove:s,onSlideEnd:r,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,m=Le(Pe,i);return n(ce.span,{...d,ref:t,onKeyDown:le(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):De.concat(Ee).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:le(e.onPointerDown,e=>{const t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),m.thumbs.has(t)?t.focus():a(e)}),onPointerMove:le(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&s(e)}),onPointerUp:le(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),r(e))})})}),Ye="SliderTrack",Ge=s.forwardRef((e,t)=>{const{__scopeSlider:i,...a}=e,s=Le(Ye,i);return n(ce.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...a,ref:t})});Ge.displayName=Ye;var Xe="SliderRange",qe=s.forwardRef((e,t)=>{const{__scopeSlider:i,...a}=e,r=Le(Xe,i),o=Ve(Xe,i),l=s.useRef(null),c=de(t,l),d=r.values.length,m=r.values.map(e=>tt(e,r.min,r.max)),h=d>1?Math.min(...m):0,u=100-Math.max(...m);return n(ce.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...a,ref:c,style:{...e.style,[o.startEdge]:h+"%",[o.endEdge]:u+"%"}})});qe.displayName=Xe;var Je="SliderThumb",Qe=s.forwardRef((e,t)=>{const i=Ae(e.__scopeSlider),[a,r]=s.useState(null),o=de(t,e=>r(e)),l=s.useMemo(()=>a?i().findIndex(e=>e.ref.current===a):-1,[i,a]);return n(Ze,{...e,ref:o,index:l})}),Ze=s.forwardRef((e,t)=>{const{__scopeSlider:a,index:r,name:o,...l}=e,c=Le(Je,a),d=Ve(Je,a),[m,h]=s.useState(null),u=de(t,e=>h(e)),g=!m||(c.form||!!m.closest("form")),p=ue(m),f=c.values[r],b=void 0===f?0:tt(f,c.min,c.max),v=function(e,t){return t>2?`Value ${e+1} of ${t}`:2===t?["Minimum","Maximum"][e]:void 0}(r,c.values.length),w=p?.[d.size],x=w?function(e,t,n){const i=e/2,a=nt([0,50],[0,i]);return(i-a(t)*n)*n}(w,b,d.direction):0;return s.useEffect(()=>{if(m)return c.thumbs.add(m),()=>{c.thumbs.delete(m)}},[m,c.thumbs]),i("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[d.startEdge]:`calc(${b}% + ${x}px)`},children:[n(Ue.ItemSlot,{scope:e.__scopeSlider,children:n(ce.span,{role:"slider","aria-label":e["aria-label"]||v,"aria-valuemin":c.min,"aria-valuenow":f,"aria-valuemax":c.max,"aria-orientation":c.orientation,"data-orientation":c.orientation,"data-disabled":c.disabled?"":void 0,tabIndex:c.disabled?void 0:0,...l,ref:u,style:void 0===f?{display:"none"}:e.style,onFocus:le(e.onFocus,()=>{c.valueIndexToChangeRef.current=r})})}),g&&n(et,{name:o??(c.name?c.name+(c.values.length>1?"[]":""):void 0),form:c.form,value:f},r)]})});Qe.displayName=Je;var et=s.forwardRef(({__scopeSlider:e,value:t,...i},a)=>{const r=s.useRef(null),o=de(r,a),l=Q(t);return s.useEffect(()=>{const e=r.current;if(!e)return;const n=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,"value").set;if(l!==t&&i){const n=new Event("input",{bubbles:!0});i.call(e,t),e.dispatchEvent(n)}},[l,t]),n(ce.input,{style:{display:"none"},...i,ref:o,defaultValue:t})});function tt(e,t,n){return re(100/(n-t)*(e-t),[0,100])}function nt(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(n-e[0])}}et.displayName="RadioBubbleInput";var it=Be,at=Ge,st=qe,rt=Qe;const ot=t=>{var{className:a,defaultValue:r,value:o,min:l=0,max:c=100}=t,d=e(t,["className","defaultValue","value","min","max"]);const m=s.useMemo(()=>Array.isArray(o)?o:Array.isArray(r)?r:[l,c],[o,r,l,c]);return i(it,Object.assign({"data-slot":"slider",defaultValue:r,value:o,min:l,max:c,className:C("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",a)},d,{children:[n(at,Object.assign({"data-slot":"slider-track",className:C("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5")},{children:n(st,{"data-slot":"slider-range",className:C("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})})),Array.from({length:m.length},(e,t)=>n(rt,{"data-slot":"slider-thumb",className:"border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},t))]}))},lt={contain:{label:"Contain",description:"Fit within bounds"},cover:{label:"Cover",description:"Fill and crop"},fill:{label:"Fill",description:"Stretch to fit"}},ct=({fit:e,alt:t,borderRadius:a,onUpdate:s})=>{var r,l,c,d,m,h,u,g;const[p,f]=o(t),[b,v]=o(!1);return i(X,Object.assign({open:b,onOpenChange:v},{children:[n(z,{children:i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(q,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:b?"secondary":"ghost",size:"icon",className:"h-7 w-7"},{children:n(we,{className:"h-4 w-4"})}))}))})),n(E,{children:"Settings"})]})}),n(J,Object.assign({className:"w-80 p-3",align:"start",contentEditable:!1,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()},{children:i("div",Object.assign({className:"space-y-3"},{children:[i("div",{children:[n("h4",Object.assign({className:"font-semibold"},{children:"Image settings"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Customize how the image appears"}))]}),n(se,{}),i("div",Object.assign({className:"space-y-1"},{children:[n(G,Object.assign({htmlFor:"alt-text",className:"text-sm font-medium"},{children:"Alt text"})),n(I,{id:"alt-text",value:p,onChange:e=>f(e.target.value),onBlur:()=>s({alt:p}),placeholder:"Describe this image...",className:"h-9"}),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Important for accessibility and SEO"}))]})),i("div",Object.assign({className:"space-y-1 z-50"},{children:[n(G,Object.assign({htmlFor:"object-fit",className:"text-sm font-medium"},{children:"How image fits"})),i(Z,Object.assign({value:e,onValueChange:e=>s({fit:e})},{children:[n(ee,Object.assign({id:"object-fit",className:"h-9 w-full"},{children:n(te,Object.assign({placeholder:"Select how image fits"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(r=lt[e])||void 0===r?void 0:r.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(l=lt[e])||void 0===l?void 0:l.description}))]}))}))})),n(ne,{children:i(ie,{children:[n(ae,Object.assign({value:"contain",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:n("div",{className:"h-4 w-3 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(c=lt.contain)||void 0===c?void 0:c.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(d=lt.contain)||void 0===d?void 0:d.description}))]}))]}))})),n(ae,Object.assign({value:"cover",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:n("div",{className:"h-8 w-6 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(m=lt.cover)||void 0===m?void 0:m.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(h=lt.cover)||void 0===h?void 0:h.description}))]}))]}))})),n(ae,Object.assign({value:"fill",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:n("div",{className:"h-8 w-8 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(u=lt.fill)||void 0===u?void 0:u.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(g=lt.fill)||void 0===g?void 0:g.description}))]}))]}))}))]})})]}))]})),i("div",Object.assign({className:"space-y-1"},{children:[i("div",Object.assign({className:"flex items-center justify-between"},{children:[n(G,Object.assign({className:"text-sm font-medium"},{children:"Border radius"})),i("span",Object.assign({className:"text-sm text-muted-foreground"},{children:[a,"px"]}))]})),n(ot,{value:[a],onValueChange:([e])=>s({borderRadius:e}),max:50,step:1,className:"w-full"})]}))]}))}))]}))},dt=({referenceRef:e,elementProps:t,onUpdate:a,onReplace:s,onDelete:r,onDownload:c,onCopy:d})=>{var m,h,u;const[g,p]=o(!1),[f,b]=o(!1),{refs:v,floatingStyles:w}=P({placement:"top-end",strategy:"absolute",middleware:[ge(8),pe({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),fe({padding:10})],whileElementsMounted:be});return l(()=>{const t=e.current;t&&(v.setReference(t),b(!0))},[e,v]),l(()=>{if(f){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[f]),f?n(U,{children:n("div",Object.assign({ref:v.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:C("pointer-events-auto z-50","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",g?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:w},{children:i(z,Object.assign({delayDuration:0},{children:[i("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"left"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"left"})},{children:n(L,{className:"h-4 w-4"})}))})),n(E,{children:"Align left"})]}),i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"center"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"center"})},{children:n(B,{className:"h-4 w-4"})}))})),n(E,{children:"Align center"})]}),i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"right"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"right"})},{children:n(K,{className:"h-4 w-4"})}))})),n(E,{children:"Align right"})]})]})),i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:s},{children:n(A,{className:"h-4 w-4"})}))})),n(E,{children:"Replace"})]}),i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c},{children:n(F,{className:"h-4 w-4"})}))})),n(E,{children:"Download"})]}),i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d},{children:n($,{className:"h-4 w-4"})}))})),n(E,{children:"Copy"})]}),n(se,{orientation:"vertical",className:"h-4"}),n(ct,{fit:null!==(m=t.fit)&&void 0!==m?m:"contain",alt:null!==(h=t.alt)&&void 0!==h?h:"",borderRadius:null!==(u=t.borderRadius)&&void 0!==u?u:0,onUpdate:a}),i(R,{children:[n(D,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:r},{children:n(xe,{className:"h-4 w-4"})}))})),n(E,{children:"Delete"})]})]}))}))}):null},mt=({blockId:e,attributes:a,children:s,elementProps:l,onUpdate:d,onDelete:g,onReplace:p,pluginOptions:f})=>{var b;const[v,w]=o(l.sizes),{isElementSelected:x}=m(),j=h({blockId:e}),y=x&&j,N=r(null),O=u(),[k,S]=o(()=>{var e,t;const n=null!==(t=null===(e=O.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)&&void 0!==t?t:650,i=null==f?void 0:f.maxSizes;return{maxWidth:(null==i?void 0:i.maxWidth)?"number"==typeof i.maxWidth?i.maxWidth:parseInt(String(i.maxWidth).replace(/[^\d]/g,""),10):n,maxHeight:(null==i?void 0:i.maxHeight)?"number"==typeof i.maxHeight?i.maxHeight:parseInt(String(i.maxHeight).replace(/[^\d]/g,""),10):550}});c(()=>{const e=()=>{var e,t;const n=null!==(t=null===(e=O.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)&&void 0!==t?t:650,i=null==f?void 0:f.maxSizes;S({maxWidth:(null==i?void 0:i.maxWidth)?"number"==typeof i.maxWidth?i.maxWidth:parseInt(String(i.maxWidth).replace(/[^\d]/g,""),10):n,maxHeight:(null==i?void 0:i.maxHeight)?"number"==typeof i.maxHeight?i.maxHeight:parseInt(String(i.maxHeight).replace(/[^\d]/g,""),10):550})};e();const t=new ResizeObserver(e);return O.refElement&&t.observe(O.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[O,f]);const I=(e,t)=>{const n=e=>"number"==typeof e?e:parseInt(String(e).replace(/[^\d]/g,""),10),i=n(e.width),a=n(e.height),s=n(t.width),r=n(t.height);if(i<=s&&a<=r)return{width:i,height:a};const o=i/s,l=a/r,c=Math.max(o,l),d=Math.round(i/c),m=Math.round(a/c);return{width:Math.min(d,s),height:Math.min(m,r)}},R={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(b=l.alignment)&&void 0!==b?b:"center"];return i("div",Object.assign({},a,{className:C("group/image mt-2 relative transition-all w-full flex",R)},{children:[i("div",Object.assign({className:"relative",contentEditable:!1,ref:N},{children:[n(V,Object.assign({style:{position:"relative",outline:y?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:y?"hsl(var(--primary))":"none"},size:{width:v.width,height:v.height},onResize:(e,t,n)=>{const i=parseInt(n.style.width,10),a=parseInt(n.style.height,10),s=I({width:i,height:a},{width:k.maxWidth,height:k.maxHeight});w(s)},onResizeStop:(e,t,n)=>{const i=parseInt(n.style.width,10),a=parseInt(n.style.height,10),s=I({width:i,height:a},{width:k.maxWidth,height:k.maxHeight});d({sizes:s})},lockAspectRatio:!0,minWidth:100,minHeight:100,maxWidth:k.maxWidth,maxHeight:k.maxHeight,position:{x:0,y:0},enableResizing:!!y&&{bottom:!1,bottomLeft:!1,bottomRight:!1,left:!0,right:!0,top:!1,topLeft:!1,topRight:!1},disableDragging:!0,resizeHandleStyles:{left:{width:"auto",height:"40px",left:"-5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"},right:{width:"auto",height:"40px",right:"-5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"}},resizeHandleComponent:{left:n("div",{className:"h-10 w-2 rounded-full bg-primary shadow-md ring-2 ring-white/80"}),right:n("div",{className:"h-10 w-2 rounded-full bg-primary shadow-md ring-2 ring-white/80"})},className:C("rounded-sm")},{children:n("img",{src:l.src,alt:l.alt||"",className:"w-full h-full transition-all duration-200",style:{objectFit:l.fit,borderRadius:`${l.borderRadius}px`},draggable:!1})})),y&&n(dt,{referenceRef:N,elementProps:l,onUpdate:d,onReplace:p,onDelete:g,onDownload:()=>t(void 0,void 0,void 0,function*(){try{const e=yield fetch(l.src),t=yield e.blob(),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=`image-${Date.now()}.jpg`,i.click(),URL.revokeObjectURL(n)}catch(e){}}),onCopy:()=>t(void 0,void 0,void 0,function*(){try{const e=yield fetch(l.src),t=yield e.blob();navigator.clipboard&&ClipboardItem?yield navigator.clipboard.write([new ClipboardItem({[t.type]:t})]):Y(l.src)}catch(e){Y(l.src)}})})]})),s]}))},ht={image:{render:({element:e,attributes:i,children:a,blockId:s})=>{const r=u(),o=g("Image"),{upload:l,progress:c,loading:m}=b(o.upload),{deleteImage:h}=v(o.delete),{preview:y,generatePreview:N,clearPreview:O}=w(),k=d(t=>{p.updateElement(r,{blockId:s,type:"image",props:Object.assign(Object.assign({},e.props),t)})},[r,s,e.props]),S=d(()=>t(void 0,void 0,void 0,function*(){yield h(e);const t=f.getBlockSlate(r,{id:s});if(!t)return;const n=p.getElementPath(r,{blockId:s,element:e});if(!n)return;const i=n?x.parent(t,n):void 0;i&&j.isElement(i[0])&&!x.isEditor(i[0])?p.deleteElement(r,{blockId:s,type:"image",path:n}):f.deleteBlock(r,{blockId:s,focus:!0})}),[r,s,e,h]),I=d(()=>{p.updateElement(r,{blockId:s,type:"image",props:Object.assign(Object.assign({},e.props),{src:null,alt:null})})},[r,s,e.props]),C=d(e=>t(void 0,void 0,void 0,function*(){var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return;N(n);const i=yield l(n);k({id:i.id||i.fileId,src:i.url,alt:n.name,sizes:{width:i.width,height:i.height}}),O(),r.focusBlock(s,{waitExecution:!1})}),[l,k,N,O,r,s]);return e.props.src?n(mt,Object.assign({blockId:s,elementId:e.id,onUpdate:k,onDelete:S,attributes:i,onReplace:I,elementProps:e.props,pluginOptions:o},{children:a})):n(Re,Object.assign({onUpload:C,preview:y,progress:c,loading:m,onInsertUrl:()=>{},onInsertFromUnsplash:()=>{},onInsertFromAI:()=>t(void 0,void 0,void 0,function*(){}),attributes:i},{children:a}))}}};export{ht as ImageUI};
7
+ */const je=T("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),ye=({onInsertFromUnsplash:e})=>n(N,Object.assign({value:"unsplash",className:"mt-4"},{children:i("div",Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n("svg",Object.assign({className:"h-6 w-6",viewBox:"0 0 32 32",fill:"currentColor"},{children:n("path",{d:"M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z"})}))})),i("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Browse free photos"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Powered by Unsplash"}))]})),n(y,Object.assign({onClick:e},{children:"Browse photos"}))]}))})),Ne=({preview:e})=>n("div",Object.assign({className:"absolute inset-0 overflow-hidden",style:{width:e.width,height:e.height}},{children:n("img",{src:e.url,alt:"Preview",className:"h-full w-full object-cover object-center",style:{width:e.width,height:e.height},draggable:!1})})),Oe=({progress:e})=>n("div",Object.assign({className:"absolute inset-0 z-20 flex flex-col items-center justify-center gap-4 bg-black/70 backdrop-blur-sm p-6"},{children:n("div",Object.assign({className:"w-full max-w-md space-y-4"},{children:i("div",Object.assign({className:"space-y-2"},{children:[i("div",Object.assign({className:"flex items-center justify-between text-sm"},{children:[n("span",Object.assign({className:"font-medium text-white"},{children:"Uploading..."})),i("span",Object.assign({className:"text-white/80"},{children:[e.percentage,"%"]}))]})),n("div",Object.assign({className:"h-2 w-full overflow-hidden rounded-full bg-white/20"},{children:n("div",{className:"h-full bg-primary transition-all duration-300 ease-out",style:{width:`${e.percentage}%`}})})),i("div",Object.assign({className:"flex items-center justify-between text-xs text-white/60"},{children:[i("span",{children:[(e.loaded/1024/1024).toFixed(2)," MB /"," ",(e.total/1024/1024).toFixed(2)," MB"]}),n(_,{className:"h-3.5 w-3.5 animate-spin"})]}))]}))}))})),ke=({onUpload:e,hasPreview:t})=>{const a=r(null);return i("div",t?Object.assign({className:"flex flex-col items-center justify-center gap-4 py-8"},{children:[i("div",Object.assign({className:"text-center space-y-2"},{children:[n("p",Object.assign({className:"text-sm font-medium text-white"},{children:"Image preview"})),n("p",Object.assign({className:"text-xs text-white/80"},{children:"Uploading your image..."}))]})),n("input",{ref:a,type:"file",accept:"image/*",onChange:e,className:"hidden"})]}):Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n(je,{className:"h-6 w-6 text-muted-foreground"})})),i("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Upload an image"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Click or drag and drop"}))]})),n(y,Object.assign({onClick:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.click()}},{children:"Choose file"})),n("input",{ref:a,type:"file",accept:"image/*",onChange:e,className:"hidden"})]}))},Se=({onInsertUrl:e})=>{const[t,a]=o(""),s=()=>{t.trim()&&(e(t.trim()),a(""))};return i("div",Object.assign({className:"mt-4 space-y-3"},{children:[n(I,{placeholder:"Paste image URL...",value:t,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&t.trim()&&s()}}),n(y,Object.assign({className:"w-full",onClick:s,disabled:!t.trim()},{children:"Embed image"}))]}))},Ie=({onInsertFromAI:e})=>{const[t,s]=o(""),[r,l]=o(!1),c=()=>{t.trim()&&!r&&(l(!0),e(t.trim()),l(!1),s(""))};return i("div",Object.assign({className:"mt-4 space-y-3"},{children:[i("div",Object.assign({className:"space-y-2"},{children:[n(I,{placeholder:"Describe the image...",value:t,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&c()},disabled:r}),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:'Example: "A sunset over mountains with dramatic clouds”'}))]})),n(y,Object.assign({className:"w-full gap-2",onClick:c,disabled:!t.trim()||r},{children:i(a,r?{children:[n(_,{className:"h-4 w-4 animate-spin"}),"Generating..."]}:{children:[n(W,{className:"h-4 w-4"}),"Generate image"]})}))]}))},Ce=({onUpload:e,onInsertUrl:t,onInsertFromUnsplash:a,onInsertFromAI:s,hasPreview:r})=>n("div",Object.assign({className:A("relative p-4",r&&"min-h-[300px] flex flex-col")},{children:i(O,Object.assign({defaultValue:"upload",className:"w-full"},{children:[i(k,Object.assign({className:A("grid w-full grid-cols-4",r&&"bg-background/80 backdrop-blur-sm")},{children:[i(S,Object.assign({value:"upload",className:"gap-1.5"},{children:[n(H,{className:"h-3.5 w-3.5"}),"Upload"]})),i(C,{children:[n(R,Object.assign({asChild:!0},{children:i(S,Object.assign({value:"link",disabled:!0,className:"gap-1.5"},{children:[n(F,{className:"h-3.5 w-3.5"}),"Link"]}))})),n(D,{children:"Link is not available yet"})]}),a&&i(C,{children:[n(R,Object.assign({asChild:!0},{children:i(S,Object.assign({value:"unsplash",disabled:!0,className:"gap-1.5"},{children:[n("svg",Object.assign({className:"h-3.5 w-3.5",viewBox:"0 0 32 32",fill:"currentColor"},{children:n("path",{d:"M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z"})})),"Unsplash"]}))})),n(D,{children:"Unsplash is not available yet"})]}),s&&i(C,{children:[n(R,Object.assign({asChild:!0},{children:i(S,Object.assign({value:"ai",disabled:!0,className:"gap-1.5"},{children:[n(W,{className:"h-3.5 w-3.5"}),"AI"]}))})),n(D,{children:"AI is not available yet"})]})]})),n(N,Object.assign({value:"upload",className:"mt-4"},{children:n(ke,{onUpload:e,hasPreview:r})})),n(N,Object.assign({value:"link"},{children:n(Se,{onInsertUrl:t})})),a&&n(ye,{onInsertFromUnsplash:a}),s&&n(N,Object.assign({value:"ai"},{children:n(Ie,{onInsertFromAI:s})}))]}))})),Re=({onUpload:e,onInsertUrl:t,onInsertFromUnsplash:a,onInsertFromAI:s,className:r,attributes:o,children:l,preview:c,progress:d,loading:m})=>{const h=null!==c&&!!c.url,u=m&&d;return i("div",Object.assign({className:A("mt-2 relative rounded-lg border bg-background overflow-hidden",h&&"min-h-[300px]",r)},o,{contentEditable:!1},{children:[h&&n(Ne,{preview:c}),!h&&n(Ce,{onUpload:e,onInsertUrl:t,onInsertFromUnsplash:a,onInsertFromAI:s,hasPreview:h}),u&&d&&n(Oe,{progress:d}),l]}))};var De=["PageUp","PageDown"],Ee=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ze={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Pe="Slider",[Ue,Ae,_e]=ve(Pe),[He,Me]=oe(Pe,[_e]),[Fe,Le]=He(Pe),Be=s.forwardRef((e,t)=>{const{name:i,min:a=0,max:r=100,step:o=1,orientation:l="horizontal",disabled:c=!1,minStepsBetweenThumbs:d=0,defaultValue:m=[a],value:h,onValueChange:u=()=>{},onValueCommit:g=()=>{},inverted:p=!1,form:f,...b}=e,v=s.useRef(new Set),w=s.useRef(0),x="horizontal"===l?We:Te,[j=[],y]=me({prop:h,defaultProp:m,onChange:e=>{const t=[...v.current];t[w.current]?.focus(),u(e)}}),N=s.useRef(j);function O(e,t,{commit:n}={commit:!1}){const i=function(e){return(String(e).split(".")[1]||"").length}(o),s=function(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}(Math.round((e-a)/o)*o+a,i),l=re(s,[a,r]);y((e=[])=>{const i=function(e=[],t,n){const i=[...e];return i[n]=t,i.sort((e,t)=>e-t)}(e,l,t);if(function(e,t){if(t>0){const n=function(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}(e);return Math.min(...n)>=t}return!0}(i,d*o)){w.current=i.indexOf(l);const t=String(i)!==String(e);return t&&n&&g(i),t?i:e}return e})}return n(Fe,{scope:e.__scopeSlider,name:i,disabled:c,min:a,max:r,valueIndexToChangeRef:w,thumbs:v.current,values:j,orientation:l,form:f,children:n(Ue.Provider,{scope:e.__scopeSlider,children:n(Ue.Slot,{scope:e.__scopeSlider,children:n(x,{"aria-disabled":c,"data-disabled":c?"":void 0,...b,ref:t,onPointerDown:le(b.onPointerDown,()=>{c||(N.current=j)}),min:a,max:r,inverted:p,onSlideStart:c?void 0:function(e){const t=function(e,t){if(1===e.length)return 0;const n=e.map(e=>Math.abs(e-t)),i=Math.min(...n);return n.indexOf(i)}(j,e);O(e,t)},onSlideMove:c?void 0:function(e){O(e,w.current)},onSlideEnd:c?void 0:function(){const e=N.current[w.current];j[w.current]!==e&&g(j)},onHomeKeyDown:()=>!c&&O(a,0,{commit:!0}),onEndKeyDown:()=>!c&&O(r,j.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:t})=>{if(!c){const n=De.includes(e.key)||e.shiftKey&&Ee.includes(e.key)?10:1,i=w.current;O(j[i]+o*n*t,i,{commit:!0})}}})})})})});Be.displayName=Pe;var[Ke,Ve]=He(Pe,{startEdge:"left",endEdge:"right",size:"width",direction:1}),We=s.forwardRef((e,t)=>{const{min:i,max:a,dir:r,inverted:o,onSlideStart:l,onSlideMove:c,onSlideEnd:d,onStepKeyDown:m,...h}=e,[u,g]=s.useState(null),p=de(t,e=>g(e)),f=s.useRef(void 0),b=he(r),v="ltr"===b,w=v&&!o||!v&&o;function x(e){const t=f.current||u.getBoundingClientRect(),n=nt([0,t.width],w?[i,a]:[a,i]);return f.current=t,n(e-t.left)}return n(Ke,{scope:e.__scopeSlider,startEdge:w?"left":"right",endEdge:w?"right":"left",direction:w?1:-1,size:"width",children:n($e,{dir:b,"data-orientation":"horizontal",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{const t=x(e.clientX);l?.(t)},onSlideMove:e=>{const t=x(e.clientX);c?.(t)},onSlideEnd:()=>{f.current=void 0,d?.()},onStepKeyDown:e=>{const t=ze[w?"from-left":"from-right"].includes(e.key);m?.({event:e,direction:t?-1:1})}})})}),Te=s.forwardRef((e,t)=>{const{min:i,max:a,inverted:r,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...m}=e,h=s.useRef(null),u=de(t,h),g=s.useRef(void 0),p=!r;function f(e){const t=g.current||h.current.getBoundingClientRect(),n=nt([0,t.height],p?[a,i]:[i,a]);return g.current=t,n(e-t.top)}return n(Ke,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:n($e,{"data-orientation":"vertical",...m,ref:u,style:{...m.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{const t=f(e.clientY);o?.(t)},onSlideMove:e=>{const t=f(e.clientY);l?.(t)},onSlideEnd:()=>{g.current=void 0,c?.()},onStepKeyDown:e=>{const t=ze[p?"from-bottom":"from-top"].includes(e.key);d?.({event:e,direction:t?-1:1})}})})}),$e=s.forwardRef((e,t)=>{const{__scopeSlider:i,onSlideStart:a,onSlideMove:s,onSlideEnd:r,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,m=Le(Pe,i);return n(ce.span,{...d,ref:t,onKeyDown:le(e.onKeyDown,e=>{"Home"===e.key?(o(e),e.preventDefault()):"End"===e.key?(l(e),e.preventDefault()):De.concat(Ee).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:le(e.onPointerDown,e=>{const t=e.target;t.setPointerCapture(e.pointerId),e.preventDefault(),m.thumbs.has(t)?t.focus():a(e)}),onPointerMove:le(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&s(e)}),onPointerUp:le(e.onPointerUp,e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&(t.releasePointerCapture(e.pointerId),r(e))})})}),Ye="SliderTrack",Ge=s.forwardRef((e,t)=>{const{__scopeSlider:i,...a}=e,s=Le(Ye,i);return n(ce.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...a,ref:t})});Ge.displayName=Ye;var Xe="SliderRange",qe=s.forwardRef((e,t)=>{const{__scopeSlider:i,...a}=e,r=Le(Xe,i),o=Ve(Xe,i),l=s.useRef(null),c=de(t,l),d=r.values.length,m=r.values.map(e=>tt(e,r.min,r.max)),h=d>1?Math.min(...m):0,u=100-Math.max(...m);return n(ce.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...a,ref:c,style:{...e.style,[o.startEdge]:h+"%",[o.endEdge]:u+"%"}})});qe.displayName=Xe;var Je="SliderThumb",Qe=s.forwardRef((e,t)=>{const i=Ae(e.__scopeSlider),[a,r]=s.useState(null),o=de(t,e=>r(e)),l=s.useMemo(()=>a?i().findIndex(e=>e.ref.current===a):-1,[i,a]);return n(Ze,{...e,ref:o,index:l})}),Ze=s.forwardRef((e,t)=>{const{__scopeSlider:a,index:r,name:o,...l}=e,c=Le(Je,a),d=Ve(Je,a),[m,h]=s.useState(null),u=de(t,e=>h(e)),g=!m||(c.form||!!m.closest("form")),p=ue(m),f=c.values[r],b=void 0===f?0:tt(f,c.min,c.max),v=function(e,t){return t>2?`Value ${e+1} of ${t}`:2===t?["Minimum","Maximum"][e]:void 0}(r,c.values.length),w=p?.[d.size],x=w?function(e,t,n){const i=e/2,a=nt([0,50],[0,i]);return(i-a(t)*n)*n}(w,b,d.direction):0;return s.useEffect(()=>{if(m)return c.thumbs.add(m),()=>{c.thumbs.delete(m)}},[m,c.thumbs]),i("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[d.startEdge]:`calc(${b}% + ${x}px)`},children:[n(Ue.ItemSlot,{scope:e.__scopeSlider,children:n(ce.span,{role:"slider","aria-label":e["aria-label"]||v,"aria-valuemin":c.min,"aria-valuenow":f,"aria-valuemax":c.max,"aria-orientation":c.orientation,"data-orientation":c.orientation,"data-disabled":c.disabled?"":void 0,tabIndex:c.disabled?void 0:0,...l,ref:u,style:void 0===f?{display:"none"}:e.style,onFocus:le(e.onFocus,()=>{c.valueIndexToChangeRef.current=r})})}),g&&n(et,{name:o??(c.name?c.name+(c.values.length>1?"[]":""):void 0),form:c.form,value:f},r)]})});Qe.displayName=Je;var et=s.forwardRef(({__scopeSlider:e,value:t,...i},a)=>{const r=s.useRef(null),o=de(r,a),l=Q(t);return s.useEffect(()=>{const e=r.current;if(!e)return;const n=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,"value").set;if(l!==t&&i){const n=new Event("input",{bubbles:!0});i.call(e,t),e.dispatchEvent(n)}},[l,t]),n(ce.input,{style:{display:"none"},...i,ref:o,defaultValue:t})});function tt(e,t,n){return re(100/(n-t)*(e-t),[0,100])}function nt(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(n-e[0])}}et.displayName="RadioBubbleInput";var it=Be,at=Ge,st=qe,rt=Qe;const ot=t=>{var{className:a,defaultValue:r,value:o,min:l=0,max:c=100}=t,d=e(t,["className","defaultValue","value","min","max"]);const m=s.useMemo(()=>Array.isArray(o)?o:Array.isArray(r)?r:[l,c],[o,r,l,c]);return i(it,Object.assign({"data-slot":"slider",defaultValue:r,value:o,min:l,max:c,className:A("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",a)},d,{children:[n(at,Object.assign({"data-slot":"slider-track",className:A("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5")},{children:n(st,{"data-slot":"slider-range",className:A("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})})),Array.from({length:m.length},(e,t)=>n(rt,{"data-slot":"slider-thumb",className:"border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},t))]}))},lt={contain:{label:"Contain",description:"Fit within bounds"},cover:{label:"Cover",description:"Fill and crop"},fill:{label:"Fill",description:"Stretch to fit"}},ct=({fit:e,alt:t,borderRadius:a,onUpdate:s})=>{var r,l,c,d,m,h,u,g;const[p,f]=o(t),[b,v]=o(!1);return i(X,Object.assign({open:b,onOpenChange:v},{children:[n(E,{children:i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(q,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:b?"secondary":"ghost",size:"icon",className:"h-7 w-7"},{children:n(we,{className:"h-4 w-4"})}))}))})),n(D,{children:"Settings"})]})}),n(J,Object.assign({className:"w-80 p-3",align:"start",contentEditable:!1,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()},{children:i("div",Object.assign({className:"space-y-3"},{children:[i("div",{children:[n("h4",Object.assign({className:"font-semibold"},{children:"Image settings"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Customize how the image appears"}))]}),n(se,{}),i("div",Object.assign({className:"space-y-1"},{children:[n(G,Object.assign({htmlFor:"alt-text",className:"text-sm font-medium"},{children:"Alt text"})),n(I,{id:"alt-text",value:p,onChange:e=>f(e.target.value),onBlur:()=>s({alt:p}),placeholder:"Describe this image...",className:"h-9"}),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Important for accessibility and SEO"}))]})),i("div",Object.assign({className:"space-y-1 z-50"},{children:[n(G,Object.assign({htmlFor:"object-fit",className:"text-sm font-medium"},{children:"How image fits"})),i(Z,Object.assign({value:e,onValueChange:e=>s({fit:e})},{children:[n(ee,Object.assign({id:"object-fit",className:"h-9 w-full"},{children:n(te,Object.assign({placeholder:"Select how image fits"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(r=lt[e])||void 0===r?void 0:r.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(l=lt[e])||void 0===l?void 0:l.description}))]}))}))})),n(ne,{children:i(ie,{children:[n(ae,Object.assign({value:"contain",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:n("div",{className:"h-4 w-3 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(c=lt.contain)||void 0===c?void 0:c.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(d=lt.contain)||void 0===d?void 0:d.description}))]}))]}))})),n(ae,Object.assign({value:"cover",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:n("div",{className:"h-8 w-6 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(m=lt.cover)||void 0===m?void 0:m.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(h=lt.cover)||void 0===h?void 0:h.description}))]}))]}))})),n(ae,Object.assign({value:"fill",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[n("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:n("div",{className:"h-8 w-8 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[n("div",Object.assign({className:"font-medium"},{children:null===(u=lt.fill)||void 0===u?void 0:u.label})),n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(g=lt.fill)||void 0===g?void 0:g.description}))]}))]}))}))]})})]}))]})),i("div",Object.assign({className:"space-y-1"},{children:[i("div",Object.assign({className:"flex items-center justify-between"},{children:[n(G,Object.assign({className:"text-sm font-medium"},{children:"Border radius"})),i("span",Object.assign({className:"text-sm text-muted-foreground"},{children:[a,"px"]}))]})),n(ot,{value:[a],onValueChange:([e])=>s({borderRadius:e}),max:50,step:1,className:"w-full"})]}))]}))}))]}))},dt=({referenceRef:e,elementProps:t,onUpdate:a,onReplace:s,onDelete:r,onDownload:c,onCopy:d})=>{var m,h,u;const[g,p]=o(!1),[f,b]=o(!1),{refs:v,floatingStyles:w}=z({placement:"top-end",strategy:"absolute",middleware:[ge(8),pe({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),fe({padding:10})],whileElementsMounted:be});return l(()=>{const t=e.current;t&&(v.setReference(t),b(!0))},[e,v]),l(()=>{if(f){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[f]),f?n(P,{children:n("div",Object.assign({ref:v.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:A("pointer-events-auto z-50","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",g?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:w},{children:i(E,Object.assign({delayDuration:0},{children:[i("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"left"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"left"})},{children:n(L,{className:"h-4 w-4"})}))})),n(D,{children:"Align left"})]}),i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"center"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"center"})},{children:n(B,{className:"h-4 w-4"})}))})),n(D,{children:"Align center"})]}),i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"right"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"right"})},{children:n(K,{className:"h-4 w-4"})}))})),n(D,{children:"Align right"})]})]})),i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:s},{children:n(U,{className:"h-4 w-4"})}))})),n(D,{children:"Replace"})]}),i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:c},{children:n(M,{className:"h-4 w-4"})}))})),n(D,{children:"Download"})]}),i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d},{children:n($,{className:"h-4 w-4"})}))})),n(D,{children:"Copy"})]}),n(se,{orientation:"vertical",className:"h-4"}),n(ct,{fit:null!==(m=t.fit)&&void 0!==m?m:"contain",alt:null!==(h=t.alt)&&void 0!==h?h:"",borderRadius:null!==(u=t.borderRadius)&&void 0!==u?u:0,onUpdate:a}),i(C,{children:[n(R,Object.assign({asChild:!0},{children:n(y,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:r},{children:n(xe,{className:"h-4 w-4"})}))})),n(D,{children:"Delete"})]})]}))}))}):null},mt=({blockId:e,attributes:a,children:s,elementProps:l,onUpdate:d,onDelete:g,onReplace:p,pluginOptions:f})=>{var b;const[v,w]=o(l.sizes),{isElementSelected:x}=m(),j=h({blockId:e}),y=x&&j,N=r(null),O=u(),[k,S]=o(()=>{var e;const t=(null===(e=O.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,n=null==f?void 0:f.maxSizes;return{maxWidth:(null==n?void 0:n.maxWidth)?"number"==typeof n.maxWidth?n.maxWidth:parseInt(String(n.maxWidth).replace(/[^\d]/g,""),10):t,maxHeight:(null==n?void 0:n.maxHeight)?"number"==typeof n.maxHeight?n.maxHeight:parseInt(String(n.maxHeight).replace(/[^\d]/g,""),10):0}});c(()=>{const e=()=>{var e;const t=(null===(e=O.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,n=null==f?void 0:f.maxSizes;S({maxWidth:(null==n?void 0:n.maxWidth)?"number"==typeof n.maxWidth?n.maxWidth:parseInt(String(n.maxWidth).replace(/[^\d]/g,""),10):t,maxHeight:(null==n?void 0:n.maxHeight)?"number"==typeof n.maxHeight?n.maxHeight:parseInt(String(n.maxHeight).replace(/[^\d]/g,""),10):0})};e();const t=new ResizeObserver(e);return O.refElement&&t.observe(O.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[O,f]);const I={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(b=l.alignment)&&void 0!==b?b:"center"];return i("div",Object.assign({},a,{className:A("group/image mt-4 relative transition-all w-full flex",I)},{children:[i("div",Object.assign({className:"relative",contentEditable:!1,ref:N},{children:[n(V,Object.assign({style:{position:"relative",outline:y?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:y?"hsl(var(--primary))":"none",padding:2},onResize:(e,t,n)=>{const i=parseInt(n.style.width,10),a=parseInt(n.style.height,10);w({width:i,height:a})},onResizeStop:(e,t,n)=>{const i=parseInt(n.style.width,10),a=parseInt(n.style.height,10);d({sizes:{width:i,height:a}})},lockAspectRatio:!0,minWidth:100,minHeight:100,maxWidth:k.maxWidth-8||void 0,maxHeight:k.maxHeight||void 0,position:{x:0,y:0},enableResizing:!!y&&{bottom:!1,bottomLeft:!1,bottomRight:!1,left:!0,right:!0,top:!1,topLeft:!1,topRight:!1},disableDragging:!0,resizeHandleStyles:{left:{width:"auto",height:"40px",left:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"},right:{width:"auto",height:"40px",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"}},resizeHandleComponent:{left:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"}),right:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"})},className:A("rounded-sm")},{children:n("img",{src:l.src,alt:l.alt||"",className:"w-full h-full transition-all duration-200",style:{objectFit:l.fit,borderRadius:`${l.borderRadius}px`},draggable:!1})})),y&&n(dt,{referenceRef:N,elementProps:l,onUpdate:d,onReplace:p,onDelete:g,onDownload:()=>t(void 0,void 0,void 0,function*(){try{const e=yield fetch(l.src),t=yield e.blob(),n=URL.createObjectURL(t),i=document.createElement("a");i.href=n,i.download=`image-${Date.now()}.jpg`,i.click(),URL.revokeObjectURL(n)}catch(e){}}),onCopy:()=>t(void 0,void 0,void 0,function*(){try{const e=yield fetch(l.src),t=yield e.blob();navigator.clipboard&&ClipboardItem?yield navigator.clipboard.write([new ClipboardItem({[t.type]:t})]):Y(l.src)}catch(e){Y(l.src)}})})]})),s]}))},ht={image:{render:({element:e,attributes:i,children:a,blockId:s})=>{const r=u(),o=g("Image"),{upload:l,progress:c,loading:m}=b(o.upload),{deleteImage:h}=v(o.delete),{preview:y,generatePreview:N,clearPreview:O}=w(),k=d(t=>{p.updateElement(r,{blockId:s,type:"image",props:Object.assign(Object.assign({},e.props),t)})},[r,s,e.props]),S=d(()=>t(void 0,void 0,void 0,function*(){yield h(e);const t=f.getBlockSlate(r,{id:s});if(!t)return;const n=p.getElementPath(r,{blockId:s,element:e});if(!n)return;const i=n?x.parent(t,n):void 0;i&&j.isElement(i[0])&&!x.isEditor(i[0])?p.deleteElement(r,{blockId:s,type:"image",path:n}):f.deleteBlock(r,{blockId:s,focus:!0})}),[r,s,e,h]),I=d(()=>{p.updateElement(r,{blockId:s,type:"image",props:Object.assign(Object.assign({},e.props),{src:null,alt:null})})},[r,s,e.props]),C=d(e=>t(void 0,void 0,void 0,function*(){var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(!n)return;N(n);const i=yield l(n);k({id:i.id||i.fileId,src:i.url,alt:n.name,sizes:{width:i.width,height:i.height}}),O(),r.focusBlock(s,{waitExecution:!1})}),[l,k,N,O,r,s]);return e.props.src?n(mt,Object.assign({blockId:s,elementId:e.id,onUpdate:k,onDelete:S,attributes:i,onReplace:I,elementProps:e.props,pluginOptions:o},{children:a})):r.readOnly?null:n(Re,Object.assign({onUpload:C,preview:y,progress:c,loading:m,onInsertUrl:()=>{},onInsertFromUnsplash:()=>{},onInsertFromAI:()=>t(void 0,void 0,void 0,function*(){}),attributes:i},{children:a}))}}};export{ht as ImageUI};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import './variables.css';
2
1
  import './styles.css';
3
2
  import { applyTheme } from './applyTheme';
4
3
  export { AccordionUI } from './accordion';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAC;AACzB,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,eAAe,UAAU,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,CAAC"}