@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
2
|
+
import {
|
|
3
|
+
BlockFromConfig,
|
|
4
|
+
BlockSchemaWithBlock,
|
|
5
|
+
FileBlockConfig,
|
|
6
|
+
} from "../../../../schema/index.js";
|
|
7
|
+
import { createAddFileButton } from "./createAddFileButton.js";
|
|
8
|
+
import { createFileNameWithIcon } from "./createFileNameWithIcon.js";
|
|
9
|
+
|
|
10
|
+
export const createFileBlockWrapper = (
|
|
11
|
+
block: BlockFromConfig<FileBlockConfig, any, any>,
|
|
12
|
+
editor: BlockNoteEditor<
|
|
13
|
+
BlockSchemaWithBlock<FileBlockConfig["type"], FileBlockConfig>,
|
|
14
|
+
any,
|
|
15
|
+
any
|
|
16
|
+
>,
|
|
17
|
+
element?: { dom: HTMLElement; destroy?: () => void },
|
|
18
|
+
buttonText?: string,
|
|
19
|
+
buttonIcon?: HTMLElement
|
|
20
|
+
) => {
|
|
21
|
+
const wrapper = document.createElement("div");
|
|
22
|
+
wrapper.className = "bn-file-block-content-wrapper";
|
|
23
|
+
|
|
24
|
+
// Show the add file button if the file has not been uploaded yet. Change to
|
|
25
|
+
// show a loader if a file upload for the block begins.
|
|
26
|
+
if (block.props.url === "") {
|
|
27
|
+
const addFileButton = createAddFileButton(
|
|
28
|
+
block,
|
|
29
|
+
editor,
|
|
30
|
+
buttonText,
|
|
31
|
+
buttonIcon
|
|
32
|
+
);
|
|
33
|
+
wrapper.appendChild(addFileButton.dom);
|
|
34
|
+
|
|
35
|
+
const destroyUploadStartHandler = editor.onUploadStart((blockId) => {
|
|
36
|
+
if (blockId === block.id) {
|
|
37
|
+
wrapper.removeChild(addFileButton.dom);
|
|
38
|
+
|
|
39
|
+
const loading = document.createElement("div");
|
|
40
|
+
loading.className = "bn-file-loading-preview";
|
|
41
|
+
loading.textContent = "Loading...";
|
|
42
|
+
wrapper.appendChild(loading);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
dom: wrapper,
|
|
48
|
+
destroy: () => {
|
|
49
|
+
destroyUploadStartHandler();
|
|
50
|
+
addFileButton.destroy();
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const ret: { dom: HTMLElement; destroy?: () => void } = { dom: wrapper };
|
|
56
|
+
|
|
57
|
+
// Show the file preview, or the file name and icon.
|
|
58
|
+
if (block.props.showPreview === false || !element) {
|
|
59
|
+
// Show file name and icon.
|
|
60
|
+
const fileNameWithIcon = createFileNameWithIcon(block);
|
|
61
|
+
wrapper.appendChild(fileNameWithIcon.dom);
|
|
62
|
+
|
|
63
|
+
ret.destroy = () => {
|
|
64
|
+
fileNameWithIcon.destroy?.();
|
|
65
|
+
};
|
|
66
|
+
} else {
|
|
67
|
+
// Show file preview.
|
|
68
|
+
wrapper.appendChild(element.dom);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Show the caption if there is one.
|
|
72
|
+
if (block.props.caption) {
|
|
73
|
+
const caption = document.createElement("p");
|
|
74
|
+
caption.className = "bn-file-caption";
|
|
75
|
+
caption.textContent = block.props.caption;
|
|
76
|
+
wrapper.appendChild(caption);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return ret;
|
|
80
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BlockFromConfig, FileBlockConfig } from "../../../../schema/index.js";
|
|
2
|
+
|
|
3
|
+
export const FILE_ICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"></path></svg>`;
|
|
4
|
+
|
|
5
|
+
export const createFileNameWithIcon = (
|
|
6
|
+
block: BlockFromConfig<FileBlockConfig, any, any>
|
|
7
|
+
): { dom: HTMLElement; destroy?: () => void } => {
|
|
8
|
+
const file = document.createElement("div");
|
|
9
|
+
file.className = "bn-file-name-with-icon";
|
|
10
|
+
|
|
11
|
+
const icon = document.createElement("div");
|
|
12
|
+
icon.className = "bn-file-icon";
|
|
13
|
+
icon.innerHTML = FILE_ICON_SVG;
|
|
14
|
+
file.appendChild(icon);
|
|
15
|
+
|
|
16
|
+
const fileName = document.createElement("p");
|
|
17
|
+
fileName.className = "bn-file-name";
|
|
18
|
+
fileName.textContent = block.props.name;
|
|
19
|
+
file.appendChild(fileName);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
dom: file,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../../../../editor/BlockNoteEditor.js";
|
|
2
|
+
import { BlockFromConfig, FileBlockConfig } from "../../../../schema/index.js";
|
|
3
|
+
import { createFileBlockWrapper } from "./createFileBlockWrapper.js";
|
|
4
|
+
|
|
5
|
+
export const createResizableFileBlockWrapper = (
|
|
6
|
+
block: BlockFromConfig<FileBlockConfig, any, any>,
|
|
7
|
+
editor: BlockNoteEditor<any, any, any>,
|
|
8
|
+
element: { dom: HTMLElement; destroy?: () => void },
|
|
9
|
+
resizeHandlesContainerElement: HTMLElement,
|
|
10
|
+
buttonText: string,
|
|
11
|
+
buttonIcon: HTMLElement
|
|
12
|
+
): { dom: HTMLElement; destroy: () => void } => {
|
|
13
|
+
const { dom, destroy } = createFileBlockWrapper(
|
|
14
|
+
block,
|
|
15
|
+
editor,
|
|
16
|
+
element,
|
|
17
|
+
buttonText,
|
|
18
|
+
buttonIcon
|
|
19
|
+
);
|
|
20
|
+
const wrapper = dom;
|
|
21
|
+
if (block.props.url && block.props.showPreview) {
|
|
22
|
+
wrapper.style.width = `${block.props.previewWidth}px`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const leftResizeHandle = document.createElement("div");
|
|
26
|
+
leftResizeHandle.className = "bn-resize-handle";
|
|
27
|
+
leftResizeHandle.style.left = "4px";
|
|
28
|
+
const rightResizeHandle = document.createElement("div");
|
|
29
|
+
rightResizeHandle.className = "bn-resize-handle";
|
|
30
|
+
rightResizeHandle.style.right = "4px";
|
|
31
|
+
|
|
32
|
+
// Temporary parameters set when the user begins resizing the element, used to
|
|
33
|
+
// calculate the new width of the element.
|
|
34
|
+
let resizeParams:
|
|
35
|
+
| {
|
|
36
|
+
handleUsed: "left" | "right";
|
|
37
|
+
initialWidth: number;
|
|
38
|
+
initialClientX: number;
|
|
39
|
+
}
|
|
40
|
+
| undefined;
|
|
41
|
+
let width = block.props.previewWidth! as number;
|
|
42
|
+
|
|
43
|
+
// Updates the element width with an updated width depending on the cursor X
|
|
44
|
+
// offset from when the resize began, and which resize handle is being used.
|
|
45
|
+
const windowMouseMoveHandler = (event: MouseEvent) => {
|
|
46
|
+
if (!resizeParams) {
|
|
47
|
+
if (
|
|
48
|
+
!editor.isEditable &&
|
|
49
|
+
resizeHandlesContainerElement.contains(leftResizeHandle) &&
|
|
50
|
+
resizeHandlesContainerElement.contains(rightResizeHandle)
|
|
51
|
+
) {
|
|
52
|
+
resizeHandlesContainerElement.removeChild(leftResizeHandle);
|
|
53
|
+
resizeHandlesContainerElement.removeChild(rightResizeHandle);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let newWidth: number;
|
|
60
|
+
|
|
61
|
+
if (block.props.textAlignment === "center") {
|
|
62
|
+
if (resizeParams.handleUsed === "left") {
|
|
63
|
+
newWidth =
|
|
64
|
+
resizeParams.initialWidth +
|
|
65
|
+
(resizeParams.initialClientX - event.clientX) * 2;
|
|
66
|
+
} else {
|
|
67
|
+
newWidth =
|
|
68
|
+
resizeParams.initialWidth +
|
|
69
|
+
(event.clientX - resizeParams.initialClientX) * 2;
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (resizeParams.handleUsed === "left") {
|
|
73
|
+
newWidth =
|
|
74
|
+
resizeParams.initialWidth +
|
|
75
|
+
resizeParams.initialClientX -
|
|
76
|
+
event.clientX;
|
|
77
|
+
} else {
|
|
78
|
+
newWidth =
|
|
79
|
+
resizeParams.initialWidth +
|
|
80
|
+
event.clientX -
|
|
81
|
+
resizeParams.initialClientX;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Min element width in px.
|
|
86
|
+
const minWidth = 64;
|
|
87
|
+
|
|
88
|
+
// Ensures the element is not wider than the editor and not narrower than a
|
|
89
|
+
// predetermined minimum width.
|
|
90
|
+
width = Math.max(newWidth, minWidth);
|
|
91
|
+
wrapper.style.width = `${width}px`;
|
|
92
|
+
};
|
|
93
|
+
// Stops mouse movements from resizing the element and updates the block's
|
|
94
|
+
// `width` prop to the new value.
|
|
95
|
+
const windowMouseUpHandler = (event: MouseEvent) => {
|
|
96
|
+
// Hides the drag handles if the cursor is no longer over the element.
|
|
97
|
+
if (
|
|
98
|
+
(!event.target ||
|
|
99
|
+
!wrapper.contains(event.target as Node) ||
|
|
100
|
+
!editor.isEditable) &&
|
|
101
|
+
resizeHandlesContainerElement.contains(leftResizeHandle) &&
|
|
102
|
+
resizeHandlesContainerElement.contains(rightResizeHandle)
|
|
103
|
+
) {
|
|
104
|
+
resizeHandlesContainerElement.removeChild(leftResizeHandle);
|
|
105
|
+
resizeHandlesContainerElement.removeChild(rightResizeHandle);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!resizeParams) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
resizeParams = undefined;
|
|
113
|
+
|
|
114
|
+
editor.updateBlock(block, {
|
|
115
|
+
props: {
|
|
116
|
+
previewWidth: width,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Shows the resize handles when hovering over the wrapper with the cursor.
|
|
122
|
+
const wrapperMouseEnterHandler = () => {
|
|
123
|
+
if (editor.isEditable) {
|
|
124
|
+
resizeHandlesContainerElement.appendChild(leftResizeHandle);
|
|
125
|
+
resizeHandlesContainerElement.appendChild(rightResizeHandle);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
// Hides the resize handles when the cursor leaves the wrapper, unless the
|
|
129
|
+
// cursor moves to one of the resize handles.
|
|
130
|
+
const wrapperMouseLeaveHandler = (event: MouseEvent) => {
|
|
131
|
+
if (
|
|
132
|
+
event.relatedTarget === leftResizeHandle ||
|
|
133
|
+
event.relatedTarget === rightResizeHandle
|
|
134
|
+
) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (resizeParams) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (
|
|
143
|
+
editor.isEditable &&
|
|
144
|
+
resizeHandlesContainerElement.contains(leftResizeHandle) &&
|
|
145
|
+
resizeHandlesContainerElement.contains(rightResizeHandle)
|
|
146
|
+
) {
|
|
147
|
+
resizeHandlesContainerElement.removeChild(leftResizeHandle);
|
|
148
|
+
resizeHandlesContainerElement.removeChild(rightResizeHandle);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Sets the resize params, allowing the user to begin resizing the element by
|
|
153
|
+
// moving the cursor left or right.
|
|
154
|
+
const leftResizeHandleMouseDownHandler = (event: MouseEvent) => {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
|
|
157
|
+
resizeParams = {
|
|
158
|
+
handleUsed: "left",
|
|
159
|
+
initialWidth: wrapper.clientWidth,
|
|
160
|
+
initialClientX: event.clientX,
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
const rightResizeHandleMouseDownHandler = (event: MouseEvent) => {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
|
|
166
|
+
resizeParams = {
|
|
167
|
+
handleUsed: "right",
|
|
168
|
+
initialWidth: wrapper.clientWidth,
|
|
169
|
+
initialClientX: event.clientX,
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
window.addEventListener("mousemove", windowMouseMoveHandler);
|
|
174
|
+
window.addEventListener("mouseup", windowMouseUpHandler);
|
|
175
|
+
wrapper.addEventListener("mouseenter", wrapperMouseEnterHandler);
|
|
176
|
+
wrapper.addEventListener("mouseleave", wrapperMouseLeaveHandler);
|
|
177
|
+
leftResizeHandle.addEventListener(
|
|
178
|
+
"mousedown",
|
|
179
|
+
leftResizeHandleMouseDownHandler
|
|
180
|
+
);
|
|
181
|
+
rightResizeHandle.addEventListener(
|
|
182
|
+
"mousedown",
|
|
183
|
+
rightResizeHandleMouseDownHandler
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
dom: wrapper,
|
|
188
|
+
destroy: () => {
|
|
189
|
+
destroy?.();
|
|
190
|
+
window.removeEventListener("mousemove", windowMouseMoveHandler);
|
|
191
|
+
window.removeEventListener("mouseup", windowMouseUpHandler);
|
|
192
|
+
wrapper.removeEventListener("mouseenter", wrapperMouseEnterHandler);
|
|
193
|
+
wrapper.removeEventListener("mouseleave", wrapperMouseLeaveHandler);
|
|
194
|
+
leftResizeHandle.removeEventListener(
|
|
195
|
+
"mousedown",
|
|
196
|
+
leftResizeHandleMouseDownHandler
|
|
197
|
+
);
|
|
198
|
+
rightResizeHandle.removeEventListener(
|
|
199
|
+
"mousedown",
|
|
200
|
+
rightResizeHandleMouseDownHandler
|
|
201
|
+
);
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const createFigureWithCaption = (
|
|
2
|
+
element: HTMLElement,
|
|
3
|
+
caption: string
|
|
4
|
+
) => {
|
|
5
|
+
const figure = document.createElement("figure");
|
|
6
|
+
const captionElement = document.createElement("figcaption");
|
|
7
|
+
captionElement.textContent = caption;
|
|
8
|
+
|
|
9
|
+
figure.appendChild(element);
|
|
10
|
+
figure.appendChild(captionElement);
|
|
11
|
+
|
|
12
|
+
return { dom: figure };
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const createLinkWithCaption = (
|
|
2
|
+
element: HTMLElement,
|
|
3
|
+
caption: string
|
|
4
|
+
) => {
|
|
5
|
+
const wrapper = document.createElement("div");
|
|
6
|
+
const fileCaption = document.createElement("p");
|
|
7
|
+
fileCaption.textContent = caption;
|
|
8
|
+
|
|
9
|
+
wrapper.appendChild(element);
|
|
10
|
+
wrapper.appendChild(fileCaption);
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
dom: wrapper,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -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() {
|
|
@@ -7,15 +7,11 @@ import {
|
|
|
7
7
|
PropSchema,
|
|
8
8
|
} from "../../schema/index.js";
|
|
9
9
|
import { defaultProps } from "../defaultProps.js";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
createResizeHandlesWrapper,
|
|
16
|
-
parseFigureElement,
|
|
17
|
-
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
18
|
-
import { parseImageElement } from "./imageBlockHelpers.js";
|
|
10
|
+
import { parseFigureElement } from "../FileBlockContent/helpers/parse/parseFigureElement.js";
|
|
11
|
+
import { createFigureWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js";
|
|
12
|
+
import { createLinkWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js";
|
|
13
|
+
import { createResizableFileBlockWrapper } from "../FileBlockContent/helpers/render/createResizableFileBlockWrapper.js";
|
|
14
|
+
import { parseImageElement } from "./parseImageElement.js";
|
|
19
15
|
|
|
20
16
|
export const FILE_IMAGE_ICON_SVG =
|
|
21
17
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"></path></svg>';
|
|
@@ -60,33 +56,29 @@ export const imageRender = (
|
|
|
60
56
|
const icon = document.createElement("div");
|
|
61
57
|
icon.innerHTML = FILE_IMAGE_ICON_SVG;
|
|
62
58
|
|
|
59
|
+
const imageWrapper = document.createElement("div");
|
|
60
|
+
imageWrapper.className = "bn-visual-media-wrapper";
|
|
61
|
+
|
|
63
62
|
const image = document.createElement("img");
|
|
64
63
|
image.className = "bn-visual-media";
|
|
65
|
-
editor.resolveFileUrl
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if (editor.resolveFileUrl) {
|
|
65
|
+
editor.resolveFileUrl(block.props.url).then((downloadUrl) => {
|
|
66
|
+
image.src = downloadUrl;
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
image.src = block.props.url;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
image.alt = block.props.name || block.props.caption || "BlockNote image";
|
|
69
73
|
image.contentEditable = "false";
|
|
70
74
|
image.draggable = false;
|
|
71
|
-
|
|
72
|
-
block.props.previewWidth,
|
|
73
|
-
editor.domElement.firstElementChild!.clientWidth
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const file = createResizeHandlesWrapper(
|
|
77
|
-
block,
|
|
78
|
-
editor,
|
|
79
|
-
image,
|
|
80
|
-
() => image.width,
|
|
81
|
-
(width) => (image.width = width)
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const element = createFileAndCaptionWrapper(block, file.dom);
|
|
75
|
+
imageWrapper.appendChild(image);
|
|
85
76
|
|
|
86
|
-
return
|
|
77
|
+
return createResizableFileBlockWrapper(
|
|
87
78
|
block,
|
|
88
79
|
editor,
|
|
89
|
-
|
|
80
|
+
{ dom: imageWrapper },
|
|
81
|
+
imageWrapper,
|
|
90
82
|
editor.dictionary.file_blocks.image.add_button_text,
|
|
91
83
|
icon.firstElementChild as HTMLElement
|
|
92
84
|
);
|
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() {
|
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
|
)
|
|
@@ -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;
|
|
@@ -7,16 +7,11 @@ import {
|
|
|
7
7
|
PropSchema,
|
|
8
8
|
} from "../../schema/index.js";
|
|
9
9
|
import { defaultProps } from "../defaultProps.js";
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
createLinkWithCaption,
|
|
16
|
-
createResizeHandlesWrapper,
|
|
17
|
-
parseFigureElement,
|
|
18
|
-
} from "../FileBlockContent/fileBlockHelpers.js";
|
|
19
|
-
import { parseVideoElement } from "./videoBlockHelpers.js";
|
|
10
|
+
import { parseFigureElement } from "../FileBlockContent/helpers/parse/parseFigureElement.js";
|
|
11
|
+
import { createFigureWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js";
|
|
12
|
+
import { createLinkWithCaption } from "../FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js";
|
|
13
|
+
import { createResizableFileBlockWrapper } from "../FileBlockContent/helpers/render/createResizableFileBlockWrapper.js";
|
|
14
|
+
import { parseVideoElement } from "./parseVideoElement.js";
|
|
20
15
|
|
|
21
16
|
export const FILE_VIDEO_ICON_SVG =
|
|
22
17
|
'<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>';
|
|
@@ -61,31 +56,29 @@ export const videoRender = (
|
|
|
61
56
|
const icon = document.createElement("div");
|
|
62
57
|
icon.innerHTML = FILE_VIDEO_ICON_SVG;
|
|
63
58
|
|
|
59
|
+
const videoWrapper = document.createElement("div");
|
|
60
|
+
videoWrapper.className = "bn-visual-media-wrapper";
|
|
61
|
+
|
|
64
62
|
const video = document.createElement("video");
|
|
65
63
|
video.className = "bn-visual-media";
|
|
66
|
-
|
|
64
|
+
if (editor.resolveFileUrl) {
|
|
65
|
+
editor.resolveFileUrl(block.props.url).then((downloadUrl) => {
|
|
66
|
+
video.src = downloadUrl;
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
video.src = block.props.url;
|
|
70
|
+
}
|
|
67
71
|
video.controls = true;
|
|
68
72
|
video.contentEditable = "false";
|
|
69
73
|
video.draggable = false;
|
|
70
|
-
video.width =
|
|
71
|
-
|
|
72
|
-
editor.domElement.firstElementChild!.clientWidth
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
const file = createResizeHandlesWrapper(
|
|
76
|
-
block,
|
|
77
|
-
editor,
|
|
78
|
-
video,
|
|
79
|
-
() => video.width,
|
|
80
|
-
(width) => (video.width = width)
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const element = createFileAndCaptionWrapper(block, file.dom);
|
|
74
|
+
video.width = block.props.previewWidth;
|
|
75
|
+
videoWrapper.appendChild(video);
|
|
84
76
|
|
|
85
|
-
return
|
|
77
|
+
return createResizableFileBlockWrapper(
|
|
86
78
|
block,
|
|
87
79
|
editor,
|
|
88
|
-
|
|
80
|
+
{ dom: videoWrapper },
|
|
81
|
+
videoWrapper,
|
|
89
82
|
editor.dictionary.file_blocks.video.add_button_text,
|
|
90
83
|
icon.firstElementChild as HTMLElement
|
|
91
84
|
);
|