UNPKG

@blocknote/shadcn

Version:

A "Notion-style" block-based extensible text editor built on top of Prosemirror and Tiptap.

3 lines (2 loc) 38.6 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("@blocknote/core"),b=require("@blocknote/react"),l=require("react"),B=require("react-hook-form"),G=require("@radix-ui/react-avatar"),U=require("clsx"),H=require("tailwind-merge"),q=require("@radix-ui/react-slot"),R=require("class-variance-authority"),K=require("@radix-ui/react-dropdown-menu"),N=require("lucide-react"),Q=require("@radix-ui/react-label"),W=require("@radix-ui/react-popover"),Z=require("@radix-ui/react-select"),J=require("@radix-ui/react-tabs"),X=require("@radix-ui/react-toggle"),Y=require("@radix-ui/react-tooltip");function C(e){if(e&&typeof e=="object"&&"default"in e)return e;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(a,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return a.default=e,Object.freeze(a)}const F=C(l),I=C(G),w=C(K),ee=C(Q),E=C(W),h=C(Z),T=C(J),te=C(X),y=C(Y);function d(...e){return H.twMerge(U.clsx(e))}function ae({className:e,...a}){return t.jsx(I.Root,{"data-slot":"avatar",className:d("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...a})}function ne({className:e,...a}){return t.jsx(I.Image,{"data-slot":"avatar-image",className:d("aspect-square size-full",e),...a})}function oe({className:e,...a}){return t.jsx(I.Fallback,{"data-slot":"avatar-fallback",className:d("bg-muted flex size-full items-center justify-center rounded-full",e),...a})}const re=R.cva("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function se({className:e,variant:a,asChild:n=!1,...o}){const r=n?q.Slot:"span";return t.jsx(r,{"data-slot":"badge",className:d(re({variant:a}),e),...o})}const ie=R.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function de({className:e,variant:a,size:n,asChild:o=!1,...r}){const s=o?q.Slot:"button";return t.jsx(s,{"data-slot":"button",className:d(ie({variant:a,size:n,className:e})),...r})}function ce({className:e,...a}){return t.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...a})}function le({className:e,...a}){return t.jsx("div",{"data-slot":"card-content",className:d("px-6",e),...a})}function ue({...e}){return t.jsx(w.Root,{"data-slot":"dropdown-menu",...e})}function me({...e}){return t.jsx(w.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function pe({className:e,sideOffset:a=4,...n}){return t.jsx(w.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,className:d("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md",e),...n})}function fe({className:e,inset:a,variant:n="default",...o}){return t.jsx(w.Item,{"data-slot":"dropdown-menu-item","data-inset":a,"data-variant":n,className:d("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=text-])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...o})}function ge({className:e,children:a,checked:n,...o}){return t.jsxs(w.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:d("focus:bg-accent focus:text-accent-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-8 pr-2 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),checked:n,...o,children:[t.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:t.jsx(w.ItemIndicator,{children:t.jsx(N.CheckIcon,{className:"size-4"})})}),a]})}function ve({className:e,inset:a,...n}){return t.jsx(w.Label,{"data-slot":"dropdown-menu-label","data-inset":a,className:d("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...n})}function xe({className:e,...a}){return t.jsx(w.Separator,{"data-slot":"dropdown-menu-separator",className:d("bg-border -mx-1 my-1 h-px",e),...a})}function be({...e}){return t.jsx(w.Sub,{"data-slot":"dropdown-menu-sub",...e})}function he({className:e,inset:a,children:n,...o}){return t.jsxs(w.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":a,className:d("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground outline-hidden flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm data-[inset]:pl-8",e),...o,children:[n,t.jsx(N.ChevronRightIcon,{className:"ml-auto size-4"})]})}function we({className:e,...a}){return t.jsx(w.SubContent,{"data-slot":"dropdown-menu-sub-content",className:d("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-lg",e),...a})}function je({className:e,...a}){return t.jsx(ee.Root,{"data-slot":"label",className:d("flex select-none items-center gap-2 text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",e),...a})}const Ce=B.FormProvider;F.createContext({});F.createContext({});function Ne({className:e,type:a,...n}){return t.jsx("input",{type:a,"data-slot":"input",className:d("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input shadow-xs flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base outline-none transition-[color,box-shadow] file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...n})}function ye({...e}){return t.jsx(E.Root,{"data-slot":"popover",...e})}function Se({...e}){return t.jsx(E.Trigger,{"data-slot":"popover-trigger",...e})}function Te({className:e,align:a="center",sideOffset:n=4,...o}){return t.jsx(E.Content,{"data-slot":"popover-content",align:a,sideOffset:n,className:d("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-popover-content-transform-origin) outline-hidden z-50 w-72 rounded-md border p-4 shadow-md",e),...o})}function ke({...e}){return t.jsx(h.Root,{"data-slot":"select",...e})}function Me({...e}){return t.jsx(h.Value,{"data-slot":"select-value",...e})}function De({className:e,size:a="default",children:n,...o}){return t.jsxs(h.Trigger,{"data-slot":"select-trigger","data-size":a,className:d("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*=text-])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 shadow-xs flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-md border bg-transparent px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...o,children:[n,t.jsx(h.Icon,{asChild:!0,children:t.jsx(N.ChevronDownIcon,{className:"size-4 opacity-50"})})]})}function ze({className:e,children:a,position:n="popper",...o}){return t.jsxs(h.Content,{"data-slot":"select-content",className:d("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-(--radix-select-content-available-height) origin-(--radix-select-content-transform-origin) relative z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...o,children:[t.jsx(Ie,{}),t.jsx(h.Viewport,{className:d("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),t.jsx(Ee,{})]})}function Re({className:e,children:a,...n}){return t.jsxs(h.Item,{"data-slot":"select-item",className:d("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*=text-])]:text-muted-foreground outline-hidden *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-8 text-sm data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...n,children:[t.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:t.jsx(h.ItemIndicator,{children:t.jsx(N.CheckIcon,{className:"size-4"})})}),t.jsx(h.ItemText,{children:a})]})}function Ie({className:e,...a}){return t.jsx(h.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:d("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(N.ChevronUpIcon,{className:"size-4"})})}function Ee({className:e,...a}){return t.jsx(h.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:d("flex cursor-default items-center justify-center py-1",e),...a,children:t.jsx(N.ChevronDownIcon,{className:"size-4"})})}function Pe({className:e,...a}){return t.jsx("div",{"data-slot":"skeleton",className:d("bg-accent animate-pulse rounded-md",e),...a})}function _e({className:e,...a}){return t.jsx(T.Root,{"data-slot":"tabs",className:d("flex flex-col gap-2",e),...a})}function Be({className:e,...a}){return t.jsx(T.List,{"data-slot":"tabs-list",className:d("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...a})}function qe({className:e,...a}){return t.jsx(T.Trigger,{"data-slot":"tabs-trigger",className:d("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-transparent px-2 py-1 text-sm font-medium transition-[color,box-shadow] focus-visible:outline-1 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...a})}function Fe({className:e,...a}){return t.jsx(T.Content,{"data-slot":"tabs-content",className:d("flex-1 outline-none",e),...a})}const Le=R.cva("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium hover:bg-muted hover:text-muted-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] outline-none transition-[color,box-shadow] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive whitespace-nowrap",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 px-2 min-w-9",sm:"h-8 px-1.5 min-w-8",lg:"h-10 px-2.5 min-w-10"}},defaultVariants:{variant:"default",size:"default"}});function Ve({className:e,variant:a,size:n,...o}){return t.jsx(te.Root,{"data-slot":"toggle",className:d(Le({variant:a,size:n,className:e})),...o})}function L({delayDuration:e=0,...a}){return t.jsx(y.Provider,{"data-slot":"tooltip-provider",delayDuration:e,...a})}function Ae({...e}){return t.jsx(L,{children:t.jsx(y.Root,{"data-slot":"tooltip",...e})})}function Oe({...e}){return t.jsx(y.Trigger,{"data-slot":"tooltip-trigger",...e})}function $e({className:e,sideOffset:a=0,children:n,...o}){return t.jsxs(y.Content,{"data-slot":"tooltip-content",sideOffset:a,className:d("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-tooltip-content-transform-origin) z-50 w-fit text-balance rounded-md px-3 py-1.5 text-xs",e),...o,children:[n,t.jsx(y.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})}const V={Avatar:{Avatar:ae,AvatarFallback:oe,AvatarImage:ne},Badge:{Badge:se},Button:{Button:de},Card:{Card:ce,CardContent:le},DropdownMenu:{DropdownMenu:ue,DropdownMenuCheckboxItem:ge,DropdownMenuContent:pe,DropdownMenuItem:fe,DropdownMenuLabel:ve,DropdownMenuSeparator:xe,DropdownMenuSub:be,DropdownMenuSubContent:we,DropdownMenuSubTrigger:he,DropdownMenuTrigger:me},Form:{Form:Ce},Input:{Input:Ne},Label:{Label:je},Popover:{Popover:ye,PopoverContent:Te,PopoverTrigger:Se},Select:{Select:ke,SelectContent:ze,SelectItem:Re,SelectTrigger:De,SelectValue:Me},Skeleton:{Skeleton:Pe},Tabs:{Tabs:_e,TabsContent:Fe,TabsList:Be,TabsTrigger:qe},Toggle:{Toggle:Ve},Tooltip:{Tooltip:Ae,TooltipContent:$e,TooltipProvider:L,TooltipTrigger:Oe}},P=l.createContext(void 0);function g(){return l.useContext(P)}const Ge=e=>{const{children:a,...n}=e;p.assertEmpty(n);const o=g(),r=B.useForm();return t.jsx(o.Form.Form,{...r,children:a})},Ue=l.forwardRef((e,a)=>{const{className:n,name:o,label:r,variant:s,icon:i,value:u,autoFocus:m,placeholder:c,disabled:f,onKeyDown:v,onChange:x,onSubmit:j,autoComplete:S,rightSection:k,...$}=e;p.assertEmpty($);const _=g();return t.jsxs("div",{className:d(n,"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50","text-foreground items-center gap-2"),children:[i,t.jsxs("div",{className:"flex-1",children:[r&&t.jsx(_.Label.Label,{htmlFor:r,children:r}),t.jsx(_.Input.Input,{className:d(n,"h-auto border-none p-0"),id:r,name:o,autoFocus:m,placeholder:c,disabled:f,value:u,onKeyDown:v,onChange:x,onSubmit:j,ref:a})]}),k]})}),He=e=>l.forwardRef((a,n)=>t.jsx(e,{onPointerDown:o=>{o.nativeEvent.fakeEvent||(o.ctrlKey=!0)},onPointerUp:o=>{const r=new PointerEvent("pointerdown",o.nativeEvent);r.fakeEvent=!0,o.target.dispatchEvent(r)},...a,ref:n})),Ke=e=>{const{children:a,onOpenChange:n,position:o,sub:r,...s}=e;p.assertEmpty(s);const i=g();return r?t.jsx(i.DropdownMenu.DropdownMenuSub,{onOpenChange:n,children:a}):t.jsx(i.DropdownMenu.DropdownMenu,{modal:!1,onOpenChange:n,children:a})},Qe=e=>{const{children:a,sub:n,...o}=e;p.assertEmpty(o);const r=g(),s=l.useMemo(()=>He(r.DropdownMenu.DropdownMenuTrigger),[r.DropdownMenu.DropdownMenuTrigger]);return n?t.jsx(r.DropdownMenu.DropdownMenuSubTrigger,{children:a}):t.jsx(s,{asChild:!0,...o,children:a})},We=l.forwardRef((e,a)=>{const{className:n,children:o,sub:r,...s}=e;p.assertEmpty(s);const i=g();return r?t.jsx(i.DropdownMenu.DropdownMenuSubContent,{className:n,ref:a,children:o}):t.jsx(i.DropdownMenu.DropdownMenuContent,{className:n,ref:a,children:o})}),Ze=l.forwardRef((e,a)=>{const{className:n,children:o,icon:r,checked:s,subTrigger:i,onClick:u,...m}=e;p.assertEmpty(m);const c=g();return i?t.jsxs(t.Fragment,{children:[r,o]}):s!==void 0?t.jsxs(c.DropdownMenu.DropdownMenuCheckboxItem,{className:d(n,"gap-1",s?"":"px-2"),ref:a,checked:s,onClick:u,...m,children:[r,o]}):t.jsxs(c.DropdownMenu.DropdownMenuItem,{className:n,ref:a,onClick:u,...m,children:[r,o,i&&t.jsx(N.ChevronRight,{className:"ml-auto h-4 w-4"})]})}),Je=l.forwardRef((e,a)=>{const{className:n,...o}=e;p.assertEmpty(o);const r=g();return t.jsx(r.DropdownMenu.DropdownMenuSeparator,{className:n,ref:a})}),Xe=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;p.assertEmpty(r);const s=g();return t.jsx(s.DropdownMenu.DropdownMenuLabel,{className:n,ref:a,children:o})}),Ye=l.forwardRef((e,a)=>{const{className:n,children:o,icon:r,onClick:s,onDragEnd:i,onDragStart:u,draggable:m,label:c,...f}=e;p.assertEmpty(f,!1);const v=g();return t.jsxs(v.Button.Button,{variant:"ghost",className:d(n,"text-gray-400"),ref:a,"aria-label":c,onClick:s,onDragStart:u,onDragEnd:i,draggable:m,...f,children:[r,o]})}),et=l.forwardRef((e,a)=>{const{className:n,tabs:o,defaultOpenTab:r,openTab:s,setOpenTab:i,loading:u,...m}=e;p.assertEmpty(m);const c=g();return t.jsxs(c.Tabs.Tabs,{className:d(n,"bg-popover max-w-screen rounded-lg p-2"),ref:a,value:s,defaultValue:r,onValueChange:i,children:[t.jsx(c.Tabs.TabsList,{children:o.map(f=>t.jsx(c.Tabs.TabsTrigger,{value:f.name,children:f.name},f.name))}),o.map(f=>t.jsx(c.Tabs.TabsContent,{value:f.name,children:t.jsx(c.Card.Card,{children:t.jsx(c.Card.CardContent,{className:"p-4",children:f.tabPanel})})},f.name))]})}),tt=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;return p.assertEmpty(r),t.jsx("div",{className:d(n,"flex flex-col items-start justify-center gap-2"),ref:a,children:o})}),at=l.forwardRef((e,a)=>{const{className:n,value:o,placeholder:r,onKeyDown:s,onChange:i,...u}=e;p.assertEmpty(u);const m=g();return t.jsx(m.Input.Input,{"data-test":"embed-input",className:d(n,"w-80 max-w-full"),ref:a,value:o,placeholder:r,onKeyDown:s,onChange:i})}),nt=e=>{const{children:a,open:n,onOpenChange:o,position:r,...s}=e;p.assertEmpty(s);const i=g();return t.jsx(i.Popover.Popover,{open:n,onOpenChange:o,children:a})},ot=l.forwardRef((e,a)=>{const{children:n,...o}=e;p.assertEmpty(o);const r=g();return t.jsx(r.Popover.PopoverTrigger,{ref:a,asChild:!0,children:n})}),rt=l.forwardRef((e,a)=>{const{className:n,variant:o,children:r,...s}=e;p.assertEmpty(s);const i=g();return t.jsx(i.Popover.PopoverContent,{sideOffset:8,className:d(n,"z-[10000] flex flex-col gap-2",o==="panel-popover"?"w-fit max-w-none border-none p-0 shadow-none":""),ref:a,children:r})}),st=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;return p.assertEmpty(r,!1),t.jsx("div",{className:n,ref:a,...r,children:o})}),it=l.forwardRef((e,a)=>{const{className:n,children:o,icon:r,onClick:s,onDragEnd:i,onDragStart:u,draggable:m,label:c,...f}=e;p.assertEmpty(f,!1);const v=g();return t.jsxs(v.Button.Button,{variant:"ghost",className:d(n,"text-gray-400"),ref:a,"aria-label":c,onClick:s,onDragStart:u,onDragEnd:i,draggable:m,...f,children:[r,o]})}),dt=l.forwardRef((e,a)=>{const{className:n,children:o,id:r,columns:s,...i}=e;return p.assertEmpty(i),t.jsx("div",{className:d("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md","grid",n),style:{gridTemplateColumns:`repeat(${s}, 1fr)`},ref:a,id:r,role:"grid",children:o})}),ct=l.forwardRef((e,a)=>{const{className:n,children:o,columns:r,...s}=e;return p.assertEmpty(s),t.jsx("div",{className:n,style:{gridColumn:`1 / ${r+1}`},ref:a,children:o})}),lt=l.forwardRef((e,a)=>{const{className:n,children:o,id:r,...s}=e;return p.assertEmpty(s),t.jsx("div",{id:r,role:"listbox",className:d("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin) z-50 min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border p-1 shadow-md",n),ref:a,children:o})}),ut=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;return p.assertEmpty(r),t.jsx("div",{className:d("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=text-])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0","hover:bg-accent hover:text-accent-foreground data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive","aria-selected:bg-accent aria-selected:text-accent-foreground data-[variant=destructive]:aria-selected:bg-destructive/10 dark:data-[variant=destructive]:aria-selected:bg-destructive/20 data-[variant=destructive]:aria-selected:text-destructive",n),ref:a,children:t.jsx("div",{children:o})})}),mt=l.forwardRef((e,a)=>{const n=g(),{className:o,item:r,isSelected:s,onClick:i,id:u,...m}=e;p.assertEmpty(m);const c=l.useRef(null);return l.useEffect(()=>{if(!c.current||!s)return;const f=b.elementOverflow(c.current,c.current.closest(".bn-suggestion-menu, #ai-suggestion-menu"));f==="top"?c.current.scrollIntoView(!0):f==="bottom"&&c.current.scrollIntoView(!1)},[s]),t.jsxs("div",{className:d("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=text-])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0","hover:bg-accent hover:text-accent-foreground data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive","aria-selected:bg-accent aria-selected:text-accent-foreground data-[variant=destructive]:aria-selected:bg-destructive/10 dark:data-[variant=destructive]:aria-selected:bg-destructive/20 data-[variant=destructive]:aria-selected:text-destructive",e.item.size==="small"?"gap-3 py-1":"",o),"data-highlighted":!0,ref:b.mergeRefs([a,c]),id:u,onMouseDown:f=>f.preventDefault(),onClick:i,role:"option","aria-selected":s||void 0,children:[r.icon&&t.jsx("div",{className:d("p-3",e.item.size==="small"?"p-0":"",o),"data-position":"left",children:r.icon}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:d("text-base",e.item.size==="small"?"text-sm":"",o),children:r.title}),t.jsx("div",{className:d("text-xs",e.item.size==="small"?"hidden":"",o),children:r.subtext})]}),r.badge&&t.jsx("div",{"data-position":"right",className:"text-xs",children:t.jsx(n.Badge.Badge,{variant:"secondary",children:r.badge})})]})}),pt=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;return p.assertEmpty(r),t.jsx("div",{className:d("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",n),ref:a,children:o})}),ft=l.forwardRef((e,a)=>{const{className:n,...o}=e;return p.assertEmpty(o),t.jsx("div",{className:d(n,"animate-spin"),ref:a,children:t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",fill:"#e8eaed",children:t.jsx("path",{d:"M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q17 0 28.5 11.5T520-840q0 17-11.5 28.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160q133 0 226.5-93.5T800-480q0-17 11.5-28.5T840-520q17 0 28.5 11.5T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Z"})})})}),gt=l.forwardRef((e,a)=>{const{className:n,children:o,onMouseDown:r,onClick:s,...i}=e;p.assertEmpty(i,!1);const u=g();return t.jsx(u.Button.Button,{variant:"ghost",className:d(n,"h-full w-full p-0 text-gray-400",n!=null&&n.includes("extend-button-add-remove-columns")?"ml-1":"mt-1",n!=null&&n.includes("extend-button-editing")?"bg-accent text-accent-foreground":""),ref:a,onClick:s,onMouseDown:r,...i,children:o})}),vt=l.forwardRef((e,a)=>{const{className:n,children:o,draggable:r,onDragStart:s,onDragEnd:i,style:u,label:m,...c}=e;p.assertEmpty(c,!1);const f=g();return t.jsx(f.Button.Button,{variant:"ghost",className:d(n,"h-fit w-fit p-0 text-gray-400"),ref:a,"aria-label":m,draggable:r,onDragStart:s,onDragEnd:i,style:u,...c,children:o})}),M=l.forwardRef((e,a)=>{const{className:n,children:o,onMouseEnter:r,onMouseLeave:s,variant:i,...u}=e;p.assertEmpty(u);const m=g();return t.jsx(m.Tooltip.TooltipProvider,{delayDuration:0,children:t.jsx("div",{className:d(n,"bg-popover text-popover-foreground flex h-fit gap-1 rounded-lg border p-1 shadow-md",i==="action-toolbar"?"w-fit":""),ref:a,onMouseEnter:r,onMouseLeave:s,children:o})})}),D=l.forwardRef((e,a)=>{const{className:n,children:o,mainTooltip:r,secondaryTooltip:s,icon:i,isSelected:u,isDisabled:m,onClick:c,label:f,variant:v,...x}=e;p.assertEmpty(x,!1);const j=g(),S=u===void 0?t.jsxs(j.Button.Button,{className:d(n,v==="compact"?"h-6 min-w-6 p-0":""),variant:"ghost",size:v==="compact"?"sm":"default",disabled:m,onClick:c,ref:a,"aria-label":f,...x,children:[i,o]}):t.jsxs(j.Toggle.Toggle,{className:d(n,"data-[state=open]:bg-accent data-[state=closed]:text-accent-foreground",v==="compact"?"h-6 min-w-6 p-0":""),size:v==="compact"?"sm":"default","aria-label":f,onClick:c,pressed:u,disabled:m,"data-state":u?"on":"off","data-disabled":m,ref:a,...x,children:[i,o]});return t.jsxs(j.Tooltip.Tooltip,{children:[t.jsx(j.Tooltip.TooltipTrigger,{asChild:!0,children:S}),t.jsxs(j.Tooltip.TooltipContent,{className:"flex flex-col items-center whitespace-pre-wrap",children:[t.jsx("span",{children:r}),s&&t.jsx("span",{children:s})]})]})}),z=l.forwardRef((e,a)=>{const{className:n,items:o,isDisabled:r,...s}=e;p.assertEmpty(s);const i=g(),u=c=>t.jsxs("div",{className:"flex items-center gap-1",children:[c.icon,c.text]}),m=o.filter(c=>c.isSelected)[0];return m?t.jsxs(i.Select.Select,{value:m.text,onValueChange:c=>{var f,v;return(v=(f=o.find(x=>x.text===c)).onClick)==null?void 0:v.call(f)},disabled:r,children:[t.jsx(i.Select.SelectTrigger,{className:"border-none",children:t.jsx(i.Select.SelectValue,{})}),t.jsx(i.Select.SelectContent,{className:n,ref:a,children:o.map(c=>t.jsx(i.Select.SelectItem,{disabled:c.isDisabled,value:c.text,children:t.jsx(u,{...c})},c.text))})]}):null}),xt=l.forwardRef((e,a)=>{const{className:n,children:o,selected:r,headerText:s,onFocus:i,onBlur:u,tabIndex:m,...c}=e;p.assertEmpty(c);const f=g();return t.jsxs(f.Card.Card,{className:d(n,"w-[300px]",r?"bg-accent text-accent-foreground":""),onFocus:i,onBlur:u,tabIndex:m,ref:a,children:[s&&t.jsx("div",{className:"px-4 pt-4 text-sm italic",children:s}),o]})}),bt=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;return p.assertEmpty(r),t.jsx("div",{className:d(n,"p-4",n!=null&&n.includes("thread-comments")?"flex flex-col gap-6 border-b":""),ref:a,children:o})}),ht=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;p.assertEmpty(r,!1);const s=g();return t.jsx(s.Button.Button,{className:d(n,"text-foreground w-fit bg-transparent p-0 hover:bg-transparent"),ref:a,children:o})}),wt=l.forwardRef((e,a)=>{const{authorInfo:n,timeString:o,edited:r,...s}=e,i=b.useDictionary();p.assertEmpty(s,!1);const u=g();return n==="loading"?t.jsxs("div",{className:"flex flex-row flex-nowrap items-center gap-4",children:[t.jsx(u.Skeleton.Skeleton,{className:"size-7 animate-pulse rounded-full bg-neutral-400"}),t.jsx(u.Skeleton.Skeleton,{className:"h-3 w-32 animate-pulse rounded-full bg-neutral-400"})]}):t.jsxs("div",{className:"flex flex-row flex-nowrap items-center gap-4",children:[t.jsxs(u.Avatar.Avatar,{children:[t.jsx(u.Avatar.AvatarImage,{src:n.avatarUrl,alt:n.username,className:"h-7 rounded-full"}),t.jsx(u.Avatar.AvatarFallback,{children:n.username[0]})]}),t.jsxs("div",{className:"flex flex-row flex-nowrap items-center gap-2",children:[t.jsx("span",{className:"text-sm font-bold",children:n.username}),t.jsxs("span",{className:"text-xs",children:[o," ",r&&`(${i.comments.edited})`]})]})]})}),jt=l.forwardRef((e,a)=>{const{className:n,showActions:o,authorInfo:r,timeString:s,actions:i,edited:u,emojiPickerOpen:m,children:c,...f}=e;p.assertEmpty(f);const[v,x]=l.useState(!1),{focused:j,ref:S}=b.useFocusWithin(),k=i&&(o===!0||o===void 0||o==="hover"&&v||j);return t.jsxs("div",{ref:a,className:d(n,"relative flex flex-col gap-2"),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[k?t.jsx("div",{className:"absolute right-0 top-0 z-10",ref:S,children:i}):null,t.jsx(wt,{...e}),c]})}),Ct=l.forwardRef((e,a)=>{const{className:n,onFocus:o,onBlur:r,autoFocus:s,editor:i,editable:u,...m}=e;p.assertEmpty(m);const c=b.useBlockNoteContext();return t.jsx(O,{autoFocus:s,className:d(n,""),theme:c==null?void 0:c.colorSchemePreference,editor:e.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:u,ref:a,onFocus:o,onBlur:r,children:t.jsx(b.FormattingToolbarController,{formattingToolbar:Nt})})}),Nt=()=>{const e=b.getFormattingToolbarItems([]).filter(a=>a.key!=="nestBlockButton"&&a.key!=="unnestBlockButton");return t.jsx(b.FormattingToolbar,{blockTypeSelectItems:[],children:e})},yt=l.forwardRef((e,a)=>{const{className:n,text:o,icon:r,isSelected:s,mainTooltip:i,secondaryTooltip:u,onClick:m,onMouseEnter:c,...f}=e;p.assertEmpty(f,!1);const v=g(),x=t.jsxs(v.Button.Button,{variant:s?"secondary":"outline",className:d(n,"flex h-7 items-center gap-1 rounded-full px-2.5"),onClick:m,onMouseEnter:c,ref:a,children:[t.jsx("span",{children:r}),t.jsx("span",{children:o})]});return i?t.jsxs(v.Tooltip.Tooltip,{children:[t.jsx(v.Tooltip.TooltipTrigger,{asChild:!0,children:x}),t.jsxs(v.Tooltip.TooltipContent,{className:"flex flex-col items-center whitespace-pre-wrap",children:[t.jsx("span",{children:i}),u&&t.jsx("span",{children:u})]})]}):x}),St=l.forwardRef((e,a)=>{const{className:n,children:o,...r}=e;p.assertEmpty(r);const s=g();return t.jsx(s.Tooltip.TooltipProvider,{delayDuration:0,children:t.jsx("div",{className:d(n,"flex w-full flex-row flex-wrap gap-1"),ref:a,children:o})})}),Tt=l.forwardRef((e,a)=>{const{className:n,children:o,onClick:r,label:s,...i}=e;p.assertEmpty(i);const u=g();return t.jsx(u.Button.Button,{type:"submit",className:n,"aria-label":s,ref:a,onClick:r,children:o})}),kt=l.forwardRef((e,a)=>{const{className:n,accept:o,value:r,placeholder:s,onChange:i,...u}=e;p.assertEmpty(u);const m=g();return t.jsx(m.Input.Input,{type:"file",className:n,ref:a,accept:o,value:r?r.name:void 0,onChange:async c=>i==null?void 0:i(c.target.files[0]),placeholder:s})}),Mt=l.forwardRef((e,a)=>{const{className:n,isSelected:o,onClick:r,item:s,id:i,...u}=e;p.assertEmpty(u);const m=l.useRef(null);return l.useEffect(()=>{if(!m.current||!o)return;const c=b.elementOverflow(m.current,m.current.closest(".bn-grid-suggestion-menu"));c==="top"?m.current.scrollIntoView(!0):c==="bottom"&&m.current.scrollIntoView(!1)},[o]),t.jsx("div",{className:d("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*=text-])]:text-muted-foreground outline-hidden relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm data-[disabled]:pointer-events-none data-[inset]:pl-8 data-[disabled]:opacity-50 [&_svg:not([class*=size-])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0","hover:bg-accent hover:text-accent-foreground data-[variant=destructive]:hover:bg-destructive/10 dark:data-[variant=destructive]:hover:bg-destructive/20 data-[variant=destructive]:hover:text-destructive","aria-selected:bg-accent aria-selected:text-accent-foreground data-[variant=destructive]:aria-selected:bg-destructive/10 dark:data-[variant=destructive]:aria-selected:bg-destructive/20 data-[variant=destructive]:aria-selected:text-destructive","text-lg!",n),ref:b.mergeRefs([a,m]),id:i,role:"option",onClick:r,"aria-selected":o||void 0,children:s.icon})}),Dt=l.forwardRef((e,a)=>{const{className:n,children:o,columns:r,...s}=e;return p.assertEmpty(s),t.jsx("div",{className:n,style:{gridColumn:`1 / ${r+1}`},ref:a,children:o})}),A={FormattingToolbar:{Root:M,Button:D,Select:z},FilePanel:{Root:et,Button:Tt,FileInput:kt,TabPanel:tt,TextInput:at},LinkToolbar:{Root:M,Button:D,Select:z},SideMenu:{Root:st,Button:it},SuggestionMenu:{Root:lt,Item:mt,EmptyItem:ut,Label:pt,Loader:ft},GridSuggestionMenu:{Root:dt,Item:Mt,EmptyItem:ct,Loader:Dt},TableHandle:{Root:vt,ExtendButton:gt},Comments:{Comment:jt,Editor:Ct,Card:xt,CardSection:bt,ExpandSectionsPrompt:ht},Generic:{Badge:{Root:yt,Group:St},Toolbar:{Root:M,Button:D,Select:z},Form:{Root:Ge,TextInput:Ue},Menu:{Root:Ke,Trigger:Qe,Dropdown:We,Divider:Je,Label:Xe,Item:Ze,Button:Ye},Popover:{Root:nt,Trigger:ot,Content:rt}}},O=e=>{const{className:a,shadCNComponents:n,...o}=e,r=l.useMemo(()=>({...V,...n}),[n]);return t.jsx(P.Provider,{value:r,children:t.jsx(b.ComponentsContext.Provider,{value:A,children:t.jsx(b.BlockNoteViewRaw,{className:p.mergeCSSClasses("bn-shadcn",a||""),...o})})})};exports.BlockNoteView=O;exports.ShadCNComponentsContext=P;exports.ShadCNDefaultComponents=V;exports.components=A;exports.useShadCNComponentsContext=g; //# sourceMappingURL=blocknote-shadcn.cjs.map