@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/dist/comments.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { Mark as
|
|
5
|
-
import { Plugin as
|
|
6
|
-
import {
|
|
7
|
-
import { Decoration as l, DecorationSet as u } from "prosemirror-view";
|
|
8
|
-
import { getRelativeSelection as d, ySyncPluginKey as f } from "y-prosemirror";
|
|
9
|
-
import * as p from "yjs";
|
|
1
|
+
import { i as e, n as t, t as n } from "./BlockNoteExtension-B_IEJHS8.js";
|
|
2
|
+
import { n as r, r as i } from "./UserStore-QbbPFj0z.js";
|
|
3
|
+
import { t as a } from "./ThreadStore-et9wB5Xt.js";
|
|
4
|
+
import { Mark as o, mergeAttributes as s } from "@tiptap/core";
|
|
5
|
+
import { Plugin as c, PluginKey as l } from "prosemirror-state";
|
|
6
|
+
import { Decoration as u, DecorationSet as d } from "prosemirror-view";
|
|
10
7
|
//#region src/comments/mark.ts
|
|
11
|
-
var
|
|
8
|
+
var f = o.create({
|
|
12
9
|
name: "comment",
|
|
13
10
|
excludes: "",
|
|
14
11
|
inclusive: !1,
|
|
15
12
|
keepOnSplit: !0,
|
|
13
|
+
group: e,
|
|
16
14
|
addAttributes() {
|
|
17
15
|
return {
|
|
18
16
|
orphan: {
|
|
@@ -28,7 +26,7 @@ var m = i.create({
|
|
|
28
26
|
};
|
|
29
27
|
},
|
|
30
28
|
renderHTML({ HTMLAttributes: e }) {
|
|
31
|
-
return ["span",
|
|
29
|
+
return ["span", s(e, { class: "bn-thread-mark" })];
|
|
32
30
|
},
|
|
33
31
|
parseHTML() {
|
|
34
32
|
return [{ tag: "span.bn-thread-mark" }];
|
|
@@ -36,33 +34,8 @@ var m = i.create({
|
|
|
36
34
|
extendMarkSchema(e) {
|
|
37
35
|
return e.name === "comment" ? { blocknoteIgnore: !0 } : {};
|
|
38
36
|
}
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
loadingUsers = /* @__PURE__ */ new Set();
|
|
42
|
-
constructor(e) {
|
|
43
|
-
super(), this.resolveUsers = e;
|
|
44
|
-
}
|
|
45
|
-
async loadUsers(e) {
|
|
46
|
-
let t = e.filter((e) => !this.userCache.has(e) && !this.loadingUsers.has(e));
|
|
47
|
-
if (t.length !== 0) {
|
|
48
|
-
for (let e of t) this.loadingUsers.add(e);
|
|
49
|
-
try {
|
|
50
|
-
let e = await this.resolveUsers(t);
|
|
51
|
-
for (let t of e) this.userCache.set(t.id, t);
|
|
52
|
-
this.emit("update", this.userCache);
|
|
53
|
-
} finally {
|
|
54
|
-
for (let e of t) this.loadingUsers.delete(e);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
getUser(e) {
|
|
59
|
-
return this.userCache.get(e);
|
|
60
|
-
}
|
|
61
|
-
subscribe(e) {
|
|
62
|
-
return this.on("update", e);
|
|
63
|
-
}
|
|
64
|
-
}, g = new s("blocknote-comments");
|
|
65
|
-
function _(e, t) {
|
|
37
|
+
}), p = new l("blocknote-comments");
|
|
38
|
+
function m(e, t) {
|
|
66
39
|
let n = /* @__PURE__ */ new Map();
|
|
67
40
|
return e.descendants((e, r) => {
|
|
68
41
|
e.marks.forEach((i) => {
|
|
@@ -81,27 +54,27 @@ function _(e, t) {
|
|
|
81
54
|
});
|
|
82
55
|
}), n;
|
|
83
56
|
}
|
|
84
|
-
var
|
|
85
|
-
if (!
|
|
86
|
-
if (!
|
|
87
|
-
let
|
|
57
|
+
var h = n(({ editor: e, options: { schema: n, threadStore: a, resolveUsers: o, confirmBeforeDiscard: s = !0 } }) => {
|
|
58
|
+
if (!o) throw Error("resolveUsers is required to be defined when using comments");
|
|
59
|
+
if (!a) throw Error("threadStore is required to be defined when using comments");
|
|
60
|
+
let l = r(o), h = f.name, g = t({
|
|
88
61
|
pendingComment: !1,
|
|
89
62
|
selectedThreadId: void 0,
|
|
90
63
|
threadPositions: /* @__PURE__ */ new Map()
|
|
91
64
|
}, { onUpdate() {
|
|
92
|
-
|
|
93
|
-
} }),
|
|
94
|
-
|
|
95
|
-
|
|
65
|
+
g.state.selectedThreadId !== g.prevState.selectedThreadId && e.transact((e) => e.setMeta(p, !0));
|
|
66
|
+
} }), _ = (t) => {
|
|
67
|
+
e.transact((e) => {
|
|
68
|
+
e.doc.descendants((n, r) => {
|
|
96
69
|
n.marks.forEach((i) => {
|
|
97
|
-
if (i.type.name ===
|
|
98
|
-
let a = i.type, o = i.attrs.threadId, s =
|
|
70
|
+
if (i.type.name === h) {
|
|
71
|
+
let a = i.type, o = i.attrs.threadId, s = t.get(o), c = !!(!s || s.resolved || s.deletedAt);
|
|
99
72
|
if (c !== i.attrs.orphan) {
|
|
100
|
-
let
|
|
101
|
-
|
|
73
|
+
let t = Math.max(r, 0), s = Math.min(r + n.nodeSize, e.doc.content.size - 1, e.doc.content.size - 1);
|
|
74
|
+
e.removeMark(t, s, i), e.addMark(t, s, a.create({
|
|
102
75
|
...i.attrs,
|
|
103
76
|
orphan: c
|
|
104
|
-
})), c &&
|
|
77
|
+
})), c && g.state.selectedThreadId === o && g.setState((e) => ({
|
|
105
78
|
...e,
|
|
106
79
|
selectedThreadId: void 0
|
|
107
80
|
}));
|
|
@@ -113,120 +86,115 @@ var v = t(({ editor: t, options: { schema: r, threadStore: i, resolveUsers: a }
|
|
|
113
86
|
};
|
|
114
87
|
return {
|
|
115
88
|
key: "comments",
|
|
116
|
-
store:
|
|
89
|
+
store: g,
|
|
90
|
+
userStore: l,
|
|
117
91
|
runsBefore: ["link"],
|
|
118
|
-
tiptapExtensions: [
|
|
119
|
-
prosemirrorPlugins: [new
|
|
120
|
-
key:
|
|
92
|
+
tiptapExtensions: [f],
|
|
93
|
+
prosemirrorPlugins: [new c({
|
|
94
|
+
key: p,
|
|
121
95
|
state: {
|
|
122
96
|
init() {
|
|
123
|
-
return { decorations:
|
|
97
|
+
return { decorations: d.empty };
|
|
124
98
|
},
|
|
125
99
|
apply(e, t) {
|
|
126
|
-
let n = e.getMeta(
|
|
100
|
+
let n = e.getMeta(p);
|
|
127
101
|
if (!e.docChanged && !n) return t;
|
|
128
|
-
let r = e.docChanged ?
|
|
129
|
-
(r.size > 0 ||
|
|
102
|
+
let r = e.docChanged ? m(e.doc, h) : g.state.threadPositions;
|
|
103
|
+
(r.size > 0 || g.state.threadPositions.size > 0) && g.setState((e) => ({
|
|
130
104
|
...e,
|
|
131
105
|
threadPositions: r
|
|
132
106
|
}));
|
|
133
107
|
let i = [];
|
|
134
|
-
if (
|
|
135
|
-
let e = r.get(
|
|
136
|
-
e && i.push(
|
|
108
|
+
if (g.state.selectedThreadId) {
|
|
109
|
+
let e = r.get(g.state.selectedThreadId);
|
|
110
|
+
e && i.push(u.inline(e.from, e.to, { class: "bn-thread-mark-selected" }));
|
|
137
111
|
}
|
|
138
|
-
return { decorations:
|
|
112
|
+
return { decorations: d.create(e.doc, i) };
|
|
139
113
|
}
|
|
140
114
|
},
|
|
141
115
|
props: {
|
|
142
116
|
decorations(e) {
|
|
143
|
-
return
|
|
117
|
+
return p.getState(e)?.decorations ?? d.empty;
|
|
144
118
|
},
|
|
145
119
|
handleClick: (e, t, n) => {
|
|
146
120
|
if (n.button !== 0) return !1;
|
|
147
121
|
let r = e.state.doc.nodeAt(t);
|
|
148
|
-
if (!r) return
|
|
122
|
+
if (!r) return g.setState((e) => ({
|
|
149
123
|
...e,
|
|
150
124
|
selectedThreadId: void 0
|
|
151
125
|
})), !1;
|
|
152
|
-
let i = r.marks.find((e) => e.type.name ===
|
|
153
|
-
if (!i) return
|
|
126
|
+
let i = r.marks.find((e) => e.type.name === h && e.attrs.orphan !== !0);
|
|
127
|
+
if (!i) return g.state.selectedThreadId !== void 0 && g.setState((e) => ({
|
|
154
128
|
...e,
|
|
155
129
|
selectedThreadId: void 0
|
|
156
130
|
})), !1;
|
|
157
131
|
let a = i.attrs.threadId;
|
|
158
|
-
return a ===
|
|
132
|
+
return a === g.state.selectedThreadId ? !1 : (g.setState((e) => ({
|
|
159
133
|
...e,
|
|
160
134
|
selectedThreadId: a
|
|
161
135
|
})), !0);
|
|
162
136
|
}
|
|
163
137
|
}
|
|
164
138
|
})],
|
|
165
|
-
threadStore:
|
|
139
|
+
threadStore: a,
|
|
166
140
|
mount() {
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
let n =
|
|
170
|
-
|
|
141
|
+
let t = a.subscribe(_);
|
|
142
|
+
_(a.getThreads());
|
|
143
|
+
let n = e.onSelectionChange(() => {
|
|
144
|
+
g.state.pendingComment && g.setState((e) => ({
|
|
171
145
|
...e,
|
|
172
146
|
pendingComment: !1
|
|
173
147
|
}));
|
|
174
148
|
});
|
|
175
149
|
return () => {
|
|
176
|
-
|
|
150
|
+
t(), n();
|
|
177
151
|
};
|
|
178
152
|
},
|
|
179
|
-
selectThread(
|
|
180
|
-
if (
|
|
181
|
-
...
|
|
153
|
+
selectThread(t, n = !0) {
|
|
154
|
+
if (g.state.selectedThreadId !== t && (g.setState((e) => ({
|
|
155
|
+
...e,
|
|
182
156
|
pendingComment: !1,
|
|
183
|
-
selectedThreadId:
|
|
184
|
-
})),
|
|
185
|
-
let n =
|
|
157
|
+
selectedThreadId: t
|
|
158
|
+
})), t && n)) {
|
|
159
|
+
let n = g.state.threadPositions.get(t);
|
|
186
160
|
if (!n) return;
|
|
187
|
-
(
|
|
161
|
+
(e.prosemirrorView?.domAtPos(n.from).node)?.scrollIntoView({
|
|
188
162
|
behavior: "smooth",
|
|
189
163
|
block: "center"
|
|
190
164
|
});
|
|
191
165
|
}
|
|
192
166
|
},
|
|
193
167
|
startPendingComment() {
|
|
194
|
-
|
|
168
|
+
g.setState((e) => ({
|
|
195
169
|
...e,
|
|
196
170
|
selectedThreadId: void 0,
|
|
197
171
|
pendingComment: !0
|
|
198
|
-
})),
|
|
172
|
+
})), e.domElement?.focus(), e.getExtension(i)?.showSelection(!0, "comments");
|
|
199
173
|
},
|
|
200
174
|
stopPendingComment() {
|
|
201
|
-
|
|
175
|
+
g.setState((e) => ({
|
|
202
176
|
...e,
|
|
203
177
|
selectedThreadId: void 0,
|
|
204
178
|
pendingComment: !1
|
|
205
|
-
})),
|
|
179
|
+
})), e.getExtension(i)?.showSelection(!1, "comments");
|
|
206
180
|
},
|
|
207
|
-
async createThread(
|
|
208
|
-
let n = await
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
},
|
|
215
|
-
yjs: a ? d(a.binding, e.state) : void 0
|
|
216
|
-
};
|
|
217
|
-
await i.addThreadToDocument({
|
|
218
|
-
threadId: n.id,
|
|
219
|
-
selection: o
|
|
220
|
-
});
|
|
221
|
-
} else t._tiptapEditor.commands.setMark(s, {
|
|
181
|
+
async createThread(t) {
|
|
182
|
+
let n = await a.createThread(t);
|
|
183
|
+
a.addThreadToDocument ? await a.addThreadToDocument({
|
|
184
|
+
threadId: n.id,
|
|
185
|
+
selection: e.transact((e) => e.selection),
|
|
186
|
+
editor: e
|
|
187
|
+
}) : e._tiptapEditor.commands.setMark(h, {
|
|
222
188
|
orphan: !1,
|
|
223
189
|
threadId: n.id
|
|
224
190
|
});
|
|
225
191
|
},
|
|
226
|
-
|
|
227
|
-
|
|
192
|
+
commentEditorSchema: n,
|
|
193
|
+
confirmBeforeDiscard: s
|
|
228
194
|
};
|
|
229
|
-
}),
|
|
195
|
+
}), g = class {}, _ = class extends g {
|
|
196
|
+
userId;
|
|
197
|
+
role;
|
|
230
198
|
constructor(e, t) {
|
|
231
199
|
super(), this.userId = e, this.role = t;
|
|
232
200
|
}
|
|
@@ -257,12 +225,9 @@ var v = t(({ editor: t, options: { schema: r, threadStore: i, resolveUsers: a }
|
|
|
257
225
|
canDeleteReaction(e, t) {
|
|
258
226
|
return t ? e.reactions.some((e) => e.emoji === t && e.userIds.includes(this.userId)) : !0;
|
|
259
227
|
}
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.auth = e;
|
|
264
|
-
}
|
|
265
|
-
}, S = class extends x {
|
|
228
|
+
}, v = class extends a {
|
|
229
|
+
userId;
|
|
230
|
+
provider;
|
|
266
231
|
constructor(e, t, n) {
|
|
267
232
|
super(n), this.userId = e, this.provider = t;
|
|
268
233
|
}
|
|
@@ -380,236 +345,6 @@ var v = t(({ editor: t, options: { schema: r, threadStore: i, resolveUsers: a }
|
|
|
380
345
|
}
|
|
381
346
|
};
|
|
382
347
|
//#endregion
|
|
383
|
-
|
|
384
|
-
function C(e) {
|
|
385
|
-
let t = new p.Map();
|
|
386
|
-
if (t.set("id", e.id), t.set("userId", e.userId), t.set("createdAt", e.createdAt.getTime()), t.set("updatedAt", e.updatedAt.getTime()), e.deletedAt ? (t.set("deletedAt", e.deletedAt.getTime()), t.set("body", void 0)) : t.set("body", e.body), e.reactions.length > 0) throw Error("Reactions should be empty in commentToYMap");
|
|
387
|
-
return t.set("reactionsByUser", new p.Map()), t.set("metadata", e.metadata), t;
|
|
388
|
-
}
|
|
389
|
-
function w(e) {
|
|
390
|
-
let t = new p.Map();
|
|
391
|
-
t.set("id", e.id), t.set("createdAt", e.createdAt.getTime()), t.set("updatedAt", e.updatedAt.getTime());
|
|
392
|
-
let n = new p.Array();
|
|
393
|
-
return n.push(e.comments.map((e) => C(e))), t.set("comments", n), t.set("resolved", e.resolved), t.set("resolvedUpdatedAt", e.resolvedUpdatedAt?.getTime()), t.set("resolvedBy", e.resolvedBy), t.set("metadata", e.metadata), t;
|
|
394
|
-
}
|
|
395
|
-
function T(e) {
|
|
396
|
-
return {
|
|
397
|
-
emoji: e.get("emoji"),
|
|
398
|
-
createdAt: new Date(e.get("createdAt")),
|
|
399
|
-
userId: e.get("userId")
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
function E(e) {
|
|
403
|
-
return [...e.values()].map((e) => T(e)).reduce((e, t) => {
|
|
404
|
-
let n = e.find((e) => e.emoji === t.emoji);
|
|
405
|
-
return n ? (n.userIds.push(t.userId), n.createdAt = new Date(Math.min(n.createdAt.getTime(), t.createdAt.getTime()))) : e.push({
|
|
406
|
-
emoji: t.emoji,
|
|
407
|
-
createdAt: t.createdAt,
|
|
408
|
-
userIds: [t.userId]
|
|
409
|
-
}), e;
|
|
410
|
-
}, []);
|
|
411
|
-
}
|
|
412
|
-
function D(e) {
|
|
413
|
-
return {
|
|
414
|
-
type: "comment",
|
|
415
|
-
id: e.get("id"),
|
|
416
|
-
userId: e.get("userId"),
|
|
417
|
-
createdAt: new Date(e.get("createdAt")),
|
|
418
|
-
updatedAt: new Date(e.get("updatedAt")),
|
|
419
|
-
deletedAt: e.get("deletedAt") ? new Date(e.get("deletedAt")) : void 0,
|
|
420
|
-
reactions: E(e.get("reactionsByUser")),
|
|
421
|
-
metadata: e.get("metadata"),
|
|
422
|
-
body: e.get("body")
|
|
423
|
-
};
|
|
424
|
-
}
|
|
425
|
-
function O(e) {
|
|
426
|
-
return {
|
|
427
|
-
type: "thread",
|
|
428
|
-
id: e.get("id"),
|
|
429
|
-
createdAt: new Date(e.get("createdAt")),
|
|
430
|
-
updatedAt: new Date(e.get("updatedAt")),
|
|
431
|
-
comments: (e.get("comments") || []).map((e) => D(e)),
|
|
432
|
-
resolved: e.get("resolved"),
|
|
433
|
-
resolvedUpdatedAt: new Date(e.get("resolvedUpdatedAt")),
|
|
434
|
-
resolvedBy: e.get("resolvedBy"),
|
|
435
|
-
metadata: e.get("metadata")
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/comments/threadstore/yjs/YjsThreadStoreBase.ts
|
|
440
|
-
var k = class extends x {
|
|
441
|
-
constructor(e, t) {
|
|
442
|
-
super(t), this.threadsYMap = e;
|
|
443
|
-
}
|
|
444
|
-
getThread(e) {
|
|
445
|
-
let t = this.threadsYMap.get(e);
|
|
446
|
-
if (!t) throw Error("Thread not found");
|
|
447
|
-
return O(t);
|
|
448
|
-
}
|
|
449
|
-
getThreads() {
|
|
450
|
-
let e = /* @__PURE__ */ new Map();
|
|
451
|
-
return this.threadsYMap.forEach((t, n) => {
|
|
452
|
-
t instanceof p.Map && e.set(n, O(t));
|
|
453
|
-
}), e;
|
|
454
|
-
}
|
|
455
|
-
subscribe(e) {
|
|
456
|
-
let t = () => {
|
|
457
|
-
e(this.getThreads());
|
|
458
|
-
};
|
|
459
|
-
return this.threadsYMap.observeDeep(t), () => {
|
|
460
|
-
this.threadsYMap.unobserveDeep(t);
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
}, A = class extends k {
|
|
464
|
-
constructor(e, t, n, r) {
|
|
465
|
-
super(n, r), this.BASE_URL = e, this.headers = t;
|
|
466
|
-
}
|
|
467
|
-
doRequest = async (e, t, n) => {
|
|
468
|
-
let r = await fetch(`${this.BASE_URL}${e}`, {
|
|
469
|
-
method: t,
|
|
470
|
-
body: JSON.stringify(n),
|
|
471
|
-
headers: {
|
|
472
|
-
"Content-Type": "application/json",
|
|
473
|
-
...this.headers
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
if (!r.ok) throw Error(`Failed to ${t} ${e}: ${r.statusText}`);
|
|
477
|
-
return r.json();
|
|
478
|
-
};
|
|
479
|
-
addThreadToDocument = async (e) => {
|
|
480
|
-
let { threadId: t, ...n } = e;
|
|
481
|
-
return this.doRequest(`/${t}/addToDocument`, "POST", n);
|
|
482
|
-
};
|
|
483
|
-
createThread = async (e) => this.doRequest("", "POST", e);
|
|
484
|
-
addComment = (e) => {
|
|
485
|
-
let { threadId: t, ...n } = e;
|
|
486
|
-
return this.doRequest(`/${t}/comments`, "POST", n);
|
|
487
|
-
};
|
|
488
|
-
updateComment = (e) => {
|
|
489
|
-
let { threadId: t, commentId: n, ...r } = e;
|
|
490
|
-
return this.doRequest(`/${t}/comments/${n}`, "PUT", r);
|
|
491
|
-
};
|
|
492
|
-
deleteComment = (e) => {
|
|
493
|
-
let { threadId: t, commentId: n, ...r } = e;
|
|
494
|
-
return this.doRequest(`/${t}/comments/${n}?soft=${!!r.softDelete}`, "DELETE");
|
|
495
|
-
};
|
|
496
|
-
deleteThread = (e) => this.doRequest(`/${e.threadId}`, "DELETE");
|
|
497
|
-
resolveThread = (e) => this.doRequest(`/${e.threadId}/resolve`, "POST");
|
|
498
|
-
unresolveThread = (e) => this.doRequest(`/${e.threadId}/unresolve`, "POST");
|
|
499
|
-
addReaction = (e) => {
|
|
500
|
-
let { threadId: t, commentId: n, ...r } = e;
|
|
501
|
-
return this.doRequest(`/${t}/comments/${n}/reactions`, "POST", r);
|
|
502
|
-
};
|
|
503
|
-
deleteReaction = (e) => this.doRequest(`/${e.threadId}/comments/${e.commentId}/reactions/${e.emoji}`, "DELETE");
|
|
504
|
-
}, j = class extends k {
|
|
505
|
-
constructor(e, t, n) {
|
|
506
|
-
super(t, n), this.userId = e;
|
|
507
|
-
}
|
|
508
|
-
transact = (e) => async (t) => this.threadsYMap.doc.transact(() => e(t));
|
|
509
|
-
createThread = this.transact((e) => {
|
|
510
|
-
if (!this.auth.canCreateThread()) throw Error("Not authorized");
|
|
511
|
-
let t = /* @__PURE__ */ new Date(), n = {
|
|
512
|
-
type: "comment",
|
|
513
|
-
id: c(),
|
|
514
|
-
userId: this.userId,
|
|
515
|
-
createdAt: t,
|
|
516
|
-
updatedAt: t,
|
|
517
|
-
reactions: [],
|
|
518
|
-
metadata: e.initialComment.metadata,
|
|
519
|
-
body: e.initialComment.body
|
|
520
|
-
}, r = {
|
|
521
|
-
type: "thread",
|
|
522
|
-
id: c(),
|
|
523
|
-
createdAt: t,
|
|
524
|
-
updatedAt: t,
|
|
525
|
-
comments: [n],
|
|
526
|
-
resolved: !1,
|
|
527
|
-
metadata: e.metadata
|
|
528
|
-
};
|
|
529
|
-
return this.threadsYMap.set(r.id, w(r)), r;
|
|
530
|
-
});
|
|
531
|
-
addThreadToDocument = void 0;
|
|
532
|
-
addComment = this.transact((e) => {
|
|
533
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
534
|
-
if (!t) throw Error("Thread not found");
|
|
535
|
-
if (!this.auth.canAddComment(O(t))) throw Error("Not authorized");
|
|
536
|
-
let n = /* @__PURE__ */ new Date(), r = {
|
|
537
|
-
type: "comment",
|
|
538
|
-
id: c(),
|
|
539
|
-
userId: this.userId,
|
|
540
|
-
createdAt: n,
|
|
541
|
-
updatedAt: n,
|
|
542
|
-
deletedAt: void 0,
|
|
543
|
-
reactions: [],
|
|
544
|
-
metadata: e.comment.metadata,
|
|
545
|
-
body: e.comment.body
|
|
546
|
-
};
|
|
547
|
-
return t.get("comments").push([C(r)]), t.set("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r;
|
|
548
|
-
});
|
|
549
|
-
updateComment = this.transact((e) => {
|
|
550
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
551
|
-
if (!t) throw Error("Thread not found");
|
|
552
|
-
let n = M(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
553
|
-
if (n === -1) throw Error("Comment not found");
|
|
554
|
-
let r = t.get("comments").get(n);
|
|
555
|
-
if (!this.auth.canUpdateComment(D(r))) throw Error("Not authorized");
|
|
556
|
-
r.set("body", e.comment.body), r.set("updatedAt", (/* @__PURE__ */ new Date()).getTime()), r.set("metadata", e.comment.metadata);
|
|
557
|
-
});
|
|
558
|
-
deleteComment = this.transact((e) => {
|
|
559
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
560
|
-
if (!t) throw Error("Thread not found");
|
|
561
|
-
let n = M(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
562
|
-
if (n === -1) throw Error("Comment not found");
|
|
563
|
-
let r = t.get("comments").get(n);
|
|
564
|
-
if (!this.auth.canDeleteComment(D(r))) throw Error("Not authorized");
|
|
565
|
-
if (r.get("deletedAt")) throw Error("Comment already deleted");
|
|
566
|
-
e.softDelete ? (r.set("deletedAt", (/* @__PURE__ */ new Date()).getTime()), r.set("body", void 0)) : t.get("comments").delete(n), t.get("comments").toArray().every((e) => e.get("deletedAt")) && (e.softDelete ? t.set("deletedAt", (/* @__PURE__ */ new Date()).getTime()) : this.threadsYMap.delete(e.threadId)), t.set("updatedAt", (/* @__PURE__ */ new Date()).getTime());
|
|
567
|
-
});
|
|
568
|
-
deleteThread = this.transact((e) => {
|
|
569
|
-
if (!this.auth.canDeleteThread(O(this.threadsYMap.get(e.threadId)))) throw Error("Not authorized");
|
|
570
|
-
this.threadsYMap.delete(e.threadId);
|
|
571
|
-
});
|
|
572
|
-
resolveThread = this.transact((e) => {
|
|
573
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
574
|
-
if (!t) throw Error("Thread not found");
|
|
575
|
-
if (!this.auth.canResolveThread(O(t))) throw Error("Not authorized");
|
|
576
|
-
t.set("resolved", !0), t.set("resolvedUpdatedAt", (/* @__PURE__ */ new Date()).getTime()), t.set("resolvedBy", this.userId);
|
|
577
|
-
});
|
|
578
|
-
unresolveThread = this.transact((e) => {
|
|
579
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
580
|
-
if (!t) throw Error("Thread not found");
|
|
581
|
-
if (!this.auth.canUnresolveThread(O(t))) throw Error("Not authorized");
|
|
582
|
-
t.set("resolved", !1), t.set("resolvedUpdatedAt", (/* @__PURE__ */ new Date()).getTime());
|
|
583
|
-
});
|
|
584
|
-
addReaction = this.transact((e) => {
|
|
585
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
586
|
-
if (!t) throw Error("Thread not found");
|
|
587
|
-
let n = M(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
588
|
-
if (n === -1) throw Error("Comment not found");
|
|
589
|
-
let r = t.get("comments").get(n);
|
|
590
|
-
if (!this.auth.canAddReaction(D(r), e.emoji)) throw Error("Not authorized");
|
|
591
|
-
let i = /* @__PURE__ */ new Date(), a = `${this.userId}-${e.emoji}`, o = r.get("reactionsByUser");
|
|
592
|
-
if (!o.has(a)) {
|
|
593
|
-
let t = new p.Map();
|
|
594
|
-
t.set("emoji", e.emoji), t.set("createdAt", i.getTime()), t.set("userId", this.userId), o.set(a, t);
|
|
595
|
-
}
|
|
596
|
-
});
|
|
597
|
-
deleteReaction = this.transact((e) => {
|
|
598
|
-
let t = this.threadsYMap.get(e.threadId);
|
|
599
|
-
if (!t) throw Error("Thread not found");
|
|
600
|
-
let n = M(t.get("comments"), (t) => t.get("id") === e.commentId);
|
|
601
|
-
if (n === -1) throw Error("Comment not found");
|
|
602
|
-
let r = t.get("comments").get(n);
|
|
603
|
-
if (!this.auth.canDeleteReaction(D(r), e.emoji)) throw Error("Not authorized");
|
|
604
|
-
let i = `${this.userId}-${e.emoji}`;
|
|
605
|
-
r.get("reactionsByUser").delete(i);
|
|
606
|
-
});
|
|
607
|
-
};
|
|
608
|
-
function M(e, t) {
|
|
609
|
-
for (let n = 0; n < e.length; n++) if (t(e.get(n))) return n;
|
|
610
|
-
return -1;
|
|
611
|
-
}
|
|
612
|
-
//#endregion
|
|
613
|
-
export { m as CommentMark, v as CommentsExtension, b as DefaultThreadStoreAuth, A as RESTYjsThreadStore, x as ThreadStore, y as ThreadStoreAuth, S as TiptapThreadStore, j as YjsThreadStore, k as YjsThreadStoreBase };
|
|
348
|
+
export { f as CommentMark, h as CommentsExtension, _ as DefaultThreadStoreAuth, a as ThreadStore, g as ThreadStoreAuth, v as TiptapThreadStore };
|
|
614
349
|
|
|
615
350
|
//# sourceMappingURL=comments.js.map
|