@blocknote/core 0.51.3 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BlockNoteExtension-B_IEJHS8.js +38 -0
- package/dist/BlockNoteExtension-B_IEJHS8.js.map +1 -0
- package/dist/BlockNoteExtension-M0znTzxP.cjs +2 -0
- package/dist/BlockNoteExtension-M0znTzxP.cjs.map +1 -0
- package/dist/ThreadStore-Bx-gSEh1.cjs +2 -0
- package/dist/ThreadStore-Bx-gSEh1.cjs.map +1 -0
- package/dist/ThreadStore-et9wB5Xt.js +11 -0
- package/dist/ThreadStore-et9wB5Xt.js.map +1 -0
- package/dist/UserStore-DCG6lsla.cjs +2 -0
- package/dist/UserStore-DCG6lsla.cjs.map +1 -0
- package/dist/UserStore-QbbPFj0z.js +73 -0
- package/dist/UserStore-QbbPFj0z.js.map +1 -0
- package/dist/blocknote.cjs +1 -1
- package/dist/blocknote.js +6 -7
- package/dist/blocks-BqHv0xhc.cjs +12 -0
- package/dist/blocks-BqHv0xhc.cjs.map +1 -0
- package/dist/{blocks-D0lMxErU.js → blocks-CiuUGa1E.js} +1096 -998
- package/dist/blocks-CiuUGa1E.js.map +1 -0
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +75 -340
- package/dist/comments.js.map +1 -1
- package/dist/{en-Cj5r8sW_.cjs → en-C5Z4Ag9_.cjs} +2 -2
- package/dist/en-C5Z4Ag9_.cjs.map +1 -0
- package/dist/{en-B9hMApn4.js → en-CGKXfWma.js} +9 -1
- package/dist/en-CGKXfWma.js.map +1 -0
- package/dist/{extensions-D2mx2C9y.js → extensions-CrUGDOks.js} +655 -583
- package/dist/extensions-CrUGDOks.js.map +1 -0
- package/dist/extensions-Ghr9QqqR.cjs +52 -0
- package/dist/extensions-Ghr9QqqR.cjs.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +4 -4
- package/dist/locales.cjs +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +177 -1
- package/dist/locales.js.map +1 -1
- package/dist/{src-Dvmif2FY.js → src-DTF83Cl9.js} +1243 -1297
- package/dist/src-DTF83Cl9.js.map +1 -0
- package/dist/src-OfbaVbMw.cjs +21 -0
- package/dist/src-OfbaVbMw.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/y.cjs +2 -0
- package/dist/y.cjs.map +1 -0
- package/dist/y.js +989 -0
- package/dist/y.js.map +1 -0
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +535 -14
- package/dist/yjs.js.map +1 -1
- package/package.json +46 -19
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.ts +1 -1
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +25 -20
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +39 -29
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.test.ts +2 -2
- package/src/api/blockManipulation/commands/nestBlock/nestBlock.ts +4 -8
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +21 -9
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +6 -5
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts +362 -4
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +240 -30
- package/src/api/blockManipulation/getBlock/getBlock.ts +4 -9
- package/src/api/blockManipulation/selections/selection.ts +3 -6
- package/src/api/blockManipulation/selections/textCursorPosition.ts +10 -10
- package/src/api/blockManipulation/setupTestEnv.ts +1 -1
- package/src/api/blockManipulation/tables/tables.test.ts +1 -1
- package/src/api/clipboard/fromClipboard/fileDropExtension.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +8 -4
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +2 -1
- package/src/api/exporters/markdown/htmlToMarkdown.ts +79 -43
- package/src/api/getBlockInfoFromPos.test.ts +256 -0
- package/src/api/getBlockInfoFromPos.ts +53 -15
- package/src/api/getBlocksChangedByTransaction.test.ts +2 -1
- package/src/api/getBlocksChangedByTransaction.ts +6 -6
- package/src/api/nodeConversions/blockToNode.test.ts +113 -0
- package/src/api/nodeConversions/blockToNode.ts +15 -3
- package/src/api/nodeConversions/fragmentToBlocks.ts +2 -4
- package/src/api/nodeConversions/nodeToBlock.ts +28 -58
- package/src/api/nodeUtil.ts +6 -2
- package/src/api/parsers/html/parseHTML.ts +1 -1
- package/src/api/parsers/html/util/nestedLists.test.ts +1 -1
- package/src/api/parsers/markdown/detectMarkdown.test.ts +1 -1
- package/src/api/parsers/markdown/markdownToHtml.ts +228 -82
- package/src/api/pmUtil.ts +18 -1
- package/src/api/positionMapping.test.ts +20 -345
- package/src/api/positionMapping.ts +13 -83
- package/src/blocks/Audio/block.ts +1 -1
- package/src/blocks/Code/block.test.ts +14 -7
- package/src/blocks/Code/block.ts +2 -2
- package/src/blocks/Image/block.ts +1 -1
- package/src/blocks/ListItem/CheckListItem/block.test.ts +1 -1
- package/src/blocks/ListItem/ListItemKeyboardShortcuts.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.test.ts +4 -11
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +47 -50
- package/src/blocks/Table/TableExtension.test.ts +129 -0
- package/src/blocks/Table/TableExtension.ts +23 -20
- package/src/blocks/Table/block.ts +18 -5
- package/src/blocks/Video/block.ts +1 -1
- package/src/blocks/utils/listItemEnterHandler.ts +3 -2
- package/src/comments/extension.ts +30 -21
- package/src/comments/index.ts +0 -3
- package/src/comments/mark.ts +4 -0
- package/src/comments/threadstore/ThreadStore.ts +4 -8
- package/src/comments/types.ts +0 -8
- package/src/editor/Block.css +307 -3
- package/src/editor/BlockNoteEditor.test.ts +39 -18
- package/src/editor/BlockNoteEditor.ts +22 -57
- package/src/editor/BlockNoteExtension.test.ts +1 -1
- package/src/editor/managers/BlockManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/ExtensionManager.test.ts +249 -0
- package/src/editor/managers/ExtensionManager/extensions.ts +7 -18
- package/src/editor/managers/ExtensionManager/index.ts +168 -68
- package/src/editor/managers/StateManager.ts +4 -3
- package/src/editor/performance.test.ts +14 -1
- package/src/editor/transformPasted.test.ts +1 -1
- package/src/extensions/Placeholder/Placeholder.ts +1 -0
- package/src/extensions/PositionMapping/PositionMapping.ts +68 -0
- package/src/extensions/PreviousBlockType/PreviousBlockType.test.ts +14 -1
- package/src/extensions/PreviousBlockType/PreviousBlockType.ts +14 -11
- package/src/extensions/SideMenu/SideMenu.ts +9 -2
- package/src/extensions/SuggestionMenu/SuggestionMenu.test.ts +1 -1
- package/src/extensions/TableHandles/TableHandles.ts +18 -20
- package/src/extensions/TrailingNode/TrailingNode.ts +33 -1
- package/src/extensions/Versioning/Versioning.test.ts +435 -0
- package/src/extensions/Versioning/Versioning.ts +628 -0
- package/src/extensions/Versioning/inMemoryVersioning.test.ts +469 -0
- package/src/extensions/Versioning/inMemoryVersioning.ts +263 -0
- package/src/extensions/Versioning/index.ts +2 -0
- package/src/extensions/index.ts +6 -9
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.ts +155 -0
- package/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +6 -8
- package/src/extensions/tiptap-extensions/Link/helpers/autolink.ts +9 -9
- package/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts +8 -10
- package/src/extensions/tiptap-extensions/Link/helpers/whitespace.ts +2 -2
- package/src/extensions/tiptap-extensions/Link/link.test.ts +26 -22
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.ts +187 -0
- package/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts +37 -24
- package/src/extensions/tiptap-extensions/index.ts +1 -25
- package/src/i18n/locales/ar.ts +9 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/en.ts +10 -1
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fa.ts +11 -1
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/he.ts +10 -1
- package/src/i18n/locales/hr.ts +10 -0
- package/src/i18n/locales/is.ts +10 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/ja.ts +9 -0
- package/src/i18n/locales/ko.ts +9 -0
- package/src/i18n/locales/nl.ts +10 -0
- package/src/i18n/locales/no.ts +10 -0
- package/src/i18n/locales/pl.ts +9 -0
- package/src/i18n/locales/pt.ts +10 -0
- package/src/i18n/locales/ru.ts +10 -0
- package/src/i18n/locales/sk.ts +10 -1
- package/src/i18n/locales/uk.ts +9 -0
- package/src/i18n/locales/uz.ts +9 -0
- package/src/i18n/locales/vi.ts +9 -0
- package/src/i18n/locales/zh-tw.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +2 -0
- package/src/pm-nodes/BlockContainer.ts +4 -1
- package/src/pm-nodes/BlockGroup.ts +4 -1
- package/src/pm-nodes/Doc.ts +4 -1
- package/src/pm-nodes/suggestionMarks.ts +43 -0
- package/src/schema/blocks/createSpec.test.ts +123 -0
- package/src/schema/blocks/createSpec.ts +82 -24
- package/src/schema/blocks/extendBlockSpec.test.ts +188 -0
- package/src/schema/blocks/internal.ts +13 -43
- package/src/schema/blocks/types.ts +69 -22
- package/src/schema/contentTypePropagation.test.ts +182 -0
- package/src/schema/index.ts +1 -0
- package/src/schema/inlineContent/internal.ts +1 -1
- package/src/schema/inlineContent/types.ts +3 -3
- package/src/schema/markGroups.ts +50 -0
- package/src/user/UserStore.ts +199 -0
- package/src/user/createUserStore.test.ts +126 -0
- package/src/user/index.ts +2 -0
- package/src/user/userColors.ts +72 -0
- package/src/util/string.ts +1 -1
- package/src/util/topo-sort.test.ts +1 -1
- package/src/util/typescript.ts +2 -1
- package/src/vite-env.d.ts +1 -1
- package/src/y/README.md +5 -0
- package/src/{comments/threadstore/yjs → y/comments}/RESTYjsThreadStore.ts +8 -14
- package/src/y/comments/YjsThreadStore.test.ts +295 -0
- package/src/y/comments/YjsThreadStore.ts +358 -0
- package/src/y/comments/YjsThreadStoreBase.ts +50 -0
- package/src/y/comments/index.ts +3 -0
- package/src/y/comments/yjsHelpers.ts +125 -0
- package/src/y/extensions/AttributionExtension.test.ts +86 -0
- package/src/y/extensions/AttributionExtension.ts +378 -0
- package/src/y/extensions/DiffVersioningExtension.test.ts +193 -0
- package/src/y/extensions/DiffVersioningExtension.ts +228 -0
- package/src/y/extensions/ForkYDoc.test.ts +253 -0
- package/src/y/extensions/ForkYDoc.ts +108 -0
- package/src/y/extensions/RelativePositionMapping.test.ts +418 -0
- package/src/y/extensions/RelativePositionMapping.ts +49 -0
- package/src/y/extensions/Suggestions.ts +174 -0
- package/src/y/extensions/Versioning.test.ts +395 -0
- package/src/y/extensions/Versioning.ts +115 -0
- package/src/y/extensions/YAttributionMarks.ts +320 -0
- package/src/{extensions/Collaboration → y/extensions}/YCursorPlugin.ts +15 -7
- package/src/y/extensions/YSync.ts +125 -0
- package/src/y/extensions/blockMatchNodes.ts +182 -0
- package/src/y/extensions/index.ts +156 -0
- package/src/y/index.ts +4 -0
- package/src/y/utils.test.ts +1042 -0
- package/src/y/utils.ts +242 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all-after.json +50 -0
- package/src/y/versioning/__test__/fixtures/activity-all.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-all.json +20 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.bin +0 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-after.json +32 -0
- package/src/y/versioning/__test__/fixtures/activity-filtered-before.json +1 -0
- package/src/y/versioning/__test__/fixtures/changeset.bin +0 -0
- package/src/y/versioning/__test__/fixtures/patch-response.json +4 -0
- package/src/y/versioning/__test__/yhub.test.ts +752 -0
- package/src/y/versioning/index.ts +1 -0
- package/src/y/versioning/yhub.ts +631 -0
- package/src/yjs/README.md +5 -0
- package/src/yjs/comments/RESTYjsThreadStore.ts +166 -0
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.test.ts +3 -3
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.ts +7 -3
- package/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.ts +3 -3
- package/src/yjs/comments/index.ts +3 -0
- package/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.ts +5 -1
- package/src/yjs/extensions/FixUpSchema.test.ts +421 -0
- package/src/yjs/extensions/FixUpSchema.ts +88 -0
- package/src/yjs/extensions/ForkYDoc.test.ts +216 -0
- package/src/{extensions/Collaboration → yjs/extensions}/ForkYDoc.ts +38 -57
- package/src/yjs/extensions/RelativePositionMapping.test.ts +418 -0
- package/src/yjs/extensions/RelativePositionMapping.ts +71 -0
- package/src/yjs/extensions/Versioning.test.ts +549 -0
- package/src/yjs/extensions/Versioning.ts +83 -0
- package/src/yjs/extensions/YCursorPlugin.ts +201 -0
- package/src/{extensions/Collaboration → yjs/extensions}/YSync.ts +1 -1
- package/src/yjs/extensions/index.ts +89 -0
- package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.test.ts +1 -1
- package/src/yjs/index.ts +2 -0
- package/src/yjs/utils.test.ts +5 -15
- package/src/yjs/utils.ts +36 -0
- package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +3 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/api/getBlockInfoFromPos.d.ts +5 -9
- package/types/src/api/nodeConversions/nodeToBlock.d.ts +4 -6
- package/types/src/api/pmUtil.d.ts +12 -1
- package/types/src/blocks/Audio/block.d.ts +2 -2
- package/types/src/blocks/Code/block.d.ts +2 -2
- package/types/src/blocks/File/block.d.ts +2 -2
- package/types/src/blocks/Heading/block.d.ts +21 -21
- package/types/src/blocks/Image/block.d.ts +3 -3
- package/types/src/blocks/ListItem/CheckListItem/block.d.ts +6 -6
- package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +6 -6
- package/types/src/blocks/Video/block.d.ts +3 -3
- package/types/src/blocks/defaultBlocks.d.ts +17 -17
- package/types/src/comments/extension.d.ts +18 -5
- package/types/src/comments/index.d.ts +0 -3
- package/types/src/comments/threadstore/ThreadStore.d.ts +4 -8
- package/types/src/comments/types.d.ts +0 -8
- package/types/src/editor/BlockNoteEditor.d.ts +8 -9
- package/types/src/editor/managers/BlockManager.d.ts +1 -1
- package/types/src/editor/managers/ExtensionManager/ExtensionManager.test.d.ts +1 -0
- package/types/src/editor/managers/ExtensionManager/extensions.d.ts +2 -2
- package/types/src/editor/managers/ExtensionManager/index.d.ts +13 -0
- package/types/src/editor/managers/SelectionManager.d.ts +1 -1
- package/types/src/extensions/PositionMapping/PositionMapping.d.ts +4 -0
- package/types/src/extensions/TableHandles/TableHandles.d.ts +6 -6
- package/types/src/extensions/Versioning/Versioning.d.ts +352 -0
- package/types/src/extensions/Versioning/Versioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.d.ts +37 -0
- package/types/src/extensions/Versioning/inMemoryVersioning.test.d.ts +1 -0
- package/types/src/extensions/Versioning/index.d.ts +2 -0
- package/types/src/extensions/index.d.ts +6 -9
- package/types/src/extensions/tiptap-extensions/KeyboardShortcuts/KeyboardShortcutsExtension.test.d.ts +1 -0
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.d.ts +6 -1
- package/types/src/extensions/tiptap-extensions/UniqueID/UniqueID.test.d.ts +4 -0
- package/types/src/extensions/tiptap-extensions/index.d.ts +1 -5
- package/types/src/i18n/locales/en.d.ts +9 -1
- package/types/src/i18n/locales/fa.d.ts +9 -1
- package/types/src/i18n/locales/sk.d.ts +9 -1
- package/types/src/index.d.ts +2 -0
- package/types/src/pm-nodes/suggestionMarks.d.ts +26 -0
- package/types/src/schema/blocks/createSpec.d.ts +4 -4
- package/types/src/schema/blocks/createSpec.test.d.ts +1 -0
- package/types/src/schema/blocks/extendBlockSpec.test.d.ts +1 -0
- package/types/src/schema/blocks/internal.d.ts +5 -7
- package/types/src/schema/blocks/types.d.ts +22 -14
- package/types/src/schema/contentTypePropagation.test.d.ts +1 -0
- package/types/src/schema/index.d.ts +1 -0
- package/types/src/schema/inlineContent/types.d.ts +3 -3
- package/types/src/schema/markGroups.d.ts +33 -0
- package/types/src/user/UserStore.d.ts +105 -0
- package/types/src/user/createUserStore.test.d.ts +1 -0
- package/types/src/user/index.d.ts +2 -0
- package/types/src/user/userColors.d.ts +36 -0
- package/types/src/y/comments/RESTYjsThreadStore.d.ts +77 -0
- package/types/src/y/comments/YjsThreadStore.d.ts +79 -0
- package/types/src/y/comments/YjsThreadStore.test.d.ts +1 -0
- package/types/src/y/comments/YjsThreadStoreBase.d.ts +15 -0
- package/types/src/y/comments/index.d.ts +3 -0
- package/types/src/y/comments/yjsHelpers.d.ts +13 -0
- package/types/src/y/extensions/AttributionExtension.d.ts +74 -0
- package/types/src/y/extensions/AttributionExtension.test.d.ts +1 -0
- package/types/src/y/extensions/DiffVersioningExtension.d.ts +69 -0
- package/types/src/y/extensions/DiffVersioningExtension.test.d.ts +1 -0
- package/types/src/{extensions/Collaboration → y/extensions}/ForkYDoc.d.ts +4 -2
- package/types/src/y/extensions/ForkYDoc.test.d.ts +1 -0
- package/types/src/y/extensions/RelativePositionMapping.d.ts +4 -0
- package/types/src/y/extensions/RelativePositionMapping.test.d.ts +1 -0
- package/types/src/y/extensions/Suggestions.d.ts +36 -0
- package/types/src/y/extensions/Versioning.d.ts +17 -0
- package/types/src/y/extensions/Versioning.test.d.ts +1 -0
- package/types/src/y/extensions/YAttributionMarks.d.ts +67 -0
- package/types/src/y/extensions/YCursorPlugin.d.ts +14 -0
- package/types/src/y/extensions/YSync.d.ts +32 -0
- package/types/src/y/extensions/blockMatchNodes.d.ts +25 -0
- package/types/src/y/extensions/index.d.ts +189 -0
- package/types/src/y/index.d.ts +4 -0
- package/types/src/y/utils.d.ts +82 -0
- package/types/src/y/utils.test.d.ts +1 -0
- package/types/src/y/versioning/__test__/yhub.test.d.ts +1 -0
- package/types/src/y/versioning/index.d.ts +1 -0
- package/types/src/y/versioning/yhub.d.ts +87 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/RESTYjsThreadStore.d.ts +6 -10
- package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStore.d.ts +3 -3
- package/types/src/yjs/comments/YjsThreadStore.test.d.ts +1 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/YjsThreadStoreBase.d.ts +3 -3
- package/types/src/yjs/comments/index.d.ts +3 -0
- package/types/src/{comments/threadstore/yjs → yjs/comments}/yjsHelpers.d.ts +1 -1
- package/types/src/yjs/extensions/FixUpSchema.d.ts +3 -0
- package/types/src/yjs/extensions/FixUpSchema.test.d.ts +1 -0
- package/types/src/yjs/extensions/ForkYDoc.d.ts +27 -0
- package/types/src/yjs/extensions/ForkYDoc.test.d.ts +1 -0
- package/types/src/yjs/extensions/RelativePositionMapping.d.ts +4 -0
- package/types/src/yjs/extensions/RelativePositionMapping.test.d.ts +1 -0
- package/types/src/yjs/extensions/Versioning.d.ts +26 -0
- package/types/src/yjs/extensions/Versioning.test.d.ts +1 -0
- package/types/src/{extensions/Collaboration → yjs/extensions}/YCursorPlugin.d.ts +5 -2
- package/types/src/{extensions/Collaboration → yjs/extensions}/YSync.d.ts +1 -1
- package/types/src/{extensions/Collaboration/Collaboration.d.ts → yjs/extensions/index.d.ts} +36 -15
- package/types/src/yjs/extensions/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
- package/types/src/yjs/index.d.ts +2 -0
- package/types/src/yjs/utils.d.ts +5 -0
- package/dist/BlockNoteExtension-B6RhuQ3V.js +0 -27
- package/dist/BlockNoteExtension-B6RhuQ3V.js.map +0 -1
- package/dist/BlockNoteExtension-ab0REuob.cjs +0 -2
- package/dist/BlockNoteExtension-ab0REuob.cjs.map +0 -1
- package/dist/EventEmitter-CuPnGDYt.js +0 -22
- package/dist/EventEmitter-CuPnGDYt.js.map +0 -1
- package/dist/EventEmitter-DHdSnYCD.cjs +0 -2
- package/dist/EventEmitter-DHdSnYCD.cjs.map +0 -1
- package/dist/ShowSelection-BsHFfdMi.js +0 -29
- package/dist/ShowSelection-BsHFfdMi.js.map +0 -1
- package/dist/ShowSelection-DhXglbt8.cjs +0 -2
- package/dist/ShowSelection-DhXglbt8.cjs.map +0 -1
- package/dist/blocks-D0lMxErU.js.map +0 -1
- package/dist/blocks-KyMOxPT3.cjs +0 -11
- package/dist/blocks-KyMOxPT3.cjs.map +0 -1
- package/dist/en-B9hMApn4.js.map +0 -1
- package/dist/en-Cj5r8sW_.cjs.map +0 -1
- package/dist/extensions-Cutrafjg.cjs +0 -52
- package/dist/extensions-Cutrafjg.cjs.map +0 -1
- package/dist/extensions-D2mx2C9y.js.map +0 -1
- package/dist/src-D5R5YzV7.cjs +0 -21
- package/dist/src-D5R5YzV7.cjs.map +0 -1
- package/dist/src-Dvmif2FY.js.map +0 -1
- package/src/comments/userstore/UserStore.ts +0 -72
- package/src/extensions/Collaboration/Collaboration.ts +0 -55
- package/src/extensions/Collaboration/ForkYDoc.test.ts +0 -179
- package/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.ts +0 -175
- package/types/src/comments/userstore/UserStore.d.ts +0 -31
- package/types/src/extensions/tiptap-extensions/Suggestions/SuggestionMarks.d.ts +0 -4
- /package/src/{extensions/Collaboration → yjs/extensions}/YUndo.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor-forked.json +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-editor.json +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap-forked.html +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/__snapshots__/fork-yjs-snap.html +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.ts +0 -0
- /package/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.ts +0 -0
- /package/types/src/{comments/threadstore/yjs/YjsThreadStore.test.d.ts → api/getBlockInfoFromPos.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/ForkYDoc.test.d.ts → api/nodeConversions/blockToNode.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts → blocks/Table/TableExtension.test.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/YUndo.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/SchemaMigration.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/index.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/migrationRule.d.ts +0 -0
- /package/types/src/{extensions/Collaboration → yjs/extensions}/schemaMigration/migrationRules/moveColorAttributes.d.ts +0 -0
|
@@ -32,8 +32,7 @@ function isAlphanumeric(char: string | undefined): boolean {
|
|
|
32
32
|
*/
|
|
33
33
|
function isIntraword(text: string, i: number, delimLen: number): boolean {
|
|
34
34
|
const before = i > 0 ? text[i - 1] : undefined;
|
|
35
|
-
const after =
|
|
36
|
-
i + delimLen < text.length ? text[i + delimLen] : undefined;
|
|
35
|
+
const after = i + delimLen < text.length ? text[i + delimLen] : undefined;
|
|
37
36
|
return isAlphanumeric(before) && isAlphanumeric(after);
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -41,14 +40,16 @@ function isIntraword(text: string, i: number, delimLen: number): boolean {
|
|
|
41
40
|
|
|
42
41
|
type InlineTokenizer = (
|
|
43
42
|
text: string,
|
|
44
|
-
i: number
|
|
43
|
+
i: number,
|
|
45
44
|
) => { html: string; end: number } | null;
|
|
46
45
|
|
|
47
46
|
function tryBackslashEscape(
|
|
48
47
|
text: string,
|
|
49
|
-
i: number
|
|
48
|
+
i: number,
|
|
50
49
|
): { html: string; end: number } | null {
|
|
51
|
-
if (text[i] !== "\\" || i + 1 >= text.length) {
|
|
50
|
+
if (text[i] !== "\\" || i + 1 >= text.length) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
52
53
|
const next = text[i + 1];
|
|
53
54
|
// Hard line break: backslash at end of line
|
|
54
55
|
if (next === "\n") {
|
|
@@ -63,39 +64,47 @@ function tryBackslashEscape(
|
|
|
63
64
|
|
|
64
65
|
function tryInlineCode(
|
|
65
66
|
text: string,
|
|
66
|
-
i: number
|
|
67
|
+
i: number,
|
|
67
68
|
): { html: string; end: number } | null {
|
|
68
|
-
if (text[i] !== "`") {
|
|
69
|
+
if (text[i] !== "`") {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
69
72
|
return parseInlineCode(text, i);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
function tryImage(
|
|
73
76
|
text: string,
|
|
74
|
-
i: number
|
|
77
|
+
i: number,
|
|
75
78
|
): { html: string; end: number } | null {
|
|
76
|
-
if (text[i] !== "!" || text[i + 1] !== "[") {
|
|
79
|
+
if (text[i] !== "!" || text[i + 1] !== "[") {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
77
82
|
return parseImage(text, i);
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
function tryLink(
|
|
81
86
|
text: string,
|
|
82
|
-
i: number
|
|
87
|
+
i: number,
|
|
83
88
|
): { html: string; end: number } | null {
|
|
84
|
-
if (text[i] !== "[") {
|
|
89
|
+
if (text[i] !== "[") {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
85
92
|
return parseLink(text, i);
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
function tryStrikethrough(
|
|
89
96
|
text: string,
|
|
90
|
-
i: number
|
|
97
|
+
i: number,
|
|
91
98
|
): { html: string; end: number } | null {
|
|
92
|
-
if (text[i] !== "~" || text[i + 1] !== "~") {
|
|
99
|
+
if (text[i] !== "~" || text[i + 1] !== "~") {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
93
102
|
return parseDelimited(text, i, "~~", "<del>", "</del>");
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
function tryBoldItalic(
|
|
97
106
|
text: string,
|
|
98
|
-
i: number
|
|
107
|
+
i: number,
|
|
99
108
|
): { html: string; end: number } | null {
|
|
100
109
|
if (
|
|
101
110
|
(text[i] === "*" && text[i + 1] === "*" && text[i + 2] === "*") ||
|
|
@@ -112,7 +121,7 @@ function tryBoldItalic(
|
|
|
112
121
|
|
|
113
122
|
function tryBold(
|
|
114
123
|
text: string,
|
|
115
|
-
i: number
|
|
124
|
+
i: number,
|
|
116
125
|
): { html: string; end: number } | null {
|
|
117
126
|
if (
|
|
118
127
|
(text[i] === "*" && text[i + 1] === "*") ||
|
|
@@ -126,7 +135,7 @@ function tryBold(
|
|
|
126
135
|
|
|
127
136
|
function tryItalic(
|
|
128
137
|
text: string,
|
|
129
|
-
i: number
|
|
138
|
+
i: number,
|
|
130
139
|
): { html: string; end: number } | null {
|
|
131
140
|
if (text[i] === "*" || (text[i] === "_" && !isIntraword(text, i, 1))) {
|
|
132
141
|
return parseDelimited(text, i, text[i], "<em>", "</em>");
|
|
@@ -136,7 +145,7 @@ function tryItalic(
|
|
|
136
145
|
|
|
137
146
|
function trySoftBreak(
|
|
138
147
|
text: string,
|
|
139
|
-
i: number
|
|
148
|
+
i: number,
|
|
140
149
|
): { html: string; end: number } | null {
|
|
141
150
|
if (text[i] === "\n") {
|
|
142
151
|
return { html: "<br>\n", end: i + 1 };
|
|
@@ -157,9 +166,11 @@ const HTML_DECL_RE = /^<![A-Za-z][\s\S]*?>/;
|
|
|
157
166
|
|
|
158
167
|
function tryInlineHtml(
|
|
159
168
|
text: string,
|
|
160
|
-
i: number
|
|
169
|
+
i: number,
|
|
161
170
|
): { html: string; end: number } | null {
|
|
162
|
-
if (text[i] !== "<") {
|
|
171
|
+
if (text[i] !== "<") {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
163
174
|
const rest = text.substring(i);
|
|
164
175
|
for (const re of [
|
|
165
176
|
HTML_COMMENT_RE,
|
|
@@ -252,7 +263,7 @@ function parseInline(text: string): string {
|
|
|
252
263
|
|
|
253
264
|
function parseInlineCode(
|
|
254
265
|
text: string,
|
|
255
|
-
start: number
|
|
266
|
+
start: number,
|
|
256
267
|
): { html: string; end: number } | null {
|
|
257
268
|
// Count opening backticks
|
|
258
269
|
let openCount = 0;
|
|
@@ -301,19 +312,25 @@ function parseInlineCode(
|
|
|
301
312
|
|
|
302
313
|
function parseImage(
|
|
303
314
|
text: string,
|
|
304
|
-
start: number
|
|
315
|
+
start: number,
|
|
305
316
|
): { html: string; end: number } | null {
|
|
306
317
|
//  or 
|
|
307
318
|
// Use balanced bracket matching to handle nested/escaped brackets in alt text
|
|
308
319
|
const altEnd = findClosingBracket(text, start + 1);
|
|
309
|
-
if (altEnd === -1) {
|
|
320
|
+
if (altEnd === -1) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
310
323
|
const altStart = start + 2; // after ![
|
|
311
324
|
|
|
312
|
-
if (text[altEnd + 1] !== "(") {
|
|
325
|
+
if (text[altEnd + 1] !== "(") {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
313
328
|
|
|
314
329
|
const urlStart = altEnd + 2;
|
|
315
330
|
const parenEnd = findClosingParen(text, urlStart - 1);
|
|
316
|
-
if (parenEnd === -1) {
|
|
331
|
+
if (parenEnd === -1) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
317
334
|
|
|
318
335
|
const alt = text.substring(altStart, altEnd);
|
|
319
336
|
const { url, title } = parseDestinationAndTitle(
|
|
@@ -332,8 +349,7 @@ function parseImage(
|
|
|
332
349
|
};
|
|
333
350
|
}
|
|
334
351
|
|
|
335
|
-
const titleAttr =
|
|
336
|
-
title !== undefined ? ` title="${escapeHtml(title)}"` : "";
|
|
352
|
+
const titleAttr = title !== undefined ? ` title="${escapeHtml(title)}"` : "";
|
|
337
353
|
return {
|
|
338
354
|
html: `<img src="${escapeHtml(url)}" alt="${escapeHtml(alt)}"${titleAttr}>`,
|
|
339
355
|
end: parenEnd + 1,
|
|
@@ -342,26 +358,31 @@ function parseImage(
|
|
|
342
358
|
|
|
343
359
|
function parseLink(
|
|
344
360
|
text: string,
|
|
345
|
-
start: number
|
|
361
|
+
start: number,
|
|
346
362
|
): { html: string; end: number } | null {
|
|
347
363
|
// [text](url)
|
|
348
364
|
const textStart = start + 1;
|
|
349
365
|
const textEnd = findClosingBracket(text, start);
|
|
350
|
-
if (textEnd === -1) {
|
|
366
|
+
if (textEnd === -1) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
351
369
|
|
|
352
|
-
if (text[textEnd + 1] !== "(") {
|
|
370
|
+
if (text[textEnd + 1] !== "(") {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
353
373
|
|
|
354
374
|
const urlStart = textEnd + 2;
|
|
355
375
|
const parenEnd = findClosingParen(text, textEnd + 1);
|
|
356
|
-
if (parenEnd === -1) {
|
|
376
|
+
if (parenEnd === -1) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
357
379
|
|
|
358
380
|
const linkText = text.substring(textStart, textEnd);
|
|
359
381
|
const { url, title } = parseDestinationAndTitle(
|
|
360
382
|
text.substring(urlStart, parenEnd),
|
|
361
383
|
);
|
|
362
384
|
|
|
363
|
-
const titleAttr =
|
|
364
|
-
title !== undefined ? ` title="${escapeHtml(title)}"` : "";
|
|
385
|
+
const titleAttr = title !== undefined ? ` title="${escapeHtml(title)}"` : "";
|
|
365
386
|
return {
|
|
366
387
|
html: `<a href="${escapeHtml(url)}"${titleAttr}>${parseInline(linkText)}</a>`,
|
|
367
388
|
end: parenEnd + 1,
|
|
@@ -375,10 +396,14 @@ function findClosingBracket(text: string, openPos: number): number {
|
|
|
375
396
|
i++; // skip escaped
|
|
376
397
|
continue;
|
|
377
398
|
}
|
|
378
|
-
if (text[i] === "[") {
|
|
399
|
+
if (text[i] === "[") {
|
|
400
|
+
depth++;
|
|
401
|
+
}
|
|
379
402
|
if (text[i] === "]") {
|
|
380
403
|
depth--;
|
|
381
|
-
if (depth === 0) {
|
|
404
|
+
if (depth === 0) {
|
|
405
|
+
return i;
|
|
406
|
+
}
|
|
382
407
|
}
|
|
383
408
|
}
|
|
384
409
|
return -1;
|
|
@@ -391,10 +416,14 @@ function findClosingParen(text: string, openPos: number): number {
|
|
|
391
416
|
i++;
|
|
392
417
|
continue;
|
|
393
418
|
}
|
|
394
|
-
if (text[i] === "(") {
|
|
419
|
+
if (text[i] === "(") {
|
|
420
|
+
depth++;
|
|
421
|
+
}
|
|
395
422
|
if (text[i] === ")") {
|
|
396
423
|
depth--;
|
|
397
|
-
if (depth === 0) {
|
|
424
|
+
if (depth === 0) {
|
|
425
|
+
return i;
|
|
426
|
+
}
|
|
398
427
|
}
|
|
399
428
|
}
|
|
400
429
|
return -1;
|
|
@@ -458,15 +487,19 @@ function parseDelimited(
|
|
|
458
487
|
start: number,
|
|
459
488
|
delimiter: string,
|
|
460
489
|
openTag: string,
|
|
461
|
-
closeTag: string
|
|
490
|
+
closeTag: string,
|
|
462
491
|
): { html: string; end: number } | null {
|
|
463
492
|
const len = delimiter.length;
|
|
464
493
|
const afterOpen = start + len;
|
|
465
494
|
|
|
466
|
-
if (afterOpen >= text.length) {
|
|
495
|
+
if (afterOpen >= text.length) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
467
498
|
|
|
468
499
|
// Opening delimiter must not be followed by whitespace
|
|
469
|
-
if (text[afterOpen] === " " || text[afterOpen] === "\t") {
|
|
500
|
+
if (text[afterOpen] === " " || text[afterOpen] === "\t") {
|
|
501
|
+
return null;
|
|
502
|
+
}
|
|
470
503
|
|
|
471
504
|
// Find closing delimiter
|
|
472
505
|
let j = afterOpen;
|
|
@@ -488,7 +521,9 @@ function parseDelimited(
|
|
|
488
521
|
// multi-char run (e.g., don't treat the * in ** as italic closer)
|
|
489
522
|
if (
|
|
490
523
|
len === 1 &&
|
|
491
|
-
((j > 0 &&
|
|
524
|
+
((j > 0 &&
|
|
525
|
+
text[j - 1] === delimiter[0] &&
|
|
526
|
+
!(j >= 2 && text[j - 2] === "\\")) ||
|
|
492
527
|
(j + len < text.length && text[j + len] === delimiter[0]))
|
|
493
528
|
) {
|
|
494
529
|
j++;
|
|
@@ -584,14 +619,69 @@ type Token =
|
|
|
584
619
|
* wrapped in a paragraph.
|
|
585
620
|
*/
|
|
586
621
|
const HTML_BLOCK_TAGS = new Set([
|
|
587
|
-
"address",
|
|
588
|
-
"
|
|
589
|
-
"
|
|
590
|
-
"
|
|
591
|
-
"
|
|
592
|
-
"
|
|
593
|
-
"
|
|
594
|
-
"
|
|
622
|
+
"address",
|
|
623
|
+
"article",
|
|
624
|
+
"aside",
|
|
625
|
+
"audio",
|
|
626
|
+
"base",
|
|
627
|
+
"basefont",
|
|
628
|
+
"blockquote",
|
|
629
|
+
"body",
|
|
630
|
+
"caption",
|
|
631
|
+
"center",
|
|
632
|
+
"col",
|
|
633
|
+
"colgroup",
|
|
634
|
+
"dd",
|
|
635
|
+
"details",
|
|
636
|
+
"dialog",
|
|
637
|
+
"dir",
|
|
638
|
+
"div",
|
|
639
|
+
"dl",
|
|
640
|
+
"dt",
|
|
641
|
+
"fieldset",
|
|
642
|
+
"figcaption",
|
|
643
|
+
"figure",
|
|
644
|
+
"footer",
|
|
645
|
+
"form",
|
|
646
|
+
"frame",
|
|
647
|
+
"frameset",
|
|
648
|
+
"h1",
|
|
649
|
+
"h2",
|
|
650
|
+
"h3",
|
|
651
|
+
"h4",
|
|
652
|
+
"h5",
|
|
653
|
+
"h6",
|
|
654
|
+
"head",
|
|
655
|
+
"header",
|
|
656
|
+
"hr",
|
|
657
|
+
"html",
|
|
658
|
+
"iframe",
|
|
659
|
+
"legend",
|
|
660
|
+
"li",
|
|
661
|
+
"link",
|
|
662
|
+
"main",
|
|
663
|
+
"menu",
|
|
664
|
+
"menuitem",
|
|
665
|
+
"nav",
|
|
666
|
+
"noframes",
|
|
667
|
+
"ol",
|
|
668
|
+
"optgroup",
|
|
669
|
+
"option",
|
|
670
|
+
"p",
|
|
671
|
+
"param",
|
|
672
|
+
"section",
|
|
673
|
+
"source",
|
|
674
|
+
"summary",
|
|
675
|
+
"table",
|
|
676
|
+
"tbody",
|
|
677
|
+
"td",
|
|
678
|
+
"tfoot",
|
|
679
|
+
"th",
|
|
680
|
+
"thead",
|
|
681
|
+
"title",
|
|
682
|
+
"tr",
|
|
683
|
+
"track",
|
|
684
|
+
"ul",
|
|
595
685
|
]);
|
|
596
686
|
|
|
597
687
|
function isHtmlBlockStart(line: string): boolean {
|
|
@@ -600,7 +690,9 @@ function isHtmlBlockStart(line: string): boolean {
|
|
|
600
690
|
return true;
|
|
601
691
|
}
|
|
602
692
|
const m = line.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
603
|
-
if (!m) {
|
|
693
|
+
if (!m) {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
604
696
|
return HTML_BLOCK_TAGS.has(m[1].toLowerCase());
|
|
605
697
|
}
|
|
606
698
|
|
|
@@ -633,7 +725,7 @@ function tokenize(markdown: string): Token[] {
|
|
|
633
725
|
i++;
|
|
634
726
|
while (i < lines.length) {
|
|
635
727
|
const closingMatch = lines[i].match(
|
|
636
|
-
new RegExp(`^ {0,3}${fenceChar}{${fenceLen},}\\s*$`)
|
|
728
|
+
new RegExp(`^ {0,3}${fenceChar}{${fenceLen},}\\s*$`),
|
|
637
729
|
);
|
|
638
730
|
if (closingMatch) {
|
|
639
731
|
i++;
|
|
@@ -730,14 +822,28 @@ function tokenize(markdown: string): Token[] {
|
|
|
730
822
|
// block-level element (per CommonMark spec)
|
|
731
823
|
while (i < lines.length) {
|
|
732
824
|
const cur = lines[i];
|
|
733
|
-
if (cur.trim() === "") {
|
|
825
|
+
if (cur.trim() === "") {
|
|
826
|
+
break;
|
|
827
|
+
}
|
|
734
828
|
// Stop on block-level markers
|
|
735
|
-
if (/^\s{0,3}>/.test(cur)) {
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
if (/^(
|
|
739
|
-
|
|
740
|
-
|
|
829
|
+
if (/^\s{0,3}>/.test(cur)) {
|
|
830
|
+
break;
|
|
831
|
+
} // new blockquote
|
|
832
|
+
if (/^(#{1,6})\s/.test(cur)) {
|
|
833
|
+
break;
|
|
834
|
+
} // heading
|
|
835
|
+
if (/^(`{3,}|~{3,})/.test(cur)) {
|
|
836
|
+
break;
|
|
837
|
+
} // code fence
|
|
838
|
+
if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(cur)) {
|
|
839
|
+
break;
|
|
840
|
+
} // hr
|
|
841
|
+
if (/^\s*([-*+]|\d+[.)])\s+/.test(cur)) {
|
|
842
|
+
break;
|
|
843
|
+
} // list item
|
|
844
|
+
if (/^\s*\|(.+\|)+\s*$/.test(cur)) {
|
|
845
|
+
break;
|
|
846
|
+
} // table
|
|
741
847
|
quoteLines.push(cur);
|
|
742
848
|
i++;
|
|
743
849
|
}
|
|
@@ -751,7 +857,7 @@ function tokenize(markdown: string): Token[] {
|
|
|
751
857
|
|
|
752
858
|
// List item (bullet, ordered, or task)
|
|
753
859
|
const listItemMatch = line.match(
|
|
754
|
-
/^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)
|
|
860
|
+
/^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)$/,
|
|
755
861
|
);
|
|
756
862
|
if (listItemMatch) {
|
|
757
863
|
const indent = listItemMatch[1].length;
|
|
@@ -787,10 +893,14 @@ function tokenize(markdown: string): Token[] {
|
|
|
787
893
|
|
|
788
894
|
// Helper to check if a line belongs to this list item
|
|
789
895
|
const belongsToItem = (lineStr: string): boolean => {
|
|
790
|
-
if (lineStr.trim() === "") {
|
|
896
|
+
if (lineStr.trim() === "") {
|
|
897
|
+
return true;
|
|
898
|
+
} // blank lines checked separately
|
|
791
899
|
const lineInd = lineStr.match(/^\s*/)![0].length;
|
|
792
900
|
// Lines at contentIndent are continuation text
|
|
793
|
-
if (lineInd >= contentIndent) {
|
|
901
|
+
if (lineInd >= contentIndent) {
|
|
902
|
+
return true;
|
|
903
|
+
}
|
|
794
904
|
// Lines between marker and content column that start a sub-list
|
|
795
905
|
if (
|
|
796
906
|
lineInd >= minChildIndent &&
|
|
@@ -799,7 +909,7 @@ function tokenize(markdown: string): Token[] {
|
|
|
799
909
|
return true;
|
|
800
910
|
}
|
|
801
911
|
return false;
|
|
802
|
-
}
|
|
912
|
+
};
|
|
803
913
|
|
|
804
914
|
// Consume ALL subsequent lines that belong to this list item
|
|
805
915
|
i++;
|
|
@@ -821,7 +931,9 @@ function tokenize(markdown: string): Token[] {
|
|
|
821
931
|
break;
|
|
822
932
|
}
|
|
823
933
|
|
|
824
|
-
if (!belongsToItem(cur)) {
|
|
934
|
+
if (!belongsToItem(cur)) {
|
|
935
|
+
break;
|
|
936
|
+
}
|
|
825
937
|
|
|
826
938
|
// Strip indent: for lines at contentIndent+, strip contentIndent chars;
|
|
827
939
|
// for sub-list lines between minChildIndent and contentIndent, strip minChildIndent
|
|
@@ -875,15 +987,31 @@ function tokenize(markdown: string): Token[] {
|
|
|
875
987
|
while (i < lines.length) {
|
|
876
988
|
const nextLine = lines[i];
|
|
877
989
|
// Stop paragraph on blank line
|
|
878
|
-
if (nextLine.trim() === "") {
|
|
990
|
+
if (nextLine.trim() === "") {
|
|
991
|
+
break;
|
|
992
|
+
}
|
|
879
993
|
// Stop on block-level element
|
|
880
|
-
if (/^(#{1,6})\s/.test(nextLine)) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
if (/^(
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
if (
|
|
994
|
+
if (/^(#{1,6})\s/.test(nextLine)) {
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
if (/^(`{3,}|~{3,})/.test(nextLine)) {
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
if (/^\s{0,3}>/.test(nextLine)) {
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(nextLine)) {
|
|
1004
|
+
break;
|
|
1005
|
+
}
|
|
1006
|
+
if (/^\s*([-*+]|\d+[.)])\s+/.test(nextLine)) {
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
if (/^\s*\|(.+\|)+\s*$/.test(nextLine)) {
|
|
1010
|
+
break;
|
|
1011
|
+
}
|
|
1012
|
+
if (isHtmlBlockStart(nextLine)) {
|
|
1013
|
+
break;
|
|
1014
|
+
}
|
|
887
1015
|
// Check if next-next line is setext marker
|
|
888
1016
|
if (
|
|
889
1017
|
i + 1 < lines.length &&
|
|
@@ -914,10 +1042,12 @@ function tokenize(markdown: string): Token[] {
|
|
|
914
1042
|
|
|
915
1043
|
function tryParseTable(
|
|
916
1044
|
lines: string[],
|
|
917
|
-
start: number
|
|
1045
|
+
start: number,
|
|
918
1046
|
): { token: TableToken; nextLine: number } | null {
|
|
919
1047
|
// A table needs at least a header row and a separator row
|
|
920
|
-
if (start + 1 >= lines.length) {
|
|
1048
|
+
if (start + 1 >= lines.length) {
|
|
1049
|
+
return null;
|
|
1050
|
+
}
|
|
921
1051
|
|
|
922
1052
|
const headerLine = lines[start];
|
|
923
1053
|
const separatorLine = lines[start + 1];
|
|
@@ -927,10 +1057,14 @@ function tryParseTable(
|
|
|
927
1057
|
if (
|
|
928
1058
|
!separatorLine.includes("|") ||
|
|
929
1059
|
!/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(separatorLine)
|
|
930
|
-
) {
|
|
1060
|
+
) {
|
|
1061
|
+
return null;
|
|
1062
|
+
}
|
|
931
1063
|
|
|
932
1064
|
// Check header line has at least one pipe (required to distinguish from plain text)
|
|
933
|
-
if (!headerLine.includes("|")) {
|
|
1065
|
+
if (!headerLine.includes("|")) {
|
|
1066
|
+
return null;
|
|
1067
|
+
}
|
|
934
1068
|
|
|
935
1069
|
const headers = parsePipeCells(headerLine);
|
|
936
1070
|
const alignments = parseAlignments(separatorLine);
|
|
@@ -939,7 +1073,9 @@ function tryParseTable(
|
|
|
939
1073
|
let i = start + 2;
|
|
940
1074
|
while (i < lines.length) {
|
|
941
1075
|
const line = lines[i];
|
|
942
|
-
if (!line.includes("|")) {
|
|
1076
|
+
if (!line.includes("|")) {
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
943
1079
|
rows.push(parsePipeCells(line));
|
|
944
1080
|
i++;
|
|
945
1081
|
}
|
|
@@ -969,7 +1105,11 @@ function parsePipeCells(line: string): string[] {
|
|
|
969
1105
|
const cells: string[] = [];
|
|
970
1106
|
let current = "";
|
|
971
1107
|
for (let i = 0; i < content.length; i++) {
|
|
972
|
-
if (
|
|
1108
|
+
if (
|
|
1109
|
+
content[i] === "\\" &&
|
|
1110
|
+
i + 1 < content.length &&
|
|
1111
|
+
content[i + 1] === "|"
|
|
1112
|
+
) {
|
|
973
1113
|
current += "|";
|
|
974
1114
|
i++;
|
|
975
1115
|
} else if (content[i] === "|") {
|
|
@@ -985,16 +1125,22 @@ function parsePipeCells(line: string): string[] {
|
|
|
985
1125
|
}
|
|
986
1126
|
|
|
987
1127
|
function parseAlignments(
|
|
988
|
-
separatorLine: string
|
|
1128
|
+
separatorLine: string,
|
|
989
1129
|
): ("left" | "center" | "right" | null)[] {
|
|
990
1130
|
const cells = parsePipeCells(separatorLine);
|
|
991
1131
|
return cells.map((cell) => {
|
|
992
1132
|
const trimmed = cell.trim();
|
|
993
1133
|
const left = trimmed.startsWith(":");
|
|
994
1134
|
const right = trimmed.endsWith(":");
|
|
995
|
-
if (left && right) {
|
|
996
|
-
|
|
997
|
-
|
|
1135
|
+
if (left && right) {
|
|
1136
|
+
return "center";
|
|
1137
|
+
}
|
|
1138
|
+
if (right) {
|
|
1139
|
+
return "right";
|
|
1140
|
+
}
|
|
1141
|
+
if (left) {
|
|
1142
|
+
return "left";
|
|
1143
|
+
}
|
|
998
1144
|
return null;
|
|
999
1145
|
});
|
|
1000
1146
|
}
|
|
@@ -1080,7 +1226,7 @@ function tokensToHtml(tokens: Token[]): string {
|
|
|
1080
1226
|
|
|
1081
1227
|
function emitListItems(
|
|
1082
1228
|
tokens: Token[],
|
|
1083
|
-
startIdx: number
|
|
1229
|
+
startIdx: number,
|
|
1084
1230
|
): { html: string; nextIndex: number } {
|
|
1085
1231
|
let html = "";
|
|
1086
1232
|
let i = startIdx;
|
|
@@ -1138,7 +1284,7 @@ function emitListItems(
|
|
|
1138
1284
|
}
|
|
1139
1285
|
|
|
1140
1286
|
function getEffectiveListType(
|
|
1141
|
-
listType: "bullet" | "ordered" | "task"
|
|
1287
|
+
listType: "bullet" | "ordered" | "task",
|
|
1142
1288
|
): "bullet" | "ordered" {
|
|
1143
1289
|
return listType === "ordered" ? "ordered" : "bullet";
|
|
1144
1290
|
}
|
package/src/api/pmUtil.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Schema } from "prosemirror-model";
|
|
1
|
+
import type { Node, NodeType, Schema } from "prosemirror-model";
|
|
2
2
|
import { Transform } from "prosemirror-transform";
|
|
3
3
|
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
|
|
4
4
|
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
|
|
@@ -52,3 +52,20 @@ export function getStyleSchema<S extends StyleSchema>(schema: Schema): S {
|
|
|
52
52
|
export function getBlockCache(schema: Schema) {
|
|
53
53
|
return getBlockNoteEditor(schema).blockCache;
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether `nodeType` is a BlockNote block whose content type is `"plain"` — i.e.
|
|
58
|
+
* it holds unstyled text and only allows the non-formatting (`"annotation"`)
|
|
59
|
+
* marks. Resolved semantically from the block schema (the source of truth),
|
|
60
|
+
* reachable from `schema.cached.blockNoteEditor`.
|
|
61
|
+
*
|
|
62
|
+
* Returns `false` for every non-block / structural node type (`doc`,
|
|
63
|
+
* `blockGroup`, `text`, inline content, table sub-nodes), since those aren't
|
|
64
|
+
* keys in the block schema.
|
|
65
|
+
*/
|
|
66
|
+
export function isPlainContentNodeType(
|
|
67
|
+
schema: Schema,
|
|
68
|
+
nodeType: NodeType,
|
|
69
|
+
): boolean {
|
|
70
|
+
return getBlockSchema(schema)[nodeType.name]?.content === "plain";
|
|
71
|
+
}
|