UNPKG

@blocknote/shadcn

Version:

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

3 lines (2 loc) 30.1 kB
(function(m,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react/jsx-runtime"),require("@blocknote/core"),require("@blocknote/react"),require("react"),require("react-hook-form"),require("class-variance-authority"),require("clsx"),require("tailwind-merge"),require("@radix-ui/react-slot"),require("@radix-ui/react-dropdown-menu"),require("lucide-react"),require("@radix-ui/react-label"),require("@radix-ui/react-popover"),require("@radix-ui/react-select"),require("@radix-ui/react-tabs"),require("@radix-ui/react-toggle"),require("@radix-ui/react-tooltip")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@blocknote/core","@blocknote/react","react","react-hook-form","class-variance-authority","clsx","tailwind-merge","@radix-ui/react-slot","@radix-ui/react-dropdown-menu","lucide-react","@radix-ui/react-label","@radix-ui/react-popover","@radix-ui/react-select","@radix-ui/react-tabs","@radix-ui/react-toggle","@radix-ui/react-tooltip"],o):(m=typeof globalThis<"u"?globalThis:m||self,o(m["blocknote-shadcn"]={},m.jsxRuntime,m.core,m.react,m.React,m.reactHookForm,m.classVarianceAuthority,m.clsx,m.tailwindMerge,m.reactSlot,m.DropdownMenuPrimitive,m.lucideReact,m.LabelPrimitive,m.PopoverPrimitive,m.SelectPrimitive,m.TabsPrimitive,m.TogglePrimitive,m.TooltipPrimitive))})(this,function(m,o,p,T,c,k,I,be,le,B,ce,N,pe,fe,ue,me,ge,he){"use strict";function C(n){if(n&&typeof n=="object"&&"default"in n)return n;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const l=C(c),v=C(ce),L=C(pe),P=C(fe),w=C(ue),S=C(me),z=C(ge),M=C(he),ve=le.extendTailwindMerge({prefix:"bn-"});function i(...n){return ve(be.clsx(n))}const we=I.cva("bn-inline-flex bn-items-center bn-rounded-full bn-border bn-px-2.5 bn-py-0.5 bn-text-xs bn-font-semibold bn-transition-colors focus:bn-outline-none focus:bn-ring-2 focus:bn-ring-ring focus:bn-ring-offset-2",{variants:{variant:{default:"bn-border-transparent bn-bg-primary bn-text-primary-foreground hover:bn-bg-primary/80",secondary:"bn-border-transparent bn-bg-secondary bn-text-secondary-foreground hover:bn-bg-secondary/80",destructive:"bn-border-transparent bn-bg-destructive bn-text-destructive-foreground hover:bn-bg-destructive/80",outline:"bn-text-foreground"}},defaultVariants:{variant:"default"}});function xe({className:n,variant:t,...e}){return o.jsx("div",{className:i(we({variant:t}),n),...e})}const ye=I.cva("bn-inline-flex bn-items-center bn-justify-center bn-whitespace-nowrap bn-rounded-md bn-text-sm bn-font-medium bn-ring-offset-background bn-transition-colors focus-visible:bn-outline-none focus-visible:bn-ring-2 focus-visible:bn-ring-ring focus-visible:bn-ring-offset-2 disabled:bn-pointer-events-none disabled:bn-opacity-50",{variants:{variant:{default:"bn-bg-primary bn-text-primary-foreground hover:bn-bg-primary/90",destructive:"bn-bg-destructive bn-text-destructive-foreground hover:bn-bg-destructive/90",outline:"bn-border bn-border-input bn-bg-background hover:bn-bg-accent hover:bn-text-accent-foreground",secondary:"bn-bg-secondary bn-text-secondary-foreground hover:bn-bg-secondary/80",ghost:"hover:bn-bg-accent hover:bn-text-accent-foreground",link:"bn-text-primary bn-underline-offset-4 hover:bn-underline"},size:{default:"bn-h-10 bn-px-4 bn-py-2",sm:"bn-h-9 bn-rounded-md bn-px-3",lg:"bn-h-11 bn-rounded-md bn-px-8",icon:"bn-h-10 bn-w-10"}},defaultVariants:{variant:"default",size:"default"}}),j=l.forwardRef(({className:n,variant:t,size:e,asChild:r=!1,...a},s)=>{const d=r?B.Slot:"button";return o.jsx(d,{className:i(ye({variant:t,size:e,className:n})),ref:s,...a})});j.displayName="Button";const V=l.forwardRef(({className:n,...t},e)=>o.jsx("div",{ref:e,className:i("bn-rounded-lg bn-border bn-bg-card bn-text-card-foreground bn-shadow-sm",n),...t}));V.displayName="Card";const Ne=l.forwardRef(({className:n,...t},e)=>o.jsx("div",{ref:e,className:i("bn-flex bn-flex-col bn-space-y-1.5 bn-p-6",n),...t}));Ne.displayName="CardHeader";const Ce=l.forwardRef(({className:n,...t},e)=>o.jsx("h3",{ref:e,className:i("bn-text-2xl bn-font-semibold bn-leading-none bn-tracking-tight",n),...t}));Ce.displayName="CardTitle";const Se=l.forwardRef(({className:n,...t},e)=>o.jsx("p",{ref:e,className:i("bn-text-sm bn-text-muted-foreground",n),...t}));Se.displayName="CardDescription";const q=l.forwardRef(({className:n,...t},e)=>o.jsx("div",{ref:e,className:i("bn-p-6 bn-pt-0",n),...t}));q.displayName="CardContent";const Te=l.forwardRef(({className:n,...t},e)=>o.jsx("div",{ref:e,className:i("bn-flex bn-items-center bn-p-6 bn-pt-0",n),...t}));Te.displayName="CardFooter";const Me=v.Root,De=v.Trigger,Ie=v.Sub,_=l.forwardRef(({className:n,inset:t,children:e,...r},a)=>o.jsxs(v.SubTrigger,{ref:a,className:i("bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-px-2 bn-py-1.5 bn-text-sm bn-outline-none focus:bn-bg-accent data-[state=open]:bn-bg-accent",t&&"bn-pl-8",n),...r,children:[e,o.jsx(N.ChevronRight,{className:"bn-ml-auto bn-h-4 bn-w-4"})]}));_.displayName=v.SubTrigger.displayName;const $=l.forwardRef(({className:n,...t},e)=>o.jsx(v.SubContent,{ref:e,className:i("bn-z-50 bn-min-w-[8rem] bn-overflow-hidden bn-rounded-md bn-border bn-bg-popover bn-p-1 bn-text-popover-foreground bn-shadow-lg data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",n),...t}));$.displayName=v.SubContent.displayName;const O=l.forwardRef(({className:n,sideOffset:t=4,...e},r)=>o.jsx(v.Content,{ref:r,sideOffset:t,className:i("bn-z-50 bn-min-w-[8rem] bn-overflow-hidden bn-rounded-md bn-border bn-bg-popover bn-p-1 bn-text-popover-foreground bn-shadow-md data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",n),...e}));O.displayName=v.Content.displayName;const G=l.forwardRef(({className:n,inset:t,...e},r)=>o.jsx(v.Item,{ref:r,className:i("bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-px-2 bn-py-1.5 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",t&&"bn-pl-8",n),...e}));G.displayName=v.Item.displayName;const U=l.forwardRef(({className:n,children:t,checked:e,...r},a)=>o.jsxs(v.CheckboxItem,{ref:a,className:i("bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",n),checked:e,...r,children:[o.jsx("span",{className:"bn-absolute bn-left-2 bn-flex bn-h-3.5 bn-w-3.5 bn-items-center bn-justify-center",children:o.jsx(v.ItemIndicator,{children:o.jsx(N.Check,{className:"bn-h-4 bn-w-4"})})}),t]}));U.displayName=v.CheckboxItem.displayName;const Pe=l.forwardRef(({className:n,children:t,...e},r)=>o.jsxs(v.RadioItem,{ref:r,className:i("bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",n),...e,children:[o.jsx("span",{className:"bn-absolute bn-left-2 bn-flex bn-h-3.5 bn-w-3.5 bn-items-center bn-justify-center",children:o.jsx(v.ItemIndicator,{children:o.jsx(N.Circle,{className:"bn-h-2 bn-w-2 bn-fill-current"})})}),t]}));Pe.displayName=v.RadioItem.displayName;const H=l.forwardRef(({className:n,inset:t,...e},r)=>o.jsx(v.Label,{ref:r,className:i("bn-px-2 bn-py-1.5 bn-text-sm bn-font-semibold",t&&"bn-pl-8",n),...e}));H.displayName=v.Label.displayName;const K=l.forwardRef(({className:n,...t},e)=>o.jsx(v.Separator,{ref:e,className:i("bn--mx-1 bn-my-1 bn-h-px bn-bg-muted",n),...t}));K.displayName=v.Separator.displayName;const Ee=I.cva("bn-text-sm bn-font-medium bn-leading-none peer-disabled:bn-cursor-not-allowed peer-disabled:bn-opacity-70"),F=l.forwardRef(({className:n,...t},e)=>o.jsx(L.Root,{ref:e,className:i(Ee(),n),...t}));F.displayName=L.Root.displayName;const ke=k.FormProvider,Fe=l.createContext({}),E=()=>{const n=l.useContext(Fe),t=l.useContext(W),{getFieldState:e,formState:r}=k.useFormContext(),a=e(n.name,r);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:s}=t;return{id:s,name:n.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...a}},W=l.createContext({}),Be=l.forwardRef(({className:n,...t},e)=>{const r=l.useId();return o.jsx(W.Provider,{value:{id:r},children:o.jsx("div",{ref:e,className:i("bn-space-y-2",n),...t})})});Be.displayName="FormItem";const Le=l.forwardRef(({className:n,...t},e)=>{const{error:r,formItemId:a}=E();return o.jsx(F,{ref:e,className:i(r&&"bn-text-destructive",n),htmlFor:a,...t})});Le.displayName="FormLabel";const ze=l.forwardRef(({...n},t)=>{const{error:e,formItemId:r,formDescriptionId:a,formMessageId:s}=E();return o.jsx(B.Slot,{ref:t,id:r,"aria-describedby":e?`${a} ${s}`:`${a}`,"aria-invalid":!!e,...n})});ze.displayName="FormControl";const je=l.forwardRef(({className:n,...t},e)=>{const{formDescriptionId:r}=E();return o.jsx("p",{ref:e,id:r,className:i("bn-text-sm bn-text-muted-foreground",n),...t})});je.displayName="FormDescription";const Ve=l.forwardRef(({className:n,children:t,...e},r)=>{const{error:a,formMessageId:s}=E(),d=a?String(a==null?void 0:a.message):t;return d?o.jsx("p",{ref:r,id:s,className:i("bn-text-sm bn-font-medium bn-text-destructive",n),...e,children:d}):null});Ve.displayName="FormMessage";const J=l.forwardRef(({className:n,type:t,...e},r)=>o.jsx("input",{type:t,className:i("bn-flex bn-h-10 bn-w-full bn-rounded-md bn-border bn-border-input bn-bg-background bn-px-3 bn-py-2 bn-text-sm bn-ring-offset-background file:bn-border-0 file:bn-bg-transparent file:bn-text-sm file:bn-font-medium placeholder:bn-text-muted-foreground focus-visible:bn-outline-none focus-visible:bn-ring-2 focus-visible:bn-ring-ring focus-visible:bn-ring-offset-2 disabled:bn-cursor-not-allowed disabled:bn-opacity-50",n),ref:r,...e}));J.displayName="Input";const qe=P.Root,_e=P.Trigger,Q=l.forwardRef(({className:n,align:t="center",sideOffset:e=4,...r},a)=>o.jsx(P.Content,{ref:a,align:t,sideOffset:e,className:i("bn-z-50 bn-w-72 bn-rounded-md bn-border bn-bg-popover bn-p-4 bn-text-popover-foreground bn-shadow-md bn-outline-none data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",n),...r}));Q.displayName=P.Content.displayName;const $e=w.Root,Oe=w.Value,X=l.forwardRef(({className:n,children:t,...e},r)=>o.jsxs(w.Trigger,{ref:r,className:i("bn-flex bn-h-10 bn-w-full bn-items-center bn-justify-between bn-rounded-md bn-border bn-border-input bn-bg-background bn-px-3 bn-py-2 bn-text-sm bn-ring-offset-background placeholder:bn-text-muted-foreground focus:bn-outline-none focus:bn-ring-2 focus:bn-ring-ring focus:bn-ring-offset-2 disabled:bn-cursor-not-allowed disabled:bn-opacity-50 [&>span]:bn-line-clamp-1",n),...e,children:[t,o.jsx(w.Icon,{asChild:!0,children:o.jsx(N.ChevronDown,{className:"bn-h-4 bn-w-4 bn-opacity-50"})})]}));X.displayName=w.Trigger.displayName;const Y=l.forwardRef(({className:n,...t},e)=>o.jsx(w.ScrollUpButton,{ref:e,className:i("bn-flex bn-cursor-default bn-items-center bn-justify-center bn-py-1",n),...t,children:o.jsx(N.ChevronUp,{className:"bn-h-4 bn-w-4"})}));Y.displayName=w.ScrollUpButton.displayName;const Z=l.forwardRef(({className:n,...t},e)=>o.jsx(w.ScrollDownButton,{ref:e,className:i("bn-flex bn-cursor-default bn-items-center bn-justify-center bn-py-1",n),...t,children:o.jsx(N.ChevronDown,{className:"bn-h-4 bn-w-4"})}));Z.displayName=w.ScrollDownButton.displayName;const A=l.forwardRef(({className:n,children:t,position:e="popper",...r},a)=>o.jsxs(w.Content,{ref:a,className:i("bn-relative bn-z-50 bn-max-h-96 bn-min-w-[8rem] bn-overflow-hidden bn-rounded-md bn-border bn-bg-popover bn-text-popover-foreground bn-shadow-md data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",e==="popper"&&"data-[side=bottom]:bn-translate-y-1 data-[side=left]:bn--translate-x-1 data-[side=right]:bn-translate-x-1 data-[side=top]:bn--translate-y-1",n),position:e,...r,children:[o.jsx(Y,{}),o.jsx(w.Viewport,{className:i("bn-p-1",e==="popper"&&"bn-h-[var(--radix-select-trigger-height)] bn-w-full bn-min-w-[var(--radix-select-trigger-width)]"),children:t}),o.jsx(Z,{})]}));A.displayName=w.Content.displayName;const Ge=l.forwardRef(({className:n,...t},e)=>o.jsx(w.Label,{ref:e,className:i("bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-font-semibold",n),...t}));Ge.displayName=w.Label.displayName;const R=l.forwardRef(({className:n,children:t,...e},r)=>o.jsxs(w.Item,{ref:r,className:i("bn-relative bn-flex bn-w-full bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-outline-none focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",n),...e,children:[o.jsx("span",{className:"bn-absolute bn-left-2 bn-flex bn-h-3.5 bn-w-3.5 bn-items-center bn-justify-center",children:o.jsx(w.ItemIndicator,{children:o.jsx(N.Check,{className:"bn-h-4 bn-w-4"})})}),o.jsx(w.ItemText,{children:t})]}));R.displayName=w.Item.displayName;const Ue=l.forwardRef(({className:n,...t},e)=>o.jsx(w.Separator,{ref:e,className:i("bn--mx-1 bn-my-1 bn-h-px bn-bg-muted",n),...t}));Ue.displayName=w.Separator.displayName;const He=S.Root,ee=l.forwardRef(({className:n,...t},e)=>o.jsx(S.List,{ref:e,className:i("bn-inline-flex bn-h-10 bn-items-center bn-justify-center bn-rounded-md bn-bg-muted bn-p-1 bn-text-muted-foreground",n),...t}));ee.displayName=S.List.displayName;const ne=l.forwardRef(({className:n,...t},e)=>o.jsx(S.Trigger,{ref:e,className:i("bn-inline-flex bn-items-center bn-justify-center bn-whitespace-nowrap bn-rounded-sm bn-px-3 bn-py-1.5 bn-text-sm bn-font-medium bn-ring-offset-background bn-transition-all focus-visible:bn-outline-none focus-visible:bn-ring-2 focus-visible:bn-ring-ring focus-visible:bn-ring-offset-2 disabled:bn-pointer-events-none disabled:bn-opacity-50 data-[state=active]:bn-bg-background data-[state=active]:bn-text-foreground data-[state=active]:bn-shadow-sm",n),...t}));ne.displayName=S.Trigger.displayName;const te=l.forwardRef(({className:n,...t},e)=>o.jsx(S.Content,{ref:e,className:i("bn-mt-2 bn-ring-offset-background focus-visible:bn-outline-none focus-visible:bn-ring-2 focus-visible:bn-ring-ring focus-visible:bn-ring-offset-2",n),...t}));te.displayName=S.Content.displayName;const Ke=I.cva("bn-inline-flex bn-items-center bn-justify-center bn-rounded-md bn-text-sm bn-font-medium bn-ring-offset-background bn-transition-colors hover:bn-bg-muted hover:bn-text-muted-foreground focus-visible:bn-outline-none focus-visible:bn-ring-2 focus-visible:bn-ring-ring focus-visible:bn-ring-offset-2 disabled:bn-pointer-events-none disabled:bn-opacity-50 data-[state=on]:bn-bg-accent data-[state=on]:bn-text-accent-foreground",{variants:{variant:{default:"bn-bg-transparent",outline:"bn-border bn-border-input bn-bg-transparent hover:bn-bg-accent hover:bn-text-accent-foreground"},size:{default:"bn-h-10 bn-px-3",sm:"bn-h-9 bn-px-2.5",lg:"bn-h-11 bn-px-5"}},defaultVariants:{variant:"default",size:"default"}}),oe=l.forwardRef(({className:n,variant:t,size:e,...r},a)=>o.jsx(z.Root,{ref:a,className:i(Ke({variant:t,size:e,className:n})),...r}));oe.displayName=z.Root.displayName;const We=M.Provider,Je=M.Root,Qe=M.Trigger,re=l.forwardRef(({className:n,sideOffset:t=4,...e},r)=>o.jsx(M.Content,{ref:r,sideOffset:t,className:i("bn-z-50 bn-overflow-hidden bn-rounded-md bn-border bn-bg-popover bn-px-3 bn-py-1.5 bn-text-sm bn-text-popover-foreground bn-shadow-md bn-animate-in bn-fade-in-0 bn-zoom-in-95 data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=closed]:bn-zoom-out-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",n),...e}));re.displayName=M.Content.displayName;const Xe={Badge:{Badge:xe},Button:{Button:j},Card:{Card:V,CardContent:q},DropdownMenu:{DropdownMenu:Me,DropdownMenuCheckboxItem:U,DropdownMenuContent:O,DropdownMenuItem:G,DropdownMenuLabel:H,DropdownMenuSeparator:K,DropdownMenuSub:Ie,DropdownMenuSubContent:$,DropdownMenuSubTrigger:_,DropdownMenuTrigger:De},Form:{Form:ke},Input:{Input:J},Label:{Label:F},Popover:{Popover:qe,PopoverContent:Q,PopoverTrigger:_e},Select:{Select:$e,SelectContent:A,SelectItem:R,SelectTrigger:X,SelectValue:Oe},Tabs:{Tabs:He,TabsContent:te,TabsList:ee,TabsTrigger:ne},Toggle:{Toggle:oe},Tooltip:{Tooltip:Je,TooltipContent:re,TooltipProvider:We,TooltipTrigger:Qe}},ae=c.createContext(void 0);function h(){return c.useContext(ae)}const Ye=n=>{const{children:t,...e}=n;p.assertEmpty(e);const r=h(),a=k.useForm();return o.jsx(r.Form.Form,{...a,children:t})},Ze=c.forwardRef((n,t)=>{const{className:e,name:r,label:a,icon:s,value:d,autoFocus:u,placeholder:f,onKeyDown:b,onChange:g,onSubmit:x,...y}=n;p.assertEmpty(y);const D=h();return a?o.jsxs("div",{children:[o.jsx(D.Label.Label,{htmlFor:a,children:a}),o.jsx(D.Input.Input,{className:e,id:a,name:r,autoFocus:u,placeholder:f,value:d,onKeyDown:b,onChange:g,onSubmit:x})]}):o.jsx(D.Input.Input,{"aria-label":r,name:r,autoFocus:u,placeholder:f,value:d,onKeyDown:b,onChange:g,onSubmit:x,ref:t})}),Ae=n=>c.forwardRef((t,e)=>o.jsx(n,{onPointerDown:r=>{r.nativeEvent.fakeEvent||(r.ctrlKey=!0)},onPointerUp:r=>{const a=new PointerEvent("pointerdown",r.nativeEvent);a.fakeEvent=!0,r.target.dispatchEvent(a)},...t,ref:e})),Re=n=>{const{children:t,onOpenChange:e,position:r,sub:a,...s}=n;p.assertEmpty(s);const d=h();return a?o.jsx(d.DropdownMenu.DropdownMenuSub,{onOpenChange:e,children:t}):o.jsx(d.DropdownMenu.DropdownMenu,{onOpenChange:e,children:t})},en=n=>{const{children:t,sub:e,...r}=n;p.assertEmpty(r);const a=h(),s=c.useMemo(()=>Ae(a.DropdownMenu.DropdownMenuTrigger),[a.DropdownMenu.DropdownMenuTrigger]);return e?o.jsx(a.DropdownMenu.DropdownMenuSubTrigger,{children:t}):o.jsx(s,{asChild:!0,...r,children:t})},nn=c.forwardRef((n,t)=>{const{className:e,children:r,sub:a,...s}=n;p.assertEmpty(s);const d=h();return a?o.jsx(d.DropdownMenu.DropdownMenuSubContent,{className:e,ref:t,children:r}):o.jsx(d.DropdownMenu.DropdownMenuContent,{className:e,ref:t,children:r})}),tn=c.forwardRef((n,t)=>{const{className:e,children:r,icon:a,checked:s,subTrigger:d,onClick:u,...f}=n;p.assertEmpty(f);const b=h();return d?o.jsxs(o.Fragment,{children:[a,r]}):s!==void 0?o.jsxs(b.DropdownMenu.DropdownMenuCheckboxItem,{className:i(e,"bn-gap-1"),ref:t,checked:s,onClick:u,...f,children:[a,r]}):o.jsxs(b.DropdownMenu.DropdownMenuItem,{className:e,ref:t,onClick:u,...f,children:[a,r,d&&o.jsx(N.ChevronRight,{className:"bn-ml-auto bn-h-4 bn-w-4"})]})}),on=c.forwardRef((n,t)=>{const{className:e,...r}=n;p.assertEmpty(r);const a=h();return o.jsx(a.DropdownMenu.DropdownMenuSeparator,{className:e,ref:t})}),rn=c.forwardRef((n,t)=>{const{className:e,children:r,...a}=n;p.assertEmpty(a);const s=h();return o.jsx(s.DropdownMenu.DropdownMenuLabel,{className:e,ref:t,children:r})}),an=c.forwardRef((n,t)=>{const{className:e,tabs:r,defaultOpenTab:a,openTab:s,setOpenTab:d,loading:u,...f}=n;p.assertEmpty(f);const b=h();return o.jsxs(b.Tabs.Tabs,{className:i(e,"bn-bg-popover bn-p-2 bn-rounded-lg"),ref:t,value:s,defaultValue:a,onValueChange:d,children:[o.jsx(b.Tabs.TabsList,{children:r.map(g=>o.jsx(b.Tabs.TabsTrigger,{value:g.name,children:g.name},g.name))}),r.map(g=>o.jsx(b.Tabs.TabsContent,{value:g.name,children:o.jsx(b.Card.Card,{children:o.jsx(b.Card.CardContent,{className:"bn-p-4",children:g.tabPanel})})},g.name))]})}),sn=c.forwardRef((n,t)=>{const{className:e,children:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{className:i(e,"bn-flex bn-flex-col bn-gap-2 bn-items-start bn-justify-center"),ref:t,children:r})}),dn=c.forwardRef((n,t)=>{const{className:e,value:r,placeholder:a,onKeyDown:s,onChange:d,...u}=n;p.assertEmpty(u);const f=h();return o.jsx(f.Input.Input,{"data-test":"embed-input",className:i(e,"bn-w-80"),ref:t,value:r,placeholder:a,onKeyDown:s,onChange:d})}),bn=n=>{const{children:t,opened:e,position:r,...a}=n;p.assertEmpty(a);const s=h();return o.jsx(s.Popover.Popover,{open:e,children:t})},ln=c.forwardRef((n,t)=>{const{children:e,...r}=n;p.assertEmpty(r);const a=h();return o.jsx(a.Popover.PopoverTrigger,{ref:t,asChild:!0,children:e})}),cn=c.forwardRef((n,t)=>{const{className:e,variant:r,children:a,...s}=n;p.assertEmpty(s);const d=h();return o.jsx(d.Popover.PopoverContent,{sideOffset:8,className:i(e,"bn-flex bn-flex-col bn-gap-2",r==="panel-popover"?"bn-p-0 bn-border-none bn-shadow-none bn-max-w-none bn-w-fit":""),ref:t,children:a})}),pn=c.forwardRef((n,t)=>{const{className:e,children:r,...a}=n;return p.assertEmpty(a,!1),o.jsx("div",{className:e,ref:t,...a,children:r})}),fn=c.forwardRef((n,t)=>{const{className:e,children:r,icon:a,onClick:s,onDragEnd:d,onDragStart:u,draggable:f,label:b,...g}=n;p.assertEmpty(g,!1);const x=h();return o.jsxs(x.Button.Button,{variant:"ghost",className:i(e,"bn-text-gray-400"),ref:t,"aria-label":b,onClick:s,onDragStart:u,onDragEnd:d,draggable:f,...g,children:[a,r]})}),un=c.forwardRef((n,t)=>{const{className:e,children:r,id:a,columns:s,...d}=n;return p.assertEmpty(d),o.jsx("div",{className:e,style:{gridTemplateColumns:`repeat(${s}, 1fr)`},ref:t,id:a,role:"grid",children:r})}),mn=c.forwardRef((n,t)=>{const{className:e,children:r,columns:a,...s}=n;return p.assertEmpty(s),o.jsx("div",{className:e,style:{gridColumn:`1 / ${a+1}`},ref:t,children:r})}),gn=c.forwardRef((n,t)=>{const{className:e,children:r,id:a,...s}=n;return p.assertEmpty(s),o.jsx("div",{id:a,role:"listbox",className:i("bn-z-50 bn-min-w-[8rem] bn-overflow-auto bn-rounded-md bn-border bn-bg-popover bn-p-1 bn-text-popover-foreground bn-shadow-md data-[state=open]:bn-animate-in data-[state=closed]:bn-animate-out data-[state=closed]:bn-fade-out-0 data-[state=open]:bn-fade-in-0 data-[state=closed]:bn-zoom-out-95 data-[state=open]:bn-zoom-in-95 data-[side=bottom]:bn-slide-in-from-top-2 data-[side=left]:bn-slide-in-from-right-2 data-[side=right]:bn-slide-in-from-left-2 data-[side=top]:bn-slide-in-from-bottom-2",e),ref:t,children:r})}),hn=c.forwardRef((n,t)=>{const{className:e,children:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{className:i("bn-relative bn-flex bn-cursor-default bn-select-none bn-items-center bn-rounded-sm bn-px-2 bn-py-1.5 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",e),ref:t,children:o.jsx("div",{children:r})})}),vn=c.forwardRef((n,t)=>{const e=h(),{className:r,item:a,isSelected:s,onClick:d,id:u,...f}=n;p.assertEmpty(f);const b=c.useRef(null);return c.useEffect(()=>{if(!b.current||!s)return;const g=T.elementOverflow(b.current,document.querySelector(".bn-suggestion-menu"));g==="top"?b.current.scrollIntoView(!0):g==="bottom"&&b.current.scrollIntoView(!1)},[s]),o.jsxs("div",{className:i("bn-relative bn-flex bn-cursor-pointer bn-select-none bn-items-center bn-rounded-sm bn-px-2 bn-py-1.5 bn-text-sm bn-outline-none bn-transition-colors focus:bn-bg-accent focus:bn-text-accent-foreground data-[disabled]:bn-pointer-events-none data-[disabled]:bn-opacity-50",r),ref:T.mergeRefs([t,b]),id:u,onClick:d,role:"option","aria-selected":s||void 0,children:[a.icon&&o.jsx("div",{className:"bn-p-3","data-position":"left",children:a.icon}),o.jsxs("div",{className:"bn-flex-1",children:[o.jsx("div",{className:"bn-text-base",children:a.title}),o.jsx("div",{className:"bn-text-xs",children:a.subtext})]}),a.badge&&o.jsx("div",{"data-position":"right",className:"bn-text-xs",children:o.jsx(e.Badge.Badge,{variant:"secondary",children:a.badge})})]})}),wn=c.forwardRef((n,t)=>{const{className:e,children:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{className:i("bn-px-2 bn-py-1.5 bn-text-sm bn-font-semibold",e),ref:t,children:r})}),xn=c.forwardRef((n,t)=>{const{className:e,children:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{className:e,ref:t,children:r})}),yn=c.forwardRef((n,t)=>{const{className:e,children:r,onMouseDown:a,onClick:s,...d}=n;p.assertEmpty(d,!1);const u=h();return o.jsx(u.Button.Button,{variant:"ghost",className:i(e,"bn-p-0 bn-h-full bn-w-full bn-text-gray-400",e!=null&&e.includes("bn-extend-button-add-remove-columns")?"bn-ml-1":"bn-mt-1",e!=null&&e.includes("bn-extend-button-editing")?"bn-bg-accent bn-text-accent-foreground":""),ref:t,onClick:s,onMouseDown:a,...d,children:r})}),Nn=c.forwardRef((n,t)=>{const{className:e,children:r,draggable:a,onDragStart:s,onDragEnd:d,style:u,label:f,...b}=n;p.assertEmpty(b,!1);const g=h();return o.jsx(g.Button.Button,{variant:"ghost",className:i(e,"bn-p-0 bn-h-fit bn-w-fit bn-text-gray-400"),ref:t,"aria-label":f,draggable:a,onDragStart:s,onDragEnd:d,style:u,...b,children:r})}),se=c.forwardRef((n,t)=>{const{className:e,children:r,onMouseEnter:a,onMouseLeave:s,...d}=n;p.assertEmpty(d);const u=h();return o.jsx(u.Tooltip.TooltipProvider,{delayDuration:0,children:o.jsx("div",{className:i(e,"bn-flex bn-gap-1 bn-p-1 bn-bg-popover bn-text-popover-foreground bn-border bn-rounded-lg bn-shadow-md"),ref:t,onMouseEnter:a,onMouseLeave:s,children:r})})}),de=c.forwardRef((n,t)=>{const{className:e,children:r,mainTooltip:a,secondaryTooltip:s,icon:d,isSelected:u,isDisabled:f,onClick:b,label:g,...x}=n;p.assertEmpty(x,!1);const y=h(),D=u===void 0?o.jsxs(y.Button.Button,{className:e,variant:"ghost",disabled:f,onClick:b,ref:t,"aria-label":g,...x,children:[d,r]}):o.jsxs(y.Toggle.Toggle,{className:i(e,"data-[state=open]:bg-accent data-[state=closed]:text-accent-foreground"),"aria-label":g,onClick:b,pressed:u,disabled:f,"data-state":u?"on":"off","data-disabled":f,ref:t,...x,children:[d,r]});return o.jsxs(y.Tooltip.Tooltip,{children:[o.jsx(y.Tooltip.TooltipTrigger,{asChild:!0,children:D}),o.jsxs(y.Tooltip.TooltipContent,{className:"bn-flex bn-flex-col bn-items-center",children:[o.jsx("span",{children:a}),s&&o.jsx("span",{children:s})]})]})}),Cn=c.forwardRef((n,t)=>{const{className:e,items:r,isDisabled:a,...s}=n;p.assertEmpty(s);const d=h(),u=b=>o.jsxs("div",{className:"bn-flex bn-gap-1 bn-items-center",children:[b.icon,b.text]}),f=r.filter(b=>b.isSelected)[0];return f?o.jsxs(d.Select.Select,{value:f.text,onValueChange:b=>{var g,x;return(x=(g=r.find(y=>y.text===b)).onClick)==null?void 0:x.call(g)},disabled:a,children:[o.jsx(d.Select.SelectTrigger,{className:"bn-border-none",children:o.jsx(d.Select.SelectValue,{})}),o.jsx(d.Select.SelectContent,{className:e,ref:t,children:r.map(b=>o.jsx(d.Select.SelectItem,{disabled:b.isDisabled,value:b.text,children:o.jsx(u,{...b})},b.text))})]}):null}),Sn=c.forwardRef((n,t)=>{const{className:e,children:r,onClick:a,label:s,...d}=n;p.assertEmpty(d);const u=h();return o.jsx(u.Button.Button,{type:"submit",className:e,"aria-label":s,ref:t,onClick:a,children:r})}),Tn=c.forwardRef((n,t)=>{const{className:e,accept:r,value:a,placeholder:s,onChange:d,...u}=n;p.assertEmpty(u);const f=h();return o.jsx(f.Input.Input,{type:"file",className:e,ref:t,accept:r,value:a?a.name:void 0,onChange:async b=>d==null?void 0:d(b.target.files[0]),placeholder:s})}),Mn=c.forwardRef((n,t)=>{const{className:e,isSelected:r,onClick:a,item:s,id:d,...u}=n;p.assertEmpty(u);const f=c.useRef(null);return c.useEffect(()=>{if(!f.current||!r)return;const b=T.elementOverflow(f.current,document.querySelector(".bn-grid-suggestion-menu"));b==="top"?f.current.scrollIntoView(!0):b==="bottom"&&f.current.scrollIntoView(!1)},[r]),o.jsx("div",{className:e,ref:T.mergeRefs([t,f]),id:d,role:"option",onClick:a,"aria-selected":r||void 0,children:s.icon})}),Dn=c.forwardRef((n,t)=>{const{className:e,children:r,columns:a,...s}=n;return p.assertEmpty(s),o.jsx("div",{className:e,style:{gridColumn:`1 / ${a+1}`},ref:t,children:r})}),ie={FormattingToolbar:{Root:se,Button:de,Select:Cn},FilePanel:{Root:an,Button:Sn,FileInput:Tn,TabPanel:sn,TextInput:dn},LinkToolbar:{Root:se,Button:de},SideMenu:{Root:pn,Button:fn},SuggestionMenu:{Root:gn,Item:vn,EmptyItem:hn,Label:wn,Loader:xn},GridSuggestionMenu:{Root:un,Item:Mn,EmptyItem:mn,Loader:Dn},TableHandle:{Root:Nn,ExtendButton:yn},Generic:{Form:{Root:Ye,TextInput:Ze},Menu:{Root:Re,Trigger:en,Dropdown:nn,Divider:on,Label:rn,Item:tn},Popover:{Root:bn,Trigger:ln,Content:cn}}},In=n=>{const{className:t,shadCNComponents:e,...r}=n,a=c.useMemo(()=>({...Xe,...e}),[e]);return o.jsx(ae.Provider,{value:a,children:o.jsx(T.ComponentsContext.Provider,{value:ie,children:o.jsx(T.BlockNoteViewRaw,{className:p.mergeCSSClasses("bn-shadcn",t||""),...r})})})};m.BlockNoteView=In,m.components=ie,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=blocknote-shadcn.umd.cjs.map