@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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { defaultSelectionBuilder, yCursorPlugin } from "y-prosemirror";
|
|
2
|
+
import {
|
|
3
|
+
createExtension,
|
|
4
|
+
ExtensionOptions,
|
|
5
|
+
} from "../../editor/BlockNoteExtension.js";
|
|
6
|
+
import type { CollaborationOptions } from "./index.js";
|
|
7
|
+
|
|
8
|
+
export type CollaborationUser = {
|
|
9
|
+
id?: string;
|
|
10
|
+
name: string;
|
|
11
|
+
color: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Determine whether the foreground color should be white or black based on a provided background color
|
|
17
|
+
* Inspired by: https://stackoverflow.com/a/3943023
|
|
18
|
+
*/
|
|
19
|
+
function isDarkColor(bgColor: string): boolean {
|
|
20
|
+
const color = bgColor.charAt(0) === "#" ? bgColor.substring(1, 7) : bgColor;
|
|
21
|
+
const r = parseInt(color.substring(0, 2), 16); // hexToR
|
|
22
|
+
const g = parseInt(color.substring(2, 4), 16); // hexToG
|
|
23
|
+
const b = parseInt(color.substring(4, 6), 16); // hexToB
|
|
24
|
+
const uicolors = [r / 255, g / 255, b / 255];
|
|
25
|
+
const c = uicolors.map((col) => {
|
|
26
|
+
if (col <= 0.03928) {
|
|
27
|
+
return col / 12.92;
|
|
28
|
+
}
|
|
29
|
+
return Math.pow((col + 0.055) / 1.055, 2.4);
|
|
30
|
+
});
|
|
31
|
+
const L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
32
|
+
return L <= 0.179;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function defaultCursorRender(user: CollaborationUser) {
|
|
36
|
+
const cursorElement = document.createElement("span");
|
|
37
|
+
|
|
38
|
+
cursorElement.classList.add("bn-collaboration-cursor__base");
|
|
39
|
+
|
|
40
|
+
const caretElement = document.createElement("span");
|
|
41
|
+
caretElement.setAttribute("contentedEditable", "false");
|
|
42
|
+
caretElement.classList.add("bn-collaboration-cursor__caret");
|
|
43
|
+
caretElement.setAttribute(
|
|
44
|
+
"style",
|
|
45
|
+
`background-color: ${user.color}; color: ${
|
|
46
|
+
isDarkColor(user.color) ? "white" : "black"
|
|
47
|
+
}`,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const labelElement = document.createElement("span");
|
|
51
|
+
|
|
52
|
+
labelElement.classList.add("bn-collaboration-cursor__label");
|
|
53
|
+
labelElement.setAttribute(
|
|
54
|
+
"style",
|
|
55
|
+
`background-color: ${user.color}; color: ${
|
|
56
|
+
isDarkColor(user.color) ? "white" : "black"
|
|
57
|
+
}`,
|
|
58
|
+
);
|
|
59
|
+
labelElement.insertBefore(document.createTextNode(user.name), null);
|
|
60
|
+
|
|
61
|
+
caretElement.insertBefore(labelElement, null);
|
|
62
|
+
|
|
63
|
+
cursorElement.insertBefore(document.createTextNode("\u2060"), null); // Non-breaking space
|
|
64
|
+
cursorElement.insertBefore(caretElement, null);
|
|
65
|
+
cursorElement.insertBefore(document.createTextNode("\u2060"), null); // Non-breaking space
|
|
66
|
+
|
|
67
|
+
return cursorElement;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const YCursorExtension = createExtension(
|
|
71
|
+
({ options }: ExtensionOptions<CollaborationOptions>) => {
|
|
72
|
+
const recentlyUpdatedCursors = new Map();
|
|
73
|
+
const awareness =
|
|
74
|
+
options.provider &&
|
|
75
|
+
"awareness" in options.provider &&
|
|
76
|
+
typeof options.provider.awareness === "object"
|
|
77
|
+
? options.provider.awareness
|
|
78
|
+
: undefined;
|
|
79
|
+
if (awareness) {
|
|
80
|
+
if (
|
|
81
|
+
"setLocalStateField" in awareness &&
|
|
82
|
+
typeof awareness.setLocalStateField === "function"
|
|
83
|
+
) {
|
|
84
|
+
awareness.setLocalStateField("user", options.user);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const handleAwarenessChange = ({
|
|
89
|
+
updated,
|
|
90
|
+
}: {
|
|
91
|
+
added: Array<number>;
|
|
92
|
+
updated: Array<number>;
|
|
93
|
+
removed: Array<number>;
|
|
94
|
+
}) => {
|
|
95
|
+
for (const clientID of updated) {
|
|
96
|
+
const cursor = recentlyUpdatedCursors.get(clientID);
|
|
97
|
+
|
|
98
|
+
if (cursor) {
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
cursor.element.setAttribute("data-active", "");
|
|
101
|
+
}, 10);
|
|
102
|
+
|
|
103
|
+
if (cursor.hideTimeout) {
|
|
104
|
+
clearTimeout(cursor.hideTimeout);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
recentlyUpdatedCursors.set(clientID, {
|
|
108
|
+
element: cursor.element,
|
|
109
|
+
hideTimeout: setTimeout(() => {
|
|
110
|
+
cursor.element.removeAttribute("data-active");
|
|
111
|
+
}, 2000),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
key: "yCursor",
|
|
119
|
+
mount() {
|
|
120
|
+
if (
|
|
121
|
+
awareness &&
|
|
122
|
+
options.showCursorLabels !== "always" &&
|
|
123
|
+
"on" in awareness &&
|
|
124
|
+
typeof awareness.on === "function"
|
|
125
|
+
) {
|
|
126
|
+
awareness.on("change", handleAwarenessChange);
|
|
127
|
+
|
|
128
|
+
return () => {
|
|
129
|
+
if ("off" in awareness && typeof awareness.off === "function") {
|
|
130
|
+
awareness.off("change", handleAwarenessChange);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return undefined;
|
|
136
|
+
},
|
|
137
|
+
prosemirrorPlugins: [
|
|
138
|
+
awareness
|
|
139
|
+
? yCursorPlugin(awareness, {
|
|
140
|
+
selectionBuilder: defaultSelectionBuilder,
|
|
141
|
+
cursorBuilder(user: CollaborationUser, clientID: number) {
|
|
142
|
+
let cursorData = recentlyUpdatedCursors.get(clientID);
|
|
143
|
+
|
|
144
|
+
if (!cursorData) {
|
|
145
|
+
const cursorElement = (
|
|
146
|
+
options.renderCursor ?? defaultCursorRender
|
|
147
|
+
)(user);
|
|
148
|
+
|
|
149
|
+
if (options.showCursorLabels !== "always") {
|
|
150
|
+
cursorElement.addEventListener("mouseenter", () => {
|
|
151
|
+
const cursor = recentlyUpdatedCursors.get(clientID)!;
|
|
152
|
+
cursor.element.setAttribute("data-active", "");
|
|
153
|
+
|
|
154
|
+
if (cursor.hideTimeout) {
|
|
155
|
+
clearTimeout(cursor.hideTimeout);
|
|
156
|
+
recentlyUpdatedCursors.set(clientID, {
|
|
157
|
+
element: cursor.element,
|
|
158
|
+
hideTimeout: undefined,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
cursorElement.addEventListener("mouseleave", () => {
|
|
164
|
+
const cursor = recentlyUpdatedCursors.get(clientID)!;
|
|
165
|
+
|
|
166
|
+
recentlyUpdatedCursors.set(clientID, {
|
|
167
|
+
element: cursor.element,
|
|
168
|
+
hideTimeout: setTimeout(() => {
|
|
169
|
+
cursor.element.removeAttribute("data-active");
|
|
170
|
+
}, 2000),
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
cursorData = {
|
|
176
|
+
element: cursorElement,
|
|
177
|
+
hideTimeout: undefined,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
recentlyUpdatedCursors.set(clientID, cursorData);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return cursorData.element;
|
|
184
|
+
},
|
|
185
|
+
})
|
|
186
|
+
: undefined,
|
|
187
|
+
].filter(Boolean),
|
|
188
|
+
dependsOn: ["ySync"],
|
|
189
|
+
updateUser(user: { name: string; color: string; [key: string]: string }) {
|
|
190
|
+
awareness?.setLocalStateField("user", user);
|
|
191
|
+
},
|
|
192
|
+
getUser(): CollaborationUser | undefined {
|
|
193
|
+
const state = awareness?.getLocalState();
|
|
194
|
+
if (!state) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
return state["user"];
|
|
198
|
+
},
|
|
199
|
+
} as const;
|
|
200
|
+
},
|
|
201
|
+
);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ExtensionOptions,
|
|
4
4
|
createExtension,
|
|
5
5
|
} from "../../editor/BlockNoteExtension.js";
|
|
6
|
-
import { CollaborationOptions } from "./
|
|
6
|
+
import type { CollaborationOptions } from "./index.js";
|
|
7
7
|
|
|
8
8
|
export const YSyncExtension = createExtension(
|
|
9
9
|
({ options }: ExtensionOptions<Pick<CollaborationOptions, "fragment">>) => {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Awareness } from "y-protocols/awareness";
|
|
2
|
+
import type * as Y from "yjs";
|
|
3
|
+
import type { BlockNoteEditorOptions } from "../../editor/BlockNoteEditor";
|
|
4
|
+
import {
|
|
5
|
+
createExtension,
|
|
6
|
+
type ExtensionOptions,
|
|
7
|
+
} from "../../editor/BlockNoteExtension.js";
|
|
8
|
+
import { FixUpSchemaExtension } from "./FixUpSchema.js";
|
|
9
|
+
import { ForkYDocExtension } from "./ForkYDoc.js";
|
|
10
|
+
import { RelativePositionMappingExtension } from "./RelativePositionMapping.js";
|
|
11
|
+
import { SchemaMigration } from "./schemaMigration/SchemaMigration.js";
|
|
12
|
+
import { CollaborationUser, YCursorExtension } from "./YCursorPlugin.js";
|
|
13
|
+
import { YSyncExtension } from "./YSync.js";
|
|
14
|
+
import { YUndoExtension } from "./YUndo.js";
|
|
15
|
+
|
|
16
|
+
export type CollaborationOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* The Yjs XML fragment that's used for collaboration.
|
|
19
|
+
*/
|
|
20
|
+
fragment: Y.XmlFragment;
|
|
21
|
+
/**
|
|
22
|
+
* The user info for the current user that's shown to other collaborators.
|
|
23
|
+
*/
|
|
24
|
+
user: CollaborationUser;
|
|
25
|
+
/**
|
|
26
|
+
* A Yjs provider (used for awareness / cursor information)
|
|
27
|
+
*/
|
|
28
|
+
provider?: { awareness?: Awareness };
|
|
29
|
+
/**
|
|
30
|
+
* Optional function to customize how cursors of users are rendered
|
|
31
|
+
*/
|
|
32
|
+
renderCursor?: (user: CollaborationUser) => HTMLElement;
|
|
33
|
+
/**
|
|
34
|
+
* Optional flag to set when the user label should be shown with the default
|
|
35
|
+
* collaboration cursor. Setting to "always" will always show the label,
|
|
36
|
+
* while "activity" will only show the label when the user moves the cursor
|
|
37
|
+
* or types. Defaults to "activity".
|
|
38
|
+
*/
|
|
39
|
+
showCursorLabels?: "always" | "activity";
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const CollaborationExtension = createExtension(
|
|
43
|
+
({ options }: ExtensionOptions<CollaborationOptions>) => {
|
|
44
|
+
return {
|
|
45
|
+
key: "collaboration",
|
|
46
|
+
blockNoteExtensions: [
|
|
47
|
+
FixUpSchemaExtension(),
|
|
48
|
+
ForkYDocExtension(options),
|
|
49
|
+
RelativePositionMappingExtension(),
|
|
50
|
+
SchemaMigration(options),
|
|
51
|
+
YCursorExtension(options),
|
|
52
|
+
YSyncExtension(options),
|
|
53
|
+
YUndoExtension(),
|
|
54
|
+
],
|
|
55
|
+
} as const;
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export function withCollaboration<
|
|
60
|
+
Options extends Partial<BlockNoteEditorOptions<any, any, any>>,
|
|
61
|
+
>(
|
|
62
|
+
options: Options & {
|
|
63
|
+
/**
|
|
64
|
+
* Options for configuring the collaboration functionality.
|
|
65
|
+
*/
|
|
66
|
+
collaboration: CollaborationOptions;
|
|
67
|
+
},
|
|
68
|
+
): Options {
|
|
69
|
+
return {
|
|
70
|
+
...options,
|
|
71
|
+
extensions: [
|
|
72
|
+
...(options.extensions ?? []),
|
|
73
|
+
CollaborationExtension(options.collaboration),
|
|
74
|
+
],
|
|
75
|
+
// We disable the default prosemirror history plugin, since it's not compatible with yjs
|
|
76
|
+
disableExtensions: ["history", ...(options.disableExtensions ?? [])],
|
|
77
|
+
// We don't want the default initial content, since it will generate a random id for the initial block on each client,
|
|
78
|
+
// leading to conflicts when syncing happens afterwards.
|
|
79
|
+
initialContent: [{ type: "paragraph", id: "initialBlockId" }],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export * from "./ForkYDoc.js";
|
|
84
|
+
export * from "./RelativePositionMapping.js";
|
|
85
|
+
export * from "./schemaMigration/SchemaMigration.js";
|
|
86
|
+
export * from "./Versioning.js";
|
|
87
|
+
export * from "./YCursorPlugin.js";
|
|
88
|
+
export * from "./YSync.js";
|
|
89
|
+
export * from "./YUndo.js";
|
package/src/yjs/index.ts
CHANGED
package/src/yjs/utils.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
1
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
4
2
|
import * as Y from "yjs";
|
|
3
|
+
import { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
|
|
4
|
+
import { Block, docToBlocks } from "../index.js";
|
|
5
5
|
import {
|
|
6
6
|
_blocksToProsemirrorNode,
|
|
7
7
|
blocksToYDoc,
|
|
@@ -450,11 +450,7 @@ describe("Test yjs utils", () => {
|
|
|
450
450
|
language: "javascript",
|
|
451
451
|
},
|
|
452
452
|
content: [
|
|
453
|
-
{
|
|
454
|
-
type: "text",
|
|
455
|
-
text: 'console.log("Hello, world!");',
|
|
456
|
-
styles: {},
|
|
457
|
-
},
|
|
453
|
+
{ type: "text", text: "console.log('Hello, world!');", styles: {} },
|
|
458
454
|
],
|
|
459
455
|
children: [],
|
|
460
456
|
},
|
|
@@ -464,13 +460,7 @@ describe("Test yjs utils", () => {
|
|
|
464
460
|
props: {
|
|
465
461
|
language: "typescript",
|
|
466
462
|
},
|
|
467
|
-
content: [
|
|
468
|
-
{
|
|
469
|
-
type: "text",
|
|
470
|
-
text: "const x: number = 42;",
|
|
471
|
-
styles: {},
|
|
472
|
-
},
|
|
473
|
-
],
|
|
463
|
+
content: [{ type: "text", text: "const x: number = 42;", styles: {} }],
|
|
474
464
|
children: [],
|
|
475
465
|
},
|
|
476
466
|
];
|
package/src/yjs/utils.ts
CHANGED
|
@@ -16,6 +16,42 @@ import {
|
|
|
16
16
|
docToBlocks,
|
|
17
17
|
} from "../index.js";
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Find a Y.AbstractType in another Y.Doc that corresponds to the same
|
|
21
|
+
* logical type in the original doc.
|
|
22
|
+
*/
|
|
23
|
+
export function findTypeInOtherYdoc<T extends Y.AbstractType<any>>(
|
|
24
|
+
ytype: T,
|
|
25
|
+
otherYdoc: Y.Doc,
|
|
26
|
+
): T {
|
|
27
|
+
const ydoc = ytype.doc;
|
|
28
|
+
if (!ydoc) {
|
|
29
|
+
throw new Error("type does not have a ydoc");
|
|
30
|
+
}
|
|
31
|
+
if (ytype._item === null) {
|
|
32
|
+
const rootKey = Array.from(ydoc.share.keys()).find(
|
|
33
|
+
(key) => ydoc.share.get(key) === ytype,
|
|
34
|
+
);
|
|
35
|
+
if (rootKey == null) {
|
|
36
|
+
throw new Error("type does not exist in other ydoc");
|
|
37
|
+
}
|
|
38
|
+
return otherYdoc.get(rootKey, ytype.constructor as new () => T) as T;
|
|
39
|
+
} else {
|
|
40
|
+
const ytypeItem = ytype._item;
|
|
41
|
+
const otherStructs = otherYdoc.store.clients.get(ytypeItem.id.client) ?? [];
|
|
42
|
+
const itemIndex = Y.findIndexSS(otherStructs, ytypeItem.id.clock);
|
|
43
|
+
const otherItem = otherStructs[itemIndex] as Y.Item | undefined;
|
|
44
|
+
if (!otherItem) {
|
|
45
|
+
throw new Error("type does not exist in other ydoc");
|
|
46
|
+
}
|
|
47
|
+
const otherContent = otherItem.content as Y.ContentType | undefined;
|
|
48
|
+
if (!otherContent) {
|
|
49
|
+
throw new Error("type does not exist in other ydoc");
|
|
50
|
+
}
|
|
51
|
+
return otherContent.type as T;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
19
55
|
/**
|
|
20
56
|
* Turn Prosemirror JSON to BlockNote style JSON
|
|
21
57
|
* @param editor BlockNote editor
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Transaction } from "prosemirror-state";
|
|
2
2
|
import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
|
|
3
3
|
import type { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../../../schema/index.js";
|
|
4
|
-
export declare function removeAndInsertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[]
|
|
4
|
+
export declare function removeAndInsertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction, blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[], options?: {
|
|
5
|
+
fixColumns?: boolean;
|
|
6
|
+
}): {
|
|
5
7
|
insertedBlocks: Block<BSchema, I, S>[];
|
|
6
8
|
removedBlocks: Block<BSchema, I, S>[];
|
|
7
9
|
};
|
|
@@ -5,7 +5,7 @@ import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "
|
|
|
5
5
|
export declare function getSelection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(tr: Transaction): Selection<BSchema, I, S> | undefined;
|
|
6
6
|
export declare function setSelection(tr: Transaction, startBlock: BlockIdentifier, endBlock: BlockIdentifier): void;
|
|
7
7
|
export declare function getSelectionCutBlocks(tr: Transaction, expandToWords?: boolean): {
|
|
8
|
-
blocks: Block<Record<string, import("../../../index.js").BlockConfig<string, import("../../../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
8
|
+
blocks: Block<Record<string, import("../../../index.js").BlockConfig<string, import("../../../index.js").PropSchema, "inline" | "none" | "plain" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
9
9
|
blockCutAtStart: string | undefined;
|
|
10
10
|
blockCutAtEnd: string | undefined;
|
|
11
11
|
_meta: {
|
|
@@ -36,6 +36,8 @@ export type BlockInfo = {
|
|
|
36
36
|
*/
|
|
37
37
|
isBlockContainer: true;
|
|
38
38
|
});
|
|
39
|
+
export declare function isSuggestedDeletionNode(node: Node): boolean;
|
|
40
|
+
export declare function getNodeId(node: Node, doc: Node): string;
|
|
39
41
|
/**
|
|
40
42
|
* Retrieves the position just before the nearest block node in a ProseMirror
|
|
41
43
|
* doc, relative to a position. If the position is within a block node or its
|
|
@@ -89,14 +91,8 @@ export declare function getBlockInfoFromResolvedPos(resolvedPos: ResolvedPos): B
|
|
|
89
91
|
* Gets information regarding the ProseMirror nodes that make up a block. The
|
|
90
92
|
* block chosen is the one currently containing the current ProseMirror
|
|
91
93
|
* selection.
|
|
92
|
-
* @param
|
|
94
|
+
* @param source The ProseMirror editor state.
|
|
93
95
|
*/
|
|
94
|
-
export declare function getBlockInfoFromSelection(
|
|
95
|
-
|
|
96
|
-
* Gets information regarding the ProseMirror nodes that make up a block. The
|
|
97
|
-
* block chosen is the one currently containing the current ProseMirror
|
|
98
|
-
* selection.
|
|
99
|
-
* @param tr The ProseMirror transaction.
|
|
100
|
-
*/
|
|
101
|
-
export declare function getBlockInfoFromTransaction(tr: Transaction): BlockInfo;
|
|
96
|
+
export declare function getBlockInfoFromSelection(source: EditorState | Transaction): BlockInfo;
|
|
97
|
+
export declare function getBlockInfoAtNearest(source: EditorState | Transaction, pos: number): BlockInfo;
|
|
102
98
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node,
|
|
1
|
+
import { Node, Slice } from "@tiptap/pm/model";
|
|
2
2
|
import type { Block } from "../../blocks/defaultBlocks.js";
|
|
3
3
|
import type { BlockSchema, InlineContent, InlineContentSchema, StyleSchema, TableContent } from "../../schema/index.js";
|
|
4
4
|
/**
|
|
@@ -12,14 +12,12 @@ export declare function contentNodeToInlineContent<I extends InlineContentSchema
|
|
|
12
12
|
export declare function nodeToCustomInlineContent<I extends InlineContentSchema, S extends StyleSchema>(node: Node, inlineContentSchema: I, styleSchema: S): InlineContent<I, S>;
|
|
13
13
|
/**
|
|
14
14
|
* Convert a Prosemirror node to a BlockNote block.
|
|
15
|
-
*
|
|
16
|
-
* TODO: test changes
|
|
17
15
|
*/
|
|
18
|
-
export declare function nodeToBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(node: Node,
|
|
16
|
+
export declare function nodeToBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(node: Node, doc: Node): Block<BSchema, I, S>;
|
|
19
17
|
/**
|
|
20
18
|
* Convert a Prosemirror document to a BlockNote document (array of blocks)
|
|
21
19
|
*/
|
|
22
|
-
export declare function docToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node
|
|
20
|
+
export declare function docToBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(doc: Node): Block<BSchema, I, S>[];
|
|
23
21
|
/**
|
|
24
22
|
*
|
|
25
23
|
* Parse a Prosemirror Slice into a BlockNote selection. The prosemirror schema looks like this:
|
|
@@ -39,7 +37,7 @@ export declare function docToBlocks<BSchema extends BlockSchema, I extends Inlin
|
|
|
39
37
|
* </blockGroup>
|
|
40
38
|
*
|
|
41
39
|
*/
|
|
42
|
-
export declare function prosemirrorSliceToSlicedBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(slice: Slice
|
|
40
|
+
export declare function prosemirrorSliceToSlicedBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(slice: Slice): {
|
|
43
41
|
/**
|
|
44
42
|
* The blocks that are included in the selection.
|
|
45
43
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Schema } from "prosemirror-model";
|
|
1
|
+
import type { Node, NodeType, Schema } from "prosemirror-model";
|
|
2
2
|
import { Transform } from "prosemirror-transform";
|
|
3
3
|
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
|
|
4
4
|
import type { BlockSchema } from "../schema/blocks/types.js";
|
|
@@ -10,3 +10,14 @@ export declare function getBlockSchema<BSchema extends BlockSchema>(schema: Sche
|
|
|
10
10
|
export declare function getInlineContentSchema<I extends InlineContentSchema>(schema: Schema): I;
|
|
11
11
|
export declare function getStyleSchema<S extends StyleSchema>(schema: Schema): S;
|
|
12
12
|
export declare function getBlockCache(schema: Schema): import("../index.js").BlockCache<any, any, any>;
|
|
13
|
+
/**
|
|
14
|
+
* Whether `nodeType` is a BlockNote block whose content type is `"plain"` — i.e.
|
|
15
|
+
* it holds unstyled text and only allows the non-formatting (`"annotation"`)
|
|
16
|
+
* marks. Resolved semantically from the block schema (the source of truth),
|
|
17
|
+
* reachable from `schema.cached.blockNoteEditor`.
|
|
18
|
+
*
|
|
19
|
+
* Returns `false` for every non-block / structural node type (`doc`,
|
|
20
|
+
* `blockGroup`, `text`, inline content, table sub-nodes), since those aren't
|
|
21
|
+
* keys in the block schema.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPlainContentNodeType(schema: Schema, nodeType: NodeType): boolean;
|
|
@@ -23,12 +23,12 @@ export declare const createAudioBlockConfig: (options: AudioOptions) => import("
|
|
|
23
23
|
};
|
|
24
24
|
}, "none">;
|
|
25
25
|
export declare const audioParse: (_config?: AudioOptions) => (element: HTMLElement) => {
|
|
26
|
-
backgroundColor: string | undefined;
|
|
27
26
|
url: string | undefined;
|
|
27
|
+
backgroundColor: string | undefined;
|
|
28
28
|
} | {
|
|
29
|
+
url: string | undefined;
|
|
29
30
|
backgroundColor: string | undefined;
|
|
30
31
|
caption: string | undefined;
|
|
31
|
-
url: string | undefined;
|
|
32
32
|
} | undefined;
|
|
33
33
|
export declare const audioRender: (config?: AudioOptions) => (block: BlockFromConfig<ReturnType<typeof createAudioBlockConfig>, any, any>, editor: BlockNoteEditor<Record<"audio", ReturnType<typeof createAudioBlockConfig>>, any, any>) => {
|
|
34
34
|
dom: HTMLElement;
|
|
@@ -47,7 +47,7 @@ export declare const createCodeBlockConfig: (options: CodeBlockOptions) => impor
|
|
|
47
47
|
readonly language: {
|
|
48
48
|
readonly default: string;
|
|
49
49
|
};
|
|
50
|
-
}, "
|
|
50
|
+
}, "plain">;
|
|
51
51
|
export declare const createCodeBlockSpec: (options?: Partial<{
|
|
52
52
|
indentLineWithTab: boolean;
|
|
53
53
|
defaultLanguage: string;
|
|
@@ -66,5 +66,5 @@ export declare const createCodeBlockSpec: (options?: Partial<{
|
|
|
66
66
|
readonly language: {
|
|
67
67
|
readonly default: string;
|
|
68
68
|
};
|
|
69
|
-
}, "
|
|
69
|
+
}, "plain">;
|
|
70
70
|
export declare function getLanguageId(options: CodeBlockOptions, languageName: string): string | undefined;
|
|
@@ -14,12 +14,12 @@ export declare const createFileBlockConfig: () => import("../../index.js").Block
|
|
|
14
14
|
};
|
|
15
15
|
}, "none">;
|
|
16
16
|
export declare const fileParse: () => (element: HTMLElement) => {
|
|
17
|
-
backgroundColor: string | undefined;
|
|
18
17
|
url: string | undefined;
|
|
18
|
+
backgroundColor: string | undefined;
|
|
19
19
|
} | {
|
|
20
|
+
url: string | undefined;
|
|
20
21
|
backgroundColor: string | undefined;
|
|
21
22
|
caption: string | undefined;
|
|
22
|
-
url: string | undefined;
|
|
23
23
|
} | undefined;
|
|
24
24
|
export declare const createFileBlockSpec: (options?: Partial<Partial<Record<string, any>>> | undefined) => import("../../index.js").BlockSpec<"file", {
|
|
25
25
|
readonly backgroundColor: {
|
|
@@ -6,14 +6,6 @@ export interface HeadingOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export type HeadingBlockConfig = ReturnType<typeof createHeadingBlockConfig>;
|
|
8
8
|
export declare const createHeadingBlockConfig: (() => import("../../index.js").BlockConfig<"heading", {
|
|
9
|
-
readonly isToggleable?: {
|
|
10
|
-
readonly default: false;
|
|
11
|
-
readonly optional: true;
|
|
12
|
-
} | undefined;
|
|
13
|
-
readonly level: {
|
|
14
|
-
readonly default: 1 | 4 | 2 | 3 | 5 | 6;
|
|
15
|
-
readonly values: readonly number[];
|
|
16
|
-
};
|
|
17
9
|
readonly backgroundColor: {
|
|
18
10
|
default: "default";
|
|
19
11
|
};
|
|
@@ -24,15 +16,15 @@ export declare const createHeadingBlockConfig: (() => import("../../index.js").B
|
|
|
24
16
|
default: "left";
|
|
25
17
|
values: readonly ["left", "center", "right", "justify"];
|
|
26
18
|
};
|
|
27
|
-
|
|
19
|
+
readonly level: {
|
|
20
|
+
readonly default: 1 | 2 | 3 | 4 | 5 | 6;
|
|
21
|
+
readonly values: readonly number[];
|
|
22
|
+
};
|
|
28
23
|
readonly isToggleable?: {
|
|
29
24
|
readonly default: false;
|
|
30
25
|
readonly optional: true;
|
|
31
26
|
} | undefined;
|
|
32
|
-
|
|
33
|
-
readonly default: 1 | 4 | 2 | 3 | 5 | 6;
|
|
34
|
-
readonly values: readonly number[];
|
|
35
|
-
};
|
|
27
|
+
}, "inline">) | ((options: HeadingOptions) => import("../../index.js").BlockConfig<"heading", {
|
|
36
28
|
readonly backgroundColor: {
|
|
37
29
|
default: "default";
|
|
38
30
|
};
|
|
@@ -43,20 +35,20 @@ export declare const createHeadingBlockConfig: (() => import("../../index.js").B
|
|
|
43
35
|
default: "left";
|
|
44
36
|
values: readonly ["left", "center", "right", "justify"];
|
|
45
37
|
};
|
|
38
|
+
readonly level: {
|
|
39
|
+
readonly default: 1 | 2 | 3 | 4 | 5 | 6;
|
|
40
|
+
readonly values: readonly number[];
|
|
41
|
+
};
|
|
42
|
+
readonly isToggleable?: {
|
|
43
|
+
readonly default: false;
|
|
44
|
+
readonly optional: true;
|
|
45
|
+
} | undefined;
|
|
46
46
|
}, "inline">);
|
|
47
47
|
export declare const createHeadingBlockSpec: (options?: Partial<{
|
|
48
48
|
defaultLevel: (typeof HEADING_LEVELS)[number];
|
|
49
49
|
levels: readonly number[];
|
|
50
50
|
allowToggleHeadings: boolean;
|
|
51
51
|
}> | undefined) => import("../../index.js").BlockSpec<"heading", {
|
|
52
|
-
readonly isToggleable?: {
|
|
53
|
-
readonly default: false;
|
|
54
|
-
readonly optional: true;
|
|
55
|
-
} | undefined;
|
|
56
|
-
readonly level: {
|
|
57
|
-
readonly default: 1 | 4 | 2 | 3 | 5 | 6;
|
|
58
|
-
readonly values: readonly number[];
|
|
59
|
-
};
|
|
60
52
|
readonly backgroundColor: {
|
|
61
53
|
default: "default";
|
|
62
54
|
};
|
|
@@ -67,5 +59,13 @@ export declare const createHeadingBlockSpec: (options?: Partial<{
|
|
|
67
59
|
default: "left";
|
|
68
60
|
values: readonly ["left", "center", "right", "justify"];
|
|
69
61
|
};
|
|
62
|
+
readonly level: {
|
|
63
|
+
readonly default: 1 | 2 | 3 | 4 | 5 | 6;
|
|
64
|
+
readonly values: readonly number[];
|
|
65
|
+
};
|
|
66
|
+
readonly isToggleable?: {
|
|
67
|
+
readonly default: false;
|
|
68
|
+
readonly optional: true;
|
|
69
|
+
} | undefined;
|
|
70
70
|
}, "inline">;
|
|
71
71
|
export {};
|
|
@@ -55,16 +55,16 @@ export declare const createImageBlockConfig: (() => import("../../index.js").Blo
|
|
|
55
55
|
};
|
|
56
56
|
}, "none">);
|
|
57
57
|
export declare const imageParse: (_config?: ImageOptions) => (element: HTMLElement) => {
|
|
58
|
-
backgroundColor: string | undefined;
|
|
59
58
|
url: string | undefined;
|
|
60
59
|
previewWidth: number | undefined;
|
|
61
60
|
name: string | undefined;
|
|
62
|
-
} | {
|
|
63
61
|
backgroundColor: string | undefined;
|
|
64
|
-
|
|
62
|
+
} | {
|
|
65
63
|
url: string | undefined;
|
|
66
64
|
previewWidth: number | undefined;
|
|
67
65
|
name: string | undefined;
|
|
66
|
+
backgroundColor: string | undefined;
|
|
67
|
+
caption: string | undefined;
|
|
68
68
|
} | undefined;
|
|
69
69
|
export declare const imageRender: (config?: ImageOptions) => (block: BlockFromConfig<ReturnType<typeof createImageBlockConfig>, any, any>, editor: BlockNoteEditor<Record<"image", ReturnType<typeof createImageBlockConfig>>, any, any>) => {
|
|
70
70
|
dom: HTMLElement;
|