@blocknote/core 0.20.0 → 0.22.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 +1602 -1569
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- 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/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +3 -3
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +1 -3
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +1 -1
- package/src/api/blockManipulation/selections/selection.ts +5 -5
- 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/paragraphInCustomBlock.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/tableAllCells.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/tableCell.html +1 -0
- package/src/api/clipboard/__snapshots__/internal/tableRow.html +1 -0
- package/src/api/clipboard/clipboardExternal.test.ts +161 -0
- package/src/api/clipboard/{clipboard.test.ts → clipboardInternal.test.ts} +66 -40
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +1 -1
- package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +7 -14
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +6 -6
- package/src/api/clipboard/testUtil.ts +27 -0
- package/src/api/clipboard/toClipboard/copyExtension.ts +8 -2
- package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -1
- 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__/simpleImage/basic/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +2 -2
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +4 -1
- package/src/api/parsers/markdown/__snapshots__/pasted/styled.json +2 -2
- package/src/api/parsers/markdown/parseMarkdown.test.ts +5 -7
- package/src/api/testUtil/partialBlockTestUtil.ts +4 -1
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +13 -14
- package/src/blocks/FileBlockContent/FileBlockContent.ts +5 -12
- package/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.ts +5 -0
- package/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.ts +16 -0
- package/src/blocks/FileBlockContent/helpers/render/createAddFileButton.ts +63 -0
- package/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.ts +80 -0
- package/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.ts +24 -0
- package/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.ts +204 -0
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.ts +13 -0
- package/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.ts +15 -0
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +3 -19
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +20 -28
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +3 -15
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +11 -3
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +25 -5
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +20 -27
- package/src/editor/Block.css +38 -54
- package/src/editor/BlockNoteEditor.test.ts +21 -1
- package/src/editor/BlockNoteEditor.ts +14 -7
- package/src/editor/BlockNoteExtensions.ts +7 -8
- package/src/editor/editor.css +7 -6
- package/src/editor/transformPasted.ts +57 -4
- package/src/extensions/LinkToolbar/protocols.ts +13 -0
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
- package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
- package/src/extensions/SideMenu/dragging.ts +3 -0
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +15 -3
- package/src/index.ts +9 -2
- package/src/schema/blocks/createSpec.ts +1 -1
- package/src/schema/blocks/internal.ts +16 -6
- package/src/schema/inlineContent/createSpec.ts +2 -2
- 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/fromClipboard/handleVSCodePaste.d.ts +2 -3
- package/types/src/api/clipboard/fromClipboard/pasteExtension.d.ts +1 -3
- 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/blocks/AudioBlockContent/AudioBlockContent.d.ts +2 -5
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +2 -5
- package/types/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.d.ts +4 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +9 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.d.ts +6 -0
- package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +9 -0
- package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.d.ts +3 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +2 -5
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +12 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +2 -5
- package/types/src/blocks/defaultBlocks.d.ts +16 -0
- package/types/src/editor/BlockNoteEditor.d.ts +6 -4
- package/types/src/editor/transformPasted.d.ts +8 -4
- package/types/src/extensions/LinkToolbar/protocols.d.ts +2 -0
- package/types/src/index.d.ts +9 -2
- 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 -246
- 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 -26
- 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 -132
- 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 -109
- 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 -97
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.js +0 -5
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.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 -70
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +0 -1
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.js +0 -317
- package/dist/src/blocks/FileBlockContent/fileBlockHelpers.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 -106
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +0 -1
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.js +0 -6
- package/dist/src/blocks/ImageBlockContent/imageBlockHelpers.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 -103
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js +0 -6
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.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 -748
- 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 -196
- 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/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 -343
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +0 -1
- package/dist/src/extensions/SideMenu/dragging.js +0 -132
- 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 -570
- 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 -56
- 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__/tableAllCells.html +0 -1
- package/src/api/clipboard/__snapshots__/tableCell.html +0 -1
- package/src/api/clipboard/__snapshots__/tableRow.html +0 -1
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +0 -456
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +0 -41
- /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__/{tableCellText.html → internal/tableCellText.html} +0 -0
- /package/src/api/clipboard/__snapshots__/{unstyledText.html → internal/unstyledText.html} +0 -0
- /package/src/blocks/AudioBlockContent/{audioBlockHelpers.ts → parseAudioElement.ts} +0 -0
- /package/src/blocks/ImageBlockContent/{imageBlockHelpers.ts → parseImageElement.ts} +0 -0
- /package/src/blocks/VideoBlockContent/{videoBlockHelpers.ts → parseVideoElement.ts} +0 -0
- /package/types/src/api/clipboard/{clipboard.test.d.ts → clipboardExternal.test.d.ts} +0 -0
- /package/types/src/blocks/AudioBlockContent/{audioBlockHelpers.d.ts → parseAudioElement.d.ts} +0 -0
- /package/types/src/blocks/ImageBlockContent/{imageBlockHelpers.d.ts → parseImageElement.d.ts} +0 -0
- /package/types/src/blocks/VideoBlockContent/{videoBlockHelpers.d.ts → parseVideoElement.d.ts} +0 -0
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { splitBlockCommand } from "../../api/blockManipulation/commands/splitBlock/splitBlock.js";
|
|
2
|
-
import { updateBlockCommand } from "../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
-
import { getBlockInfoFromSelection } from "../../api/getBlockInfoFromPos.js";
|
|
4
|
-
export const handleEnter = (editor) => {
|
|
5
|
-
const ttEditor = editor._tiptapEditor;
|
|
6
|
-
const blockInfo = getBlockInfoFromSelection(ttEditor.state);
|
|
7
|
-
if (!blockInfo.isBlockContainer) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
const { bnBlock: blockContainer, blockContent } = blockInfo;
|
|
11
|
-
const selectionEmpty = ttEditor.state.selection.anchor === ttEditor.state.selection.head;
|
|
12
|
-
if (!(blockContent.node.type.name === "bulletListItem" ||
|
|
13
|
-
blockContent.node.type.name === "numberedListItem" ||
|
|
14
|
-
blockContent.node.type.name === "checkListItem") ||
|
|
15
|
-
!selectionEmpty) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return ttEditor.commands.first(({ state, chain, commands }) => [
|
|
19
|
-
() =>
|
|
20
|
-
// Changes list item block to a paragraph block if the content is empty.
|
|
21
|
-
commands.command(() => {
|
|
22
|
-
if (blockContent.node.childCount === 0) {
|
|
23
|
-
return commands.command(updateBlockCommand(editor, blockContainer.beforePos, {
|
|
24
|
-
type: "paragraph",
|
|
25
|
-
props: {},
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}),
|
|
30
|
-
() =>
|
|
31
|
-
// Splits the current block, moving content inside that's after the cursor
|
|
32
|
-
// to a new block of the same type below.
|
|
33
|
-
commands.command(() => {
|
|
34
|
-
if (blockContent.node.childCount > 0) {
|
|
35
|
-
chain()
|
|
36
|
-
.deleteSelection()
|
|
37
|
-
.command(splitBlockCommand(state.selection.from, true))
|
|
38
|
-
.run();
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}),
|
|
43
|
-
]);
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=ListItemKeyboardShortcuts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItemKeyboardShortcuts.js","sourceRoot":"","sources":["../../../../src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+DAA+D,CAAC;AAClG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iEAAiE,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,MAAM,CAAC,MAAM,WAAW,GAAG,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AC,OAAO,CAAC,GAAG,EAAE;YACpB,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;gBACrC,KAAK,EAAE;qBACJ,eAAe,EAAE;qBACjB,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;qBACtD,GAAG,EAAE,CAAC;gBAET,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;KACL,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
-
import { getBlockInfo } from "../../../api/getBlockInfoFromPos.js";
|
|
3
|
-
// ProseMirror Plugin which automatically assigns indices to ordered list items per nesting level.
|
|
4
|
-
const PLUGIN_KEY = new PluginKey(`numbered-list-indexing`);
|
|
5
|
-
export const NumberedListIndexingPlugin = () => {
|
|
6
|
-
return new Plugin({
|
|
7
|
-
key: PLUGIN_KEY,
|
|
8
|
-
appendTransaction: (_transactions, _oldState, newState) => {
|
|
9
|
-
const tr = newState.tr;
|
|
10
|
-
tr.setMeta("numberedListIndexing", true);
|
|
11
|
-
let modified = false;
|
|
12
|
-
// Traverses each node the doc using DFS, so blocks which are on the same nesting level will be traversed in the
|
|
13
|
-
// same order they appear. This means the index of each list item block can be calculated by incrementing the
|
|
14
|
-
// index of the previous list item block.
|
|
15
|
-
newState.doc.descendants((node, pos) => {
|
|
16
|
-
if (node.type.name === "blockContainer" &&
|
|
17
|
-
node.firstChild.type.name === "numberedListItem") {
|
|
18
|
-
let newIndex = "1";
|
|
19
|
-
const blockInfo = getBlockInfo({
|
|
20
|
-
posBeforeNode: pos,
|
|
21
|
-
node,
|
|
22
|
-
});
|
|
23
|
-
if (!blockInfo.isBlockContainer) {
|
|
24
|
-
throw new Error("impossible");
|
|
25
|
-
}
|
|
26
|
-
// Checks if this block is the start of a new ordered list, i.e. if it's the first block in the document, the
|
|
27
|
-
// first block in its nesting level, or the previous block is not an ordered list item.
|
|
28
|
-
const prevBlock = tr.doc.resolve(blockInfo.bnBlock.beforePos).nodeBefore;
|
|
29
|
-
if (prevBlock) {
|
|
30
|
-
const prevBlockInfo = getBlockInfo({
|
|
31
|
-
posBeforeNode: blockInfo.bnBlock.beforePos - prevBlock.nodeSize,
|
|
32
|
-
node: prevBlock,
|
|
33
|
-
});
|
|
34
|
-
const isPrevBlockOrderedListItem = prevBlockInfo.blockNoteType === "numberedListItem";
|
|
35
|
-
if (isPrevBlockOrderedListItem) {
|
|
36
|
-
if (!prevBlockInfo.isBlockContainer) {
|
|
37
|
-
throw new Error("impossible");
|
|
38
|
-
}
|
|
39
|
-
const prevBlockIndex = prevBlockInfo.blockContent.node.attrs["index"];
|
|
40
|
-
newIndex = (parseInt(prevBlockIndex) + 1).toString();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const contentNode = blockInfo.blockContent.node;
|
|
44
|
-
const index = contentNode.attrs["index"];
|
|
45
|
-
if (index !== newIndex) {
|
|
46
|
-
modified = true;
|
|
47
|
-
tr.setNodeMarkup(blockInfo.blockContent.beforePos, undefined, {
|
|
48
|
-
...contentNode.attrs,
|
|
49
|
-
index: newIndex,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return modified ? tr : null;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
//# sourceMappingURL=NumberedListIndexingPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumberedListIndexingPlugin.js","sourceRoot":"","sources":["../../../../../src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qCA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SAAS;yBAChB,CAAC,CAAC;wBAEH,MAAM,0BAA0B,GAC9B,aAAa,CAAC,aAAa,KAAK,kBAAkB,CAAC;wBAErD,IAAI,0BAA0B,EAAE,CAAC;4BAC/B,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;gCACpC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;4BAChC,CAAC;4BACD,MAAM,cAAc,GAClB,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;4BAEjD,QAAQ,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;wBACvD,CAAC;oBACH,CAAC;oBAED,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC;oBAChD,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBAEzC,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;wBACvB,QAAQ,GAAG,IAAI,CAAC;wBAEhB,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE;4BAC5D,GAAG,WAAW,CAAC,KAAK;4BACpB,KAAK,EAAE,QAAQ;yBAChB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { InputRule } from "@tiptap/core";
|
|
2
|
-
import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
3
|
-
import { getBlockInfoFromSelection } from "../../../api/getBlockInfoFromPos.js";
|
|
4
|
-
import { createBlockSpecFromStronglyTypedTiptapNode, createStronglyTypedTiptapNode, } from "../../../schema/index.js";
|
|
5
|
-
import { createDefaultBlockDOMOutputSpec } from "../../defaultBlockHelpers.js";
|
|
6
|
-
import { defaultProps } from "../../defaultProps.js";
|
|
7
|
-
import { handleEnter } from "../ListItemKeyboardShortcuts.js";
|
|
8
|
-
import { NumberedListIndexingPlugin } from "./NumberedListIndexingPlugin.js";
|
|
9
|
-
export const numberedListItemPropSchema = {
|
|
10
|
-
...defaultProps,
|
|
11
|
-
};
|
|
12
|
-
const NumberedListItemBlockContent = createStronglyTypedTiptapNode({
|
|
13
|
-
name: "numberedListItem",
|
|
14
|
-
content: "inline*",
|
|
15
|
-
group: "blockContent",
|
|
16
|
-
priority: 90,
|
|
17
|
-
addAttributes() {
|
|
18
|
-
return {
|
|
19
|
-
index: {
|
|
20
|
-
default: null,
|
|
21
|
-
parseHTML: (element) => element.getAttribute("data-index"),
|
|
22
|
-
renderHTML: (attributes) => {
|
|
23
|
-
return {
|
|
24
|
-
"data-index": attributes.index,
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
addInputRules() {
|
|
31
|
-
return [
|
|
32
|
-
// Creates an ordered list when starting with "1.".
|
|
33
|
-
new InputRule({
|
|
34
|
-
find: new RegExp(`^1\\.\\s$`),
|
|
35
|
-
handler: ({ state, chain, range }) => {
|
|
36
|
-
const blockInfo = getBlockInfoFromSelection(state);
|
|
37
|
-
if (!blockInfo.isBlockContainer ||
|
|
38
|
-
blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
chain()
|
|
42
|
-
.command(updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
43
|
-
type: "numberedListItem",
|
|
44
|
-
props: {},
|
|
45
|
-
}))
|
|
46
|
-
// Removes the "1." characters used to set the list.
|
|
47
|
-
.deleteRange({ from: range.from, to: range.to });
|
|
48
|
-
},
|
|
49
|
-
}),
|
|
50
|
-
];
|
|
51
|
-
},
|
|
52
|
-
addKeyboardShortcuts() {
|
|
53
|
-
return {
|
|
54
|
-
Enter: () => handleEnter(this.options.editor),
|
|
55
|
-
"Mod-Shift-7": () => {
|
|
56
|
-
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
57
|
-
if (!blockInfo.isBlockContainer ||
|
|
58
|
-
blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return this.editor.commands.command(updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
62
|
-
type: "numberedListItem",
|
|
63
|
-
props: {},
|
|
64
|
-
}));
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
addProseMirrorPlugins() {
|
|
69
|
-
return [NumberedListIndexingPlugin()];
|
|
70
|
-
},
|
|
71
|
-
parseHTML() {
|
|
72
|
-
return [
|
|
73
|
-
{
|
|
74
|
-
tag: "div[data-content-type=" + this.name + "]", // TODO: remove if we can't come up with test case that needs this
|
|
75
|
-
},
|
|
76
|
-
// Case for regular HTML list structure.
|
|
77
|
-
// (e.g.: when pasting from other apps)
|
|
78
|
-
{
|
|
79
|
-
tag: "li",
|
|
80
|
-
getAttrs: (element) => {
|
|
81
|
-
if (typeof element === "string") {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
const parent = element.parentElement;
|
|
85
|
-
if (parent === null) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
if (parent.tagName === "OL" ||
|
|
89
|
-
(parent.tagName === "DIV" && parent.parentElement.tagName === "OL")) {
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
},
|
|
94
|
-
node: "numberedListItem",
|
|
95
|
-
},
|
|
96
|
-
// Case for BlockNote list structure.
|
|
97
|
-
// (e.g.: when pasting from blocknote)
|
|
98
|
-
{
|
|
99
|
-
tag: "p",
|
|
100
|
-
getAttrs: (element) => {
|
|
101
|
-
if (typeof element === "string") {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
const parent = element.parentElement;
|
|
105
|
-
if (parent === null) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
if (parent.getAttribute("data-content-type") === "numberedListItem") {
|
|
109
|
-
return {};
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
},
|
|
113
|
-
priority: 300,
|
|
114
|
-
node: "numberedListItem",
|
|
115
|
-
},
|
|
116
|
-
];
|
|
117
|
-
},
|
|
118
|
-
renderHTML({ HTMLAttributes }) {
|
|
119
|
-
return createDefaultBlockDOMOutputSpec(this.name,
|
|
120
|
-
// We use a <p> tag, because for <li> tags we'd need an <ol> element to
|
|
121
|
-
// put them in to be semantically correct, which we can't have due to the
|
|
122
|
-
// schema.
|
|
123
|
-
"p", {
|
|
124
|
-
...(this.options.domAttributes?.blockContent || {}),
|
|
125
|
-
...HTMLAttributes,
|
|
126
|
-
}, this.options.domAttributes?.inlineContent || {});
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
export const NumberedListItem = createBlockSpecFromStronglyTypedTiptapNode(NumberedListItemBlockContent, numberedListItemPropSchema);
|
|
130
|
-
//# sourceMappingURL=NumberedListItemBlockContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NumberedListItemBlockContent.js","sourceRoot":"","sources":["../../../../../src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oEAAoE,CAAC;AACxG,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAEL,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAA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,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,0CAA0C,CACxE,4BAA4B,EAC5B,0BAA0B,CAC3B,CAAC"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { updateBlockCommand } from "../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
2
|
-
import { getBlockInfoFromSelection } from "../../api/getBlockInfoFromPos.js";
|
|
3
|
-
import { createBlockSpecFromStronglyTypedTiptapNode, createStronglyTypedTiptapNode, } from "../../schema/index.js";
|
|
4
|
-
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
5
|
-
import { defaultProps } from "../defaultProps.js";
|
|
6
|
-
export const paragraphPropSchema = {
|
|
7
|
-
...defaultProps,
|
|
8
|
-
};
|
|
9
|
-
export const ParagraphBlockContent = createStronglyTypedTiptapNode({
|
|
10
|
-
name: "paragraph",
|
|
11
|
-
content: "inline*",
|
|
12
|
-
group: "blockContent",
|
|
13
|
-
addKeyboardShortcuts() {
|
|
14
|
-
return {
|
|
15
|
-
"Mod-Alt-0": () => {
|
|
16
|
-
const blockInfo = getBlockInfoFromSelection(this.editor.state);
|
|
17
|
-
if (!blockInfo.isBlockContainer ||
|
|
18
|
-
blockInfo.blockContent.node.type.spec.content !== "inline*") {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
return this.editor.commands.command(updateBlockCommand(this.options.editor, blockInfo.bnBlock.beforePos, {
|
|
22
|
-
type: "paragraph",
|
|
23
|
-
props: {},
|
|
24
|
-
}));
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
parseHTML() {
|
|
29
|
-
return [
|
|
30
|
-
{ tag: "div[data-content-type=" + this.name + "]" },
|
|
31
|
-
{
|
|
32
|
-
tag: "p",
|
|
33
|
-
priority: 200,
|
|
34
|
-
getAttrs: (element) => {
|
|
35
|
-
if (typeof element === "string" || !element.textContent?.trim()) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return {};
|
|
39
|
-
},
|
|
40
|
-
node: "paragraph",
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
},
|
|
44
|
-
renderHTML({ HTMLAttributes }) {
|
|
45
|
-
return createDefaultBlockDOMOutputSpec(this.name, "p", {
|
|
46
|
-
...(this.options.domAttributes?.blockContent || {}),
|
|
47
|
-
...HTMLAttributes,
|
|
48
|
-
}, this.options.domAttributes?.inlineContent || {});
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
export const Paragraph = createBlockSpecFromStronglyTypedTiptapNode(ParagraphBlockContent, paragraphPropSchema);
|
|
52
|
-
//# sourceMappingURL=ParagraphBlockContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ParagraphBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iEAAiE,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACL,0CAA0C,EAC1C,6BAA6B,GAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,YAAY;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;IACjE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,cAAc;IAErB,oBAAoB;QAClB,OAAO;YACL,WAAW,EAAE,GAAG,EAAE;gBAChB,MAAM,SAAS,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC/D,IACE,CAAC,SAAS,CAAC,gBAAgB;oBAC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{ Node } from "@tiptap/core";
|
|
2
|
-
import { TableCell } from "@tiptap/extension-table-cell";
|
|
3
|
-
import { TableHeader } from "@tiptap/extension-table-header";
|
|
4
|
-
import { TableRow } from "@tiptap/extension-table-row";
|
|
5
|
-
import { TableView } from "prosemirror-tables";
|
|
6
|
-
import { createBlockSpecFromStronglyTypedTiptapNode, createStronglyTypedTiptapNode, } from "../../schema/index.js";
|
|
7
|
-
import { mergeCSSClasses } from "../../util/browser.js";
|
|
8
|
-
import { createDefaultBlockDOMOutputSpec } from "../defaultBlockHelpers.js";
|
|
9
|
-
import { defaultProps } from "../defaultProps.js";
|
|
10
|
-
import { EMPTY_CELL_WIDTH, TableExtension } from "./TableExtension.js";
|
|
11
|
-
export const tablePropSchema = {
|
|
12
|
-
textColor: defaultProps.textColor,
|
|
13
|
-
};
|
|
14
|
-
export const TableBlockContent = createStronglyTypedTiptapNode({
|
|
15
|
-
name: "table",
|
|
16
|
-
content: "tableRow+",
|
|
17
|
-
group: "blockContent",
|
|
18
|
-
tableRole: "table",
|
|
19
|
-
isolating: true,
|
|
20
|
-
parseHTML() {
|
|
21
|
-
return [{ tag: "table" }];
|
|
22
|
-
},
|
|
23
|
-
renderHTML({ HTMLAttributes }) {
|
|
24
|
-
return createDefaultBlockDOMOutputSpec(this.name, "table", {
|
|
25
|
-
...(this.options.domAttributes?.blockContent || {}),
|
|
26
|
-
...HTMLAttributes,
|
|
27
|
-
}, this.options.domAttributes?.inlineContent || {});
|
|
28
|
-
},
|
|
29
|
-
// This node view is needed for the `columnResizing` plugin. By default, the
|
|
30
|
-
// plugin adds its own node view, which overrides how the node is rendered vs
|
|
31
|
-
// `renderHTML`. This means that the wrapping `blockContent` HTML element is
|
|
32
|
-
// no longer rendered. The `columnResizing` plugin uses the `TableView` as its
|
|
33
|
-
// default node view. `BlockNoteTableView` extends it by wrapping it in a
|
|
34
|
-
// `blockContent` element, so the DOM structure is consistent with other block
|
|
35
|
-
// types.
|
|
36
|
-
addNodeView() {
|
|
37
|
-
return ({ node, HTMLAttributes }) => {
|
|
38
|
-
class BlockNoteTableView extends TableView {
|
|
39
|
-
node;
|
|
40
|
-
cellMinWidth;
|
|
41
|
-
blockContentHTMLAttributes;
|
|
42
|
-
constructor(node, cellMinWidth, blockContentHTMLAttributes) {
|
|
43
|
-
super(node, cellMinWidth);
|
|
44
|
-
this.node = node;
|
|
45
|
-
this.cellMinWidth = cellMinWidth;
|
|
46
|
-
this.blockContentHTMLAttributes = blockContentHTMLAttributes;
|
|
47
|
-
const blockContent = document.createElement("div");
|
|
48
|
-
blockContent.className = mergeCSSClasses("bn-block-content", blockContentHTMLAttributes.class);
|
|
49
|
-
blockContent.setAttribute("data-content-type", "table");
|
|
50
|
-
for (const [attribute, value] of Object.entries(blockContentHTMLAttributes)) {
|
|
51
|
-
if (attribute !== "class") {
|
|
52
|
-
blockContent.setAttribute(attribute, value);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const tableWrapper = this.dom;
|
|
56
|
-
const tableWrapperInner = document.createElement("div");
|
|
57
|
-
tableWrapperInner.className = "tableWrapper-inner";
|
|
58
|
-
tableWrapperInner.appendChild(tableWrapper.firstChild);
|
|
59
|
-
tableWrapper.appendChild(tableWrapperInner);
|
|
60
|
-
blockContent.appendChild(tableWrapper);
|
|
61
|
-
const floatingContainer = document.createElement("div");
|
|
62
|
-
floatingContainer.className = "table-widgets-container";
|
|
63
|
-
floatingContainer.style.position = "relative";
|
|
64
|
-
tableWrapper.appendChild(floatingContainer);
|
|
65
|
-
this.dom = blockContent;
|
|
66
|
-
}
|
|
67
|
-
ignoreMutation(record) {
|
|
68
|
-
return (!record.target.closest(".tableWrapper-inner") ||
|
|
69
|
-
super.ignoreMutation(record));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return new BlockNoteTableView(node, EMPTY_CELL_WIDTH, {
|
|
73
|
-
...(this.options.domAttributes?.blockContent || {}),
|
|
74
|
-
...HTMLAttributes,
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
const TableParagraph = Node.create({
|
|
80
|
-
name: "tableParagraph",
|
|
81
|
-
group: "tableContent",
|
|
82
|
-
content: "inline*",
|
|
83
|
-
parseHTML() {
|
|
84
|
-
return [
|
|
85
|
-
{
|
|
86
|
-
preserveWhitespace: "full",
|
|
87
|
-
// set this rule as high priority so it takes precedence over the default paragraph rule,
|
|
88
|
-
// but only if we're in the tableContent context
|
|
89
|
-
priority: 210,
|
|
90
|
-
context: "tableContent",
|
|
91
|
-
tag: "p",
|
|
92
|
-
getAttrs: (_element) => {
|
|
93
|
-
return {};
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
tag: "p",
|
|
98
|
-
getAttrs: (element) => {
|
|
99
|
-
if (typeof element === "string" || !element.textContent) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
const parent = element.parentElement;
|
|
103
|
-
if (parent === null) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
if (parent.tagName === "TD") {
|
|
107
|
-
return {};
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
},
|
|
114
|
-
renderHTML({ HTMLAttributes }) {
|
|
115
|
-
return ["p", HTMLAttributes, 0];
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
export const Table = createBlockSpecFromStronglyTypedTiptapNode(TableBlockContent, tablePropSchema, [
|
|
119
|
-
TableExtension,
|
|
120
|
-
TableParagraph,
|
|
121
|
-
TableHeader.extend({
|
|
122
|
-
content: "tableContent",
|
|
123
|
-
}),
|
|
124
|
-
TableCell.extend({
|
|
125
|
-
content: "tableContent",
|
|
126
|
-
}),
|
|
127
|
-
TableRow,
|
|
128
|
-
]);
|
|
129
|
-
//# sourceMappingURL=TableBlockContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableBlockContent.js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CAAC;oBACf,CAAC;oBAED,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;oBAErC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;wBACpB,OAAO,KAAK,CAAC;oBACf,CAAC;oBAED,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;wBAC5B,OAAO,EAAE,CAAC;oBACZ,CAAC;oBAED,OAAO,KAAK,CAAC;gBACf,CAAC;aACF;SACF,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,EAAE,cAAc,EAAE;QAC3B,OAAO,CAAC,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,0CAA0C,CAC7D,iBAAiB,EACjB,eAAe,EACf;IACE,cAAc;IACd,cAAc;IACd,WAAW,CAAC,MAAM,CAAC;QACjB,OAAO,EAAE,cAAc;KACxB,CAAC;IACF,SAAS,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,cAAc;KACxB,CAAC;IACF,QAAQ;CACT,CACF,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { callOrReturn, Extension, getExtensionField } from "@tiptap/core";
|
|
2
|
-
import { columnResizing, goToNextCell, tableEditing } from "prosemirror-tables";
|
|
3
|
-
export const RESIZE_MIN_WIDTH = 35;
|
|
4
|
-
export const EMPTY_CELL_WIDTH = 120;
|
|
5
|
-
export const EMPTY_CELL_HEIGHT = 31;
|
|
6
|
-
export const TableExtension = Extension.create({
|
|
7
|
-
name: "BlockNoteTableExtension",
|
|
8
|
-
addProseMirrorPlugins: () => {
|
|
9
|
-
return [
|
|
10
|
-
columnResizing({
|
|
11
|
-
cellMinWidth: RESIZE_MIN_WIDTH,
|
|
12
|
-
defaultCellMinWidth: EMPTY_CELL_WIDTH,
|
|
13
|
-
// We set this to null as we implement our own node view in the table
|
|
14
|
-
// block content. This node view is the same as what's used by default,
|
|
15
|
-
// but is wrapped in a `blockContent` HTML element.
|
|
16
|
-
View: null,
|
|
17
|
-
}),
|
|
18
|
-
tableEditing(),
|
|
19
|
-
];
|
|
20
|
-
},
|
|
21
|
-
addKeyboardShortcuts() {
|
|
22
|
-
return {
|
|
23
|
-
// Makes enter create a new line within the cell.
|
|
24
|
-
Enter: () => {
|
|
25
|
-
if (this.editor.state.selection.empty &&
|
|
26
|
-
this.editor.state.selection.$head.parent.type.name ===
|
|
27
|
-
"tableParagraph") {
|
|
28
|
-
this.editor.commands.setHardBreak();
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
},
|
|
33
|
-
// Ensures that backspace won't delete the table if the text cursor is at
|
|
34
|
-
// the start of a cell and the selection is empty.
|
|
35
|
-
Backspace: () => {
|
|
36
|
-
const selection = this.editor.state.selection;
|
|
37
|
-
const selectionIsEmpty = selection.empty;
|
|
38
|
-
const selectionIsAtStartOfNode = selection.$head.parentOffset === 0;
|
|
39
|
-
const selectionIsInTableParagraphNode = selection.$head.node().type.name === "tableParagraph";
|
|
40
|
-
return (selectionIsEmpty &&
|
|
41
|
-
selectionIsAtStartOfNode &&
|
|
42
|
-
selectionIsInTableParagraphNode);
|
|
43
|
-
},
|
|
44
|
-
// Enables navigating cells using the tab key.
|
|
45
|
-
Tab: () => {
|
|
46
|
-
return this.editor.commands.command(({ state, dispatch, view }) => goToNextCell(1)(state, dispatch, view));
|
|
47
|
-
},
|
|
48
|
-
"Shift-Tab": () => {
|
|
49
|
-
return this.editor.commands.command(({ state, dispatch, view }) => goToNextCell(-1)(state, dispatch, view));
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
extendNodeSchema(extension) {
|
|
54
|
-
const context = {
|
|
55
|
-
name: extension.name,
|
|
56
|
-
options: extension.options,
|
|
57
|
-
storage: extension.storage,
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
tableRole: callOrReturn(getExtensionField(extension, "tableRole", context)),
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=TableExtension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableExtension.js","sourceRoot":"","sources":["../../../../src/blocks/TableBlockContent/TableExtension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhF,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC;IAC7C,IAAI,EAAE,yBAAyB;IAE/B,qBAAqB,EAAE,GAAG,EAAE;QAC1B,OAAO;YACL,cAAc,CAAC;gBACb,YAAY,EAAE,gBAAgB;gBAC9B,mBAAmB,EAAE,gBAAgB;gBACrC,qEAAqE;gBACrE,uEAAuE;gBACvE,mDAAmD;gBACnD,IAAI,EAAE,IAAI;aACX,CAAC;YACF,YAAY,EAAE;SACf,CAAC;IACJ,CAAC;IAED,oBAAoB;QAClB,OAAO;YACL,iDAAiD;YACjD,KAAK,EAAE,GAAG,EAAE;gBACV,IACE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK;oBACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;wBAChD,gBAAgB,EAClB,CAAC;oBACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;oBAEpC,OAAO,IAAI,CAAC;gBACd,CAAC;gBAED,OAAO,KAAK,CAAC;YACf,CAAC;YACD,yE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AE,OAAO,CAAC,CACnD;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { createBlockSpec, } from "../../schema/index.js";
|
|
2
|
-
import { defaultProps } from "../defaultProps.js";
|
|
3
|
-
import { createFigureWithCaption, createFileAndCaptionWrapper, createFileBlockWrapper, createLinkWithCaption, createResizeHandlesWrapper, parseFigureElement, } from "../FileBlockContent/fileBlockHelpers.js";
|
|
4
|
-
import { parseVideoElement } from "./videoBlockHelpers.js";
|
|
5
|
-
export const FILE_VIDEO_ICON_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"></path></svg>';
|
|
6
|
-
export const videoPropSchema = {
|
|
7
|
-
textAlignment: defaultProps.textAlignment,
|
|
8
|
-
backgroundColor: defaultProps.backgroundColor,
|
|
9
|
-
// File name.
|
|
10
|
-
name: {
|
|
11
|
-
default: "",
|
|
12
|
-
},
|
|
13
|
-
// File url.
|
|
14
|
-
url: {
|
|
15
|
-
default: "",
|
|
16
|
-
},
|
|
17
|
-
// File caption.
|
|
18
|
-
caption: {
|
|
19
|
-
default: "",
|
|
20
|
-
},
|
|
21
|
-
showPreview: {
|
|
22
|
-
default: true,
|
|
23
|
-
},
|
|
24
|
-
// File preview width in px.
|
|
25
|
-
previewWidth: {
|
|
26
|
-
default: 512,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
export const videoBlockConfig = {
|
|
30
|
-
type: "video",
|
|
31
|
-
propSchema: videoPropSchema,
|
|
32
|
-
content: "none",
|
|
33
|
-
isFileBlock: true,
|
|
34
|
-
fileBlockAccept: ["video/*"],
|
|
35
|
-
};
|
|
36
|
-
export const videoRender = (block, editor) => {
|
|
37
|
-
const icon = document.createElement("div");
|
|
38
|
-
icon.innerHTML = FILE_VIDEO_ICON_SVG;
|
|
39
|
-
const video = document.createElement("video");
|
|
40
|
-
video.className = "bn-visual-media";
|
|
41
|
-
video.src = block.props.url;
|
|
42
|
-
video.controls = true;
|
|
43
|
-
video.contentEditable = "false";
|
|
44
|
-
video.draggable = false;
|
|
45
|
-
video.width = Math.min(block.props.previewWidth, editor.domElement.firstElementChild.clientWidth);
|
|
46
|
-
const file = createResizeHandlesWrapper(block, editor, video, () => video.width, (width) => (video.width = width));
|
|
47
|
-
const element = createFileAndCaptionWrapper(block, file.dom);
|
|
48
|
-
return createFileBlockWrapper(block, editor, element, editor.dictionary.file_blocks.video.add_button_text, icon.firstElementChild);
|
|
49
|
-
};
|
|
50
|
-
export const videoParse = (element) => {
|
|
51
|
-
if (element.tagName === "VIDEO") {
|
|
52
|
-
return parseVideoElement(element);
|
|
53
|
-
}
|
|
54
|
-
if (element.tagName === "FIGURE") {
|
|
55
|
-
const parsedFigure = parseFigureElement(element, "video");
|
|
56
|
-
if (!parsedFigure) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
const { targetElement, caption } = parsedFigure;
|
|
60
|
-
return {
|
|
61
|
-
...parseVideoElement(targetElement),
|
|
62
|
-
caption,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return undefined;
|
|
66
|
-
};
|
|
67
|
-
export const videoToExternalHTML = (block) => {
|
|
68
|
-
if (!block.props.url) {
|
|
69
|
-
const div = document.createElement("p");
|
|
70
|
-
div.textContent = "Add video";
|
|
71
|
-
return {
|
|
72
|
-
dom: div,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
let video;
|
|
76
|
-
if (block.props.showPreview) {
|
|
77
|
-
video = document.createElement("video");
|
|
78
|
-
video.src = block.props.url;
|
|
79
|
-
video.width = block.props.previewWidth;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
video = document.createElement("a");
|
|
83
|
-
video.href = block.props.url;
|
|
84
|
-
video.textContent = block.props.name || block.props.url;
|
|
85
|
-
}
|
|
86
|
-
if (block.props.caption) {
|
|
87
|
-
if (block.props.showPreview) {
|
|
88
|
-
return createFigureWithCaption(video, block.props.caption);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return createLinkWithCaption(video, block.props.caption);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
dom: video,
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
export const VideoBlock = createBlockSpec(videoBlockConfig, {
|
|
99
|
-
render: videoRender,
|
|
100
|
-
parse: videoParse,
|
|
101
|
-
toExternalHTML: videoToExternalHTML,
|
|
102
|
-
});
|
|
103
|
-
//# sourceMappingURL=VideoBlockContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlockContent.js","sourceRoot":"","sources":["../../../../src/blocks/VideoBlockContent/VideoBlockContent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,8ZAA8Z,CAAC;AAEja,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa,EAAE,YAAY,CAAC,aAAa;IACzC,eAAe,EAAE,YAAY,CAAC,eAAe;IAC7C,aAAa;IAC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