@blocknote/core 0.19.2 → 0.21.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 +2035 -1758
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +6 -3
- package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +219 -0
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +175 -0
- package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +1 -0
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +4 -1
- package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -1
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +6 -3
- package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -1
- package/dist/src/api/blockManipulation/getBlock/getBlock.js +56 -0
- package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/selection.js +149 -0
- package/dist/src/api/blockManipulation/selections/selection.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/selection.test.js +39 -0
- package/dist/src/api/blockManipulation/selections/selection.test.js.map +1 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +3 -0
- package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -1
- package/dist/src/api/clipboard/clipboard.test.js +6 -3
- package/dist/src/api/clipboard/clipboard.test.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleFileInsertion.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +2 -3
- package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -1
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js +5 -5
- package/dist/src/api/clipboard/fromClipboard/pasteExtension.js.map +1 -1
- package/dist/src/api/clipboard/toClipboard/copyExtension.js +4 -2
- package/dist/src/api/clipboard/toClipboard/copyExtension.js.map +1 -1
- package/dist/src/api/nodeUtil.js +1 -1
- package/dist/src/api/nodeUtil.js.map +1 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js +4 -1
- package/dist/src/api/parsers/markdown/parseMarkdown.test.js.map +1 -1
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js +14 -7
- package/dist/src/blocks/AudioBlockContent/AudioBlockContent.js.map +1 -1
- package/dist/src/blocks/AudioBlockContent/{audioBlockHelpers.js → parseAudioElement.js} +1 -1
- package/dist/src/blocks/AudioBlockContent/parseAudioElement.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js +5 -4
- package/dist/src/blocks/FileBlockContent/FileBlockContent.js.map +1 -1
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js +5 -0
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseEmbedElement.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js +10 -0
- package/dist/src/blocks/FileBlockContent/helpers/parse/parseFigureElement.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js +39 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createAddFileButton.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js +51 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js +17 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createFileNameWithIcon.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js +147 -0
- package/dist/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js +9 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createFigureWithCaption.js.map +1 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js +11 -0
- package/dist/src/blocks/FileBlockContent/helpers/toExternalHTML/createLinkWithCaption.js.map +1 -0
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js +17 -9
- package/dist/src/blocks/ImageBlockContent/ImageBlockContent.js.map +1 -1
- package/dist/src/blocks/ImageBlockContent/{imageBlockHelpers.js → parseImageElement.js} +1 -1
- package/dist/src/blocks/ImageBlockContent/parseImageElement.js.map +1 -0
- package/dist/src/blocks/TableBlockContent/TableExtension.js +8 -1
- package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -1
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js +18 -7
- package/dist/src/blocks/VideoBlockContent/VideoBlockContent.js.map +1 -1
- package/dist/src/blocks/VideoBlockContent/{videoBlockHelpers.js → parseVideoElement.js} +1 -1
- package/dist/src/blocks/VideoBlockContent/parseVideoElement.js.map +1 -0
- package/dist/src/editor/BlockNoteEditor.js +64 -62
- package/dist/src/editor/BlockNoteEditor.js.map +1 -1
- package/dist/src/editor/BlockNoteExtensions.js +5 -8
- package/dist/src/editor/BlockNoteExtensions.js.map +1 -1
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +4 -2
- package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -1
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +10 -8
- package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -1
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +7 -3
- package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -1
- package/dist/src/extensions/LinkToolbar/protocols.js +14 -0
- package/dist/src/extensions/LinkToolbar/protocols.js.map +1 -0
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +19 -13
- package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js +5 -1
- package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -1
- package/dist/src/extensions/SideMenu/dragging.js +8 -1
- package/dist/src/extensions/SideMenu/dragging.js.map +1 -1
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js +3 -3
- package/dist/src/extensions/SuggestionMenu/SuggestionPlugin.js.map +1 -1
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +37 -11
- package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -1
- package/dist/src/i18n/locales/ru.js +1 -1
- package/dist/src/index.js +9 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/schema/inlineContent/createSpec.js +1 -1
- package/dist/src/schema/inlineContent/createSpec.js.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/insertBlocks/insertBlocks.ts +6 -6
- package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +9506 -0
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +295 -0
- package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +336 -0
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +5 -1
- package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +11 -3
- package/src/api/blockManipulation/getBlock/getBlock.ts +141 -0
- package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +660 -0
- package/src/api/blockManipulation/selections/selection.test.ts +56 -0
- package/src/api/blockManipulation/selections/selection.ts +244 -0
- package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +4 -0
- package/src/api/clipboard/__snapshots__/tableAllCells.html +1 -1
- package/src/api/clipboard/__snapshots__/tableCell.html +1 -1
- package/src/api/clipboard/__snapshots__/tableRow.html +1 -1
- package/src/api/clipboard/clipboard.test.ts +7 -3
- 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/toClipboard/copyExtension.ts +7 -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/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/nodeUtil.ts +2 -2
- package/src/api/parsers/markdown/parseMarkdown.test.ts +5 -7
- 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/ImageBlockContent/ImageBlockContent.ts +20 -28
- package/src/blocks/TableBlockContent/TableExtension.ts +12 -1
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +20 -27
- package/src/editor/Block.css +35 -51
- package/src/editor/BlockNoteEditor.ts +101 -92
- package/src/editor/BlockNoteExtensions.ts +9 -8
- package/src/editor/editor.css +1 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +4 -2
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +11 -8
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -4
- package/src/extensions/LinkToolbar/protocols.ts +13 -0
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +29 -21
- package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
- package/src/extensions/SideMenu/dragging.ts +8 -1
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +3 -6
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +49 -12
- package/src/i18n/locales/ru.ts +1 -1
- package/src/index.ts +9 -2
- package/src/schema/inlineContent/createSpec.ts +2 -2
- package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +15 -0
- package/types/src/api/blockManipulation/getBlock/getBlock.d.ts +7 -0
- package/types/src/api/blockManipulation/selections/selection.d.ts +5 -0
- package/types/src/api/blockManipulation/selections/selection.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/nodeUtil.d.ts +1 -1
- 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/VideoBlockContent/VideoBlockContent.d.ts +2 -5
- package/types/src/editor/BlockNoteEditor.d.ts +60 -14
- package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
- package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
- package/types/src/extensions/LinkToolbar/protocols.d.ts +2 -0
- package/types/src/index.d.ts +9 -2
- package/types/src/pm-nodes/BlockContainer.d.ts +2 -2
- package/types/src/pm-nodes/BlockGroup.d.ts +2 -2
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +0 -116
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +0 -1
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +0 -110
- package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +0 -1
- package/dist/src/blocks/AudioBlockContent/audioBlockHelpers.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/ImageBlockContent/imageBlockHelpers.js.map +0 -1
- package/dist/src/blocks/VideoBlockContent/videoBlockHelpers.js.map +0 -1
- package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +0 -3799
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +0 -196
- package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +0 -176
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +0 -456
- package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +0 -5
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +0 -41
- /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/blockManipulation/commands/{moveBlock/moveBlock.test.d.ts → moveBlocks/moveBlocks.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,141 @@
|
|
|
1
|
+
import { Block } from "../../../blocks/defaultBlocks.js";
|
|
2
|
+
import type { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
3
|
+
import {
|
|
4
|
+
BlockIdentifier,
|
|
5
|
+
BlockSchema,
|
|
6
|
+
InlineContentSchema,
|
|
7
|
+
StyleSchema,
|
|
8
|
+
} from "../../../schema/index.js";
|
|
9
|
+
import { nodeToBlock } from "../../nodeConversions/nodeToBlock.js";
|
|
10
|
+
import { getNodeById } from "../../nodeUtil.js";
|
|
11
|
+
|
|
12
|
+
export function getBlock<
|
|
13
|
+
BSchema extends BlockSchema,
|
|
14
|
+
I extends InlineContentSchema,
|
|
15
|
+
S extends StyleSchema
|
|
16
|
+
>(
|
|
17
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
18
|
+
blockIdentifier: BlockIdentifier
|
|
19
|
+
): Block<BSchema, I, S> | undefined {
|
|
20
|
+
const id =
|
|
21
|
+
typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
22
|
+
|
|
23
|
+
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
24
|
+
if (!posInfo) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return nodeToBlock(
|
|
29
|
+
posInfo.node,
|
|
30
|
+
editor.schema.blockSchema,
|
|
31
|
+
editor.schema.inlineContentSchema,
|
|
32
|
+
editor.schema.styleSchema,
|
|
33
|
+
editor.blockCache
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getPrevBlock<
|
|
38
|
+
BSchema extends BlockSchema,
|
|
39
|
+
I extends InlineContentSchema,
|
|
40
|
+
S extends StyleSchema
|
|
41
|
+
>(
|
|
42
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
43
|
+
blockIdentifier: BlockIdentifier
|
|
44
|
+
): Block<BSchema, I, S> | undefined {
|
|
45
|
+
const id =
|
|
46
|
+
typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
47
|
+
|
|
48
|
+
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
49
|
+
if (!posInfo) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const $posBeforeNode = editor._tiptapEditor.state.doc.resolve(
|
|
54
|
+
posInfo.posBeforeNode
|
|
55
|
+
);
|
|
56
|
+
const nodeToConvert = $posBeforeNode.nodeBefore;
|
|
57
|
+
if (!nodeToConvert) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return nodeToBlock(
|
|
62
|
+
nodeToConvert,
|
|
63
|
+
editor.schema.blockSchema,
|
|
64
|
+
editor.schema.inlineContentSchema,
|
|
65
|
+
editor.schema.styleSchema,
|
|
66
|
+
editor.blockCache
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function getNextBlock<
|
|
71
|
+
BSchema extends BlockSchema,
|
|
72
|
+
I extends InlineContentSchema,
|
|
73
|
+
S extends StyleSchema
|
|
74
|
+
>(
|
|
75
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
76
|
+
blockIdentifier: BlockIdentifier
|
|
77
|
+
): Block<BSchema, I, S> | undefined {
|
|
78
|
+
const id =
|
|
79
|
+
typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
80
|
+
|
|
81
|
+
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
82
|
+
if (!posInfo) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const $posAfterNode = editor._tiptapEditor.state.doc.resolve(
|
|
87
|
+
posInfo.posBeforeNode + posInfo.node.nodeSize
|
|
88
|
+
);
|
|
89
|
+
const nodeToConvert = $posAfterNode.nodeAfter;
|
|
90
|
+
if (!nodeToConvert) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return nodeToBlock(
|
|
95
|
+
nodeToConvert,
|
|
96
|
+
editor.schema.blockSchema,
|
|
97
|
+
editor.schema.inlineContentSchema,
|
|
98
|
+
editor.schema.styleSchema,
|
|
99
|
+
editor.blockCache
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function getParentBlock<
|
|
104
|
+
BSchema extends BlockSchema,
|
|
105
|
+
I extends InlineContentSchema,
|
|
106
|
+
S extends StyleSchema
|
|
107
|
+
>(
|
|
108
|
+
editor: BlockNoteEditor<BSchema, I, S>,
|
|
109
|
+
blockIdentifier: BlockIdentifier
|
|
110
|
+
): Block<BSchema, I, S> | undefined {
|
|
111
|
+
const id =
|
|
112
|
+
typeof blockIdentifier === "string" ? blockIdentifier : blockIdentifier.id;
|
|
113
|
+
|
|
114
|
+
const posInfo = getNodeById(id, editor._tiptapEditor.state.doc);
|
|
115
|
+
if (!posInfo) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const $posBeforeNode = editor._tiptapEditor.state.doc.resolve(
|
|
120
|
+
posInfo.posBeforeNode
|
|
121
|
+
);
|
|
122
|
+
const parentNode = $posBeforeNode.node();
|
|
123
|
+
const grandparentNode = $posBeforeNode.node(-1);
|
|
124
|
+
const nodeToConvert =
|
|
125
|
+
grandparentNode.type.name !== "doc"
|
|
126
|
+
? parentNode.type.name === "blockGroup"
|
|
127
|
+
? grandparentNode
|
|
128
|
+
: parentNode
|
|
129
|
+
: undefined;
|
|
130
|
+
if (!nodeToConvert) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return nodeToBlock(
|
|
135
|
+
nodeToConvert,
|
|
136
|
+
editor.schema.blockSchema,
|
|
137
|
+
editor.schema.inlineContentSchema,
|
|
138
|
+
editor.schema.styleSchema,
|
|
139
|
+
editor.blockCache
|
|
140
|
+
);
|
|
141
|
+
}
|