UNPKG

@blocknote/shadcn

Version:

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

3 lines (2 loc) 35.9 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),p=require("@blocknote/core"),N=require("@blocknote/react"),b=require("react"),F=require("react-hook-form"),he=require("@radix-ui/react-avatar"),ve=require("clsx"),we=require("tailwind-merge"),I=require("class-variance-authority"),z=require("@radix-ui/react-slot"),Ne=require("@radix-ui/react-dropdown-menu"),j=require("lucide-react"),ye=require("@radix-ui/react-label"),Ce=require("@radix-ui/react-popover"),je=require("@radix-ui/react-select"),Se=require("@radix-ui/react-tabs"),Te=require("@radix-ui/react-toggle"),Re=require("@radix-ui/react-tooltip");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 s=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,s.get?s:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const m=C(b),T=C(he),h=C(Ne),V=C(ye),D=C(Ce),v=C(je),S=C(Se),_=C(Te),R=C(Re),Me=we.extendTailwindMerge({prefix:"bn-"});function i(...n){return Me(ve.clsx(n))}const A=m.forwardRef(({className:n,...t},e)=>o.jsx(T.Root,{ref:e,className:i("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",n),...t}));A.displayName=T.Root.displayName;const $=m.forwardRef(({className:n,...t},e)=>o.jsx(T.Image,{ref:e,className:i("aspect-square h-full w-full",n),...t}));$.displayName=T.Image.displayName;const O=m.forwardRef(({className:n,...t},e)=>o.jsx(T.Fallback,{ref:e,className:i("bg-muted flex h-full w-full items-center justify-center rounded-full",n),...t}));O.displayName=T.Fallback.displayName;const Ie=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 De({className:n,variant:t,...e}){return o.jsx("div",{className:i(Ie({variant:t}),n),...e})}const Ee=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"}}),G=m.forwardRef(({className:n,variant:t,size:e,asChild:s=!1,...r},a)=>{const d=s?z.Slot:"button";return o.jsx(d,{className:i(Ee({variant:t,size:e,className:n})),ref:a,type:"button",...r})});G.displayName="Button";const H=m.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}));H.displayName="Card";const Pe=m.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}));Pe.displayName="CardHeader";const ke=m.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}));ke.displayName="CardTitle";const Be=m.forwardRef(({className:n,...t},e)=>o.jsx("p",{ref:e,className:i("bn-text-sm bn-text-muted-foreground",n),...t}));Be.displayName="CardDescription";const U=m.forwardRef(({className:n,...t},e)=>o.jsx("div",{ref:e,className:i("bn-p-6 bn-pt-0",n),...t}));U.displayName="CardContent";const Fe=m.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}));Fe.displayName="CardFooter";const Le=h.Root,qe=h.Trigger,ze=h.Sub,K=m.forwardRef(({className:n,inset:t,children:e,...s},r)=>o.jsxs(h.SubTrigger,{ref:r,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),...s,children:[e,o.jsx(j.ChevronRight,{className:"bn-ml-auto bn-h-4 bn-w-4"})]}));K.displayName=h.SubTrigger.displayName;const Q=m.forwardRef(({className:n,...t},e)=>o.jsx(h.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}));Q.displayName=h.SubContent.displayName;const W=m.forwardRef(({className:n,sideOffset:t=4,...e},s)=>o.jsx(h.Content,{ref:s,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}));W.displayName=h.Content.displayName;const Z=m.forwardRef(({className:n,inset:t,...e},s)=>o.jsx(h.Item,{ref:s,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}));Z.displayName=h.Item.displayName;const J=m.forwardRef(({className:n,children:t,checked:e,...s},r)=>o.jsxs(h.CheckboxItem,{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),checked:e,...s,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(h.ItemIndicator,{children:o.jsx(j.Check,{className:"bn-h-4 bn-w-4"})})}),t]}));J.displayName=h.CheckboxItem.displayName;const Ve=m.forwardRef(({className:n,children:t,...e},s)=>o.jsxs(h.RadioItem,{ref:s,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(h.ItemIndicator,{children:o.jsx(j.Circle,{className:"bn-h-2 bn-w-2 bn-fill-current"})})}),t]}));Ve.displayName=h.RadioItem.displayName;const X=m.forwardRef(({className:n,inset:t,...e},s)=>o.jsx(h.Label,{ref:s,className:i("bn-px-2 bn-py-1.5 bn-text-sm bn-font-semibold",t&&"bn-pl-8",n),...e}));X.displayName=h.Label.displayName;const Y=m.forwardRef(({className:n,...t},e)=>o.jsx(h.Separator,{ref:e,className:i("bn--mx-1 bn-my-1 bn-h-px bn-bg-muted",n),...t}));Y.displayName=h.Separator.displayName;const _e=I.cva("bn-text-sm bn-font-medium bn-leading-none peer-disabled:bn-cursor-not-allowed peer-disabled:bn-opacity-70"),L=m.forwardRef(({className:n,...t},e)=>o.jsx(V.Root,{ref:e,className:i(_e(),n),...t}));L.displayName=V.Root.displayName;const Ae=F.FormProvider,$e=m.createContext({}),E=()=>{const n=m.useContext($e),t=m.useContext(ee),{getFieldState:e,formState:s}=F.useFormContext(),r=e(n.name,s);if(!n)throw new Error("useFormField should be used within <FormField>");const{id:a}=t;return{id:a,name:n.name,formItemId:`${a}-form-item`,formDescriptionId:`${a}-form-item-description`,formMessageId:`${a}-form-item-message`,...r}},ee=m.createContext({}),Oe=m.forwardRef(({className:n,...t},e)=>{const s=m.useId();return o.jsx(ee.Provider,{value:{id:s},children:o.jsx("div",{ref:e,className:i("bn-space-y-2",n),...t})})});Oe.displayName="FormItem";const Ge=m.forwardRef(({className:n,...t},e)=>{const{error:s,formItemId:r}=E();return o.jsx(L,{ref:e,className:i(s&&"bn-text-destructive",n),htmlFor:r,...t})});Ge.displayName="FormLabel";const He=m.forwardRef(({...n},t)=>{const{error:e,formItemId:s,formDescriptionId:r,formMessageId:a}=E();return o.jsx(z.Slot,{ref:t,id:s,"aria-describedby":e?`${r} ${a}`:`${r}`,"aria-invalid":!!e,...n})});He.displayName="FormControl";const Ue=m.forwardRef(({className:n,...t},e)=>{const{formDescriptionId:s}=E();return o.jsx("p",{ref:e,id:s,className:i("bn-text-sm bn-text-muted-foreground",n),...t})});Ue.displayName="FormDescription";const Ke=m.forwardRef(({className:n,children:t,...e},s)=>{const{error:r,formMessageId:a}=E(),d=r?String(r==null?void 0:r.message):t;return d?o.jsx("p",{ref:s,id:a,className:i("bn-text-sm bn-font-medium bn-text-destructive",n),...e,children:d}):null});Ke.displayName="FormMessage";const ne=m.forwardRef(({className:n,type:t,...e},s)=>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:s,...e}));ne.displayName="Input";const Qe=D.Root,We=D.Trigger,te=m.forwardRef(({className:n,align:t="center",sideOffset:e=4,...s},r)=>o.jsx(D.Content,{ref:r,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),...s}));te.displayName=D.Content.displayName;const Ze=v.Root,Je=v.Value,oe=m.forwardRef(({className:n,children:t,...e},s)=>o.jsxs(v.Trigger,{ref:s,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(v.Icon,{asChild:!0,children:o.jsx(j.ChevronDown,{className:"bn-h-4 bn-w-4 bn-opacity-50"})})]}));oe.displayName=v.Trigger.displayName;const se=m.forwardRef(({className:n,...t},e)=>o.jsx(v.ScrollUpButton,{ref:e,className:i("bn-flex bn-cursor-default bn-items-center bn-justify-center bn-py-1",n),...t,children:o.jsx(j.ChevronUp,{className:"bn-h-4 bn-w-4"})}));se.displayName=v.ScrollUpButton.displayName;const re=m.forwardRef(({className:n,...t},e)=>o.jsx(v.ScrollDownButton,{ref:e,className:i("bn-flex bn-cursor-default bn-items-center bn-justify-center bn-py-1",n),...t,children:o.jsx(j.ChevronDown,{className:"bn-h-4 bn-w-4"})}));re.displayName=v.ScrollDownButton.displayName;const ae=m.forwardRef(({className:n,children:t,position:e="popper",...s},r)=>o.jsxs(v.Content,{ref:r,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,...s,children:[o.jsx(se,{}),o.jsx(v.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(re,{})]}));ae.displayName=v.Content.displayName;const Xe=m.forwardRef(({className:n,...t},e)=>o.jsx(v.Label,{ref:e,className:i("bn-py-1.5 bn-pl-8 bn-pr-2 bn-text-sm bn-font-semibold",n),...t}));Xe.displayName=v.Label.displayName;const ie=m.forwardRef(({className:n,children:t,...e},s)=>o.jsxs(v.Item,{ref:s,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(v.ItemIndicator,{children:o.jsx(j.Check,{className:"bn-h-4 bn-w-4"})})}),o.jsx(v.ItemText,{children:t})]}));ie.displayName=v.Item.displayName;const Ye=m.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}));Ye.displayName=v.Separator.displayName;function en({className:n,...t}){return o.jsx("div",{className:i("bg-primary/10 animate-pulse rounded-md",n),...t})}const nn=S.Root,de=m.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}));de.displayName=S.List.displayName;const le=m.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}));le.displayName=S.Trigger.displayName;const be=m.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}));be.displayName=S.Content.displayName;const tn=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"}}),ce=m.forwardRef(({className:n,variant:t,size:e,...s},r)=>o.jsx(_.Root,{ref:r,className:i(tn({variant:t,size:e,className:n})),...s}));ce.displayName=_.Root.displayName;const on=R.Provider,sn=R.Root,rn=R.Trigger,me=m.forwardRef(({className:n,sideOffset:t=4,...e},s)=>o.jsx(R.Content,{ref:s,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}));me.displayName=R.Content.displayName;const an={Avatar:{Avatar:A,AvatarFallback:O,AvatarImage:$},Badge:{Badge:De},Button:{Button:G},Card:{Card:H,CardContent:U},DropdownMenu:{DropdownMenu:Le,DropdownMenuCheckboxItem:J,DropdownMenuContent:W,DropdownMenuItem:Z,DropdownMenuLabel:X,DropdownMenuSeparator:Y,DropdownMenuSub:ze,DropdownMenuSubContent:Q,DropdownMenuSubTrigger:K,DropdownMenuTrigger:qe},Form:{Form:Ae},Input:{Input:ne},Label:{Label:L},Popover:{Popover:Qe,PopoverContent:te,PopoverTrigger:We},Select:{Select:Ze,SelectContent:ae,SelectItem:ie,SelectTrigger:oe,SelectValue:Je},Skeleton:{Skeleton:en},Tabs:{Tabs:nn,TabsContent:be,TabsList:de,TabsTrigger:le},Toggle:{Toggle:ce},Tooltip:{Tooltip:sn,TooltipContent:me,TooltipProvider:on,TooltipTrigger:rn}},ue=b.createContext(void 0);function g(){return b.useContext(ue)}const dn=n=>{const{children:t,...e}=n;p.assertEmpty(e);const s=g(),r=F.useForm();return o.jsx(s.Form.Form,{...r,children:t})},ln=b.forwardRef((n,t)=>{const{className:e,name:s,label:r,variant:a,icon:d,value:c,autoFocus:u,placeholder:l,disabled:f,onKeyDown:x,onChange:w,onSubmit:y,autoComplete:M,rightSection:ge,...xe}=n;p.assertEmpty(xe);const q=g();return o.jsxs("div",{className:i(e,"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","bn-items-center bn-gap-2 bn-text-foreground"),children:[d,o.jsxs("div",{className:"bn-flex-1",children:[r&&o.jsx(q.Label.Label,{htmlFor:r,children:r}),o.jsx(q.Input.Input,{className:i(e,"bn-border-none bn-p-0 bn-h-auto"),id:r,name:s,autoFocus:u,placeholder:l,disabled:f,value:c,onKeyDown:x,onChange:w,onSubmit:y,ref:t})]}),ge]})}),bn=n=>b.forwardRef((t,e)=>o.jsx(n,{onPointerDown:s=>{s.nativeEvent.fakeEvent||(s.ctrlKey=!0)},onPointerUp:s=>{const r=new PointerEvent("pointerdown",s.nativeEvent);r.fakeEvent=!0,s.target.dispatchEvent(r)},...t,ref:e})),cn=n=>{const{children:t,onOpenChange:e,position:s,sub:r,...a}=n;p.assertEmpty(a);const d=g();return r?o.jsx(d.DropdownMenu.DropdownMenuSub,{onOpenChange:e,children:t}):o.jsx(d.DropdownMenu.DropdownMenu,{modal:!1,onOpenChange:e,children:t})},mn=n=>{const{children:t,sub:e,...s}=n;p.assertEmpty(s);const r=g(),a=b.useMemo(()=>bn(r.DropdownMenu.DropdownMenuTrigger),[r.DropdownMenu.DropdownMenuTrigger]);return e?o.jsx(r.DropdownMenu.DropdownMenuSubTrigger,{children:t}):o.jsx(a,{asChild:!0,...s,children:t})},un=b.forwardRef((n,t)=>{const{className:e,children:s,sub:r,...a}=n;p.assertEmpty(a);const d=g();return r?o.jsx(d.DropdownMenu.DropdownMenuSubContent,{className:e,ref:t,children:s}):o.jsx(d.DropdownMenu.DropdownMenuContent,{className:e,ref:t,children:s})}),pn=b.forwardRef((n,t)=>{const{className:e,children:s,icon:r,checked:a,subTrigger:d,onClick:c,...u}=n;p.assertEmpty(u);const l=g();return d?o.jsxs(o.Fragment,{children:[r,s]}):a!==void 0?o.jsxs(l.DropdownMenu.DropdownMenuCheckboxItem,{className:i(e,"bn-gap-1",a?"":"bn-px-2"),ref:t,checked:a,onClick:c,...u,children:[r,s]}):o.jsxs(l.DropdownMenu.DropdownMenuItem,{className:e,ref:t,onClick:c,...u,children:[r,s,d&&o.jsx(j.ChevronRight,{className:"bn-ml-auto bn-h-4 bn-w-4"})]})}),fn=b.forwardRef((n,t)=>{const{className:e,...s}=n;p.assertEmpty(s);const r=g();return o.jsx(r.DropdownMenu.DropdownMenuSeparator,{className:e,ref:t})}),gn=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;p.assertEmpty(r);const a=g();return o.jsx(a.DropdownMenu.DropdownMenuLabel,{className:e,ref:t,children:s})}),xn=b.forwardRef((n,t)=>{const{className:e,children:s,icon:r,onClick:a,onDragEnd:d,onDragStart:c,draggable:u,label:l,...f}=n;p.assertEmpty(f,!1);const x=g();return o.jsxs(x.Button.Button,{variant:"ghost",className:i(e,"bn-text-gray-400"),ref:t,"aria-label":l,onClick:a,onDragStart:c,onDragEnd:d,draggable:u,...f,children:[r,s]})}),hn=b.forwardRef((n,t)=>{const{className:e,tabs:s,defaultOpenTab:r,openTab:a,setOpenTab:d,loading:c,...u}=n;p.assertEmpty(u);const l=g();return o.jsxs(l.Tabs.Tabs,{className:i(e,"bn-bg-popover bn-p-2 bn-rounded-lg"),ref:t,value:a,defaultValue:r,onValueChange:d,children:[o.jsx(l.Tabs.TabsList,{children:s.map(f=>o.jsx(l.Tabs.TabsTrigger,{value:f.name,children:f.name},f.name))}),s.map(f=>o.jsx(l.Tabs.TabsContent,{value:f.name,children:o.jsx(l.Card.Card,{children:o.jsx(l.Card.CardContent,{className:"bn-p-4",children:f.tabPanel})})},f.name))]})}),vn=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;return p.assertEmpty(r),o.jsx("div",{className:i(e,"bn-flex bn-flex-col bn-gap-2 bn-items-start bn-justify-center"),ref:t,children:s})}),wn=b.forwardRef((n,t)=>{const{className:e,value:s,placeholder:r,onKeyDown:a,onChange:d,...c}=n;p.assertEmpty(c);const u=g();return o.jsx(u.Input.Input,{"data-test":"embed-input",className:i(e,"bn-w-80"),ref:t,value:s,placeholder:r,onKeyDown:a,onChange:d})}),Nn=n=>{const{children:t,opened:e,position:s,...r}=n;p.assertEmpty(r);const a=g();return o.jsx(a.Popover.Popover,{open:e,children:t})},yn=b.forwardRef((n,t)=>{const{children:e,...s}=n;p.assertEmpty(s);const r=g();return o.jsx(r.Popover.PopoverTrigger,{ref:t,asChild:!0,children:e})}),Cn=b.forwardRef((n,t)=>{const{className:e,variant:s,children:r,...a}=n;p.assertEmpty(a);const d=g();return o.jsx(d.Popover.PopoverContent,{sideOffset:8,className:i(e,"bn-flex bn-flex-col bn-gap-2",s==="panel-popover"?"bn-p-0 bn-border-none bn-shadow-none bn-max-w-none bn-w-fit":""),ref:t,children:r})}),jn=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;return p.assertEmpty(r,!1),o.jsx("div",{className:e,ref:t,...r,children:s})}),Sn=b.forwardRef((n,t)=>{const{className:e,children:s,icon:r,onClick:a,onDragEnd:d,onDragStart:c,draggable:u,label:l,...f}=n;p.assertEmpty(f,!1);const x=g();return o.jsxs(x.Button.Button,{variant:"ghost",className:i(e,"bn-text-gray-400"),ref:t,"aria-label":l,onClick:a,onDragStart:c,onDragEnd:d,draggable:u,...f,children:[r,s]})}),Tn=b.forwardRef((n,t)=>{const{className:e,children:s,id:r,columns:a,...d}=n;return p.assertEmpty(d),o.jsx("div",{className:e,style:{gridTemplateColumns:`repeat(${a}, 1fr)`},ref:t,id:r,role:"grid",children:s})}),Rn=b.forwardRef((n,t)=>{const{className:e,children:s,columns:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{className:e,style:{gridColumn:`1 / ${r+1}`},ref:t,children:s})}),Mn=b.forwardRef((n,t)=>{const{className:e,children:s,id:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{id:r,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:s})}),In=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;return p.assertEmpty(r),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:s})})}),Dn=b.forwardRef((n,t)=>{const e=g(),{className:s,item:r,isSelected:a,onClick:d,id:c,...u}=n;p.assertEmpty(u);const l=b.useRef(null);return b.useEffect(()=>{if(!l.current||!a)return;const f=N.elementOverflow(l.current,document.querySelector(".bn-suggestion-menu, #ai-suggestion-menu"));f==="top"?l.current.scrollIntoView(!0):f==="bottom"&&l.current.scrollIntoView(!1)},[a]),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",n.item.size==="small"?"bn-gap-3 bn-py-1":"",s),ref:N.mergeRefs([t,l]),id:c,onMouseDown:f=>f.preventDefault(),onClick:d,role:"option","aria-selected":a||void 0,children:[r.icon&&o.jsx("div",{className:i("bn-p-3",n.item.size==="small"?"bn-p-0":"",s),"data-position":"left",children:r.icon}),o.jsxs("div",{className:"bn-flex-1",children:[o.jsx("div",{className:i("bn-text-base",n.item.size==="small"?"bn-text-sm":"",s),children:r.title}),o.jsx("div",{className:i("bn-text-xs",n.item.size==="small"?"bn-hidden":"",s),children:r.subtext})]}),r.badge&&o.jsx("div",{"data-position":"right",className:"bn-text-xs",children:o.jsx(e.Badge.Badge,{variant:"secondary",children:r.badge})})]})}),En=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;return p.assertEmpty(r),o.jsx("div",{className:i("bn-px-2 bn-py-1.5 bn-text-sm bn-font-semibold",e),ref:t,children:s})}),Pn=b.forwardRef((n,t)=>{const{className:e,...s}=n;return p.assertEmpty(s),o.jsx("div",{className:i(e,"bn-animate-spin"),ref:t,children:o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",fill:"#e8eaed",children:o.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"})})})}),kn=b.forwardRef((n,t)=>{const{className:e,children:s,onMouseDown:r,onClick:a,...d}=n;p.assertEmpty(d,!1);const c=g();return o.jsx(c.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:a,onMouseDown:r,...d,children:s})}),Bn=b.forwardRef((n,t)=>{const{className:e,children:s,draggable:r,onDragStart:a,onDragEnd:d,style:c,label:u,...l}=n;p.assertEmpty(l,!1);const f=g();return o.jsx(f.Button.Button,{variant:"ghost",className:i(e,"bn-p-0 bn-h-fit bn-w-fit bn-text-gray-400"),ref:t,"aria-label":u,draggable:r,onDragStart:a,onDragEnd:d,style:c,...l,children:s})}),P=b.forwardRef((n,t)=>{const{className:e,children:s,onMouseEnter:r,onMouseLeave:a,variant:d,...c}=n;p.assertEmpty(c);const u=g();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 bn-h-fit",d==="action-toolbar"?"bn-w-fit":""),ref:t,onMouseEnter:r,onMouseLeave:a,children:s})})}),k=b.forwardRef((n,t)=>{const{className:e,children:s,mainTooltip:r,secondaryTooltip:a,icon:d,isSelected:c,isDisabled:u,onClick:l,label:f,variant:x,...w}=n;p.assertEmpty(w,!1);const y=g(),M=c===void 0?o.jsxs(y.Button.Button,{className:i(e,x==="compact"?"bn-h-6 bn-min-w-6 bn-p-0":""),variant:"ghost",size:x==="compact"?"sm":"default",disabled:u,onClick:l,ref:t,"aria-label":f,...w,children:[d,s]}):o.jsxs(y.Toggle.Toggle,{className:i(e,"data-[state=open]:bg-accent data-[state=closed]:text-accent-foreground",x==="compact"?"bn-h-6 bn-min-w-6 bn-p-0":""),size:x==="compact"?"sm":"default","aria-label":f,onClick:l,pressed:c,disabled:u,"data-state":c?"on":"off","data-disabled":u,ref:t,...w,children:[d,s]});return o.jsxs(y.Tooltip.Tooltip,{children:[o.jsx(y.Tooltip.TooltipTrigger,{asChild:!0,children:M}),o.jsxs(y.Tooltip.TooltipContent,{className:"bn-flex bn-flex-col bn-items-center bn-whitespace-pre-wrap",children:[o.jsx("span",{children:r}),a&&o.jsx("span",{children:a})]})]})}),B=b.forwardRef((n,t)=>{const{className:e,items:s,isDisabled:r,...a}=n;p.assertEmpty(a);const d=g(),c=l=>o.jsxs("div",{className:"bn-flex bn-gap-1 bn-items-center",children:[l.icon,l.text]}),u=s.filter(l=>l.isSelected)[0];return u?o.jsxs(d.Select.Select,{value:u.text,onValueChange:l=>{var f,x;return(x=(f=s.find(w=>w.text===l)).onClick)==null?void 0:x.call(f)},disabled:r,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:s.map(l=>o.jsx(d.Select.SelectItem,{disabled:l.isDisabled,value:l.text,children:o.jsx(c,{...l})},l.text))})]}):null}),Fn=b.forwardRef((n,t)=>{const{className:e,children:s,selected:r,headerText:a,onFocus:d,onBlur:c,tabIndex:u,...l}=n;p.assertEmpty(l);const f=g();return o.jsxs(f.Card.Card,{className:i(e,"bn-w-[300px]",r?"bn-bg-accent bn-text-accent-foreground":""),onFocus:d,onBlur:c,tabIndex:u,ref:t,children:[a&&o.jsx("div",{className:"bn-px-4 bn-pt-4 bn-italic bn-text-sm",children:a}),s]})}),Ln=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;return p.assertEmpty(r),o.jsx("div",{className:i(e,"bn-p-4",e!=null&&e.includes("bn-thread-comments")?"bn-flex bn-flex-col bn-gap-6 bn-border-b":""),ref:t,children:s})}),qn=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;p.assertEmpty(r,!1);const a=g();return o.jsx(a.Button.Button,{className:i(e,"bn-p-0 bn-w-fit bn-text-foreground bn-bg-transparent hover:bn-bg-transparent"),ref:t,children:s})}),zn=b.forwardRef((n,t)=>{const{authorInfo:e,timeString:s,edited:r,...a}=n,d=N.useDictionary();p.assertEmpty(a,!1);const c=g();return e==="loading"?o.jsxs("div",{className:"bn-flex bn-flex-row bn-flex-nowrap bn-items-center bn-gap-4",children:[o.jsx(c.Skeleton.Skeleton,{className:"bn-size-7 bn-rounded-full bn-bg-neutral-400 bn-animate-pulse"}),o.jsx(c.Skeleton.Skeleton,{className:"bn-h-3 bn-w-32 bn-rounded-full bn-bg-neutral-400 bn-animate-pulse"})]}):o.jsxs("div",{className:"bn-flex bn-flex-row bn-flex-nowrap bn-items-center bn-gap-4",children:[o.jsxs(c.Avatar.Avatar,{children:[o.jsx(c.Avatar.AvatarImage,{src:e.avatarUrl,alt:e.username,className:"bn-h-7 bn-rounded-full"}),o.jsx(c.Avatar.AvatarFallback,{children:e.username[0]})]}),o.jsxs("div",{className:"bn-flex bn-flex-row bn-flex-nowrap bn-items-center bn-gap-2",children:[o.jsx("span",{className:"bn-text-sm bn-font-bold",children:e.username}),o.jsxs("span",{className:"bn-text-xs",children:[s," ",r&&`(${d.comments.edited})`]})]})]})}),Vn=b.forwardRef((n,t)=>{const{className:e,showActions:s,authorInfo:r,timeString:a,actions:d,edited:c,children:u,...l}=n;p.assertEmpty(l);const[f,x]=b.useState(!1),{focused:w,ref:y}=N.useFocusWithin(),M=d&&(s===!0||s===void 0||s==="hover"&&f||w);return o.jsxs("div",{ref:t,className:i(e,"bn-relative bn-flex bn-flex-col bn-gap-2"),onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),children:[M?o.jsx("div",{className:"bn-absolute bn-right-0 bn-top-0 bn-z-10",ref:y,children:d}):null,o.jsx(zn,{...n}),u]})}),_n=b.forwardRef((n,t)=>{const{className:e,onFocus:s,onBlur:r,autoFocus:a,editor:d,editable:c,...u}=n;return p.assertEmpty(u),o.jsx(fe,{autoFocus:a,className:i(e,""),editor:n.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:c,ref:t,onFocus:s,onBlur:r,children:o.jsx(N.FormattingToolbarController,{formattingToolbar:An})})}),An=()=>{const n=N.getFormattingToolbarItems([]).filter(t=>t.key!=="nestBlockButton"&&t.key!=="unnestBlockButton");return o.jsx(N.FormattingToolbar,{blockTypeSelectItems:[],children:n})},$n=b.forwardRef((n,t)=>{const{className:e,text:s,icon:r,isSelected:a,mainTooltip:d,secondaryTooltip:c,onClick:u,onMouseEnter:l,...f}=n;p.assertEmpty(f,!1);const x=g(),w=o.jsxs(x.Button.Button,{variant:a?"secondary":"outline",className:i(e,"bn-flex bn-items-center bn-gap-1 bn-rounded-full bn-h-7 bn-px-2.5"),onClick:u,onMouseEnter:l,ref:t,children:[o.jsx("span",{children:r}),o.jsx("span",{children:s})]});return d?o.jsxs(x.Tooltip.Tooltip,{children:[o.jsx(x.Tooltip.TooltipTrigger,{asChild:!0,children:w}),o.jsxs(x.Tooltip.TooltipContent,{className:"bn-flex bn-flex-col bn-items-center bn-whitespace-pre-wrap",children:[o.jsx("span",{children:d}),c&&o.jsx("span",{children:c})]})]}):w}),On=b.forwardRef((n,t)=>{const{className:e,children:s,...r}=n;p.assertEmpty(r);const a=g();return o.jsx(a.Tooltip.TooltipProvider,{delayDuration:0,children:o.jsx("div",{className:i(e,"bn-flex bn-flex-row bn-flex-wrap bn-gap-1 bn-w-full"),ref:t,children:s})})}),Gn=b.forwardRef((n,t)=>{const{className:e,children:s,onClick:r,label:a,...d}=n;p.assertEmpty(d);const c=g();return o.jsx(c.Button.Button,{type:"submit",className:e,"aria-label":a,ref:t,onClick:r,children:s})}),Hn=b.forwardRef((n,t)=>{const{className:e,accept:s,value:r,placeholder:a,onChange:d,...c}=n;p.assertEmpty(c);const u=g();return o.jsx(u.Input.Input,{type:"file",className:e,ref:t,accept:s,value:r?r.name:void 0,onChange:async l=>d==null?void 0:d(l.target.files[0]),placeholder:a})}),Un=b.forwardRef((n,t)=>{const{className:e,isSelected:s,onClick:r,item:a,id:d,...c}=n;p.assertEmpty(c);const u=b.useRef(null);return b.useEffect(()=>{if(!u.current||!s)return;const l=N.elementOverflow(u.current,document.querySelector(".bn-grid-suggestion-menu"));l==="top"?u.current.scrollIntoView(!0):l==="bottom"&&u.current.scrollIntoView(!1)},[s]),o.jsx("div",{className:e,ref:N.mergeRefs([t,u]),id:d,role:"option",onClick:r,"aria-selected":s||void 0,children:a.icon})}),Kn=b.forwardRef((n,t)=>{const{className:e,children:s,columns:r,...a}=n;return p.assertEmpty(a),o.jsx("div",{className:e,style:{gridColumn:`1 / ${r+1}`},ref:t,children:s})}),pe={FormattingToolbar:{Root:P,Button:k,Select:B},FilePanel:{Root:hn,Button:Gn,FileInput:Hn,TabPanel:vn,TextInput:wn},LinkToolbar:{Root:P,Button:k,Select:B},SideMenu:{Root:jn,Button:Sn},SuggestionMenu:{Root:Mn,Item:Dn,EmptyItem:In,Label:En,Loader:Pn},GridSuggestionMenu:{Root:Tn,Item:Un,EmptyItem:Rn,Loader:Kn},TableHandle:{Root:Bn,ExtendButton:kn},Comments:{Comment:Vn,Editor:_n,Card:Fn,CardSection:Ln,ExpandSectionsPrompt:qn},Generic:{Badge:{Root:$n,Group:On},Toolbar:{Root:P,Button:k,Select:B},Form:{Root:dn,TextInput:ln},Menu:{Root:cn,Trigger:mn,Dropdown:un,Divider:fn,Label:gn,Item:pn,Button:xn},Popover:{Root:Nn,Trigger:yn,Content:Cn}}},fe=n=>{const{className:t,shadCNComponents:e,...s}=n,r=b.useMemo(()=>({...an,...e}),[e]);return o.jsx(ue.Provider,{value:r,children:o.jsx(N.ComponentsContext.Provider,{value:pe,children:o.jsx(N.BlockNoteViewRaw,{className:p.mergeCSSClasses("bn-shadcn",t||""),...s})})})};exports.BlockNoteView=fe;exports.components=pe; //# sourceMappingURL=blocknote-shadcn.cjs.map