UNPKG

@blocknote/react

Version:

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

2 lines 2.32 kB
const e=require(`./defaultCommentEditorSchema-Cow33c_f.cjs`);let t=require(`react`),n=require(`@blocknote/core/comments`),r=require(`@floating-ui/react`),i=require(`@blocknote/core`),a=require(`react/jsx-runtime`),o=require(`@tiptap/pm/state`);var s=(0,t.memo)(({isEmpty:e,onSave:t,Components:n,dict:r})=>(0,a.jsx)(n.Generic.Toolbar.Root,{className:(0,i.mergeCSSClasses)(`bn-action-toolbar`,`bn-comment-actions`),variant:`action-toolbar`,children:(0,a.jsx)(n.Generic.Toolbar.Button,{className:`bn-button`,mainTooltip:r.comments.save_button_text,variant:`compact`,isDisabled:e,onClick:t,children:r.comments.save_button_text})}));function c(){let r=e.m(),i=e.f(n.CommentsExtension),c=e.l(),l=e.s(),u=e.r({trailingBlock:!1,dictionary:{...l,placeholders:{emptyDocument:l.placeholders.new_comment}},schema:i.commentEditorSchema||e.t}),d=(0,t.useCallback)(async()=>{await i.createThread({initialComment:{body:u.document}}),i.stopPendingComment(),r.transact(e=>{e.setSelection(o.TextSelection.create(e.doc,e.selection.to))}),r.focus()},[i,u,r]);return(0,a.jsx)(c.Comments.Card,{className:`bn-thread`,children:(0,a.jsx)(e.n,{autoFocus:!0,editable:!0,editor:u,actions:({isFocused:e,isEmpty:t})=>(0,a.jsx)(s,{isFocused:e,isEmpty:t,onSave:d,Components:c,dict:l})})})}var l=e._({default:()=>u});function u(i){let o=e.m(),s=e.f(n.CommentsExtension),l=e.p(n.CommentsExtension,{editor:o,selector:e=>e.pendingComment}),u=e.o({editor:o,selector:({editor:e})=>l?{from:e.prosemirrorState.selection.from,to:e.prosemirrorState.selection.to}:void 0}),d=(0,t.useMemo)(()=>({...i.floatingUIOptions,useFloatingOptions:{open:!!l,onOpenChange:e=>{e||(s.stopPendingComment(),o.focus())},placement:`bottom`,middleware:[(0,r.offset)(10),(0,r.shift)(),(0,r.flip)()],...i.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!1},elementProps:{style:{zIndex:60},...i.floatingUIOptions?.elementProps}}),[s,o,l,i.floatingUIOptions]),f=i.floatingComposer||c;return(0,a.jsx)(e.i,{position:u,portalElement:i.portalElement,...d,children:(0,a.jsx)(f,{})})}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}}); //# sourceMappingURL=FloatingComposerController-B4zPPPwD.cjs.map