@blocknote/core 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +2320 -1692
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +7 -7
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +3 -3
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteImage.html +111 -0
- package/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +96 -0
- package/src/api/clipboard/__snapshots__/external/pasteTable.html +149 -0
- package/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +124 -0
- package/src/api/clipboard/__snapshots__/internal/basicBlocks.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +1 -0
- package/src/api/clipboard/clipboardExternal.test.ts +161 -0
- package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +186 -38
- package/src/api/clipboard/testUtil.ts +27 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -0
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html +1 -0
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +7 -1
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +3 -1
- package/src/api/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md +0 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +16 -0
- package/src/api/nodeConversions/nodeToBlock.ts +4 -1
- package/src/api/parsers/html/__snapshots__/parse-codeblocks.json +62 -0
- package/src/api/parsers/html/parseHTML.test.ts +9 -0
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
- package/src/api/testUtil/cases/defaultSchema.ts +15 -1
- package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +32 -11
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -28
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +1 -1
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +4 -16
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +26 -6
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +49 -0
- package/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.ts +45 -0
- package/src/blocks/PageBreakBlockContent/schema.ts +40 -0
- package/src/editor/Block.css +18 -4
- package/src/editor/BlockNoteEditor.test.ts +21 -1
- package/src/editor/BlockNoteEditor.ts +17 -0
- package/src/editor/BlockNoteExtensions.ts +111 -16
- package/src/editor/editor.css +28 -13
- package/src/editor/transformPasted.ts +57 -4
- package/src/extensions/SideMenu/SideMenuPlugin.ts +115 -23
- package/src/extensions/SideMenu/dragging.ts +0 -1
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +1 -1
- package/src/i18n/locales/ar.ts +6 -0
- package/src/i18n/locales/de.ts +6 -0
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +6 -0
- package/src/i18n/locales/fr.ts +47 -17
- package/src/i18n/locales/hr.ts +72 -54
- package/src/i18n/locales/index.ts +1 -0
- package/src/i18n/locales/is.ts +6 -0
- package/src/i18n/locales/it.ts +315 -0
- package/src/i18n/locales/ja.ts +6 -0
- package/src/i18n/locales/ko.ts +6 -0
- package/src/i18n/locales/nl.ts +6 -0
- package/src/i18n/locales/pl.ts +6 -0
- package/src/i18n/locales/pt.ts +6 -0
- package/src/i18n/locales/ru.ts +6 -0
- package/src/i18n/locales/vi.ts +6 -0
- package/src/i18n/locales/zh.ts +6 -0
- package/src/index.ts +3 -0
- package/src/schema/blocks/createSpec.ts +1 -1
- package/src/schema/blocks/internal.ts +16 -6
- package/src/schema/inlineContent/internal.ts +4 -1
- package/src/schema/propTypes.ts +41 -18
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +8 -0
- package/types/src/api/clipboard/clipboardInternal.test.d.ts +1 -0
- package/types/src/api/clipboard/testUtil.d.ts +509 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +8 -0
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +8 -0
- package/types/src/api/testUtil/cases/customStyles.d.ts +8 -0
- package/types/src/api/testUtil/cases/defaultSchema.d.ts +2 -1
- package/types/src/blocks/CodeBlockContent/CodeBlockContent.d.ts +2 -0
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
- package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +31 -0
- package/types/src/blocks/PageBreakBlockContent/getPageBreakSlashMenuItems.d.ts +8 -0
- package/types/src/blocks/PageBreakBlockContent/schema.d.ts +86 -0
- package/types/src/blocks/defaultBlocks.d.ts +16 -0
- package/types/src/editor/BlockNoteEditor.d.ts +15 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +2 -0
- package/types/src/editor/transformPasted.d.ts +8 -4
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +25 -5
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +1 -1
- package/types/src/i18n/locales/de.d.ts +6 -0
- package/types/src/i18n/locales/en.d.ts +6 -0
- package/types/src/i18n/locales/es.d.ts +6 -0
- package/types/src/i18n/locales/hr.d.ts +6 -0
- package/types/src/i18n/locales/index.d.ts +1 -0
- package/types/src/i18n/locales/it.d.ts +245 -0
- package/types/src/index.d.ts +3 -0
- package/types/src/schema/propTypes.d.ts +20 -2
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +0 -30
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js +0 -99
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js +0 -97
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js +0 -88
- package/dist/src/api/blockManipulation/commands/mergeBlocks/mergeBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +0 -219
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +0 -175
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js +0 -57
- package/dist/src/api/blockManipulation/commands/nestBlock/nestBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js +0 -5
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js +0 -31
- package/dist/src/api/blockManipulation/commands/removeBlocks/removeBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js +0 -71
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js +0 -157
- package/dist/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js +0 -27
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +0 -67
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +0 -148
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js +0 -252
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.test.js.map +0 -1
- package/dist/src/api/blockManipulation/getBlock/getBlock.js +0 -56
- package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/insertContentAt.js +0 -64
- package/dist/src/api/blockManipulation/insertContentAt.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/selection.js +0 -149
- package/dist/src/api/blockManipulation/selections/selection.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/selection.test.js +0 -39
- package/dist/src/api/blockManipulation/selections/selection.test.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +0 -79
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +0 -1
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js +0 -33
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.test.js.map +0 -1
- package/dist/src/api/blockManipulation/setupTestEnv.js +0 -172
- package/dist/src/api/blockManipulation/setupTestEnv.js.map +0 -1
- package/dist/src/api/clipboard/clipboard.test.js +0 -249
- package/dist/src/api/clipboard/clipboard.test.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js +0 -8
- package/dist/src/api/clipboard/fromClipboard/acceptedMIMETypes.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js +0 -38
- package/dist/src/api/clipboard/fromClipboard/fileDropExtension.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +0 -111
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +0 -25
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +0 -1
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +0 -57
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +0 -1
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +0 -134
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +0 -1
- package/dist/src/api/exporters/html/externalHTMLExporter.js +0 -35
- package/dist/src/api/exporters/html/externalHTMLExporter.js.map +0 -1
- package/dist/src/api/exporters/html/htmlConversion.test.js +0 -72
- package/dist/src/api/exporters/html/htmlConversion.test.js.map +0 -1
- package/dist/src/api/exporters/html/internalHTMLSerializer.js +0 -21
- package/dist/src/api/exporters/html/internalHTMLSerializer.js.map +0 -1
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js +0 -141
- package/dist/src/api/exporters/html/util/serializeBlocksExternalHTML.js.map +0 -1
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js +0 -96
- package/dist/src/api/exporters/html/util/serializeBlocksInternalHTML.js.map +0 -1
- package/dist/src/api/exporters/markdown/markdownExporter.js +0 -31
- package/dist/src/api/exporters/markdown/markdownExporter.js.map +0 -1
- package/dist/src/api/exporters/markdown/markdownExporter.test.js +0 -57
- package/dist/src/api/exporters/markdown/markdownExporter.test.js.map +0 -1
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js +0 -33
- package/dist/src/api/exporters/markdown/removeUnderlinesRehypePlugin.js.map +0 -1
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js +0 -37
- package/dist/src/api/exporters/markdown/util/addSpacesToCheckboxesRehypePlugin.js.map +0 -1
- package/dist/src/api/getBlockInfoFromPos.js +0 -165
- package/dist/src/api/getBlockInfoFromPos.js.map +0 -1
- package/dist/src/api/nodeConversions/blockToNode.js +0 -197
- package/dist/src/api/nodeConversions/blockToNode.js.map +0 -1
- package/dist/src/api/nodeConversions/fragmentToBlocks.js +0 -50
- package/dist/src/api/nodeConversions/fragmentToBlocks.js.map +0 -1
- package/dist/src/api/nodeConversions/nodeConversions.test.js +0 -54
- package/dist/src/api/nodeConversions/nodeConversions.test.js.map +0 -1
- package/dist/src/api/nodeConversions/nodeToBlock.js +0 -316
- package/dist/src/api/nodeConversions/nodeToBlock.js.map +0 -1
- package/dist/src/api/nodeUtil.js +0 -28
- package/dist/src/api/nodeUtil.js.map +0 -1
- package/dist/src/api/parsers/html/parseHTML.js +0 -19
- package/dist/src/api/parsers/html/parseHTML.js.map +0 -1
- package/dist/src/api/parsers/html/parseHTML.test.js +0 -470
- package/dist/src/api/parsers/html/parseHTML.test.js.map +0 -1
- package/dist/src/api/parsers/html/util/nestedLists.js +0 -106
- package/dist/src/api/parsers/html/util/nestedLists.js.map +0 -1
- package/dist/src/api/parsers/html/util/nestedLists.test.js +0 -166
- package/dist/src/api/parsers/html/util/nestedLists.test.js.map +0 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.js +0 -52
- package/dist/src/api/parsers/markdown/parseMarkdown.js.map +0 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +0 -112
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +0 -1
- package/dist/src/api/testUtil/cases/customBlocks.js +0 -313
- package/dist/src/api/testUtil/cases/customBlocks.js.map +0 -1
- package/dist/src/api/testUtil/cases/customInlineContent.js +0 -91
- package/dist/src/api/testUtil/cases/customInlineContent.js.map +0 -1
- package/dist/src/api/testUtil/cases/customStyles.js +0 -83
- package/dist/src/api/testUtil/cases/customStyles.js.map +0 -1
- package/dist/src/api/testUtil/cases/defaultSchema.js +0 -673
- package/dist/src/api/testUtil/cases/defaultSchema.js.map +0 -1
- package/dist/src/api/testUtil/index.js +0 -2
- package/dist/src/api/testUtil/index.js.map +0 -1
- package/dist/src/api/testUtil/partialBlockTestUtil.js +0 -114
- package/dist/src/api/testUtil/partialBlockTestUtil.js.map +0 -1
- package/dist/src/api/testUtil/paste.js +0 -29
- package/dist/src/api/testUtil/paste.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +0 -104
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js +0 -5
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +0 -1
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +0 -281
- package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +0 -1
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +0 -110
- package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +0 -71
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +0 -5
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +0 -10
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +0 -39
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +0 -51
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +0 -17
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +0 -147
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +0 -9
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +0 -11
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js +0 -15
- package/dist/src/blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js.map +0 -1
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js +0 -145
- package/dist/src/blocks/HeadingBlockContent/HeadingBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +0 -114
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js +0 -6
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js +0 -113
- package/dist/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js +0 -224
- package/dist/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js +0 -45
- package/dist/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js +0 -58
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.js.map +0 -1
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js +0 -130
- package/dist/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.js.map +0 -1
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js +0 -52
- package/dist/src/blocks/ParagraphBlockContent/ParagraphBlockContent.js.map +0 -1
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js +0 -129
- package/dist/src/blocks/TableBlockContent/TableBlockContent.js.map +0 -1
- package/dist/src/blocks/TableBlockContent/TableExtension.js +0 -64
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +0 -114
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js +0 -6
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +0 -1
- package/dist/src/blocks/defaultBlockHelpers.js +0 -50
- package/dist/src/blocks/defaultBlockHelpers.js.map +0 -1
- package/dist/src/blocks/defaultBlockTypeGuards.js +0 -40
- package/dist/src/blocks/defaultBlockTypeGuards.js.map +0 -1
- package/dist/src/blocks/defaultBlocks.js +0 -50
- package/dist/src/blocks/defaultBlocks.js.map +0 -1
- package/dist/src/blocks/defaultProps.js +0 -19
- package/dist/src/blocks/defaultProps.js.map +0 -1
- package/dist/src/editor/BlockNoteEditor.js +0 -751
- package/dist/src/editor/BlockNoteEditor.js.map +0 -1
- package/dist/src/editor/BlockNoteEditor.test.js +0 -65
- package/dist/src/editor/BlockNoteEditor.test.js.map +0 -1
- package/dist/src/editor/BlockNoteExtensions.js +0 -192
- package/dist/src/editor/BlockNoteExtensions.js.map +0 -1
- package/dist/src/editor/BlockNoteSchema.js +0 -38
- package/dist/src/editor/BlockNoteSchema.js.map +0 -1
- package/dist/src/editor/BlockNoteTipTapEditor.js +0 -169
- package/dist/src/editor/BlockNoteTipTapEditor.js.map +0 -1
- package/dist/src/editor/cursorPositionTypes.js +0 -2
- package/dist/src/editor/cursorPositionTypes.js.map +0 -1
- package/dist/src/editor/defaultColors.js +0 -77
- package/dist/src/editor/defaultColors.js.map +0 -1
- package/dist/src/editor/selectionTypes.js +0 -2
- package/dist/src/editor/selectionTypes.js.map +0 -1
- package/dist/src/editor/transformPasted.js +0 -79
- package/dist/src/editor/transformPasted.js.map +0 -1
- package/dist/src/exporter/Exporter.js +0 -36
- package/dist/src/exporter/Exporter.js.map +0 -1
- package/dist/src/exporter/index.js +0 -3
- package/dist/src/exporter/index.js.map +0 -1
- package/dist/src/exporter/mapping.js +0 -12
- package/dist/src/exporter/mapping.js.map +0 -1
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js +0 -30
- package/dist/src/extensions/BackgroundColor/BackgroundColorExtension.js.map +0 -1
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js +0 -39
- package/dist/src/extensions/BackgroundColor/BackgroundColorMark.js.map +0 -1
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js +0 -131
- package/dist/src/extensions/FilePanel/FilePanelPlugin.js.map +0 -1
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +0 -197
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +0 -1
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +0 -341
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +0 -1
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +0 -251
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +0 -1
- package/dist/src/extensions/LinkToolbar/protocols.js +0 -14
- package/dist/src/extensions/LinkToolbar/protocols.js.map +0 -1
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js +0 -54
- package/dist/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js.map +0 -1
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +0 -90
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +0 -1
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js +0 -187
- package/dist/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js +0 -68
- package/dist/src/extensions/SideMenu/MultipleNodeSelection.js.map +0 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +0 -347
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/dragging.js +0 -135
- package/dist/src/extensions/SideMenu/dragging.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js +0 -2
- package/dist/src/extensions/SuggestionMenu/DefaultGridSuggestionItem.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js +0 -2
- package/dist/src/extensions/SuggestionMenu/DefaultSuggestionItem.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +0 -245
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js +0 -26
- package/dist/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.js.map +0 -1
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -241
- package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +0 -1
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +0 -579
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +0 -1
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js +0 -36
- package/dist/src/extensions/TextAlignment/TextAlignmentExtension.js.map +0 -1
- package/dist/src/extensions/TextColor/TextColorExtension.js +0 -29
- package/dist/src/extensions/TextColor/TextColorExtension.js.map +0 -1
- package/dist/src/extensions/TextColor/TextColorMark.js +0 -37
- package/dist/src/extensions/TextColor/TextColorMark.js.map +0 -1
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js +0 -58
- package/dist/src/extensions/TrailingNode/TrailingNodeExtension.js.map +0 -1
- package/dist/src/extensions/UniqueID/UniqueID.js +0 -283
- package/dist/src/extensions/UniqueID/UniqueID.js.map +0 -1
- package/dist/src/extensions/getDraggableBlockFromElement.js +0 -13
- package/dist/src/extensions/getDraggableBlockFromElement.js.map +0 -1
- package/dist/src/extensions-shared/UiElementPosition.js +0 -2
- package/dist/src/extensions-shared/UiElementPosition.js.map +0 -1
- package/dist/src/i18n/dictionary.js +0 -4
- package/dist/src/i18n/dictionary.js.map +0 -1
- package/dist/src/i18n/locales/ar.js +0 -298
- package/dist/src/i18n/locales/ar.js.map +0 -1
- package/dist/src/i18n/locales/de.js +0 -313
- package/dist/src/i18n/locales/de.js.map +0 -1
- package/dist/src/i18n/locales/en.js +0 -314
- package/dist/src/i18n/locales/en.js.map +0 -1
- package/dist/src/i18n/locales/es.js +0 -312
- package/dist/src/i18n/locales/es.js.map +0 -1
- package/dist/src/i18n/locales/fr.js +0 -313
- package/dist/src/i18n/locales/fr.js.map +0 -1
- package/dist/src/i18n/locales/hr.js +0 -308
- package/dist/src/i18n/locales/hr.js.map +0 -1
- package/dist/src/i18n/locales/index.js +0 -16
- package/dist/src/i18n/locales/index.js.map +0 -1
- package/dist/src/i18n/locales/is.js +0 -305
- package/dist/src/i18n/locales/is.js.map +0 -1
- package/dist/src/i18n/locales/ja.js +0 -333
- package/dist/src/i18n/locales/ja.js.map +0 -1
- package/dist/src/i18n/locales/ko.js +0 -326
- package/dist/src/i18n/locales/ko.js.map +0 -1
- package/dist/src/i18n/locales/nl.js +0 -313
- package/dist/src/i18n/locales/nl.js.map +0 -1
- package/dist/src/i18n/locales/pl.js +0 -297
- package/dist/src/i18n/locales/pl.js.map +0 -1
- package/dist/src/i18n/locales/pt.js +0 -305
- package/dist/src/i18n/locales/pt.js.map +0 -1
- package/dist/src/i18n/locales/ru.js +0 -340
- package/dist/src/i18n/locales/ru.js.map +0 -1
- package/dist/src/i18n/locales/vi.js +0 -312
- package/dist/src/i18n/locales/vi.js.map +0 -1
- package/dist/src/i18n/locales/zh.js +0 -346
- package/dist/src/i18n/locales/zh.js.map +0 -1
- package/dist/src/index.js +0 -63
- package/dist/src/index.js.map +0 -1
- package/dist/src/pm-nodes/BlockContainer.js +0 -72
- package/dist/src/pm-nodes/BlockContainer.js.map +0 -1
- package/dist/src/pm-nodes/BlockGroup.js +0 -43
- package/dist/src/pm-nodes/BlockGroup.js.map +0 -1
- package/dist/src/pm-nodes/Doc.js +0 -7
- package/dist/src/pm-nodes/Doc.js.map +0 -1
- package/dist/src/pm-nodes/index.js +0 -4
- package/dist/src/pm-nodes/index.js.map +0 -1
- package/dist/src/schema/blocks/createSpec.js +0 -126
- package/dist/src/schema/blocks/createSpec.js.map +0 -1
- package/dist/src/schema/blocks/internal.js +0 -147
- package/dist/src/schema/blocks/internal.js.map +0 -1
- package/dist/src/schema/blocks/types.js +0 -2
- package/dist/src/schema/blocks/types.js.map +0 -1
- package/dist/src/schema/index.js +0 -11
- package/dist/src/schema/index.js.map +0 -1
- package/dist/src/schema/inlineContent/createSpec.js +0 -64
- package/dist/src/schema/inlineContent/createSpec.js.map +0 -1
- package/dist/src/schema/inlineContent/internal.js +0 -52
- package/dist/src/schema/inlineContent/internal.js.map +0 -1
- package/dist/src/schema/inlineContent/types.js +0 -10
- package/dist/src/schema/inlineContent/types.js.map +0 -1
- package/dist/src/schema/propTypes.js +0 -2
- package/dist/src/schema/propTypes.js.map +0 -1
- package/dist/src/schema/styles/createSpec.js +0 -48
- package/dist/src/schema/styles/createSpec.js.map +0 -1
- package/dist/src/schema/styles/internal.js +0 -53
- package/dist/src/schema/styles/internal.js.map +0 -1
- package/dist/src/schema/styles/types.js +0 -2
- package/dist/src/schema/styles/types.js.map +0 -1
- package/dist/src/util/EventEmitter.js +0 -33
- package/dist/src/util/EventEmitter.js.map +0 -1
- package/dist/src/util/browser.js +0 -17
- package/dist/src/util/browser.js.map +0 -1
- package/dist/src/util/combineByGroup.js +0 -20
- package/dist/src/util/combineByGroup.js.map +0 -1
- package/dist/src/util/esmDependencies.js +0 -35
- package/dist/src/util/esmDependencies.js.map +0 -1
- package/dist/src/util/string.js +0 -14
- package/dist/src/util/string.js.map +0 -1
- package/dist/src/util/typescript.js +0 -12
- package/dist/src/util/typescript.js.map +0 -1
- /package/src/api/clipboard/__snapshots__/{childToParent.html → internal/childToParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{childrenToNextParent.html → internal/childrenToNextParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{childrenToNextParentsChildren.html → internal/childrenToNextParentsChildren.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{image.html → internal/image.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{multipleChildren.html → internal/multipleChildren.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{multipleStyledText.html → internal/multipleStyledText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{nestedImage.html → internal/nestedImage.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{partialChildToParent.html → internal/partialChildToParent.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{styledText.html → internal/styledText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableAllCells.html → internal/tableAllCells.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableCell.html → internal/tableCell.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableCellText.html → internal/tableCellText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{tableRow.html → internal/tableRow.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
- /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
|
@@ -78,7 +78,9 @@ function serializeBlock<
|
|
|
78
78
|
for (const [name, spec] of Object.entries(
|
|
79
79
|
editor.schema.blockSchema[block.type as any].propSchema
|
|
80
80
|
)) {
|
|
81
|
-
(
|
|
81
|
+
if (spec.default !== undefined) {
|
|
82
|
+
(props as any)[name] = spec.default;
|
|
83
|
+
}
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
|
|
File without changes
|
|
@@ -1605,6 +1605,22 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
1605
1605
|
}
|
|
1606
1606
|
`;
|
|
1607
1607
|
|
|
1608
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert pageBreak/basic to/from prosemirror 1`] = `
|
|
1609
|
+
{
|
|
1610
|
+
"attrs": {
|
|
1611
|
+
"backgroundColor": "default",
|
|
1612
|
+
"id": "1",
|
|
1613
|
+
"textColor": "default",
|
|
1614
|
+
},
|
|
1615
|
+
"content": [
|
|
1616
|
+
{
|
|
1617
|
+
"type": "pageBreak",
|
|
1618
|
+
},
|
|
1619
|
+
],
|
|
1620
|
+
"type": "blockContainer",
|
|
1621
|
+
}
|
|
1622
|
+
`;
|
|
1623
|
+
|
|
1608
1624
|
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/basic to/from prosemirror 1`] = `
|
|
1609
1625
|
{
|
|
1610
1626
|
"attrs": {
|
|
@@ -355,7 +355,10 @@ export function nodeToBlock<
|
|
|
355
355
|
})) {
|
|
356
356
|
const propSchema = blockSpec.propSchema;
|
|
357
357
|
|
|
358
|
-
if (
|
|
358
|
+
if (
|
|
359
|
+
attr in propSchema &&
|
|
360
|
+
!(propSchema[attr].default === undefined && value === undefined)
|
|
361
|
+
) {
|
|
359
362
|
props[attr] = value;
|
|
360
363
|
}
|
|
361
364
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "1",
|
|
4
|
+
"type": "codeBlock",
|
|
5
|
+
"props": {
|
|
6
|
+
"language": "javascript"
|
|
7
|
+
},
|
|
8
|
+
"content": [
|
|
9
|
+
{
|
|
10
|
+
"type": "text",
|
|
11
|
+
"text": "console.log(\"Should default to JS\")",
|
|
12
|
+
"styles": {}
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"children": []
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "2",
|
|
19
|
+
"type": "codeBlock",
|
|
20
|
+
"props": {
|
|
21
|
+
"language": "typescript"
|
|
22
|
+
},
|
|
23
|
+
"content": [
|
|
24
|
+
{
|
|
25
|
+
"type": "text",
|
|
26
|
+
"text": "console.log(\"Should parse TS from data-language\")",
|
|
27
|
+
"styles": {}
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"children": []
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "3",
|
|
34
|
+
"type": "codeBlock",
|
|
35
|
+
"props": {
|
|
36
|
+
"language": "python"
|
|
37
|
+
},
|
|
38
|
+
"content": [
|
|
39
|
+
{
|
|
40
|
+
"type": "text",
|
|
41
|
+
"text": "print(\"Should parse Python from language- class\")",
|
|
42
|
+
"styles": {}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"children": []
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "4",
|
|
49
|
+
"type": "codeBlock",
|
|
50
|
+
"props": {
|
|
51
|
+
"language": "typescript"
|
|
52
|
+
},
|
|
53
|
+
"content": [
|
|
54
|
+
{
|
|
55
|
+
"type": "text",
|
|
56
|
+
"text": "console.log(\"Should prioritize TS from data-language over language- class\")",
|
|
57
|
+
"styles": {}
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"children": []
|
|
61
|
+
}
|
|
62
|
+
]
|
|
@@ -516,4 +516,13 @@ With Hard Break</p>
|
|
|
516
516
|
|
|
517
517
|
await parseHTMLAndCompareSnapshots(html, "parse-google-docs-html");
|
|
518
518
|
});
|
|
519
|
+
|
|
520
|
+
it("Parse codeblocks", async () => {
|
|
521
|
+
const html = `<pre><code>console.log("Should default to JS")</code></pre>
|
|
522
|
+
<pre><code data-language="typescript">console.log("Should parse TS from data-language")</code></pre>
|
|
523
|
+
<pre><code class="language-python">print("Should parse Python from language- class")</code></pre>
|
|
524
|
+
<pre><code class="language-ruby" data-language="typescript">console.log("Should prioritize TS from data-language over language- class")</code></pre>`;
|
|
525
|
+
|
|
526
|
+
await parseHTMLAndCompareSnapshots(html, "parse-codeblocks");
|
|
527
|
+
});
|
|
519
528
|
});
|
|
@@ -6,16 +6,22 @@ import {
|
|
|
6
6
|
DefaultInlineContentSchema,
|
|
7
7
|
DefaultStyleSchema,
|
|
8
8
|
} from "../../../blocks/defaultBlocks.js";
|
|
9
|
+
import {
|
|
10
|
+
pageBreakSchema,
|
|
11
|
+
withPageBreak,
|
|
12
|
+
} from "../../../blocks/PageBreakBlockContent/schema.js";
|
|
9
13
|
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
14
|
+
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js";
|
|
10
15
|
|
|
11
16
|
export const defaultSchemaTestCases: EditorTestCases<
|
|
12
|
-
DefaultBlockSchema,
|
|
17
|
+
DefaultBlockSchema & typeof pageBreakSchema.blockSchema,
|
|
13
18
|
DefaultInlineContentSchema,
|
|
14
19
|
DefaultStyleSchema
|
|
15
20
|
> = {
|
|
16
21
|
name: "default schema",
|
|
17
22
|
createEditor: () => {
|
|
18
23
|
return BlockNoteEditor.create({
|
|
24
|
+
schema: withPageBreak(BlockNoteSchema.create()),
|
|
19
25
|
uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY,
|
|
20
26
|
});
|
|
21
27
|
},
|
|
@@ -202,6 +208,14 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
202
208
|
},
|
|
203
209
|
],
|
|
204
210
|
},
|
|
211
|
+
{
|
|
212
|
+
name: "pageBreak/basic",
|
|
213
|
+
blocks: [
|
|
214
|
+
{
|
|
215
|
+
type: "pageBreak",
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
},
|
|
205
219
|
{
|
|
206
220
|
name: "file/button",
|
|
207
221
|
blocks: [
|
|
@@ -111,7 +111,10 @@ export function partialBlockToBlockForTesting<
|
|
|
111
111
|
|
|
112
112
|
Object.entries(schema[partialBlock.type!].propSchema).forEach(
|
|
113
113
|
([propKey, propValue]) => {
|
|
114
|
-
if (
|
|
114
|
+
if (
|
|
115
|
+
withDefaults.props[propKey] === undefined &&
|
|
116
|
+
propValue.default !== undefined
|
|
117
|
+
) {
|
|
115
118
|
(withDefaults.props as any)[propKey] = propValue.default;
|
|
116
119
|
}
|
|
117
120
|
}
|
|
@@ -25,6 +25,10 @@ interface CodeBlockOptions {
|
|
|
25
25
|
supportedLanguages: SupportedLanguageConfig[];
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export const shikiParserSymbol = Symbol.for("blocknote.shikiParser");
|
|
29
|
+
export const shikiHighlighterPromiseSymbol = Symbol.for(
|
|
30
|
+
"blocknote.shikiHighlighterPromise"
|
|
31
|
+
);
|
|
28
32
|
export const defaultCodeBlockPropSchema = {
|
|
29
33
|
language: {
|
|
30
34
|
default: "javascript",
|
|
@@ -77,9 +81,10 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
|
77
81
|
const languages = classNames
|
|
78
82
|
.filter((className) => className.startsWith("language-"))
|
|
79
83
|
.map((className) => className.replace("language-", ""));
|
|
80
|
-
const [classLanguage] = languages;
|
|
81
84
|
|
|
82
|
-
|
|
85
|
+
if (languages.length > 0) {
|
|
86
|
+
language = languages[0].toLowerCase();
|
|
87
|
+
}
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
if (!language) {
|
|
@@ -93,6 +98,7 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
|
93
98
|
);
|
|
94
99
|
},
|
|
95
100
|
renderHTML: (attributes) => {
|
|
101
|
+
// TODO: Use `data-language="..."` instead for easier parsing
|
|
96
102
|
return attributes.language && attributes.language !== "text"
|
|
97
103
|
? {
|
|
98
104
|
class: `language-${attributes.language}`,
|
|
@@ -106,9 +112,11 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
|
106
112
|
return [
|
|
107
113
|
{
|
|
108
114
|
tag: "div[data-content-type=" + this.name + "]",
|
|
115
|
+
contentElement: "code",
|
|
109
116
|
},
|
|
110
117
|
{
|
|
111
118
|
tag: "pre",
|
|
119
|
+
contentElement: "code",
|
|
112
120
|
preserveWhitespace: "full",
|
|
113
121
|
},
|
|
114
122
|
];
|
|
@@ -195,19 +203,30 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
|
195
203
|
};
|
|
196
204
|
},
|
|
197
205
|
addProseMirrorPlugins() {
|
|
206
|
+
const supportedLanguages = this.options
|
|
207
|
+
.supportedLanguages as SupportedLanguageConfig[];
|
|
208
|
+
const globalThisForShiki = globalThis as {
|
|
209
|
+
[shikiHighlighterPromiseSymbol]?: Promise<Highlighter>;
|
|
210
|
+
[shikiParserSymbol]?: Parser;
|
|
211
|
+
};
|
|
212
|
+
|
|
198
213
|
let highlighter: Highlighter | undefined;
|
|
199
214
|
let parser: Parser | undefined;
|
|
200
215
|
|
|
201
|
-
const supportedLanguages = this.options
|
|
202
|
-
.supportedLanguages as SupportedLanguageConfig[];
|
|
203
216
|
const lazyParser: Parser = (options) => {
|
|
204
217
|
if (!highlighter) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
218
|
+
globalThisForShiki[shikiHighlighterPromiseSymbol] =
|
|
219
|
+
globalThisForShiki[shikiHighlighterPromiseSymbol] ||
|
|
220
|
+
createHighlighter({
|
|
221
|
+
themes: ["github-dark"],
|
|
222
|
+
langs: [],
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return globalThisForShiki[shikiHighlighterPromiseSymbol].then(
|
|
226
|
+
(createdHighlighter) => {
|
|
227
|
+
highlighter = createdHighlighter;
|
|
228
|
+
}
|
|
229
|
+
);
|
|
211
230
|
}
|
|
212
231
|
|
|
213
232
|
const language = options.language;
|
|
@@ -223,7 +242,9 @@ const CodeBlockContent = createStronglyTypedTiptapNode({
|
|
|
223
242
|
}
|
|
224
243
|
|
|
225
244
|
if (!parser) {
|
|
226
|
-
parser =
|
|
245
|
+
parser =
|
|
246
|
+
globalThisForShiki[shikiParserSymbol] || createParser(highlighter);
|
|
247
|
+
globalThisForShiki[shikiParserSymbol] = parser;
|
|
227
248
|
}
|
|
228
249
|
|
|
229
250
|
return parser(options);
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
PropSchema,
|
|
6
6
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
7
7
|
createStronglyTypedTiptapNode,
|
|
8
|
+
propsToAttributes,
|
|
8
9
|
} from "../../schema/index.js";
|
|
9
10
|
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
10
11
|
import { defaultProps } from "../defaultProps.js";
|
|
@@ -18,26 +19,9 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
18
19
|
name: "heading",
|
|
19
20
|
content: "inline*",
|
|
20
21
|
group: "blockContent",
|
|
22
|
+
|
|
21
23
|
addAttributes() {
|
|
22
|
-
return
|
|
23
|
-
level: {
|
|
24
|
-
default: 1,
|
|
25
|
-
// instead of "level" attributes, use "data-level"
|
|
26
|
-
parseHTML: (element) => {
|
|
27
|
-
const attr = element.getAttribute("data-level")!;
|
|
28
|
-
const parsed = parseInt(attr);
|
|
29
|
-
if (isFinite(parsed)) {
|
|
30
|
-
return parsed;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
},
|
|
34
|
-
renderHTML: (attributes) => {
|
|
35
|
-
return {
|
|
36
|
-
"data-level": (attributes.level as number).toString(),
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
24
|
+
return propsToAttributes(headingPropSchema);
|
|
41
25
|
},
|
|
42
26
|
|
|
43
27
|
addInputRules() {
|
|
@@ -140,15 +124,6 @@ const HeadingBlockContent = createStronglyTypedTiptapNode({
|
|
|
140
124
|
return [
|
|
141
125
|
{
|
|
142
126
|
tag: "div[data-content-type=" + this.name + "]",
|
|
143
|
-
getAttrs: (element) => {
|
|
144
|
-
if (typeof element === "string") {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
level: element.getAttribute("data-level"),
|
|
150
|
-
};
|
|
151
|
-
},
|
|
152
127
|
},
|
|
153
128
|
{
|
|
154
129
|
tag: "h1",
|
package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts
CHANGED
|
@@ -79,7 +79,7 @@ const BulletListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
79
79
|
return [
|
|
80
80
|
// Case for regular HTML list structure.
|
|
81
81
|
{
|
|
82
|
-
tag: "div[data-content-type=" + this.name + "]",
|
|
82
|
+
tag: "div[data-content-type=" + this.name + "]",
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
tag: "li",
|
package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
PropSchema,
|
|
9
9
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
10
10
|
createStronglyTypedTiptapNode,
|
|
11
|
+
propsToAttributes,
|
|
11
12
|
} from "../../../schema/index.js";
|
|
12
13
|
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers.js";
|
|
13
14
|
import { defaultProps } from "../../defaultProps.js";
|
|
@@ -24,22 +25,9 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
24
25
|
name: "checkListItem",
|
|
25
26
|
content: "inline*",
|
|
26
27
|
group: "blockContent",
|
|
28
|
+
|
|
27
29
|
addAttributes() {
|
|
28
|
-
return
|
|
29
|
-
checked: {
|
|
30
|
-
default: false,
|
|
31
|
-
// instead of "checked" attributes, use "data-checked"
|
|
32
|
-
parseHTML: (element) =>
|
|
33
|
-
element.getAttribute("data-checked") === "true" || undefined,
|
|
34
|
-
renderHTML: (attributes) => {
|
|
35
|
-
return attributes.checked
|
|
36
|
-
? {
|
|
37
|
-
"data-checked": (attributes.checked as boolean).toString(),
|
|
38
|
-
}
|
|
39
|
-
: {};
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
30
|
+
return propsToAttributes(checkListItemPropSchema);
|
|
43
31
|
},
|
|
44
32
|
|
|
45
33
|
addInputRules() {
|
|
@@ -130,7 +118,7 @@ const checkListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
130
118
|
parseHTML() {
|
|
131
119
|
return [
|
|
132
120
|
{
|
|
133
|
-
tag: "div[data-content-type=" + this.name + "]",
|
|
121
|
+
tag: "div[data-content-type=" + this.name + "]",
|
|
134
122
|
},
|
|
135
123
|
// Checkbox only.
|
|
136
124
|
{
|
package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts
CHANGED
|
@@ -20,7 +20,7 @@ export const NumberedListIndexingPlugin = () => {
|
|
|
20
20
|
node.type.name === "blockContainer" &&
|
|
21
21
|
node.firstChild!.type.name === "numberedListItem"
|
|
22
22
|
) {
|
|
23
|
-
let newIndex = "1
|
|
23
|
+
let newIndex = `${node.firstChild!.attrs["start"] || 1}`;
|
|
24
24
|
|
|
25
25
|
const blockInfo = getBlockInfo({
|
|
26
26
|
posBeforeNode: pos,
|
|
@@ -60,13 +60,21 @@ export const NumberedListIndexingPlugin = () => {
|
|
|
60
60
|
|
|
61
61
|
const contentNode = blockInfo.blockContent.node;
|
|
62
62
|
const index = contentNode.attrs["index"];
|
|
63
|
+
const isFirst =
|
|
64
|
+
prevBlock?.firstChild?.type.name !== "numberedListItem";
|
|
63
65
|
|
|
64
|
-
if (index !== newIndex) {
|
|
66
|
+
if (index !== newIndex || (contentNode.attrs.start && !isFirst)) {
|
|
65
67
|
modified = true;
|
|
66
68
|
|
|
69
|
+
const { start, ...attrs } = contentNode.attrs;
|
|
70
|
+
|
|
67
71
|
tr.setNodeMarkup(blockInfo.blockContent.beforePos, undefined, {
|
|
68
|
-
...
|
|
72
|
+
...attrs,
|
|
69
73
|
index: newIndex,
|
|
74
|
+
...(typeof start === "number" &&
|
|
75
|
+
isFirst && {
|
|
76
|
+
start,
|
|
77
|
+
}),
|
|
70
78
|
});
|
|
71
79
|
}
|
|
72
80
|
}
|
package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
PropSchema,
|
|
6
6
|
createBlockSpecFromStronglyTypedTiptapNode,
|
|
7
7
|
createStronglyTypedTiptapNode,
|
|
8
|
+
propsToAttributes,
|
|
8
9
|
} from "../../../schema/index.js";
|
|
9
10
|
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers.js";
|
|
10
11
|
import { defaultProps } from "../../defaultProps.js";
|
|
@@ -13,6 +14,7 @@ import { NumberedListIndexingPlugin } from "./NumberedListIndexingPlugin.js";
|
|
|
13
14
|
|
|
14
15
|
export const numberedListItemPropSchema = {
|
|
15
16
|
...defaultProps,
|
|
17
|
+
start: { default: undefined, type: "number" },
|
|
16
18
|
} satisfies PropSchema;
|
|
17
19
|
|
|
18
20
|
const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
@@ -22,6 +24,9 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
22
24
|
priority: 90,
|
|
23
25
|
addAttributes() {
|
|
24
26
|
return {
|
|
27
|
+
...propsToAttributes(numberedListItemPropSchema),
|
|
28
|
+
// the index attribute is only used internally (it's not part of the blocknote schema)
|
|
29
|
+
// that's why it's defined explicitly here, and not part of the prop schema
|
|
25
30
|
index: {
|
|
26
31
|
default: null,
|
|
27
32
|
parseHTML: (element) => element.getAttribute("data-index"),
|
|
@@ -38,15 +43,17 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
38
43
|
return [
|
|
39
44
|
// Creates an ordered list when starting with "1.".
|
|
40
45
|
new InputRule({
|
|
41
|
-
find: new RegExp(`^
|
|
42
|
-
handler: ({ state, chain, range }) => {
|
|
46
|
+
find: new RegExp(`^(\\d+)\\.\\s$`),
|
|
47
|
+
handler: ({ state, chain, range, match }) => {
|
|
43
48
|
const blockInfo = getBlockInfoFromSelection(state);
|
|
44
49
|
if (
|
|
45
50
|
!blockInfo.isBlockContainer ||
|
|
46
|
-
blockInfo.blockContent.node.type.spec.content !== "inline*"
|
|
51
|
+
blockInfo.blockContent.node.type.spec.content !== "inline*" ||
|
|
52
|
+
blockInfo.blockNoteType === "numberedListItem"
|
|
47
53
|
) {
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
56
|
+
const startIndex = parseInt(match[1]);
|
|
50
57
|
|
|
51
58
|
chain()
|
|
52
59
|
.command(
|
|
@@ -55,7 +62,11 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
55
62
|
blockInfo.bnBlock.beforePos,
|
|
56
63
|
{
|
|
57
64
|
type: "numberedListItem",
|
|
58
|
-
props:
|
|
65
|
+
props:
|
|
66
|
+
(startIndex === 1 && {}) ||
|
|
67
|
+
({
|
|
68
|
+
start: startIndex,
|
|
69
|
+
} as any),
|
|
59
70
|
}
|
|
60
71
|
)
|
|
61
72
|
)
|
|
@@ -95,7 +106,7 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
95
106
|
parseHTML() {
|
|
96
107
|
return [
|
|
97
108
|
{
|
|
98
|
-
tag: "div[data-content-type=" + this.name + "]",
|
|
109
|
+
tag: "div[data-content-type=" + this.name + "]",
|
|
99
110
|
},
|
|
100
111
|
// Case for regular HTML list structure.
|
|
101
112
|
// (e.g.: when pasting from other apps)
|
|
@@ -116,7 +127,16 @@ const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
|
116
127
|
parent.tagName === "OL" ||
|
|
117
128
|
(parent.tagName === "DIV" && parent.parentElement!.tagName === "OL")
|
|
118
129
|
) {
|
|
119
|
-
|
|
130
|
+
const startIndex =
|
|
131
|
+
parseInt(parent.getAttribute("start") || "1") || 1;
|
|
132
|
+
|
|
133
|
+
if (element.previousSibling || startIndex === 1) {
|
|
134
|
+
return {};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
start: startIndex,
|
|
139
|
+
};
|
|
120
140
|
}
|
|
121
141
|
|
|
122
142
|
return false;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createBlockSpec,
|
|
3
|
+
CustomBlockConfig,
|
|
4
|
+
Props,
|
|
5
|
+
} from "../../schema/index.js";
|
|
6
|
+
|
|
7
|
+
export const pageBreakConfig = {
|
|
8
|
+
type: "pageBreak" as const,
|
|
9
|
+
propSchema: {},
|
|
10
|
+
content: "none",
|
|
11
|
+
isFileBlock: false,
|
|
12
|
+
isSelectable: false,
|
|
13
|
+
} satisfies CustomBlockConfig;
|
|
14
|
+
export const pageBreakRender = () => {
|
|
15
|
+
const pageBreak = document.createElement("div");
|
|
16
|
+
|
|
17
|
+
pageBreak.className = "bn-page-break";
|
|
18
|
+
pageBreak.setAttribute("data-page-break", "");
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
dom: pageBreak,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export const pageBreakParse = (
|
|
25
|
+
element: HTMLElement
|
|
26
|
+
): Partial<Props<typeof pageBreakConfig.propSchema>> | undefined => {
|
|
27
|
+
if (element.tagName === "DIV" && element.hasAttribute("data-page-break")) {
|
|
28
|
+
return {
|
|
29
|
+
type: "pageBreak",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
export const pageBreakToExternalHTML = () => {
|
|
36
|
+
const pageBreak = document.createElement("div");
|
|
37
|
+
|
|
38
|
+
pageBreak.setAttribute("data-page-break", "");
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
dom: pageBreak,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const PageBreak = createBlockSpec(pageBreakConfig, {
|
|
46
|
+
render: pageBreakRender,
|
|
47
|
+
parse: pageBreakParse,
|
|
48
|
+
toExternalHTML: pageBreakToExternalHTML,
|
|
49
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
2
|
+
import { DefaultSuggestionItem } from "../../extensions/SuggestionMenu/DefaultSuggestionItem.js";
|
|
3
|
+
import { insertOrUpdateBlock } from "../../extensions/SuggestionMenu/getDefaultSlashMenuItems.js";
|
|
4
|
+
import {
|
|
5
|
+
BlockSchema,
|
|
6
|
+
InlineContentSchema,
|
|
7
|
+
StyleSchema,
|
|
8
|
+
} from "../../schema/index.js";
|
|
9
|
+
import { pageBreakSchema } from "./schema.js";
|
|
10
|
+
|
|
11
|
+
export function checkPageBreakBlocksInSchema<
|
|
12
|
+
I extends InlineContentSchema,
|
|
13
|
+
S extends StyleSchema
|
|
14
|
+
>(
|
|
15
|
+
editor: BlockNoteEditor<any, I, S>
|
|
16
|
+
): editor is BlockNoteEditor<typeof pageBreakSchema.blockSchema, I, S> {
|
|
17
|
+
return (
|
|
18
|
+
"pageBreak" in editor.schema.blockSchema &&
|
|
19
|
+
editor.schema.blockSchema["pageBreak"] ===
|
|
20
|
+
pageBreakSchema.blockSchema["pageBreak"]
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getPageBreakSlashMenuItems<
|
|
25
|
+
BSchema extends BlockSchema,
|
|
26
|
+
I extends InlineContentSchema,
|
|
27
|
+
S extends StyleSchema
|
|
28
|
+
>(editor: BlockNoteEditor<BSchema, I, S>) {
|
|
29
|
+
const items: (Omit<DefaultSuggestionItem, "key"> & { key: "page_break" })[] =
|
|
30
|
+
[];
|
|
31
|
+
|
|
32
|
+
if (checkPageBreakBlocksInSchema(editor)) {
|
|
33
|
+
items.push({
|
|
34
|
+
...editor.dictionary.slash_menu.page_break,
|
|
35
|
+
onItemClick: () => {
|
|
36
|
+
insertOrUpdateBlock(editor, {
|
|
37
|
+
type: "pageBreak",
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
key: "page_break",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return items;
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js";
|
|
2
|
+
import {
|
|
3
|
+
BlockSchema,
|
|
4
|
+
InlineContentSchema,
|
|
5
|
+
StyleSchema,
|
|
6
|
+
} from "../../schema/index.js";
|
|
7
|
+
import { PageBreak } from "./PageBreakBlockContent.js";
|
|
8
|
+
|
|
9
|
+
export const pageBreakSchema = BlockNoteSchema.create({
|
|
10
|
+
blockSpecs: {
|
|
11
|
+
pageBreak: PageBreak,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Adds page break support to the given schema.
|
|
17
|
+
*/
|
|
18
|
+
export const withPageBreak = <
|
|
19
|
+
B extends BlockSchema,
|
|
20
|
+
I extends InlineContentSchema,
|
|
21
|
+
S extends StyleSchema
|
|
22
|
+
>(
|
|
23
|
+
schema: BlockNoteSchema<B, I, S>
|
|
24
|
+
) => {
|
|
25
|
+
return BlockNoteSchema.create({
|
|
26
|
+
blockSpecs: {
|
|
27
|
+
...schema.blockSpecs,
|
|
28
|
+
...pageBreakSchema.blockSpecs,
|
|
29
|
+
},
|
|
30
|
+
inlineContentSpecs: schema.inlineContentSpecs,
|
|
31
|
+
styleSpecs: schema.styleSpecs,
|
|
32
|
+
}) as any as BlockNoteSchema<
|
|
33
|
+
// typescript needs some help here
|
|
34
|
+
B & {
|
|
35
|
+
pageBreak: typeof PageBreak.config;
|
|
36
|
+
},
|
|
37
|
+
I,
|
|
38
|
+
S
|
|
39
|
+
>;
|
|
40
|
+
};
|