@blocknote/core 0.56.0 → 0.57.1
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/NOTICE.txt +101 -0
- package/dist/BlockNoteExtension-U58cXw1g.js +64 -0
- package/dist/ThreadStore-CSEwCO0O.js +8 -0
- package/dist/{UserStore-OZJP3K8T.js → UserStore-BFv6NXA-.js} +3 -7
- package/dist/ar-DPJDxCQI.js +3 -0
- package/dist/blocknote.js +8 -6
- package/dist/blocks-BUX9dXi9.js +2063 -0
- package/dist/blocks.js +3 -2
- package/dist/comments.js +8 -9
- package/dist/de-CakHBokE.js +3 -0
- package/dist/emoji-data.js +102 -0
- package/dist/en-BGdzE27X.js +3 -0
- package/dist/{en-Ch-vvt5e.js → en-Ne9rlj9Y.js} +9 -6
- package/dist/es-VeBX6MEG.js +3 -0
- package/dist/{extensions-BbM81hHa.js → extensions-CEgexSyF.js} +846 -824
- package/dist/extensions.js +4 -4
- package/dist/fa-Dt7EYtKf.js +3 -0
- package/dist/fr-DUhhjxrJ.js +3 -0
- package/dist/getDefaultSlashMenuItems-DfDOr807.js +1939 -0
- package/dist/he-BShJg1dK.js +3 -0
- package/dist/hr-BXtyqmwg.js +3 -0
- package/dist/is-2Fb-0w_j.js +3 -0
- package/dist/it-CiZtVb3Y.js +3 -0
- package/dist/ja-CsxD3kEL.js +3 -0
- package/dist/ko-It6g03Cy.js +3 -0
- package/dist/locales.js +692 -54
- package/dist/markGroups-BszXCkX8.js +18 -0
- package/dist/nb-CLao87La.js +3 -0
- package/dist/nl-JQSo8dht.js +3 -0
- package/dist/pl-DEMBgHEP.js +3 -0
- package/dist/pt-CBCdYAax.js +3 -0
- package/dist/ru-BQk_9Q-L.js +3 -0
- package/dist/sk-kgB2DtDL.js +3 -0
- package/dist/{src-BmLsLZfE.js → src-DksfoQmN.js} +1173 -1090
- package/dist/style.css +1 -1
- package/dist/tr-DkcSXX8f.js +3 -0
- package/dist/uk-Bib-e6bV.js +3 -0
- package/dist/uz-B2jaKhJb.js +3 -0
- package/dist/vi-V_GFRxE8.js +3 -0
- package/dist/y.js +366 -365
- package/dist/yjs.js +140 -138
- package/dist/zh-hant-2ZrAkFnC.js +3 -0
- package/dist/zh-jglyCmjs.js +3 -0
- package/package.json +45 -21
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.d.ts +5 -0
- package/types/src/api/blockManipulation/tables/tables.d.ts +9 -4
- package/types/src/api/clipboard/fromClipboard/normalizeOfficeHTML.d.ts +5 -0
- package/types/src/api/exporters/markdown/wrapWithDelimiter.d.ts +6 -0
- package/types/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.d.ts +4 -0
- package/types/src/blocks/defaultBlocks.d.ts +10 -0
- package/types/src/editor/BlockNoteEditor.d.ts +2 -1
- package/types/src/editor/managers/ExtensionManager/index.d.ts +4 -4
- package/types/src/editor/managers/StyleManager.d.ts +2 -1
- package/types/src/emoji-data/frimousse/ar.d.ts +2 -0
- package/types/src/emoji-data/frimousse/common.d.ts +3 -0
- package/types/src/emoji-data/frimousse/de.d.ts +2 -0
- package/types/src/emoji-data/frimousse/en.d.ts +2 -0
- package/types/src/emoji-data/frimousse/es.d.ts +2 -0
- package/types/src/emoji-data/frimousse/fa.d.ts +2 -0
- package/types/src/emoji-data/frimousse/fr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/he.d.ts +2 -0
- package/types/src/emoji-data/frimousse/hr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/is.d.ts +2 -0
- package/types/src/emoji-data/frimousse/it.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ja.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ko.d.ts +2 -0
- package/types/src/emoji-data/frimousse/loadFrimousseData.d.ts +2 -0
- package/types/src/emoji-data/frimousse/nb.d.ts +2 -0
- package/types/src/emoji-data/frimousse/nl.d.ts +2 -0
- package/types/src/emoji-data/frimousse/pl.d.ts +2 -0
- package/types/src/emoji-data/frimousse/pt.d.ts +2 -0
- package/types/src/emoji-data/frimousse/ru.d.ts +2 -0
- package/types/src/emoji-data/frimousse/sk.d.ts +2 -0
- package/types/src/emoji-data/frimousse/tr.d.ts +2 -0
- package/types/src/emoji-data/frimousse/types.d.ts +21 -0
- package/types/src/emoji-data/frimousse/uk.d.ts +2 -0
- package/types/src/emoji-data/frimousse/uz.d.ts +2 -0
- package/types/src/emoji-data/frimousse/vi.d.ts +2 -0
- package/types/src/emoji-data/frimousse/zh-hant.d.ts +2 -0
- package/types/src/emoji-data/frimousse/zh.d.ts +2 -0
- package/types/src/emoji-data/index.d.ts +3 -0
- package/types/src/emoji-data/searchEmojis.d.ts +5 -0
- package/types/src/extensions/Loading/Loading.d.ts +11 -0
- package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +13 -4
- package/types/src/extensions/SideMenu/SideMenu.d.ts +2 -1
- package/types/src/extensions/Versioning/Versioning.d.ts +2 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +1 -0
- package/types/src/extensions/Versioning/types.d.ts +12 -6
- package/types/src/extensions/Versioning/versioningState.d.ts +6 -0
- package/types/src/extensions/index.d.ts +1 -2
- package/types/src/i18n/dictionary.d.ts +4 -1
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/fa.d.ts +6 -0
- package/types/src/i18n/locales/index.d.ts +1 -0
- package/types/src/i18n/locales/sk.d.ts +6 -0
- package/types/src/i18n/locales/tr.d.ts +378 -0
- package/types/src/index.d.ts +0 -1
- package/types/src/schema/inlineContent/createSpec.d.ts +2 -1
- package/types/src/schema/inlineContent/internal.d.ts +1 -1
- package/types/src/schema/inlineContent/types.d.ts +2 -4
- package/types/src/schema/styles/createSpec.d.ts +2 -1
- package/types/src/schema/styles/internal.d.ts +4 -1
- package/types/src/schema/styles/types.d.ts +2 -0
- package/types/src/y/extensions/YSync.d.ts +1 -1
- package/types/src/y/extensions/index.d.ts +1 -1
- package/types/src/y/versioning/yhub.d.ts +2 -0
- package/types/src/yjs/extensions/Versioning.d.ts +1 -0
- package/types/src/yjs/extensions/YUndo.d.ts +3 -2
- package/types/src/yjs/extensions/index.d.ts +1 -1
- package/dist/BlockNoteExtension-DjEkXkR5.cjs +0 -2
- package/dist/BlockNoteExtension-DjEkXkR5.cjs.map +0 -1
- package/dist/BlockNoteExtension-TsTGtIeX.js +0 -87
- package/dist/BlockNoteExtension-TsTGtIeX.js.map +0 -1
- package/dist/ThreadStore-Bx-gSEh1.cjs +0 -2
- package/dist/ThreadStore-Bx-gSEh1.cjs.map +0 -1
- package/dist/ThreadStore-et9wB5Xt.js +0 -11
- package/dist/ThreadStore-et9wB5Xt.js.map +0 -1
- package/dist/UserStore-CTVzVGh-.cjs +0 -2
- package/dist/UserStore-CTVzVGh-.cjs.map +0 -1
- package/dist/UserStore-OZJP3K8T.js.map +0 -1
- package/dist/blocknote.cjs +0 -1
- package/dist/blocks-COVwe5Cf.cjs +0 -12
- package/dist/blocks-COVwe5Cf.cjs.map +0 -1
- package/dist/blocks-COYcDVg7.js +0 -3943
- package/dist/blocks-COYcDVg7.js.map +0 -1
- package/dist/blocks.cjs +0 -1
- package/dist/comments.cjs +0 -2
- package/dist/comments.cjs.map +0 -1
- package/dist/comments.js.map +0 -1
- package/dist/en-Ch-vvt5e.js.map +0 -1
- package/dist/en-N5lu0-j8.cjs +0 -2
- package/dist/en-N5lu0-j8.cjs.map +0 -1
- package/dist/extensions-BbM81hHa.js.map +0 -1
- package/dist/extensions-D_WkAfSt.cjs +0 -58
- package/dist/extensions-D_WkAfSt.cjs.map +0 -1
- package/dist/extensions.cjs +0 -1
- package/dist/locales.cjs +0 -2
- package/dist/locales.cjs.map +0 -1
- package/dist/locales.js.map +0 -1
- package/dist/src-4OQT3z5S.cjs +0 -23
- package/dist/src-4OQT3z5S.cjs.map +0 -1
- package/dist/src-BmLsLZfE.js.map +0 -1
- package/dist/webpack-stats.json +0 -1
- package/dist/y.cjs +0 -2
- package/dist/y.cjs.map +0 -1
- package/dist/y.js.map +0 -1
- package/dist/yjs.cjs +0 -2
- package/dist/yjs.cjs.map +0 -1
- package/dist/yjs.js.map +0 -1
- package/src/api/README.md +0 -8
- package/src/api/__snapshots__/blocks-deleted-nested-deep.json +0 -26
- package/src/api/__snapshots__/blocks-deleted-nested.json +0 -68
- package/src/api/__snapshots__/blocks-deleted.json +0 -26
- package/src/api/__snapshots__/blocks-indented-changed.json +0 -129
- package/src/api/__snapshots__/blocks-inserted-nested.json +0 -62
- package/src/api/__snapshots__/blocks-inserted.json +0 -20
- package/src/api/__snapshots__/blocks-moved-deeper-into-nesting.json +0 -164
- package/src/api/__snapshots__/blocks-moved-down-twice-in-same-parent.json +0 -44
- package/src/api/__snapshots__/blocks-moved-insert-changes-sibling-order.json +0 -26
- package/src/api/__snapshots__/blocks-moved-multiple-in-same-transaction.json +0 -188
- package/src/api/__snapshots__/blocks-moved-nested-sibling-reorder.json +0 -180
- package/src/api/__snapshots__/blocks-moved-to-different-parent.json +0 -78
- package/src/api/__snapshots__/blocks-moved-to-root-level.json +0 -78
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-parent.json +0 -44
- package/src/api/__snapshots__/blocks-moved-up-down-in-same-transaction.json +0 -44
- package/src/api/__snapshots__/blocks-outdented-changed.json +0 -129
- package/src/api/__snapshots__/blocks-updated-content-inserted.json +0 -42
- package/src/api/__snapshots__/blocks-updated-multiple-insert.json +0 -50
- package/src/api/__snapshots__/blocks-updated-multiple.json +0 -82
- package/src/api/__snapshots__/blocks-updated-nested-deep.json +0 -42
- package/src/api/__snapshots__/blocks-updated-nested-multiple.json +0 -118
- package/src/api/__snapshots__/blocks-updated-nested.json +0 -78
- package/src/api/__snapshots__/blocks-updated-single.json +0 -42
- package/src/api/__snapshots__/blocks-updated.json +0 -42
- package/src/api/blockManipulation/__snapshots__/transactions.test.ts.snap +0 -34
- package/src/api/blockManipulation/commands/insertBlocks/__snapshots__/insertBlocks.test.ts.snap +0 -4570
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +0 -176
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +0 -95
- package/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.ts +0 -217
- package/src/api/blockManipulation/commands/mergeBlocks/__snapshots__/mergeBlocks.test.ts.snap +0 -2761
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +0 -251
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.ts +0 -187
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +0 -13625
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +0 -391
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +0 -350
- package/src/api/blockManipulation/commands/nestBlock/__snapshots__/nestBlock.test.ts.snap +0 -952
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +0 -917
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +0 -248
- package/src/api/blockManipulation/commands/replaceBlocks/__snapshots__/replaceBlocks.test.ts.snap +0 -5710
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +0 -306
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +0 -143
- package/src/api/blockManipulation/commands/splitBlock/__snapshots__/splitBlock.test.ts.snap +0 -3507
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +0 -364
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +0 -90
- package/src/api/blockManipulation/commands/updateBlock/__snapshots__/updateBlock.test.ts.snap +0 -15085
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +0 -1210
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +0 -706
- package/src/api/blockManipulation/getBlock/getBlock.ts +0 -104
- package/src/api/blockManipulation/insertContentAt.ts +0 -83
- package/src/api/blockManipulation/layoutBlocks/fixLayoutBlock.ts +0 -173
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.ts +0 -293
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.fixture.ts +0 -145
- package/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.ts +0 -783
- package/src/api/blockManipulation/layoutBlocks/plainBlocks.test.ts +0 -180
- package/src/api/blockManipulation/layoutBlocks/titledBlocks.test.ts +0 -365
- package/src/api/blockManipulation/selections/selection.ts +0 -234
- package/src/api/blockManipulation/selections/textCursorPosition.ts +0 -63
- package/src/api/blockManipulation/setupTestEnv.ts +0 -223
- package/src/api/blockManipulation/tables/tables.test.ts +0 -2127
- package/src/api/blockManipulation/tables/tables.ts +0 -887
- package/src/api/clipboard/fromClipboard/acceptedMIMETypes.ts +0 -8
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +0 -55
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +0 -209
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +0 -38
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +0 -157
- package/src/api/clipboard/toClipboard/copyExtension.ts +0 -299
- package/src/api/combineTransactionSteps.ts +0 -22
- package/src/api/exporters/html/externalHTMLExporter.ts +0 -76
- package/src/api/exporters/html/internalHTMLSerializer.ts +0 -182
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +0 -510
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +0 -283
- package/src/api/exporters/markdown/htmlToMarkdown.ts +0 -895
- package/src/api/exporters/markdown/markdownExporter.ts +0 -41
- package/src/api/getBlockInfoFromPos.test.ts +0 -681
- package/src/api/getBlockInfoFromPos.ts +0 -693
- package/src/api/getBlocksChangedByTransaction.test.ts +0 -783
- package/src/api/getBlocksChangedByTransaction.ts +0 -458
- package/src/api/getChangedRangeWithAttrs.ts +0 -54
- package/src/api/getChangedRanges.test.ts +0 -391
- package/src/api/getChangedRanges.ts +0 -368
- package/src/api/nodeConversions/blockToNode.test.ts +0 -113
- package/src/api/nodeConversions/blockToNode.ts +0 -427
- package/src/api/nodeConversions/fragmentToBlocks.ts +0 -48
- package/src/api/nodeConversions/nodeToBlock.ts +0 -717
- package/src/api/nodeUtil.ts +0 -46
- package/src/api/parsers/html/parseHTML.ts +0 -80
- package/src/api/parsers/html/util/__snapshots__/nestedLists.test.ts.snap +0 -144
- package/src/api/parsers/html/util/nestedLists.test.ts +0 -165
- package/src/api/parsers/html/util/nestedLists.ts +0 -123
- package/src/api/parsers/html/util/normalizeWhitespace.ts +0 -87
- package/src/api/parsers/markdown/autolink.ts +0 -23
- package/src/api/parsers/markdown/detectMarkdown.test.ts +0 -211
- package/src/api/parsers/markdown/detectMarkdown.ts +0 -61
- package/src/api/parsers/markdown/markdownToHtml.ts +0 -1444
- package/src/api/parsers/markdown/parseMarkdown.ts +0 -24
- package/src/api/pmUtil.ts +0 -79
- package/src/api/positionMapping.test.ts +0 -209
- package/src/api/positionMapping.ts +0 -42
- package/src/blocks/Audio/block.ts +0 -171
- package/src/blocks/Audio/parseAudioElement.ts +0 -5
- package/src/blocks/BlockNoteSchema.ts +0 -59
- package/src/blocks/Code/CodeBlockOptions.ts +0 -83
- package/src/blocks/Code/block.test.ts +0 -265
- package/src/blocks/Code/block.ts +0 -56
- package/src/blocks/Code/helpers/extensions/CodeKeyboardShortcutsExtension.ts +0 -125
- package/src/blocks/Code/helpers/parse/parsePreCode.ts +0 -45
- package/src/blocks/Code/helpers/render/createCodeBlock.ts +0 -98
- package/src/blocks/Code/helpers/toExternalHTML/createPreCode.ts +0 -14
- package/src/blocks/Divider/block.ts +0 -49
- package/src/blocks/File/block.ts +0 -95
- package/src/blocks/File/helpers/parse/parseEmbedElement.ts +0 -5
- package/src/blocks/File/helpers/parse/parseFigureElement.ts +0 -16
- package/src/blocks/File/helpers/render/createAddFileButton.ts +0 -69
- package/src/blocks/File/helpers/render/createFileBlockWrapper.ts +0 -88
- package/src/blocks/File/helpers/render/createFileNameWithIcon.ts +0 -37
- package/src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts +0 -271
- package/src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts +0 -13
- package/src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts +0 -15
- package/src/blocks/Heading/block.ts +0 -227
- package/src/blocks/Image/block.ts +0 -193
- package/src/blocks/Image/parseImageElement.ts +0 -7
- package/src/blocks/ListItem/BulletListItem/block.ts +0 -129
- package/src/blocks/ListItem/CheckListItem/block.test.ts +0 -61
- package/src/blocks/ListItem/CheckListItem/block.ts +0 -184
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +0 -352
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +0 -239
- package/src/blocks/ListItem/NumberedListItem/block.ts +0 -143
- package/src/blocks/ListItem/ToggleListItem/block.ts +0 -139
- package/src/blocks/ListItem/getListItemContent.ts +0 -115
- package/src/blocks/PageBreak/block.ts +0 -72
- package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +0 -47
- package/src/blocks/Paragraph/block.ts +0 -80
- package/src/blocks/Quote/block.ts +0 -99
- package/src/blocks/README.md +0 -3
- package/src/blocks/Table/TableExtension.test.ts +0 -231
- package/src/blocks/Table/TableExtension.ts +0 -115
- package/src/blocks/Table/block.ts +0 -492
- package/src/blocks/ToggleWrapper/createToggleFrame.ts +0 -126
- package/src/blocks/ToggleWrapper/toggleBlocks.browser.test.ts +0 -1056
- package/src/blocks/Video/block.ts +0 -142
- package/src/blocks/Video/parseVideoElement.ts +0 -7
- package/src/blocks/defaultBlockHelpers.ts +0 -113
- package/src/blocks/defaultBlockTypeGuards.ts +0 -167
- package/src/blocks/defaultBlockTypeItems.test.ts +0 -70
- package/src/blocks/defaultBlockTypeItems.ts +0 -99
- package/src/blocks/defaultBlocks.test.ts +0 -67
- package/src/blocks/defaultBlocks.ts +0 -214
- package/src/blocks/defaultProps.ts +0 -165
- package/src/blocks/getDetailsContent.ts +0 -77
- package/src/blocks/index.ts +0 -30
- package/src/comments/CommentEditorSubmitExtension.test.ts +0 -141
- package/src/comments/CommentEditorSubmitExtension.ts +0 -56
- package/src/comments/extension.ts +0 -396
- package/src/comments/index.ts +0 -8
- package/src/comments/mark.ts +0 -64
- package/src/comments/threadstore/DefaultThreadStoreAuth.ts +0 -106
- package/src/comments/threadstore/ThreadStore.ts +0 -130
- package/src/comments/threadstore/ThreadStoreAuth.ts +0 -13
- package/src/comments/threadstore/TipTapThreadStore.ts +0 -292
- package/src/comments/threadstore/tiptap/types.ts +0 -131
- package/src/comments/types.ts +0 -121
- package/src/editor/Block.css +0 -1498
- package/src/editor/BlockNoteEditor.node.test.ts +0 -35
- package/src/editor/BlockNoteEditor.test.ts +0 -278
- package/src/editor/BlockNoteEditor.ts +0 -1559
- package/src/editor/BlockNoteExtension.test.ts +0 -103
- package/src/editor/BlockNoteExtension.ts +0 -246
- package/src/editor/README.md +0 -3
- package/src/editor/blockColors.browser.test.ts +0 -127
- package/src/editor/cursorPositionTypes.ts +0 -17
- package/src/editor/defaultColors.ts +0 -77
- package/src/editor/editor.css +0 -257
- package/src/editor/managers/BlockManager.ts +0 -256
- package/src/editor/managers/EventManager.browser.test.ts +0 -334
- package/src/editor/managers/EventManager.ts +0 -260
- package/src/editor/managers/ExportManager.ts +0 -137
- package/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.ts +0 -45
- package/src/editor/managers/ExtensionManager/ExtensionManager.node.test.ts +0 -209
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +0 -336
- package/src/editor/managers/ExtensionManager/extensions.ts +0 -200
- package/src/editor/managers/ExtensionManager/index.ts +0 -764
- package/src/editor/managers/ExtensionManager/symbol.ts +0 -5
- package/src/editor/managers/SelectionManager.ts +0 -120
- package/src/editor/managers/StateManager.ts +0 -261
- package/src/editor/managers/StyleManager.browser.test.ts +0 -122
- package/src/editor/managers/StyleManager.test.ts +0 -98
- package/src/editor/managers/StyleManager.ts +0 -278
- package/src/editor/managers/index.ts +0 -8
- package/src/editor/performance.test.ts +0 -192
- package/src/editor/selectionTypes.ts +0 -14
- package/src/editor/transformPasted.test.ts +0 -295
- package/src/editor/transformPasted.ts +0 -294
- package/src/exporter/ExportImage.ts +0 -50
- package/src/exporter/Exporter.test.ts +0 -255
- package/src/exporter/Exporter.ts +0 -185
- package/src/exporter/index.ts +0 -3
- package/src/exporter/mapping.ts +0 -110
- package/src/extensions/BlockChange/BlockChange.ts +0 -67
- package/src/extensions/DropCursor/DropCursor.ts +0 -376
- package/src/extensions/DropCursor/dropIntoChildren.ts +0 -80
- package/src/extensions/DropCursor/utils.ts +0 -195
- package/src/extensions/FilePanel/FilePanel.ts +0 -41
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +0 -157
- package/src/extensions/History/History.ts +0 -11
- package/src/extensions/InlineContentBoundaryEdit/InlineContentBoundaryEdit.ts +0 -109
- package/src/extensions/LinkToolbar/LinkToolbar.ts +0 -76
- package/src/extensions/LinkToolbar/protocols.ts +0 -13
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.ts +0 -190
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +0 -112
- package/src/extensions/Placeholder/Placeholder.test.ts +0 -23
- package/src/extensions/Placeholder/Placeholder.ts +0 -150
- package/src/extensions/PositionMapping/PositionMapping.ts +0 -68
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +0 -156
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +0 -201
- package/src/extensions/README.md +0 -3
- package/src/extensions/ReadOnly/ReadOnly.test.ts +0 -181
- package/src/extensions/ReadOnly/ReadOnly.ts +0 -73
- package/src/extensions/ShowSelection/ShowSelection.ts +0 -61
- package/src/extensions/SideMenu/MultipleNodeSelection.ts +0 -89
- package/src/extensions/SideMenu/SideMenu.ts +0 -470
- package/src/extensions/SideMenu/blockDropHandling.ts +0 -372
- package/src/extensions/SideMenu/blockGeometry.browser.test.ts +0 -148
- package/src/extensions/SideMenu/blockGeometry.test.ts +0 -46
- package/src/extensions/SideMenu/blockGeometry.ts +0 -53
- package/src/extensions/SideMenu/dragging.ts +0 -200
- package/src/extensions/SideMenu/sideMenuHover.test.ts +0 -36
- package/src/extensions/SideMenu/sideMenuHover.ts +0 -270
- package/src/extensions/SourceBlockWithPreview/SourceBlockWithPreview.ts +0 -193
- package/src/extensions/SourceInlineContentWithPreview/SourceInlineContentWithPreview.ts +0 -142
- package/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.ts +0 -4
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +0 -11
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +0 -309
- package/src/extensions/SuggestionMenu/SuggestionMenu.ts +0 -436
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +0 -76
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -299
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.ts +0 -130
- package/src/extensions/SyntaxHighlighting/SyntaxHighlighting.ts +0 -89
- package/src/extensions/SyntaxHighlighting/inlineHighlight.test.ts +0 -135
- package/src/extensions/SyntaxHighlighting/shiki.ts +0 -116
- package/src/extensions/TableHandles/TableHandles.browser.test.ts +0 -307
- package/src/extensions/TableHandles/TableHandles.ts +0 -1263
- package/src/extensions/TrailingNode/TrailingNode.ts +0 -233
- package/src/extensions/Versioning/Versioning.browser.test.ts +0 -151
- package/src/extensions/Versioning/Versioning.node.test.ts +0 -177
- package/src/extensions/Versioning/Versioning.ts +0 -161
- package/src/extensions/Versioning/__test__/result.ts +0 -12
- package/src/extensions/Versioning/comparison.test.ts +0 -40
- package/src/extensions/Versioning/createVersioning.test.ts +0 -867
- package/src/extensions/Versioning/createVersioning.ts +0 -499
- package/src/extensions/Versioning/formatVersionDate.ts +0 -24
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +0 -572
- package/src/extensions/Versioning/inMemoryVersioning.ts +0 -268
- package/src/extensions/Versioning/index.ts +0 -6
- package/src/extensions/Versioning/scrollScheduling.test.ts +0 -51
- package/src/extensions/Versioning/scrollToFirstChange.test.ts +0 -320
- package/src/extensions/Versioning/scrollToFirstChange.ts +0 -139
- package/src/extensions/Versioning/types.ts +0 -219
- package/src/extensions/Versioning/versioningState.ts +0 -154
- package/src/extensions/blockDOM.browser.test.ts +0 -102
- package/src/extensions/blockDOM.test.ts +0 -178
- package/src/extensions/blockDOM.ts +0 -135
- package/src/extensions/index.ts +0 -27
- package/src/extensions/tiptap-extensions/BackgroundColor/BackgroundColorExtension.ts +0 -17
- package/src/extensions/tiptap-extensions/HardBreak/HardBreak.ts +0 -35
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +0 -1870
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +0 -1116
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.ts +0 -152
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +0 -174
- package/src/extensions/tiptap-extensions/Link/helpers/clickHandler.ts +0 -82
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +0 -412
- package/src/extensions/tiptap-extensions/Link/helpers/pasteHandler.ts +0 -53
- package/src/extensions/tiptap-extensions/Link/helpers/tlds.ts +0 -7
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +0 -13
- package/src/extensions/tiptap-extensions/Link/index.ts +0 -2
- package/src/extensions/tiptap-extensions/Link/link.test.ts +0 -945
- package/src/extensions/tiptap-extensions/Link/link.ts +0 -238
- package/src/extensions/tiptap-extensions/TextAlignment/TextAlignmentExtension.ts +0 -33
- package/src/extensions/tiptap-extensions/TextColor/TextColorExtension.ts +0 -17
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +0 -173
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +0 -339
- package/src/extensions/tiptap-extensions/index.ts +0 -7
- package/src/extensions-shared/UiElementPosition.ts +0 -4
- package/src/fonts/inter.browser.test.ts +0 -57
- package/src/i18n/dictionary.ts +0 -17
- package/src/i18n/index.ts +0 -2
- package/src/i18n/locales/ar.ts +0 -443
- package/src/i18n/locales/de.ts +0 -477
- package/src/i18n/locales/en.ts +0 -458
- package/src/i18n/locales/es.ts +0 -456
- package/src/i18n/locales/fa.ts +0 -427
- package/src/i18n/locales/fr.ts +0 -504
- package/src/i18n/locales/he.ts +0 -458
- package/src/i18n/locales/hr.ts +0 -472
- package/src/i18n/locales/index.ts +0 -23
- package/src/i18n/locales/is.ts +0 -472
- package/src/i18n/locales/it.ts +0 -480
- package/src/i18n/locales/ja.ts +0 -498
- package/src/i18n/locales/ko.ts +0 -471
- package/src/i18n/locales/nl.ts +0 -459
- package/src/i18n/locales/no.ts +0 -476
- package/src/i18n/locales/pl.ts +0 -449
- package/src/i18n/locales/pt.ts +0 -451
- package/src/i18n/locales/ru.ts +0 -502
- package/src/i18n/locales/sk.ts +0 -456
- package/src/i18n/locales/uk.ts +0 -482
- package/src/i18n/locales/uz.ts +0 -492
- package/src/i18n/locales/vi.ts +0 -457
- package/src/i18n/locales/zh-tw.ts +0 -499
- package/src/i18n/locales/zh.ts +0 -499
- package/src/index.ts +0 -66
- package/src/locales.ts +0 -1
- package/src/pm-nodes/BlockContainer.test.ts +0 -101
- package/src/pm-nodes/BlockContainer.ts +0 -200
- package/src/pm-nodes/BlockGroup.ts +0 -58
- package/src/pm-nodes/Doc.ts +0 -11
- package/src/pm-nodes/README.md +0 -143
- package/src/pm-nodes/index.ts +0 -3
- package/src/pm-nodes/suggestionMarks.ts +0 -43
- package/src/schema/README.md +0 -3
- package/src/schema/blocks/children.test.ts +0 -288
- package/src/schema/blocks/children.ts +0 -136
- package/src/schema/blocks/createSpec.browser.test.ts +0 -176
- package/src/schema/blocks/createSpec.test.ts +0 -354
- package/src/schema/blocks/createSpec.ts +0 -732
- package/src/schema/blocks/extendBlockSpec.test.ts +0 -188
- package/src/schema/blocks/frame.test.ts +0 -112
- package/src/schema/blocks/frame.ts +0 -337
- package/src/schema/blocks/internal.test.ts +0 -86
- package/src/schema/blocks/internal.ts +0 -288
- package/src/schema/blocks/keyboard.ts +0 -154
- package/src/schema/blocks/layoutBlockAttributes.ts +0 -29
- package/src/schema/blocks/meta.test.ts +0 -53
- package/src/schema/blocks/meta.ts +0 -35
- package/src/schema/blocks/renderFrame.test.ts +0 -691
- package/src/schema/blocks/types.ts +0 -966
- package/src/schema/blocks/validateChildren.ts +0 -156
- package/src/schema/contentTypePropagation.test.ts +0 -182
- package/src/schema/dataAttributes.test.ts +0 -72
- package/src/schema/dataAttributes.ts +0 -69
- package/src/schema/index.ts +0 -15
- package/src/schema/inlineContent/createSpec.test.ts +0 -161
- package/src/schema/inlineContent/createSpec.ts +0 -409
- package/src/schema/inlineContent/internal.ts +0 -131
- package/src/schema/inlineContent/types.ts +0 -204
- package/src/schema/markGroups.ts +0 -82
- package/src/schema/nodeViewMutations.test.ts +0 -146
- package/src/schema/nodeViewMutations.ts +0 -49
- package/src/schema/propTypes.ts +0 -61
- package/src/schema/schema.test.ts +0 -110
- package/src/schema/schema.ts +0 -243
- package/src/schema/styles/createSpec.ts +0 -140
- package/src/schema/styles/internal.ts +0 -155
- package/src/schema/styles/types.ts +0 -57
- package/src/style.css +0 -2
- package/src/user/UserStore.ts +0 -199
- package/src/user/createUserStore.test.ts +0 -126
- package/src/user/index.ts +0 -2
- package/src/user/userColors.test.ts +0 -108
- package/src/user/userColors.ts +0 -101
- package/src/util/EventEmitter.ts +0 -59
- package/src/util/README.md +0 -3
- package/src/util/Store.test.ts +0 -132
- package/src/util/Store.ts +0 -135
- package/src/util/browser.ts +0 -54
- package/src/util/combineByGroup.ts +0 -25
- package/src/util/expandToWords.ts +0 -38
- package/src/util/string.ts +0 -36
- package/src/util/table.ts +0 -110
- package/src/util/topo-sort.test.ts +0 -125
- package/src/util/topo-sort.ts +0 -206
- package/src/util/typescript.ts +0 -17
- package/src/vite-env.d.ts +0 -7
- package/src/y/README.md +0 -5
- package/src/y/comments/RESTYjsThreadStore.ts +0 -138
- package/src/y/comments/YjsThreadStore.test.ts +0 -295
- package/src/y/comments/YjsThreadStore.ts +0 -358
- package/src/y/comments/YjsThreadStoreBase.ts +0 -50
- package/src/y/comments/index.ts +0 -3
- package/src/y/comments/yjsHelpers.ts +0 -125
- package/src/y/extensions/AttributionExtension.test.ts +0 -364
- package/src/y/extensions/AttributionExtension.ts +0 -401
- package/src/y/extensions/DiffVersioningExtension.test.ts +0 -242
- package/src/y/extensions/DiffVersioningExtension.ts +0 -200
- package/src/y/extensions/EmptyDocBinding.test.ts +0 -282
- package/src/y/extensions/ForkYDoc.node.test.ts +0 -77
- package/src/y/extensions/ForkYDoc.test.ts +0 -344
- package/src/y/extensions/ForkYDoc.ts +0 -117
- package/src/y/extensions/History.test.ts +0 -125
- package/src/y/extensions/RelativePositionMapping.test.ts +0 -453
- package/src/y/extensions/RelativePositionMapping.ts +0 -45
- package/src/y/extensions/Suggestions.ts +0 -174
- package/src/y/extensions/Versioning.node.test.ts +0 -126
- package/src/y/extensions/Versioning.test.ts +0 -117
- package/src/y/extensions/Versioning.ts +0 -74
- package/src/y/extensions/YAttributionMarks.ts +0 -422
- package/src/y/extensions/YCursorPlugin.ts +0 -192
- package/src/y/extensions/YSync.node.test.ts +0 -75
- package/src/y/extensions/YSync.ts +0 -197
- package/src/y/extensions/YSyncRemount.test.ts +0 -99
- package/src/y/extensions/blockMatchNodes.ts +0 -173
- package/src/y/extensions/index.ts +0 -140
- package/src/y/extensions/legacyYjsDocBinding.test.ts +0 -652
- package/src/y/extensions/nestingChanges.test.ts +0 -326
- package/src/y/extensions/persistentBlockGroups.test.ts +0 -1709
- package/src/y/extensions/persistentBlockGroups.ts +0 -953
- package/src/y/extensions/snapshotCodec.test.ts +0 -105
- package/src/y/extensions/snapshotCodec.ts +0 -39
- package/src/y/extensions/snapshotPreview.test.ts +0 -201
- package/src/y/extensions/snapshotPreview.ts +0 -292
- package/src/y/extensions/tableReshape.test.ts +0 -121
- package/src/y/extensions/v1BindingSnapshotDiff.test.ts +0 -121
- package/src/y/extensions/versionDiffAttribution.test.ts +0 -944
- package/src/y/extensions/versionDiffPerformance.test.ts +0 -101
- package/src/y/index.ts +0 -5
- package/src/y/utils.test.ts +0 -1309
- package/src/y/utils.ts +0 -366
- package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +0 -50
- package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all.json +0 -20
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +0 -32
- package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +0 -1
- package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
- package/src/y/versioning/__test__/fixtures/patch-response.json +0 -4
- package/src/y/versioning/__test__/yhub.test.ts +0 -966
- package/src/y/versioning/index.ts +0 -6
- package/src/y/versioning/yhub.ts +0 -350
- package/src/y/versioning/yhubClient.ts +0 -345
- package/src/yjs/README.md +0 -5
- package/src/yjs/comments/RESTYjsThreadStore.test.ts +0 -95
- package/src/yjs/comments/RESTYjsThreadStore.ts +0 -172
- package/src/yjs/comments/YjsThreadStore.test.ts +0 -295
- package/src/yjs/comments/YjsThreadStore.ts +0 -345
- package/src/yjs/comments/YjsThreadStoreBase.ts +0 -50
- package/src/yjs/comments/index.ts +0 -3
- package/src/yjs/comments/yjsHelpers.ts +0 -127
- package/src/yjs/extensions/FixUpSchema.test.ts +0 -421
- package/src/yjs/extensions/FixUpSchema.ts +0 -99
- package/src/yjs/extensions/ForkYDoc.browser.test.ts +0 -84
- package/src/yjs/extensions/ForkYDoc.node.test.ts +0 -231
- package/src/yjs/extensions/ForkYDoc.test.ts +0 -320
- package/src/yjs/extensions/ForkYDoc.ts +0 -177
- package/src/yjs/extensions/RelativePositionMapping.test.ts +0 -418
- package/src/yjs/extensions/RelativePositionMapping.ts +0 -77
- package/src/yjs/extensions/Versioning.test.ts +0 -376
- package/src/yjs/extensions/Versioning.ts +0 -126
- package/src/yjs/extensions/YCursorPlugin.ts +0 -201
- package/src/yjs/extensions/YSync.ts +0 -16
- package/src/yjs/extensions/YUndo.ts +0 -12
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor-forked.json +0 -19
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-editor.json +0 -19
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap-forked.html +0 -1
- package/src/yjs/extensions/__snapshots__/fork-yjs-snap.html +0 -1
- package/src/yjs/extensions/index.ts +0 -89
- package/src/yjs/extensions/schemaMigration/SchemaMigration.ts +0 -59
- package/src/yjs/extensions/schemaMigration/migrationRules/index.ts +0 -4
- package/src/yjs/extensions/schemaMigration/migrationRules/migrationRule.ts +0 -4
- package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.ts +0 -130
- package/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.ts +0 -91
- package/src/yjs/index.ts +0 -7
- package/src/yjs/utils.test.ts +0 -1013
- package/src/yjs/utils.ts +0 -186
- package/types/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/insertBlocks/insertPlacement.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/nestBlock/nestBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/commands/updateBlock/updateBlock.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.browser.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/layoutBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/plainBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/layoutBlocks/titledBlocks.test.d.ts +0 -1
- package/types/src/api/blockManipulation/tables/tables.test.d.ts +0 -1
- package/types/src/api/getBlockInfoFromPos.test.d.ts +0 -1
- package/types/src/api/getBlocksChangedByTransaction.test.d.ts +0 -1
- package/types/src/api/getChangedRanges.test.d.ts +0 -1
- package/types/src/api/nodeConversions/blockToNode.test.d.ts +0 -1
- package/types/src/api/parsers/html/util/nestedLists.test.d.ts +0 -1
- package/types/src/api/parsers/markdown/detectMarkdown.test.d.ts +0 -1
- package/types/src/api/positionMapping.test.d.ts +0 -1
- package/types/src/blocks/Code/block.test.d.ts +0 -1
- package/types/src/blocks/ListItem/CheckListItem/block.test.d.ts +0 -1
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.d.ts +0 -1
- package/types/src/blocks/Table/TableExtension.test.d.ts +0 -1
- package/types/src/blocks/ToggleWrapper/toggleBlocks.browser.test.d.ts +0 -1
- package/types/src/blocks/defaultBlockTypeItems.test.d.ts +0 -1
- package/types/src/blocks/defaultBlocks.test.d.ts +0 -1
- package/types/src/comments/CommentEditorSubmitExtension.test.d.ts +0 -1
- package/types/src/editor/BlockNoteEditor.node.test.d.ts +0 -1
- package/types/src/editor/BlockNoteEditor.test.d.ts +0 -1
- package/types/src/editor/BlockNoteExtension.test.d.ts +0 -1
- package/types/src/editor/blockColors.browser.test.d.ts +0 -1
- package/types/src/editor/managers/EventManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.node.test.d.ts +0 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +0 -1
- package/types/src/editor/managers/StyleManager.browser.test.d.ts +0 -1
- package/types/src/editor/managers/StyleManager.test.d.ts +0 -1
- package/types/src/editor/performance.test.d.ts +0 -1
- package/types/src/editor/transformPasted.test.d.ts +0 -1
- package/types/src/exporter/Exporter.test.d.ts +0 -1
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.test.d.ts +0 -1
- package/types/src/extensions/Placeholder/Placeholder.test.d.ts +0 -1
- package/types/src/extensions/PreviousBlockType/PreviousBlockType.test.d.ts +0 -1
- package/types/src/extensions/ReadOnly/ReadOnly.test.d.ts +0 -1
- package/types/src/extensions/SideMenu/blockGeometry.browser.test.d.ts +0 -1
- package/types/src/extensions/SideMenu/blockGeometry.test.d.ts +0 -1
- package/types/src/extensions/SideMenu/sideMenuHover.test.d.ts +0 -1
- package/types/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.d.ts +0 -4
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.test.d.ts +0 -1
- package/types/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.d.ts +0 -4
- package/types/src/extensions/SyntaxHighlighting/SyntaxHighlighting.test.d.ts +0 -1
- package/types/src/extensions/SyntaxHighlighting/inlineHighlight.test.d.ts +0 -1
- package/types/src/extensions/TableHandles/TableHandles.browser.test.d.ts +0 -1
- package/types/src/extensions/Versioning/Versioning.browser.test.d.ts +0 -1
- package/types/src/extensions/Versioning/Versioning.node.test.d.ts +0 -1
- package/types/src/extensions/Versioning/__test__/result.d.ts +0 -3
- package/types/src/extensions/Versioning/comparison.test.d.ts +0 -1
- package/types/src/extensions/Versioning/createVersioning.test.d.ts +0 -1
- package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +0 -1
- package/types/src/extensions/Versioning/scrollScheduling.test.d.ts +0 -1
- package/types/src/extensions/Versioning/scrollToFirstChange.test.d.ts +0 -1
- package/types/src/extensions/blockDOM.browser.test.d.ts +0 -1
- package/types/src/extensions/blockDOM.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +0 -4
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/blockIdentity.browser.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/Link/link.test.d.ts +0 -1
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +0 -4
- package/types/src/fonts/inter.browser.test.d.ts +0 -2
- package/types/src/pm-nodes/BlockContainer.test.d.ts +0 -1
- package/types/src/schema/blocks/children.test.d.ts +0 -1
- package/types/src/schema/blocks/createSpec.browser.test.d.ts +0 -1
- package/types/src/schema/blocks/createSpec.test.d.ts +0 -1
- package/types/src/schema/blocks/extendBlockSpec.test.d.ts +0 -1
- package/types/src/schema/blocks/frame.test.d.ts +0 -1
- package/types/src/schema/blocks/internal.test.d.ts +0 -1
- package/types/src/schema/blocks/meta.test.d.ts +0 -1
- package/types/src/schema/blocks/renderFrame.test.d.ts +0 -1
- package/types/src/schema/contentTypePropagation.test.d.ts +0 -1
- package/types/src/schema/dataAttributes.test.d.ts +0 -1
- package/types/src/schema/inlineContent/createSpec.test.d.ts +0 -1
- package/types/src/schema/nodeViewMutations.test.d.ts +0 -1
- package/types/src/schema/schema.test.d.ts +0 -1
- package/types/src/user/createUserStore.test.d.ts +0 -1
- package/types/src/user/userColors.test.d.ts +0 -1
- package/types/src/util/Store.test.d.ts +0 -1
- package/types/src/util/topo-sort.test.d.ts +0 -1
- package/types/src/y/comments/YjsThreadStore.test.d.ts +0 -1
- package/types/src/y/extensions/AttributionExtension.test.d.ts +0 -1
- package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +0 -1
- package/types/src/y/extensions/EmptyDocBinding.test.d.ts +0 -1
- package/types/src/y/extensions/ForkYDoc.node.test.d.ts +0 -1
- package/types/src/y/extensions/ForkYDoc.test.d.ts +0 -1
- package/types/src/y/extensions/History.test.d.ts +0 -1
- package/types/src/y/extensions/RelativePositionMapping.test.d.ts +0 -1
- package/types/src/y/extensions/Versioning.node.test.d.ts +0 -1
- package/types/src/y/extensions/Versioning.test.d.ts +0 -1
- package/types/src/y/extensions/YSync.node.test.d.ts +0 -1
- package/types/src/y/extensions/YSyncRemount.test.d.ts +0 -1
- package/types/src/y/extensions/legacyYjsDocBinding.test.d.ts +0 -1
- package/types/src/y/extensions/nestingChanges.test.d.ts +0 -1
- package/types/src/y/extensions/persistentBlockGroups.test.d.ts +0 -1
- package/types/src/y/extensions/snapshotCodec.test.d.ts +0 -1
- package/types/src/y/extensions/snapshotPreview.test.d.ts +0 -1
- package/types/src/y/extensions/tableReshape.test.d.ts +0 -1
- package/types/src/y/extensions/v1BindingSnapshotDiff.test.d.ts +0 -1
- package/types/src/y/extensions/versionDiffAttribution.test.d.ts +0 -1
- package/types/src/y/extensions/versionDiffPerformance.test.d.ts +0 -1
- package/types/src/y/utils.test.d.ts +0 -1
- package/types/src/y/versioning/__test__/yhub.test.d.ts +0 -1
- package/types/src/yjs/comments/RESTYjsThreadStore.test.d.ts +0 -1
- package/types/src/yjs/comments/YjsThreadStore.test.d.ts +0 -1
- package/types/src/yjs/extensions/FixUpSchema.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.browser.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.node.test.d.ts +0 -1
- package/types/src/yjs/extensions/ForkYDoc.test.d.ts +0 -1
- package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +0 -1
- package/types/src/yjs/extensions/Versioning.test.d.ts +0 -1
- package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +0 -1
- package/types/src/yjs/utils.test.d.ts +0 -1
|
@@ -1,1116 +0,0 @@
|
|
|
1
|
-
import { type ChainedCommands, Extension } from "@tiptap/core";
|
|
2
|
-
import { Fragment, type Node } from "prosemirror-model";
|
|
3
|
-
import {
|
|
4
|
-
NodeSelection,
|
|
5
|
-
Selection,
|
|
6
|
-
TextSelection,
|
|
7
|
-
Transaction,
|
|
8
|
-
} from "prosemirror-state";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
mergeBlocksCommand,
|
|
12
|
-
getMergeContent,
|
|
13
|
-
} from "../../../api/blockManipulation/commands/mergeBlocks/mergeBlocks.js";
|
|
14
|
-
import {
|
|
15
|
-
liftItem,
|
|
16
|
-
nestBlock,
|
|
17
|
-
unnestBlock,
|
|
18
|
-
} from "../../../api/blockManipulation/commands/nestBlock/nestBlock.js";
|
|
19
|
-
import { fixLayoutBlocksById } from "../../../api/blockManipulation/layoutBlocks/fixLayoutBlock.js";
|
|
20
|
-
import { nodeToBlock } from "../../../api/nodeConversions/nodeToBlock.js";
|
|
21
|
-
import { isLayoutNode } from "../../../schema/blocks/children.js";
|
|
22
|
-
import { splitBlockCommand } from "../../../api/blockManipulation/commands/splitBlock/splitBlock.js";
|
|
23
|
-
import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
24
|
-
import {
|
|
25
|
-
type BlockInfo,
|
|
26
|
-
ascendToInsertablePos,
|
|
27
|
-
getInsertionPos,
|
|
28
|
-
getAncestorLayoutBlocks,
|
|
29
|
-
getFirstLeafBlock,
|
|
30
|
-
getBlockInfoAt,
|
|
31
|
-
getBlockInfoFromNode,
|
|
32
|
-
getBlockInfoFromSelection,
|
|
33
|
-
getLastDescendantBlockInfo,
|
|
34
|
-
getNextBlockInfo,
|
|
35
|
-
getParentBlockInfo,
|
|
36
|
-
getPrevBlockInfo,
|
|
37
|
-
blockEdgeSelection,
|
|
38
|
-
} from "../../../api/getBlockInfoFromPos.js";
|
|
39
|
-
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
40
|
-
import { FilePanelExtension } from "../../FilePanel/FilePanel.js";
|
|
41
|
-
import { FormattingToolbarExtension } from "../../FormattingToolbar/FormattingToolbar.js";
|
|
42
|
-
|
|
43
|
-
// Move a block across a layout block boundary, repair its former ancestors, and
|
|
44
|
-
// map the caret through any repairs that change the insertion position.
|
|
45
|
-
function moveBlockOutAndPlaceCaret(
|
|
46
|
-
tr: Transaction,
|
|
47
|
-
block: BlockInfo["block"],
|
|
48
|
-
insertAt: number,
|
|
49
|
-
) {
|
|
50
|
-
const layoutBlocksToFix = getAncestorLayoutBlocks(tr.doc, block.beforePos);
|
|
51
|
-
tr.delete(block.beforePos, block.afterPos);
|
|
52
|
-
const insertionPos = tr.mapping.map(insertAt);
|
|
53
|
-
tr.insert(insertionPos, block.node);
|
|
54
|
-
const stepsBeforeFix = tr.steps.length;
|
|
55
|
-
fixLayoutBlocksById(tr, layoutBlocksToFix);
|
|
56
|
-
tr.setSelection(
|
|
57
|
-
TextSelection.near(
|
|
58
|
-
tr.doc.resolve(tr.mapping.slice(stepsBeforeFix).map(insertionPos) + 1),
|
|
59
|
-
),
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Delete a following block, retaining its children and any compatible text.
|
|
64
|
-
// A sole child also removes its child group instead of leaving an empty body.
|
|
65
|
-
function deleteBlockAndAppendContent(
|
|
66
|
-
chain: ChainedCommands,
|
|
67
|
-
current: Extract<BlockInfo, { hasContent: true }>,
|
|
68
|
-
next: Extract<BlockInfo, { hasContent: true }>,
|
|
69
|
-
remove: Pick<BlockInfo["block"], "beforePos" | "afterPos"> = next.block,
|
|
70
|
-
) {
|
|
71
|
-
return chain
|
|
72
|
-
.insertContentAt(
|
|
73
|
-
next.block.afterPos,
|
|
74
|
-
next.children?.node.content || Fragment.empty,
|
|
75
|
-
)
|
|
76
|
-
.deleteRange({ from: remove.beforePos, to: remove.afterPos })
|
|
77
|
-
.insertContentAt(current.contentEnd, getMergeContent(current, next) ?? null)
|
|
78
|
-
.setTextSelection(current.contentEnd)
|
|
79
|
-
.scrollIntoView()
|
|
80
|
-
.run();
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const KeyboardShortcutsExtension = Extension.create<{
|
|
84
|
-
editor: BlockNoteEditor<any, any, any>;
|
|
85
|
-
tabBehavior: "prefer-navigate-ui" | "prefer-indent";
|
|
86
|
-
selectAllBehavior: "block-first" | "document";
|
|
87
|
-
}>({
|
|
88
|
-
priority: 50,
|
|
89
|
-
|
|
90
|
-
// TODO: The shortcuts need a refactor. Do we want to use a command priority
|
|
91
|
-
// design as there is now, or clump the logic into a single function?
|
|
92
|
-
addKeyboardShortcuts() {
|
|
93
|
-
const bnEditor = this.options.editor;
|
|
94
|
-
// The `keyboard` settings of the block that `node` holds, in `doc`.
|
|
95
|
-
function keyboardOf(node: Node, doc: Node) {
|
|
96
|
-
const block = nodeToBlock(node, doc);
|
|
97
|
-
return bnEditor.schema.blockSpecs[block.type].implementation.keyboard(
|
|
98
|
-
block,
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
function canOutdentFrom(doc: Node) {
|
|
102
|
-
return (parent: Node) => keyboardOf(parent, doc).childrenCanOutdent;
|
|
103
|
-
}
|
|
104
|
-
// handleBackspace is partially adapted from https://github.com/ueberdosis/tiptap/blob/ed56337470efb4fd277128ab7ef792b37cfae992/packages/core/src/extensions/keymap.ts
|
|
105
|
-
const handleBackspace = () =>
|
|
106
|
-
this.editor.commands.first(({ chain, commands }) => [
|
|
107
|
-
// Deletes the selection if it's not empty.
|
|
108
|
-
() => commands.deleteSelection(),
|
|
109
|
-
// Undoes an input rule if one was triggered in the last editor state change.
|
|
110
|
-
() => commands.undoInputRule(),
|
|
111
|
-
// Resets the block (`keyboard.resetsTo`, a paragraph by default) if the
|
|
112
|
-
// selection is at the start of the block and the block isn't already
|
|
113
|
-
// in that form.
|
|
114
|
-
() =>
|
|
115
|
-
commands.command(({ state }) => {
|
|
116
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
117
|
-
if (!blockInfo.hasContent) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const selectionAtBlockStart =
|
|
122
|
-
state.selection.from === blockInfo.contentStart;
|
|
123
|
-
if (!selectionAtBlockStart) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const resetsTo = keyboardOf(
|
|
128
|
-
blockInfo.block.node,
|
|
129
|
-
state.doc,
|
|
130
|
-
).resetsTo;
|
|
131
|
-
const content = blockInfo.content.node;
|
|
132
|
-
const alreadyReset =
|
|
133
|
-
content.type.name === resetsTo.type &&
|
|
134
|
-
Object.entries(resetsTo.props ?? {}).every(
|
|
135
|
-
([prop, value]) => content.attrs[prop] === value,
|
|
136
|
-
);
|
|
137
|
-
if (alreadyReset) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return commands.command(
|
|
142
|
-
updateBlockCommand(blockInfo.block.beforePos, resetsTo as any),
|
|
143
|
-
);
|
|
144
|
-
}),
|
|
145
|
-
// Merges at the start of the block, into the preceding sibling
|
|
146
|
-
// (or its deepest descendant) or parent. Both must have inline content.
|
|
147
|
-
() =>
|
|
148
|
-
commands.command(({ state }) => {
|
|
149
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
150
|
-
if (!blockInfo.hasContent) {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
const { block: blockContainer } = blockInfo;
|
|
154
|
-
|
|
155
|
-
const prevSibling = getPrevBlockInfo(
|
|
156
|
-
state.doc,
|
|
157
|
-
blockInfo.block.beforePos,
|
|
158
|
-
);
|
|
159
|
-
// A preceding layout block takes the move branch below. Otherwise
|
|
160
|
-
// the block merges into the block above (its last descendant), or
|
|
161
|
-
// into its parent when it has no previous sibling;
|
|
162
|
-
// mergeBlocksCommand decides whether their contents are
|
|
163
|
-
// compatible.
|
|
164
|
-
if (prevSibling && !prevSibling.hasContent) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const selectionAtBlockStart =
|
|
169
|
-
state.selection.from === blockInfo.contentStart;
|
|
170
|
-
const selectionEmpty = state.selection.empty;
|
|
171
|
-
|
|
172
|
-
const posBetweenBlocks = blockContainer.beforePos;
|
|
173
|
-
|
|
174
|
-
if (selectionAtBlockStart && selectionEmpty) {
|
|
175
|
-
return chain()
|
|
176
|
-
.command(mergeBlocksCommand(posBetweenBlocks))
|
|
177
|
-
.scrollIntoView()
|
|
178
|
-
.run();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return false;
|
|
182
|
-
}),
|
|
183
|
-
// Move into the preceding layout block's trailing slot, or out of the
|
|
184
|
-
// current layout block when this is its first block.
|
|
185
|
-
() =>
|
|
186
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
187
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
188
|
-
if (
|
|
189
|
-
!blockInfo.hasContent ||
|
|
190
|
-
state.selection.from !== blockInfo.contentStart
|
|
191
|
-
) {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const blockType = blockInfo.block.node.type;
|
|
196
|
-
let target = getPrevBlockInfo(tr.doc, blockInfo.block.beforePos);
|
|
197
|
-
let insertionPos: number | undefined;
|
|
198
|
-
if (target) {
|
|
199
|
-
if (target.hasContent) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
} else {
|
|
203
|
-
const $pos = tr.doc.resolve(blockInfo.block.beforePos);
|
|
204
|
-
if (!isLayoutNode($pos.parent.type)) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
const $layoutBlockPos = tr.doc.resolve($pos.before());
|
|
208
|
-
// Between columns, move into the previous column. Outside a
|
|
209
|
-
// layout block, move above the closest boundary that accepts us.
|
|
210
|
-
const prevSibling = $layoutBlockPos.nodeBefore;
|
|
211
|
-
if (
|
|
212
|
-
isLayoutNode($layoutBlockPos.parent.type) &&
|
|
213
|
-
prevSibling &&
|
|
214
|
-
isLayoutNode(prevSibling.type)
|
|
215
|
-
) {
|
|
216
|
-
target = getBlockInfoFromNode(
|
|
217
|
-
prevSibling,
|
|
218
|
-
$layoutBlockPos.pos - prevSibling.nodeSize,
|
|
219
|
-
);
|
|
220
|
-
} else {
|
|
221
|
-
insertionPos = ascendToInsertablePos(
|
|
222
|
-
tr.doc,
|
|
223
|
-
$layoutBlockPos.pos,
|
|
224
|
-
blockType,
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (target) {
|
|
229
|
-
insertionPos = getInsertionPos(
|
|
230
|
-
tr.doc,
|
|
231
|
-
target,
|
|
232
|
-
"last-child",
|
|
233
|
-
blockType,
|
|
234
|
-
)?.pos;
|
|
235
|
-
}
|
|
236
|
-
if (insertionPos === undefined) {
|
|
237
|
-
return false;
|
|
238
|
-
}
|
|
239
|
-
if (dispatch) {
|
|
240
|
-
moveBlockOutAndPlaceCaret(tr, blockInfo.block, insertionPos);
|
|
241
|
-
}
|
|
242
|
-
return true;
|
|
243
|
-
}),
|
|
244
|
-
// Removes an empty inline block when merging is impossible. Its
|
|
245
|
-
// children take its place; the cursor moves to the preceding block.
|
|
246
|
-
() =>
|
|
247
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
248
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
249
|
-
if (
|
|
250
|
-
!blockInfo.hasContent ||
|
|
251
|
-
!state.selection.empty ||
|
|
252
|
-
blockInfo.contentKind !== "inline" ||
|
|
253
|
-
!blockInfo.isContentEmpty
|
|
254
|
-
) {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
const prevBlockInfo = getPrevBlockInfo(
|
|
258
|
-
state.doc,
|
|
259
|
-
blockInfo.block.beforePos,
|
|
260
|
-
);
|
|
261
|
-
const parent = !prevBlockInfo
|
|
262
|
-
? getParentBlockInfo(state.doc, blockInfo.block.beforePos)
|
|
263
|
-
: undefined;
|
|
264
|
-
const target = prevBlockInfo
|
|
265
|
-
? getLastDescendantBlockInfo(prevBlockInfo)
|
|
266
|
-
: parent;
|
|
267
|
-
if (!target?.hasContent) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
if (dispatch) {
|
|
271
|
-
if (
|
|
272
|
-
parent?.children?.node.childCount === 1 &&
|
|
273
|
-
!blockInfo.children
|
|
274
|
-
) {
|
|
275
|
-
tr.delete(parent.children.beforePos, parent.children.afterPos);
|
|
276
|
-
} else {
|
|
277
|
-
tr.replaceWith(
|
|
278
|
-
blockInfo.block.beforePos,
|
|
279
|
-
blockInfo.block.afterPos,
|
|
280
|
-
blockInfo.children?.node.content ?? Fragment.empty,
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
tr.setSelection(
|
|
284
|
-
target.contentKind === "none"
|
|
285
|
-
? NodeSelection.create(tr.doc, target.content.beforePos)
|
|
286
|
-
: TextSelection.near(tr.doc.resolve(target.contentEnd), -1),
|
|
287
|
-
);
|
|
288
|
-
tr.scrollIntoView();
|
|
289
|
-
}
|
|
290
|
-
return true;
|
|
291
|
-
}),
|
|
292
|
-
// Deletes previous block if it contains no content and isn't a table,
|
|
293
|
-
// when the selection is empty and at the start of the block. Moves the
|
|
294
|
-
// current block into the deleted block's place.
|
|
295
|
-
() =>
|
|
296
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
297
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
298
|
-
|
|
299
|
-
if (!blockInfo.hasContent) {
|
|
300
|
-
return false;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
const selectionAtBlockStart =
|
|
304
|
-
state.selection.from === blockInfo.contentStart;
|
|
305
|
-
const selectionEmpty = state.selection.empty;
|
|
306
|
-
|
|
307
|
-
const prevBlockInfo = getPrevBlockInfo(
|
|
308
|
-
state.doc,
|
|
309
|
-
blockInfo.block.beforePos,
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
if (prevBlockInfo && selectionAtBlockStart && selectionEmpty) {
|
|
313
|
-
// An emptied layout block has no content to merge with, so the
|
|
314
|
-
// guard below rejects it — the merge branch above only fires
|
|
315
|
-
// for a previous block with content of its own.
|
|
316
|
-
const bottomBlock = getLastDescendantBlockInfo(prevBlockInfo);
|
|
317
|
-
|
|
318
|
-
if (!bottomBlock.hasContent) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
const prevBlockNotTableAndNoContent =
|
|
323
|
-
bottomBlock.contentKind === "none" ||
|
|
324
|
-
(bottomBlock.contentKind === "inline" &&
|
|
325
|
-
bottomBlock.isContentEmpty);
|
|
326
|
-
|
|
327
|
-
if (prevBlockNotTableAndNoContent) {
|
|
328
|
-
if (dispatch) {
|
|
329
|
-
tr.delete(
|
|
330
|
-
blockInfo.block.beforePos,
|
|
331
|
-
blockInfo.block.afterPos,
|
|
332
|
-
);
|
|
333
|
-
tr.replaceWith(
|
|
334
|
-
bottomBlock.block.beforePos,
|
|
335
|
-
bottomBlock.block.afterPos,
|
|
336
|
-
blockInfo.block.node,
|
|
337
|
-
);
|
|
338
|
-
tr.setSelection(
|
|
339
|
-
TextSelection.near(
|
|
340
|
-
tr.doc.resolve(bottomBlock.block.beforePos + 2),
|
|
341
|
-
),
|
|
342
|
-
);
|
|
343
|
-
tr.scrollIntoView();
|
|
344
|
-
}
|
|
345
|
-
return true;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return false;
|
|
350
|
-
}),
|
|
351
|
-
// If no merge/deletion is possible (for example beside a table or
|
|
352
|
-
// under an image), unindent instead of trapping the cursor or losing text.
|
|
353
|
-
() =>
|
|
354
|
-
commands.command(({ state, tr }) => {
|
|
355
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
356
|
-
if (
|
|
357
|
-
!blockInfo.hasContent ||
|
|
358
|
-
!state.selection.empty ||
|
|
359
|
-
state.selection.from !== blockInfo.contentStart
|
|
360
|
-
) {
|
|
361
|
-
return false;
|
|
362
|
-
}
|
|
363
|
-
return liftItem(
|
|
364
|
-
tr,
|
|
365
|
-
tr.doc.type.schema.nodes["blockContainer"],
|
|
366
|
-
tr.doc.type.schema.nodes["blockGroup"],
|
|
367
|
-
canOutdentFrom(tr.doc),
|
|
368
|
-
);
|
|
369
|
-
}),
|
|
370
|
-
]);
|
|
371
|
-
|
|
372
|
-
const handleDelete = () =>
|
|
373
|
-
this.editor.commands.first(({ chain, commands }) => [
|
|
374
|
-
// Deletes the selection if it's not empty.
|
|
375
|
-
() => commands.deleteSelection(),
|
|
376
|
-
// Deletes the first child block and un-nests its children, if the
|
|
377
|
-
// selection is empty and at the end of the current block. If both the
|
|
378
|
-
// parent and child blocks have inline content, the child block's
|
|
379
|
-
// content is appended to the parent's. The child block's own children
|
|
380
|
-
// are unindented before it's deleted.
|
|
381
|
-
() =>
|
|
382
|
-
commands.command(({ state }) => {
|
|
383
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
384
|
-
if (!blockInfo.hasContent || !blockInfo.children) {
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
const { children } = blockInfo;
|
|
388
|
-
|
|
389
|
-
// A block can have an empty children node (the `childContainer`
|
|
390
|
-
// group), but then there is no first child to pull anything out
|
|
391
|
-
// of.
|
|
392
|
-
if (children.node.childCount === 0) {
|
|
393
|
-
return false;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
const selectionAtBlockEnd =
|
|
397
|
-
state.selection.from === blockInfo.contentEnd;
|
|
398
|
-
const selectionEmpty = state.selection.empty;
|
|
399
|
-
|
|
400
|
-
const firstChildBlockInfo = getBlockInfoAt(
|
|
401
|
-
state.doc,
|
|
402
|
-
children.childrenStart,
|
|
403
|
-
);
|
|
404
|
-
if (!firstChildBlockInfo.hasContent) {
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (selectionAtBlockEnd && selectionEmpty) {
|
|
409
|
-
return deleteBlockAndAppendContent(
|
|
410
|
-
chain(),
|
|
411
|
-
blockInfo,
|
|
412
|
-
firstChildBlockInfo,
|
|
413
|
-
children.node.childCount === 1
|
|
414
|
-
? children
|
|
415
|
-
: firstChildBlockInfo.block,
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
return false;
|
|
420
|
-
}),
|
|
421
|
-
// Merges block with the next one (at the same nesting level or lower),
|
|
422
|
-
// if one exists, the block has no children, and the selection is at the
|
|
423
|
-
// end of the block.
|
|
424
|
-
() =>
|
|
425
|
-
commands.command(({ state }) => {
|
|
426
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
427
|
-
if (!blockInfo.hasContent) {
|
|
428
|
-
return false;
|
|
429
|
-
}
|
|
430
|
-
const { block: blockContainer } = blockInfo;
|
|
431
|
-
|
|
432
|
-
const nextBlockInfo = getNextBlockInfo(
|
|
433
|
-
state.doc,
|
|
434
|
-
blockInfo.block.beforePos,
|
|
435
|
-
);
|
|
436
|
-
if (!nextBlockInfo || !nextBlockInfo.hasContent) {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
const selectionAtBlockEnd =
|
|
441
|
-
state.selection.from === blockInfo.contentEnd;
|
|
442
|
-
const selectionEmpty = state.selection.empty;
|
|
443
|
-
|
|
444
|
-
const posBetweenBlocks = blockContainer.afterPos;
|
|
445
|
-
|
|
446
|
-
if (selectionAtBlockEnd && selectionEmpty) {
|
|
447
|
-
return chain()
|
|
448
|
-
.command(mergeBlocksCommand(posBetweenBlocks))
|
|
449
|
-
.scrollIntoView()
|
|
450
|
-
.run();
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
return false;
|
|
454
|
-
}),
|
|
455
|
-
// Pull the next leaf across a layout block boundary. It may be inside
|
|
456
|
-
// the next sibling layout block, or follow the layout blocks we're leaving.
|
|
457
|
-
() =>
|
|
458
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
459
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
460
|
-
if (
|
|
461
|
-
!blockInfo.hasContent ||
|
|
462
|
-
state.selection.from !== blockInfo.contentEnd
|
|
463
|
-
) {
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
let $boundary = tr.doc.resolve(blockInfo.block.afterPos);
|
|
468
|
-
while (
|
|
469
|
-
!$boundary.nodeAfter &&
|
|
470
|
-
$boundary.depth > 0 &&
|
|
471
|
-
isLayoutNode($boundary.parent.type)
|
|
472
|
-
) {
|
|
473
|
-
$boundary = tr.doc.resolve($boundary.after());
|
|
474
|
-
}
|
|
475
|
-
const nextNode = $boundary.nodeAfter;
|
|
476
|
-
if (!nextNode) {
|
|
477
|
-
return false;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const crossedBoundary = $boundary.pos !== blockInfo.block.afterPos;
|
|
481
|
-
if (!crossedBoundary && !isLayoutNode(nextNode.type)) {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
const target = getFirstLeafBlock(
|
|
485
|
-
getBlockInfoFromNode(nextNode, $boundary.pos),
|
|
486
|
-
);
|
|
487
|
-
if (!target) {
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
if (dispatch) {
|
|
492
|
-
moveBlockOutAndPlaceCaret(
|
|
493
|
-
tr,
|
|
494
|
-
target.block,
|
|
495
|
-
blockInfo.block.afterPos,
|
|
496
|
-
);
|
|
497
|
-
}
|
|
498
|
-
return true;
|
|
499
|
-
}),
|
|
500
|
-
// Deletes the next block at either the same or lower nesting level, if
|
|
501
|
-
// the selection is empty and at the end of the block. If both the
|
|
502
|
-
// current and next blocks have inline content, the next block's
|
|
503
|
-
// content is appended to the current block's. The next block's own
|
|
504
|
-
// children are unindented before it's deleted.
|
|
505
|
-
() =>
|
|
506
|
-
commands.command(({ state }) => {
|
|
507
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
508
|
-
if (!blockInfo.hasContent) {
|
|
509
|
-
return false;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const selectionAtBlockEnd =
|
|
513
|
-
state.selection.from === blockInfo.contentEnd;
|
|
514
|
-
const selectionEmpty = state.selection.empty;
|
|
515
|
-
|
|
516
|
-
if (selectionAtBlockEnd && selectionEmpty) {
|
|
517
|
-
let nextBlockInfo: BlockInfo | undefined;
|
|
518
|
-
let ancestor: BlockInfo | undefined = blockInfo;
|
|
519
|
-
while (ancestor) {
|
|
520
|
-
nextBlockInfo = getNextBlockInfo(
|
|
521
|
-
state.doc,
|
|
522
|
-
ancestor.block.beforePos,
|
|
523
|
-
);
|
|
524
|
-
if (nextBlockInfo) {
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
527
|
-
ancestor = getParentBlockInfo(
|
|
528
|
-
state.doc,
|
|
529
|
-
ancestor.block.beforePos,
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
if (!nextBlockInfo || !nextBlockInfo.hasContent) {
|
|
533
|
-
return false;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
return deleteBlockAndAppendContent(
|
|
537
|
-
chain(),
|
|
538
|
-
blockInfo,
|
|
539
|
-
nextBlockInfo,
|
|
540
|
-
nextBlockInfo.block,
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
return false;
|
|
545
|
-
}),
|
|
546
|
-
// Deletes the current block if it's an empty block with inline content,
|
|
547
|
-
// and moves the selection to the next block.
|
|
548
|
-
() =>
|
|
549
|
-
commands.command(({ state }) => {
|
|
550
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
551
|
-
if (!blockInfo.hasContent) {
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const blockEmpty =
|
|
556
|
-
blockInfo.isContentEmpty && blockInfo.contentKind === "inline";
|
|
557
|
-
|
|
558
|
-
if (blockEmpty) {
|
|
559
|
-
const nextBlockInfo = getNextBlockInfo(
|
|
560
|
-
state.doc,
|
|
561
|
-
blockInfo.block.beforePos,
|
|
562
|
-
);
|
|
563
|
-
if (!nextBlockInfo || !nextBlockInfo.hasContent) {
|
|
564
|
-
return false;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const chainedCommands = chain();
|
|
568
|
-
|
|
569
|
-
chainedCommands.command(({ tr }) => {
|
|
570
|
-
tr.setSelection(
|
|
571
|
-
blockEdgeSelection(tr.doc, nextBlockInfo, "start"),
|
|
572
|
-
);
|
|
573
|
-
return true;
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
return chainedCommands
|
|
577
|
-
.deleteRange({
|
|
578
|
-
from: blockInfo.block.beforePos,
|
|
579
|
-
to: blockInfo.block.afterPos,
|
|
580
|
-
})
|
|
581
|
-
.scrollIntoView()
|
|
582
|
-
.run();
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
return false;
|
|
586
|
-
}),
|
|
587
|
-
// Deletes next block if it contains no content and isn't a table,
|
|
588
|
-
// when the selection is empty and at the end of the block. Moves the
|
|
589
|
-
// current block into the deleted block's place.
|
|
590
|
-
() =>
|
|
591
|
-
commands.command(({ state }) => {
|
|
592
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
593
|
-
|
|
594
|
-
if (!blockInfo.hasContent) {
|
|
595
|
-
return false;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
const selectionAtBlockEnd =
|
|
599
|
-
state.selection.from === blockInfo.contentEnd;
|
|
600
|
-
const selectionEmpty = state.selection.empty;
|
|
601
|
-
|
|
602
|
-
const nextBlockInfo = getNextBlockInfo(
|
|
603
|
-
state.doc,
|
|
604
|
-
blockInfo.block.beforePos,
|
|
605
|
-
);
|
|
606
|
-
if (!nextBlockInfo) {
|
|
607
|
-
return false;
|
|
608
|
-
}
|
|
609
|
-
if (!nextBlockInfo.hasContent) {
|
|
610
|
-
return false;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
if (nextBlockInfo && selectionAtBlockEnd && selectionEmpty) {
|
|
614
|
-
const nextBlockNotTableAndNoContent =
|
|
615
|
-
nextBlockInfo.contentKind === "none" ||
|
|
616
|
-
(nextBlockInfo.contentKind === "inline" &&
|
|
617
|
-
nextBlockInfo.isContentEmpty);
|
|
618
|
-
|
|
619
|
-
if (nextBlockNotTableAndNoContent) {
|
|
620
|
-
return chain()
|
|
621
|
-
.deleteRange({
|
|
622
|
-
from: nextBlockInfo.block.beforePos,
|
|
623
|
-
to: nextBlockInfo.block.afterPos,
|
|
624
|
-
})
|
|
625
|
-
.insertContentAt(
|
|
626
|
-
blockInfo.block.afterPos,
|
|
627
|
-
nextBlockInfo.children?.node.content ?? null,
|
|
628
|
-
)
|
|
629
|
-
.run();
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
return false;
|
|
634
|
-
}),
|
|
635
|
-
]);
|
|
636
|
-
|
|
637
|
-
const handleEnter = (withShift = false) => {
|
|
638
|
-
return this.editor.commands.first(({ commands, tr }) => [
|
|
639
|
-
// Resets an empty block (`keyboard.resetsTo`) if it resets on Enter
|
|
640
|
-
// (`keyboard.emptyEnterResets`), e.g. an empty list item turns into a
|
|
641
|
-
// paragraph. Its children stay.
|
|
642
|
-
() =>
|
|
643
|
-
commands.command(({ state }) => {
|
|
644
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
645
|
-
if (
|
|
646
|
-
!blockInfo.hasContent ||
|
|
647
|
-
!state.selection.empty ||
|
|
648
|
-
!blockInfo.isContentEmpty
|
|
649
|
-
) {
|
|
650
|
-
return false;
|
|
651
|
-
}
|
|
652
|
-
const keyboard = keyboardOf(blockInfo.block.node, state.doc);
|
|
653
|
-
if (!keyboard.emptyEnterResets) {
|
|
654
|
-
return false;
|
|
655
|
-
}
|
|
656
|
-
return commands.command(
|
|
657
|
-
updateBlockCommand(
|
|
658
|
-
blockInfo.block.beforePos,
|
|
659
|
-
keyboard.resetsTo as any,
|
|
660
|
-
),
|
|
661
|
-
);
|
|
662
|
-
}),
|
|
663
|
-
// Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
|
|
664
|
-
// of the block.
|
|
665
|
-
() =>
|
|
666
|
-
commands.command(({ state, tr }) => {
|
|
667
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
668
|
-
if (!blockInfo.hasContent) {
|
|
669
|
-
return false;
|
|
670
|
-
}
|
|
671
|
-
const { block: blockContainer } = blockInfo;
|
|
672
|
-
|
|
673
|
-
const { depth } = state.doc.resolve(blockContainer.beforePos);
|
|
674
|
-
|
|
675
|
-
const selectionAtBlockStart =
|
|
676
|
-
state.selection.$anchor.parentOffset === 0;
|
|
677
|
-
const selectionEmpty =
|
|
678
|
-
state.selection.anchor === state.selection.head;
|
|
679
|
-
const blockEmpty = blockInfo.isContentEmpty;
|
|
680
|
-
const blockIndented = depth > 1;
|
|
681
|
-
|
|
682
|
-
if (
|
|
683
|
-
selectionAtBlockStart &&
|
|
684
|
-
selectionEmpty &&
|
|
685
|
-
blockEmpty &&
|
|
686
|
-
blockIndented
|
|
687
|
-
) {
|
|
688
|
-
// Only outdents where the parent says so
|
|
689
|
-
// (`keyboard.emptyChildEnter: "outdent"`); otherwise the block
|
|
690
|
-
// leaves at the end, or a new child is added, further down.
|
|
691
|
-
const parent = getParentBlockInfo(
|
|
692
|
-
state.doc,
|
|
693
|
-
blockContainer.beforePos,
|
|
694
|
-
);
|
|
695
|
-
if (
|
|
696
|
-
parent &&
|
|
697
|
-
keyboardOf(parent.block.node, state.doc).emptyChildEnter !==
|
|
698
|
-
"outdent"
|
|
699
|
-
) {
|
|
700
|
-
return false;
|
|
701
|
-
}
|
|
702
|
-
return liftItem(
|
|
703
|
-
tr,
|
|
704
|
-
tr.doc.type.schema.nodes["blockContainer"],
|
|
705
|
-
tr.doc.type.schema.nodes["blockGroup"],
|
|
706
|
-
canOutdentFrom(tr.doc),
|
|
707
|
-
);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
return false;
|
|
711
|
-
}),
|
|
712
|
-
// Creates a hard break if the block is configured to do so
|
|
713
|
-
// (`keyboard.enter` / `keyboard.shiftEnter`).
|
|
714
|
-
() =>
|
|
715
|
-
commands.command(({ state }) => {
|
|
716
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
717
|
-
|
|
718
|
-
const blockSpec =
|
|
719
|
-
this.options.editor.schema.blockSpecs[blockInfo.blockNoteType];
|
|
720
|
-
|
|
721
|
-
const keyboard = keyboardOf(blockInfo.block.node, state.doc);
|
|
722
|
-
|
|
723
|
-
if (
|
|
724
|
-
// Enter as a line break makes Shift-Enter one too.
|
|
725
|
-
keyboard.enter === "line-break" ||
|
|
726
|
-
(withShift && keyboard.shiftEnter === "line-break")
|
|
727
|
-
) {
|
|
728
|
-
// "plain" blocks (e.g. code/math/diagram source) hold text only
|
|
729
|
-
// (their content is `text*`), which can't contain a `hardBreak`
|
|
730
|
-
// node - inserting one would split the block into a new one.
|
|
731
|
-
// They represent line breaks as literal newline characters.
|
|
732
|
-
if (blockSpec?.config?.content === "plain") {
|
|
733
|
-
tr.insertText("\n", tr.selection.head);
|
|
734
|
-
return true;
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
const marks =
|
|
738
|
-
tr.storedMarks ||
|
|
739
|
-
tr.selection.$head
|
|
740
|
-
.marks()
|
|
741
|
-
.filter((m) =>
|
|
742
|
-
this.editor.extensionManager.splittableMarks.includes(
|
|
743
|
-
m.type.name,
|
|
744
|
-
),
|
|
745
|
-
);
|
|
746
|
-
|
|
747
|
-
tr.insert(
|
|
748
|
-
tr.selection.head,
|
|
749
|
-
tr.doc.type.schema.nodes.hardBreak.create(),
|
|
750
|
-
).ensureMarks(marks);
|
|
751
|
-
return true;
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
return false;
|
|
755
|
-
}),
|
|
756
|
-
// If the block is empty and the last child of a block whose empty
|
|
757
|
-
// children exit at the end (`keyboard.emptyChildEnter:
|
|
758
|
-
// "exit-at-end"`, the default for layout blocks), moves the block out
|
|
759
|
-
// (double Enter exits the layout block). The block lands at the nearest enclosing position that
|
|
760
|
-
// accepts it. E.g. out of a column it skips the columnList, which
|
|
761
|
-
// holds only columns, and lands below it. Without this, Enter only
|
|
762
|
-
// ever creates new blocks within the layout block, so the cursor could
|
|
763
|
-
// never leave a trailing layout block. Shift+Enter still adds spacing
|
|
764
|
-
// inside a layout block. The first block of a body stays put: it is
|
|
765
|
-
// where the body begins, not a way out of it.
|
|
766
|
-
() =>
|
|
767
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
768
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
769
|
-
if (!blockInfo.hasContent) {
|
|
770
|
-
return false;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
const selectionEmpty =
|
|
774
|
-
state.selection.anchor === state.selection.head;
|
|
775
|
-
const blockEmpty = blockInfo.isContentEmpty;
|
|
776
|
-
if (!selectionEmpty || !blockEmpty) {
|
|
777
|
-
return false;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
const $pos = tr.doc.resolve(blockInfo.block.beforePos);
|
|
781
|
-
// Only fires on the layout block's last child.
|
|
782
|
-
if (tr.doc.resolve(blockInfo.block.afterPos).nodeAfter !== null) {
|
|
783
|
-
return false;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
const owner = getParentBlockInfo(tr.doc, blockInfo.block.beforePos);
|
|
787
|
-
if (!owner) {
|
|
788
|
-
return false;
|
|
789
|
-
}
|
|
790
|
-
if (
|
|
791
|
-
keyboardOf(owner.block.node, tr.doc).emptyChildEnter !==
|
|
792
|
-
"exit-at-end"
|
|
793
|
-
) {
|
|
794
|
-
return false;
|
|
795
|
-
}
|
|
796
|
-
// The first block of a body stays put: it is where the body
|
|
797
|
-
// begins, not a way out of it. (A layout block's own first child has
|
|
798
|
-
// no such role, so it may still leave.)
|
|
799
|
-
if ($pos.index() === 0 && owner.hasContent) {
|
|
800
|
-
return false;
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
const ownerAfterPos = ascendToInsertablePos(
|
|
804
|
-
tr.doc,
|
|
805
|
-
owner.block.afterPos,
|
|
806
|
-
state.schema.nodes["blockContainer"],
|
|
807
|
-
"after",
|
|
808
|
-
);
|
|
809
|
-
if (ownerAfterPos === undefined) {
|
|
810
|
-
return false;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
if (dispatch) {
|
|
814
|
-
moveBlockOutAndPlaceCaret(tr, blockInfo.block, ownerAfterPos);
|
|
815
|
-
tr.scrollIntoView();
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
return true;
|
|
819
|
-
}),
|
|
820
|
-
// Creates a new block and moves the selection to it if the current one is empty, while the selection is also
|
|
821
|
-
// empty & at the start of the block.
|
|
822
|
-
() =>
|
|
823
|
-
commands.command(({ state, dispatch, tr }) => {
|
|
824
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
825
|
-
if (!blockInfo.hasContent) {
|
|
826
|
-
return false;
|
|
827
|
-
}
|
|
828
|
-
const { block: blockContainer } = blockInfo;
|
|
829
|
-
|
|
830
|
-
const selectionAtBlockStart =
|
|
831
|
-
state.selection.$anchor.parentOffset === 0;
|
|
832
|
-
const selectionEmpty =
|
|
833
|
-
state.selection.anchor === state.selection.head;
|
|
834
|
-
const blockEmpty = blockInfo.isContentEmpty;
|
|
835
|
-
|
|
836
|
-
if (
|
|
837
|
-
selectionAtBlockStart &&
|
|
838
|
-
selectionEmpty &&
|
|
839
|
-
blockEmpty &&
|
|
840
|
-
keyboardOf(blockInfo.block.node, state.doc).enter !==
|
|
841
|
-
"into-children"
|
|
842
|
-
) {
|
|
843
|
-
const newBlockInsertionPos = blockContainer.afterPos;
|
|
844
|
-
const newBlockContentPos = newBlockInsertionPos + 2;
|
|
845
|
-
|
|
846
|
-
if (dispatch) {
|
|
847
|
-
// Creates a new block with the children of the current block,
|
|
848
|
-
// if it has any.
|
|
849
|
-
const newBlock = state.schema.nodes[
|
|
850
|
-
"blockContainer"
|
|
851
|
-
].createAndFill(
|
|
852
|
-
undefined,
|
|
853
|
-
[
|
|
854
|
-
state.schema.nodes["paragraph"].createAndFill() ||
|
|
855
|
-
undefined,
|
|
856
|
-
blockInfo.children?.node,
|
|
857
|
-
].filter((node) => node !== undefined),
|
|
858
|
-
)!;
|
|
859
|
-
|
|
860
|
-
// Inserts the new block and moves the selection to it.
|
|
861
|
-
tr.insert(newBlockInsertionPos, newBlock)
|
|
862
|
-
.setSelection(
|
|
863
|
-
new TextSelection(tr.doc.resolve(newBlockContentPos)),
|
|
864
|
-
)
|
|
865
|
-
.scrollIntoView();
|
|
866
|
-
|
|
867
|
-
// Deletes old block's children, as they have been moved to
|
|
868
|
-
// the new one.
|
|
869
|
-
if (blockInfo.children) {
|
|
870
|
-
tr.delete(
|
|
871
|
-
blockInfo.children.beforePos,
|
|
872
|
-
blockInfo.children.afterPos,
|
|
873
|
-
);
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
return true;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
return false;
|
|
881
|
-
}),
|
|
882
|
-
// Enter at the start of non-empty content inserts an empty block above
|
|
883
|
-
// it: the same type when the block's splits keep their type (lists),
|
|
884
|
-
// a paragraph otherwise, with default props. The block itself, with
|
|
885
|
-
// its id, props (e.g. a checklist item's checked state) and children,
|
|
886
|
-
// stays where it is (#550).
|
|
887
|
-
() =>
|
|
888
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
889
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
890
|
-
if (
|
|
891
|
-
!blockInfo.hasContent ||
|
|
892
|
-
blockInfo.contentKind === "table" ||
|
|
893
|
-
!state.selection.empty ||
|
|
894
|
-
blockInfo.isContentEmpty ||
|
|
895
|
-
state.selection.from !== blockInfo.contentStart
|
|
896
|
-
) {
|
|
897
|
-
return false;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
if (dispatch) {
|
|
901
|
-
const contentType = keyboardOf(blockInfo.block.node, state.doc)
|
|
902
|
-
.splitKeepsType
|
|
903
|
-
? blockInfo.content.node.type
|
|
904
|
-
: state.schema.nodes["paragraph"];
|
|
905
|
-
const newBlock = state.schema.nodes["blockContainer"].create(
|
|
906
|
-
undefined,
|
|
907
|
-
contentType.create(),
|
|
908
|
-
);
|
|
909
|
-
tr.insert(blockInfo.block.beforePos, newBlock).scrollIntoView();
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
return true;
|
|
913
|
-
}),
|
|
914
|
-
// Enter in the content of a block whose Enter goes into its children
|
|
915
|
-
// (`keyboard.enter: "into-children"`, e.g. an open toggle) starts its
|
|
916
|
-
// children rather than splitting the block in two: whatever follows
|
|
917
|
-
// the cursor becomes the first child, and the existing children stay
|
|
918
|
-
// where they are.
|
|
919
|
-
() =>
|
|
920
|
-
commands.command(({ state, tr, dispatch }) => {
|
|
921
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
922
|
-
if (!blockInfo.hasContent) {
|
|
923
|
-
return false;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
if (
|
|
927
|
-
keyboardOf(blockInfo.block.node, state.doc).enter !==
|
|
928
|
-
"into-children"
|
|
929
|
-
) {
|
|
930
|
-
return false;
|
|
931
|
-
}
|
|
932
|
-
if (!state.selection.empty) {
|
|
933
|
-
return false;
|
|
934
|
-
}
|
|
935
|
-
if (
|
|
936
|
-
state.selection.from < blockInfo.contentStart ||
|
|
937
|
-
state.selection.from > blockInfo.contentEnd
|
|
938
|
-
) {
|
|
939
|
-
return false;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
if (dispatch) {
|
|
943
|
-
// Everything after the cursor moves into the new block, so
|
|
944
|
-
// splitting the title mid-way puts its tail at the top of the
|
|
945
|
-
// body instead of handing the body to a new sibling.
|
|
946
|
-
const tail = blockInfo.content.node.cut(
|
|
947
|
-
state.selection.from - blockInfo.contentStart,
|
|
948
|
-
);
|
|
949
|
-
const newBlock = state.schema.nodes["blockContainer"].create(
|
|
950
|
-
undefined,
|
|
951
|
-
state.schema.nodes["paragraph"].create(undefined, tail.content),
|
|
952
|
-
);
|
|
953
|
-
|
|
954
|
-
tr.delete(state.selection.from, blockInfo.contentEnd);
|
|
955
|
-
|
|
956
|
-
const body = getBlockInfoAt(
|
|
957
|
-
tr.doc,
|
|
958
|
-
blockInfo.block.beforePos,
|
|
959
|
-
).children;
|
|
960
|
-
// Without a body yet, one is created around the new block.
|
|
961
|
-
const insertPos = body
|
|
962
|
-
? body.childrenStart
|
|
963
|
-
: tr.mapping.map(blockInfo.content.afterPos);
|
|
964
|
-
tr.insert(
|
|
965
|
-
insertPos,
|
|
966
|
-
body
|
|
967
|
-
? newBlock
|
|
968
|
-
: state.schema.nodes["blockGroup"].create(
|
|
969
|
-
undefined,
|
|
970
|
-
newBlock,
|
|
971
|
-
),
|
|
972
|
-
)
|
|
973
|
-
.setSelection(
|
|
974
|
-
new TextSelection(tr.doc.resolve(insertPos + (body ? 2 : 3))),
|
|
975
|
-
)
|
|
976
|
-
.scrollIntoView();
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
return true;
|
|
980
|
-
}),
|
|
981
|
-
// Splits the current block, moving content inside that's after the cursor to a new text block below. Also
|
|
982
|
-
// deletes the selection beforehand, if it's not empty.
|
|
983
|
-
() =>
|
|
984
|
-
commands.command(({ state, chain }) => {
|
|
985
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
986
|
-
if (!blockInfo.hasContent) {
|
|
987
|
-
return false;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
const selectionAtBlockStart =
|
|
991
|
-
state.selection.$anchor.parentOffset === 0;
|
|
992
|
-
const blockEmpty = blockInfo.isContentEmpty;
|
|
993
|
-
|
|
994
|
-
if (!blockEmpty) {
|
|
995
|
-
const keyboard = keyboardOf(blockInfo.block.node, state.doc);
|
|
996
|
-
const keepType = selectionAtBlockStart || keyboard.splitKeepsType;
|
|
997
|
-
chain()
|
|
998
|
-
.deleteSelection()
|
|
999
|
-
.command(
|
|
1000
|
-
splitBlockCommand(
|
|
1001
|
-
state.selection.from,
|
|
1002
|
-
keepType,
|
|
1003
|
-
selectionAtBlockStart,
|
|
1004
|
-
keyboard.splitKeepsChildren,
|
|
1005
|
-
),
|
|
1006
|
-
)
|
|
1007
|
-
.scrollIntoView()
|
|
1008
|
-
.run();
|
|
1009
|
-
|
|
1010
|
-
return true;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
return false;
|
|
1014
|
-
}),
|
|
1015
|
-
]);
|
|
1016
|
-
};
|
|
1017
|
-
|
|
1018
|
-
const options = this.options;
|
|
1019
|
-
function handleTab(shift: boolean) {
|
|
1020
|
-
const { editor, tabBehavior } = options;
|
|
1021
|
-
if (
|
|
1022
|
-
tabBehavior !== "prefer-indent" &&
|
|
1023
|
-
(editor.getExtension(FormattingToolbarExtension)?.store.state ||
|
|
1024
|
-
editor.getExtension(FilePanelExtension)?.store.state !== undefined)
|
|
1025
|
-
) {
|
|
1026
|
-
// Let the browser navigate into and out of an open toolbar.
|
|
1027
|
-
return false;
|
|
1028
|
-
}
|
|
1029
|
-
return shift ? unnestBlock(editor) : nestBlock(editor);
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
return {
|
|
1033
|
-
Backspace: handleBackspace,
|
|
1034
|
-
Delete: handleDelete,
|
|
1035
|
-
Enter: () => handleEnter(),
|
|
1036
|
-
"Shift-Enter": () => handleEnter(true),
|
|
1037
|
-
Tab: () => handleTab(false),
|
|
1038
|
-
"Shift-Tab": () => handleTab(true),
|
|
1039
|
-
"Shift-Mod-ArrowUp": () => {
|
|
1040
|
-
this.options.editor.moveBlocksUp();
|
|
1041
|
-
return true;
|
|
1042
|
-
},
|
|
1043
|
-
"Shift-Mod-ArrowDown": () => {
|
|
1044
|
-
this.options.editor.moveBlocksDown();
|
|
1045
|
-
return true;
|
|
1046
|
-
},
|
|
1047
|
-
"Mod-z": () => this.options.editor.undo(),
|
|
1048
|
-
"Mod-y": () => this.options.editor.redo(),
|
|
1049
|
-
"Shift-Mod-z": () => this.options.editor.redo(),
|
|
1050
|
-
"Mod-a": () => {
|
|
1051
|
-
const view = this.editor.view;
|
|
1052
|
-
const { doc, selection, tr } = view.state;
|
|
1053
|
-
|
|
1054
|
-
// By default, the first `Mod-a` selects the current block's content,
|
|
1055
|
-
// and any subsequent `Mod-a` expands the selection to the whole
|
|
1056
|
-
// document. We use `TextSelection`s rather than an `AllSelection` for the
|
|
1057
|
-
// whole-document case as the latter creates from/to positions outside a
|
|
1058
|
-
// block, causing errors when calling e.g. `getBlock`.
|
|
1059
|
-
const wholeDocSelection = TextSelection.between(
|
|
1060
|
-
Selection.atStart(doc).$from,
|
|
1061
|
-
Selection.atEnd(doc).$to,
|
|
1062
|
-
);
|
|
1063
|
-
|
|
1064
|
-
if (this.options.selectAllBehavior === "document") {
|
|
1065
|
-
view.dispatch(tr.setSelection(wholeDocSelection));
|
|
1066
|
-
return true;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
// Selection covering just the current block's content. `between` snaps
|
|
1070
|
-
// to the nearest inline positions inside the block, so it also handles
|
|
1071
|
-
// blocks whose content isn't directly inline - e.g. table blocks, where
|
|
1072
|
-
// it spans from the first cell to the last. Blocks without any inline
|
|
1073
|
-
// content (e.g. images) are ignored, as `between` would then spill
|
|
1074
|
-
// outside the block, and select-all falls through to the whole document.
|
|
1075
|
-
let blockSelection: Selection | undefined;
|
|
1076
|
-
const blockInfo = getBlockInfoFromSelection(view.state);
|
|
1077
|
-
if (blockInfo.hasContent) {
|
|
1078
|
-
const contentFrom = blockInfo.contentStart;
|
|
1079
|
-
const contentTo = blockInfo.contentEnd;
|
|
1080
|
-
const candidate = TextSelection.between(
|
|
1081
|
-
doc.resolve(contentFrom),
|
|
1082
|
-
doc.resolve(contentTo),
|
|
1083
|
-
);
|
|
1084
|
-
|
|
1085
|
-
if (
|
|
1086
|
-
!candidate.empty &&
|
|
1087
|
-
candidate.from >= contentFrom &&
|
|
1088
|
-
candidate.to <= contentTo
|
|
1089
|
-
) {
|
|
1090
|
-
blockSelection = candidate;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
// Expands to the whole document when there's no selectable block content
|
|
1095
|
-
// to select first, when the selection already extends beyond the current
|
|
1096
|
-
// block, or when the current block's content is already fully selected.
|
|
1097
|
-
const selectWholeDoc =
|
|
1098
|
-
!blockSelection ||
|
|
1099
|
-
selection.from < blockSelection.from ||
|
|
1100
|
-
selection.to > blockSelection.to ||
|
|
1101
|
-
(selection.from === blockSelection.from &&
|
|
1102
|
-
selection.to === blockSelection.to);
|
|
1103
|
-
|
|
1104
|
-
if (blockSelection && !selectWholeDoc) {
|
|
1105
|
-
tr.setSelection(blockSelection).scrollIntoView();
|
|
1106
|
-
} else {
|
|
1107
|
-
tr.setSelection(wholeDocSelection);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
view.dispatch(tr);
|
|
1111
|
-
|
|
1112
|
-
return true;
|
|
1113
|
-
},
|
|
1114
|
-
};
|
|
1115
|
-
},
|
|
1116
|
-
});
|