@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,1444 +0,0 @@
|
|
|
1
|
-
import { isVideoUrl } from "../../../util/string.js";
|
|
2
|
-
import { findLinks } from "../../../extensions/tiptap-extensions/Link/helpers/linkDetector.js";
|
|
3
|
-
import { parseAutolinkLiteral } from "./autolink.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Custom markdown-to-HTML converter for BlockNote.
|
|
7
|
-
* Replaces the unified/remark/rehype pipeline with a direct, minimal implementation
|
|
8
|
-
* that handles exactly the markdown features BlockNote needs.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// ─── HTML Escaping ───────────────────────────────────────────────────────────
|
|
12
|
-
|
|
13
|
-
function escapeHtml(str: string): string {
|
|
14
|
-
return str
|
|
15
|
-
.replace(/&/g, "&")
|
|
16
|
-
.replace(/</g, "<")
|
|
17
|
-
.replace(/>/g, ">")
|
|
18
|
-
.replace(/"/g, """);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
22
|
-
|
|
23
|
-
function isAlphanumeric(char: string | undefined): boolean {
|
|
24
|
-
if (!char) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
return /\w/.test(char);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Returns true when an underscore delimiter at position `i` is "intraword",
|
|
32
|
-
* meaning the characters on both sides are alphanumeric (e.g. `snake_case`).
|
|
33
|
-
* In that case the underscore should NOT be treated as emphasis per CommonMark.
|
|
34
|
-
*/
|
|
35
|
-
function isIntraword(text: string, i: number, delimLen: number): boolean {
|
|
36
|
-
const before = i > 0 ? text[i - 1] : undefined;
|
|
37
|
-
const after = i + delimLen < text.length ? text[i + delimLen] : undefined;
|
|
38
|
-
return isAlphanumeric(before) && isAlphanumeric(after);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// ─── Inline Parser ───────────────────────────────────────────────────────────
|
|
42
|
-
|
|
43
|
-
type InlineTokenizer = (
|
|
44
|
-
text: string,
|
|
45
|
-
i: number,
|
|
46
|
-
allowLinks: boolean,
|
|
47
|
-
) => { html: string; end: number } | null;
|
|
48
|
-
|
|
49
|
-
function tryBackslashEscape(
|
|
50
|
-
text: string,
|
|
51
|
-
i: number,
|
|
52
|
-
): { html: string; end: number } | null {
|
|
53
|
-
if (text[i] !== "\\" || i + 1 >= text.length) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
const next = text[i + 1];
|
|
57
|
-
// Hard line break: backslash at end of line
|
|
58
|
-
if (next === "\n") {
|
|
59
|
-
return { html: "<br>\n", end: i + 2 };
|
|
60
|
-
}
|
|
61
|
-
// Escapable characters
|
|
62
|
-
if ("\\`*_{}[]()#+-.!~|>".includes(next)) {
|
|
63
|
-
return { html: escapeHtml(next), end: i + 2 };
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function tryInlineCode(
|
|
69
|
-
text: string,
|
|
70
|
-
i: number,
|
|
71
|
-
): { html: string; end: number } | null {
|
|
72
|
-
if (text[i] !== "`") {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return parseInlineCode(text, i);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function tryImage(
|
|
79
|
-
text: string,
|
|
80
|
-
i: number,
|
|
81
|
-
): { html: string; end: number } | null {
|
|
82
|
-
if (text[i] !== "!" || text[i + 1] !== "[") {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
return parseImage(text, i);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function tryLink(
|
|
89
|
-
text: string,
|
|
90
|
-
i: number,
|
|
91
|
-
): { html: string; end: number } | null {
|
|
92
|
-
if (text[i] !== "[") {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
return parseLink(text, i);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function tryAutolink(
|
|
99
|
-
text: string,
|
|
100
|
-
i: number,
|
|
101
|
-
): { html: string; end: number } | null {
|
|
102
|
-
const rest = text.substring(i);
|
|
103
|
-
|
|
104
|
-
// CommonMark autolinks: <scheme:destination> and <email@example.com>.
|
|
105
|
-
if (text[i] === "<") {
|
|
106
|
-
const urlMatch = rest.match(/^<([a-zA-Z][a-zA-Z0-9+.-]{1,31}:[^\s<>]*)>/);
|
|
107
|
-
if (urlMatch) {
|
|
108
|
-
const url = urlMatch[1];
|
|
109
|
-
return {
|
|
110
|
-
html: `<a href="${escapeHtml(url)}">${escapeHtml(url)}</a>`,
|
|
111
|
-
end: i + urlMatch[0].length,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const emailMatch = rest.match(/^<([^\s<>]+)>/);
|
|
116
|
-
const email = emailMatch?.[1];
|
|
117
|
-
const detectedEmail = email
|
|
118
|
-
? findLinks(email).find(
|
|
119
|
-
(match) =>
|
|
120
|
-
match.type === "email" &&
|
|
121
|
-
match.start === 0 &&
|
|
122
|
-
match.end === email.length,
|
|
123
|
-
)
|
|
124
|
-
: undefined;
|
|
125
|
-
if (emailMatch && email && detectedEmail) {
|
|
126
|
-
return {
|
|
127
|
-
html: `<a href="${escapeHtml(detectedEmail.href)}">${escapeHtml(email)}</a>`,
|
|
128
|
-
end: i + emailMatch[0].length,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// GFM autolink literals. Only start at a word boundary, so URL-like text
|
|
136
|
-
// embedded in a larger word remains plain text.
|
|
137
|
-
if (i > 0 && /[a-zA-Z0-9_]/.test(text[i - 1])) {
|
|
138
|
-
return null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const literalMatch = rest.match(/^(https?:\/\/|www\.)[^\s<>]+/i);
|
|
142
|
-
if (!literalMatch) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const autolink = parseAutolinkLiteral(literalMatch[0]);
|
|
147
|
-
if (!autolink) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
html: `<a href="${escapeHtml(autolink.href)}">${escapeHtml(autolink.value)}</a>`,
|
|
153
|
-
end: i + autolink.value.length,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function tryStrikethrough(
|
|
158
|
-
text: string,
|
|
159
|
-
i: number,
|
|
160
|
-
allowLinks: boolean,
|
|
161
|
-
): { html: string; end: number } | null {
|
|
162
|
-
if (text[i] !== "~" || text[i + 1] !== "~") {
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
return parseDelimited(text, i, "~~", "<del>", "</del>", allowLinks);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function tryBoldItalic(
|
|
169
|
-
text: string,
|
|
170
|
-
i: number,
|
|
171
|
-
allowLinks: boolean,
|
|
172
|
-
): { html: string; end: number } | null {
|
|
173
|
-
if (
|
|
174
|
-
(text[i] === "*" && text[i + 1] === "*" && text[i + 2] === "*") ||
|
|
175
|
-
(text[i] === "_" &&
|
|
176
|
-
text[i + 1] === "_" &&
|
|
177
|
-
text[i + 2] === "_" &&
|
|
178
|
-
!isIntraword(text, i, 3))
|
|
179
|
-
) {
|
|
180
|
-
const delimiter = text.substring(i, i + 3);
|
|
181
|
-
return parseDelimited(
|
|
182
|
-
text,
|
|
183
|
-
i,
|
|
184
|
-
delimiter,
|
|
185
|
-
"<strong><em>",
|
|
186
|
-
"</em></strong>",
|
|
187
|
-
allowLinks,
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function tryBold(
|
|
194
|
-
text: string,
|
|
195
|
-
i: number,
|
|
196
|
-
allowLinks: boolean,
|
|
197
|
-
): { html: string; end: number } | null {
|
|
198
|
-
if (
|
|
199
|
-
(text[i] === "*" && text[i + 1] === "*") ||
|
|
200
|
-
(text[i] === "_" && text[i + 1] === "_" && !isIntraword(text, i, 2))
|
|
201
|
-
) {
|
|
202
|
-
const delimiter = text.substring(i, i + 2);
|
|
203
|
-
return parseDelimited(
|
|
204
|
-
text,
|
|
205
|
-
i,
|
|
206
|
-
delimiter,
|
|
207
|
-
"<strong>",
|
|
208
|
-
"</strong>",
|
|
209
|
-
allowLinks,
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
return null;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function tryItalic(
|
|
216
|
-
text: string,
|
|
217
|
-
i: number,
|
|
218
|
-
allowLinks: boolean,
|
|
219
|
-
): { html: string; end: number } | null {
|
|
220
|
-
if (text[i] === "*" || (text[i] === "_" && !isIntraword(text, i, 1))) {
|
|
221
|
-
return parseDelimited(text, i, text[i], "<em>", "</em>", allowLinks);
|
|
222
|
-
}
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
function trySoftBreak(
|
|
227
|
-
text: string,
|
|
228
|
-
i: number,
|
|
229
|
-
): { html: string; end: number } | null {
|
|
230
|
-
if (text[i] === "\n") {
|
|
231
|
-
return { html: "<br>\n", end: i + 1 };
|
|
232
|
-
}
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// Inline raw HTML: pass through tags, comments, CDATA, processing
|
|
237
|
-
// instructions, and declarations verbatim so authors can mix HTML into
|
|
238
|
-
// markdown (e.g. `text <em>foo</em> more`). Anything that doesn't match
|
|
239
|
-
// these shapes falls through and gets HTML-escaped as plain text.
|
|
240
|
-
const INLINE_HTML_TAG_RE =
|
|
241
|
-
/^<\/?[a-zA-Z][a-zA-Z0-9-]*(?:\s+[a-zA-Z_:][a-zA-Z0-9_.:-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*\s*\/?>/;
|
|
242
|
-
const HTML_COMMENT_RE = /^<!--[\s\S]*?-->/;
|
|
243
|
-
const HTML_CDATA_RE = /^<!\[CDATA\[[\s\S]*?\]\]>/;
|
|
244
|
-
const HTML_PI_RE = /^<\?[\s\S]*?\?>/;
|
|
245
|
-
const HTML_DECL_RE = /^<![A-Za-z][\s\S]*?>/;
|
|
246
|
-
|
|
247
|
-
function tryInlineHtml(
|
|
248
|
-
text: string,
|
|
249
|
-
i: number,
|
|
250
|
-
): { html: string; end: number } | null {
|
|
251
|
-
if (text[i] !== "<") {
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
const rest = text.substring(i);
|
|
255
|
-
for (const re of [
|
|
256
|
-
HTML_COMMENT_RE,
|
|
257
|
-
HTML_CDATA_RE,
|
|
258
|
-
HTML_PI_RE,
|
|
259
|
-
HTML_DECL_RE,
|
|
260
|
-
INLINE_HTML_TAG_RE,
|
|
261
|
-
]) {
|
|
262
|
-
const m = rest.match(re);
|
|
263
|
-
if (m) {
|
|
264
|
-
return { html: m[0], end: i + m[0].length };
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/** Characters that can start an inline syntax token. */
|
|
271
|
-
const SPECIAL_CHARS = new Set("\\`![~*_\n<");
|
|
272
|
-
|
|
273
|
-
function canStartInlineToken(text: string, position: number): boolean {
|
|
274
|
-
const char = text[position];
|
|
275
|
-
if (SPECIAL_CHARS.has(char)) {
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
if (char === "h") {
|
|
279
|
-
return (
|
|
280
|
-
text.startsWith("http://", position) ||
|
|
281
|
-
text.startsWith("https://", position)
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
if (char === "w") {
|
|
285
|
-
return text.startsWith("www.", position);
|
|
286
|
-
}
|
|
287
|
-
return false;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Ordered array of inline tokenizers, tried in priority order.
|
|
292
|
-
* The first match wins.
|
|
293
|
-
*/
|
|
294
|
-
const inlineTokenizers: InlineTokenizer[] = [
|
|
295
|
-
tryBackslashEscape,
|
|
296
|
-
tryInlineCode,
|
|
297
|
-
tryImage,
|
|
298
|
-
tryLink,
|
|
299
|
-
tryAutolink,
|
|
300
|
-
tryStrikethrough,
|
|
301
|
-
tryBoldItalic, // *** / ___
|
|
302
|
-
tryBold, // ** / __
|
|
303
|
-
tryItalic, // * / _
|
|
304
|
-
tryInlineHtml,
|
|
305
|
-
trySoftBreak,
|
|
306
|
-
];
|
|
307
|
-
|
|
308
|
-
const linkTextTokenizers = inlineTokenizers.filter(
|
|
309
|
-
(tokenizer) => tokenizer !== tryLink && tokenizer !== tryAutolink,
|
|
310
|
-
);
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Parse inline markdown syntax and return HTML.
|
|
314
|
-
* Handles: bold, italic, bold+italic, strikethrough, inline code,
|
|
315
|
-
* links, images (with video detection), hard line breaks, backslash escapes.
|
|
316
|
-
*/
|
|
317
|
-
function parseInline(text: string, allowLinks = true): string {
|
|
318
|
-
let result = "";
|
|
319
|
-
let i = 0;
|
|
320
|
-
const tokenizers = allowLinks ? inlineTokenizers : linkTextTokenizers;
|
|
321
|
-
|
|
322
|
-
while (i < text.length) {
|
|
323
|
-
// Hard line break: 2+ trailing spaces immediately before a newline.
|
|
324
|
-
// (The other hard-break form, backslash + newline, is handled by
|
|
325
|
-
// tryBackslashEscape.) Strip the trailing spaces from the accumulated
|
|
326
|
-
// result before emitting the <br>.
|
|
327
|
-
if (
|
|
328
|
-
text[i] === "\n" &&
|
|
329
|
-
i >= 2 &&
|
|
330
|
-
text[i - 1] === " " &&
|
|
331
|
-
text[i - 2] === " "
|
|
332
|
-
) {
|
|
333
|
-
result = result.replace(/ +$/, "");
|
|
334
|
-
result += "<br>\n";
|
|
335
|
-
i++;
|
|
336
|
-
continue;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// Try each tokenizer in priority order
|
|
340
|
-
let matched = false;
|
|
341
|
-
if (canStartInlineToken(text, i)) {
|
|
342
|
-
for (const tokenizer of tokenizers) {
|
|
343
|
-
const r = tokenizer(text, i, allowLinks);
|
|
344
|
-
if (r) {
|
|
345
|
-
result += r.html;
|
|
346
|
-
i = r.end;
|
|
347
|
-
matched = true;
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (!matched) {
|
|
354
|
-
// Batch consecutive plain-text characters and escape once
|
|
355
|
-
const runStart = i;
|
|
356
|
-
i++;
|
|
357
|
-
while (i < text.length && !canStartInlineToken(text, i)) {
|
|
358
|
-
i++;
|
|
359
|
-
}
|
|
360
|
-
result += escapeHtml(text.substring(runStart, i));
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
return result;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
function parseInlineCode(
|
|
368
|
-
text: string,
|
|
369
|
-
start: number,
|
|
370
|
-
): { html: string; end: number } | null {
|
|
371
|
-
// Count opening backticks
|
|
372
|
-
let openCount = 0;
|
|
373
|
-
let i = start;
|
|
374
|
-
while (i < text.length && text[i] === "`") {
|
|
375
|
-
openCount++;
|
|
376
|
-
i++;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// Find matching closing backticks
|
|
380
|
-
let j = i;
|
|
381
|
-
while (j < text.length) {
|
|
382
|
-
if (text[j] === "`") {
|
|
383
|
-
let closeCount = 0;
|
|
384
|
-
const closeStart = j;
|
|
385
|
-
while (j < text.length && text[j] === "`") {
|
|
386
|
-
closeCount++;
|
|
387
|
-
j++;
|
|
388
|
-
}
|
|
389
|
-
if (closeCount === openCount) {
|
|
390
|
-
let code = text.substring(i, closeStart);
|
|
391
|
-
// Per CommonMark: line endings inside a code span are converted to
|
|
392
|
-
// single spaces, then if the result starts AND ends with a space and
|
|
393
|
-
// is not all-spaces, one leading + trailing space is stripped (so
|
|
394
|
-
// `` ` `foo` ` `` is `<code>`foo`</code>`).
|
|
395
|
-
code = code.replace(/\n/g, " ");
|
|
396
|
-
if (
|
|
397
|
-
code.length >= 2 &&
|
|
398
|
-
code[0] === " " &&
|
|
399
|
-
code[code.length - 1] === " " &&
|
|
400
|
-
/[^ ]/.test(code)
|
|
401
|
-
) {
|
|
402
|
-
code = code.substring(1, code.length - 1);
|
|
403
|
-
}
|
|
404
|
-
return {
|
|
405
|
-
html: `<code>${escapeHtml(code)}</code>`,
|
|
406
|
-
end: j,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
} else {
|
|
410
|
-
j++;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function parseImage(
|
|
417
|
-
text: string,
|
|
418
|
-
start: number,
|
|
419
|
-
): { html: string; end: number } | null {
|
|
420
|
-
//  or 
|
|
421
|
-
// Use balanced bracket matching to handle nested/escaped brackets in alt text
|
|
422
|
-
const altEnd = findClosingBracket(text, start + 1);
|
|
423
|
-
if (altEnd === -1) {
|
|
424
|
-
return null;
|
|
425
|
-
}
|
|
426
|
-
const altStart = start + 2; // after ![
|
|
427
|
-
|
|
428
|
-
if (text[altEnd + 1] !== "(") {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
const urlStart = altEnd + 2;
|
|
433
|
-
const parenEnd = findClosingParen(text, urlStart - 1);
|
|
434
|
-
if (parenEnd === -1) {
|
|
435
|
-
return null;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
const alt = text.substring(altStart, altEnd);
|
|
439
|
-
const { url, title } = parseDestinationAndTitle(
|
|
440
|
-
text.substring(urlStart, parenEnd),
|
|
441
|
-
);
|
|
442
|
-
|
|
443
|
-
if (isVideoUrl(url)) {
|
|
444
|
-
// Use the alt text as the video's display name (falling back to the
|
|
445
|
-
// title) so a video link written with the standard `` form
|
|
446
|
-
// round-trips into BlockNote's video block. Captioned videos go through
|
|
447
|
-
// raw `<figure>` HTML instead, see htmlToMarkdown.serializeMediaFigure.
|
|
448
|
-
const name = alt || title;
|
|
449
|
-
return {
|
|
450
|
-
html: `<video src="${escapeHtml(url)}"${name ? ` data-name="${escapeHtml(name)}"` : ""} data-url="${escapeHtml(url)}" controls></video>`,
|
|
451
|
-
end: parenEnd + 1,
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
const titleAttr = title !== undefined ? ` title="${escapeHtml(title)}"` : "";
|
|
456
|
-
return {
|
|
457
|
-
html: `<img src="${escapeHtml(url)}" alt="${escapeHtml(alt)}"${titleAttr}>`,
|
|
458
|
-
end: parenEnd + 1,
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function parseLink(
|
|
463
|
-
text: string,
|
|
464
|
-
start: number,
|
|
465
|
-
): { html: string; end: number } | null {
|
|
466
|
-
// [text](url)
|
|
467
|
-
const textStart = start + 1;
|
|
468
|
-
const textEnd = findClosingBracket(text, start);
|
|
469
|
-
if (textEnd === -1) {
|
|
470
|
-
return null;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
if (text[textEnd + 1] !== "(") {
|
|
474
|
-
return null;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
const urlStart = textEnd + 2;
|
|
478
|
-
const parenEnd = findClosingParen(text, textEnd + 1);
|
|
479
|
-
if (parenEnd === -1) {
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
const linkText = text.substring(textStart, textEnd);
|
|
484
|
-
const { url, title } = parseDestinationAndTitle(
|
|
485
|
-
text.substring(urlStart, parenEnd),
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
const titleAttr = title !== undefined ? ` title="${escapeHtml(title)}"` : "";
|
|
489
|
-
return {
|
|
490
|
-
html: `<a href="${escapeHtml(url)}"${titleAttr}>${parseInline(linkText, false)}</a>`,
|
|
491
|
-
end: parenEnd + 1,
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
function findClosingBracket(text: string, openPos: number): number {
|
|
496
|
-
let depth = 0;
|
|
497
|
-
for (let i = openPos; i < text.length; i++) {
|
|
498
|
-
if (text[i] === "\\" && i + 1 < text.length) {
|
|
499
|
-
i++; // skip escaped
|
|
500
|
-
continue;
|
|
501
|
-
}
|
|
502
|
-
if (text[i] === "[") {
|
|
503
|
-
depth++;
|
|
504
|
-
}
|
|
505
|
-
if (text[i] === "]") {
|
|
506
|
-
depth--;
|
|
507
|
-
if (depth === 0) {
|
|
508
|
-
return i;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
return -1;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function findClosingParen(text: string, openPos: number): number {
|
|
516
|
-
let depth = 0;
|
|
517
|
-
for (let i = openPos; i < text.length; i++) {
|
|
518
|
-
if (text[i] === "\\" && i + 1 < text.length) {
|
|
519
|
-
i++;
|
|
520
|
-
continue;
|
|
521
|
-
}
|
|
522
|
-
if (text[i] === "(") {
|
|
523
|
-
depth++;
|
|
524
|
-
}
|
|
525
|
-
if (text[i] === ")") {
|
|
526
|
-
depth--;
|
|
527
|
-
if (depth === 0) {
|
|
528
|
-
return i;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return -1;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Parse the inside of `(...)` from a link/image (the URL and optional title).
|
|
537
|
-
* Handles three URL forms:
|
|
538
|
-
* - bare: `/uri` or `/uri "title"`
|
|
539
|
-
* - angle-bracket: `<url>` or `<url> "title"` (brackets are stripped)
|
|
540
|
-
* And three title-quote forms: `"..."`, `'...'`, `(...)`.
|
|
541
|
-
*/
|
|
542
|
-
function parseDestinationAndTitle(raw: string): {
|
|
543
|
-
url: string;
|
|
544
|
-
title?: string;
|
|
545
|
-
} {
|
|
546
|
-
raw = raw.trim();
|
|
547
|
-
let url: string;
|
|
548
|
-
let rest: string;
|
|
549
|
-
|
|
550
|
-
if (raw.startsWith("<")) {
|
|
551
|
-
const close = raw.indexOf(">");
|
|
552
|
-
if (close === -1) {
|
|
553
|
-
// Unmatched `<` — treat the whole thing as the URL minus the `<`.
|
|
554
|
-
url = raw.substring(1);
|
|
555
|
-
rest = "";
|
|
556
|
-
} else {
|
|
557
|
-
url = raw.substring(1, close);
|
|
558
|
-
rest = raw.substring(close + 1).trim();
|
|
559
|
-
}
|
|
560
|
-
} else {
|
|
561
|
-
// Split at first unescaped whitespace.
|
|
562
|
-
let split = raw.length;
|
|
563
|
-
for (let i = 0; i < raw.length; i++) {
|
|
564
|
-
if (raw[i] === "\\" && i + 1 < raw.length) {
|
|
565
|
-
i++;
|
|
566
|
-
continue;
|
|
567
|
-
}
|
|
568
|
-
if (raw[i] === " " || raw[i] === "\t" || raw[i] === "\n") {
|
|
569
|
-
split = i;
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
url = raw.substring(0, split);
|
|
574
|
-
rest = raw.substring(split).trim();
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
let title: string | undefined;
|
|
578
|
-
if (rest.length > 0) {
|
|
579
|
-
const titleMatch = rest.match(/^"([^"]*)"$|^'([^']*)'$|^\(([^)]*)\)$/);
|
|
580
|
-
if (titleMatch) {
|
|
581
|
-
title = titleMatch[1] ?? titleMatch[2] ?? titleMatch[3];
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
return { url, title };
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
function parseDelimited(
|
|
589
|
-
text: string,
|
|
590
|
-
start: number,
|
|
591
|
-
delimiter: string,
|
|
592
|
-
openTag: string,
|
|
593
|
-
closeTag: string,
|
|
594
|
-
allowLinks: boolean,
|
|
595
|
-
): { html: string; end: number } | null {
|
|
596
|
-
const len = delimiter.length;
|
|
597
|
-
const afterOpen = start + len;
|
|
598
|
-
|
|
599
|
-
if (afterOpen >= text.length) {
|
|
600
|
-
return null;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
// Opening delimiter must not be followed by whitespace
|
|
604
|
-
if (text[afterOpen] === " " || text[afterOpen] === "\t") {
|
|
605
|
-
return null;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// Find closing delimiter
|
|
609
|
-
let j = afterOpen;
|
|
610
|
-
while (j < text.length) {
|
|
611
|
-
// Skip escaped characters
|
|
612
|
-
if (text[j] === "\\" && j + 1 < text.length) {
|
|
613
|
-
j += 2;
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (text.substring(j, j + len) === delimiter) {
|
|
618
|
-
// Closing delimiter must not be preceded by whitespace
|
|
619
|
-
if (text[j - 1] === " " || text[j - 1] === "\t") {
|
|
620
|
-
j++;
|
|
621
|
-
continue;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
// For single-char delimiters, don't accept closer if it's part of a
|
|
625
|
-
// multi-char run (e.g., don't treat the * in ** as italic closer)
|
|
626
|
-
if (
|
|
627
|
-
len === 1 &&
|
|
628
|
-
((j > 0 &&
|
|
629
|
-
text[j - 1] === delimiter[0] &&
|
|
630
|
-
!(j >= 2 && text[j - 2] === "\\")) ||
|
|
631
|
-
(j + len < text.length && text[j + len] === delimiter[0]))
|
|
632
|
-
) {
|
|
633
|
-
j++;
|
|
634
|
-
continue;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
const inner = text.substring(afterOpen, j);
|
|
638
|
-
if (inner.length === 0) {
|
|
639
|
-
j++;
|
|
640
|
-
continue;
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
return {
|
|
644
|
-
html: openTag + parseInline(inner, allowLinks) + closeTag,
|
|
645
|
-
end: j + len,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
j++;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
return null;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// ─── Block-Level Types ───────────────────────────────────────────────────────
|
|
655
|
-
|
|
656
|
-
interface BlockToken {
|
|
657
|
-
type: string;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
interface HeadingToken extends BlockToken {
|
|
661
|
-
type: "heading";
|
|
662
|
-
level: number;
|
|
663
|
-
content: string;
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
interface ParagraphToken extends BlockToken {
|
|
667
|
-
type: "paragraph";
|
|
668
|
-
content: string;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
interface CodeBlockToken extends BlockToken {
|
|
672
|
-
type: "codeBlock";
|
|
673
|
-
language: string;
|
|
674
|
-
code: string;
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
interface BlockquoteToken extends BlockToken {
|
|
678
|
-
type: "blockquote";
|
|
679
|
-
content: string;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
interface HorizontalRuleToken extends BlockToken {
|
|
683
|
-
type: "hr";
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
interface ListItemToken extends BlockToken {
|
|
687
|
-
type: "listItem";
|
|
688
|
-
listType: "bullet" | "ordered" | "task";
|
|
689
|
-
indent: number;
|
|
690
|
-
content: string;
|
|
691
|
-
start?: number; // for ordered lists
|
|
692
|
-
checked?: boolean; // for task lists
|
|
693
|
-
childContent?: string; // recursively parsed content within this item
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
interface TableToken extends BlockToken {
|
|
697
|
-
type: "table";
|
|
698
|
-
headers: string[];
|
|
699
|
-
rows: string[][];
|
|
700
|
-
alignments: ("left" | "center" | "right" | null)[];
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
interface RawHtmlToken extends BlockToken {
|
|
704
|
-
type: "rawHtml";
|
|
705
|
-
content: string;
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
type Token =
|
|
709
|
-
| HeadingToken
|
|
710
|
-
| ParagraphToken
|
|
711
|
-
| CodeBlockToken
|
|
712
|
-
| BlockquoteToken
|
|
713
|
-
| HorizontalRuleToken
|
|
714
|
-
| ListItemToken
|
|
715
|
-
| TableToken
|
|
716
|
-
| RawHtmlToken;
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* HTML block-level tag names (from the CommonMark type-6 list, plus `audio`
|
|
720
|
-
* which BlockNote serializes as raw HTML since markdown has no shorthand
|
|
721
|
-
* for it). When a line starts with `<` followed by one of these tag names,
|
|
722
|
-
* the run of non-blank lines is emitted verbatim as raw HTML rather than
|
|
723
|
-
* wrapped in a paragraph.
|
|
724
|
-
*/
|
|
725
|
-
const HTML_BLOCK_TAGS = new Set([
|
|
726
|
-
"address",
|
|
727
|
-
"article",
|
|
728
|
-
"aside",
|
|
729
|
-
"audio",
|
|
730
|
-
"base",
|
|
731
|
-
"basefont",
|
|
732
|
-
"blockquote",
|
|
733
|
-
"body",
|
|
734
|
-
"caption",
|
|
735
|
-
"center",
|
|
736
|
-
"col",
|
|
737
|
-
"colgroup",
|
|
738
|
-
"dd",
|
|
739
|
-
"details",
|
|
740
|
-
"dialog",
|
|
741
|
-
"dir",
|
|
742
|
-
"div",
|
|
743
|
-
"dl",
|
|
744
|
-
"dt",
|
|
745
|
-
"fieldset",
|
|
746
|
-
"figcaption",
|
|
747
|
-
"figure",
|
|
748
|
-
"footer",
|
|
749
|
-
"form",
|
|
750
|
-
"frame",
|
|
751
|
-
"frameset",
|
|
752
|
-
"h1",
|
|
753
|
-
"h2",
|
|
754
|
-
"h3",
|
|
755
|
-
"h4",
|
|
756
|
-
"h5",
|
|
757
|
-
"h6",
|
|
758
|
-
"head",
|
|
759
|
-
"header",
|
|
760
|
-
"hr",
|
|
761
|
-
"html",
|
|
762
|
-
"iframe",
|
|
763
|
-
"legend",
|
|
764
|
-
"li",
|
|
765
|
-
"link",
|
|
766
|
-
"main",
|
|
767
|
-
"menu",
|
|
768
|
-
"menuitem",
|
|
769
|
-
"nav",
|
|
770
|
-
"noframes",
|
|
771
|
-
"ol",
|
|
772
|
-
"optgroup",
|
|
773
|
-
"option",
|
|
774
|
-
"p",
|
|
775
|
-
"param",
|
|
776
|
-
"section",
|
|
777
|
-
"source",
|
|
778
|
-
"summary",
|
|
779
|
-
"table",
|
|
780
|
-
"tbody",
|
|
781
|
-
"td",
|
|
782
|
-
"tfoot",
|
|
783
|
-
"th",
|
|
784
|
-
"thead",
|
|
785
|
-
"title",
|
|
786
|
-
"tr",
|
|
787
|
-
"track",
|
|
788
|
-
"ul",
|
|
789
|
-
]);
|
|
790
|
-
|
|
791
|
-
function isHtmlBlockStart(line: string): boolean {
|
|
792
|
-
// <!-- ..., <?..., <![CDATA[..., <!DOCTYPE, etc.
|
|
793
|
-
if (/^ {0,3}<(!--|\?|![A-Za-z]|!\[CDATA\[)/.test(line)) {
|
|
794
|
-
return true;
|
|
795
|
-
}
|
|
796
|
-
const m = line.match(/^ {0,3}<\/?([a-zA-Z][a-zA-Z0-9-]*)(?:\s|\/?>|$)/);
|
|
797
|
-
if (!m) {
|
|
798
|
-
return false;
|
|
799
|
-
}
|
|
800
|
-
return HTML_BLOCK_TAGS.has(m[1].toLowerCase());
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
// ─── Block-Level Tokenizer ──────────────────────────────────────────────────
|
|
804
|
-
|
|
805
|
-
function tokenize(markdown: string): Token[] {
|
|
806
|
-
const lines = markdown.split("\n");
|
|
807
|
-
const tokens: Token[] = [];
|
|
808
|
-
let i = 0;
|
|
809
|
-
let prevLineWasBlank = true; // treat start of document as after blank
|
|
810
|
-
|
|
811
|
-
while (i < lines.length) {
|
|
812
|
-
const line = lines[i];
|
|
813
|
-
|
|
814
|
-
// Blank line — skip
|
|
815
|
-
if (line.trim() === "") {
|
|
816
|
-
prevLineWasBlank = true;
|
|
817
|
-
i++;
|
|
818
|
-
continue;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
// Fenced code block (0-3 leading spaces allowed per CommonMark)
|
|
822
|
-
const fenceMatch = line.match(/^ {0,3}(`{3,}|~{3,})(.*)$/);
|
|
823
|
-
if (fenceMatch) {
|
|
824
|
-
const fence = fenceMatch[1];
|
|
825
|
-
const fenceChar = fence[0];
|
|
826
|
-
const fenceLen = fence.length;
|
|
827
|
-
const language = fenceMatch[2].trim();
|
|
828
|
-
const codeLines: string[] = [];
|
|
829
|
-
i++;
|
|
830
|
-
while (i < lines.length) {
|
|
831
|
-
const closingMatch = lines[i].match(
|
|
832
|
-
new RegExp(`^ {0,3}${fenceChar}{${fenceLen},}\\s*$`),
|
|
833
|
-
);
|
|
834
|
-
if (closingMatch) {
|
|
835
|
-
i++;
|
|
836
|
-
break;
|
|
837
|
-
}
|
|
838
|
-
codeLines.push(lines[i]);
|
|
839
|
-
i++;
|
|
840
|
-
}
|
|
841
|
-
tokens.push({
|
|
842
|
-
type: "codeBlock",
|
|
843
|
-
language: language || "",
|
|
844
|
-
code: codeLines.join("\n"),
|
|
845
|
-
});
|
|
846
|
-
prevLineWasBlank = false;
|
|
847
|
-
continue;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
// ATX Heading.
|
|
851
|
-
// - Closing `#` sequence requires a preceding space (so `### foo###`
|
|
852
|
-
// keeps the trailing #s as text, while `### foo ###` strips them).
|
|
853
|
-
// - Trailing whitespace is always stripped from the heading content.
|
|
854
|
-
const headingMatch = line.match(/^(#{1,6})\s+(.+?)(?:\s+#+\s*|\s*)$/);
|
|
855
|
-
if (headingMatch) {
|
|
856
|
-
tokens.push({
|
|
857
|
-
type: "heading",
|
|
858
|
-
level: headingMatch[1].length,
|
|
859
|
-
content: headingMatch[2],
|
|
860
|
-
});
|
|
861
|
-
prevLineWasBlank = false;
|
|
862
|
-
i++;
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
// Horizontal rule: ---, ***, ___ (3+ chars, optionally with spaces)
|
|
867
|
-
if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(line)) {
|
|
868
|
-
// Setext H2: --- immediately after a paragraph (no blank line between)
|
|
869
|
-
const prevToken = tokens[tokens.length - 1];
|
|
870
|
-
if (
|
|
871
|
-
!prevLineWasBlank &&
|
|
872
|
-
line.trim().match(/^-+$/) &&
|
|
873
|
-
prevToken &&
|
|
874
|
-
prevToken.type === "paragraph"
|
|
875
|
-
) {
|
|
876
|
-
const para = prevToken as ParagraphToken;
|
|
877
|
-
tokens[tokens.length - 1] = {
|
|
878
|
-
type: "heading",
|
|
879
|
-
level: 2,
|
|
880
|
-
content: para.content,
|
|
881
|
-
};
|
|
882
|
-
prevLineWasBlank = false;
|
|
883
|
-
i++;
|
|
884
|
-
continue;
|
|
885
|
-
}
|
|
886
|
-
tokens.push({ type: "hr" });
|
|
887
|
-
prevLineWasBlank = false;
|
|
888
|
-
i++;
|
|
889
|
-
continue;
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
// Setext heading detection: check if next line is === or ---
|
|
893
|
-
if (i + 1 < lines.length) {
|
|
894
|
-
const nextLine = lines[i + 1];
|
|
895
|
-
if (/^={1,}\s*$/.test(nextLine) && line.trim().length > 0) {
|
|
896
|
-
tokens.push({
|
|
897
|
-
type: "heading",
|
|
898
|
-
level: 1,
|
|
899
|
-
content: line.trim(),
|
|
900
|
-
});
|
|
901
|
-
prevLineWasBlank = false;
|
|
902
|
-
i += 2;
|
|
903
|
-
continue;
|
|
904
|
-
}
|
|
905
|
-
// Setext H2 --- handled in HR section above
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
// Table: detect by looking for separator row
|
|
909
|
-
const tableResult = tryParseTable(lines, i);
|
|
910
|
-
if (tableResult) {
|
|
911
|
-
tokens.push(tableResult.token);
|
|
912
|
-
i = tableResult.nextLine;
|
|
913
|
-
prevLineWasBlank = false;
|
|
914
|
-
continue;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
// Blockquote
|
|
918
|
-
if (/^\s{0,3}>/.test(line)) {
|
|
919
|
-
const quoteLines: string[] = [];
|
|
920
|
-
while (i < lines.length && /^\s{0,3}>/.test(lines[i])) {
|
|
921
|
-
// Remove the > prefix
|
|
922
|
-
quoteLines.push(lines[i].replace(/^\s{0,3}>\s?/, ""));
|
|
923
|
-
i++;
|
|
924
|
-
}
|
|
925
|
-
// Lazy continuation: collect non-blank lines that don't start a new
|
|
926
|
-
// block-level element (per CommonMark spec)
|
|
927
|
-
while (i < lines.length) {
|
|
928
|
-
const cur = lines[i];
|
|
929
|
-
if (cur.trim() === "") {
|
|
930
|
-
break;
|
|
931
|
-
}
|
|
932
|
-
// Stop on block-level markers
|
|
933
|
-
if (/^\s{0,3}>/.test(cur)) {
|
|
934
|
-
break;
|
|
935
|
-
} // new blockquote
|
|
936
|
-
if (/^(#{1,6})\s/.test(cur)) {
|
|
937
|
-
break;
|
|
938
|
-
} // heading
|
|
939
|
-
if (/^(`{3,}|~{3,})/.test(cur)) {
|
|
940
|
-
break;
|
|
941
|
-
} // code fence
|
|
942
|
-
if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(cur)) {
|
|
943
|
-
break;
|
|
944
|
-
} // hr
|
|
945
|
-
if (/^\s*([-*+]|\d+[.)])\s+/.test(cur)) {
|
|
946
|
-
break;
|
|
947
|
-
} // list item
|
|
948
|
-
if (/^\s*\|(.+\|)+\s*$/.test(cur)) {
|
|
949
|
-
break;
|
|
950
|
-
} // table
|
|
951
|
-
quoteLines.push(cur);
|
|
952
|
-
i++;
|
|
953
|
-
}
|
|
954
|
-
tokens.push({
|
|
955
|
-
type: "blockquote",
|
|
956
|
-
content: quoteLines.join("\n"),
|
|
957
|
-
});
|
|
958
|
-
prevLineWasBlank = false;
|
|
959
|
-
continue;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
// List item (bullet, ordered, or task)
|
|
963
|
-
const listItemMatch = line.match(
|
|
964
|
-
/^(\s*)([-*+]|\d+[.)])(\s+)(\[[ xX]\] )?(.*)$/,
|
|
965
|
-
);
|
|
966
|
-
if (listItemMatch) {
|
|
967
|
-
const indent = listItemMatch[1].length;
|
|
968
|
-
const marker = listItemMatch[2];
|
|
969
|
-
const markerSpaces = listItemMatch[3];
|
|
970
|
-
const checkbox = listItemMatch[4];
|
|
971
|
-
const firstLineContent = listItemMatch[5];
|
|
972
|
-
|
|
973
|
-
let listType: "bullet" | "ordered" | "task";
|
|
974
|
-
let start: number | undefined;
|
|
975
|
-
let checked: boolean | undefined;
|
|
976
|
-
|
|
977
|
-
if (checkbox) {
|
|
978
|
-
listType = "task";
|
|
979
|
-
checked = checkbox.trim() !== "[ ]";
|
|
980
|
-
} else if (/^\d+[.)]$/.test(marker)) {
|
|
981
|
-
listType = "ordered";
|
|
982
|
-
start = parseInt(marker, 10);
|
|
983
|
-
} else {
|
|
984
|
-
listType = "bullet";
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
// Content indent = column where content actually starts
|
|
988
|
-
const contentIndent =
|
|
989
|
-
indent +
|
|
990
|
-
marker.length +
|
|
991
|
-
markerSpaces.length +
|
|
992
|
-
(checkbox ? checkbox.length : 0);
|
|
993
|
-
|
|
994
|
-
// Minimum indent for child content: anything indented past the marker
|
|
995
|
-
// (sub-lists can start at indent > marker position)
|
|
996
|
-
const minChildIndent = indent + 1;
|
|
997
|
-
|
|
998
|
-
// Helper to check if a line belongs to this list item
|
|
999
|
-
const belongsToItem = (lineStr: string): boolean => {
|
|
1000
|
-
if (lineStr.trim() === "") {
|
|
1001
|
-
return true;
|
|
1002
|
-
} // blank lines checked separately
|
|
1003
|
-
const lineInd = lineStr.match(/^\s*/)![0].length;
|
|
1004
|
-
// Lines at contentIndent are continuation text
|
|
1005
|
-
if (lineInd >= contentIndent) {
|
|
1006
|
-
return true;
|
|
1007
|
-
}
|
|
1008
|
-
// Lines between marker and content column that start a sub-list
|
|
1009
|
-
if (
|
|
1010
|
-
lineInd >= minChildIndent &&
|
|
1011
|
-
lineStr.match(/^\s*([-*+]|\d+[.)])\s+/)
|
|
1012
|
-
) {
|
|
1013
|
-
return true;
|
|
1014
|
-
}
|
|
1015
|
-
return false;
|
|
1016
|
-
};
|
|
1017
|
-
|
|
1018
|
-
// Consume ALL subsequent lines that belong to this list item
|
|
1019
|
-
i++;
|
|
1020
|
-
const subLines: string[] = [];
|
|
1021
|
-
while (i < lines.length) {
|
|
1022
|
-
const cur = lines[i];
|
|
1023
|
-
|
|
1024
|
-
if (cur.trim() === "") {
|
|
1025
|
-
// Blank line: include if followed by content that belongs to this item
|
|
1026
|
-
let lookAhead = i + 1;
|
|
1027
|
-
while (lookAhead < lines.length && lines[lookAhead].trim() === "") {
|
|
1028
|
-
lookAhead++;
|
|
1029
|
-
}
|
|
1030
|
-
if (lookAhead < lines.length && belongsToItem(lines[lookAhead])) {
|
|
1031
|
-
subLines.push("");
|
|
1032
|
-
i++;
|
|
1033
|
-
continue;
|
|
1034
|
-
}
|
|
1035
|
-
break;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
if (!belongsToItem(cur)) {
|
|
1039
|
-
break;
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
// Strip indent: for lines at contentIndent+, strip contentIndent chars;
|
|
1043
|
-
// for sub-list lines between minChildIndent and contentIndent, strip minChildIndent
|
|
1044
|
-
const lineIndent = cur.match(/^\s*/)![0].length;
|
|
1045
|
-
if (lineIndent >= contentIndent) {
|
|
1046
|
-
subLines.push(cur.substring(contentIndent));
|
|
1047
|
-
} else {
|
|
1048
|
-
// Sub-list item between minChildIndent and contentIndent
|
|
1049
|
-
subLines.push(cur.substring(minChildIndent));
|
|
1050
|
-
}
|
|
1051
|
-
i++;
|
|
1052
|
-
}
|
|
1053
|
-
|
|
1054
|
-
// Build the list item token
|
|
1055
|
-
// If there are sub-lines, they become child content (recursively tokenized)
|
|
1056
|
-
// Don't trim — preserve relative indentation of sub-lines
|
|
1057
|
-
const childContent = subLines.join("\n").replace(/^\n+|\n+$/g, "");
|
|
1058
|
-
tokens.push({
|
|
1059
|
-
type: "listItem",
|
|
1060
|
-
listType,
|
|
1061
|
-
indent,
|
|
1062
|
-
content: firstLineContent.trim(),
|
|
1063
|
-
start,
|
|
1064
|
-
checked,
|
|
1065
|
-
childContent: childContent || undefined,
|
|
1066
|
-
});
|
|
1067
|
-
prevLineWasBlank = false;
|
|
1068
|
-
continue;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
// Block-level raw HTML: a line starting with `<tag>` (block-level tag),
|
|
1072
|
-
// `<!-- ... -->`, `<?...?>`, `<!DOCTYPE ...>`, or `<![CDATA[...]]>`.
|
|
1073
|
-
// Lines are emitted verbatim until the next blank line.
|
|
1074
|
-
if (isHtmlBlockStart(line)) {
|
|
1075
|
-
const htmlLines: string[] = [];
|
|
1076
|
-
while (i < lines.length && lines[i].trim() !== "") {
|
|
1077
|
-
htmlLines.push(lines[i]);
|
|
1078
|
-
i++;
|
|
1079
|
-
}
|
|
1080
|
-
tokens.push({
|
|
1081
|
-
type: "rawHtml",
|
|
1082
|
-
content: htmlLines.join("\n"),
|
|
1083
|
-
});
|
|
1084
|
-
prevLineWasBlank = false;
|
|
1085
|
-
continue;
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
// Paragraph (default)
|
|
1089
|
-
const paraLines: string[] = [line];
|
|
1090
|
-
i++;
|
|
1091
|
-
while (i < lines.length) {
|
|
1092
|
-
const nextLine = lines[i];
|
|
1093
|
-
// Stop paragraph on blank line
|
|
1094
|
-
if (nextLine.trim() === "") {
|
|
1095
|
-
break;
|
|
1096
|
-
}
|
|
1097
|
-
// Stop on block-level element
|
|
1098
|
-
if (/^(#{1,6})\s/.test(nextLine)) {
|
|
1099
|
-
break;
|
|
1100
|
-
}
|
|
1101
|
-
if (/^(`{3,}|~{3,})/.test(nextLine)) {
|
|
1102
|
-
break;
|
|
1103
|
-
}
|
|
1104
|
-
if (/^\s{0,3}>/.test(nextLine)) {
|
|
1105
|
-
break;
|
|
1106
|
-
}
|
|
1107
|
-
if (/^(\s{0,3})([-*_])\s*(\2\s*){2,}$/.test(nextLine)) {
|
|
1108
|
-
break;
|
|
1109
|
-
}
|
|
1110
|
-
if (/^\s*([-*+]|\d+[.)])\s+/.test(nextLine)) {
|
|
1111
|
-
break;
|
|
1112
|
-
}
|
|
1113
|
-
if (/^\s*\|(.+\|)+\s*$/.test(nextLine)) {
|
|
1114
|
-
break;
|
|
1115
|
-
}
|
|
1116
|
-
if (isHtmlBlockStart(nextLine)) {
|
|
1117
|
-
break;
|
|
1118
|
-
}
|
|
1119
|
-
// Check if next-next line is setext marker
|
|
1120
|
-
if (
|
|
1121
|
-
i + 1 < lines.length &&
|
|
1122
|
-
/^[=-]+\s*$/.test(lines[i + 1]) &&
|
|
1123
|
-
nextLine.trim().length > 0
|
|
1124
|
-
) {
|
|
1125
|
-
break;
|
|
1126
|
-
}
|
|
1127
|
-
paraLines.push(nextLine);
|
|
1128
|
-
i++;
|
|
1129
|
-
}
|
|
1130
|
-
// CommonMark allows up to 3 leading spaces of indent on paragraph lines.
|
|
1131
|
-
// Also strip trailing whitespace from the final line so a trailing
|
|
1132
|
-
// hard-break sequence (` \n` at end of paragraph) doesn't leak as
|
|
1133
|
-
// literal trailing spaces in the rendered output.
|
|
1134
|
-
tokens.push({
|
|
1135
|
-
type: "paragraph",
|
|
1136
|
-
content: paraLines
|
|
1137
|
-
.map((l) => l.replace(/^ {1,3}/, ""))
|
|
1138
|
-
.join("\n")
|
|
1139
|
-
.replace(/[ \t]+$/, ""),
|
|
1140
|
-
});
|
|
1141
|
-
prevLineWasBlank = false;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
return tokens;
|
|
1145
|
-
}
|
|
1146
|
-
|
|
1147
|
-
function tryParseTable(
|
|
1148
|
-
lines: string[],
|
|
1149
|
-
start: number,
|
|
1150
|
-
): { token: TableToken; nextLine: number } | null {
|
|
1151
|
-
// A table needs at least a header row and a separator row
|
|
1152
|
-
if (start + 1 >= lines.length) {
|
|
1153
|
-
return null;
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
const headerLine = lines[start];
|
|
1157
|
-
const separatorLine = lines[start + 1];
|
|
1158
|
-
|
|
1159
|
-
// Check separator line format: | --- | --- | or --- | --- (outer pipes optional)
|
|
1160
|
-
// Must contain at least one pipe and only dashes, colons, pipes, and whitespace
|
|
1161
|
-
if (
|
|
1162
|
-
!separatorLine.includes("|") ||
|
|
1163
|
-
!/^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/.test(separatorLine)
|
|
1164
|
-
) {
|
|
1165
|
-
return null;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
// Check header line has at least one pipe (required to distinguish from plain text)
|
|
1169
|
-
if (!headerLine.includes("|")) {
|
|
1170
|
-
return null;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
const headers = parsePipeCells(headerLine);
|
|
1174
|
-
const alignments = parseAlignments(separatorLine);
|
|
1175
|
-
|
|
1176
|
-
const rows: string[][] = [];
|
|
1177
|
-
let i = start + 2;
|
|
1178
|
-
while (i < lines.length) {
|
|
1179
|
-
const line = lines[i];
|
|
1180
|
-
if (!line.includes("|")) {
|
|
1181
|
-
break;
|
|
1182
|
-
}
|
|
1183
|
-
rows.push(parsePipeCells(line));
|
|
1184
|
-
i++;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
return {
|
|
1188
|
-
token: {
|
|
1189
|
-
type: "table",
|
|
1190
|
-
headers,
|
|
1191
|
-
rows,
|
|
1192
|
-
alignments,
|
|
1193
|
-
},
|
|
1194
|
-
nextLine: i,
|
|
1195
|
-
};
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
function parsePipeCells(line: string): string[] {
|
|
1199
|
-
// Trim leading/trailing pipes and split
|
|
1200
|
-
const trimmed = line.trim();
|
|
1201
|
-
const withoutOuterPipes = trimmed.startsWith("|")
|
|
1202
|
-
? trimmed.substring(1)
|
|
1203
|
-
: trimmed;
|
|
1204
|
-
const content = withoutOuterPipes.endsWith("|")
|
|
1205
|
-
? withoutOuterPipes.substring(0, withoutOuterPipes.length - 1)
|
|
1206
|
-
: withoutOuterPipes;
|
|
1207
|
-
|
|
1208
|
-
// Split by pipes, handling escaped pipes
|
|
1209
|
-
const cells: string[] = [];
|
|
1210
|
-
let current = "";
|
|
1211
|
-
for (let i = 0; i < content.length; i++) {
|
|
1212
|
-
if (
|
|
1213
|
-
content[i] === "\\" &&
|
|
1214
|
-
i + 1 < content.length &&
|
|
1215
|
-
content[i + 1] === "|"
|
|
1216
|
-
) {
|
|
1217
|
-
current += "|";
|
|
1218
|
-
i++;
|
|
1219
|
-
} else if (content[i] === "|") {
|
|
1220
|
-
cells.push(current.trim());
|
|
1221
|
-
current = "";
|
|
1222
|
-
} else {
|
|
1223
|
-
current += content[i];
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
cells.push(current.trim());
|
|
1227
|
-
|
|
1228
|
-
return cells;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
function parseAlignments(
|
|
1232
|
-
separatorLine: string,
|
|
1233
|
-
): ("left" | "center" | "right" | null)[] {
|
|
1234
|
-
const cells = parsePipeCells(separatorLine);
|
|
1235
|
-
return cells.map((cell) => {
|
|
1236
|
-
const trimmed = cell.trim();
|
|
1237
|
-
const left = trimmed.startsWith(":");
|
|
1238
|
-
const right = trimmed.endsWith(":");
|
|
1239
|
-
if (left && right) {
|
|
1240
|
-
return "center";
|
|
1241
|
-
}
|
|
1242
|
-
if (right) {
|
|
1243
|
-
return "right";
|
|
1244
|
-
}
|
|
1245
|
-
if (left) {
|
|
1246
|
-
return "left";
|
|
1247
|
-
}
|
|
1248
|
-
return null;
|
|
1249
|
-
});
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
// ─── HTML Emitter ────────────────────────────────────────────────────────────
|
|
1253
|
-
|
|
1254
|
-
function tokensToHtml(tokens: Token[]): string {
|
|
1255
|
-
let html = "";
|
|
1256
|
-
let i = 0;
|
|
1257
|
-
|
|
1258
|
-
while (i < tokens.length) {
|
|
1259
|
-
const token = tokens[i];
|
|
1260
|
-
|
|
1261
|
-
switch (token.type) {
|
|
1262
|
-
case "heading": {
|
|
1263
|
-
const t = token as HeadingToken;
|
|
1264
|
-
html += `<h${t.level}>${parseInline(t.content)}</h${t.level}>`;
|
|
1265
|
-
i++;
|
|
1266
|
-
break;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
case "paragraph": {
|
|
1270
|
-
const t = token as ParagraphToken;
|
|
1271
|
-
html += `<p>${parseInline(t.content)}</p>`;
|
|
1272
|
-
i++;
|
|
1273
|
-
break;
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
case "codeBlock": {
|
|
1277
|
-
const t = token as CodeBlockToken;
|
|
1278
|
-
const langAttr = t.language
|
|
1279
|
-
? ` data-language="${escapeHtml(t.language)}"`
|
|
1280
|
-
: "";
|
|
1281
|
-
html += `<pre><code${langAttr}>${escapeHtml(t.code)}</code></pre>`;
|
|
1282
|
-
i++;
|
|
1283
|
-
break;
|
|
1284
|
-
}
|
|
1285
|
-
|
|
1286
|
-
case "blockquote": {
|
|
1287
|
-
const t = token as BlockquoteToken;
|
|
1288
|
-
// Recursively parse blockquote content as markdown
|
|
1289
|
-
const innerTokens = tokenize(t.content);
|
|
1290
|
-
const innerHtml = tokensToHtml(innerTokens);
|
|
1291
|
-
html += `<blockquote>${innerHtml}</blockquote>`;
|
|
1292
|
-
i++;
|
|
1293
|
-
break;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
case "hr":
|
|
1297
|
-
html += `<hr>`;
|
|
1298
|
-
i++;
|
|
1299
|
-
break;
|
|
1300
|
-
|
|
1301
|
-
case "listItem": {
|
|
1302
|
-
// Collect consecutive list items and build nested list structure
|
|
1303
|
-
const listHtml = emitListItems(tokens, i);
|
|
1304
|
-
html += listHtml.html;
|
|
1305
|
-
i = listHtml.nextIndex;
|
|
1306
|
-
break;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
case "table": {
|
|
1310
|
-
const t = token as TableToken;
|
|
1311
|
-
html += emitTable(t);
|
|
1312
|
-
i++;
|
|
1313
|
-
break;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
case "rawHtml": {
|
|
1317
|
-
const t = token as RawHtmlToken;
|
|
1318
|
-
html += t.content;
|
|
1319
|
-
i++;
|
|
1320
|
-
break;
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
default:
|
|
1324
|
-
i++;
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
return html;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
function emitListItems(
|
|
1332
|
-
tokens: Token[],
|
|
1333
|
-
startIdx: number,
|
|
1334
|
-
): { html: string; nextIndex: number } {
|
|
1335
|
-
let html = "";
|
|
1336
|
-
let i = startIdx;
|
|
1337
|
-
let currentListType: "bullet" | "ordered" | null = null;
|
|
1338
|
-
|
|
1339
|
-
while (i < tokens.length && tokens[i].type === "listItem") {
|
|
1340
|
-
const item = tokens[i] as ListItemToken;
|
|
1341
|
-
const effectiveType = getEffectiveListType(item.listType);
|
|
1342
|
-
|
|
1343
|
-
// Check if we need to switch list type
|
|
1344
|
-
if (currentListType !== null && currentListType !== effectiveType) {
|
|
1345
|
-
// Close current list, open new one
|
|
1346
|
-
html += `</${currentListType === "ordered" ? "ol" : "ul"}>`;
|
|
1347
|
-
currentListType = null;
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
// Open list if needed
|
|
1351
|
-
if (currentListType === null) {
|
|
1352
|
-
if (effectiveType === "ordered") {
|
|
1353
|
-
const startAttr =
|
|
1354
|
-
item.start !== undefined && item.start !== 1
|
|
1355
|
-
? ` start="${item.start}"`
|
|
1356
|
-
: "";
|
|
1357
|
-
html += `<ol${startAttr}>`;
|
|
1358
|
-
} else {
|
|
1359
|
-
html += `<ul>`;
|
|
1360
|
-
}
|
|
1361
|
-
currentListType = effectiveType;
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
// Emit list item
|
|
1365
|
-
if (item.listType === "task") {
|
|
1366
|
-
const checkedAttr = item.checked ? " checked" : "";
|
|
1367
|
-
html += `<li><input type="checkbox" disabled${checkedAttr}><p>${parseInline(item.content)}</p>`;
|
|
1368
|
-
} else {
|
|
1369
|
-
html += `<li><p>${parseInline(item.content)}</p>`;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// Render child content (nested items, continuation paragraphs, etc.)
|
|
1373
|
-
if (item.childContent) {
|
|
1374
|
-
const childTokens = tokenize(item.childContent);
|
|
1375
|
-
html += tokensToHtml(childTokens);
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
html += `</li>`;
|
|
1379
|
-
i++;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
// Close the list
|
|
1383
|
-
if (currentListType !== null) {
|
|
1384
|
-
html += `</${currentListType === "ordered" ? "ol" : "ul"}>`;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
return { html, nextIndex: i };
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
function getEffectiveListType(
|
|
1391
|
-
listType: "bullet" | "ordered" | "task",
|
|
1392
|
-
): "bullet" | "ordered" {
|
|
1393
|
-
return listType === "ordered" ? "ordered" : "bullet";
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
function emitTable(table: TableToken): string {
|
|
1397
|
-
let html = "<table>";
|
|
1398
|
-
|
|
1399
|
-
// BlockNote tables have no required header row, but the markdown table
|
|
1400
|
-
// syntax does. When we serialize a headerless BlockNote table to markdown
|
|
1401
|
-
// we emit an empty header row; on re-parse, treat that empty header as
|
|
1402
|
-
// "no header" so the round-trip is stable (issue #739).
|
|
1403
|
-
const headerIsEmpty = table.headers.every((h) => h.trim() === "");
|
|
1404
|
-
const colCount = table.headers.length;
|
|
1405
|
-
|
|
1406
|
-
if (!headerIsEmpty) {
|
|
1407
|
-
html += "<thead><tr>";
|
|
1408
|
-
for (let c = 0; c < colCount; c++) {
|
|
1409
|
-
const align = table.alignments[c];
|
|
1410
|
-
const alignAttr = align ? ` align="${align}"` : "";
|
|
1411
|
-
html += `<th${alignAttr}>${parseInline(table.headers[c])}</th>`;
|
|
1412
|
-
}
|
|
1413
|
-
html += "</tr></thead>";
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
if (table.rows.length > 0) {
|
|
1417
|
-
html += "<tbody>";
|
|
1418
|
-
for (const row of table.rows) {
|
|
1419
|
-
html += "<tr>";
|
|
1420
|
-
for (let c = 0; c < colCount; c++) {
|
|
1421
|
-
const cell = c < row.length ? row[c] : "";
|
|
1422
|
-
const align = table.alignments[c];
|
|
1423
|
-
const alignAttr = align ? ` align="${align}"` : "";
|
|
1424
|
-
html += `<td${alignAttr}>${parseInline(cell)}</td>`;
|
|
1425
|
-
}
|
|
1426
|
-
html += "</tr>";
|
|
1427
|
-
}
|
|
1428
|
-
html += "</tbody>";
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
html += "</table>";
|
|
1432
|
-
return html;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
// ─── Public API ──────────────────────────────────────────────────────────────
|
|
1436
|
-
|
|
1437
|
-
/**
|
|
1438
|
-
* Convert a markdown string to an HTML string.
|
|
1439
|
-
* This is a direct replacement for the unified/remark/rehype pipeline.
|
|
1440
|
-
*/
|
|
1441
|
-
export function markdownToHtml(markdown: string): string {
|
|
1442
|
-
const tokens = tokenize(markdown);
|
|
1443
|
-
return tokensToHtml(tokens);
|
|
1444
|
-
}
|