@blocknote/core 0.55.0 → 0.56.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-DjEkXkR5.cjs +2 -0
- package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +1 -0
- package/dist/{BlockNoteExtension-CbvDA0F7.js → BlockNoteExtension-TsTGtIeX.js} +34 -27
- package/dist/BlockNoteExtension-TsTGtIeX.js.map +1 -0
- package/dist/{UserStore-mj3fXW4D.cjs → UserStore-CTVzVGh-.cjs} +2 -2
- package/dist/{UserStore-mj3fXW4D.cjs.map → UserStore-CTVzVGh-.cjs.map} +1 -1
- package/dist/{UserStore-C4TzkGEn.js → UserStore-OZJP3K8T.js} +2 -2
- package/dist/{UserStore-C4TzkGEn.js.map → UserStore-OZJP3K8T.js.map} +1 -1
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -6
- package/dist/blocks-COVwe5Cf.cjs +12 -0
- package/dist/blocks-COVwe5Cf.cjs.map +1 -0
- package/dist/{blocks-DaEUT0O1.js → blocks-COYcDVg7.js} +1572 -1156
- package/dist/blocks-COYcDVg7.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.js +12 -12
- package/dist/{en-BAn9gxr-.js → en-Ch-vvt5e.js} +36 -2
- package/dist/en-Ch-vvt5e.js.map +1 -0
- package/dist/en-N5lu0-j8.cjs +2 -0
- package/dist/en-N5lu0-j8.cjs.map +1 -0
- package/dist/extensions-BbM81hHa.js +3069 -0
- package/dist/extensions-BbM81hHa.js.map +1 -0
- package/dist/extensions-D_WkAfSt.cjs +58 -0
- package/dist/extensions-D_WkAfSt.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 +771 -23
- package/dist/locales.js.map +1 -1
- package/dist/src-4OQT3z5S.cjs +23 -0
- package/dist/src-4OQT3z5S.cjs.map +1 -0
- package/dist/{src-D5w0XAHX.js → src-BmLsLZfE.js} +1390 -1278
- package/dist/src-BmLsLZfE.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +1 -1
- package/dist/y.cjs.map +1 -1
- package/dist/y.js +1284 -554
- package/dist/y.js.map +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +189 -148
- package/dist/yjs.js.map +1 -1
- package/package.json +8 -8
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +45 -6
- package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +217 -0
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +113 -9
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +151 -163
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +47 -31
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +122 -181
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +256 -0
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +80 -40
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +71 -0
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +39 -31
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +221 -8
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +40 -8
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +272 -40
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +138 -117
- package/src/api/blockManipulation/getBlock/getBlock.ts +4 -11
- package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +173 -0
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +293 -0
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +145 -0
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +783 -0
- package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +180 -0
- package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +365 -0
- package/src/api/blockManipulation/selections/selection.ts +20 -53
- package/src/api/blockManipulation/selections/textCursorPosition.ts +17 -72
- package/src/api/blockManipulation/setupTestEnv.ts +38 -6
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +4 -4
- package/src/api/clipboard/toClipboard/copyExtension.ts +3 -3
- package/src/api/combineTransactionSteps.ts +22 -0
- package/src/api/exporters/html/externalHTMLExporter.ts +1 -1
- package/src/api/exporters/html/internalHTMLSerializer.ts +4 -4
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +111 -36
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +51 -21
- package/src/api/exporters/markdown/htmlToMarkdown.ts +12 -1
- package/src/api/exporters/markdown/markdownExporter.ts +1 -1
- package/src/api/getBlockInfoFromPos.test.ts +428 -3
- package/src/api/getBlockInfoFromPos.ts +531 -129
- package/src/api/getBlocksChangedByTransaction.test.ts +7 -7
- package/src/api/getBlocksChangedByTransaction.ts +3 -3
- package/src/api/{getChangedRange.ts → getChangedRangeWithAttrs.ts} +2 -2
- package/src/api/getChangedRanges.test.ts +391 -0
- package/src/api/getChangedRanges.ts +368 -0
- package/src/api/nodeConversions/blockToNode.ts +44 -16
- package/src/api/nodeConversions/fragmentToBlocks.ts +29 -44
- package/src/api/nodeConversions/nodeToBlock.ts +120 -68
- package/src/api/nodeUtil.ts +1 -1
- package/src/api/parsers/markdown/autolink.ts +23 -0
- package/src/api/parsers/markdown/markdownToHtml.ts +115 -11
- package/src/blocks/Code/block.test.ts +4 -4
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +6 -1
- package/src/blocks/Heading/block.ts +54 -15
- package/src/blocks/ListItem/BulletListItem/block.ts +6 -4
- package/src/blocks/ListItem/CheckListItem/block.test.ts +2 -2
- package/src/blocks/ListItem/CheckListItem/block.ts +6 -4
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +14 -17
- package/src/blocks/ListItem/NumberedListItem/block.ts +6 -4
- package/src/blocks/ListItem/ToggleListItem/block.ts +23 -12
- package/src/blocks/Table/block.ts +2 -10
- package/src/blocks/ToggleWrapper/createToggleFrame.ts +126 -0
- package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +1056 -0
- package/src/blocks/defaultBlockTypeItems.test.ts +70 -0
- package/src/blocks/defaultBlockTypeItems.ts +99 -0
- package/src/blocks/defaultBlocks.test.ts +67 -0
- package/src/blocks/defaultBlocks.ts +7 -1
- package/src/blocks/index.ts +2 -1
- package/src/editor/Block.css +286 -154
- package/src/editor/BlockNoteEditor.node.test.ts +35 -0
- package/src/editor/BlockNoteEditor.test.ts +2 -2
- package/src/editor/BlockNoteEditor.ts +71 -9
- package/src/editor/BlockNoteExtension.ts +5 -5
- package/src/editor/blockColors.browser.test.ts +127 -0
- package/src/editor/editor.css +60 -0
- package/src/editor/managers/BlockManager.ts +4 -3
- package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +45 -0
- package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +209 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +10 -1
- package/src/editor/managers/ExtensionManager/index.ts +135 -68
- package/src/editor/managers/StateManager.ts +14 -4
- package/src/editor/transformPasted.ts +14 -13
- package/src/exporter/Exporter.test.ts +70 -1
- package/src/exporter/Exporter.ts +34 -4
- package/src/exporter/mapping.ts +41 -10
- package/src/extensions/DropCursor/DropCursor.ts +119 -6
- package/src/extensions/DropCursor/dropIntoChildren.ts +80 -0
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +7 -1
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +190 -0
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +41 -4
- package/src/extensions/Placeholder/Placeholder.test.ts +23 -0
- package/src/extensions/Placeholder/Placeholder.ts +8 -7
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +36 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +8 -4
- package/src/extensions/ReadOnly/ReadOnly.test.ts +181 -0
- package/src/extensions/ReadOnly/ReadOnly.ts +73 -0
- package/src/extensions/SideMenu/SideMenu.ts +401 -764
- package/src/extensions/SideMenu/blockDropHandling.ts +372 -0
- package/src/extensions/SideMenu/blockGeometry.browser.test.ts +148 -0
- package/src/extensions/SideMenu/blockGeometry.test.ts +46 -0
- package/src/extensions/SideMenu/blockGeometry.ts +53 -0
- package/src/extensions/SideMenu/dragging.ts +19 -32
- package/src/extensions/SideMenu/sideMenuHover.test.ts +36 -0
- package/src/extensions/SideMenu/sideMenuHover.ts +270 -0
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +5 -4
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +10 -1
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +36 -136
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +14 -4
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +1 -1
- package/src/extensions/SyntaxHighlighting/shiki.ts +1 -1
- package/src/extensions/TableHandles/TableHandles.ts +4 -6
- package/src/extensions/Versioning/Versioning.browser.test.ts +151 -0
- package/src/extensions/Versioning/Versioning.node.test.ts +177 -0
- package/src/extensions/Versioning/Versioning.ts +145 -612
- package/src/extensions/Versioning/__test__/result.ts +12 -0
- package/src/extensions/Versioning/comparison.test.ts +40 -0
- package/src/extensions/Versioning/createVersioning.test.ts +867 -0
- package/src/extensions/Versioning/createVersioning.ts +499 -0
- package/src/extensions/Versioning/formatVersionDate.ts +24 -0
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +533 -430
- package/src/extensions/Versioning/inMemoryVersioning.ts +246 -251
- package/src/extensions/Versioning/index.ts +4 -0
- package/src/extensions/Versioning/scrollScheduling.test.ts +51 -0
- package/src/extensions/Versioning/scrollToFirstChange.test.ts +320 -0
- package/src/extensions/Versioning/scrollToFirstChange.ts +139 -0
- package/src/extensions/Versioning/types.ts +219 -0
- package/src/extensions/Versioning/versioningState.ts +154 -0
- package/src/extensions/blockDOM.browser.test.ts +102 -0
- package/src/extensions/blockDOM.test.ts +178 -0
- package/src/extensions/blockDOM.ts +135 -0
- package/src/extensions/index.ts +2 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +1719 -53
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +645 -531
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +152 -0
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +4 -9
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +10 -24
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +22 -19
- package/src/fonts/inter.browser.test.ts +57 -0
- package/src/fonts/inter.css +111 -0
- package/src/i18n/locales/ar.ts +32 -0
- package/src/i18n/locales/de.ts +32 -0
- package/src/i18n/locales/en.ts +32 -0
- package/src/i18n/locales/es.ts +32 -0
- package/src/i18n/locales/fa.ts +32 -0
- package/src/i18n/locales/fr.ts +32 -0
- package/src/i18n/locales/he.ts +32 -0
- package/src/i18n/locales/hr.ts +32 -0
- package/src/i18n/locales/is.ts +32 -0
- package/src/i18n/locales/it.ts +32 -0
- package/src/i18n/locales/ja.ts +32 -0
- package/src/i18n/locales/ko.ts +32 -0
- package/src/i18n/locales/nl.ts +32 -0
- package/src/i18n/locales/no.ts +32 -0
- package/src/i18n/locales/pl.ts +32 -0
- package/src/i18n/locales/pt.ts +32 -0
- package/src/i18n/locales/ru.ts +32 -0
- package/src/i18n/locales/sk.ts +32 -0
- package/src/i18n/locales/uk.ts +32 -0
- package/src/i18n/locales/uz.ts +32 -0
- package/src/i18n/locales/vi.ts +32 -0
- package/src/i18n/locales/zh-tw.ts +32 -0
- package/src/i18n/locales/zh.ts +32 -0
- package/src/index.ts +13 -3
- package/src/pm-nodes/BlockContainer.test.ts +101 -0
- package/src/pm-nodes/BlockContainer.ts +110 -1
- package/src/pm-nodes/BlockGroup.ts +2 -1
- package/src/pm-nodes/README.md +2 -0
- package/src/schema/blocks/children.test.ts +288 -0
- package/src/schema/blocks/children.ts +136 -0
- package/src/schema/blocks/createSpec.browser.test.ts +176 -0
- package/src/schema/blocks/createSpec.test.ts +231 -0
- package/src/schema/blocks/createSpec.ts +493 -267
- package/src/schema/blocks/frame.test.ts +112 -0
- package/src/schema/blocks/frame.ts +337 -0
- package/src/schema/blocks/internal.ts +50 -17
- package/src/schema/blocks/keyboard.ts +154 -0
- package/src/schema/blocks/layoutBlockAttributes.ts +29 -0
- package/src/schema/blocks/meta.test.ts +53 -0
- package/src/schema/blocks/meta.ts +35 -0
- package/src/schema/blocks/renderFrame.test.ts +691 -0
- package/src/schema/blocks/types.ts +285 -21
- package/src/schema/blocks/validateChildren.ts +156 -0
- package/src/schema/dataAttributes.test.ts +72 -0
- package/src/schema/dataAttributes.ts +69 -0
- package/src/schema/index.ts +3 -0
- package/src/schema/inlineContent/internal.ts +7 -12
- package/src/schema/markGroups.ts +34 -2
- package/src/schema/schema.ts +8 -1
- package/src/user/userColors.test.ts +108 -0
- package/src/user/userColors.ts +42 -13
- package/src/y/comments/RESTYjsThreadStore.ts +1 -1
- package/src/y/comments/YjsThreadStore.test.ts +1 -1
- package/src/y/comments/YjsThreadStore.ts +27 -27
- package/src/y/comments/YjsThreadStoreBase.ts +2 -2
- package/src/y/comments/yjsHelpers.ts +11 -11
- package/src/y/extensions/AttributionExtension.test.ts +271 -2
- package/src/y/extensions/AttributionExtension.ts +146 -123
- package/src/y/extensions/DiffVersioningExtension.test.ts +67 -18
- package/src/y/extensions/DiffVersioningExtension.ts +95 -123
- package/src/y/extensions/EmptyDocBinding.test.ts +282 -0
- package/src/y/extensions/ForkYDoc.node.test.ts +77 -0
- package/src/y/extensions/ForkYDoc.test.ts +93 -2
- package/src/y/extensions/ForkYDoc.ts +22 -13
- package/src/y/extensions/History.test.ts +125 -0
- package/src/y/extensions/RelativePositionMapping.test.ts +35 -0
- package/src/y/extensions/RelativePositionMapping.ts +7 -11
- package/src/y/extensions/Versioning.node.test.ts +126 -0
- package/src/y/extensions/Versioning.test.ts +110 -401
- package/src/y/extensions/Versioning.ts +66 -107
- package/src/y/extensions/YAttributionMarks.ts +111 -9
- package/src/y/extensions/YCursorPlugin.ts +3 -0
- package/src/y/extensions/YSync.node.test.ts +75 -0
- package/src/y/extensions/YSync.ts +76 -4
- package/src/y/extensions/YSyncRemount.test.ts +99 -0
- package/src/y/extensions/blockMatchNodes.ts +20 -29
- package/src/y/extensions/index.ts +10 -26
- package/src/y/extensions/legacyYjsDocBinding.test.ts +652 -0
- package/src/y/extensions/nestingChanges.test.ts +326 -0
- package/src/y/extensions/persistentBlockGroups.test.ts +1709 -0
- package/src/y/extensions/persistentBlockGroups.ts +953 -0
- package/src/y/extensions/snapshotCodec.test.ts +105 -0
- package/src/y/extensions/snapshotCodec.ts +39 -0
- package/src/y/extensions/snapshotPreview.test.ts +201 -0
- package/src/y/extensions/snapshotPreview.ts +292 -0
- package/src/y/extensions/tableReshape.test.ts +121 -0
- package/src/y/extensions/v1BindingSnapshotDiff.test.ts +121 -0
- package/src/y/extensions/versionDiffAttribution.test.ts +944 -0
- package/src/y/extensions/versionDiffPerformance.test.ts +101 -0
- package/src/y/index.ts +1 -0
- package/src/y/utils.test.ts +289 -22
- package/src/y/utils.ts +167 -43
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +5 -5
- package/src/y/versioning/__test__/fixtures/activity-all.json +3 -3
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +2 -2
- package/src/y/versioning/__test__/yhub.test.ts +902 -721
- package/src/y/versioning/index.ts +6 -1
- package/src/y/versioning/yhub.ts +316 -603
- package/src/y/versioning/yhubClient.ts +345 -0
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +10 -0
- package/src/yjs/extensions/FixUpSchema.ts +11 -0
- package/src/yjs/extensions/ForkYDoc.browser.test.ts +84 -0
- package/src/yjs/extensions/ForkYDoc.node.test.ts +231 -0
- package/src/yjs/extensions/ForkYDoc.test.ts +68 -1
- package/src/yjs/extensions/ForkYDoc.ts +57 -39
- package/src/yjs/extensions/Versioning.test.ts +345 -530
- package/src/yjs/extensions/Versioning.ts +111 -68
- package/src/yjs/extensions/index.ts +1 -1
- package/src/yjs/index.ts +4 -0
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.d.ts +2 -1
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.d.ts +24 -24
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.d.ts +3 -2
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -2
- package/types/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.d.ts +34 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +1 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +460 -0
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +1 -0
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +15 -69
- package/types/src/api/combineTransactionSteps.d.ts +12 -0
- package/types/src/api/getBlockInfoFromPos.d.ts +218 -44
- package/types/src/api/{getChangedRange.d.ts → getChangedRangeWithAttrs.d.ts} +1 -1
- package/types/src/api/getChangedRanges.d.ts +23 -0
- package/types/src/api/getChangedRanges.test.d.ts +1 -0
- package/types/src/api/nodeConversions/fragmentToBlocks.d.ts +0 -3
- package/types/src/api/parsers/markdown/autolink.d.ts +5 -0
- package/types/src/blocks/ToggleWrapper/createToggleFrame.d.ts +29 -0
- package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +1 -0
- package/types/src/blocks/defaultBlockTypeItems.d.ts +37 -0
- package/types/src/blocks/defaultBlockTypeItems.test.d.ts +1 -0
- package/types/src/blocks/defaultBlocks.test.d.ts +1 -0
- package/types/src/blocks/index.d.ts +2 -1
- package/types/src/editor/BlockNoteEditor.d.ts +36 -8
- package/types/src/editor/BlockNoteEditor.node.test.d.ts +1 -0
- package/types/src/editor/blockColors.browser.test.d.ts +1 -0
- package/types/src/editor/managers/BlockManager.d.ts +4 -3
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +1 -0
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +1 -0
- package/types/src/editor/managers/ExtensionManager/index.d.ts +15 -3
- package/types/src/editor/managers/StateManager.d.ts +1 -1
- package/types/src/editor/transformPasted.d.ts +1 -1
- package/types/src/exporter/Exporter.d.ts +11 -4
- package/types/src/exporter/mapping.d.ts +13 -1
- package/types/src/extensions/DropCursor/DropCursor.d.ts +1 -1
- package/types/src/extensions/DropCursor/dropIntoChildren.d.ts +38 -0
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +1 -1
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +1 -0
- package/types/src/extensions/Placeholder/Placeholder.test.d.ts +1 -0
- package/types/src/extensions/ReadOnly/ReadOnly.d.ts +21 -0
- package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/SideMenu.d.ts +49 -88
- package/types/src/extensions/SideMenu/blockDropHandling.d.ts +11 -0
- package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/blockGeometry.d.ts +22 -0
- package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +1 -0
- package/types/src/extensions/SideMenu/dragging.d.ts +0 -4
- package/types/src/extensions/SideMenu/sideMenuHover.d.ts +58 -0
- package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +1 -0
- package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +1 -0
- package/types/src/extensions/Versioning/Versioning.d.ts +34 -311
- package/types/src/extensions/Versioning/Versioning.node.test.d.ts +1 -0
- package/types/src/extensions/Versioning/__test__/result.d.ts +3 -0
- package/types/src/extensions/Versioning/comparison.test.d.ts +1 -0
- package/types/src/extensions/Versioning/createVersioning.d.ts +32 -0
- package/types/src/extensions/Versioning/createVersioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/formatVersionDate.d.ts +7 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +64 -36
- package/types/src/extensions/Versioning/index.d.ts +4 -0
- package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +1 -0
- package/types/src/extensions/Versioning/scrollToFirstChange.d.ts +18 -0
- package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +1 -0
- package/types/src/extensions/Versioning/types.d.ts +239 -0
- package/types/src/extensions/Versioning/versioningState.d.ts +43 -0
- package/types/src/extensions/blockDOM.browser.test.d.ts +1 -0
- package/types/src/extensions/blockDOM.d.ts +37 -0
- package/types/src/extensions/blockDOM.test.d.ts +1 -0
- package/types/src/extensions/index.d.ts +2 -0
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +3 -0
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +1 -0
- package/types/src/fonts/inter.browser.test.d.ts +2 -0
- package/types/src/i18n/locales/en.d.ts +32 -0
- package/types/src/i18n/locales/fa.d.ts +32 -0
- package/types/src/i18n/locales/sk.d.ts +32 -0
- package/types/src/index.d.ts +6 -3
- package/types/src/pm-nodes/BlockContainer.d.ts +6 -0
- package/types/src/pm-nodes/BlockContainer.test.d.ts +1 -0
- package/types/src/schema/blocks/children.d.ts +39 -0
- package/types/src/schema/blocks/children.test.d.ts +1 -0
- package/types/src/schema/blocks/createSpec.browser.test.d.ts +1 -0
- package/types/src/schema/blocks/createSpec.d.ts +13 -0
- package/types/src/schema/blocks/frame.d.ts +109 -0
- package/types/src/schema/blocks/frame.test.d.ts +1 -0
- package/types/src/schema/blocks/internal.d.ts +6 -0
- package/types/src/schema/blocks/keyboard.d.ts +111 -0
- package/types/src/schema/blocks/layoutBlockAttributes.d.ts +9 -0
- package/types/src/schema/blocks/meta.d.ts +14 -0
- package/types/src/schema/blocks/meta.test.d.ts +1 -0
- package/types/src/schema/blocks/renderFrame.test.d.ts +1 -0
- package/types/src/schema/blocks/types.d.ts +228 -15
- package/types/src/schema/blocks/validateChildren.d.ts +5 -0
- package/types/src/schema/dataAttributes.d.ts +19 -0
- package/types/src/schema/dataAttributes.test.d.ts +1 -0
- package/types/src/schema/index.d.ts +3 -0
- package/types/src/schema/markGroups.d.ts +8 -0
- package/types/src/user/userColors.d.ts +24 -3
- package/types/src/user/userColors.test.d.ts +1 -0
- package/types/src/y/comments/RESTYjsThreadStore.d.ts +1 -1
- package/types/src/y/comments/YjsThreadStore.d.ts +1 -1
- package/types/src/y/comments/YjsThreadStoreBase.d.ts +2 -2
- package/types/src/y/comments/yjsHelpers.d.ts +5 -5
- package/types/src/y/extensions/AttributionExtension.d.ts +19 -21
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +9 -4
- package/types/src/y/extensions/EmptyDocBinding.test.d.ts +1 -0
- package/types/src/y/extensions/ForkYDoc.d.ts +3 -1
- package/types/src/y/extensions/ForkYDoc.node.test.d.ts +1 -0
- package/types/src/y/extensions/History.test.d.ts +1 -0
- package/types/src/y/extensions/Versioning.d.ts +4 -15
- package/types/src/y/extensions/Versioning.node.test.d.ts +1 -0
- package/types/src/y/extensions/YAttributionMarks.d.ts +13 -2
- package/types/src/y/extensions/YCursorPlugin.d.ts +1 -0
- package/types/src/y/extensions/YSync.d.ts +4 -18
- package/types/src/y/extensions/YSync.node.test.d.ts +1 -0
- package/types/src/y/extensions/YSyncRemount.test.d.ts +1 -0
- package/types/src/y/extensions/blockMatchNodes.d.ts +0 -22
- package/types/src/y/extensions/index.d.ts +27 -44
- package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +1 -0
- package/types/src/y/extensions/nestingChanges.test.d.ts +1 -0
- package/types/src/y/extensions/persistentBlockGroups.d.ts +189 -0
- package/types/src/y/extensions/persistentBlockGroups.test.d.ts +1 -0
- package/types/src/y/extensions/snapshotCodec.d.ts +13 -0
- package/types/src/y/extensions/snapshotCodec.test.d.ts +1 -0
- package/types/src/y/extensions/snapshotPreview.d.ts +21 -0
- package/types/src/y/extensions/snapshotPreview.test.d.ts +1 -0
- package/types/src/y/extensions/tableReshape.test.d.ts +1 -0
- package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +1 -0
- package/types/src/y/extensions/versionDiffAttribution.test.d.ts +1 -0
- package/types/src/y/extensions/versionDiffPerformance.test.d.ts +1 -0
- package/types/src/y/index.d.ts +1 -0
- package/types/src/y/utils.d.ts +39 -19
- package/types/src/y/versioning/index.d.ts +1 -1
- package/types/src/y/versioning/yhub.d.ts +69 -86
- package/types/src/y/versioning/yhubClient.d.ts +67 -0
- package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +2 -0
- package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +1 -0
- package/types/src/yjs/extensions/Versioning.d.ts +36 -22
- package/types/src/yjs/extensions/index.d.ts +2 -1
- package/types/src/yjs/index.d.ts +1 -0
- package/dist/BlockNoteExtension-BJCLnwrE.cjs +0 -2
- package/dist/BlockNoteExtension-BJCLnwrE.cjs.map +0 -1
- package/dist/BlockNoteExtension-CbvDA0F7.js.map +0 -1
- package/dist/blocks-DLgTreVu.cjs +0 -12
- package/dist/blocks-DLgTreVu.cjs.map +0 -1
- package/dist/blocks-DaEUT0O1.js.map +0 -1
- package/dist/en-BAn9gxr-.js.map +0 -1
- package/dist/en-CHnrV5l8.cjs +0 -2
- package/dist/en-CHnrV5l8.cjs.map +0 -1
- package/dist/extensions-B1JQURVF.js +0 -2138
- package/dist/extensions-B1JQURVF.js.map +0 -1
- package/dist/extensions-CZkqKzJO.cjs +0 -58
- package/dist/extensions-CZkqKzJO.cjs.map +0 -1
- package/dist/src-D5w0XAHX.js.map +0 -1
- package/dist/src-th5uZEvx.cjs +0 -23
- package/dist/src-th5uZEvx.cjs.map +0 -1
- package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +0 -173
- package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +0 -63
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +0 -197
- package/src/blocks/utils/listItemEnterHandler.ts +0 -43
- package/src/extensions/Versioning/Versioning.test.ts +0 -435
- package/src/extensions/getDraggableBlockFromElement.ts +0 -19
- package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +0 -32
- package/types/src/blocks/ListItem/ListItemKeyboardShortcuts.d.ts +0 -2
- package/types/src/blocks/ToggleWrapper/createToggleWrapper.d.ts +0 -15
- package/types/src/blocks/utils/listItemEnterHandler.d.ts +0 -2
- package/types/src/extensions/getDraggableBlockFromElement.d.ts +0 -5
- /package/types/src/{extensions/Versioning/Versioning.test.d.ts → api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts} +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import * as delta from "lib0/delta";
|
|
2
|
+
import * as dt from "lib0/delta/transformer";
|
|
3
|
+
import type * as s from "lib0/schema";
|
|
4
|
+
/**
|
|
5
|
+
* # Persistent block groups
|
|
6
|
+
*
|
|
7
|
+
* A `@y/prosemirror` transformer (the `transformers` option of `syncPlugin`)
|
|
8
|
+
* that keeps BlockNote's nested `blockGroup` nodes alive in the Yjs document
|
|
9
|
+
* and hides the empty ones from ProseMirror.
|
|
10
|
+
*
|
|
11
|
+
* ## The problem
|
|
12
|
+
*
|
|
13
|
+
* BlockNote nests child blocks as `blockContainer > [blockContent, blockGroup?]`
|
|
14
|
+
* and its ProseMirror schema forbids an empty `blockGroup`
|
|
15
|
+
* (`content: "blockGroupChild+"`). So the editor creates the group together
|
|
16
|
+
* with the first nested block and removes it with the last one. Under
|
|
17
|
+
* concurrency that is a conflict generator: two users who nest a first child
|
|
18
|
+
* under the same block at the same time each insert their own `blockGroup`,
|
|
19
|
+
* and after the merge the container holds two groups, which the schema
|
|
20
|
+
* rejects. BlockNote worked around it by replacing the whole container
|
|
21
|
+
* whenever a group appeared or disappeared (the nesting check that used to be
|
|
22
|
+
* in `blockMatchNodes`), which turns the same race into two copies of the
|
|
23
|
+
* parent block and rewrites the parent on every first nesting and last
|
|
24
|
+
* un-nesting.
|
|
25
|
+
*
|
|
26
|
+
* ## The model
|
|
27
|
+
*
|
|
28
|
+
* What Yjs stores is decoupled from what ProseMirror shows:
|
|
29
|
+
*
|
|
30
|
+
* - **Yjs (side A)** keeps every `blockGroup` once it exists. Emptying one
|
|
31
|
+
* leaves it in place, and (with `implicitGroups`, the default) a container
|
|
32
|
+
* the editor creates gets an empty group right away. Two users nesting a
|
|
33
|
+
* first child concurrently therefore write into the *same* group item, and
|
|
34
|
+
* Yjs merges their children like any other concurrent list insert.
|
|
35
|
+
* - **ProseMirror (side B)** sees one `blockGroup` per container, present only
|
|
36
|
+
* while it has children.
|
|
37
|
+
*
|
|
38
|
+
* Yjs ProseMirror
|
|
39
|
+
* blockContainer[ content, group[] ] ⇄ blockContainer[ content ]
|
|
40
|
+
* blockContainer[ content, group[a] ] ⇄ blockContainer[ content, group[a] ]
|
|
41
|
+
* blockContainer[ content, g1[a], g2[b] ] ⇄ blockContainer[ content, group[a, b] ]
|
|
42
|
+
* blockContainer[ content ] ⇄ blockContainer[ content ] (legacy)
|
|
43
|
+
*
|
|
44
|
+
* The third row is what a document written before this transformer (no
|
|
45
|
+
* groups until the first nesting) produces when two users nest a first child
|
|
46
|
+
* concurrently: the view merges every group of a container into one, so the
|
|
47
|
+
* race degrades to an ordering question instead of invalid content. Edits
|
|
48
|
+
* inside the merged group route back to the Yjs group that holds that
|
|
49
|
+
* position. A legacy container never gets a group implicitly (that would be a
|
|
50
|
+
* concurrent write by every client that opens the document); its first nesting
|
|
51
|
+
* creates the group, as before.
|
|
52
|
+
*
|
|
53
|
+
* ## Rules, per `blockContainer`
|
|
54
|
+
*
|
|
55
|
+
* Yjs → view (`applyA`):
|
|
56
|
+
* - every `blockGroup` child collapses into one view group placed after all
|
|
57
|
+
* other children; it exists iff the groups hold at least one child in total
|
|
58
|
+
* - a change that makes the total go 0 → n inserts the view group, n → 0
|
|
59
|
+
* deletes it, n → m modifies it with the inner change re-based onto merged
|
|
60
|
+
* coordinates (a group's children start at the sum of the lengths of the
|
|
61
|
+
* groups before it)
|
|
62
|
+
* - the group wrapper's own attributes, formats and attribution have no view
|
|
63
|
+
* counterpart and are dropped; a group inserted by a suggestion renders its
|
|
64
|
+
* *children* as inserted, which is what the user sees anyway
|
|
65
|
+
*
|
|
66
|
+
* view → Yjs (`applyB`):
|
|
67
|
+
* - an edit at a merged offset routes into the group covering it; at a
|
|
68
|
+
* boundary between two groups the earlier group wins
|
|
69
|
+
* - deleting the view group empties every Yjs group and keeps them all
|
|
70
|
+
* - inserting a view group (only possible while no view group exists) routes
|
|
71
|
+
* its children into the first Yjs group, or, when the container has no
|
|
72
|
+
* group at all (a legacy container), inserts the group as the editor built
|
|
73
|
+
* it
|
|
74
|
+
* - a container the view inserts without a group gets an empty group appended
|
|
75
|
+
* (`implicitGroups`)
|
|
76
|
+
*
|
|
77
|
+
* Cursor positions (root marks) map through the same layout, in both
|
|
78
|
+
* directions.
|
|
79
|
+
*
|
|
80
|
+
* ## Shape of the implementation
|
|
81
|
+
*
|
|
82
|
+
* {@link persistentBlockGroups} composes lib0's `children` template
|
|
83
|
+
* recursively over the node types that can hold containers (`blockGroup`,
|
|
84
|
+
* `column`, `columnList`) and pipes the stateful per-container stage
|
|
85
|
+
* ({@link PersistentGroupTransformer}) after the recursion, so that stage sees
|
|
86
|
+
* its container's children in Yjs layout on the way in and in view layout on
|
|
87
|
+
* the way back. Every other node type (block content, inline content) opts
|
|
88
|
+
* out of the recursion and costs nothing.
|
|
89
|
+
*
|
|
90
|
+
* The per-container state is the container's Yjs child layout: a list of
|
|
91
|
+
* {@link Seg}s, one per child, telling groups (with their child count) apart
|
|
92
|
+
* from everything else. It is kept current from the changes that flow through,
|
|
93
|
+
* so no stage ever re-reads a document; a change costs O(size of the change)
|
|
94
|
+
* plus O(children of the containers on its path), and a container has two or
|
|
95
|
+
* three children.
|
|
96
|
+
*
|
|
97
|
+
* ## Assumptions
|
|
98
|
+
*
|
|
99
|
+
* - `blockContainer` children are a content node followed by zero or more
|
|
100
|
+
* `blockGroup`s (BlockNote never produces anything else). The code tolerates
|
|
101
|
+
* other layouts, but the view then shows non-group children in Yjs order
|
|
102
|
+
* followed by the merged group, which may differ from the Yjs order.
|
|
103
|
+
* - the view inserts at most one `blockGroup` per container (its schema
|
|
104
|
+
* guarantees that).
|
|
105
|
+
*/
|
|
106
|
+
/**
|
|
107
|
+
* Options of {@link persistentBlockGroups}.
|
|
108
|
+
*/
|
|
109
|
+
export type PersistentBlockGroupsOptions = {
|
|
110
|
+
/** The nested list node that is kept and hidden. Default `"blockGroup"`. */
|
|
111
|
+
groupName?: string;
|
|
112
|
+
/** The block node whose children the group lives in. Default `"blockContainer"`. */
|
|
113
|
+
containerName?: string;
|
|
114
|
+
/**
|
|
115
|
+
* The node types (besides the container) that can hold containers, so the
|
|
116
|
+
* recursion descends into them. Default `["blockGroup", "column", "columnList"]`.
|
|
117
|
+
*/
|
|
118
|
+
nestingNodes?: readonly string[];
|
|
119
|
+
/**
|
|
120
|
+
* Whether a container the view creates gets an empty group right away
|
|
121
|
+
* (default `true`). With `false`, groups are only kept once the first
|
|
122
|
+
* nesting creates them; concurrent first nestings then leave two groups in
|
|
123
|
+
* Yjs, which the view merges.
|
|
124
|
+
*/
|
|
125
|
+
implicitGroups?: boolean;
|
|
126
|
+
};
|
|
127
|
+
type AnyDelta = delta.DeltaAny;
|
|
128
|
+
type AnyBuilder = delta.DeltaBuilderAny;
|
|
129
|
+
/**
|
|
130
|
+
* One child of a container in Yjs layout: a group with its child count, or
|
|
131
|
+
* anything else.
|
|
132
|
+
*/
|
|
133
|
+
type Seg = {
|
|
134
|
+
readonly group: false;
|
|
135
|
+
} | {
|
|
136
|
+
readonly group: true;
|
|
137
|
+
readonly len: number;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The stateful per-container stage. Side A is the container's children in
|
|
141
|
+
* Yjs layout, side B in view layout (see the module doc for the rules).
|
|
142
|
+
*/
|
|
143
|
+
export declare class PersistentGroupTransformer extends dt.Transformer<any, any> {
|
|
144
|
+
readonly groupName: string;
|
|
145
|
+
readonly implicitGroups: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* The container's Yjs child layout, kept current from the changes that
|
|
148
|
+
* flow through (both directions).
|
|
149
|
+
*/
|
|
150
|
+
segs: Seg[];
|
|
151
|
+
/**
|
|
152
|
+
* Whether no change has been seen yet. The first change a stage receives
|
|
153
|
+
* is the whole container node (lib0's `children` feeds a freshly inserted
|
|
154
|
+
* child through a fresh stage); when that node comes from the view, the
|
|
155
|
+
* container is new and gets its implicit group.
|
|
156
|
+
*/
|
|
157
|
+
fresh: boolean;
|
|
158
|
+
constructor($in: s.Schema<AnyDelta>, $out: s.Schema<AnyDelta>, groupName: string, implicitGroups: boolean);
|
|
159
|
+
/** Yjs layout change → view layout change. */
|
|
160
|
+
applyA(da: AnyBuilder): dt.TransformResultAny;
|
|
161
|
+
/** View layout change → Yjs layout change. */
|
|
162
|
+
applyB(db: AnyBuilder): dt.TransformResultAny;
|
|
163
|
+
}
|
|
164
|
+
/** Template of the per-container stage. */
|
|
165
|
+
export declare class PersistentGroup extends dt.Template<any, any> {
|
|
166
|
+
readonly groupName: string;
|
|
167
|
+
readonly implicitGroups: boolean;
|
|
168
|
+
constructor($d: s.Schema<AnyDelta>, groupName: string, implicitGroups: boolean);
|
|
169
|
+
get name(): string;
|
|
170
|
+
init(): dt.Transformer<any, any>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* The transformer: hide empty `blockGroup`s from the view, keep them in Yjs,
|
|
174
|
+
* create them with every new container, and merge concurrently created ones
|
|
175
|
+
* (module doc above). Slot it into the sync plugin:
|
|
176
|
+
*
|
|
177
|
+
* ```ts
|
|
178
|
+
* syncPlugin({ transformers: [persistentBlockGroups], customCompare: blockMatchNodes })
|
|
179
|
+
* ```
|
|
180
|
+
*
|
|
181
|
+
* and into the standalone conversions with
|
|
182
|
+
* `defaultTransformer({ mapAttributionToMark, transformers: [persistentBlockGroups] })`.
|
|
183
|
+
*
|
|
184
|
+
* The returned template is the recursion over the document (lib0's
|
|
185
|
+
* `children`): containers get the per-container stage, the `nestingNodes`
|
|
186
|
+
* descend, every other node opts out.
|
|
187
|
+
*/
|
|
188
|
+
export declare function persistentBlockGroups<IN extends delta.DeltaConf>($d: s.Schema<delta.Delta<IN>>, options?: PersistentBlockGroupsOptions): dt.Template<IN, any>;
|
|
189
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Y from "@y/y";
|
|
2
|
+
/** Serialize the live fragment as a V2 update. */
|
|
3
|
+
export declare function serializeFragment(fragment: Y.Node): Uint8Array;
|
|
4
|
+
export type DecodedFragment = {
|
|
5
|
+
doc: Y.Doc;
|
|
6
|
+
fragment: Y.Node;
|
|
7
|
+
};
|
|
8
|
+
/** Materialize a stored update into a throwaway doc and resolve `fragment` inside it. */
|
|
9
|
+
export declare function decodeFragmentUpdate(fragment: Y.Node, content: Uint8Array, opts?: {
|
|
10
|
+
suggestionDoc?: boolean;
|
|
11
|
+
}): DecodedFragment;
|
|
12
|
+
/** Release a decoded throwaway doc. */
|
|
13
|
+
export declare function destroyDecodedFragment(decoded: DecodedFragment | undefined): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as Y from "@y/y";
|
|
2
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
3
|
+
/**
|
|
4
|
+
* Throws when something syncs `doc` (a provider or a persistence layer listens
|
|
5
|
+
* to its updates). A decoded snapshot is written to (see
|
|
6
|
+
* {@link splitChangedBlocks}), and that write must never reach a stored
|
|
7
|
+
* document.
|
|
8
|
+
*/
|
|
9
|
+
export declare function assertUnsyncedDoc(doc: Y.Doc): void;
|
|
10
|
+
/**
|
|
11
|
+
* Decode a snapshot, diff it against a baseline if given, and render it.
|
|
12
|
+
*
|
|
13
|
+
* Snapshots are decoded into throwaway documents, so pointing the binding at
|
|
14
|
+
* one is already an isolated state: the live fragment stops receiving view
|
|
15
|
+
* updates, and nothing typed into the preview reaches the live document.
|
|
16
|
+
* {@link configureYProsemirror} rebuilds the binding against the decoded
|
|
17
|
+
* fragment through the same `customCompare`/attribution pipeline the live
|
|
18
|
+
* binding uses; passing the `renderer` keeps the attribution tooltips
|
|
19
|
+
* ("who/when") working.
|
|
20
|
+
*/
|
|
21
|
+
export declare function showSnapshotPreview(editor: BlockNoteEditor<any, any, any>, fragment: Y.Node, snapshotContent: Uint8Array, compareToContent?: Uint8Array, attributions?: Y.ContentMap): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/src/y/index.d.ts
CHANGED
package/types/src/y/utils.d.ts
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
|
+
import { defaultTransformer, ynodeToPmnode } from "@y/prosemirror";
|
|
1
2
|
import * as d from "lib0/delta";
|
|
2
3
|
import { Node } from "prosemirror-model";
|
|
3
|
-
import { Transaction } from "prosemirror-state";
|
|
4
|
+
import type { Transaction } from "prosemirror-state";
|
|
4
5
|
import { type Block, type BlockNoteEditor, type BlockSchema, type InlineContentSchema, type PartialBlock, type StyleSchema } from "../index.js";
|
|
5
6
|
import * as Y from "@y/y";
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* The Y ⇄ ProseMirror pipeline of the collaboration binding (see
|
|
9
|
+
* `YSyncExtension`): attributions become `y-attributed-*` marks and nested
|
|
10
|
+
* `blockGroup`s are persistent (kept in Y, hidden while empty, merged in the
|
|
11
|
+
* view). Every conversion outside a bound editor goes through the same
|
|
12
|
+
* pipeline, so a document imported with `blocksToYDoc` gets its groups and one
|
|
13
|
+
* read with `yDocToBlocks` hides the empty ones.
|
|
14
|
+
*/
|
|
15
|
+
export declare const blockNoteTransformer: ReturnType<typeof defaultTransformer>;
|
|
16
|
+
/**
|
|
17
|
+
* Find the equivalent of a Y.Node in another Y.Doc.
|
|
8
18
|
*
|
|
9
19
|
* For root types this looks up the matching shared key; for sub-types it
|
|
10
20
|
* locates the item by its client/clock ID in the target doc's store.
|
|
11
21
|
*/
|
|
12
|
-
export declare function findTypeInOtherYdoc<T extends Y.
|
|
22
|
+
export declare function findTypeInOtherYdoc<T extends Y.Node<any>>(ytype: T, otherYdoc: Y.Doc): T;
|
|
23
|
+
/**
|
|
24
|
+
* Collect all stored Yjs ID ranges belonging to a fragment, including deleted
|
|
25
|
+
* descendants. Items belonging to other shared types are excluded.
|
|
26
|
+
*
|
|
27
|
+
* Resolves the fragment in the supplied document and scans its stored items:
|
|
28
|
+
* walking visible content would miss deleted subtrees. To include all deleted
|
|
29
|
+
* descendants, the document or update must retain them; content already
|
|
30
|
+
* garbage-collected cannot be recovered here.
|
|
31
|
+
*
|
|
32
|
+
* Updates are loaded into a temporary document with `gc: false`, which is
|
|
33
|
+
* destroyed after collection. Caller-provided documents are never destroyed.
|
|
34
|
+
*/
|
|
35
|
+
export declare function collectFragmentIds(fragment: Y.Node, docOrUpdate: Uint8Array | Y.Doc): Y.IdSet;
|
|
13
36
|
/**
|
|
14
37
|
* Turn Prosemirror JSON to BlockNote style JSON
|
|
15
38
|
* @param editor BlockNote editor
|
|
@@ -24,16 +47,15 @@ export declare function _prosemirrorJSONToBlocks<BSchema extends BlockSchema, IS
|
|
|
24
47
|
* @returns Prosemirror root node
|
|
25
48
|
*/
|
|
26
49
|
export declare function _blocksToProsemirrorNode<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: PartialBlock<BSchema, ISchema, SSchema>[]): Node;
|
|
27
|
-
/** YJS / BLOCKNOTE conversions */
|
|
28
50
|
/**
|
|
29
|
-
* Turn a Y.
|
|
51
|
+
* Turn a Y.Node collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
|
|
30
52
|
* @param editor BlockNote editor
|
|
31
|
-
* @param fragment Y.
|
|
53
|
+
* @param fragment Y.Node
|
|
32
54
|
* @returns BlockNote document (BlockNote style JSON of all blocks)
|
|
33
55
|
*/
|
|
34
|
-
export declare function yfragmentToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, fragment: Y.
|
|
56
|
+
export declare function yfragmentToBlocks<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, fragment: Y.Node): Block<BSchema, ISchema, SSchema>[];
|
|
35
57
|
/**
|
|
36
|
-
* Convert blocks to a Y.
|
|
58
|
+
* Convert blocks to a Y.Node
|
|
37
59
|
*
|
|
38
60
|
* This can be used when importing existing content to Y.Doc for the first time,
|
|
39
61
|
* note that this should not be used to rehydrate a Y.Doc from a database once
|
|
@@ -42,9 +64,9 @@ export declare function yfragmentToBlocks<BSchema extends BlockSchema, ISchema e
|
|
|
42
64
|
* @param editor BlockNote editor
|
|
43
65
|
* @param blocks the blocks to convert
|
|
44
66
|
* @param fragment XML fragment name
|
|
45
|
-
* @returns Y.
|
|
67
|
+
* @returns Y.Node
|
|
46
68
|
*/
|
|
47
|
-
export declare function blocksToYType<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: Block<BSchema, ISchema, SSchema>[], fragment?: Y.
|
|
69
|
+
export declare function blocksToYType<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema>(editor: BlockNoteEditor<BSchema, ISchema, SSchema>, blocks: Block<BSchema, ISchema, SSchema>[], fragment?: Y.Node): Y.Node<any>;
|
|
48
70
|
/**
|
|
49
71
|
* Turn a Y.Doc collaborative doc into a BlockNote document (BlockNote style JSON of all blocks)
|
|
50
72
|
* @param editor BlockNote editor
|
|
@@ -70,13 +92,11 @@ export declare function blocksToYDoc<BSchema extends BlockSchema, ISchema extend
|
|
|
70
92
|
*/
|
|
71
93
|
export declare function docDiffToDelta(previousDoc: Node, newDoc: Node): d.Delta<d.DeltaConf>;
|
|
72
94
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
95
|
+
* Append steps that render a Y node into the transaction's current document.
|
|
96
|
+
* Supports both plain and already-attributed documents, replacing old preview
|
|
97
|
+
* marks with the renderer's attributions using BlockNote's node-pairing policy.
|
|
98
|
+
* Defaults to the binding's pipeline ({@link blockNoteTransformer}). Does not
|
|
99
|
+
* dispatch or write to the Y node; the caller controls sync configuration and
|
|
100
|
+
* dispatch.
|
|
77
101
|
*/
|
|
78
|
-
export declare function
|
|
79
|
-
tr: Transaction;
|
|
80
|
-
fragment: Y.Type;
|
|
81
|
-
renderer?: Y.AbstractRenderer | null;
|
|
82
|
-
}): Transaction;
|
|
102
|
+
export declare function yNodeToTransaction(tr: Transaction, node: Y.Node, options?: NonNullable<Parameters<typeof ynodeToPmnode>[2]>): Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { createYHubVersionStorage, YVersioningExtension, YHubVersioningExtension, type YHubVersionStorageOptions, } from "./yhub.js";
|
|
@@ -1,88 +1,71 @@
|
|
|
1
1
|
import * as Y from "@y/y";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Base URL of the YHub API, including the API prefix
|
|
9
|
-
* (e.g. `"https://yhub.example.com/api"`).
|
|
10
|
-
* Must **not** include a trailing slash.
|
|
11
|
-
*/
|
|
12
|
-
baseUrl: string;
|
|
13
|
-
/** YHub organisation identifier. */
|
|
14
|
-
org: string;
|
|
15
|
-
/** Document identifier within the organisation. */
|
|
16
|
-
docId: string;
|
|
17
|
-
/**
|
|
18
|
-
* Optional headers to include in every request (e.g. authentication tokens).
|
|
19
|
-
*/
|
|
20
|
-
headers?: Record<string, string>;
|
|
21
|
-
/**
|
|
22
|
-
* Maximum number of activity entries to fetch when listing versions.
|
|
23
|
-
* @default 50
|
|
24
|
-
*/
|
|
25
|
-
activityLimit?: number;
|
|
26
|
-
/**
|
|
27
|
-
* When set, forwarded as the `group` query param to the YHub activity API,
|
|
28
|
-
* controlling whether adjacent edits are grouped into single entries.
|
|
29
|
-
*/
|
|
30
|
-
group?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Maximum gap (in ms) between edits for them to be grouped together.
|
|
33
|
-
* Forwarded as the `groupMaxGap` query param.
|
|
34
|
-
* @default 10000
|
|
35
|
-
*/
|
|
36
|
-
groupMaxGap?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Maximum total duration (in ms) a single group of edits may span.
|
|
39
|
-
* When set, forwarded as the `groupMaxDuration` query param.
|
|
40
|
-
*/
|
|
41
|
-
groupMaxDuration?: number;
|
|
42
|
-
/**
|
|
43
|
-
* When `true`, adjacent edits are grouped together even when made by
|
|
44
|
-
* *different* users (their ids accumulate in the grouped entry's `by`).
|
|
45
|
-
* When `false` (the default), only same-user adjacent edits are merged.
|
|
46
|
-
* Forwarded as the `mergeUsers` query param.
|
|
47
|
-
* @default false
|
|
48
|
-
*/
|
|
49
|
-
mergeUsers?: boolean;
|
|
2
|
+
import type { VersionStorage } from "../../extensions/Versioning/types.js";
|
|
3
|
+
import { type YHubClientOptions, type YHubQueryParams } from "./yhubClient.js";
|
|
4
|
+
export interface YHubVersionStorageOptions extends YHubClientOptions {
|
|
5
|
+
/** Activity grouping and filters. `limit` is the page size, defaulting to 50. History is newest first. */
|
|
6
|
+
activityParams?: YHubQueryParams;
|
|
50
7
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
8
|
+
type YHubStorage = VersionStorage<Uint8Array, Y.ContentMap> & Required<Pick<VersionStorage<Uint8Array, Y.ContentMap>, "getAttributions" | "create" | "restore" | "rename" | "remove">>;
|
|
9
|
+
/** Configure Y14 history independently of collaboration installation. */
|
|
10
|
+
export declare function YVersioningExtension(options: {
|
|
11
|
+
storage: VersionStorage<Uint8Array, Y.ContentMap>;
|
|
12
|
+
scrollToFirstChange?: boolean;
|
|
13
|
+
}): import("../../index.js").ExtensionFactoryInstance<{
|
|
14
|
+
store: import("../../index.js").Store<import("../../extensions/index.js").VersioningState>;
|
|
15
|
+
open: () => boolean;
|
|
16
|
+
close: () => void;
|
|
17
|
+
list: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
18
|
+
loadMore: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
19
|
+
select: (target: import("../../extensions/index.js").VersionSelection, selectionOptions?: {
|
|
20
|
+
compareTo?: string;
|
|
21
|
+
} | undefined) => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
22
|
+
restore: (id: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
23
|
+
rename: (id: string, name?: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
24
|
+
readonly canCompare: boolean;
|
|
25
|
+
readonly historyIncludesBeginning: boolean;
|
|
26
|
+
readonly canCreate: boolean;
|
|
27
|
+
readonly canRename: boolean;
|
|
28
|
+
readonly canRestore: boolean;
|
|
29
|
+
readonly canRemove: boolean;
|
|
30
|
+
create(this: void, name?: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
31
|
+
remove(this: void, id: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
32
|
+
dispose(): void;
|
|
33
|
+
} & {
|
|
34
|
+
readonly key: "versioning";
|
|
35
|
+
readonly userStore: import("../../index.js").UserStore<import("../../index.js").User>;
|
|
36
|
+
readonly mount: () => () => void;
|
|
37
|
+
}>;
|
|
38
|
+
/** Install YHub history for the editor's live collaboration document. */
|
|
39
|
+
export declare function YHubVersioningExtension(options: YHubVersionStorageOptions & {
|
|
40
|
+
scrollToFirstChange?: boolean;
|
|
41
|
+
}): import("../../index.js").ExtensionFactoryInstance<{
|
|
42
|
+
store: import("../../index.js").Store<import("../../extensions/index.js").VersioningState>;
|
|
43
|
+
open: () => boolean;
|
|
44
|
+
close: () => void;
|
|
45
|
+
list: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
46
|
+
loadMore: () => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
47
|
+
select: (target: import("../../extensions/index.js").VersionSelection, selectionOptions?: {
|
|
48
|
+
compareTo?: string;
|
|
49
|
+
} | undefined) => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
50
|
+
restore: (id: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
51
|
+
rename: (id: string, name?: string) => Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
52
|
+
readonly canCompare: boolean;
|
|
53
|
+
readonly historyIncludesBeginning: boolean;
|
|
54
|
+
readonly canCreate: boolean;
|
|
55
|
+
readonly canRename: boolean;
|
|
56
|
+
readonly canRestore: boolean;
|
|
57
|
+
readonly canRemove: boolean;
|
|
58
|
+
create(this: void, name?: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
59
|
+
remove(this: void, id: string): Promise<import("../../extensions/index.js").VersionOperationResult>;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
} & {
|
|
62
|
+
readonly key: "versioning";
|
|
63
|
+
readonly userStore: import("../../index.js").UserStore<import("../../index.js").User>;
|
|
64
|
+
readonly mount: () => () => void;
|
|
65
|
+
}>;
|
|
66
|
+
/** Continuous history for a live fragment, with no editor dependency. */
|
|
67
|
+
export declare function createYHubVersionStorage(options: YHubVersionStorageOptions & {
|
|
68
|
+
fragment: Y.Node;
|
|
69
|
+
beforeRestoreName: string;
|
|
70
|
+
}): YHubStorage;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { VersionResult } from "../../extensions/Versioning/types.js";
|
|
2
|
+
export interface YHubClientOptions {
|
|
3
|
+
/** API base URL, including the API prefix, without a trailing slash. */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Organisation identifier. */
|
|
6
|
+
org: string;
|
|
7
|
+
/** Document identifier within the organisation. */
|
|
8
|
+
docId: string;
|
|
9
|
+
/** Headers included in every request, e.g. authentication tokens. */
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
/** Authentication query parameters included in every request. The open YHub demo uses `userid`. */
|
|
12
|
+
queryParams?: YHubQueryParams;
|
|
13
|
+
/** Bounds each request, including reading the response body. Defaults to 30 seconds. */
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface YHubVersion<Metadata = unknown> {
|
|
17
|
+
type: "version:v1";
|
|
18
|
+
t: number;
|
|
19
|
+
name: string;
|
|
20
|
+
custom: Metadata | null | undefined;
|
|
21
|
+
updatedAt: number;
|
|
22
|
+
}
|
|
23
|
+
/** Activity with wire-format authors and attribution pairs normalized. */
|
|
24
|
+
export interface YHubActivityEntry<Metadata = unknown> {
|
|
25
|
+
from: number;
|
|
26
|
+
to: number;
|
|
27
|
+
by: string[];
|
|
28
|
+
customAttributions: Record<string, string>;
|
|
29
|
+
version?: YHubVersion<Metadata>;
|
|
30
|
+
}
|
|
31
|
+
export interface YHubChangeset {
|
|
32
|
+
/** Encoded document state at the requested timestamp. */
|
|
33
|
+
ydoc?: Uint8Array;
|
|
34
|
+
/** Encoded content map, when requested. */
|
|
35
|
+
attributions?: Uint8Array;
|
|
36
|
+
}
|
|
37
|
+
export interface YHubDocument {
|
|
38
|
+
doc: Uint8Array;
|
|
39
|
+
}
|
|
40
|
+
/** Query values are serialized without adding defaults. */
|
|
41
|
+
export type YHubQueryParams = Record<string, string | number | boolean | undefined>;
|
|
42
|
+
export interface YHubRollbackParams {
|
|
43
|
+
/** Inclusive start of the rollback window, in Unix milliseconds. */
|
|
44
|
+
from: number;
|
|
45
|
+
/** Encoded content IDs to roll back. */
|
|
46
|
+
contentIds: Uint8Array;
|
|
47
|
+
}
|
|
48
|
+
/** Document-scoped REST operations; binary Yjs payloads remain encoded. */
|
|
49
|
+
export declare class YHubClient<Metadata = unknown> {
|
|
50
|
+
private readonly baseUrl;
|
|
51
|
+
private readonly documentPath;
|
|
52
|
+
private readonly headers;
|
|
53
|
+
private readonly queryParams;
|
|
54
|
+
private readonly timeoutMs;
|
|
55
|
+
constructor({ baseUrl, org, docId, headers, queryParams, timeoutMs, }: YHubClientOptions);
|
|
56
|
+
private request;
|
|
57
|
+
getVersion(t: number): Promise<VersionResult<YHubVersion<Metadata> | undefined>>;
|
|
58
|
+
createVersion(t: number, name: string, custom?: Metadata | null): Promise<VersionResult<YHubVersion<Metadata>>>;
|
|
59
|
+
updateVersion(version: YHubVersion<Metadata>, name: string, custom?: Metadata | null | undefined): Promise<VersionResult<YHubVersion<Metadata>>>;
|
|
60
|
+
deleteVersion(version: YHubVersion<Metadata>): Promise<VersionResult<void>>;
|
|
61
|
+
getActivity(params?: YHubQueryParams, signal?: AbortSignal): Promise<VersionResult<YHubActivityEntry<Metadata>[]>>;
|
|
62
|
+
getChangeset(params?: YHubQueryParams, signal?: AbortSignal): Promise<VersionResult<YHubChangeset>>;
|
|
63
|
+
getDocument(params?: YHubQueryParams): Promise<VersionResult<Uint8Array>>;
|
|
64
|
+
getContent(to: number, signal?: AbortSignal): Promise<VersionResult<Uint8Array>>;
|
|
65
|
+
getAttributions(from: number, to?: number, signal?: AbortSignal): Promise<VersionResult<Uint8Array>>;
|
|
66
|
+
rollback(params: YHubRollbackParams): Promise<VersionResult<void>>;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,8 @@ export declare const ForkYDocExtension: (options: CollaborationOptions) => impor
|
|
|
12
12
|
readonly fork: ({ initialUpdate, }?: {
|
|
13
13
|
initialUpdate?: Uint8Array;
|
|
14
14
|
}) => void;
|
|
15
|
+
/** Replace only the local fork, retaining live restoration state. */
|
|
16
|
+
readonly replaceSnapshot: (initialUpdate: Uint8Array) => void;
|
|
15
17
|
/**
|
|
16
18
|
* Resume syncing the Y.js document to the remote
|
|
17
19
|
* If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|