@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
package/src/editor/Block.css
CHANGED
|
@@ -33,8 +33,8 @@ BASIC STYLES
|
|
|
33
33
|
transition: all 0.2s;
|
|
34
34
|
/* Workaround for selection issue on Chrome, see #1588 and also here:
|
|
35
35
|
https://discuss.prosemirror.net/t/mouse-down-selection-behaviour-different-on-chrome/8426
|
|
36
|
-
The :before element causes the selection to be set in the wrong place vs
|
|
37
|
-
other browsers. Setting no height fixes this, while list item indicators are
|
|
36
|
+
The :before element causes the selection to be set in the wrong place vs
|
|
37
|
+
other browsers. Setting no height fixes this, while list item indicators are
|
|
38
38
|
still displayed fine as overflow is not hidden. */
|
|
39
39
|
height: 0;
|
|
40
40
|
overflow: visible;
|
|
@@ -52,6 +52,7 @@ BASIC STYLES
|
|
|
52
52
|
.bn-trailing-block {
|
|
53
53
|
cursor: text;
|
|
54
54
|
height: 30px;
|
|
55
|
+
user-select: none;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/*
|
|
@@ -182,6 +183,11 @@ NESTED BLOCKS
|
|
|
182
183
|
> .bn-block
|
|
183
184
|
> div[data-type="modification"]
|
|
184
185
|
> div[data-type="modification"]
|
|
186
|
+
> .bn-block-content[data-content-type="heading"],
|
|
187
|
+
.bn-block-outer:not([data-prev-type])
|
|
188
|
+
> .bn-block
|
|
189
|
+
> :is(ins, del)
|
|
190
|
+
> .bn-suggestion-node
|
|
185
191
|
> .bn-block-content[data-content-type="heading"] {
|
|
186
192
|
font-size: var(--level);
|
|
187
193
|
font-weight: bold;
|
|
@@ -238,6 +244,11 @@ NESTED BLOCKS
|
|
|
238
244
|
.bn-block-outer:not([data-prev-type])
|
|
239
245
|
> .bn-block
|
|
240
246
|
> div[data-type="modification"]
|
|
247
|
+
> .bn-block-content[data-content-type="numberedListItem"]::before,
|
|
248
|
+
.bn-block-outer:not([data-prev-type])
|
|
249
|
+
> .bn-block
|
|
250
|
+
> :is(ins, del)
|
|
251
|
+
> .bn-suggestion-node
|
|
241
252
|
> .bn-block-content[data-content-type="numberedListItem"]::before {
|
|
242
253
|
content: var(--index) ".";
|
|
243
254
|
}
|
|
@@ -348,7 +359,12 @@ NESTED BLOCKS
|
|
|
348
359
|
.bn-block-outer:not([data-prev-type])
|
|
349
360
|
> .bn-block
|
|
350
361
|
> div[data-type="modification"]
|
|
351
|
-
> .bn-block-content[data-content-type="bulletListItem"]::before
|
|
362
|
+
> .bn-block-content[data-content-type="bulletListItem"]::before,
|
|
363
|
+
.bn-block-outer:not([data-prev-type])
|
|
364
|
+
> .bn-block
|
|
365
|
+
> :is(ins, del)
|
|
366
|
+
> .bn-suggestion-node
|
|
367
|
+
.bn-block-content[data-content-type="bulletListItem"]::before {
|
|
352
368
|
content: "•";
|
|
353
369
|
}
|
|
354
370
|
|
|
@@ -739,3 +755,291 @@ NESTED BLOCKS
|
|
|
739
755
|
.bn-thread-mark .bn-thread-mark-selected {
|
|
740
756
|
background: rgba(255, 200, 0, 0.25);
|
|
741
757
|
}
|
|
758
|
+
|
|
759
|
+
div[data-type="modification"] {
|
|
760
|
+
display: inline;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
.bn-root ins,
|
|
764
|
+
.bn-root del {
|
|
765
|
+
background-color: color-mix(in srgb, var(--user-color-light) 50%, white);
|
|
766
|
+
color: var(--user-color-dark);
|
|
767
|
+
position: relative;
|
|
768
|
+
text-decoration: none;
|
|
769
|
+
border-radius: 4px;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
.dark.bn-root ins,
|
|
773
|
+
.dark.bn-root del {
|
|
774
|
+
background-color: color-mix(in srgb, var(--user-color-dark) 50%, black);
|
|
775
|
+
color: var(--user-color-light);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/*
|
|
779
|
+
In the editor the <ins>/<del> mark wrapper is rendered with `display: contents`
|
|
780
|
+
(see SuggestionMarks.ts) so it never affects layout (e.g. table cells). Because a
|
|
781
|
+
`display: contents` element paints nothing, the highlight is applied to the inner
|
|
782
|
+
content span instead, using the `--user-color-*` properties that cascade down
|
|
783
|
+
from the wrapper. The `.bn-root ins, .bn-root del` rules above still style
|
|
784
|
+
serialized/static output, where the wrapper is a real, painted box.
|
|
785
|
+
*/
|
|
786
|
+
.bn-suggestion-mark {
|
|
787
|
+
background-color: color-mix(in srgb, var(--user-color-light) 50%, white);
|
|
788
|
+
color: var(--user-color-dark);
|
|
789
|
+
border-radius: 4px;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
.dark.bn-root .bn-suggestion-mark {
|
|
793
|
+
background-color: color-mix(in srgb, var(--user-color-dark) 50%, black);
|
|
794
|
+
color: white;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/*
|
|
798
|
+
Block-level (over a node) suggestion marks. The `.bn-suggestion-node` span is
|
|
799
|
+
`display: contents` so it can't paint a background itself; instead the wrapped
|
|
800
|
+
nodes (its children — e.g. <p>/<td>/<tr>) carry the highlight. Like inline marks
|
|
801
|
+
they also show an attribution tooltip on hover (handled in JS, see
|
|
802
|
+
SuggestionMarks.ts).
|
|
803
|
+
|
|
804
|
+
This rule is the highlight for insertions, and the fallback for block deletions
|
|
805
|
+
that wrap content with no `.bn-block-content` of their own (e.g. a deleted table
|
|
806
|
+
row/cell). Block deletions that *do* wrap blocks are restyled per-block below.
|
|
807
|
+
*/
|
|
808
|
+
.bn-suggestion-node > * {
|
|
809
|
+
background-color: color-mix(in srgb, var(--user-color-light) 50%, white);
|
|
810
|
+
border-radius: 4px;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
.dark.bn-root .bn-suggestion-node > * {
|
|
814
|
+
background-color: color-mix(in srgb, var(--user-color-dark) 50%, black);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/*
|
|
818
|
+
A deleted block is tagged with a localized "Deleted" badge before its content.
|
|
819
|
+
The wrapper span (.bn-suggestion-node--delete) is `display: contents` and can't
|
|
820
|
+
render a pseudo-element of its own, so the badge is rendered on the first wrapped
|
|
821
|
+
node, which inherits the label text from the `--deleted-label` custom property
|
|
822
|
+
set in SuggestionMarks.ts (falling back to "Deleted" if absent). This is the
|
|
823
|
+
fallback badge for deletions without a `.bn-block-content` (see above); deletions
|
|
824
|
+
that wrap blocks get a per-block badge below instead.
|
|
825
|
+
*/
|
|
826
|
+
.bn-suggestion-node--delete > *:first-child::before {
|
|
827
|
+
content: var(--deleted-label, "Deleted");
|
|
828
|
+
display: inline-block;
|
|
829
|
+
margin-right: 6px;
|
|
830
|
+
padding: 0 4px;
|
|
831
|
+
font-size: 11px;
|
|
832
|
+
font-weight: bold;
|
|
833
|
+
text-transform: uppercase;
|
|
834
|
+
letter-spacing: 0.04em;
|
|
835
|
+
line-height: 1.4;
|
|
836
|
+
vertical-align: middle;
|
|
837
|
+
/* Use the editor's text color (themed for light/dark) rather than inheriting,
|
|
838
|
+
which would pick up the deleted content's user color. */
|
|
839
|
+
color: var(--bn-colors-editor-text);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/*
|
|
843
|
+
Block suggestions are decided *per block*, not per mark: a deleted parent holding
|
|
844
|
+
a paragraph and an image should strike the paragraph text yet still flag the image
|
|
845
|
+
as deleted. So when a mark wraps real blocks we drop the subtree-wide highlight
|
|
846
|
+
(scoped with `:has(.bn-block-content)` so table row/cell suggestions keep the
|
|
847
|
+
fallback above) and restyle each `.bn-block-content` on its own terms below — for
|
|
848
|
+
insertions and deletions alike.
|
|
849
|
+
*/
|
|
850
|
+
.bn-suggestion-node:has(.bn-block-content) > *,
|
|
851
|
+
.dark.bn-root .bn-suggestion-node:has(.bn-block-content) > * {
|
|
852
|
+
background-color: transparent;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/* The fallback "Deleted" badge (above) is only for deletions with no
|
|
856
|
+
`.bn-block-content`; per-block deletions are flagged individually below. */
|
|
857
|
+
.bn-suggestion-node--delete:has(.bn-block-content) > *:first-child::before {
|
|
858
|
+
content: none;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/*
|
|
862
|
+
A block WITH inline content (paragraph, heading, list item, quote, code, …) needs
|
|
863
|
+
no block-level background: a deletion strikes its text through in the author's
|
|
864
|
+
color, while an insertion already highlights the text via its inline mark
|
|
865
|
+
(.bn-suggestion-mark), so the transparent rule above is all it needs.
|
|
866
|
+
`.bn-inline-content` is present only on inline-content blocks (table cells use a
|
|
867
|
+
bare <p>; images/files/dividers have none), so it's what tells the two cases
|
|
868
|
+
apart. It can be nested below `.bn-block-content` (e.g. code wraps it in <pre>),
|
|
869
|
+
hence the descendant match.
|
|
870
|
+
*/
|
|
871
|
+
.bn-suggestion-node--delete .bn-block-content .bn-inline-content {
|
|
872
|
+
color: var(--user-color-dark);
|
|
873
|
+
text-decoration: line-through;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
.dark.bn-root .bn-suggestion-node--delete .bn-block-content .bn-inline-content {
|
|
877
|
+
color: var(--user-color-light);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/*
|
|
881
|
+
Deleted table cells are a special case: a <tr>/<td> has no `.bn-block-content` and
|
|
882
|
+
its text sits in a bare <p> (not `.bn-inline-content`), so neither the
|
|
883
|
+
strikethrough above nor the block card reaches it — and a table row/cell can't
|
|
884
|
+
host the "Deleted" card anyway. Treat them like inline deletions instead: strike
|
|
885
|
+
the cell text through in the author's color, and suppress the fallback badge.
|
|
886
|
+
*/
|
|
887
|
+
.bn-suggestion-node--delete :is(td, th) p {
|
|
888
|
+
color: var(--user-color-dark);
|
|
889
|
+
text-decoration: line-through;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
.dark.bn-root .bn-suggestion-node--delete :is(td, th) p {
|
|
893
|
+
color: var(--user-color-light);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.bn-suggestion-node--delete > :is(table, tr, td, th):first-child::before {
|
|
897
|
+
content: none;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/*
|
|
901
|
+
A block with NO inline content (image, file, divider, whole table, …) has no text
|
|
902
|
+
to mark up, so the suggestion is shown as a filled card in the author's color, per
|
|
903
|
+
block — on insertions and deletions alike. The card lives on `.bn-block-content`
|
|
904
|
+
because it's the only element present for every block type (the suggestion wrapper
|
|
905
|
+
spans the whole subtree; the media wrapper exists only for files), but it sets
|
|
906
|
+
only non-collapsing properties — background / radius / padding never depend on the
|
|
907
|
+
content's intrinsic size, so no block can break.
|
|
908
|
+
*/
|
|
909
|
+
.bn-suggestion-node .bn-block-content:not(:has(.bn-inline-content)) {
|
|
910
|
+
background-color: color-mix(in srgb, var(--user-color-light) 50%, white);
|
|
911
|
+
border-radius: 16px;
|
|
912
|
+
padding: 12px;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.dark.bn-root
|
|
916
|
+
.bn-suggestion-node
|
|
917
|
+
.bn-block-content:not(:has(.bn-inline-content)) {
|
|
918
|
+
background-color: color-mix(in srgb, var(--user-color-dark) 50%, black);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/*
|
|
922
|
+
Media (image/video/audio/file) has an intrinsic width via its
|
|
923
|
+
`.bn-file-block-content-wrapper`, so the card hugs it instead of spanning the
|
|
924
|
+
column. Width-less blocks (a divider's `flex: 1` <hr>, a table) keep full width on
|
|
925
|
+
purpose — `fit-content` would collapse them to nothing, and full width is the
|
|
926
|
+
right look for them anyway. This is the only place that touches sizing, and it's
|
|
927
|
+
gated on a wrapper that only width-bearing blocks have.
|
|
928
|
+
*/
|
|
929
|
+
.bn-suggestion-node
|
|
930
|
+
.bn-block-content:not(:has(.bn-inline-content)):has(
|
|
931
|
+
> .bn-file-block-content-wrapper
|
|
932
|
+
) {
|
|
933
|
+
width: fit-content;
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
/*
|
|
937
|
+
A deletion additionally flags the block with the localized "Deleted" label, placed
|
|
938
|
+
above the content (out of flow) with extra top padding reserving its row.
|
|
939
|
+
*/
|
|
940
|
+
.bn-suggestion-node--delete .bn-block-content:not(:has(.bn-inline-content)) {
|
|
941
|
+
position: relative;
|
|
942
|
+
padding: 48px 24px 24px;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
.bn-suggestion-node--delete
|
|
946
|
+
.bn-block-content:not(:has(.bn-inline-content))::before {
|
|
947
|
+
content: var(--deleted-label, "Deleted");
|
|
948
|
+
/* Sits in the reserved top padding, above the content. Out of flow so it never
|
|
949
|
+
becomes a flex item beside the block. */
|
|
950
|
+
position: absolute;
|
|
951
|
+
top: 16px;
|
|
952
|
+
left: 24px;
|
|
953
|
+
font-size: 18px;
|
|
954
|
+
font-weight: 500;
|
|
955
|
+
line-height: 1.2;
|
|
956
|
+
/* Use the editor's text color (themed for light/dark) rather than inheriting,
|
|
957
|
+
which would pick up the suggestion's user color. */
|
|
958
|
+
color: var(--bn-colors-editor-text);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/*
|
|
962
|
+
Modification marks (data-type="modification") are shown as a dotted underline in
|
|
963
|
+
the author's color rather than a filled highlight. The text and background are
|
|
964
|
+
left untouched so only the dotted underline carries the color. Both the inline
|
|
965
|
+
(.bn-suggestion-mark) and block-level (.bn-suggestion-node) variants are covered.
|
|
966
|
+
*/
|
|
967
|
+
[data-type="modification"] .bn-suggestion-mark,
|
|
968
|
+
[data-type="modification"] .bn-suggestion-node > * {
|
|
969
|
+
background-color: transparent;
|
|
970
|
+
color: inherit;
|
|
971
|
+
text-decoration: underline dotted;
|
|
972
|
+
text-decoration-color: var(--user-color-dark);
|
|
973
|
+
text-decoration-thickness: 2px;
|
|
974
|
+
text-underline-offset: 2px;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
.dark.bn-root [data-type="modification"] .bn-suggestion-mark,
|
|
978
|
+
.dark.bn-root [data-type="modification"] .bn-suggestion-node > * {
|
|
979
|
+
background-color: transparent;
|
|
980
|
+
color: inherit;
|
|
981
|
+
text-decoration-color: var(--user-color-light);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
/* On hover, reveal the author's color as a filled background. */
|
|
985
|
+
[data-type="modification"] .bn-suggestion-mark:hover,
|
|
986
|
+
[data-type="modification"] .bn-suggestion-node:hover > * {
|
|
987
|
+
background-color: color-mix(in srgb, var(--user-color-light) 50%, white);
|
|
988
|
+
border-radius: 4px;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
.dark.bn-root [data-type="modification"] .bn-suggestion-mark:hover,
|
|
992
|
+
.dark.bn-root [data-type="modification"] .bn-suggestion-node:hover > * {
|
|
993
|
+
background-color: color-mix(in srgb, var(--user-color-dark) 50%, black);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/*
|
|
997
|
+
Deletions are shown as struck-through text in the author's color with no
|
|
998
|
+
background fill (unlike insertions, which carry a filled highlight).
|
|
999
|
+
*/
|
|
1000
|
+
.bn-suggestion-mark--delete {
|
|
1001
|
+
background-color: transparent;
|
|
1002
|
+
color: var(--user-color-dark);
|
|
1003
|
+
text-decoration: line-through;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
.dark.bn-root .bn-suggestion-mark--delete {
|
|
1007
|
+
background-color: transparent;
|
|
1008
|
+
color: var(--user-color-light);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/*
|
|
1012
|
+
Attribution tooltip for suggestion marks (<ins> / <del> / modification).
|
|
1013
|
+
Positioning and portaling are handled by the React controller via floating-ui
|
|
1014
|
+
(see AttributionTooltipController), so only the static box styling lives
|
|
1015
|
+
here. The background color is set inline from the mark's user color unless an
|
|
1016
|
+
app-provided class overrides it (see getSuggestionMarkClassName).
|
|
1017
|
+
*/
|
|
1018
|
+
.bn-suggestion-tooltip {
|
|
1019
|
+
width: max-content;
|
|
1020
|
+
max-width: calc(100vw - 8px);
|
|
1021
|
+
padding: 0 4px;
|
|
1022
|
+
font-weight: bold;
|
|
1023
|
+
font-size: 12px;
|
|
1024
|
+
color: white;
|
|
1025
|
+
background-color: rgb(35, 35, 35);
|
|
1026
|
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
1027
|
+
border-radius: 4px;
|
|
1028
|
+
white-space: nowrap;
|
|
1029
|
+
pointer-events: none;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
.bn-root del {
|
|
1033
|
+
background-color: transparent;
|
|
1034
|
+
color: var(--user-color-dark);
|
|
1035
|
+
text-decoration: line-through;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
.dark.bn-root del {
|
|
1039
|
+
background-color: transparent;
|
|
1040
|
+
color: var(--user-color-light);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
.bn-root del:hover {
|
|
1044
|
+
text-decoration-line: overline;
|
|
1045
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expect, it } from "
|
|
1
|
+
import { afterEach, expect, it } from "vite-plus/test";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -7,20 +7,33 @@ import {
|
|
|
7
7
|
} from "../api/getBlockInfoFromPos.js";
|
|
8
8
|
import { BlockNoteEditor } from "./BlockNoteEditor.js";
|
|
9
9
|
import { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
|
|
10
|
+
import { withCollaboration } from "../yjs/index.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @vitest-environment jsdom
|
|
13
14
|
*/
|
|
15
|
+
|
|
16
|
+
const editorsToCleanup: BlockNoteEditor<any, any, any>[] = [];
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
for (const editor of editorsToCleanup) {
|
|
20
|
+
editor.unmount();
|
|
21
|
+
}
|
|
22
|
+
editorsToCleanup.length = 0;
|
|
23
|
+
});
|
|
24
|
+
|
|
14
25
|
it("creates an editor", () => {
|
|
15
26
|
const editor = BlockNoteEditor.create();
|
|
27
|
+
editorsToCleanup.push(editor);
|
|
16
28
|
const posInfo = editor.transact((tr) => getNearestBlockPos(tr.doc, 2));
|
|
17
29
|
const info = getBlockInfo(posInfo);
|
|
18
30
|
expect(info.blockNoteType).toEqual("paragraph");
|
|
19
31
|
});
|
|
20
32
|
|
|
21
|
-
it("immediately replaces doc",
|
|
33
|
+
it("immediately replaces doc", () => {
|
|
22
34
|
const editor = BlockNoteEditor.create();
|
|
23
|
-
|
|
35
|
+
editorsToCleanup.push(editor);
|
|
36
|
+
const blocks = editor.tryParseMarkdownToBlocks(
|
|
24
37
|
"This is a normal text\n\n# And this is a large heading",
|
|
25
38
|
);
|
|
26
39
|
editor.replaceBlocks(editor.document, blocks);
|
|
@@ -66,21 +79,23 @@ it("immediately replaces doc", async () => {
|
|
|
66
79
|
`);
|
|
67
80
|
});
|
|
68
81
|
|
|
69
|
-
it("adds id attribute when requested",
|
|
82
|
+
it("adds id attribute when requested", () => {
|
|
70
83
|
const editor = BlockNoteEditor.create({
|
|
71
84
|
setIdAttribute: true,
|
|
72
85
|
});
|
|
73
|
-
|
|
86
|
+
editorsToCleanup.push(editor);
|
|
87
|
+
const blocks = editor.tryParseMarkdownToBlocks(
|
|
74
88
|
"This is a normal text\n\n# And this is a large heading",
|
|
75
89
|
);
|
|
76
90
|
editor.replaceBlocks(editor.document, blocks);
|
|
77
|
-
expect(
|
|
91
|
+
expect(editor.blocksToFullHTML(editor.document)).toMatchInlineSnapshot(
|
|
78
92
|
`"<div class="bn-block-group" data-node-type="blockGroup"><div class="bn-block-outer" data-node-type="blockOuter" data-id="1" id="1"><div class="bn-block" data-node-type="blockContainer" data-id="1" id="1"><div class="bn-block-content" data-content-type="paragraph"><p class="bn-inline-content">This is a normal text</p></div></div></div><div class="bn-block-outer" data-node-type="blockOuter" data-id="2" id="2"><div class="bn-block" data-node-type="blockContainer" data-id="2" id="2"><div class="bn-block-content" data-content-type="heading"><h1 class="bn-inline-content">And this is a large heading</h1></div></div></div></div>"`,
|
|
79
93
|
);
|
|
80
94
|
});
|
|
81
95
|
|
|
82
96
|
it("updates block", () => {
|
|
83
97
|
const editor = BlockNoteEditor.create();
|
|
98
|
+
editorsToCleanup.push(editor);
|
|
84
99
|
editor.updateBlock(editor.document[0], {
|
|
85
100
|
content: "hello",
|
|
86
101
|
});
|
|
@@ -89,6 +104,7 @@ it("updates block", () => {
|
|
|
89
104
|
it("block prop types", () => {
|
|
90
105
|
// this test checks whether the block props are correctly typed in typescript
|
|
91
106
|
const editor = BlockNoteEditor.create();
|
|
107
|
+
editorsToCleanup.push(editor);
|
|
92
108
|
const block = editor.document[0];
|
|
93
109
|
if (block.type === "paragraph") {
|
|
94
110
|
// @ts-expect-error
|
|
@@ -108,6 +124,7 @@ it("block prop types", () => {
|
|
|
108
124
|
|
|
109
125
|
it("onMount and onUnmount", async () => {
|
|
110
126
|
const editor = BlockNoteEditor.create();
|
|
127
|
+
editorsToCleanup.push(editor);
|
|
111
128
|
let mounted = false;
|
|
112
129
|
let unmounted = false;
|
|
113
130
|
editor.onMount(() => {
|
|
@@ -132,17 +149,20 @@ it("sets an initial block id when using Y.js", async () => {
|
|
|
132
149
|
const doc = new Y.Doc();
|
|
133
150
|
const fragment = doc.getXmlFragment("doc");
|
|
134
151
|
let transactionCount = 0;
|
|
135
|
-
const editor = BlockNoteEditor.create(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
_tiptapOptions: {
|
|
141
|
-
onTransaction: () => {
|
|
142
|
-
transactionCount++;
|
|
152
|
+
const editor = BlockNoteEditor.create(
|
|
153
|
+
withCollaboration({
|
|
154
|
+
collaboration: {
|
|
155
|
+
fragment,
|
|
156
|
+
user: { name: "Hello", color: "#FFFFFF" },
|
|
143
157
|
},
|
|
144
|
-
|
|
145
|
-
|
|
158
|
+
_tiptapOptions: {
|
|
159
|
+
onTransaction: () => {
|
|
160
|
+
transactionCount++;
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
165
|
+
editorsToCleanup.push(editor);
|
|
146
166
|
|
|
147
167
|
editor.mount(document.createElement("div"));
|
|
148
168
|
|
|
@@ -186,13 +206,14 @@ it("sets an initial block id when using Y.js", async () => {
|
|
|
186
206
|
]);
|
|
187
207
|
expect(transactionCount).toBe(2);
|
|
188
208
|
// Only after a real modification is made, will the fragment be updated
|
|
189
|
-
expect(fragment.toJSON()).
|
|
190
|
-
|
|
209
|
+
expect(fragment.toJSON()).toMatch(
|
|
210
|
+
/^<blockgroup><blockcontainer id="[^"]+"><paragraph backgroundColor="default" textAlignment="left" textColor="default">Hello<\/paragraph><\/blockcontainer><\/blockgroup>$/,
|
|
191
211
|
);
|
|
192
212
|
});
|
|
193
213
|
|
|
194
214
|
it("onBeforeChange", () => {
|
|
195
215
|
const editor = BlockNoteEditor.create();
|
|
216
|
+
editorsToCleanup.push(editor);
|
|
196
217
|
let beforeChangeCalled = false;
|
|
197
218
|
let changes: BlocksChanged<any, any, any> = [];
|
|
198
219
|
editor.onBeforeChange(({ getChanges }) => {
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
DefaultStyleSchema,
|
|
18
18
|
PartialBlock,
|
|
19
19
|
} from "../blocks/index.js";
|
|
20
|
-
import type { CollaborationOptions } from "../extensions/Collaboration/Collaboration.js";
|
|
21
20
|
import {
|
|
22
21
|
BlockChangeExtension,
|
|
23
22
|
DropCursorOptions,
|
|
@@ -81,12 +80,6 @@ export interface BlockNoteEditorOptions<
|
|
|
81
80
|
*/
|
|
82
81
|
autofocus?: FocusPosition;
|
|
83
82
|
|
|
84
|
-
/**
|
|
85
|
-
* When enabled, allows for collaboration between multiple users.
|
|
86
|
-
* See [Real-time Collaboration](https://www.blocknotejs.org/docs/advanced/real-time-collaboration) for more info.
|
|
87
|
-
*/
|
|
88
|
-
collaboration?: CollaborationOptions;
|
|
89
|
-
|
|
90
83
|
/**
|
|
91
84
|
* Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
|
|
92
85
|
*
|
|
@@ -192,10 +185,7 @@ export interface BlockNoteEditorOptions<
|
|
|
192
185
|
* @deprecated, provide placeholders via dictionary instead
|
|
193
186
|
* @internal
|
|
194
187
|
*/
|
|
195
|
-
placeholders?: Record<
|
|
196
|
-
string | "default" | "emptyDocument",
|
|
197
|
-
string | undefined
|
|
198
|
-
>;
|
|
188
|
+
placeholders?: Record<string, string | undefined>;
|
|
199
189
|
|
|
200
190
|
/**
|
|
201
191
|
* Custom paste handler that can be used to override the default paste behavior.
|
|
@@ -501,17 +491,6 @@ export class BlockNoteEditor<
|
|
|
501
491
|
|
|
502
492
|
const tiptapExtensions = this._extensionManager.getTiptapExtensions();
|
|
503
493
|
|
|
504
|
-
const collaborationEnabled =
|
|
505
|
-
this._extensionManager.hasExtension("ySync") ||
|
|
506
|
-
this._extensionManager.hasExtension("liveblocksExtension");
|
|
507
|
-
|
|
508
|
-
if (collaborationEnabled && newOptions.initialContent) {
|
|
509
|
-
// eslint-disable-next-line no-console
|
|
510
|
-
console.warn(
|
|
511
|
-
"When using Collaboration, initialContent might cause conflicts, because changes should come from the collaboration provider",
|
|
512
|
-
);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
494
|
const tiptapOptions: EditorOptions = {
|
|
516
495
|
...blockNoteTipTapOptions,
|
|
517
496
|
...newOptions._tiptapOptions,
|
|
@@ -519,12 +498,14 @@ export class BlockNoteEditor<
|
|
|
519
498
|
autofocus: newOptions.autofocus ?? false,
|
|
520
499
|
extensions: tiptapExtensions,
|
|
521
500
|
editorProps: {
|
|
501
|
+
scrollMargin: { top: 72, bottom: 72, left: 0, right: 0 },
|
|
522
502
|
...newOptions._tiptapOptions?.editorProps,
|
|
523
503
|
attributes: {
|
|
524
504
|
// As of TipTap v2.5.0 the tabIndex is removed when the editor is not
|
|
525
505
|
// editable, so you can't focus it. We want to revert this as we have
|
|
526
506
|
// UI behaviour that relies on it.
|
|
527
507
|
tabIndex: "0",
|
|
508
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-spread
|
|
528
509
|
...newOptions._tiptapOptions?.editorProps?.attributes,
|
|
529
510
|
...newOptions.domAttributes?.editor,
|
|
530
511
|
class: mergeCSSClasses(
|
|
@@ -538,29 +519,24 @@ export class BlockNoteEditor<
|
|
|
538
519
|
} as any;
|
|
539
520
|
|
|
540
521
|
try {
|
|
541
|
-
const initialContent =
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
id: "initialBlockId",
|
|
548
|
-
},
|
|
549
|
-
]
|
|
550
|
-
: [
|
|
551
|
-
{
|
|
552
|
-
type: "paragraph",
|
|
553
|
-
id: UniqueID.options.generateID(),
|
|
554
|
-
},
|
|
555
|
-
]);
|
|
522
|
+
const initialContent = newOptions.initialContent || [
|
|
523
|
+
{
|
|
524
|
+
type: "paragraph",
|
|
525
|
+
id: UniqueID.options.generateID(),
|
|
526
|
+
},
|
|
527
|
+
];
|
|
556
528
|
|
|
557
529
|
if (!Array.isArray(initialContent) || initialContent.length === 0) {
|
|
558
530
|
throw new Error(
|
|
559
531
|
"initialContent must be a non-empty array of blocks, received: " +
|
|
560
|
-
initialContent,
|
|
532
|
+
JSON.stringify(initialContent),
|
|
561
533
|
);
|
|
562
534
|
}
|
|
563
535
|
const schema = getSchema(tiptapOptions.extensions!);
|
|
536
|
+
// `blockToNode` (via `isPlainContentNodeType`) resolves the block schema
|
|
537
|
+
// through `schema.cached.blockNoteEditor`, so stamp it on this throwaway
|
|
538
|
+
// schema now — the real `pmSchema` is stamped separately below.
|
|
539
|
+
schema.cached.blockNoteEditor = this;
|
|
564
540
|
const pmNodes = initialContent.map((b) =>
|
|
565
541
|
blockToNode(b, schema, this.schema.styleSchema).toJSON(),
|
|
566
542
|
);
|
|
@@ -590,25 +566,6 @@ export class BlockNoteEditor<
|
|
|
590
566
|
);
|
|
591
567
|
}
|
|
592
568
|
|
|
593
|
-
// When y-prosemirror creates an empty document, the `blockContainer` node is created with an `id` of `null`.
|
|
594
|
-
// This causes the unique id extension to generate a new id for the initial block, which is not what we want
|
|
595
|
-
// Since it will be randomly generated & cause there to be more updates to the ydoc
|
|
596
|
-
// This is a hack to make it so that anytime `schema.doc.createAndFill` is called, the initial block id is already set to "initialBlockId"
|
|
597
|
-
let cache: Node | undefined = undefined;
|
|
598
|
-
const oldCreateAndFill = this.pmSchema.nodes.doc.createAndFill;
|
|
599
|
-
this.pmSchema.nodes.doc.createAndFill = (...args: any) => {
|
|
600
|
-
if (cache) {
|
|
601
|
-
return cache;
|
|
602
|
-
}
|
|
603
|
-
const ret = oldCreateAndFill.apply(this.pmSchema.nodes.doc, args)!;
|
|
604
|
-
|
|
605
|
-
// create a copy that we can mutate (otherwise, assigning attrs is not safe and corrupts the pm state)
|
|
606
|
-
const jsonNode = JSON.parse(JSON.stringify(ret.toJSON()));
|
|
607
|
-
jsonNode.content[0].content[0].attrs.id = "initialBlockId";
|
|
608
|
-
|
|
609
|
-
cache = Node.fromJSON(this.pmSchema, jsonNode);
|
|
610
|
-
return cache;
|
|
611
|
-
};
|
|
612
569
|
this.pmSchema.cached.blockNoteEditor = this;
|
|
613
570
|
|
|
614
571
|
this._tiptapEditor.on("mount", () => {
|
|
@@ -722,6 +679,14 @@ export class BlockNoteEditor<
|
|
|
722
679
|
...args: Parameters<ExtensionManager["registerExtension"]>
|
|
723
680
|
) => this._extensionManager.registerExtension(...args) as any;
|
|
724
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Atomically unregister old extensions and register new ones in a single
|
|
684
|
+
* plugin update, avoiding re-entrant dispatch issues.
|
|
685
|
+
*/
|
|
686
|
+
public replaceExtension: ExtensionManager["replaceExtension"] = (
|
|
687
|
+
...args: Parameters<ExtensionManager["replaceExtension"]>
|
|
688
|
+
) => this._extensionManager.replaceExtension(...args);
|
|
689
|
+
|
|
725
690
|
/**
|
|
726
691
|
* Get an extension from the editor
|
|
727
692
|
*/
|