UNPKG

@liveblocks/react-blocknote

Version:

An integration of BlockNote + React to enable collaboration, comments, live cursors, and more with Liveblocks.

1 lines 2.54 kB
{"version":3,"file":"liveblocksEditorOptions.cjs","sources":["../../src/initialization/liveblocksEditorOptions.ts"],"sourcesContent":["import {\n type BlockNoteEditorOptions,\n type BlockSchema,\n createBlockNoteExtension,\n type DefaultBlockSchema,\n type DefaultInlineContentSchema,\n type DefaultStyleSchema,\n type InlineContentSchema,\n type StyleSchema,\n} from \"@blocknote/core\";\nimport type { Extension } from \"@tiptap/core\";\n\nimport { withLiveblocksSchema } from \"./schema\";\n/**\n * Helper function to add Liveblocks support to BlockNoteEditorOptions\n */\nexport const withLiveblocksEditorOptions = <\n B extends BlockSchema = DefaultBlockSchema,\n I extends InlineContentSchema = DefaultInlineContentSchema,\n S extends StyleSchema = DefaultStyleSchema,\n>(\n liveblocksExtension: Extension<any, any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n blocknoteOptions: Partial<BlockNoteEditorOptions<B, I, S>> = {},\n liveblocksOptions: Partial<{ mentions: boolean }> = {}\n): Partial<BlockNoteEditorOptions<B, I, S>> => {\n const {\n schema: blocknoteSchema,\n extensions: blocknoteExtensions,\n disableExtensions: blocknoteDisableExtensions,\n ...extraBlocknoteOptions\n } = blocknoteOptions;\n\n return {\n // add the liveblocks schema (i.e.: add the mentions nodes to the schema)\n schema: withLiveblocksSchema(blocknoteSchema, liveblocksOptions),\n\n // add the liveblocks extension\n extensions: [\n createBlockNoteExtension({\n key: \"liveblocksExtension\",\n tiptapExtensions: [liveblocksExtension],\n }),\n ...(blocknoteExtensions ?? []),\n ],\n\n // disable the history extension\n disableExtensions: [\"history\", ...(blocknoteDisableExtensions || [])],\n\n // pass the rest of the options through\n ...extraBlocknoteOptions,\n };\n};\n"],"names":["withLiveblocksSchema","createBlockNoteExtension"],"mappings":";;;;;AAgBa,MAAA,2BAAA,GAA8B,CAKzC,mBAEA,EAAA,gBAAA,GAA6D,EAC7D,EAAA,iBAAA,GAAoD,EACP,KAAA;AAC7C,EAAM,MAAA;AAAA,IACJ,MAAQ,EAAA,eAAA;AAAA,IACR,UAAY,EAAA,mBAAA;AAAA,IACZ,iBAAmB,EAAA,0BAAA;AAAA,IACnB,GAAG,qBAAA;AAAA,GACD,GAAA,gBAAA,CAAA;AAEJ,EAAO,OAAA;AAAA;AAAA,IAEL,MAAA,EAAQA,2BAAqB,CAAA,eAAA,EAAiB,iBAAiB,CAAA;AAAA;AAAA,IAG/D,UAAY,EAAA;AAAA,MACVC,6BAAyB,CAAA;AAAA,QACvB,GAAK,EAAA,qBAAA;AAAA,QACL,gBAAA,EAAkB,CAAC,mBAAmB,CAAA;AAAA,OACvC,CAAA;AAAA,MACD,GAAI,uBAAuB,EAAC;AAAA,KAC9B;AAAA;AAAA,IAGA,mBAAmB,CAAC,SAAA,EAAW,GAAI,0BAAA,IAA8B,EAAG,CAAA;AAAA;AAAA,IAGpE,GAAG,qBAAA;AAAA,GACL,CAAA;AACF;;;;"}