@bettaibi/react-blocknote
Version:
A modern, versatile rich text editor component for React applications with an elegant UI and Notion-like functionality. Supports both React 18 and React 19.
2 lines (1 loc) • 13.1 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./blocknote-pWdOw1PK.cjs"),e=n.createLucideIcon("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]),t={LEFT:{textAlign:"left"},CENTER:{textAlign:"center"},RIGHT:{textAlign:"right"}};exports.BlockNoteProvider=n.BlockNoteProvider,exports.AlignCenterButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().setTextAlign("center").run(),className:e,title:"Align Center",...l,children:t??n.jsxRuntimeExports.jsx(n.AlignCenter,{size:o})}):null},exports.AlignLeftButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().setTextAlign("left").run(),className:e,title:"Align Left",...l,children:t??n.jsxRuntimeExports.jsx(n.AlignLeft,{size:o})}):null},exports.AlignRightButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().setTextAlign("right").run(),className:e,title:"Align Right",...l,children:t??n.jsxRuntimeExports.jsx(n.AlignRight,{size:o})}):null},exports.BlockNoteContent=function({className:e=""}){const t=n.useBlockNoteContext();return n.jsxRuntimeExports.jsx(n.EditorContent,{editor:t,className:e})},exports.BlockquoteButton=function({className:t="",children:o,iconSize:l=16,...i}){const u=n.useBlockNoteContext();return u?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>u.chain().focus().toggleBlockquote().run(),className:t,title:"Blockquote",...i,children:o??n.jsxRuntimeExports.jsx(e,{size:l})}):null},exports.BoldButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleBold().run(),className:e,title:"Bold",...l,children:t??n.jsxRuntimeExports.jsx(n.Bold,{size:o})}):null},exports.BubbleMenu=function({children:e,className:t="",...o}){const l=n.useBlockNoteContext();return l?n.jsxRuntimeExports.jsx(n.BubbleMenu,{editor:l,tippyOptions:{duration:100},className:t,...o,children:e}):null},exports.BulletListButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleBulletList().run(),className:e,title:"Bullet List",...l,children:t??n.jsxRuntimeExports.jsx(n.List,{size:o})}):null},exports.CodeBlockButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleCodeBlock().run(),className:e,title:"Code Block",...l,children:t??n.jsxRuntimeExports.jsx(n.Code,{size:o})}):null},exports.CodeButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleCode().run(),className:e,title:"Inline Code",...l,children:t??n.jsxRuntimeExports.jsx(n.Code,{size:o})}):null},exports.H1Button=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleHeading({level:1}).run(),className:e,title:"Heading 1",...l,children:t??n.jsxRuntimeExports.jsx(n.Heading1,{size:o})}):null},exports.H2Button=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleHeading({level:2}).run(),className:e,title:"Heading 2",...l,children:t??n.jsxRuntimeExports.jsx(n.Heading2,{size:o})}):null},exports.H3Button=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleHeading({level:3}).run(),className:e,title:"Heading 3",...l,children:t??n.jsxRuntimeExports.jsx(n.Heading3,{size:o})}):null},exports.H4Button=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleHeading({level:4}).run(),className:e,title:"Heading 4",...l,children:t??n.jsxRuntimeExports.jsx(n.Heading4,{size:o})}):null},exports.H5Button=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleHeading({level:5}).run(),className:e,title:"Heading 5",...l,children:t??n.jsxRuntimeExports.jsx(n.Heading5,{size:o})}):null},exports.H6Button=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleHeading({level:6}).run(),className:e,title:"Heading 6",...l,children:t??n.jsxRuntimeExports.jsx(n.Heading6,{size:o})}):null},exports.ItalicButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleItalic().run(),className:e,title:"Italic",...l,children:t??n.jsxRuntimeExports.jsx(n.Italic,{size:o})}):null},exports.NormalTextButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().setParagraph().run(),className:e,title:"Normal Text",...l,children:t??n.jsxRuntimeExports.jsx(n.Type,{size:o})}):null},exports.OrderedListButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleOrderedList().run(),className:e,title:"Ordered List",...l,children:t??n.jsxRuntimeExports.jsx(n.ListOrdered,{size:o})}):null},exports.RedoButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().redo().run(),disabled:!i.can().chain().focus().redo().run(),className:e,title:"Redo",...l,children:t??n.jsxRuntimeExports.jsx(n.Redo,{size:o})}):null},exports.StrikeButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleStrike().run(),className:e,title:"Strikethrough",...l,children:t??n.jsxRuntimeExports.jsx(n.Strikethrough,{size:o})}):null},exports.TaskListButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleTaskList().run(),className:e,title:"Task List",...l,children:t??n.jsxRuntimeExports.jsx(n.SquareCheckBig,{size:o})}):null},exports.UnderlineButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().toggleUnderline().run(),className:e,title:"Underline",...l,children:t??n.jsxRuntimeExports.jsx(n.Underline,{size:o})}):null},exports.UndoButton=function({className:e="",children:t,iconSize:o=16,...l}){const i=n.useBlockNoteContext();return i?n.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>i.chain().focus().undo().run(),disabled:!i.can().chain().focus().undo().run(),className:e,title:"Undo",...l,children:t??n.jsxRuntimeExports.jsx(n.Undo,{size:o})}):null},exports.useBlockNoteHandlers=function(){const e=n.useBlockNoteContext();return{handleBold:function(){null==e||e.chain().focus().toggleBold().run()},handleItalic:function(){null==e||e.chain().focus().toggleItalic().run()},handleUnderline:function(){null==e||e.chain().focus().toggleUnderline().run()},handleStrike:function(){null==e||e.chain().focus().toggleStrike().run()},handleCode:function(){null==e||e.chain().focus().toggleCode().run()},handleHeading1:function(){null==e||e.chain().focus().toggleHeading({level:1}).run()},handleHeading2:function(){null==e||e.chain().focus().toggleHeading({level:2}).run()},handleHeading3:function(){null==e||e.chain().focus().toggleHeading({level:3}).run()},handleHeading4:function(){null==e||e.chain().focus().toggleHeading({level:4}).run()},handleHeading5:function(){null==e||e.chain().focus().toggleHeading({level:5}).run()},handleHeading6:function(){null==e||e.chain().focus().toggleHeading({level:6}).run()},handleNormalText:function(){null==e||e.chain().focus().setParagraph().run()},handleBulletList:function(){null==e||e.chain().focus().toggleBulletList().run()},handleOrderedList:function(){null==e||e.chain().focus().toggleOrderedList().run()},handleTaskList:function(){null==e||e.chain().focus().toggleTaskList().run()},handleCodeBlock:function(){null==e||e.chain().focus().toggleCodeBlock().run()},handleBlockquote:function(){null==e||e.chain().focus().toggleBlockquote().run()},handleAlignLeft:function(){null==e||e.chain().focus().setTextAlign("left").run()},handleAlignCenter:function(){null==e||e.chain().focus().setTextAlign("center").run()},handleAlignRight:function(){null==e||e.chain().focus().setTextAlign("right").run()},handleUndo:function(){null==e||e.chain().focus().undo().run()},handleRedo:function(){null==e||e.chain().focus().redo().run()},handleImage:function({src:n,alt:t=""}){e.chain().focus().setImage({src:n,alt:t}).run()},handleLink:function(n){e.chain().focus().extendMarkRange("link").setLink({href:n}).run()},handleInsertTable:function(){null==e||e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},handleDeleteTable:function(){null==e||e.chain().focus().deleteTable().run()},handleAddColumnBefore:function(){null==e||e.chain().focus().addColumnBefore().run()},handleAddColumnAfter:function(){null==e||e.chain().focus().addColumnAfter().run()},handleDeleteColumn:function(){null==e||e.chain().focus().deleteColumn().run()},handleAddRowBefore:function(){null==e||e.chain().focus().addRowBefore().run()},handleAddRowAfter:function(){null==e||e.chain().focus().addRowAfter().run()},handleDeleteRow:function(){null==e||e.chain().focus().deleteRow().run()}}},exports.useBlockNoteValues=function(){const e=n.useBlockNoteContext(),o=null==e?void 0:e.can().undo(),l=null==e?void 0:e.can().redo(),i=null==e?void 0:e.can().chain().focus().toggleBold().run(),u=null==e?void 0:e.can().chain().focus().toggleItalic().run(),c=null==e?void 0:e.can().chain().focus().toggleUnderline().run(),s=null==e?void 0:e.can().chain().focus().toggleStrike().run(),a=null==e?void 0:e.can().chain().focus().toggleCode().run(),r=null==e?void 0:e.can().chain().focus().toggleHeading({level:1}).run(),d=null==e?void 0:e.can().chain().focus().toggleHeading({level:2}).run(),x=null==e?void 0:e.can().chain().focus().toggleHeading({level:3}).run(),g=null==e?void 0:e.can().chain().focus().toggleHeading({level:4}).run(),h=null==e?void 0:e.can().chain().focus().toggleHeading({level:5}).run(),f=null==e?void 0:e.can().chain().focus().toggleHeading({level:6}).run(),m=null==e?void 0:e.can().chain().focus().setParagraph().run(),p=null==e?void 0:e.can().chain().focus().toggleBulletList().run(),j=null==e?void 0:e.can().chain().focus().toggleOrderedList().run(),B=null==e?void 0:e.can().chain().focus().toggleTaskList().run(),k=null==e?void 0:e.can().chain().focus().toggleCodeBlock().run(),C=null==e?void 0:e.can().chain().focus().toggleBlockquote().run(),N=null==e?void 0:e.can().chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),R=null==e?void 0:e.can().chain().focus().deleteTable().run(),b=null==e?void 0:e.can().chain().focus().addColumnBefore().run(),v=null==e?void 0:e.can().chain().focus().addColumnAfter().run(),H=null==e?void 0:e.can().chain().focus().deleteColumn().run(),E=null==e?void 0:e.can().chain().focus().addRowBefore().run(),z=null==e?void 0:e.can().chain().focus().addRowAfter().run(),A=null==e?void 0:e.can().chain().focus().deleteRow().run();return{getActiveMark:function(n){return!!(null==e?void 0:e.isActive(n))},getTextAlignState:function(n){return!!(null==e?void 0:e.isActive(n))},TextAlign:t,canUndo:o,canRedo:l,canBold:i,canItalic:u,canUnderline:c,canStrike:s,canCode:a,canHeading1:r,canHeading2:d,canHeading3:x,canHeading4:g,canHeading5:h,canHeading6:f,canNormalText:m,canBulletList:p,canOrderedList:j,canTaskList:B,canCodeBlock:k,canBlockquote:C,canInsertTable:N,canDeleteTable:R,canAddColumnBefore:b,canAddColumnAfter:v,canDeleteColumn:H,canAddRowBefore:E,canAddRowAfter:z,canDeleteRow:A}};