@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
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import type { User } from "../types.js";
|
|
2
|
-
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The `UserStore` is used to retrieve and cache information about users.
|
|
6
|
-
*
|
|
7
|
-
* It does this by calling `resolveUsers` (which is user-defined in the Editor Options)
|
|
8
|
-
* for users that are not yet cached.
|
|
9
|
-
*/
|
|
10
|
-
export class UserStore<U extends User> extends EventEmitter<any> {
|
|
11
|
-
private userCache: Map<string, U> = new Map();
|
|
12
|
-
|
|
13
|
-
// avoid duplicate loads
|
|
14
|
-
private loadingUsers = new Set<string>();
|
|
15
|
-
|
|
16
|
-
public constructor(
|
|
17
|
-
private readonly resolveUsers: (userIds: string[]) => Promise<U[]>,
|
|
18
|
-
) {
|
|
19
|
-
super();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Load information about users based on an array of user ids.
|
|
24
|
-
*/
|
|
25
|
-
public async loadUsers(userIds: string[]) {
|
|
26
|
-
const missingUsers = userIds.filter(
|
|
27
|
-
(id) => !this.userCache.has(id) && !this.loadingUsers.has(id),
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
if (missingUsers.length === 0) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (const id of missingUsers) {
|
|
35
|
-
this.loadingUsers.add(id);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const users = await this.resolveUsers(missingUsers);
|
|
40
|
-
for (const user of users) {
|
|
41
|
-
this.userCache.set(user.id, user);
|
|
42
|
-
}
|
|
43
|
-
this.emit("update", this.userCache);
|
|
44
|
-
} finally {
|
|
45
|
-
for (const id of missingUsers) {
|
|
46
|
-
// delete the users from the loading set
|
|
47
|
-
// on a next call to `loadUsers` we will either
|
|
48
|
-
// return the cached user or retry loading the user if the request failed failed
|
|
49
|
-
this.loadingUsers.delete(id);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Retrieve information about a user based on their id, if cached.
|
|
56
|
-
*
|
|
57
|
-
* The user will have to be loaded via `loadUsers` first
|
|
58
|
-
*/
|
|
59
|
-
public getUser(userId: string): U | undefined {
|
|
60
|
-
return this.userCache.get(userId);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Subscribe to changes in the user store.
|
|
65
|
-
*
|
|
66
|
-
* @param cb - The callback to call when the user store changes.
|
|
67
|
-
* @returns A function to unsubscribe from the user store.
|
|
68
|
-
*/
|
|
69
|
-
public subscribe(cb: (users: Map<string, U>) => void): () => void {
|
|
70
|
-
return this.on("update", cb);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type * as Y from "yjs";
|
|
2
|
-
import type { Awareness } from "y-protocols/awareness";
|
|
3
|
-
import {
|
|
4
|
-
createExtension,
|
|
5
|
-
ExtensionOptions,
|
|
6
|
-
} from "../../editor/BlockNoteExtension.js";
|
|
7
|
-
import { ForkYDocExtension } from "./ForkYDoc.js";
|
|
8
|
-
import { SchemaMigration } from "./schemaMigration/SchemaMigration.js";
|
|
9
|
-
import { YCursorExtension } from "./YCursorPlugin.js";
|
|
10
|
-
import { YSyncExtension } from "./YSync.js";
|
|
11
|
-
import { YUndoExtension } from "./YUndo.js";
|
|
12
|
-
|
|
13
|
-
export type CollaborationOptions = {
|
|
14
|
-
/**
|
|
15
|
-
* The Yjs XML fragment that's used for collaboration.
|
|
16
|
-
*/
|
|
17
|
-
fragment: Y.XmlFragment;
|
|
18
|
-
/**
|
|
19
|
-
* The user info for the current user that's shown to other collaborators.
|
|
20
|
-
*/
|
|
21
|
-
user: {
|
|
22
|
-
name: string;
|
|
23
|
-
color: string;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* A Yjs provider (used for awareness / cursor information)
|
|
27
|
-
*/
|
|
28
|
-
provider?: { awareness?: Awareness };
|
|
29
|
-
/**
|
|
30
|
-
* Optional function to customize how cursors of users are rendered
|
|
31
|
-
*/
|
|
32
|
-
renderCursor?: (user: any) => HTMLElement;
|
|
33
|
-
/**
|
|
34
|
-
* Optional flag to set when the user label should be shown with the default
|
|
35
|
-
* collaboration cursor. Setting to "always" will always show the label,
|
|
36
|
-
* while "activity" will only show the label when the user moves the cursor
|
|
37
|
-
* or types. Defaults to "activity".
|
|
38
|
-
*/
|
|
39
|
-
showCursorLabels?: "always" | "activity";
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const CollaborationExtension = createExtension(
|
|
43
|
-
({ options }: ExtensionOptions<CollaborationOptions>) => {
|
|
44
|
-
return {
|
|
45
|
-
key: "collaboration",
|
|
46
|
-
blockNoteExtensions: [
|
|
47
|
-
ForkYDocExtension(options),
|
|
48
|
-
YCursorExtension(options),
|
|
49
|
-
YSyncExtension(options),
|
|
50
|
-
YUndoExtension(),
|
|
51
|
-
SchemaMigration(options),
|
|
52
|
-
],
|
|
53
|
-
} as const;
|
|
54
|
-
},
|
|
55
|
-
);
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { expect, it } from "vitest";
|
|
2
|
-
import * as Y from "yjs";
|
|
3
|
-
import { Awareness } from "y-protocols/awareness";
|
|
4
|
-
import { BlockNoteEditor } from "../../index.js";
|
|
5
|
-
import { ForkYDocExtension } from "./ForkYDoc.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @vitest-environment jsdom
|
|
9
|
-
*/
|
|
10
|
-
it("can fork a document", async () => {
|
|
11
|
-
const doc = new Y.Doc();
|
|
12
|
-
const fragment = doc.getXmlFragment("doc");
|
|
13
|
-
const editor = BlockNoteEditor.create({
|
|
14
|
-
collaboration: {
|
|
15
|
-
fragment,
|
|
16
|
-
user: { name: "Hello", color: "#FFFFFF" },
|
|
17
|
-
provider: {
|
|
18
|
-
awareness: new Awareness(doc),
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const div = document.createElement("div");
|
|
25
|
-
editor.mount(div);
|
|
26
|
-
|
|
27
|
-
editor.replaceBlocks(editor.document, [
|
|
28
|
-
{
|
|
29
|
-
type: "paragraph",
|
|
30
|
-
content: [{ text: "Hello", styles: {}, type: "text" }],
|
|
31
|
-
},
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
35
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
36
|
-
);
|
|
37
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
38
|
-
"__snapshots__/fork-yjs-snap-editor.json",
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
editor.getExtension(ForkYDocExtension)!.fork();
|
|
42
|
-
|
|
43
|
-
editor.replaceBlocks(editor.document, [
|
|
44
|
-
{
|
|
45
|
-
type: "paragraph",
|
|
46
|
-
content: [{ text: "Hello World", styles: {}, type: "text" }],
|
|
47
|
-
},
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
51
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
52
|
-
);
|
|
53
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
54
|
-
"__snapshots__/fork-yjs-snap-editor-forked.json",
|
|
55
|
-
);
|
|
56
|
-
} finally {
|
|
57
|
-
editor.unmount();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("can merge a document", async () => {
|
|
62
|
-
const doc = new Y.Doc();
|
|
63
|
-
const fragment = doc.getXmlFragment("doc");
|
|
64
|
-
const editor = BlockNoteEditor.create({
|
|
65
|
-
collaboration: {
|
|
66
|
-
fragment,
|
|
67
|
-
user: { name: "Hello", color: "#FFFFFF" },
|
|
68
|
-
provider: {
|
|
69
|
-
awareness: new Awareness(doc),
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
try {
|
|
75
|
-
const div = document.createElement("div");
|
|
76
|
-
editor.mount(div);
|
|
77
|
-
|
|
78
|
-
editor.replaceBlocks(editor.document, [
|
|
79
|
-
{
|
|
80
|
-
type: "paragraph",
|
|
81
|
-
content: [{ text: "Hello", styles: {}, type: "text" }],
|
|
82
|
-
},
|
|
83
|
-
]);
|
|
84
|
-
|
|
85
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
86
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
87
|
-
);
|
|
88
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
89
|
-
"__snapshots__/fork-yjs-snap-editor.json",
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
editor.getExtension(ForkYDocExtension)!.fork();
|
|
93
|
-
|
|
94
|
-
editor.replaceBlocks(editor.document, [
|
|
95
|
-
{
|
|
96
|
-
type: "paragraph",
|
|
97
|
-
content: [{ text: "Hello World", styles: {}, type: "text" }],
|
|
98
|
-
},
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
102
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
103
|
-
);
|
|
104
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
105
|
-
"__snapshots__/fork-yjs-snap-editor-forked.json",
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
editor.getExtension(ForkYDocExtension)!.merge({ keepChanges: false });
|
|
109
|
-
|
|
110
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
111
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
112
|
-
);
|
|
113
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
114
|
-
"__snapshots__/fork-yjs-snap-editor.json",
|
|
115
|
-
);
|
|
116
|
-
} finally {
|
|
117
|
-
editor.unmount();
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it("can fork an keep the changes to the original document", async () => {
|
|
122
|
-
const doc = new Y.Doc();
|
|
123
|
-
const fragment = doc.getXmlFragment("doc");
|
|
124
|
-
const editor = BlockNoteEditor.create({
|
|
125
|
-
collaboration: {
|
|
126
|
-
fragment,
|
|
127
|
-
user: { name: "Hello", color: "#FFFFFF" },
|
|
128
|
-
provider: {
|
|
129
|
-
awareness: new Awareness(doc),
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
const div = document.createElement("div");
|
|
136
|
-
editor.mount(div);
|
|
137
|
-
|
|
138
|
-
editor.replaceBlocks(editor.document, [
|
|
139
|
-
{
|
|
140
|
-
type: "paragraph",
|
|
141
|
-
content: [{ text: "Hello", styles: {}, type: "text" }],
|
|
142
|
-
},
|
|
143
|
-
]);
|
|
144
|
-
|
|
145
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
146
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
147
|
-
);
|
|
148
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
149
|
-
"__snapshots__/fork-yjs-snap-editor.json",
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
editor.getExtension(ForkYDocExtension)!.fork();
|
|
153
|
-
|
|
154
|
-
editor.replaceBlocks(editor.document, [
|
|
155
|
-
{
|
|
156
|
-
type: "paragraph",
|
|
157
|
-
content: [{ text: "Hello World", styles: {}, type: "text" }],
|
|
158
|
-
},
|
|
159
|
-
]);
|
|
160
|
-
|
|
161
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
162
|
-
"__snapshots__/fork-yjs-snap.html",
|
|
163
|
-
);
|
|
164
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
165
|
-
"__snapshots__/fork-yjs-snap-editor-forked.json",
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
editor.getExtension(ForkYDocExtension)!.merge({ keepChanges: true });
|
|
169
|
-
|
|
170
|
-
await expect(fragment.toJSON()).toMatchFileSnapshot(
|
|
171
|
-
"__snapshots__/fork-yjs-snap-forked.html",
|
|
172
|
-
);
|
|
173
|
-
await expect(editor.document).toMatchFileSnapshot(
|
|
174
|
-
"__snapshots__/fork-yjs-snap-editor-forked.json",
|
|
175
|
-
);
|
|
176
|
-
} finally {
|
|
177
|
-
editor.unmount();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { Mark } from "@tiptap/core";
|
|
2
|
-
import { MarkSpec } from "prosemirror-model";
|
|
3
|
-
|
|
4
|
-
// This copies the marks from @handlewithcare/prosemirror-suggest-changes,
|
|
5
|
-
// but uses the Tiptap Mark API instead so we can use them in BlockNote
|
|
6
|
-
|
|
7
|
-
// The ideal solution would be to not depend on tiptap nodes / marks, but be able to use prosemirror nodes / marks directly
|
|
8
|
-
// this way we could directly use the exported marks from @handlewithcare/prosemirror-suggest-changes
|
|
9
|
-
export const SuggestionAddMark = Mark.create({
|
|
10
|
-
name: "insertion",
|
|
11
|
-
inclusive: false,
|
|
12
|
-
excludes: "deletion modification insertion",
|
|
13
|
-
addAttributes() {
|
|
14
|
-
return {
|
|
15
|
-
id: { default: null, validate: "number" }, // note: validate is supported in prosemirror but not in tiptap, so this doesn't actually work (considered not critical)
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
extendMarkSchema(extension) {
|
|
19
|
-
if (extension.name !== "insertion") {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
blocknoteIgnore: true,
|
|
24
|
-
inclusive: false,
|
|
25
|
-
|
|
26
|
-
toDOM(mark, inline) {
|
|
27
|
-
return [
|
|
28
|
-
"ins",
|
|
29
|
-
{
|
|
30
|
-
"data-id": String(mark.attrs["id"]),
|
|
31
|
-
"data-inline": String(inline),
|
|
32
|
-
...(!inline && { style: "display: contents" }), // changed to "contents" to make this work for table rows
|
|
33
|
-
},
|
|
34
|
-
0,
|
|
35
|
-
];
|
|
36
|
-
},
|
|
37
|
-
parseDOM: [
|
|
38
|
-
{
|
|
39
|
-
tag: "ins",
|
|
40
|
-
getAttrs(node) {
|
|
41
|
-
if (!node.dataset["id"]) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
id: parseInt(node.dataset["id"], 10),
|
|
46
|
-
};
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
} satisfies MarkSpec;
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export const SuggestionDeleteMark = Mark.create({
|
|
55
|
-
name: "deletion",
|
|
56
|
-
inclusive: false,
|
|
57
|
-
excludes: "insertion modification deletion",
|
|
58
|
-
addAttributes() {
|
|
59
|
-
return {
|
|
60
|
-
id: { default: null, validate: "number" }, // note: validate is supported in prosemirror but not in tiptap
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
extendMarkSchema(extension) {
|
|
64
|
-
if (extension.name !== "deletion") {
|
|
65
|
-
return {};
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
blocknoteIgnore: true,
|
|
69
|
-
inclusive: false,
|
|
70
|
-
|
|
71
|
-
// attrs: {
|
|
72
|
-
// id: { validate: "number" },
|
|
73
|
-
// },
|
|
74
|
-
toDOM(mark, inline) {
|
|
75
|
-
return [
|
|
76
|
-
"del",
|
|
77
|
-
{
|
|
78
|
-
"data-id": String(mark.attrs["id"]),
|
|
79
|
-
"data-inline": String(inline),
|
|
80
|
-
...(!inline && { style: "display: contents" }), // changed to "contents" to make this work for table rows
|
|
81
|
-
},
|
|
82
|
-
0,
|
|
83
|
-
];
|
|
84
|
-
},
|
|
85
|
-
parseDOM: [
|
|
86
|
-
{
|
|
87
|
-
tag: "del",
|
|
88
|
-
getAttrs(node) {
|
|
89
|
-
if (!node.dataset["id"]) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
id: parseInt(node.dataset["id"], 10),
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
} satisfies MarkSpec;
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
export const SuggestionModificationMark = Mark.create({
|
|
103
|
-
name: "modification",
|
|
104
|
-
inclusive: false,
|
|
105
|
-
excludes: "deletion insertion",
|
|
106
|
-
addAttributes() {
|
|
107
|
-
// note: validate is supported in prosemirror but not in tiptap
|
|
108
|
-
return {
|
|
109
|
-
id: { default: null, validate: "number" },
|
|
110
|
-
type: { validate: "string" },
|
|
111
|
-
attrName: { default: null, validate: "string|null" },
|
|
112
|
-
previousValue: { default: null },
|
|
113
|
-
newValue: { default: null },
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
extendMarkSchema(extension) {
|
|
117
|
-
if (extension.name !== "modification") {
|
|
118
|
-
return {};
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
blocknoteIgnore: true,
|
|
122
|
-
inclusive: false,
|
|
123
|
-
// attrs: {
|
|
124
|
-
// id: { validate: "number" },
|
|
125
|
-
// type: { validate: "string" },
|
|
126
|
-
// attrName: { default: null, validate: "string|null" },
|
|
127
|
-
// previousValue: { default: null },
|
|
128
|
-
// newValue: { default: null },
|
|
129
|
-
// },
|
|
130
|
-
toDOM(mark, inline) {
|
|
131
|
-
return [
|
|
132
|
-
inline ? "span" : "div",
|
|
133
|
-
{
|
|
134
|
-
"data-type": "modification",
|
|
135
|
-
"data-id": String(mark.attrs["id"]),
|
|
136
|
-
"data-mod-type": mark.attrs["type"] as string,
|
|
137
|
-
"data-mod-prev-val": JSON.stringify(mark.attrs["previousValue"]),
|
|
138
|
-
// TODO: Try to serialize marks with toJSON?
|
|
139
|
-
"data-mod-new-val": JSON.stringify(mark.attrs["newValue"]),
|
|
140
|
-
},
|
|
141
|
-
0,
|
|
142
|
-
];
|
|
143
|
-
},
|
|
144
|
-
parseDOM: [
|
|
145
|
-
{
|
|
146
|
-
tag: "span[data-type='modification']",
|
|
147
|
-
getAttrs(node) {
|
|
148
|
-
if (!node.dataset["id"]) {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
id: parseInt(node.dataset["id"], 10),
|
|
153
|
-
type: node.dataset["modType"],
|
|
154
|
-
previousValue: node.dataset["modPrevVal"],
|
|
155
|
-
newValue: node.dataset["modNewVal"],
|
|
156
|
-
};
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
tag: "div[data-type='modification']",
|
|
161
|
-
getAttrs(node) {
|
|
162
|
-
if (!node.dataset["id"]) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
id: parseInt(node.dataset["id"], 10),
|
|
167
|
-
type: node.dataset["modType"],
|
|
168
|
-
previousValue: node.dataset["modPrevVal"],
|
|
169
|
-
};
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
} satisfies MarkSpec;
|
|
174
|
-
},
|
|
175
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { User } from "../types.js";
|
|
2
|
-
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
3
|
-
/**
|
|
4
|
-
* The `UserStore` is used to retrieve and cache information about users.
|
|
5
|
-
*
|
|
6
|
-
* It does this by calling `resolveUsers` (which is user-defined in the Editor Options)
|
|
7
|
-
* for users that are not yet cached.
|
|
8
|
-
*/
|
|
9
|
-
export declare class UserStore<U extends User> extends EventEmitter<any> {
|
|
10
|
-
private readonly resolveUsers;
|
|
11
|
-
private userCache;
|
|
12
|
-
private loadingUsers;
|
|
13
|
-
constructor(resolveUsers: (userIds: string[]) => Promise<U[]>);
|
|
14
|
-
/**
|
|
15
|
-
* Load information about users based on an array of user ids.
|
|
16
|
-
*/
|
|
17
|
-
loadUsers(userIds: string[]): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Retrieve information about a user based on their id, if cached.
|
|
20
|
-
*
|
|
21
|
-
* The user will have to be loaded via `loadUsers` first
|
|
22
|
-
*/
|
|
23
|
-
getUser(userId: string): U | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Subscribe to changes in the user store.
|
|
26
|
-
*
|
|
27
|
-
* @param cb - The callback to call when the user store changes.
|
|
28
|
-
* @returns A function to unsubscribe from the user store.
|
|
29
|
-
*/
|
|
30
|
-
subscribe(cb: (users: Map<string, U>) => void): () => void;
|
|
31
|
-
}
|
|
File without changes
|
|
File without changes
|
/package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json
RENAMED
|
File without changes
|
/package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|