@blocknote/core 0.51.4 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-B_IEJHS8.js +38 -0
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +1 -0
- package/dist/BlockNoteExtension-M0znTzxP.cjs +2 -0
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +1 -0
- package/dist/ThreadStore-Bx-gSEh1.cjs +2 -0
- package/dist/ThreadStore-Bx-gSEh1.cjs.map +1 -0
- package/dist/ThreadStore-et9wB5Xt.js +11 -0
- package/dist/ThreadStore-et9wB5Xt.js.map +1 -0
- package/dist/UserStore-DCG6lsla.cjs +2 -0
- package/dist/UserStore-DCG6lsla.cjs.map +1 -0
- package/dist/UserStore-QbbPFj0z.js +73 -0
- package/dist/UserStore-QbbPFj0z.js.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -7
- package/dist/blocks-BqHv0xhc.cjs +12 -0
- package/dist/blocks-BqHv0xhc.cjs.map +1 -0
- package/dist/{blocks-DGsP5WKr.js → blocks-CiuUGa1E.js} +1093 -994
- package/dist/blocks-CiuUGa1E.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +75 -340
- package/dist/comments.js.map +1 -1
- package/dist/{en-Cj5r8sW_.cjs → en-C5Z4Ag9_.cjs} +2 -2
- package/dist/en-C5Z4Ag9_.cjs.map +1 -0
- package/dist/{en-B9hMApn4.js → en-CGKXfWma.js} +9 -1
- package/dist/en-CGKXfWma.js.map +1 -0
- package/dist/{extensions-Co4y7P63.js → extensions-CrUGDOks.js} +655 -583
- package/dist/extensions-CrUGDOks.js.map +1 -0
- package/dist/extensions-Ghr9QqqR.cjs +52 -0
- package/dist/extensions-Ghr9QqqR.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +177 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-Bcud0PIg.js → src-DTF83Cl9.js} +1243 -1297
- package/dist/src-DTF83Cl9.js.map +1 -0
- package/dist/src-OfbaVbMw.cjs +21 -0
- package/dist/src-OfbaVbMw.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +2 -0
- package/dist/y.cjs.map +1 -0
- package/dist/y.js +989 -0
- package/dist/y.js.map +1 -0
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +535 -14
- package/dist/yjs.js.map +1 -1
- package/package.json +46 -19
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -20
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +39 -29
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +2 -2
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +4 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +21 -9
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +6 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +362 -4
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +240 -30
- package/src/api/blockManipulation/getBlock/getBlock.ts +4 -9
- package/src/api/blockManipulation/selections/selection.ts +3 -6
- package/src/api/blockManipulation/selections/textCursorPosition.ts +10 -10
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/blockManipulation/tables/tables.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -4
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +2 -1
- package/src/api/exporters/markdown/htmlToMarkdown.ts +79 -43
- package/src/api/getBlockInfoFromPos.test.ts +256 -0
- package/src/api/getBlockInfoFromPos.ts +53 -15
- package/src/api/getBlocksChangedByTransaction.test.ts +2 -1
- package/src/api/getBlocksChangedByTransaction.ts +6 -6
- package/src/api/nodeConversions/blockToNode.test.ts +113 -0
- package/src/api/nodeConversions/blockToNode.ts +15 -3
- package/src/api/nodeConversions/fragmentToBlocks.ts +2 -4
- package/src/api/nodeConversions/nodeToBlock.ts +28 -58
- package/src/api/nodeUtil.ts +6 -2
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -1
- package/src/api/parsers/markdown/detectMarkdown.test.ts +1 -1
- package/src/api/parsers/markdown/markdownToHtml.ts +228 -82
- package/src/api/pmUtil.ts +18 -1
- package/src/api/positionMapping.test.ts +20 -345
- package/src/api/positionMapping.ts +13 -83
- package/src/blocks/Audio/block.ts +1 -1
- package/src/blocks/Code/block.test.ts +14 -7
- package/src/blocks/Code/block.ts +2 -2
- package/src/blocks/Image/block.ts +1 -1
- package/src/blocks/ListItem/CheckListItem/block.test.ts +1 -1
- package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +4 -11
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +47 -50
- package/src/blocks/Table/TableExtension.test.ts +9 -6
- package/src/blocks/Table/TableExtension.ts +20 -6
- package/src/blocks/Table/block.ts +18 -5
- package/src/blocks/Video/block.ts +1 -1
- package/src/blocks/utils/listItemEnterHandler.ts +3 -2
- package/src/comments/extension.ts +30 -21
- package/src/comments/index.ts +0 -3
- package/src/comments/mark.ts +4 -0
- package/src/comments/threadstore/ThreadStore.ts +4 -8
- package/src/comments/types.ts +0 -8
- package/src/editor/Block.css +307 -3
- package/src/editor/BlockNoteEditor.test.ts +21 -18
- package/src/editor/BlockNoteEditor.ts +22 -57
- package/src/editor/BlockNoteExtension.test.ts +1 -1
- package/src/editor/managers/BlockManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +249 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +7 -18
- package/src/editor/managers/ExtensionManager/index.ts +168 -68
- package/src/editor/managers/StateManager.ts +4 -3
- package/src/editor/performance.test.ts +14 -1
- package/src/editor/transformPasted.test.ts +1 -1
- package/src/extensions/Placeholder/Placeholder.ts +1 -0
- package/src/extensions/PositionMapping/PositionMapping.ts +68 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +14 -1
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +14 -11
- package/src/extensions/SideMenu/SideMenu.ts +9 -2
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +1 -1
- package/src/extensions/TableHandles/TableHandles.ts +18 -20
- package/src/extensions/TrailingNode/TrailingNode.ts +33 -1
- package/src/extensions/Versioning/Versioning.test.ts +435 -0
- package/src/extensions/Versioning/Versioning.ts +628 -0
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +469 -0
- package/src/extensions/Versioning/inMemoryVersioning.ts +263 -0
- package/src/extensions/Versioning/index.ts +2 -0
- package/src/extensions/index.ts +6 -9
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +155 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +6 -8
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +9 -9
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +8 -10
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +2 -2
- package/src/extensions/tiptap-extensions/Link/link.test.ts +26 -22
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +187 -0
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +37 -24
- package/src/extensions/tiptap-extensions/index.ts +1 -25
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +10 -1
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +11 -1
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +10 -1
- package/src/i18n/locales/hr.ts +10 -0
- package/src/i18n/locales/is.ts +10 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +10 -0
- package/src/i18n/locales/no.ts +10 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +10 -0
- package/src/i18n/locales/ru.ts +10 -0
- package/src/i18n/locales/sk.ts +10 -1
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +2 -0
- package/src/pm-nodes/BlockContainer.ts +4 -1
- package/src/pm-nodes/BlockGroup.ts +4 -1
- package/src/pm-nodes/Doc.ts +4 -1
- package/src/pm-nodes/suggestionMarks.ts +43 -0
- package/src/schema/blocks/createSpec.test.ts +123 -0
- package/src/schema/blocks/createSpec.ts +82 -24
- package/src/schema/blocks/extendBlockSpec.test.ts +188 -0
- package/src/schema/blocks/internal.ts +13 -43
- package/src/schema/blocks/types.ts +69 -22
- package/src/schema/contentTypePropagation.test.ts +182 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/inlineContent/internal.ts +1 -1
- package/src/schema/inlineContent/types.ts +3 -3
- package/src/schema/markGroups.ts +50 -0
- package/src/user/UserStore.ts +199 -0
- package/src/user/createUserStore.test.ts +126 -0
- package/src/user/index.ts +2 -0
- package/src/user/userColors.ts +72 -0
- package/src/util/string.ts +1 -1
- package/src/util/topo-sort.test.ts +1 -1
- package/src/util/typescript.ts +2 -1
- package/src/vite-env.d.ts +1 -1
- package/src/y/README.md +5 -0
- package/src/{comments/threadstore/yjs → y/comments}/RESTYjsThreadStore.ts +8 -14
- package/src/y/comments/YjsThreadStore.test.ts +295 -0
- package/src/y/comments/YjsThreadStore.ts +358 -0
- package/src/y/comments/YjsThreadStoreBase.ts +50 -0
- package/src/y/comments/index.ts +3 -0
- package/src/y/comments/yjsHelpers.ts +125 -0
- package/src/y/extensions/AttributionExtension.test.ts +86 -0
- package/src/y/extensions/AttributionExtension.ts +378 -0
- package/src/y/extensions/DiffVersioningExtension.test.ts +193 -0
- package/src/y/extensions/DiffVersioningExtension.ts +228 -0
- package/src/y/extensions/ForkYDoc.test.ts +253 -0
- package/src/y/extensions/ForkYDoc.ts +108 -0
- package/src/y/extensions/RelativePositionMapping.test.ts +418 -0
- package/src/y/extensions/RelativePositionMapping.ts +49 -0
- package/src/y/extensions/Suggestions.ts +174 -0
- package/src/y/extensions/Versioning.test.ts +395 -0
- package/src/y/extensions/Versioning.ts +115 -0
- package/src/y/extensions/YAttributionMarks.ts +320 -0
- package/src/{extensions/Collaboration → y/extensions}/YCursorPlugin.ts +15 -7
- package/src/y/extensions/YSync.ts +125 -0
- package/src/y/extensions/blockMatchNodes.ts +182 -0
- package/src/y/extensions/index.ts +156 -0
- package/src/y/index.ts +4 -0
- package/src/y/utils.test.ts +1042 -0
- package/src/y/utils.ts +242 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +50 -0
- package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all.json +20 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +32 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +1 -0
- package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
- package/src/y/versioning/__test__/fixtures/patch-response.json +4 -0
- package/src/y/versioning/__test__/yhub.test.ts +752 -0
- package/src/y/versioning/index.ts +1 -0
- package/src/y/versioning/yhub.ts +631 -0
- package/src/yjs/README.md +5 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +166 -0
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.test.ts +3 -3
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.ts +7 -3
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.ts +3 -3
- package/src/yjs/comments/index.ts +3 -0
- package/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.ts +5 -1
- package/src/yjs/extensions/FixUpSchema.test.ts +421 -0
- package/src/yjs/extensions/FixUpSchema.ts +88 -0
- package/src/yjs/extensions/ForkYDoc.test.ts +216 -0
- package/src/{extensions/Collaboration → yjs/extensions}/ForkYDoc.ts +38 -57
- package/src/yjs/extensions/RelativePositionMapping.test.ts +418 -0
- package/src/yjs/extensions/RelativePositionMapping.ts +71 -0
- package/src/yjs/extensions/Versioning.test.ts +549 -0
- package/src/yjs/extensions/Versioning.ts +83 -0
- package/src/yjs/extensions/YCursorPlugin.ts +201 -0
- package/src/{extensions/Collaboration → yjs/extensions}/YSync.ts +1 -1
- package/src/yjs/extensions/index.ts +89 -0
- package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.test.ts +1 -1
- package/src/yjs/index.ts +2 -0
- package/src/yjs/utils.test.ts +5 -15
- package/src/yjs/utils.ts +36 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +3 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +5 -9
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +4 -6
- package/types/src/api/pmUtil.d.ts +12 -1
- package/types/src/blocks/Audio/block.d.ts +2 -2
- package/types/src/blocks/Code/block.d.ts +2 -2
- package/types/src/blocks/File/block.d.ts +2 -2
- package/types/src/blocks/Heading/block.d.ts +21 -21
- package/types/src/blocks/Image/block.d.ts +3 -3
- package/types/src/blocks/ListItem/CheckListItem/block.d.ts +6 -6
- package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +6 -6
- package/types/src/blocks/Video/block.d.ts +3 -3
- package/types/src/blocks/defaultBlocks.d.ts +17 -17
- package/types/src/comments/extension.d.ts +18 -5
- package/types/src/comments/index.d.ts +0 -3
- package/types/src/comments/threadstore/ThreadStore.d.ts +4 -8
- package/types/src/comments/types.d.ts +0 -8
- package/types/src/editor/BlockNoteEditor.d.ts +8 -9
- package/types/src/editor/managers/BlockManager.d.ts +1 -1
- package/types/src/editor/managers/ExtensionManager/extensions.d.ts +2 -2
- package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
- package/types/src/editor/managers/SelectionManager.d.ts +1 -1
- package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
- package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
- package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/index.d.ts +2 -0
- package/types/src/extensions/index.d.ts +6 -9
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
- package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
- package/types/src/i18n/locales/en.d.ts +9 -1
- package/types/src/i18n/locales/fa.d.ts +9 -1
- package/types/src/i18n/locales/sk.d.ts +9 -1
- package/types/src/index.d.ts +2 -0
- package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
- package/types/src/schema/blocks/createSpec.d.ts +4 -4
- package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
- package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
- package/types/src/schema/blocks/internal.d.ts +5 -7
- package/types/src/schema/blocks/types.d.ts +22 -14
- package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
- package/types/src/schema/index.d.ts +1 -0
- package/types/src/schema/inlineContent/types.d.ts +3 -3
- package/types/src/schema/markGroups.d.ts +33 -0
- package/types/src/user/UserStore.d.ts +105 -0
- package/types/src/user/createUserStore.test.d.ts +1 -0
- package/types/src/user/index.d.ts +2 -0
- package/types/src/user/userColors.d.ts +36 -0
- package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
- package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
- package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
- package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
- package/types/src/y/comments/index.d.ts +3 -0
- package/types/src/y/comments/yjsHelpers.d.ts +13 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
- package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
- package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
- package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
- package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
- package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
- package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
- package/types/src/y/extensions/Suggestions.d.ts +36 -0
- package/types/src/y/extensions/Versioning.d.ts +17 -0
- package/types/src/y/extensions/Versioning.test.d.ts +1 -0
- package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
- package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
- package/types/src/y/extensions/YSync.d.ts +32 -0
- package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
- package/types/src/y/extensions/index.d.ts +189 -0
- package/types/src/y/index.d.ts +4 -0
- package/types/src/y/utils.d.ts +82 -0
- package/types/src/y/utils.test.d.ts +1 -0
- package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
- package/types/src/y/versioning/index.d.ts +1 -0
- package/types/src/y/versioning/yhub.d.ts +87 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
- package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
- package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
- package/types/src/yjs/comments/index.d.ts +3 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
- package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
- package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
- package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
- package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
- package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
- package/types/src/yjs/extensions/Versioning.d.ts +26 -0
- package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
- package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
- package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
- package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
- package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
- package/types/src/yjs/index.d.ts +2 -0
- package/types/src/yjs/utils.d.ts +5 -0
- package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
- package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
- package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
- package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
- package/dist/EventEmitter-CuPnGDYt.js +0 -22
- package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
- package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
- package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
- package/dist/ShowSelection-BsHFfdMi.js +0 -29
- package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
- package/dist/ShowSelection-DhXglbt8.cjs +0 -2
- package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
- package/dist/blocks-Bm6IfL1R.cjs +0 -11
- package/dist/blocks-Bm6IfL1R.cjs.map +0 -1
- package/dist/blocks-DGsP5WKr.js.map +0 -1
- package/dist/en-B9hMApn4.js.map +0 -1
- package/dist/en-Cj5r8sW_.cjs.map +0 -1
- package/dist/extensions-Co4y7P63.js.map +0 -1
- package/dist/extensions-IJK3t0sz.cjs +0 -52
- package/dist/extensions-IJK3t0sz.cjs.map +0 -1
- package/dist/src-B6rlChSc.cjs +0 -21
- package/dist/src-B6rlChSc.cjs.map +0 -1
- package/dist/src-Bcud0PIg.js.map +0 -1
- package/src/comments/userstore/UserStore.ts +0 -72
- package/src/extensions/Collaboration/Collaboration.ts +0 -55
- package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
- package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
- package/types/src/comments/userstore/UserStore.d.ts +0 -31
- package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
- /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
- /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → editor/managers/ExtensionManager/ExtensionManager.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Attributes,
|
|
2
|
-
import type {
|
|
1
|
+
import { Attributes, Node } from "@tiptap/core";
|
|
2
|
+
import type { Node as PMNode } from "prosemirror-model";
|
|
3
3
|
import type { ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
|
|
4
|
-
import { InlineContentSchema } from "../inlineContent/types.js";
|
|
5
4
|
import { PropSchema, Props } from "../propTypes.js";
|
|
6
|
-
import {
|
|
7
|
-
import { BlockConfig, BlockSchemaWithBlock, LooseBlockSpec, SpecificBlock } from "./types.js";
|
|
5
|
+
import { LooseBlockSpec } from "./types.js";
|
|
8
6
|
export declare function propsToAttributes(propSchema: PropSchema): Attributes;
|
|
9
|
-
export declare function getBlockFromPos
|
|
7
|
+
export declare function getBlockFromPos(getPos: () => number | undefined, doc: PMNode): import("../../index.js").Block<Record<string, import("./types.js").BlockConfig<string, PropSchema, "inline" | "none" | "plain" | "table">>, import("../index.js").InlineContentSchema, import("../index.js").StyleSchema>;
|
|
10
8
|
export declare function wrapInBlockStructure<BType extends string, PSchema extends PropSchema>(element: {
|
|
11
9
|
dom: HTMLElement | DocumentFragment;
|
|
12
10
|
contentDOM?: HTMLElement;
|
|
@@ -19,5 +17,5 @@ export declare function wrapInBlockStructure<BType extends string, PSchema exten
|
|
|
19
17
|
export declare function createBlockSpecFromTiptapNode<const T extends {
|
|
20
18
|
node: Node;
|
|
21
19
|
type: string;
|
|
22
|
-
content: "inline" | "table" | "none";
|
|
20
|
+
content: "inline" | "table" | "none" | "plain";
|
|
23
21
|
}, P extends PropSchema>(config: T, propSchema: P, extensions?: ExtensionFactoryInstance[]): LooseBlockSpec<T["type"], P, T["content"]>;
|
|
@@ -4,7 +4,7 @@ import type { Fragment, Schema } from "prosemirror-model";
|
|
|
4
4
|
import type { ViewMutationRecord } from "prosemirror-view";
|
|
5
5
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
6
6
|
import type { Extension, ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
|
|
7
|
-
import type { InlineContent, InlineContentSchema, PartialInlineContent } from "../inlineContent/types.js";
|
|
7
|
+
import type { InlineContent, InlineContentSchema, PartialInlineContent, StyledText } from "../inlineContent/types.js";
|
|
8
8
|
import type { PropSchema, Props } from "../propTypes.js";
|
|
9
9
|
import type { StyleSchema } from "../styles/types.js";
|
|
10
10
|
export type BlockNoteDOMElement = "editor" | "block" | "blockGroup" | "blockContent" | "inlineContent";
|
|
@@ -42,7 +42,7 @@ export interface BlockConfigMeta {
|
|
|
42
42
|
* BlockConfig contains the "schema" info about a Block type
|
|
43
43
|
* i.e. what props it supports, what content it supports, etc.
|
|
44
44
|
*/
|
|
45
|
-
export interface BlockConfig<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" = "inline" | "none" | "table"> {
|
|
45
|
+
export interface BlockConfig<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" | "plain" = "inline" | "none" | "table" | "plain"> {
|
|
46
46
|
/**
|
|
47
47
|
* The type of the block (unique identifier within a schema)
|
|
48
48
|
*/
|
|
@@ -61,13 +61,13 @@ export interface BlockConfig<T extends string = string, PS extends PropSchema =
|
|
|
61
61
|
* BlockConfigOrCreator is a union type of BlockConfig and a function that returns a BlockConfig.
|
|
62
62
|
* This is used to create block configs that can be passed to the createBlockSpec function.
|
|
63
63
|
*/
|
|
64
|
-
export type BlockConfigOrCreator<TName extends string = string, TProps extends PropSchema = PropSchema, TContent extends "inline" | "none" = "inline" | "none", TOptions extends Record<string, any> | undefined = Record<string, any> | undefined> = BlockConfig<TName, TProps, TContent> | (TOptions extends undefined ? () => BlockConfig<TName, TProps, TContent> : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>);
|
|
64
|
+
export type BlockConfigOrCreator<TName extends string = string, TProps extends PropSchema = PropSchema, TContent extends "inline" | "none" | "plain" = "inline" | "none" | "plain", TOptions extends Record<string, any> | undefined = Record<string, any> | undefined> = BlockConfig<TName, TProps, TContent> | (TOptions extends undefined ? () => BlockConfig<TName, TProps, TContent> : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>);
|
|
65
65
|
/**
|
|
66
66
|
* ExtractBlockConfigFromConfigOrCreator is a helper type that extracts the BlockConfig type from a BlockConfigOrCreator.
|
|
67
67
|
*/
|
|
68
|
-
export type ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator extends BlockConfig<string, PropSchema, "inline" | "none"> | ((...args: any[]) => BlockConfig<string, PropSchema, "inline" | "none">)> = ConfigOrCreator extends (...args: any[]) => infer Config ? Config : ConfigOrCreator;
|
|
69
|
-
export type CustomBlockConfig<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" = "inline" | "none"> = BlockConfig<T, PS, C>;
|
|
70
|
-
export type BlockSpec<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" = "inline" | "none" | "table"> = {
|
|
68
|
+
export type ExtractBlockConfigFromConfigOrCreator<ConfigOrCreator extends BlockConfig<string, PropSchema, "inline" | "none" | "plain"> | ((...args: any[]) => BlockConfig<string, PropSchema, "inline" | "none" | "plain">)> = ConfigOrCreator extends (...args: any[]) => infer Config ? Config : ConfigOrCreator;
|
|
69
|
+
export type CustomBlockConfig<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "plain" = "inline" | "none" | "plain"> = BlockConfig<T, PS, C>;
|
|
70
|
+
export type BlockSpec<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" | "plain" = "inline" | "none" | "table" | "plain"> = {
|
|
71
71
|
config: BlockConfig<T, PS, C>;
|
|
72
72
|
implementation: BlockImplementation<T, PS, C>;
|
|
73
73
|
extensions?: (Extension | ExtensionFactoryInstance)[];
|
|
@@ -76,18 +76,18 @@ export type BlockSpec<T extends string = string, PS extends PropSchema = PropSch
|
|
|
76
76
|
* BlockSpecOrCreator is a union type of BlockSpec and a function that returns a BlockSpec.
|
|
77
77
|
* This is used to create block specs that can be passed to the createBlockSpec function.
|
|
78
78
|
*/
|
|
79
|
-
export type BlockSpecOrCreator<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" = "inline" | "none" | "table", TOptions extends Record<string, any> | undefined = Record<string, any> | undefined> = BlockSpec<T, PS, C> | (TOptions extends undefined ? () => BlockSpec<T, PS, C> : (options: Partial<TOptions>) => BlockSpec<T, PS, C>);
|
|
79
|
+
export type BlockSpecOrCreator<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" | "plain" = "inline" | "none" | "table" | "plain", TOptions extends Record<string, any> | undefined = Record<string, any> | undefined> = BlockSpec<T, PS, C> | (TOptions extends undefined ? () => BlockSpec<T, PS, C> : (options: Partial<TOptions>) => BlockSpec<T, PS, C>);
|
|
80
80
|
/**
|
|
81
81
|
* ExtractBlockSpecFromSpecOrCreator is a helper type that extracts the BlockSpec type from a BlockSpecOrCreator.
|
|
82
82
|
*/
|
|
83
|
-
export type ExtractBlockSpecFromSpecOrCreator<SpecOrCreator extends BlockSpec<string, PropSchema, "inline" | "none"> | ((...args: any[]) => BlockSpec<string, PropSchema, "inline" | "none">)> = SpecOrCreator extends (...args: any[]) => infer Spec ? Spec : SpecOrCreator;
|
|
83
|
+
export type ExtractBlockSpecFromSpecOrCreator<SpecOrCreator extends BlockSpec<string, PropSchema, "inline" | "none" | "plain"> | ((...args: any[]) => BlockSpec<string, PropSchema, "inline" | "none" | "plain">)> = SpecOrCreator extends (...args: any[]) => infer Spec ? Spec : SpecOrCreator;
|
|
84
84
|
/**
|
|
85
85
|
* This allows de-coupling the types that we display to users versus the types we expose internally.
|
|
86
86
|
*
|
|
87
87
|
* This prevents issues with type-inference across parameters that Typescript cannot handle.
|
|
88
88
|
* Specifically, the blocks shape cannot be properly inferred to a specific type like we expose to the user.
|
|
89
89
|
*/
|
|
90
|
-
export type LooseBlockSpec<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" = "inline" | "none" | "table"> = {
|
|
90
|
+
export type LooseBlockSpec<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "table" | "plain" = "inline" | "none" | "table" | "plain"> = {
|
|
91
91
|
config: BlockConfig<T, PS, C>;
|
|
92
92
|
implementation: Omit<BlockImplementation<T, PS, C>, "render" | "toExternalHTML"> & {
|
|
93
93
|
render: (
|
|
@@ -185,11 +185,17 @@ export type TableContent<I extends InlineContentSchema, S extends StyleSchema =
|
|
|
185
185
|
cells: InlineContent<I, S>[][] | TableCell<I, S>[];
|
|
186
186
|
}[];
|
|
187
187
|
};
|
|
188
|
+
export type PlainContent = (StyledText<{}> & {
|
|
189
|
+
styles: Record<string, never>;
|
|
190
|
+
})[];
|
|
191
|
+
export type PartialPlainContent = string | (string | (StyledText<{}> & {
|
|
192
|
+
styles: Record<string, never>;
|
|
193
|
+
}))[];
|
|
188
194
|
export type BlockFromConfigNoChildren<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
189
195
|
id: string;
|
|
190
196
|
type: B["type"];
|
|
191
197
|
props: Props<B["propSchema"]>;
|
|
192
|
-
content: B["content"] extends "inline" ? InlineContent<I, S>[] : B["content"] extends "table" ? TableContent<I, S> : B["content"] extends "none" ? undefined : never;
|
|
198
|
+
content: B["content"] extends "inline" ? InlineContent<I, S>[] : B["content"] extends "table" ? TableContent<I, S> : B["content"] extends "plain" ? PlainContent : B["content"] extends "none" ? undefined : never;
|
|
193
199
|
};
|
|
194
200
|
export type BlockFromConfig<B extends BlockConfig, I extends InlineContentSchema, S extends StyleSchema> = BlockFromConfigNoChildren<B, I, S> & {
|
|
195
201
|
children: BlockNoDefaults<BlockSchema, I, S>[];
|
|
@@ -227,7 +233,7 @@ type PartialBlockFromConfigNoChildren<B extends BlockConfig, I extends InlineCon
|
|
|
227
233
|
id?: string;
|
|
228
234
|
type?: B["type"];
|
|
229
235
|
props?: Partial<Props<B["propSchema"]>>;
|
|
230
|
-
content?: B["content"] extends "inline" ? PartialInlineContent<I, S> : B["content"] extends "table" ? PartialTableContent<I, S> : B["content"] extends "none" ? undefined : never;
|
|
236
|
+
content?: B["content"] extends "inline" ? PartialInlineContent<I, S> : B["content"] extends "table" ? PartialTableContent<I, S> : B["content"] extends "plain" ? PartialPlainContent : B["content"] extends "none" ? undefined : never;
|
|
231
237
|
};
|
|
232
238
|
type PartialBlocksWithoutChildren<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
233
239
|
[BType in keyof BSchema]: PartialBlockFromConfigNoChildren<BSchema[BType], I, S>;
|
|
@@ -244,7 +250,7 @@ export type PartialBlockFromConfig<B extends BlockConfig, I extends InlineConten
|
|
|
244
250
|
export type BlockIdentifier = {
|
|
245
251
|
id: string;
|
|
246
252
|
} | string;
|
|
247
|
-
export type BlockImplementation<TName extends string = string, TProps extends PropSchema = PropSchema, TContent extends "inline" | "none" | "table" = "inline" | "none" | "table"> = {
|
|
253
|
+
export type BlockImplementation<TName extends string = string, TProps extends PropSchema = PropSchema, TContent extends "inline" | "none" | "table" | "plain" = "inline" | "none" | "table" | "plain"> = {
|
|
248
254
|
/**
|
|
249
255
|
* Metadata
|
|
250
256
|
*/
|
|
@@ -254,6 +260,7 @@ export type BlockImplementation<TName extends string = string, TProps extends Pr
|
|
|
254
260
|
*/
|
|
255
261
|
render: (this: Record<string, never> | ({
|
|
256
262
|
blockContentDOMAttributes: Record<string, string>;
|
|
263
|
+
propSchema?: TProps;
|
|
257
264
|
} & ({
|
|
258
265
|
renderType: "nodeView";
|
|
259
266
|
props: NodeViewRendererProps;
|
|
@@ -280,6 +287,7 @@ export type BlockImplementation<TName extends string = string, TProps extends Pr
|
|
|
280
287
|
*/
|
|
281
288
|
toExternalHTML?: (this: Partial<{
|
|
282
289
|
blockContentDOMAttributes: Record<string, string>;
|
|
290
|
+
propSchema: TProps;
|
|
283
291
|
}>, block: BlockFromConfig<BlockConfig<TName, TProps, TContent>, any, any>, editor: BlockNoteEditor<Record<TName, BlockConfig<TName, TProps, TContent>>>, context: {
|
|
284
292
|
nestingLevel: number;
|
|
285
293
|
}) => {
|
|
@@ -313,6 +321,6 @@ export type BlockImplementationOrCreator<ConfigOrCreator extends BlockConfigOrCr
|
|
|
313
321
|
/**
|
|
314
322
|
* ExtractBlockImplementationFromImplementationOrCreator is a helper type that extracts the BlockImplementation type from a BlockImplementationOrCreator.
|
|
315
323
|
*/
|
|
316
|
-
export type ExtractBlockImplementationFromImplementationOrCreator<ImplementationOrCreator extends BlockImplementation<string, PropSchema, "inline" | "none"> | ((...args: any[]) => BlockImplementation<string, PropSchema, "inline" | "none">)> = ImplementationOrCreator extends (...args: any[]) => infer Implementation ? Implementation : ImplementationOrCreator;
|
|
317
|
-
export type CustomBlockImplementation<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" = "inline" | "none"> = BlockImplementation<T, PS, C>;
|
|
324
|
+
export type ExtractBlockImplementationFromImplementationOrCreator<ImplementationOrCreator extends BlockImplementation<string, PropSchema, "inline" | "none" | "plain"> | ((...args: any[]) => BlockImplementation<string, PropSchema, "inline" | "none" | "plain">)> = ImplementationOrCreator extends (...args: any[]) => infer Implementation ? Implementation : ImplementationOrCreator;
|
|
325
|
+
export type CustomBlockImplementation<T extends string = string, PS extends PropSchema = PropSchema, C extends "inline" | "none" | "plain" = "inline" | "none" | "plain"> = BlockImplementation<T, PS, C>;
|
|
318
326
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,7 @@ export * from "./blocks/types.js";
|
|
|
4
4
|
export * from "./inlineContent/createSpec.js";
|
|
5
5
|
export * from "./inlineContent/internal.js";
|
|
6
6
|
export * from "./inlineContent/types.js";
|
|
7
|
+
export * from "./markGroups.js";
|
|
7
8
|
export * from "./propTypes.js";
|
|
8
9
|
export * from "./styles/createSpec.js";
|
|
9
10
|
export * from "./styles/internal.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
|
+
import { ViewMutationRecord } from "prosemirror-view";
|
|
3
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
2
4
|
import { PropSchema, Props } from "../propTypes.js";
|
|
3
5
|
import { StyleSchema, Styles } from "../styles/types.js";
|
|
4
|
-
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
5
|
-
import { ViewMutationRecord } from "prosemirror-view";
|
|
6
6
|
export type CustomInlineContentConfig = {
|
|
7
7
|
type: string;
|
|
8
|
-
content: "styled" | "none";
|
|
8
|
+
content: "styled" | "none" | "plain";
|
|
9
9
|
readonly propSchema: PropSchema;
|
|
10
10
|
};
|
|
11
11
|
export type InlineContentConfig = CustomInlineContentConfig | "text" | "link";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
2
|
+
/**
|
|
3
|
+
* ProseMirror mark group for "non-formatting" marks: comments and the
|
|
4
|
+
* suggestion/diff marks (the AI `insertion`/`deletion`/`modification` marks and
|
|
5
|
+
* the Yjs `y-attributed-*` marks). These annotate content without representing
|
|
6
|
+
* inline formatting and are ignored by BlockNote's content model
|
|
7
|
+
* (`blocknoteIgnore`).
|
|
8
|
+
*
|
|
9
|
+
* They are the only marks allowed on `"plain"` blocks (e.g. code blocks), which
|
|
10
|
+
* otherwise disallow all formatting marks. A block references this group rather
|
|
11
|
+
* than the individual marks because each of them comes from an optional
|
|
12
|
+
* extension (comments, AI suggestions, Yjs attribution) and so is only present
|
|
13
|
+
* when that extension is configured.
|
|
14
|
+
*/
|
|
15
|
+
export declare const NON_FORMATTING_MARK_GROUP = "annotation";
|
|
16
|
+
/**
|
|
17
|
+
* The `marks` field value for `"plain"` blocks (e.g. code blocks), which hold
|
|
18
|
+
* unstyled text and so disallow formatting marks but still allow the
|
|
19
|
+
* non-formatting ones.
|
|
20
|
+
*
|
|
21
|
+
* Every mark in {@link NON_FORMATTING_MARK_GROUP} comes from an optional
|
|
22
|
+
* extension, so a node spec that referenced the group unconditionally would make
|
|
23
|
+
* ProseMirror throw "Unknown mark type: 'annotation'" while building the schema
|
|
24
|
+
* of an editor that has none of them registered — an empty mark group is an
|
|
25
|
+
* unknown reference just like a missing mark is. (This mirrors `suggestionMarks`
|
|
26
|
+
* for the block-level suggestion group.)
|
|
27
|
+
*
|
|
28
|
+
* Returns the group name (which ProseMirror expands to every mark in it) when at
|
|
29
|
+
* least one such mark is registered, or `""` otherwise. Evaluated at
|
|
30
|
+
* schema-build time, where the tiptap editor's fully-flattened extension list is
|
|
31
|
+
* available on `this.editor`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function nonFormattingMarks(editor: Editor | undefined): string;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Store } from "@tanstack/store";
|
|
2
|
+
/**
|
|
3
|
+
* A collaborator of the document.
|
|
4
|
+
*/
|
|
5
|
+
export type User = {
|
|
6
|
+
/**
|
|
7
|
+
* The {@link User}'s unique identifier
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The {@link User}'s name/label
|
|
12
|
+
*/
|
|
13
|
+
username: string;
|
|
14
|
+
/**
|
|
15
|
+
* The {@link User}'s profile image
|
|
16
|
+
*/
|
|
17
|
+
avatarUrl: string;
|
|
18
|
+
/**
|
|
19
|
+
* The color used to represent the user (e.g. for collaboration cursors).
|
|
20
|
+
*/
|
|
21
|
+
color?: string;
|
|
22
|
+
/**
|
|
23
|
+
* A lighter variant of {@link color}.
|
|
24
|
+
*/
|
|
25
|
+
colorLight?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A store that retrieves and caches information about users, generic over the
|
|
29
|
+
* resolved user type `U`.
|
|
30
|
+
*
|
|
31
|
+
* Created via {@link createUserStore}. Features that need to resolve user ids to
|
|
32
|
+
* user information (comments, suggestions, versions) build one internally and
|
|
33
|
+
* expose it on their extension instance so their UI can read from it.
|
|
34
|
+
*/
|
|
35
|
+
export type UserStore<U extends User = User> = {
|
|
36
|
+
/**
|
|
37
|
+
* A store mapping user ids to the resolved {@link User} information.
|
|
38
|
+
*/
|
|
39
|
+
store: Store<Map<User["id"], U>>;
|
|
40
|
+
/**
|
|
41
|
+
* Load information about users based on an array of user ids.
|
|
42
|
+
*
|
|
43
|
+
* Users that are already cached or currently being loaded are skipped, so
|
|
44
|
+
* it is safe to call this often (e.g. on every render).
|
|
45
|
+
*/
|
|
46
|
+
loadUsers: (userIds: User["id"][]) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Re-fetch information about users, ignoring the cache. Users that are
|
|
49
|
+
* currently being loaded are still skipped to avoid duplicate requests.
|
|
50
|
+
*/
|
|
51
|
+
refetchUsers: (userIds: User["id"][]) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieve information about a user based on their id, if cached.
|
|
54
|
+
*
|
|
55
|
+
* The user has to be loaded via `loadUsers` first.
|
|
56
|
+
*/
|
|
57
|
+
getUser: (userId: User["id"]) => U | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Manually set information about a user. This is useful if you have a
|
|
60
|
+
* resolver that returns partial information (e.g. just the username) and you
|
|
61
|
+
* want to fill in the rest later (e.g. avatarUrl).
|
|
62
|
+
*/
|
|
63
|
+
setUser: (user: U | U[]) => void;
|
|
64
|
+
};
|
|
65
|
+
export type UserStoreResolver<U extends User = User> = (
|
|
66
|
+
/**
|
|
67
|
+
* The user ids to resolve. The resolver should return information for all of
|
|
68
|
+
* these users, or an empty array if none could be resolved.
|
|
69
|
+
*/
|
|
70
|
+
userIds: User["id"][],
|
|
71
|
+
/**
|
|
72
|
+
* The {@link UserStore} that is calling this resolver. This allows you to return a user synchronously, and update the store later if you need to fetch additional information asynchronously.
|
|
73
|
+
*/
|
|
74
|
+
store: UserStore<any>) => Promise<U[]>;
|
|
75
|
+
/**
|
|
76
|
+
* A resolver callback or an already-built {@link UserStore} — the shape that
|
|
77
|
+
* user-facing options (comments, collaboration) accept so callers can either let
|
|
78
|
+
* the extension build a store or pass a shared one.
|
|
79
|
+
*/
|
|
80
|
+
export type UserStoreOrResolver<U extends User = User> = ((userIds: User["id"][], store: UserStore<any>) => Promise<U[]>) | UserStore<any>;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a {@link UserStore} that retrieves and caches information about users.
|
|
83
|
+
*
|
|
84
|
+
* It does this by calling `resolveUsers` for users that are not yet cached, and
|
|
85
|
+
* stores the results in a BlockNote store so they can be subscribed to (e.g. via
|
|
86
|
+
* `useStore` in React).
|
|
87
|
+
*
|
|
88
|
+
* `resolveUsers` is called with the ids of users that are not yet cached, and
|
|
89
|
+
* should return the information for those users. The type of the returned users
|
|
90
|
+
* is inferred and flows through to {@link UserStore.getUser} and the store, so
|
|
91
|
+
* you can return a type with additional properties and have them be reported
|
|
92
|
+
* back.
|
|
93
|
+
*
|
|
94
|
+
* See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.
|
|
95
|
+
*/
|
|
96
|
+
export declare function createUserStore<U extends User = User>(resolveUsers: (userIds: User["id"][], store: UserStore<any>) => Promise<U[]>): UserStore<U>;
|
|
97
|
+
/**
|
|
98
|
+
* Normalize a {@link UserStoreOrResolver} to a {@link UserStore}:
|
|
99
|
+
* - an existing store is returned as-is (so a single de-duped cache can be
|
|
100
|
+
* shared across extensions),
|
|
101
|
+
* - a resolver function is wrapped with {@link createUserStore},
|
|
102
|
+
* - `undefined` yields an empty store that resolves nothing (consumers then fall
|
|
103
|
+
* back to showing raw user ids).
|
|
104
|
+
*/
|
|
105
|
+
export declare function normalizeToUserStore<U extends User = User>(resolveUsersOrStore?: UserStoreOrResolver<U>): UserStore<U>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { UserStore } from "./UserStore.js";
|
|
2
|
+
/** Fallback palette used when a user has no resolved color of their own. */
|
|
3
|
+
export declare const userColorPalette: Array<{
|
|
4
|
+
light: string;
|
|
5
|
+
dark: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** The deterministic {@link userColorPalette} entry for a single user id. */
|
|
8
|
+
export declare const fallbackColorForUserId: (id: string) => {
|
|
9
|
+
light: string;
|
|
10
|
+
dark: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The (first) user's resolved color from the {@link UserStore}, or their
|
|
14
|
+
* {@link fallbackColorForUserId} palette entry. Used where a concrete color
|
|
15
|
+
* string is needed (the portaled hover tooltip); marks themselves use the
|
|
16
|
+
* cascaded {@link userColorVarNames} properties instead.
|
|
17
|
+
*/
|
|
18
|
+
export declare const colorsForUserIds: (userStore: UserStore, userIds: readonly string[] | undefined | null) => {
|
|
19
|
+
light: string;
|
|
20
|
+
dark: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Reduce a user id to a fixed-width `[0-9a-f]` token safe to embed in a CSS
|
|
24
|
+
* custom-property name. Uses the (non-cryptographic) FNV-1a 32-bit hash; a
|
|
25
|
+
* collision only means two authors share a highlight color.
|
|
26
|
+
*/
|
|
27
|
+
export declare const cssVarUserId: (id: string) => string;
|
|
28
|
+
/**
|
|
29
|
+
* The `--user-color-<key>-{light,dark}` custom-property names for a user. Set on
|
|
30
|
+
* the editor root by `AttributionExtension`, read by the mark wrapper via
|
|
31
|
+
* `var(..., <fallback>)`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const userColorVarNames: (id: string) => {
|
|
34
|
+
light: string;
|
|
35
|
+
dark: string;
|
|
36
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as Y from "@y/y";
|
|
2
|
+
import type { CommentBody } from "../../comments/types.js";
|
|
3
|
+
import type { ThreadStoreAuth } from "../../comments/threadstore/ThreadStoreAuth.js";
|
|
4
|
+
import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
|
|
5
|
+
/**
|
|
6
|
+
* This is a REST-based implementation of the YjsThreadStoreBase for @y/y (v14).
|
|
7
|
+
* It Reads data directly from the underlying document (same as YjsThreadStore),
|
|
8
|
+
* but for Writes, it sends data to a REST API that should:
|
|
9
|
+
* - check the user has the correct permissions to make the desired changes
|
|
10
|
+
* - apply the updates to the underlying Yjs document
|
|
11
|
+
*
|
|
12
|
+
* (see https://github.com/TypeCellOS/BlockNote-demo-nextjs-hocuspocus)
|
|
13
|
+
*
|
|
14
|
+
* The reason we still use the Yjs document as underlying storage is that it makes it easy to
|
|
15
|
+
* sync updates in real-time to other collaborators.
|
|
16
|
+
* (but technically, you could also implement a different storage altogether
|
|
17
|
+
* and not store the thread related data in the Yjs document)
|
|
18
|
+
*/
|
|
19
|
+
export declare class RESTYjsThreadStore extends YjsThreadStoreBase {
|
|
20
|
+
private readonly BASE_URL;
|
|
21
|
+
private readonly headers;
|
|
22
|
+
constructor(BASE_URL: string, headers: Record<string, string>, threadsYType: Y.Type, auth: ThreadStoreAuth);
|
|
23
|
+
private doRequest;
|
|
24
|
+
addThreadToDocument: (options: {
|
|
25
|
+
threadId: string;
|
|
26
|
+
selection: {
|
|
27
|
+
head: number;
|
|
28
|
+
anchor: number;
|
|
29
|
+
};
|
|
30
|
+
}) => Promise<any>;
|
|
31
|
+
createThread: (options: {
|
|
32
|
+
initialComment: {
|
|
33
|
+
body: CommentBody;
|
|
34
|
+
metadata?: any;
|
|
35
|
+
};
|
|
36
|
+
metadata?: any;
|
|
37
|
+
}) => Promise<any>;
|
|
38
|
+
addComment: (options: {
|
|
39
|
+
comment: {
|
|
40
|
+
body: CommentBody;
|
|
41
|
+
metadata?: any;
|
|
42
|
+
};
|
|
43
|
+
threadId: string;
|
|
44
|
+
}) => Promise<any>;
|
|
45
|
+
updateComment: (options: {
|
|
46
|
+
comment: {
|
|
47
|
+
body: CommentBody;
|
|
48
|
+
metadata?: any;
|
|
49
|
+
};
|
|
50
|
+
threadId: string;
|
|
51
|
+
commentId: string;
|
|
52
|
+
}) => Promise<any>;
|
|
53
|
+
deleteComment: (options: {
|
|
54
|
+
threadId: string;
|
|
55
|
+
commentId: string;
|
|
56
|
+
softDelete?: boolean;
|
|
57
|
+
}) => Promise<any>;
|
|
58
|
+
deleteThread: (options: {
|
|
59
|
+
threadId: string;
|
|
60
|
+
}) => Promise<any>;
|
|
61
|
+
resolveThread: (options: {
|
|
62
|
+
threadId: string;
|
|
63
|
+
}) => Promise<any>;
|
|
64
|
+
unresolveThread: (options: {
|
|
65
|
+
threadId: string;
|
|
66
|
+
}) => Promise<any>;
|
|
67
|
+
addReaction: (options: {
|
|
68
|
+
threadId: string;
|
|
69
|
+
commentId: string;
|
|
70
|
+
emoji: string;
|
|
71
|
+
}) => Promise<any>;
|
|
72
|
+
deleteReaction: (options: {
|
|
73
|
+
threadId: string;
|
|
74
|
+
commentId: string;
|
|
75
|
+
emoji: string;
|
|
76
|
+
}) => Promise<any>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as Y from "@y/y";
|
|
2
|
+
import type { CommentBody, ThreadData } from "../../comments/types.js";
|
|
3
|
+
import type { ThreadStoreAuth } from "../../comments/threadstore/ThreadStoreAuth.js";
|
|
4
|
+
import { YjsThreadStoreBase } from "./YjsThreadStoreBase.js";
|
|
5
|
+
/**
|
|
6
|
+
* This is a @y/y (v14)-based implementation of the ThreadStore interface.
|
|
7
|
+
*
|
|
8
|
+
* It reads and writes thread / comments information directly to the underlying Yjs Document.
|
|
9
|
+
*
|
|
10
|
+
* @important While this is the easiest to add to your app, there are two challenges:
|
|
11
|
+
* - The user needs to be able to write to the Yjs document to store the information.
|
|
12
|
+
* So a user without write access to the Yjs document cannot leave any comments.
|
|
13
|
+
* - Even with write access, the operations are not secure. Unless your Yjs server
|
|
14
|
+
* guards against malicious operations, it's technically possible for one user to make changes to another user's comments, etc.
|
|
15
|
+
* (even though these options are not visible in the UI, a malicious user can make unauthorized changes to the underlying Yjs document)
|
|
16
|
+
*/
|
|
17
|
+
export declare class YjsThreadStore extends YjsThreadStoreBase {
|
|
18
|
+
private readonly userId;
|
|
19
|
+
constructor(userId: string, threadsYType: Y.Type, auth: ThreadStoreAuth);
|
|
20
|
+
private transact;
|
|
21
|
+
createThread: (options: {
|
|
22
|
+
initialComment: {
|
|
23
|
+
body: CommentBody;
|
|
24
|
+
metadata?: any;
|
|
25
|
+
};
|
|
26
|
+
metadata?: any;
|
|
27
|
+
}) => Promise<ThreadData>;
|
|
28
|
+
addThreadToDocument: undefined;
|
|
29
|
+
addComment: (options: {
|
|
30
|
+
comment: {
|
|
31
|
+
body: CommentBody;
|
|
32
|
+
metadata?: any;
|
|
33
|
+
};
|
|
34
|
+
threadId: string;
|
|
35
|
+
}) => Promise<{
|
|
36
|
+
type: "comment";
|
|
37
|
+
id: string;
|
|
38
|
+
userId: string;
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
updatedAt: Date;
|
|
41
|
+
reactions: import("../../comments/types.js").CommentReactionData[];
|
|
42
|
+
metadata: any;
|
|
43
|
+
} & {
|
|
44
|
+
deletedAt?: never;
|
|
45
|
+
body: CommentBody;
|
|
46
|
+
}>;
|
|
47
|
+
updateComment: (options: {
|
|
48
|
+
comment: {
|
|
49
|
+
body: CommentBody;
|
|
50
|
+
metadata?: any;
|
|
51
|
+
};
|
|
52
|
+
threadId: string;
|
|
53
|
+
commentId: string;
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
deleteComment: (options: {
|
|
56
|
+
threadId: string;
|
|
57
|
+
commentId: string;
|
|
58
|
+
softDelete?: boolean;
|
|
59
|
+
}) => Promise<void>;
|
|
60
|
+
deleteThread: (options: {
|
|
61
|
+
threadId: string;
|
|
62
|
+
}) => Promise<void>;
|
|
63
|
+
resolveThread: (options: {
|
|
64
|
+
threadId: string;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
unresolveThread: (options: {
|
|
67
|
+
threadId: string;
|
|
68
|
+
}) => Promise<void>;
|
|
69
|
+
addReaction: (options: {
|
|
70
|
+
threadId: string;
|
|
71
|
+
commentId: string;
|
|
72
|
+
emoji: string;
|
|
73
|
+
}) => Promise<void>;
|
|
74
|
+
deleteReaction: (options: {
|
|
75
|
+
threadId: string;
|
|
76
|
+
commentId: string;
|
|
77
|
+
emoji: string;
|
|
78
|
+
}) => Promise<void>;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as Y from "@y/y";
|
|
2
|
+
import type { ThreadData } from "../../comments/types.js";
|
|
3
|
+
import { ThreadStore } from "../../comments/threadstore/ThreadStore.js";
|
|
4
|
+
import type { ThreadStoreAuth } from "../../comments/threadstore/ThreadStoreAuth.js";
|
|
5
|
+
/**
|
|
6
|
+
* This is an abstract class that only implements the READ methods required by the ThreadStore interface.
|
|
7
|
+
* The data is read from a @y/y Type used as a map (via attributes).
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class YjsThreadStoreBase extends ThreadStore {
|
|
10
|
+
protected readonly threadsYType: Y.Type;
|
|
11
|
+
constructor(threadsYType: Y.Type, auth: ThreadStoreAuth);
|
|
12
|
+
getThread(threadId: string): ThreadData;
|
|
13
|
+
getThreads(): Map<string, ThreadData>;
|
|
14
|
+
subscribe(cb: (threads: Map<string, ThreadData>) => void): () => void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Y from "@y/y";
|
|
2
|
+
import type { CommentData, ThreadData } from "../../comments/types.js";
|
|
3
|
+
export declare function commentToYType(comment: CommentData): Y.Type<any>;
|
|
4
|
+
export declare function threadToYType(thread: ThreadData): Y.Type<any>;
|
|
5
|
+
type SingleUserCommentReactionData = {
|
|
6
|
+
emoji: string;
|
|
7
|
+
createdAt: Date;
|
|
8
|
+
userId: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function yTypeToReaction(yType: Y.Type): SingleUserCommentReactionData;
|
|
11
|
+
export declare function yTypeToComment(yType: Y.Type): CommentData;
|
|
12
|
+
export declare function yTypeToThread(yType: Y.Type): ThreadData;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
2
|
+
import { type UserStoreOrResolver } from "../../user/index.js";
|
|
3
|
+
import { type GetAttributionMarkClassName } from "./YAttributionMarks.js";
|
|
4
|
+
/**
|
|
5
|
+
* The box the tooltip anchors to. The wrapper is `display: contents` (no box of
|
|
6
|
+
* its own), so use its content span child, falling back further for block marks.
|
|
7
|
+
* Exported for the React controller's floating-ui `getBoundingClientRect`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getReferenceRect: (wrapper: Element) => DOMRect;
|
|
10
|
+
/**
|
|
11
|
+
* The per-line client rects of the reference element, for floating-ui's
|
|
12
|
+
* `inline()` middleware — it needs one rect per line to position off a
|
|
13
|
+
* multi-line mark, and virtual elements don't get a default `getClientRects`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getReferenceClientRects: (wrapper: Element) => DOMRectList;
|
|
16
|
+
/**
|
|
17
|
+
* State for the currently-hovered suggestion mark's tooltip (`undefined` when
|
|
18
|
+
* none). The extension computes it; a React controller renders + positions it
|
|
19
|
+
* (see `AttributionTooltipController`).
|
|
20
|
+
*/
|
|
21
|
+
export type AttributionTooltipState = {
|
|
22
|
+
/** The wrapper element the tooltip anchors to (floating-ui reference). */
|
|
23
|
+
anchor: HTMLElement;
|
|
24
|
+
/** Per-user background color, resolved from the user store (default path). */
|
|
25
|
+
color: string;
|
|
26
|
+
/** The kind of change — `format` is the modification mark. */
|
|
27
|
+
modificationType: "insert" | "delete" | "format";
|
|
28
|
+
/** Whether the mark wraps inline content or a whole block. */
|
|
29
|
+
contentType: "inline-content" | "block";
|
|
30
|
+
/** Resolved usernames (falls back to raw ids), for custom renderers. */
|
|
31
|
+
users: string[];
|
|
32
|
+
/**
|
|
33
|
+
* The changed format keys (e.g. `["bold", "italic"]`), present only for
|
|
34
|
+
* `format` marks. This is the raw change context — the view layer turns it
|
|
35
|
+
* into a localized label via its `formatChangeLabel`.
|
|
36
|
+
*/
|
|
37
|
+
format?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Class name from the `getAttributionMarkClassName` callback (override path).
|
|
40
|
+
* When present, the tooltip applies this and skips the inline `color`.
|
|
41
|
+
*/
|
|
42
|
+
className?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Resolves the attribution tooltip state for suggestion marks on hover (exposed
|
|
46
|
+
* via a store for React), and loads each mark's author so its color/username
|
|
47
|
+
* resolves. Marks nest, so a single delegated `mouseover` listener picks the
|
|
48
|
+
* `closest` wrapper to the pointer — the innermost mark wins.
|
|
49
|
+
*/
|
|
50
|
+
export declare const AttributionExtension: (options?: {
|
|
51
|
+
/** Resolves authors to usernames. Optional; unresolved ids show raw. */
|
|
52
|
+
resolveUsers?: UserStoreOrResolver;
|
|
53
|
+
/** See {@link GetAttributionMarkClassName}. */
|
|
54
|
+
getAttributionMarkClassName?: GetAttributionMarkClassName;
|
|
55
|
+
} | undefined) => import("../../index.js").ExtensionFactoryInstance<{
|
|
56
|
+
key: string;
|
|
57
|
+
userStore: import("../../index.js").UserStore<import("../../index.js").User>;
|
|
58
|
+
store: import("@tanstack/store").Store<AttributionTooltipState | undefined, (cb: AttributionTooltipState | undefined) => AttributionTooltipState | undefined>;
|
|
59
|
+
prosemirrorPlugins: Plugin<null>[];
|
|
60
|
+
mount({ dom, root, signal }: {
|
|
61
|
+
dom: HTMLElement;
|
|
62
|
+
root: Document | ShadowRoot;
|
|
63
|
+
signal: AbortSignal;
|
|
64
|
+
}): void;
|
|
65
|
+
blockNoteExtensions: import("../../index.js").ExtensionFactoryInstance<{
|
|
66
|
+
key: string;
|
|
67
|
+
tiptapExtensions: (import("@tiptap/core").Mark<{
|
|
68
|
+
getAttributionMarkClassName?: GetAttributionMarkClassName;
|
|
69
|
+
}, any> | import("@tiptap/core").Mark<{
|
|
70
|
+
editor?: import("../../index.js").BlockNoteEditor<any, any, any>;
|
|
71
|
+
getAttributionMarkClassName?: GetAttributionMarkClassName;
|
|
72
|
+
}, any>)[];
|
|
73
|
+
}>[];
|
|
74
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|