@blocknote/core 0.51.3 → 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-D0lMxErU.js → blocks-CiuUGa1E.js} +1096 -998
- 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-D2mx2C9y.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-Dvmif2FY.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 +129 -0
- package/src/blocks/Table/TableExtension.ts +23 -20
- 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 +39 -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/ExtensionManager.test.d.ts +1 -0
- 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-D0lMxErU.js.map +0 -1
- package/dist/blocks-KyMOxPT3.cjs +0 -11
- package/dist/blocks-KyMOxPT3.cjs.map +0 -1
- package/dist/en-B9hMApn4.js.map +0 -1
- package/dist/en-Cj5r8sW_.cjs.map +0 -1
- package/dist/extensions-Cutrafjg.cjs +0 -52
- package/dist/extensions-Cutrafjg.cjs.map +0 -1
- package/dist/extensions-D2mx2C9y.js.map +0 -1
- package/dist/src-D5R5YzV7.cjs +0 -21
- package/dist/src-D5R5YzV7.cjs.map +0 -1
- package/dist/src-Dvmif2FY.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 → blocks/Table/TableExtension.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
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
import type { BlockSchema } from "../schema/index.js";
|
|
12
12
|
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
|
|
13
13
|
import type { StyleSchema } from "../schema/styles/types.js";
|
|
14
|
+
import { getNodeId } from "./getBlockInfoFromPos.js";
|
|
14
15
|
import { nodeToBlock } from "./nodeConversions/nodeToBlock.js";
|
|
15
16
|
import { isNodeBlock } from "./nodeUtil.js";
|
|
16
|
-
import { getPmSchema } from "./pmUtil.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Change detection utilities for BlockNote.
|
|
@@ -40,7 +40,7 @@ function getParentBlockId(doc: Node, pos: number): string | undefined {
|
|
|
40
40
|
for (let i = resolvedPos.depth; i > 0; i--) {
|
|
41
41
|
const parent = resolvedPos.node(i);
|
|
42
42
|
if (isNodeBlock(parent)) {
|
|
43
|
-
return parent
|
|
43
|
+
return getNodeId(parent, doc);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
return undefined;
|
|
@@ -161,7 +161,6 @@ function collectSnapshot<
|
|
|
161
161
|
}
|
|
162
162
|
> = {};
|
|
163
163
|
const childrenByParent: Record<string, string[]> = {};
|
|
164
|
-
const pmSchema = getPmSchema(doc);
|
|
165
164
|
doc.descendants((node, pos) => {
|
|
166
165
|
if (!isNodeBlock(node)) {
|
|
167
166
|
return true;
|
|
@@ -171,9 +170,10 @@ function collectSnapshot<
|
|
|
171
170
|
if (!childrenByParent[key]) {
|
|
172
171
|
childrenByParent[key] = [];
|
|
173
172
|
}
|
|
174
|
-
const block = nodeToBlock(node,
|
|
175
|
-
|
|
176
|
-
|
|
173
|
+
const block = nodeToBlock(node, doc);
|
|
174
|
+
const nodeId = getNodeId(node, doc);
|
|
175
|
+
byId[nodeId] = { block, parentId };
|
|
176
|
+
childrenByParent[key].push(nodeId);
|
|
177
177
|
return true;
|
|
178
178
|
});
|
|
179
179
|
return { byId, childrenByParent };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Node, Schema } from "@tiptap/pm/model";
|
|
2
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
3
|
+
|
|
4
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
5
|
+
import { blockToNode } from "./blockToNode.js";
|
|
6
|
+
import { nodeToBlock } from "./nodeToBlock.js";
|
|
7
|
+
|
|
8
|
+
// `nodeToBlock(node, doc)` takes the containing document as its second argument
|
|
9
|
+
// (it's used to disambiguate suggestion-deletion nodes). These fixtures build a
|
|
10
|
+
// single `blockContainer` in isolation, so wrap it in a minimal valid doc.
|
|
11
|
+
const wrapInDoc = (schema: Schema, blockContainer: Node): Node =>
|
|
12
|
+
schema.nodes["doc"].createChecked(
|
|
13
|
+
null,
|
|
14
|
+
schema.nodes["blockGroup"].createChecked(null, blockContainer),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @vitest-environment jsdom
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// Backwards compatibility for the "plain" content migration on the NON-Yjs
|
|
22
|
+
// (BlockNote JSON) path. A block whose content type changed from "inline"
|
|
23
|
+
// (formatting marks allowed) to "plain" (only the "annotation" group allowed)
|
|
24
|
+
// may appear in stored BlockNote JSON with formatting styles on its text. The
|
|
25
|
+
// write path must drop those disallowed marks instead of throwing when the node
|
|
26
|
+
// is assembled (`createChecked`), and the change must be scoped to plain blocks
|
|
27
|
+
// so inline blocks still keep their formatting.
|
|
28
|
+
|
|
29
|
+
// Old BlockNote JSON: a (now-plain) code block carrying a bold style.
|
|
30
|
+
const legacyBoldCodeBlock = {
|
|
31
|
+
type: "codeBlock" as const,
|
|
32
|
+
props: { language: "javascript" },
|
|
33
|
+
content: [
|
|
34
|
+
{ type: "text" as const, text: "const x = 1;", styles: { bold: true } },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
describe("blockToNode: plain-block backwards compatibility (write path)", () => {
|
|
39
|
+
it("does not throw and drops formatting when converting a plain block with styles", () => {
|
|
40
|
+
const editor = BlockNoteEditor.create();
|
|
41
|
+
|
|
42
|
+
expect(() =>
|
|
43
|
+
blockToNode(legacyBoldCodeBlock as any, editor.pmSchema),
|
|
44
|
+
).not.toThrow();
|
|
45
|
+
|
|
46
|
+
const node = blockToNode(legacyBoldCodeBlock as any, editor.pmSchema);
|
|
47
|
+
// The node is valid (would otherwise fail this check).
|
|
48
|
+
expect(() => node.check()).not.toThrow();
|
|
49
|
+
|
|
50
|
+
// Round-trips back to a plain string with no materialized formatting.
|
|
51
|
+
const block = nodeToBlock(node, wrapInDoc(editor.pmSchema, node));
|
|
52
|
+
expect(block.type).toBe("codeBlock");
|
|
53
|
+
expect(block.content).toEqual([
|
|
54
|
+
{
|
|
55
|
+
styles: {},
|
|
56
|
+
text: "const x = 1;",
|
|
57
|
+
type: "text",
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
editor._tiptapEditor.destroy();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("keeps formatting on an inline block (scoped to plain blocks only)", () => {
|
|
65
|
+
const editor = BlockNoteEditor.create();
|
|
66
|
+
|
|
67
|
+
const node = blockToNode(
|
|
68
|
+
{
|
|
69
|
+
type: "paragraph",
|
|
70
|
+
content: [{ type: "text", text: "hello", styles: { bold: true } }],
|
|
71
|
+
} as any,
|
|
72
|
+
editor.pmSchema,
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const block = nodeToBlock(node, wrapInDoc(editor.pmSchema, node));
|
|
76
|
+
expect(block.type).toBe("paragraph");
|
|
77
|
+
// Paragraph is "inline" content, so bold survives.
|
|
78
|
+
expect(Array.isArray(block.content)).toBe(true);
|
|
79
|
+
expect((block.content as any[])[0].styles.bold).toBe(true);
|
|
80
|
+
|
|
81
|
+
editor._tiptapEditor.destroy();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("mounts an editor with legacy initialContent without throwing", () => {
|
|
85
|
+
const editor = BlockNoteEditor.create({
|
|
86
|
+
initialContent: [legacyBoldCodeBlock as any],
|
|
87
|
+
});
|
|
88
|
+
editor.mount(document.createElement("div"));
|
|
89
|
+
|
|
90
|
+
expect(editor.document.map((b) => b.type)).toEqual(["codeBlock"]);
|
|
91
|
+
expect(editor.document[0].content).toEqual([
|
|
92
|
+
{
|
|
93
|
+
styles: {},
|
|
94
|
+
text: "const x = 1;",
|
|
95
|
+
type: "text",
|
|
96
|
+
},
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
editor._tiptapEditor.destroy();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("read path already strips marks: nodeToBlock yields a bare string", () => {
|
|
103
|
+
const editor = BlockNoteEditor.create();
|
|
104
|
+
|
|
105
|
+
// Build the node leniently and confirm the read path emits no styles even if
|
|
106
|
+
// the block content is plain text.
|
|
107
|
+
const node = blockToNode(legacyBoldCodeBlock as any, editor.pmSchema);
|
|
108
|
+
const block = nodeToBlock(node, wrapInDoc(editor.pmSchema, node));
|
|
109
|
+
expect(Array.isArray(block.content)).toBe(true);
|
|
110
|
+
|
|
111
|
+
editor._tiptapEditor.destroy();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
import { getColspan, isPartialTableCell } from "../../util/table.js";
|
|
20
20
|
import { UnreachableCaseError } from "../../util/typescript.js";
|
|
21
21
|
import { getAbsoluteTableCells } from "../blockManipulation/tables/tables.js";
|
|
22
|
-
import { getStyleSchema } from "../pmUtil.js";
|
|
22
|
+
import { getStyleSchema, isPlainContentNodeType } from "../pmUtil.js";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Convert a StyledText inline element to a
|
|
@@ -52,11 +52,23 @@ function styledTextToNodes<T extends StyleSchema>(
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// Backwards compat: old BlockNote JSON may carry formatting marks (e.g. bold)
|
|
56
|
+
// on a block whose content type is now "plain". Those marks aren't allowed on
|
|
57
|
+
// the node, and would make `createChecked` throw when the block is assembled.
|
|
58
|
+
// Drop them here (for plain blocks only) — comment/suggestion (annotation)
|
|
59
|
+
// marks are allowed and kept by `allowedMarks`.
|
|
60
|
+
const allowedMarks =
|
|
61
|
+
blockType &&
|
|
62
|
+
schema.nodes[blockType] &&
|
|
63
|
+
isPlainContentNodeType(schema, schema.nodes[blockType])
|
|
64
|
+
? [...schema.nodes[blockType].allowedMarks(marks)]
|
|
65
|
+
: marks;
|
|
66
|
+
|
|
55
67
|
const parseHardBreaks = !blockType || !schema.nodes[blockType].spec.code;
|
|
56
68
|
|
|
57
69
|
if (!parseHardBreaks) {
|
|
58
70
|
return styledText.text.length > 0
|
|
59
|
-
? [schema.text(styledText.text,
|
|
71
|
+
? [schema.text(styledText.text, allowedMarks)]
|
|
60
72
|
: [];
|
|
61
73
|
}
|
|
62
74
|
|
|
@@ -72,7 +84,7 @@ function styledTextToNodes<T extends StyleSchema>(
|
|
|
72
84
|
if (text === "\n") {
|
|
73
85
|
return schema.nodes["hardBreak"].createChecked();
|
|
74
86
|
} else {
|
|
75
|
-
return schema.text(text,
|
|
87
|
+
return schema.text(text, allowedMarks);
|
|
76
88
|
}
|
|
77
89
|
})
|
|
78
90
|
);
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
InlineContentSchema,
|
|
6
6
|
StyleSchema,
|
|
7
7
|
} from "../../schema/index.js";
|
|
8
|
-
import { getPmSchema } from "../pmUtil.js";
|
|
9
8
|
import { nodeToBlock } from "./nodeToBlock.js";
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -20,7 +19,6 @@ export function fragmentToBlocks<
|
|
|
20
19
|
// pass these to the exporter
|
|
21
20
|
const blocks: BlockNoDefaults<B, I, S>[] = [];
|
|
22
21
|
fragment.descendants((node) => {
|
|
23
|
-
const pmSchema = getPmSchema(node);
|
|
24
22
|
if (node.type.name === "blockContainer") {
|
|
25
23
|
if (node.firstChild?.type.name === "blockGroup") {
|
|
26
24
|
// selection started within a block group
|
|
@@ -49,13 +47,13 @@ export function fragmentToBlocks<
|
|
|
49
47
|
if (node.type.name === "columnList" && node.childCount === 1) {
|
|
50
48
|
// column lists with a single column should be flattened (not the entire column list has been selected)
|
|
51
49
|
node.firstChild?.forEach((child) => {
|
|
52
|
-
blocks.push(nodeToBlock(child,
|
|
50
|
+
blocks.push(nodeToBlock(child, node));
|
|
53
51
|
});
|
|
54
52
|
return false;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
if (node.type.isInGroup("bnBlock")) {
|
|
58
|
-
blocks.push(nodeToBlock(node,
|
|
56
|
+
blocks.push(nodeToBlock(node, node));
|
|
59
57
|
// don't descend into children, as they're already included in the block returned by nodeToBlock
|
|
60
58
|
return false;
|
|
61
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mark, Node,
|
|
1
|
+
import { Mark, Node, Slice } from "@tiptap/pm/model";
|
|
2
2
|
import type { Block } from "../../blocks/defaultBlocks.js";
|
|
3
3
|
import UniqueID from "../../extensions/tiptap-extensions/UniqueID/UniqueID.js";
|
|
4
4
|
import type {
|
|
@@ -18,12 +18,14 @@ import {
|
|
|
18
18
|
isStyledTextInlineContent,
|
|
19
19
|
} from "../../schema/inlineContent/types.js";
|
|
20
20
|
import { UnreachableCaseError } from "../../util/typescript.js";
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
getBlockInfoWithManualOffset,
|
|
23
|
+
getNodeId,
|
|
24
|
+
} from "../getBlockInfoFromPos.js";
|
|
22
25
|
import {
|
|
23
26
|
getBlockCache,
|
|
24
27
|
getBlockSchema,
|
|
25
28
|
getInlineContentSchema,
|
|
26
|
-
getPmSchema,
|
|
27
29
|
getStyleSchema,
|
|
28
30
|
} from "../pmUtil.js";
|
|
29
31
|
|
|
@@ -385,21 +387,17 @@ export function nodeToCustomInlineContent<
|
|
|
385
387
|
|
|
386
388
|
/**
|
|
387
389
|
* Convert a Prosemirror node to a BlockNote block.
|
|
388
|
-
*
|
|
389
|
-
* TODO: test changes
|
|
390
390
|
*/
|
|
391
391
|
export function nodeToBlock<
|
|
392
392
|
BSchema extends BlockSchema,
|
|
393
393
|
I extends InlineContentSchema,
|
|
394
394
|
S extends StyleSchema,
|
|
395
|
-
>(
|
|
396
|
-
node
|
|
397
|
-
schema
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
blockCache = getBlockCache(schema),
|
|
402
|
-
): Block<BSchema, I, S> {
|
|
395
|
+
>(node: Node, doc: Node): Block<BSchema, I, S> {
|
|
396
|
+
const schema = node.type.schema;
|
|
397
|
+
const blockSchema = getBlockSchema(schema) as BSchema;
|
|
398
|
+
const inlineContentSchema = getInlineContentSchema(schema) as I;
|
|
399
|
+
const styleSchema = getStyleSchema(schema) as S;
|
|
400
|
+
const blockCache = getBlockCache(schema);
|
|
403
401
|
if (!node.type.isInGroup("bnBlock")) {
|
|
404
402
|
throw Error("Node should be a bnBlock, but is instead: " + node.type.name);
|
|
405
403
|
}
|
|
@@ -412,10 +410,11 @@ export function nodeToBlock<
|
|
|
412
410
|
|
|
413
411
|
const blockInfo = getBlockInfoWithManualOffset(node, 0);
|
|
414
412
|
|
|
415
|
-
let id
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
413
|
+
let id: string;
|
|
414
|
+
try {
|
|
415
|
+
id = getNodeId(blockInfo.bnBlock.node, doc);
|
|
416
|
+
} catch {
|
|
417
|
+
// Only used for blocks converted from other formats.
|
|
419
418
|
id = UniqueID.options.generateID();
|
|
420
419
|
}
|
|
421
420
|
|
|
@@ -444,16 +443,7 @@ export function nodeToBlock<
|
|
|
444
443
|
|
|
445
444
|
const children: Block<BSchema, I, S>[] = [];
|
|
446
445
|
blockInfo.childContainer?.node.forEach((child) => {
|
|
447
|
-
children.push(
|
|
448
|
-
nodeToBlock(
|
|
449
|
-
child,
|
|
450
|
-
schema,
|
|
451
|
-
blockSchema,
|
|
452
|
-
inlineContentSchema,
|
|
453
|
-
styleSchema,
|
|
454
|
-
blockCache,
|
|
455
|
-
),
|
|
456
|
-
);
|
|
446
|
+
children.push(nodeToBlock(child, doc));
|
|
457
447
|
});
|
|
458
448
|
|
|
459
449
|
let content: Block<any, any, any>["content"];
|
|
@@ -476,6 +466,14 @@ export function nodeToBlock<
|
|
|
476
466
|
inlineContentSchema,
|
|
477
467
|
styleSchema,
|
|
478
468
|
);
|
|
469
|
+
} else if (blockConfig.content === "plain") {
|
|
470
|
+
if (!blockInfo.isBlockContainer) {
|
|
471
|
+
throw new Error("impossible");
|
|
472
|
+
}
|
|
473
|
+
// Plain content is a single unstyled text item; an empty block is an
|
|
474
|
+
// empty array, matching inline content.
|
|
475
|
+
const text = blockInfo.blockContent.node.textContent;
|
|
476
|
+
content = text.length > 0 ? [{ type: "text", text, styles: {} }] : [];
|
|
479
477
|
} else if (blockConfig.content === "none") {
|
|
480
478
|
content = undefined;
|
|
481
479
|
} else {
|
|
@@ -502,27 +500,11 @@ export function docToBlocks<
|
|
|
502
500
|
BSchema extends BlockSchema,
|
|
503
501
|
I extends InlineContentSchema,
|
|
504
502
|
S extends StyleSchema,
|
|
505
|
-
>(
|
|
506
|
-
doc: Node,
|
|
507
|
-
schema: Schema = getPmSchema(doc),
|
|
508
|
-
blockSchema: BSchema = getBlockSchema(schema) as BSchema,
|
|
509
|
-
inlineContentSchema: I = getInlineContentSchema(schema) as I,
|
|
510
|
-
styleSchema: S = getStyleSchema(schema) as S,
|
|
511
|
-
blockCache = getBlockCache(schema),
|
|
512
|
-
) {
|
|
503
|
+
>(doc: Node) {
|
|
513
504
|
const blocks: Block<BSchema, I, S>[] = [];
|
|
514
505
|
if (doc.firstChild) {
|
|
515
506
|
doc.firstChild.descendants((node) => {
|
|
516
|
-
blocks.push(
|
|
517
|
-
nodeToBlock(
|
|
518
|
-
node,
|
|
519
|
-
schema,
|
|
520
|
-
blockSchema,
|
|
521
|
-
inlineContentSchema,
|
|
522
|
-
styleSchema,
|
|
523
|
-
blockCache,
|
|
524
|
-
),
|
|
525
|
-
);
|
|
507
|
+
blocks.push(nodeToBlock(node, doc));
|
|
526
508
|
return false;
|
|
527
509
|
});
|
|
528
510
|
}
|
|
@@ -554,11 +536,6 @@ export function prosemirrorSliceToSlicedBlocks<
|
|
|
554
536
|
S extends StyleSchema,
|
|
555
537
|
>(
|
|
556
538
|
slice: Slice,
|
|
557
|
-
schema: Schema,
|
|
558
|
-
blockSchema: BSchema = getBlockSchema(schema) as BSchema,
|
|
559
|
-
inlineContentSchema: I = getInlineContentSchema(schema) as I,
|
|
560
|
-
styleSchema: S = getStyleSchema(schema) as S,
|
|
561
|
-
blockCache: WeakMap<Node, Block<BSchema, I, S>> = getBlockCache(schema),
|
|
562
539
|
): {
|
|
563
540
|
/**
|
|
564
541
|
* The blocks that are included in the selection.
|
|
@@ -629,14 +606,7 @@ export function prosemirrorSliceToSlicedBlocks<
|
|
|
629
606
|
return;
|
|
630
607
|
}
|
|
631
608
|
|
|
632
|
-
const block = nodeToBlock(
|
|
633
|
-
blockContainer,
|
|
634
|
-
schema,
|
|
635
|
-
blockSchema,
|
|
636
|
-
inlineContentSchema,
|
|
637
|
-
styleSchema,
|
|
638
|
-
blockCache,
|
|
639
|
-
);
|
|
609
|
+
const block = nodeToBlock(blockContainer, slice.content.firstChild!);
|
|
640
610
|
const childGroup =
|
|
641
611
|
blockContainer.childCount > 1 ? blockContainer.child(1) : undefined;
|
|
642
612
|
|
package/src/api/nodeUtil.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Node } from "prosemirror-model";
|
|
2
|
+
import { getNodeId } from "./getBlockInfoFromPos.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Get a TipTap node by id
|
|
@@ -16,8 +17,11 @@ export function getNodeById(
|
|
|
16
17
|
return false;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
// Keeps traversing nodes if block with target ID has not been found.
|
|
20
|
-
|
|
20
|
+
// Keeps traversing nodes if block with target ID has not been found. Some
|
|
21
|
+
// bnBlock nodes we merely pass over (e.g. `column`/`columnList`) may not
|
|
22
|
+
// carry an id — skip them without calling the throwing `getNodeId`, which
|
|
23
|
+
// errors on id-less nodes. Only nodes that actually have an id are compared.
|
|
24
|
+
if (!isNodeBlock(node) || !node.attrs.id || getNodeId(node, doc) !== id) {
|
|
21
25
|
return true;
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -30,7 +30,7 @@ export function HTMLToBlocks<
|
|
|
30
30
|
const blocks: Block<BSchema, I, S>[] = [];
|
|
31
31
|
|
|
32
32
|
for (let i = 0; i < parentNode.childCount; i++) {
|
|
33
|
-
blocks.push(nodeToBlock(parentNode.child(i),
|
|
33
|
+
blocks.push(nodeToBlock(parentNode.child(i), parentNode));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return blocks;
|