@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.
package/dist/video.js CHANGED
@@ -1,7 +1,7 @@
1
- import{_ as e,a as t}from"./chunks/_tslib-35bb891d.js";import{jsxs as i,jsx as s,Fragment as n}from"react/jsx-runtime";import*as a from"react";import{useRef as r,useState as l,useLayoutEffect as o,useEffect as c,useCallback as d}from"react";import{useElementSelected as h,useBlockSelected as m,useYooptaEditor as u,useYooptaPluginOptions as p,Elements as g,Blocks as b}from"@yoopta/editor";import{parseVideoUrl as v,getEmbedUrl as f,useVideoUpload as j,useVideoDelete as w,useVideoPreview as x,buildVideoProvider as y}from"@yoopta/video";import{Editor as N,Element as O}from"slate";import{B as k}from"./chunks/button-7aec29d6.js";import{I as C}from"./chunks/input-b2431223.js";import{T as z,c as I,b as E,a as R}from"./chunks/tabs-294764a6.js";import{c as S}from"./chunks/utils-3345eade.js";import{L as U,U as P,D}from"./chunks/upload-b1dd210d.js";import{L as H,A as L,a as W,b as F,R as M}from"./chunks/index-87b75648.js";import{c as V}from"./chunks/createLucideIcon-8605f860.js";import{P as A}from"./chunks/play-998f23d2.js";import{T as B,a as _,b as T,c as q,u as $,F as Y,R as K}from"./chunks/tooltip-65b9c3a0.js";import{C as G,c as J}from"./chunks/index-0bca29df.js";import{L as X}from"./chunks/label-21d46c31.js";import{P as Z,a as Q,b as ee}from"./chunks/popover-8e6ee2ab.js";import{u as te,S as ie,a as se,b as ne,c as ae,e as re,d as le}from"./chunks/select-a8bcd8b5.js";import{S as oe}from"./chunks/separator-219dc1f7.js";import{c as ce,P as de,a as he}from"./chunks/index-17323747.js";import{u as me}from"./chunks/index-91a5b8d5.js";import{u as ue}from"./chunks/index-ff0e3962.js";import{e as pe,o as ge,f as be,s as ve,b as fe}from"./chunks/index-23c7fb16.js";import{S as je}from"./chunks/settings-2-84fe63d9.js";import{E as we}from"./chunks/external-link-1579dd7f.js";import{T as xe}from"./chunks/trash-2-f36597ff.js";import"./chunks/index-ba3032f8.js";import"./chunks/index-f85dae42.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-70f4e709.js";import"./chunks/index-13505606.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/index-056e5c06.js";import"./chunks/chevron-down-28dfb290.js";import"./chunks/check-06bd6a78.js";import"./chunks/chevron-up-9a13532e.js";
1
+ import{_ as e,a as i}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as s,Fragment as n}from"react/jsx-runtime";import*as a from"react";import{useRef as r,useState as l,useLayoutEffect as o,useEffect as c,useCallback as d}from"react";import{useElementSelected as h,useBlockSelected as m,useYooptaEditor as u,useYooptaPluginOptions as p,Elements as g,Blocks as b}from"@yoopta/editor";import{parseVideoUrl as v,getEmbedUrl as f,useVideoUpload as j,useVideoDelete as x,useVideoPreview as w,buildVideoProvider as y}from"@yoopta/video";import{Editor as N,Element as O}from"slate";import{B as k}from"./chunks/button-7aec29d6.js";import{I as C}from"./chunks/input-b2431223.js";import{T as I,c as z,b as R,a as U}from"./chunks/tabs-294764a6.js";import{c as P}from"./chunks/utils-3345eade.js";import{L as S,U as E,D}from"./chunks/upload-b1dd210d.js";import{L,A as H,a as F,b as W,R as _}from"./chunks/index-87b75648.js";import{c as V}from"./chunks/createLucideIcon-8605f860.js";import{P as A}from"./chunks/play-998f23d2.js";import{T as B,a as q,b as M,c as T,u as $,F as Y,R as K}from"./chunks/tooltip-65b9c3a0.js";import{C as G,c as J}from"./chunks/index-0bca29df.js";import{L as X}from"./chunks/label-21d46c31.js";import{P as Z,a as Q,b as ee}from"./chunks/popover-8e6ee2ab.js";import{u as ie,S as te,a as se,b as ne,c as ae,e as re,d as le}from"./chunks/select-a8bcd8b5.js";import{S as oe}from"./chunks/separator-219dc1f7.js";import{c as ce,P as de,a as he}from"./chunks/index-17323747.js";import{u as me}from"./chunks/index-91a5b8d5.js";import{u as ue}from"./chunks/index-ff0e3962.js";import{e as pe,o as ge,f as be,s as ve,b as fe}from"./chunks/index-23c7fb16.js";import{S as je}from"./chunks/settings-2-84fe63d9.js";import{E as xe}from"./chunks/external-link-1579dd7f.js";import{T as we}from"./chunks/trash-2-f36597ff.js";import"./chunks/index-ba3032f8.js";import"./chunks/index-f85dae42.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-70f4e709.js";import"./chunks/index-13505606.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/index-056e5c06.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 ye=V("Video",[["path",{d:"m22 8-6 4 6 4V8Z",key:"50v9me"}],["rect",{width:"14",height:"12",x:"2",y:"6",rx:"2",ry:"2",key:"1rqjg6"}]]),Ne=({preview:e})=>s("div",Object.assign({className:"absolute inset-0 overflow-hidden flex items-center justify-center bg-black/5"},{children:s("video",{src:e.url,className:"max-w-full max-h-full object-contain",style:{maxWidth:e.width||"100%",maxHeight:e.height||"100%"},controls:!1,muted:!0,draggable:!1})})),Oe=({progress:e})=>s("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:s("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:[s("span",Object.assign({className:"font-medium text-white"},{children:"Uploading video..."})),i("span",Object.assign({className:"text-white/80"},{children:[e.percentage,"%"]}))]})),s("div",Object.assign({className:"h-2 w-full overflow-hidden rounded-full bg-white/20"},{children:s("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"]}),s(U,{className:"h-3.5 w-3.5 animate-spin"})]}))]}))}))})),ke=({onUpload:e,hasPreview:t})=>{const n=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:[s("p",Object.assign({className:"text-sm font-medium text-white"},{children:"Video preview"})),s("p",Object.assign({className:"text-xs text-white/80"},{children:"Uploading your video..."}))]})),s("input",{ref:n,type:"file",accept:"video/*",onChange:e,className:"hidden"})]}):Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[s("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:s(ye,{className:"h-6 w-6 text-muted-foreground"})})),i("div",Object.assign({className:"text-center"},{children:[s("p",Object.assign({className:"text-sm font-medium"},{children:"Upload a video"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Click or drag and drop"}))]})),s(k,Object.assign({onClick:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.click()}},{children:"Choose file"})),s("input",{ref:n,type:"file",accept:"video/*",onChange:e,className:"hidden"})]}))},Ce=({onInsertUrl:e})=>{const[t,n]=l(""),[a,r]=l(!1),[o,c]=l(null),d=()=>{t.trim()&&(e(t.trim()),n(""),r(!1),c(null))};return i("div",Object.assign({className:"mt-4 space-y-3"},{children:[i("div",Object.assign({className:"space-y-2"},{children:[s(C,{placeholder:"Paste video URL (YouTube, Vimeo, Dailymotion, Loom, Wistia)...",value:t,onChange:e=>(e=>{if(n(e),e.trim()){const t=v(e.trim());r(t.isValid),c(t.provider?t.provider.charAt(0).toUpperCase()+t.provider.slice(1):null)}else r(!1),c(null)})(e.target.value),onKeyDown:e=>{"Enter"===e.key&&t.trim()&&a&&d()}}),t.trim()&&s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:a?i("span",Object.assign({className:"flex items-center gap-1.5 text-green-600 dark:text-green-400"},{children:[s(A,{className:"h-3 w-3"}),o," video detected"]})):s("span",Object.assign({className:"text-destructive"},{children:"Invalid video URL. Supported: YouTube, Vimeo, Dailymotion, Loom, Wistia"}))}))]})),s(k,Object.assign({className:"w-full",onClick:d,disabled:!t.trim()||!a},{children:a?`Embed ${o} video`:"Embed video"}))]}))},ze=({onUpload:e,onInsertUrl:t,hasPreview:n})=>s("div",Object.assign({className:S("relative p-4",n&&"min-h-[300px] flex flex-col")},{children:i(z,Object.assign({defaultValue:"upload",className:"w-full"},{children:[i(I,Object.assign({className:S("grid w-full grid-cols-2",n&&"bg-background/80 backdrop-blur-sm")},{children:[i(E,Object.assign({value:"upload",className:"gap-1.5"},{children:[s(P,{className:"h-3.5 w-3.5"}),"Upload"]})),i(E,Object.assign({value:"link",className:"gap-1.5"},{children:[s(H,{className:"h-3.5 w-3.5"}),"Link"]}))]})),s(R,Object.assign({value:"upload",className:"mt-4"},{children:s(ke,{onUpload:e,hasPreview:n})})),s(R,Object.assign({value:"link"},{children:s(Ce,{onInsertUrl:t})}))]}))})),Ie=({onUpload:e,onInsertUrl:t,className:n,attributes:a,children:r,preview:l,progress:o,loading:c})=>{const d=null!==l&&!!l.url,h=c&&o;return i("div",Object.assign({className:S("mt-2 relative rounded-lg border bg-background overflow-hidden",d&&"min-h-[300px]",n)},a,{contentEditable:!1},{children:[d&&s(Ne,{preview:l}),!d&&s(ze,{onUpload:e,onInsertUrl:t,hasPreview:d}),h&&o&&s(Oe,{progress:o}),r]}))};var Ee="Switch",[Re,Se]=ce(Ee),[Ue,Pe]=Re(Ee),De=a.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:l,defaultChecked:o,required:c,disabled:d,value:h="on",onCheckedChange:m,form:u,...p}=e,[g,b]=a.useState(null),v=me(t,e=>b(e)),f=a.useRef(!1),j=!g||(u||!!g.closest("form")),[w,x]=ue({prop:l,defaultProp:o??!1,onChange:m,caller:Ee});return i(Ue,{scope:n,checked:w,disabled:d,children:[s(de.button,{type:"button",role:"switch","aria-checked":w,"aria-required":c,"data-state":Fe(w),"data-disabled":d?"":void 0,disabled:d,value:h,...p,ref:v,onClick:he(e.onClick,e=>{x(e=>!e),j&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})}),j&&s(We,{control:g,bubbles:!f.current,name:r,value:h,checked:w,required:c,disabled:d,form:u,style:{transform:"translateX(-100%)"}})]})});De.displayName=Ee;var He="SwitchThumb",Le=a.forwardRef((e,t)=>{const{__scopeSwitch:i,...n}=e,a=Pe(He,i);return s(de.span,{"data-state":Fe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:t})});Le.displayName=He;var We=a.forwardRef(({__scopeSwitch:e,control:t,checked:i,bubbles:n=!0,...r},l)=>{const o=a.useRef(null),c=me(o,l),d=te(i),h=pe(t);return a.useEffect(()=>{const e=o.current;if(!e)return;const t=window.HTMLInputElement.prototype,s=Object.getOwnPropertyDescriptor(t,"checked").set;if(d!==i&&s){const t=new Event("click",{bubbles:n});s.call(e,i),e.dispatchEvent(t)}},[d,i,n]),s("input",{type:"checkbox","aria-hidden":!0,defaultChecked:i,...r,tabIndex:-1,ref:c,style:{...r.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function Fe(e){return e?"checked":"unchecked"}We.displayName="SwitchBubbleInput";var Me=De,Ve=Le;const Ae=a.forwardRef((t,i)=>{var{className:n}=t,a=e(t,["className"]);return s(Me,Object.assign({className:S("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n)},a,{ref:i},{children:s(Ve,{className:S("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}))});Ae.displayName=Me.displayName;const Be={contain:{label:"Contain",description:"Fit within bounds"},cover:{label:"Cover",description:"Fill and crop"},fill:{label:"Fill",description:"Stretch to fit"}},_e=({fit:e,settings:t,onUpdate:n})=>{var a,r,o,c,d,h,m,u,p,g,b,v;const[f,j]=l(!1),w=e=>{n({settings:Object.assign(Object.assign({},t),e)})};return i(Z,Object.assign({open:f,onOpenChange:j},{children:[s(B,{children:i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(Q,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:f?"secondary":"ghost",size:"icon",className:"h-7 w-7"},{children:s(je,{className:"h-4 w-4"})}))}))})),s(q,{children:"Settings"})]})}),s(ee,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:[s("h4",Object.assign({className:"font-semibold"},{children:"Video settings"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Customize video playback and display"}))]}),s(oe,{}),i("div",Object.assign({className:"space-y-1"},{children:[s(X,Object.assign({htmlFor:"object-fit",className:"text-sm font-medium"},{children:"How video fits"})),i(ie,Object.assign({value:e||"contain",onValueChange:e=>n({fit:e})},{children:[s(se,Object.assign({id:"object-fit",className:"h-9 w-full"},{children:s(ne,Object.assign({placeholder:"Select how video fits"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(a=Be[e||"contain"])||void 0===a?void 0:a.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(r=Be[e||"contain"])||void 0===r?void 0:r.description}))]}))}))})),s(ae,{children:i(re,{children:[s(le,Object.assign({value:"contain",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:s("div",{className:"h-4 w-3 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(o=Be.contain)||void 0===o?void 0:o.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(c=Be.contain)||void 0===c?void 0:c.description}))]}))]}))})),s(le,Object.assign({value:"cover",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:s("div",{className:"h-8 w-6 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(d=Be.cover)||void 0===d?void 0:d.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(h=Be.cover)||void 0===h?void 0:h.description}))]}))]}))})),s(le,Object.assign({value:"fill",className:"cursor-pointer"},{children:i("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:s("div",{className:"h-8 w-8 rounded bg-primary"})})),i("div",Object.assign({className:"flex-1"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(m=Be.fill)||void 0===m?void 0:m.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(u=Be.fill)||void 0===u?void 0:u.description}))]}))]}))}))]})})]}))]})),s(oe,{}),i("div",Object.assign({className:"space-y-3"},{children:[i("div",Object.assign({className:"flex items-center justify-between"},{children:[i("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"controls",className:"text-sm font-medium"},{children:"Show controls"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Display video player controls"}))]})),s(Ae,{id:"controls",checked:null!==(p=t.controls)&&void 0!==p&&p,onCheckedChange:e=>w({controls:e})})]})),i("div",Object.assign({className:"flex items-center justify-between"},{children:[i("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"loop",className:"text-sm font-medium"},{children:"Loop video"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Automatically replay when finished"}))]})),s(Ae,{id:"loop",checked:null!==(g=t.loop)&&void 0!==g&&g,onCheckedChange:e=>w({loop:e})})]})),i("div",Object.assign({className:"flex items-center justify-between"},{children:[i("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"muted",className:"text-sm font-medium"},{children:"Muted"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Start video without sound"}))]})),s(Ae,{id:"muted",checked:null!==(b=t.muted)&&void 0!==b&&b,onCheckedChange:e=>w({muted:e})})]})),i("div",Object.assign({className:"flex items-center justify-between"},{children:[i("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"autoplay",className:"text-sm font-medium"},{children:"Autoplay"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Start playing automatically (may require muted)"}))]})),s(Ae,{id:"autoplay",checked:null!==(v=t.autoPlay)&&void 0!==v&&v,onCheckedChange:e=>w({autoPlay:e})})]}))]}))]}))}))]}))},Te=({referenceRef:e,elementProps:t,onUpdate:a,onReplace:r,onDelete:c,onDownload:d,onCopy:h})=>{var m,u;const[p,g]=l(!1),[b,v]=l(!1),f=t.provider&&t.provider.type,j="alignment"in t,{refs:w,floatingStyles:x}=$({placement:"top-end",strategy:"absolute",middleware:[ge(8),be({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),ve({padding:10})],whileElementsMounted:fe});o(()=>{const t=e.current;t&&(w.setReference(t),v(!0))},[e,w]),o(()=>{if(b){const e=requestAnimationFrame(()=>{g(!0)});return()=>cancelAnimationFrame(e)}},[b]);return b?s(Y,{children:s("div",Object.assign({ref:w.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:S("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",p?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:x},{children:i(B,Object.assign({delayDuration:0},{children:[j&&i("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"left"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"left"})},{children:s(L,{className:"h-4 w-4"})}))})),s(q,{children:"Align left"})]}),i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"center"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"center"})},{children:s(W,{className:"h-4 w-4"})}))})),s(q,{children:"Align center"})]}),i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"right"===t.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"right"})},{children:s(F,{className:"h-4 w-4"})}))})),s(q,{children:"Align right"})]})]})),i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r},{children:s(K,{className:"h-4 w-4"})}))})),s(q,{children:"Replace"})]}),!f&&t.src&&i(n,{children:[i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{if(d)d();else if(t.src&&!f){const e=document.createElement("a");e.href=t.src,e.download=`video-${Date.now()}.mp4`,e.click()}}},{children:s(D,{className:"h-4 w-4"})}))})),s(q,{children:"Download"})]}),i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{h?h():t.src&&J(t.src)}},{children:s(G,{className:"h-4 w-4"})}))})),s(q,{children:"Copy URL"})]})]}),f&&(null===(m=t.provider)||void 0===m?void 0:m.url)&&i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;(null===(e=t.provider)||void 0===e?void 0:e.url)&&window.open(t.provider.url,"_blank")}},{children:s(we,{className:"h-4 w-4"})}))})),s(q,{children:"Open in new tab"})]}),!f&&i(n,{children:[s(oe,{orientation:"vertical",className:"h-4"}),s(_e,{fit:null!==(u=t.fit)&&void 0!==u?u:"contain",settings:t.settings||{controls:!1,loop:!1,muted:!1,autoPlay:!1},onUpdate:a})]}),i(_,{children:[s(T,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:c},{children:s(xe,{className:"h-4 w-4"})}))})),s(q,{children:"Delete"})]})]}))}))}):null},qe=({blockId:e,attributes:n,children:a,elementProps:o,onUpdate:d,onDelete:p,onReplace:g,pluginOptions:b})=>{var v,j,w,x;const[y,N]=l(o.sizes||{width:650,height:400}),{isElementSelected:O}=h(),k=m({blockId:e}),C=O&&k,z=r(null),I=u(),[E,R]=l(()=>{var e;const t=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||650,i=null==b?void 0:b.maxSizes;return{maxWidth:(null==i?void 0:i.maxWidth)?"number"==typeof i.maxWidth?i.maxWidth:parseInt(String(i.maxWidth).replace(/[^\d]/g,""),10):t,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;const t=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||650,i=null==b?void 0:b.maxSizes;R({maxWidth:(null==i?void 0:i.maxWidth)?"number"==typeof i.maxWidth?i.maxWidth:parseInt(String(i.maxWidth).replace(/[^\d]/g,""),10):t,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 I.refElement&&t.observe(I.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[I,b]);const U=(e,t)=>{const i=e=>"number"==typeof e?e:parseInt(String(e).replace(/[^\d]/g,""),10),s=i(e.width),n=i(e.height),a=i(t.width),r=i(t.height);if(s<=a&&n<=r)return{width:s,height:n};const l=s/a,o=n/r,c=Math.max(l,o),d=Math.round(s/c),h=Math.round(n/c);return{width:Math.min(d,a),height:Math.min(h,r)}},P=o.provider&&o.provider.type,D=o.src||"",H=P&&(null===(v=o.provider)||void 0===v?void 0:v.id)?f(o.provider.type,o.provider.id):null,L=o.settings||{controls:!0,loop:!1,muted:!1,autoPlay:!1},W={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(j=o.alignment)&&void 0!==j?j:"center"];return i("div",Object.assign({},n,{className:S("group/video mt-2 relative transition-all w-full flex",W)},{children:[i("div",Object.assign({className:"relative",contentEditable:!1},{children:[s(M,Object.assign({ref:e=>{(null==e?void 0:e.resizableElement)&&e.resizableElement instanceof HTMLElement&&(z.current=e.resizableElement)},style:{position:"relative",outline:C?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:C?"hsl(var(--primary))":"none"},size:{width:"number"==typeof y.width?y.width:parseInt(String(y.width),10),height:"number"==typeof y.height?y.height:parseInt(String(y.height),10)},onResize:(e,t,i)=>{const s=parseInt(i.style.width,10),n=parseInt(i.style.height,10),a=U({width:s,height:n},{width:E.maxWidth,height:E.maxHeight});N(a)},onResizeStop:(e,t,i)=>{const s=parseInt(i.style.width,10),n=parseInt(i.style.height,10),a=U({width:s,height:n},{width:E.maxWidth,height:E.maxHeight});d({sizes:a})},lockAspectRatio:!0,minWidth:200,minHeight:150,maxWidth:E.maxWidth,maxHeight:E.maxHeight,position:{x:0,y:0},enableResizing:!!C&&{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:s("div",{className:"h-10 w-2 rounded-full bg-primary shadow-md ring-2 ring-white/80"}),right:s("div",{className:"h-10 w-2 rounded-full bg-primary shadow-md ring-2 ring-white/80"})},className:S("rounded-sm overflow-hidden")},{children:P&&H?s("iframe",{title:o.provider.type,src:H,width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"w-full h-full",style:{aspectRatio:`${y.width} / ${y.height}`}}):s("video",{title:"Video",src:D,controls:L.controls,loop:L.loop,muted:L.muted,autoPlay:L.autoPlay,poster:null!==(w=o.poster)&&void 0!==w?w:void 0,className:"w-full h-full transition-all duration-200",style:{objectFit:null!==(x=o.fit)&&void 0!==x?x:"contain"},draggable:!1})})),C&&s(Te,{referenceRef:z,elementProps:o,onUpdate:d,onReplace:g,onDelete:p,onDownload:()=>t(void 0,void 0,void 0,function*(){if(o.src&&!P)try{const e=yield fetch(o.src),t=yield e.blob(),i=URL.createObjectURL(t),s=document.createElement("a");s.href=i,s.download=`video-${Date.now()}.mp4`,s.click(),URL.revokeObjectURL(i)}catch(e){}}),onCopy:()=>t(void 0,void 0,void 0,function*(){var e;if(o.src)try{if(P&&(null===(e=o.provider)||void 0===e?void 0:e.url)){const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(o.provider.url)}else{const e=yield fetch(o.src),t=yield e.blob();if(navigator.clipboard&&ClipboardItem)yield navigator.clipboard.write([new ClipboardItem({[t.type]:t})]);else{const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(o.src)}}}catch(e){const{default:t}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});t(o.src||"")}})})]})),a]}))},$e={video:{render:({element:e,attributes:i,children:n,blockId:a})=>{const r=u(),l=p("Video"),{upload:o,progress:c,loading:h}=j(l.upload),{deleteVideo:m}=w(l.delete),{preview:f,generatePreview:k,clearPreview:C}=x(),z=d(t=>{g.updateElement(r,{blockId:a,type:"video",props:Object.assign(Object.assign({},e.props),t)})},[r,a,e.props]),I=d(()=>t(void 0,void 0,void 0,function*(){yield m(e);const t=b.getBlockSlate(r,{id:a});if(!t)return;const i=g.getElementPath(r,{blockId:a,element:e});if(!i)return;const s=i?N.parent(t,i):void 0;s&&O.isElement(s[0])&&!N.isEditor(s[0])?g.deleteElement(r,{blockId:a,type:"video",path:i}):b.deleteBlock(r,{blockId:a,focus:!0})}),[r,a,e,m]),E=d(()=>{g.updateElement(r,{blockId:a,type:"video",props:Object.assign(Object.assign({},e.props),{src:null,provider:null})})},[r,a,e.props]),R=d(i=>t(void 0,void 0,void 0,function*(){var t;const s=null===(t=i.target.files)||void 0===t?void 0:t[0];if(!s)return;k(s);const n=yield o(s);z({id:n.id||n.fileId,src:n.url,sizes:n.width&&n.height?{width:n.width,height:n.height}:e.props.sizes||{width:650,height:400},provider:n.provider||null,poster:n.poster||null}),C()}),[o,z,k,C,e.props.sizes]),S=d(i=>t(void 0,void 0,void 0,function*(){const t=v(i);if(t.isValid&&t.provider){const s=y(i);z({src:t.embedUrl,provider:s,sizes:e.props.sizes||{width:650,height:400}})}else i.trim()&&z({src:i.trim(),provider:null,sizes:e.props.sizes||{width:650,height:400}})}),[z,e.props.sizes]);return e.props.src||e.props.provider?s(qe,Object.assign({blockId:a,elementId:e.id,onUpdate:z,onDelete:I,attributes:i,onReplace:E,elementProps:e.props,pluginOptions:l},{children:n})):s(Ie,Object.assign({onUpload:R,preview:f,progress:c,loading:h,onInsertUrl:S,attributes:i},{children:n}))}}};export{$e as VideoUI};
7
+ */const ye=V("Video",[["path",{d:"m22 8-6 4 6 4V8Z",key:"50v9me"}],["rect",{width:"14",height:"12",x:"2",y:"6",rx:"2",ry:"2",key:"1rqjg6"}]]),Ne=({preview:e})=>s("div",Object.assign({className:"absolute inset-0 overflow-hidden flex items-center justify-center bg-black/5"},{children:s("video",{src:e.url,className:"max-w-full max-h-full object-contain",style:{maxWidth:e.width||"100%",maxHeight:e.height||"100%"},controls:!1,muted:!0,draggable:!1})})),Oe=({progress:e})=>s("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:s("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:[s("span",Object.assign({className:"font-medium text-white"},{children:"Uploading video..."})),t("span",Object.assign({className:"text-white/80"},{children:[e.percentage,"%"]}))]})),s("div",Object.assign({className:"h-2 w-full overflow-hidden rounded-full bg-white/20"},{children:s("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-white/60"},{children:[t("span",{children:[(e.loaded/1024/1024).toFixed(2)," MB /"," ",(e.total/1024/1024).toFixed(2)," MB"]}),s(S,{className:"h-3.5 w-3.5 animate-spin"})]}))]}))}))})),ke=({onUpload:e,hasPreview:i})=>{const n=r(null);return t("div",i?Object.assign({className:"flex flex-col items-center justify-center gap-4 py-8"},{children:[t("div",Object.assign({className:"text-center space-y-2"},{children:[s("p",Object.assign({className:"text-sm font-medium text-white"},{children:"Video preview"})),s("p",Object.assign({className:"text-xs text-white/80"},{children:"Uploading your video..."}))]})),s("input",{ref:n,type:"file",accept:"video/*",onChange:e,className:"hidden"})]}):Object.assign({className:"flex flex-col items-center gap-3 py-6"},{children:[s("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:s(ye,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[s("p",Object.assign({className:"text-sm font-medium"},{children:"Upload a video"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Click or drag and drop"}))]})),s(k,Object.assign({onClick:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.click()}},{children:"Choose file"})),s("input",{ref:n,type:"file",accept:"video/*",onChange:e,className:"hidden"})]}))},Ce=({onInsertUrl:e})=>{const[i,n]=l(""),[a,r]=l(!1),[o,c]=l(null),d=()=>{i.trim()&&(e(i.trim()),n(""),r(!1),c(null))};return t("div",Object.assign({className:"mt-4 space-y-3"},{children:[t("div",Object.assign({className:"space-y-2"},{children:[s(C,{placeholder:"Paste video URL (YouTube, Vimeo, Dailymotion, Loom, Wistia)...",value:i,onChange:e=>(e=>{if(n(e),e.trim()){const i=v(e.trim());r(i.isValid),c(i.provider?i.provider.charAt(0).toUpperCase()+i.provider.slice(1):null)}else r(!1),c(null)})(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&a&&d()}}),i.trim()&&s("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:[s(A,{className:"h-3 w-3"}),o," video detected"]})):s("span",Object.assign({className:"text-destructive"},{children:"Invalid video URL. Supported: YouTube, Vimeo, Dailymotion, Loom, Wistia"}))}))]})),s(k,Object.assign({className:"w-full",onClick:d,disabled:!i.trim()||!a},{children:a?`Embed ${o} video`:"Embed video"}))]}))},Ie=({onUpload:e,onInsertUrl:i,hasPreview:n})=>s("div",Object.assign({className:P("relative p-4",n&&"min-h-[300px] flex flex-col")},{children:t(I,Object.assign({defaultValue:"upload",className:"w-full"},{children:[t(z,Object.assign({className:P("grid w-full grid-cols-2",n&&"bg-background/80 backdrop-blur-sm")},{children:[t(R,Object.assign({value:"upload",className:"gap-1.5"},{children:[s(E,{className:"h-3.5 w-3.5"}),"Upload"]})),t(R,Object.assign({value:"link",className:"gap-1.5"},{children:[s(L,{className:"h-3.5 w-3.5"}),"Link"]}))]})),s(U,Object.assign({value:"upload",className:"mt-4"},{children:s(ke,{onUpload:e,hasPreview:n})})),s(U,Object.assign({value:"link"},{children:s(Ce,{onInsertUrl:i})}))]}))})),ze=({onUpload:e,onInsertUrl:i,className:n,attributes:a,children:r,preview:l,progress:o,loading:c})=>{const d=null!==l&&!!l.url,h=c&&o;return t("div",Object.assign({className:P("mt-2 relative rounded-lg border bg-background overflow-hidden",d&&"min-h-[300px]",n)},a,{contentEditable:!1},{children:[d&&s(Ne,{preview:l}),!d&&s(Ie,{onUpload:e,onInsertUrl:i,hasPreview:d}),h&&o&&s(Oe,{progress:o}),r]}))};var Re="Switch",[Ue,Pe]=ce(Re),[Se,Ee]=Ue(Re),De=a.forwardRef((e,i)=>{const{__scopeSwitch:n,name:r,checked:l,defaultChecked:o,required:c,disabled:d,value:h="on",onCheckedChange:m,form:u,...p}=e,[g,b]=a.useState(null),v=me(i,e=>b(e)),f=a.useRef(!1),j=!g||(u||!!g.closest("form")),[x,w]=ue({prop:l,defaultProp:o??!1,onChange:m,caller:Re});return t(Se,{scope:n,checked:x,disabled:d,children:[s(de.button,{type:"button",role:"switch","aria-checked":x,"aria-required":c,"data-state":We(x),"data-disabled":d?"":void 0,disabled:d,value:h,...p,ref:v,onClick:he(e.onClick,e=>{w(e=>!e),j&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})}),j&&s(Fe,{control:g,bubbles:!f.current,name:r,value:h,checked:x,required:c,disabled:d,form:u,style:{transform:"translateX(-100%)"}})]})});De.displayName=Re;var Le="SwitchThumb",He=a.forwardRef((e,i)=>{const{__scopeSwitch:t,...n}=e,a=Ee(Le,t);return s(de.span,{"data-state":We(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:i})});He.displayName=Le;var Fe=a.forwardRef(({__scopeSwitch:e,control:i,checked:t,bubbles:n=!0,...r},l)=>{const o=a.useRef(null),c=me(o,l),d=ie(t),h=pe(i);return a.useEffect(()=>{const e=o.current;if(!e)return;const i=window.HTMLInputElement.prototype,s=Object.getOwnPropertyDescriptor(i,"checked").set;if(d!==t&&s){const i=new Event("click",{bubbles:n});s.call(e,t),e.dispatchEvent(i)}},[d,t,n]),s("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...r,tabIndex:-1,ref:c,style:{...r.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});function We(e){return e?"checked":"unchecked"}Fe.displayName="SwitchBubbleInput";var _e=De,Ve=He;const Ae=a.forwardRef((i,t)=>{var{className:n}=i,a=e(i,["className"]);return s(_e,Object.assign({className:P("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n)},a,{ref:t},{children:s(Ve,{className:P("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}))});Ae.displayName=_e.displayName;const Be={contain:{label:"Contain",description:"Fit within bounds"},cover:{label:"Cover",description:"Fill and crop"},fill:{label:"Fill",description:"Stretch to fit"}},qe=({fit:e,settings:i,onUpdate:n})=>{var a,r,o,c,d,h,m,u,p,g,b,v;const[f,j]=l(!1),x=e=>{n({settings:Object.assign(Object.assign({},i),e)})};return t(Z,Object.assign({open:f,onOpenChange:j},{children:[s(B,{children:t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(Q,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:f?"secondary":"ghost",size:"icon",className:"h-7 w-7"},{children:s(je,{className:"h-4 w-4"})}))}))})),s(T,{children:"Settings"})]})}),s(ee,Object.assign({className:"w-80 p-3",align:"start",contentEditable:!1,onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation()},{children:t("div",Object.assign({className:"space-y-3"},{children:[t("div",{children:[s("h4",Object.assign({className:"font-semibold"},{children:"Video settings"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Customize video playback and display"}))]}),s(oe,{}),t("div",Object.assign({className:"space-y-1"},{children:[s(X,Object.assign({htmlFor:"object-fit",className:"text-sm font-medium"},{children:"How video fits"})),t(te,Object.assign({value:e||"contain",onValueChange:e=>n({fit:e})},{children:[s(se,Object.assign({id:"object-fit",className:"h-9 w-full"},{children:s(ne,Object.assign({placeholder:"Select how video fits"},{children:t("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(a=Be[e||"contain"])||void 0===a?void 0:a.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(r=Be[e||"contain"])||void 0===r?void 0:r.description}))]}))}))})),s(ae,{children:t(re,{children:[s(le,Object.assign({value:"contain",className:"cursor-pointer"},{children:t("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:s("div",{className:"h-4 w-3 rounded bg-primary"})})),t("div",Object.assign({className:"flex-1"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(o=Be.contain)||void 0===o?void 0:o.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(c=Be.contain)||void 0===c?void 0:c.description}))]}))]}))})),s(le,Object.assign({value:"cover",className:"cursor-pointer"},{children:t("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:s("div",{className:"h-8 w-6 rounded bg-primary"})})),t("div",Object.assign({className:"flex-1"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(d=Be.cover)||void 0===d?void 0:d.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(h=Be.cover)||void 0===h?void 0:h.description}))]}))]}))})),s(le,Object.assign({value:"fill",className:"cursor-pointer"},{children:t("div",Object.assign({className:"flex items-center gap-2"},{children:[s("div",Object.assign({className:"flex h-8 w-8 shrink-0 items-center justify-center rounded border"},{children:s("div",{className:"h-8 w-8 rounded bg-primary"})})),t("div",Object.assign({className:"flex-1"},{children:[s("div",Object.assign({className:"font-medium"},{children:null===(m=Be.fill)||void 0===m?void 0:m.label})),s("div",Object.assign({className:"text-xs text-muted-foreground"},{children:null===(u=Be.fill)||void 0===u?void 0:u.description}))]}))]}))}))]})})]}))]})),s(oe,{}),t("div",Object.assign({className:"space-y-3"},{children:[t("div",Object.assign({className:"flex items-center justify-between"},{children:[t("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"controls",className:"text-sm font-medium"},{children:"Show controls"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Display video player controls"}))]})),s(Ae,{id:"controls",checked:null!==(p=i.controls)&&void 0!==p&&p,onCheckedChange:e=>x({controls:e})})]})),t("div",Object.assign({className:"flex items-center justify-between"},{children:[t("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"loop",className:"text-sm font-medium"},{children:"Loop video"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Automatically replay when finished"}))]})),s(Ae,{id:"loop",checked:null!==(g=i.loop)&&void 0!==g&&g,onCheckedChange:e=>x({loop:e})})]})),t("div",Object.assign({className:"flex items-center justify-between"},{children:[t("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"muted",className:"text-sm font-medium"},{children:"Muted"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Start video without sound"}))]})),s(Ae,{id:"muted",checked:null!==(b=i.muted)&&void 0!==b&&b,onCheckedChange:e=>x({muted:e})})]})),t("div",Object.assign({className:"flex items-center justify-between"},{children:[t("div",Object.assign({className:"space-y-0.5"},{children:[s(X,Object.assign({htmlFor:"autoplay",className:"text-sm font-medium"},{children:"Autoplay"})),s("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Start playing automatically (may require muted)"}))]})),s(Ae,{id:"autoplay",checked:null!==(v=i.autoPlay)&&void 0!==v&&v,onCheckedChange:e=>x({autoPlay:e})})]}))]}))]}))}))]}))},Me=({referenceRef:e,elementProps:i,onUpdate:a,onReplace:r,onDelete:c,onDownload:d,onCopy:h})=>{var m,u;const[p,g]=l(!1),[b,v]=l(!1),f=i.provider&&i.provider.type,j="alignment"in i,{refs:x,floatingStyles:w}=$({placement:"top-end",strategy:"absolute",middleware:[ge(8),be({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),ve({padding:10})],whileElementsMounted:fe});o(()=>{const i=e.current;i&&(x.setReference(i),v(!0))},[e,x]),o(()=>{if(b){const e=requestAnimationFrame(()=>{g(!0)});return()=>cancelAnimationFrame(e)}},[b]);return b?s(Y,{children:s("div",Object.assign({ref:x.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:P("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",p?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:w},{children:t(B,Object.assign({delayDuration:0},{children:[j&&t("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"left"===i.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"left"})},{children:s(H,{className:"h-4 w-4"})}))})),s(T,{children:"Align left"})]}),t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"center"===i.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"center"})},{children:s(F,{className:"h-4 w-4"})}))})),s(T,{children:"Align center"})]}),t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"right"===i.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>a({alignment:"right"})},{children:s(W,{className:"h-4 w-4"})}))})),s(T,{children:"Align right"})]})]})),t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:r},{children:s(K,{className:"h-4 w-4"})}))})),s(T,{children:"Replace"})]}),!f&&i.src&&t(n,{children:[t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{if(d)d();else if(i.src&&!f){const e=document.createElement("a");e.href=i.src,e.download=`video-${Date.now()}.mp4`,e.click()}}},{children:s(D,{className:"h-4 w-4"})}))})),s(T,{children:"Download"})]}),t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{h?h():i.src&&J(i.src)}},{children:s(G,{className:"h-4 w-4"})}))})),s(T,{children:"Copy URL"})]})]}),f&&(null===(m=i.provider)||void 0===m?void 0:m.url)&&t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;(null===(e=i.provider)||void 0===e?void 0:e.url)&&window.open(i.provider.url,"_blank")}},{children:s(xe,{className:"h-4 w-4"})}))})),s(T,{children:"Open in new tab"})]}),!f&&t(n,{children:[s(oe,{orientation:"vertical",className:"h-4"}),s(qe,{fit:null!==(u=i.fit)&&void 0!==u?u:"contain",settings:i.settings||{controls:!1,loop:!1,muted:!1,autoPlay:!1},onUpdate:a})]}),t(q,{children:[s(M,Object.assign({asChild:!0},{children:s(k,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:c},{children:s(we,{className:"h-4 w-4"})}))})),s(T,{children:"Delete"})]})]}))}))}):null},Te=({blockId:e,attributes:n,children:a,elementProps:o,onUpdate:d,onDelete:p,onReplace:g,pluginOptions:b})=>{var v,j,x,w,y;const[N,O]=l(o.sizes),{isElementSelected:k}=h(),C=m({blockId:e}),I=k&&C,z=r(null),R=u(),[U,S]=l(()=>{var e;const i=(null===(e=R.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,t=null==b?void 0:b.maxSizes;return{maxWidth:(null==t?void 0:t.maxWidth)?"number"==typeof t.maxWidth?t.maxWidth:parseInt(String(t.maxWidth).replace(/[^\d]/g,""),10):i,maxHeight:(null==t?void 0:t.maxHeight)?"number"==typeof t.maxHeight?t.maxHeight:parseInt(String(t.maxHeight).replace(/[^\d]/g,""),10):0}});c(()=>{const e=()=>{var e;const i=(null===(e=R.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,t=null==b?void 0:b.maxSizes;S({maxWidth:(null==t?void 0:t.maxWidth)?"number"==typeof t.maxWidth?t.maxWidth:parseInt(String(t.maxWidth).replace(/[^\d]/g,""),10):i,maxHeight:(null==t?void 0:t.maxHeight)?"number"==typeof t.maxHeight?t.maxHeight:parseInt(String(t.maxHeight).replace(/[^\d]/g,""),10):0})};e();const i=new ResizeObserver(e);return R.refElement&&i.observe(R.refElement),window.addEventListener("resize",e),()=>{i.disconnect(),window.removeEventListener("resize",e)}},[R,b]);const E=o.provider&&o.provider.type,D=o.src||"",L=E&&(null===(v=o.provider)||void 0===v?void 0:v.id)?f(o.provider.type,o.provider.id):null,H=null!==(j=o.settings)&&void 0!==j?j:{controls:!0,loop:!1,muted:!1,autoPlay:!1},F={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(x=o.alignment)&&void 0!==x?x:"center"];return t("div",Object.assign({},n,{className:P("group/video mt-4 relative transition-all w-full flex",F)},{children:[t("div",Object.assign({className:"relative",contentEditable:!1,ref:z},{children:[s(_,Object.assign({style:{position:"relative",outline:I?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:I?"hsl(var(--primary))":"none",padding:2},onResize:(e,i,t)=>{const s=parseInt(t.style.width,10),n=parseInt(t.style.height,10);O({width:s,height:n})},onResizeStop:(e,i,t)=>{const s=parseInt(t.style.width,10),n=parseInt(t.style.height,10);d({sizes:{width:s,height:n}})},lockAspectRatio:!0,minWidth:200,minHeight:150,maxWidth:U.maxWidth-8||void 0,maxHeight:U.maxHeight||void 0,position:{x:0,y:0},enableResizing:!!I&&{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:s("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:s("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:P("rounded-sm overflow-hidden")},{children:E&&L?s("iframe",{title:o.provider.type,src:L,width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:"w-full h-full",style:{aspectRatio:`${null==N?void 0:N.width} / ${null==N?void 0:N.height}`}}):s("video",{title:"Video",src:D,controls:H.controls,loop:H.loop,muted:H.muted,autoPlay:H.autoPlay,poster:null!==(w=o.poster)&&void 0!==w?w:void 0,className:"w-full h-full transition-all duration-200",style:{objectFit:null!==(y=o.fit)&&void 0!==y?y:"contain"},draggable:!1})})),I&&s(Me,{referenceRef:z,elementProps:o,onUpdate:d,onReplace:g,onDelete:p,onDownload:()=>i(void 0,void 0,void 0,function*(){if(o.src&&!E)try{const e=yield fetch(o.src),i=yield e.blob(),t=URL.createObjectURL(i),s=document.createElement("a");s.href=t,s.download=`video-${Date.now()}.mp4`,s.click(),URL.revokeObjectURL(t)}catch(e){}}),onCopy:()=>i(void 0,void 0,void 0,function*(){var e;if(o.src)try{if(E&&(null===(e=o.provider)||void 0===e?void 0:e.url)){const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(o.provider.url)}else{const e=yield fetch(o.src),i=yield e.blob();if(navigator.clipboard&&ClipboardItem)yield navigator.clipboard.write([new ClipboardItem({[i.type]:i})]);else{const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(o.src)}}}catch(e){const{default:i}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});i(o.src||"")}})})]})),a]}))},$e={video:{render:({element:e,attributes:t,children:n,blockId:a})=>{const r=u(),l=p("Video"),{upload:o,progress:c,loading:h}=j(l.upload),{deleteVideo:m}=x(l.delete),{preview:f,generatePreview:k,clearPreview:C}=w(),I=d(i=>{g.updateElement(r,{blockId:a,type:"video",props:Object.assign(Object.assign({},e.props),i)})},[r,a,e.props]),z=d(()=>i(void 0,void 0,void 0,function*(){yield m(e);const i=b.getBlockSlate(r,{id:a});if(!i)return;const t=g.getElementPath(r,{blockId:a,element:e});if(!t)return;const s=t?N.parent(i,t):void 0;s&&O.isElement(s[0])&&!N.isEditor(s[0])?g.deleteElement(r,{blockId:a,type:"video",path:t}):b.deleteBlock(r,{blockId:a,focus:!0})}),[r,a,e,m]),R=d(()=>{g.updateElement(r,{blockId:a,type:"video",props:Object.assign(Object.assign({},e.props),{src:null,provider:null})})},[r,a,e.props]),U=d(t=>i(void 0,void 0,void 0,function*(){var i;const s=null===(i=t.target.files)||void 0===i?void 0:i[0];if(!s)return;k(s);const n=yield o(s);I({id:n.id||n.fileId,src:n.url,sizes:n.width&&n.height?{width:n.width,height:n.height}:e.props.sizes||{width:650,height:400},provider:n.provider||null,poster:n.poster||null}),C()}),[o,I,k,C,e.props.sizes]),P=d(t=>i(void 0,void 0,void 0,function*(){const i=v(t);if(i.isValid&&i.provider){const s=y(t);I({src:i.embedUrl,provider:s,sizes:e.props.sizes||{width:650,height:400}})}else t.trim()&&I({src:t.trim(),provider:null,sizes:e.props.sizes||{width:650,height:400}})}),[I,e.props.sizes]);return e.props.src||e.props.provider?s(Te,Object.assign({blockId:a,elementId:e.id,onUpdate:I,onDelete:z,attributes:t,onReplace:R,elementProps:e.props,pluginOptions:l},{children:n})):r.readOnly?null:s(ze,Object.assign({onUpload:U,preview:f,progress:c,loading:h,onInsertUrl:P,attributes:t},{children:n}))}}};export{$e as VideoUI};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoopta/themes-shadcn",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "Shadcn UI theme for Yoopta Editor plugins",
5
5
  "author": "Darginec05 <devopsbanda@gmail.com>",
6
6
  "homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
@@ -81,6 +81,7 @@
81
81
  "types": "./dist/index.d.ts",
82
82
  "import": "./dist/index.js"
83
83
  },
84
+ "./variables.css": "./dist/variables.css",
84
85
  "./accordion": {
85
86
  "types": "./dist/types/accordion/index.d.ts",
86
87
  "import": "./dist/accordion.js"
@@ -170,18 +171,18 @@
170
171
  "dist/"
171
172
  ],
172
173
  "peerDependencies": {
173
- "@yoopta/code": "^6.0.0",
174
- "@yoopta/editor": "^6.0.0",
175
- "@yoopta/embed": "^6.0.0",
176
- "@yoopta/file": "^6.0.0",
177
- "@yoopta/image": "^6.0.0",
178
- "@yoopta/lists": "^6.0.0",
179
- "@yoopta/steps": "^6.0.0",
180
- "@yoopta/table": "^6.0.0",
181
- "@yoopta/table-of-contents": "^6.0.0",
182
- "@yoopta/tabs": "^6.0.0",
183
- "@yoopta/ui": "^6.0.0",
184
- "@yoopta/video": "^6.0.0",
174
+ "@yoopta/code": "^6.0.2",
175
+ "@yoopta/editor": "^6.0.2",
176
+ "@yoopta/embed": "^6.0.2",
177
+ "@yoopta/file": "^6.0.2",
178
+ "@yoopta/image": "^6.0.2",
179
+ "@yoopta/lists": "^6.0.2",
180
+ "@yoopta/steps": "^6.0.2",
181
+ "@yoopta/table": "^6.0.2",
182
+ "@yoopta/table-of-contents": "^6.0.2",
183
+ "@yoopta/tabs": "^6.0.2",
184
+ "@yoopta/ui": "^6.0.2",
185
+ "@yoopta/video": "^6.0.2",
185
186
  "react": ">=18.2.0",
186
187
  "react-dom": ">=18.2.0",
187
188
  "slate": "^0.120.0",
@@ -224,7 +225,7 @@
224
225
  "test": "node ./__tests__/yoopta-themes-shadcn.test.js",
225
226
  "start": "rollup --config rollup.config.js --watch --bundleConfigAsCjs --environment NODE_ENV:development",
226
227
  "prepublishOnly": "yarn build",
227
- "build": "rollup --config rollup.config.js --bundleConfigAsCjs --environment NODE_ENV:production"
228
+ "build": "rollup --config rollup.config.js --bundleConfigAsCjs --environment NODE_ENV:production && cp src/variables.css dist/variables.css"
228
229
  },
229
230
  "bugs": {
230
231
  "url": "https://github.com/Darginec05/Yoopta-Editor/issues"