@blocknote/core 0.38.0 → 0.39.1-capitol
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/BlockNoteSchema-Bsa_tSAC.cjs +11 -0
- package/dist/BlockNoteSchema-Bsa_tSAC.cjs.map +1 -0
- package/dist/BlockNoteSchema-CZez1nQf.js +4244 -0
- package/dist/BlockNoteSchema-CZez1nQf.js.map +1 -0
- package/dist/blocknote.cjs +4 -12
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +3401 -7305
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +2 -0
- package/dist/blocks.cjs.map +1 -0
- package/dist/blocks.js +71 -0
- package/dist/blocks.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +19 -17
- package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +1 -1
- package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +2 -2
- package/src/api/blockManipulation/commands/splitBlock/splitBlock.ts +34 -25
- package/src/api/blockManipulation/setupTestEnv.ts +0 -1
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +6 -10
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
- package/src/api/clipboard/toClipboard/copyExtension.ts +1 -1
- package/src/api/exporters/html/util/serializeBlocksExternalHTML.ts +128 -28
- package/src/api/exporters/html/util/serializeBlocksInternalHTML.ts +101 -41
- package/src/api/pmUtil.ts +1 -1
- package/src/api/positionMapping.test.ts +58 -15
- package/src/api/positionMapping.ts +2 -4
- package/src/blocks/Audio/block.ts +174 -0
- package/src/blocks/BlockNoteSchema.ts +59 -0
- package/src/blocks/Code/block.ts +299 -0
- package/src/blocks/File/block.ts +98 -0
- package/src/blocks/{FileBlockContent → File}/helpers/render/createAddFileButton.ts +5 -2
- package/src/blocks/{FileBlockContent → File}/helpers/render/createFileBlockWrapper.ts +15 -6
- package/src/blocks/{FileBlockContent → File}/helpers/render/createFileNameWithIcon.ts +15 -2
- package/src/blocks/{FileBlockContent → File}/helpers/render/createResizableFileBlockWrapper.ts +21 -2
- package/src/blocks/Heading/block.ts +138 -0
- package/src/blocks/Image/block.ts +190 -0
- package/src/blocks/ListItem/BulletListItem/block.ts +116 -0
- package/src/blocks/ListItem/CheckListItem/block.ts +175 -0
- package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +173 -0
- package/src/blocks/ListItem/NumberedListItem/block.ts +133 -0
- package/src/blocks/ListItem/ToggleListItem/block.ts +78 -0
- package/src/blocks/PageBreak/block.ts +72 -0
- package/src/blocks/{PageBreakBlockContent → PageBreak}/getPageBreakSlashMenuItems.ts +9 -7
- package/src/blocks/Paragraph/block.ts +80 -0
- package/src/blocks/Quote/block.ts +90 -0
- package/src/blocks/{TableBlockContent/TableBlockContent.ts → Table/block.ts} +169 -51
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +1 -1
- package/src/blocks/Video/block.ts +143 -0
- package/src/blocks/defaultBlockHelpers.ts +2 -2
- package/src/blocks/defaultBlockTypeGuards.ts +143 -174
- package/src/blocks/defaultBlocks.ts +107 -35
- package/src/blocks/defaultProps.ts +145 -4
- package/src/blocks/index.ts +26 -0
- package/src/blocks/utils/listItemEnterHandler.ts +42 -0
- package/src/editor/Block.css +54 -18
- package/src/editor/BlockNoteEditor.ts +256 -211
- package/src/editor/BlockNoteExtension.ts +92 -0
- package/src/editor/BlockNoteExtensions.ts +18 -17
- package/src/editor/defaultColors.ts +2 -2
- package/src/exporter/Exporter.ts +1 -1
- package/src/exporter/mapping.ts +1 -1
- package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +3 -20
- package/src/extensions/BackgroundColor/BackgroundColorMark.ts +6 -8
- package/src/extensions/BlockChange/BlockChangePlugin.ts +2 -1
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +2 -2
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +2 -2
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
- package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
- package/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.ts +52 -0
- package/src/extensions/Collaboration/schemaMigration/migrationRules/index.ts +4 -0
- package/src/extensions/Collaboration/schemaMigration/migrationRules/migrationRule.ts +4 -0
- package/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.ts +78 -0
- package/src/extensions/Comments/CommentsPlugin.ts +1 -1
- package/src/extensions/FilePanel/FilePanelPlugin.ts +5 -10
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +1 -1
- package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +4 -3
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
- package/src/extensions/PreviousBlockType/PreviousBlockTypePlugin.ts +1 -23
- package/src/extensions/SideMenu/SideMenuPlugin.ts +1 -3
- package/src/extensions/SideMenu/dragging.ts +2 -2
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +4 -7
- package/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts +6 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +24 -17
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +8 -8
- package/src/extensions/TextAlignment/TextAlignmentExtension.ts +5 -11
- package/src/extensions/TextColor/TextColorExtension.ts +3 -17
- package/src/extensions/TextColor/TextColorMark.ts +4 -9
- package/src/extensions/UniqueID/UniqueID.ts +6 -13
- package/src/index.ts +2 -28
- package/src/schema/blocks/createSpec.ts +342 -169
- package/src/schema/blocks/internal.ts +77 -138
- package/src/schema/blocks/types.ts +264 -94
- package/src/schema/index.ts +1 -0
- package/src/schema/inlineContent/createSpec.ts +99 -21
- package/src/schema/inlineContent/internal.ts +16 -7
- package/src/schema/inlineContent/types.ts +24 -2
- package/src/schema/propTypes.ts +15 -9
- package/src/schema/schema.ts +209 -0
- package/src/schema/styles/createSpec.ts +79 -31
- package/src/schema/styles/internal.ts +61 -2
- package/src/schema/styles/types.ts +17 -3
- package/src/util/topo-sort.test.ts +125 -0
- package/src/util/topo-sort.ts +160 -0
- package/types/src/api/blockManipulation/commands/splitBlock/splitBlock.d.ts +2 -1
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/api/blockManipulation/setupTestEnv.d.ts +29 -543
- package/types/src/api/exporters/html/util/serializeBlocksExternalHTML.d.ts +1 -1
- package/types/src/api/exporters/html/util/serializeBlocksInternalHTML.d.ts +1 -1
- package/types/src/api/exporters/markdown/util/convertVideoToMarkdownRehypePlugin.d.ts +2 -0
- package/types/src/api/exporters/markdown/util/removeUnderlinesRehypePlugin.d.ts +6 -0
- package/types/src/api/pmUtil.d.ts +1 -1
- package/types/src/blocks/Audio/block.d.ts +58 -0
- package/types/src/blocks/BlockNoteSchema.d.ts +18 -0
- package/types/src/blocks/{CodeBlockContent/CodeBlockContent.d.ts → Code/block.d.ts} +25 -26
- package/types/src/blocks/Code/shiki.d.ts +4 -0
- package/types/src/blocks/Divider/block.d.ts +3 -0
- package/types/src/blocks/File/block.d.ts +37 -0
- package/types/src/blocks/File/helpers/render/createAddFileButton.d.ts +6 -0
- package/types/src/blocks/File/helpers/render/createFileBlockWrapper.d.ts +25 -0
- package/types/src/blocks/{FileBlockContent → File}/helpers/render/createFileNameWithIcon.d.ts +6 -2
- package/types/src/blocks/File/helpers/render/createResizableFileBlockWrapper.d.ts +31 -0
- package/types/src/blocks/Heading/block.d.ts +71 -0
- package/types/src/blocks/Image/block.d.ts +102 -0
- package/types/src/blocks/ListItem/BulletListItem/block.d.ts +25 -0
- package/types/src/blocks/ListItem/CheckListItem/block.d.ts +33 -0
- package/types/src/blocks/ListItem/NumberedListItem/IndexingPlugin.d.ts +8 -0
- package/types/src/blocks/ListItem/NumberedListItem/block.d.ts +33 -0
- package/types/src/blocks/ListItem/ToggleListItem/block.d.ts +25 -0
- package/types/src/blocks/PageBreak/block.d.ts +11 -0
- package/types/src/blocks/{PageBreakBlockContent → PageBreak}/getPageBreakSlashMenuItems.d.ts +4 -2
- package/types/src/blocks/Paragraph/block.d.ts +25 -0
- package/types/src/blocks/Quote/block.d.ts +17 -0
- package/types/src/blocks/Table/block.d.ts +21 -0
- package/types/src/blocks/Video/block.d.ts +67 -0
- package/types/src/blocks/defaultBlockHelpers.d.ts +1 -1
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +15 -36
- package/types/src/blocks/defaultBlocks.d.ts +221 -1060
- package/types/src/blocks/defaultProps.d.ts +17 -1
- package/types/src/blocks/index.d.ts +24 -0
- package/types/src/blocks/utils/listItemEnterHandler.d.ts +2 -0
- package/types/src/editor/BlockNoteEditor.d.ts +36 -67
- package/types/src/editor/BlockNoteExtension.d.ts +67 -0
- package/types/src/editor/BlockNoteExtensions.d.ts +1 -1
- package/types/src/editor/defaultColors.d.ts +8 -76
- package/types/src/editor/managers/BlockManager.d.ts +114 -0
- package/types/src/editor/managers/CollaborationManager.d.ts +115 -0
- package/types/src/editor/managers/EventManager.d.ts +58 -0
- package/types/src/editor/managers/ExportManager.d.ts +64 -0
- package/types/src/editor/managers/ExtensionManager.d.ts +68 -0
- package/types/src/editor/managers/SelectionManager.d.ts +54 -0
- package/types/src/editor/managers/StateManager.d.ts +115 -0
- package/types/src/editor/managers/StyleManager.d.ts +48 -0
- package/types/src/editor/managers/index.d.ts +8 -0
- package/types/src/exporter/Exporter.d.ts +1 -1
- package/types/src/exporter/mapping.d.ts +1 -1
- package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +4 -1
- package/types/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.d.ts +7 -0
- package/types/src/extensions/Collaboration/schemaMigration/migrationRules/index.d.ts +3 -0
- package/types/src/extensions/Collaboration/schemaMigration/migrationRules/migrationRule.d.ts +3 -0
- package/types/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.d.ts +2 -0
- package/types/src/extensions/Comments/CommentsPlugin.d.ts +1 -1
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +4 -4
- package/types/src/extensions/TextColor/TextColorMark.d.ts +4 -1
- package/types/src/index.d.ts +2 -25
- package/types/src/schema/blocks/createSpec.d.ts +16 -36
- package/types/src/schema/blocks/internal.d.ts +11 -33
- package/types/src/schema/blocks/types.d.ts +181 -57
- package/types/src/schema/index.d.ts +1 -0
- package/types/src/schema/inlineContent/createSpec.d.ts +36 -2
- package/types/src/schema/inlineContent/internal.d.ts +7 -15
- package/types/src/schema/inlineContent/types.d.ts +15 -1
- package/types/src/schema/propTypes.d.ts +4 -4
- package/types/src/schema/schema.d.ts +40 -0
- package/types/src/schema/styles/createSpec.d.ts +6 -4
- package/types/src/schema/styles/internal.d.ts +6 -3
- package/types/src/schema/styles/types.d.ts +11 -2
- package/types/src/util/topo-sort.d.ts +18 -0
- package/types/src/util/topo-sort.test.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +0 -144
- package/src/blocks/CodeBlockContent/CodeBlockContent.ts +0 -445
- package/src/blocks/FileBlockContent/FileBlockContent.ts +0 -100
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +0 -159
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +0 -159
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +0 -134
- package/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.ts +0 -299
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts +0 -86
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +0 -172
- package/src/blocks/ListItemBlockContent/ToggleListItemBlockContent/ToggleListItemBlockContent.ts +0 -104
- package/src/blocks/PageBreakBlockContent/PageBreakBlockContent.ts +0 -49
- package/src/blocks/PageBreakBlockContent/schema.ts +0 -40
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +0 -78
- package/src/blocks/QuoteBlockContent/QuoteBlockContent.ts +0 -121
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +0 -158
- package/src/editor/BlockNoteSchema.ts +0 -107
- package/src/editor/BlockNoteTipTapEditor.ts +0 -335
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +0 -99
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +0 -90
- package/types/src/blocks/FileBlockContent/helpers/render/createAddFileButton.d.ts +0 -6
- package/types/src/blocks/FileBlockContent/helpers/render/createFileBlockWrapper.d.ts +0 -9
- package/types/src/blocks/FileBlockContent/helpers/render/createResizableFileBlockWrapper.d.ts +0 -9
- package/types/src/blocks/HeadingBlockContent/HeadingBlockContent.d.ts +0 -67
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +0 -131
- package/types/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +0 -46
- package/types/src/blocks/ListItemBlockContent/CheckListItemBlockContent/CheckListItemBlockContent.d.ts +0 -55
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +0 -2
- package/types/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +0 -58
- package/types/src/blocks/ListItemBlockContent/ToggleListItemBlockContent/ToggleListItemBlockContent.d.ts +0 -46
- package/types/src/blocks/PageBreakBlockContent/PageBreakBlockContent.d.ts +0 -31
- package/types/src/blocks/PageBreakBlockContent/schema.d.ts +0 -86
- package/types/src/blocks/ParagraphBlockContent/ParagraphBlockContent.d.ts +0 -52
- package/types/src/blocks/QuoteBlockContent/QuoteBlockContent.d.ts +0 -52
- package/types/src/blocks/TableBlockContent/TableBlockContent.d.ts +0 -39
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +0 -131
- package/types/src/editor/BlockNoteSchema.d.ts +0 -34
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +0 -43
- /package/src/blocks/{AudioBlockContent → Audio}/parseAudioElement.ts +0 -0
- /package/src/blocks/{FileBlockContent → File}/helpers/parse/parseEmbedElement.ts +0 -0
- /package/src/blocks/{FileBlockContent → File}/helpers/parse/parseFigureElement.ts +0 -0
- /package/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createFigureWithCaption.ts +0 -0
- /package/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createLinkWithCaption.ts +0 -0
- /package/src/blocks/{FileBlockContent → File/helpers}/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -0
- /package/src/blocks/{ImageBlockContent → Image}/parseImageElement.ts +0 -0
- /package/src/blocks/{ListItemBlockContent → ListItem}/ListItemKeyboardShortcuts.ts +0 -0
- /package/src/blocks/{ListItemBlockContent → ListItem}/getListItemContent.ts +0 -0
- /package/src/blocks/{TableBlockContent → Table}/TableExtension.ts +0 -0
- /package/src/blocks/{VideoBlockContent → Video}/parseVideoElement.ts +0 -0
- /package/types/src/blocks/{AudioBlockContent → Audio}/parseAudioElement.d.ts +0 -0
- /package/types/src/blocks/{FileBlockContent → File}/helpers/parse/parseEmbedElement.d.ts +0 -0
- /package/types/src/blocks/{FileBlockContent → File}/helpers/parse/parseFigureElement.d.ts +0 -0
- /package/types/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createFigureWithCaption.d.ts +0 -0
- /package/types/src/blocks/{FileBlockContent → File}/helpers/toExternalHTML/createLinkWithCaption.d.ts +0 -0
- /package/types/src/blocks/{FileBlockContent → File/helpers}/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -0
- /package/types/src/blocks/{ImageBlockContent → Image}/parseImageElement.d.ts +0 -0
- /package/types/src/blocks/{ListItemBlockContent → ListItem}/ListItemKeyboardShortcuts.d.ts +0 -0
- /package/types/src/blocks/{ListItemBlockContent → ListItem}/getListItemContent.d.ts +0 -0
- /package/types/src/blocks/{TableBlockContent → Table}/TableExtension.d.ts +0 -0
- /package/types/src/blocks/{VideoBlockContent → Video}/parseVideoElement.d.ts +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Attribute } from "@tiptap/core";
|
|
1
2
|
import type { Props } from "../schema/index.js";
|
|
2
3
|
export declare const defaultProps: {
|
|
3
4
|
backgroundColor: {
|
|
@@ -12,4 +13,19 @@ export declare const defaultProps: {
|
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
export type DefaultProps = Props<typeof defaultProps>;
|
|
15
|
-
export declare const
|
|
16
|
+
export declare const parseDefaultProps: (element: HTMLElement) => Partial<Props<{
|
|
17
|
+
backgroundColor: {
|
|
18
|
+
default: "default";
|
|
19
|
+
};
|
|
20
|
+
textColor: {
|
|
21
|
+
default: "default";
|
|
22
|
+
};
|
|
23
|
+
textAlignment: {
|
|
24
|
+
default: "left";
|
|
25
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
26
|
+
};
|
|
27
|
+
}>>;
|
|
28
|
+
export declare const addDefaultPropsExternalHTML: (props: Partial<DefaultProps>, element: HTMLElement) => void;
|
|
29
|
+
export declare const getBackgroundColorAttribute: (attributeName?: string) => Attribute;
|
|
30
|
+
export declare const getTextColorAttribute: (attributeName?: string) => Attribute;
|
|
31
|
+
export declare const getTextAlignmentAttribute: (attributeName?: string) => Attribute;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./Audio/block.js";
|
|
2
|
+
export * from "./Audio/parseAudioElement.js";
|
|
3
|
+
export * from "./Code/block.js";
|
|
4
|
+
export * from "./File/block.js";
|
|
5
|
+
export * from "./Heading/block.js";
|
|
6
|
+
export * from "./Image/block.js";
|
|
7
|
+
export * from "./ListItem/BulletListItem/block.js";
|
|
8
|
+
export * from "./ListItem/CheckListItem/block.js";
|
|
9
|
+
export * from "./ListItem/NumberedListItem/block.js";
|
|
10
|
+
export * from "./ListItem/ToggleListItem/block.js";
|
|
11
|
+
export * from "./PageBreak/block.js";
|
|
12
|
+
export * from "./Paragraph/block.js";
|
|
13
|
+
export * from "./Quote/block.js";
|
|
14
|
+
export * from "./Table/block.js";
|
|
15
|
+
export * from "./Video/block.js";
|
|
16
|
+
export { EMPTY_CELL_HEIGHT, EMPTY_CELL_WIDTH } from "./Table/TableExtension.js";
|
|
17
|
+
export * from "./ToggleWrapper/createToggleWrapper.js";
|
|
18
|
+
export * from "./File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.js";
|
|
19
|
+
export * from "./PageBreak/getPageBreakSlashMenuItems.js";
|
|
20
|
+
export * from "./BlockNoteSchema.js";
|
|
21
|
+
export * from "./defaultBlockHelpers.js";
|
|
22
|
+
export * from "./defaultBlocks.js";
|
|
23
|
+
export * from "./defaultBlockTypeGuards.js";
|
|
24
|
+
export * from "./defaultProps.js";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { AnyExtension, EditorOptions } from "@tiptap/core";
|
|
1
|
+
import { AnyExtension, EditorOptions, Editor as TiptapEditor } from "@tiptap/core";
|
|
2
|
+
import { type Command, type Plugin, type Transaction } from "@tiptap/pm/state";
|
|
2
3
|
import { Node, Schema } from "prosemirror-model";
|
|
3
4
|
import * as Y from "yjs";
|
|
4
|
-
import {
|
|
5
|
+
import { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
|
|
6
|
+
import type { ThreadStore, User } from "../comments/index.js";
|
|
7
|
+
import type { ForkYDocPlugin } from "../extensions/Collaboration/ForkYDocPlugin.js";
|
|
5
8
|
import type { CommentsPlugin } from "../extensions/Comments/CommentsPlugin.js";
|
|
6
9
|
import { FilePanelProsemirrorPlugin } from "../extensions/FilePanel/FilePanelPlugin.js";
|
|
7
10
|
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
@@ -9,21 +12,15 @@ import { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkTool
|
|
|
9
12
|
import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin.js";
|
|
10
13
|
import { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
11
14
|
import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin.js";
|
|
12
|
-
import { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema/index.js";
|
|
13
|
-
import { NoInfer } from "../util/typescript.js";
|
|
14
|
-
import { TextCursorPosition } from "./cursorPositionTypes.js";
|
|
15
|
-
import { Selection } from "./selectionTypes.js";
|
|
16
|
-
import { BlockNoteSchema } from "./BlockNoteSchema.js";
|
|
17
|
-
import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor.js";
|
|
18
15
|
import { Dictionary } from "../i18n/dictionary.js";
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
|
|
22
|
-
import { CodeBlockOptions } from "../blocks/CodeBlockContent/CodeBlockContent.js";
|
|
23
|
-
import type { ThreadStore, User } from "../comments/index.js";
|
|
24
|
-
import type { ForkYDocPlugin } from "../extensions/Collaboration/ForkYDocPlugin.js";
|
|
16
|
+
import { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, CustomBlockNoteSchema, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema/index.js";
|
|
17
|
+
import "../style.css";
|
|
25
18
|
import { EventEmitter } from "../util/EventEmitter.js";
|
|
19
|
+
import { NoInfer } from "../util/typescript.js";
|
|
26
20
|
import { BlockNoteExtension } from "./BlockNoteExtension.js";
|
|
21
|
+
import { TextCursorPosition } from "./cursorPositionTypes.js";
|
|
22
|
+
import { Selection } from "./selectionTypes.js";
|
|
23
|
+
import { Block, BlockNoteSchema, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/index.js";
|
|
27
24
|
import "../style.css";
|
|
28
25
|
/**
|
|
29
26
|
* A factory function that returns a BlockNoteExtension
|
|
@@ -77,10 +74,6 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
77
74
|
*/
|
|
78
75
|
showCursorLabels?: "always" | "activity";
|
|
79
76
|
};
|
|
80
|
-
/**
|
|
81
|
-
* Options for code blocks.
|
|
82
|
-
*/
|
|
83
|
-
codeBlock?: CodeBlockOptions;
|
|
84
77
|
/**
|
|
85
78
|
* Configuration for the comments feature, requires a `threadStore`.
|
|
86
79
|
*
|
|
@@ -130,17 +123,6 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
130
123
|
width?: number;
|
|
131
124
|
class?: string;
|
|
132
125
|
}) => Plugin;
|
|
133
|
-
/**
|
|
134
|
-
* Configuration for headings
|
|
135
|
-
*/
|
|
136
|
-
heading?: {
|
|
137
|
-
/**
|
|
138
|
-
* The levels of headings that should be available in the editor.
|
|
139
|
-
* @note Configurable up to 6 levels of headings.
|
|
140
|
-
* @default [1, 2, 3]
|
|
141
|
-
*/
|
|
142
|
-
levels?: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
143
|
-
};
|
|
144
126
|
/**
|
|
145
127
|
* The content that should be in the editor when it's created, represented as an array of {@link PartialBlock} objects.
|
|
146
128
|
*
|
|
@@ -171,7 +153,7 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
171
153
|
*/
|
|
172
154
|
pasteHandler?: (context: {
|
|
173
155
|
event: ClipboardEvent;
|
|
174
|
-
editor: BlockNoteEditor<BSchema
|
|
156
|
+
editor: BlockNoteEditor<NoInfer<BSchema>, NoInfer<ISchema>, NoInfer<SSchema>>;
|
|
175
157
|
/**
|
|
176
158
|
* The default paste handler
|
|
177
159
|
* @param context The context object
|
|
@@ -208,7 +190,7 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
208
190
|
* See [Custom Schemas](https://www.blocknotejs.org/docs/custom-schemas) for more info.
|
|
209
191
|
* @remarks `BlockNoteSchema`
|
|
210
192
|
*/
|
|
211
|
-
schema:
|
|
193
|
+
schema: CustomBlockNoteSchema<BSchema, ISchema, SSchema>;
|
|
212
194
|
/**
|
|
213
195
|
* A flag indicating whether to set an HTML ID for every block
|
|
214
196
|
*
|
|
@@ -296,23 +278,16 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
296
278
|
/**
|
|
297
279
|
* Register extensions to the editor.
|
|
298
280
|
*
|
|
299
|
-
*
|
|
300
|
-
*/
|
|
301
|
-
extensions?: Array<BlockNoteExtension | BlockNoteExtensionFactory>;
|
|
302
|
-
/**
|
|
303
|
-
* Boolean indicating whether the editor is in headless mode.
|
|
304
|
-
* Headless mode means we can use features like importing / exporting blocks,
|
|
305
|
-
* but there's no underlying editor (UI) instantiated.
|
|
281
|
+
* See [Extensions](/docs/features/extensions) for more info.
|
|
306
282
|
*
|
|
307
|
-
*
|
|
308
|
-
* @internal
|
|
283
|
+
* @remarks `BlockNoteExtension[]`
|
|
309
284
|
*/
|
|
310
|
-
|
|
285
|
+
extensions?: Array<BlockNoteExtension | BlockNoteExtensionFactory>;
|
|
311
286
|
};
|
|
312
287
|
export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> extends EventEmitter<{
|
|
313
288
|
create: void;
|
|
314
289
|
}> {
|
|
315
|
-
protected readonly options: Partial<BlockNoteEditorOptions<
|
|
290
|
+
protected readonly options: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>;
|
|
316
291
|
/**
|
|
317
292
|
* The underlying prosemirror schema
|
|
318
293
|
*/
|
|
@@ -321,16 +296,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
321
296
|
* extensions that are added to the editor, can be tiptap extensions or prosemirror plugins
|
|
322
297
|
*/
|
|
323
298
|
extensions: Record<string, SupportedExtension>;
|
|
324
|
-
|
|
325
|
-
* Boolean indicating whether the editor is in headless mode.
|
|
326
|
-
* Headless mode means we can use features like importing / exporting blocks,
|
|
327
|
-
* but there's no underlying editor (UI) instantiated.
|
|
328
|
-
*
|
|
329
|
-
* You probably don't need to set this manually, but use the `server-util` package instead that uses this option internally
|
|
330
|
-
*/
|
|
331
|
-
readonly headless: boolean;
|
|
332
|
-
readonly _tiptapEditor: Omit<BlockNoteTipTapEditor, "view"> & {
|
|
333
|
-
view: EditorView | undefined;
|
|
299
|
+
readonly _tiptapEditor: TiptapEditor & {
|
|
334
300
|
contentComponent: any;
|
|
335
301
|
};
|
|
336
302
|
/**
|
|
@@ -351,7 +317,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
351
317
|
/**
|
|
352
318
|
* The schema of the editor. The schema defines which Blocks, InlineContent, and Styles are available in the editor.
|
|
353
319
|
*/
|
|
354
|
-
readonly schema:
|
|
320
|
+
readonly schema: CustomBlockNoteSchema<BSchema, ISchema, SSchema>;
|
|
355
321
|
readonly blockImplementations: BlockSpecs;
|
|
356
322
|
readonly inlineContentImplementations: InlineContentSpecs;
|
|
357
323
|
readonly styleImplementations: StyleSpecs;
|
|
@@ -391,13 +357,11 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
391
357
|
cellTextColor: boolean;
|
|
392
358
|
headers: boolean;
|
|
393
359
|
};
|
|
394
|
-
codeBlock: CodeBlockOptions;
|
|
395
|
-
heading: {
|
|
396
|
-
levels: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
397
|
-
};
|
|
398
360
|
};
|
|
399
|
-
static create<
|
|
400
|
-
|
|
361
|
+
static create<Options extends Partial<BlockNoteEditorOptions<any, any, any>> | undefined>(options?: Options): Options extends {
|
|
362
|
+
schema: CustomBlockNoteSchema<infer BSchema, infer ISchema, infer SSchema>;
|
|
363
|
+
} ? BlockNoteEditor<BSchema, ISchema, SSchema> : BlockNoteEditor<DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;
|
|
364
|
+
protected constructor(options: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>);
|
|
401
365
|
/**
|
|
402
366
|
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
403
367
|
*/
|
|
@@ -465,11 +429,15 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
465
429
|
new (...args: any[]): T;
|
|
466
430
|
} & typeof BlockNoteExtension, key?: string): T;
|
|
467
431
|
/**
|
|
468
|
-
* Mount the editor to a
|
|
432
|
+
* Mount the editor to a DOM element.
|
|
469
433
|
*
|
|
470
434
|
* @warning Not needed to call manually when using React, use BlockNoteView to take care of mounting
|
|
471
435
|
*/
|
|
472
|
-
mount: (
|
|
436
|
+
mount: (element: HTMLElement) => void;
|
|
437
|
+
/**
|
|
438
|
+
* Unmount the editor from the DOM element it is bound to
|
|
439
|
+
*/
|
|
440
|
+
unmount: () => void;
|
|
473
441
|
/**
|
|
474
442
|
* Get the underlying prosemirror state
|
|
475
443
|
* @note Prefer using `editor.transact` to read the current editor state, as that will ensure the state is up to date
|
|
@@ -480,9 +448,10 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
480
448
|
* Get the underlying prosemirror view
|
|
481
449
|
* @see https://prosemirror.net/docs/ref/#view.EditorView
|
|
482
450
|
*/
|
|
483
|
-
get prosemirrorView(): EditorView
|
|
451
|
+
get prosemirrorView(): import("prosemirror-view").EditorView;
|
|
484
452
|
get domElement(): HTMLDivElement | undefined;
|
|
485
453
|
isFocused(): boolean;
|
|
454
|
+
get headless(): boolean;
|
|
486
455
|
focus(): void;
|
|
487
456
|
onUploadStart(callback: (blockId?: string) => void): () => void;
|
|
488
457
|
onUploadEnd(callback: (blockId?: string) => void): () => void;
|
|
@@ -577,7 +546,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
577
546
|
* only the part of the block that is included in the selection.
|
|
578
547
|
*/
|
|
579
548
|
getSelectionCutBlocks(): {
|
|
580
|
-
blocks: Block<Record<string, import("../index.js").BlockConfig
|
|
549
|
+
blocks: Block<Record<string, import("../index.js").BlockConfig<string, import("../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
581
550
|
blockCutAtStart: string | undefined;
|
|
582
551
|
blockCutAtEnd: string | undefined;
|
|
583
552
|
_meta: {
|
|
@@ -622,7 +591,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
622
591
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
623
592
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
624
593
|
*/
|
|
625
|
-
removeBlocks(blocksToRemove: BlockIdentifier[]): Block<Record<string, import("../index.js").BlockConfig
|
|
594
|
+
removeBlocks(blocksToRemove: BlockIdentifier[]): Block<Record<string, import("../index.js").BlockConfig<string, import("../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
626
595
|
/**
|
|
627
596
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
628
597
|
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
@@ -781,14 +750,14 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
781
750
|
* Returns the blocks that were inserted, updated, or deleted by the change that occurred.
|
|
782
751
|
*/
|
|
783
752
|
getChanges(): BlocksChanged<BSchema, ISchema, SSchema>;
|
|
784
|
-
}) => void): (
|
|
753
|
+
}) => void): () => void;
|
|
785
754
|
/**
|
|
786
755
|
* A callback function that runs whenever the text cursor position or selection changes.
|
|
787
756
|
*
|
|
788
757
|
* @param callback The callback to execute.
|
|
789
758
|
* @returns A function to remove the callback.
|
|
790
759
|
*/
|
|
791
|
-
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void, includeSelectionChangedByRemote?: boolean): (
|
|
760
|
+
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void, includeSelectionChangedByRemote?: boolean): () => void;
|
|
792
761
|
/**
|
|
793
762
|
* A callback function that runs when the editor has been initialized.
|
|
794
763
|
*
|
|
@@ -813,7 +782,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
813
782
|
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
814
783
|
* @param text The text to paste.
|
|
815
784
|
*/
|
|
816
|
-
pasteText(text: string): boolean
|
|
785
|
+
pasteText(text: string): boolean;
|
|
817
786
|
/**
|
|
818
787
|
* Paste markdown into the editor.
|
|
819
788
|
* @param markdown The markdown to paste.
|
|
@@ -1,9 +1,76 @@
|
|
|
1
1
|
import { Plugin } from "prosemirror-state";
|
|
2
2
|
import { EventEmitter } from "../util/EventEmitter.js";
|
|
3
|
+
import { AnyExtension } from "@tiptap/core";
|
|
4
|
+
import { BlockSchema, InlineContentSchema, PartialBlockNoDefaults, StyleSchema } from "../schema/index.js";
|
|
5
|
+
import { BlockNoteEditor } from "./BlockNoteEditor.js";
|
|
3
6
|
export declare abstract class BlockNoteExtension<TEvent extends Record<string, any> = any> extends EventEmitter<TEvent> {
|
|
4
7
|
static key(): string;
|
|
5
8
|
protected addProsemirrorPlugin(plugin: Plugin): void;
|
|
6
9
|
readonly plugins: Plugin[];
|
|
7
10
|
get priority(): number | undefined;
|
|
8
11
|
constructor(..._args: any[]);
|
|
12
|
+
/**
|
|
13
|
+
* Input rules for the block
|
|
14
|
+
*/
|
|
15
|
+
inputRules?: InputRule[];
|
|
16
|
+
/**
|
|
17
|
+
* A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed
|
|
18
|
+
*
|
|
19
|
+
* The keys are in the format:
|
|
20
|
+
* - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers
|
|
21
|
+
* - Key identifiers are based on the strings that can appear in KeyEvent.key
|
|
22
|
+
* - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)
|
|
23
|
+
* - You may use `Space` as an alias for the " " name
|
|
24
|
+
* - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)
|
|
25
|
+
* - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly
|
|
26
|
+
* - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* keyboardShortcuts: {
|
|
31
|
+
* "Mod-Enter": (ctx) => { return true; },
|
|
32
|
+
* "Shift-Ctrl-Space": (ctx) => { return true; },
|
|
33
|
+
* "a": (ctx) => { return true; },
|
|
34
|
+
* "Space": (ctx) => { return true; }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
keyboardShortcuts?: Record<string, (ctx: {
|
|
39
|
+
editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>;
|
|
40
|
+
}) => boolean>;
|
|
41
|
+
tiptapExtensions?: AnyExtension[];
|
|
9
42
|
}
|
|
43
|
+
export type InputRule = {
|
|
44
|
+
/**
|
|
45
|
+
* The regex to match when to trigger the input rule
|
|
46
|
+
*/
|
|
47
|
+
find: RegExp;
|
|
48
|
+
/**
|
|
49
|
+
* The function to call when the input rule is matched
|
|
50
|
+
* @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block
|
|
51
|
+
*/
|
|
52
|
+
replace: (props: {
|
|
53
|
+
/**
|
|
54
|
+
* The result of the regex match
|
|
55
|
+
*/
|
|
56
|
+
match: RegExpMatchArray;
|
|
57
|
+
/**
|
|
58
|
+
* The range of the text that was matched
|
|
59
|
+
*/
|
|
60
|
+
range: {
|
|
61
|
+
from: number;
|
|
62
|
+
to: number;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The editor instance
|
|
66
|
+
*/
|
|
67
|
+
editor: BlockNoteEditor<any, any, any>;
|
|
68
|
+
}) => undefined | PartialBlockNoDefaults<any, any, any>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* This creates an instance of a BlockNoteExtension that can be used to add to a schema.
|
|
72
|
+
* It is a bit of a hack, but it works.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createBlockNoteExtension(options: Partial<Pick<BlockNoteExtension, "inputRules" | "keyboardShortcuts" | "plugins" | "tiptapExtensions">> & {
|
|
75
|
+
key: string;
|
|
76
|
+
}): BlockNoteExtension;
|
|
@@ -3,7 +3,7 @@ import * as Y from "yjs";
|
|
|
3
3
|
import type { ThreadStore } from "../comments/index.js";
|
|
4
4
|
import { BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, StyleSchema, StyleSpecs } from "../schema/index.js";
|
|
5
5
|
import type { BlockNoteEditor, BlockNoteEditorOptions, SupportedExtension } from "./BlockNoteEditor.js";
|
|
6
|
-
import { BlockNoteSchema } from "
|
|
6
|
+
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
|
|
7
7
|
type ExtensionOptions<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
8
8
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
9
9
|
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
@@ -1,76 +1,8 @@
|
|
|
1
|
-
export declare const COLORS_DEFAULT: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
red: {
|
|
11
|
-
text: string;
|
|
12
|
-
background: string;
|
|
13
|
-
};
|
|
14
|
-
orange: {
|
|
15
|
-
text: string;
|
|
16
|
-
background: string;
|
|
17
|
-
};
|
|
18
|
-
yellow: {
|
|
19
|
-
text: string;
|
|
20
|
-
background: string;
|
|
21
|
-
};
|
|
22
|
-
green: {
|
|
23
|
-
text: string;
|
|
24
|
-
background: string;
|
|
25
|
-
};
|
|
26
|
-
blue: {
|
|
27
|
-
text: string;
|
|
28
|
-
background: string;
|
|
29
|
-
};
|
|
30
|
-
purple: {
|
|
31
|
-
text: string;
|
|
32
|
-
background: string;
|
|
33
|
-
};
|
|
34
|
-
pink: {
|
|
35
|
-
text: string;
|
|
36
|
-
background: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export declare const COLORS_DARK_MODE_DEFAULT: {
|
|
40
|
-
gray: {
|
|
41
|
-
text: string;
|
|
42
|
-
background: string;
|
|
43
|
-
};
|
|
44
|
-
brown: {
|
|
45
|
-
text: string;
|
|
46
|
-
background: string;
|
|
47
|
-
};
|
|
48
|
-
red: {
|
|
49
|
-
text: string;
|
|
50
|
-
background: string;
|
|
51
|
-
};
|
|
52
|
-
orange: {
|
|
53
|
-
text: string;
|
|
54
|
-
background: string;
|
|
55
|
-
};
|
|
56
|
-
yellow: {
|
|
57
|
-
text: string;
|
|
58
|
-
background: string;
|
|
59
|
-
};
|
|
60
|
-
green: {
|
|
61
|
-
text: string;
|
|
62
|
-
background: string;
|
|
63
|
-
};
|
|
64
|
-
blue: {
|
|
65
|
-
text: string;
|
|
66
|
-
background: string;
|
|
67
|
-
};
|
|
68
|
-
purple: {
|
|
69
|
-
text: string;
|
|
70
|
-
background: string;
|
|
71
|
-
};
|
|
72
|
-
pink: {
|
|
73
|
-
text: string;
|
|
74
|
-
background: string;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
1
|
+
export declare const COLORS_DEFAULT: Record<string, {
|
|
2
|
+
text: string;
|
|
3
|
+
background: string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const COLORS_DARK_MODE_DEFAULT: Record<string, {
|
|
6
|
+
text: string;
|
|
7
|
+
background: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
2
|
+
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
3
|
+
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
4
|
+
export declare class BlockManager<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
5
|
+
private editor;
|
|
6
|
+
constructor(editor: BlockNoteEditor<BSchema, ISchema, SSchema>);
|
|
7
|
+
/**
|
|
8
|
+
* Gets a snapshot of all top-level (non-nested) blocks in the editor.
|
|
9
|
+
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
10
|
+
*/
|
|
11
|
+
get document(): Block<BSchema, ISchema, SSchema>[];
|
|
12
|
+
/**
|
|
13
|
+
* Gets a snapshot of an existing block from the editor.
|
|
14
|
+
* @param blockIdentifier The identifier of an existing block that should be
|
|
15
|
+
* retrieved.
|
|
16
|
+
* @returns The block that matches the identifier, or `undefined` if no
|
|
17
|
+
* matching block was found.
|
|
18
|
+
*/
|
|
19
|
+
getBlock(blockIdentifier: BlockIdentifier): Block<BSchema, ISchema, SSchema> | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Gets a snapshot of the previous sibling of an existing block from the
|
|
22
|
+
* editor.
|
|
23
|
+
* @param blockIdentifier The identifier of an existing block for which the
|
|
24
|
+
* previous sibling should be retrieved.
|
|
25
|
+
* @returns The previous sibling of the block that matches the identifier.
|
|
26
|
+
* `undefined` if no matching block was found, or it's the first child/block
|
|
27
|
+
* in the document.
|
|
28
|
+
*/
|
|
29
|
+
getPrevBlock(blockIdentifier: BlockIdentifier): Block<BSchema, ISchema, SSchema> | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Gets a snapshot of the next sibling of an existing block from the editor.
|
|
32
|
+
* @param blockIdentifier The identifier of an existing block for which the
|
|
33
|
+
* next sibling should be retrieved.
|
|
34
|
+
* @returns The next sibling of the block that matches the identifier.
|
|
35
|
+
* `undefined` if no matching block was found, or it's the last child/block in
|
|
36
|
+
* the document.
|
|
37
|
+
*/
|
|
38
|
+
getNextBlock(blockIdentifier: BlockIdentifier): Block<BSchema, ISchema, SSchema> | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Gets a snapshot of the parent of an existing block from the editor.
|
|
41
|
+
* @param blockIdentifier The identifier of an existing block for which the
|
|
42
|
+
* parent should be retrieved.
|
|
43
|
+
* @returns The parent of the block that matches the identifier. `undefined`
|
|
44
|
+
* if no matching block was found, or the block isn't nested.
|
|
45
|
+
*/
|
|
46
|
+
getParentBlock(blockIdentifier: BlockIdentifier): Block<BSchema, ISchema, SSchema> | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Traverses all blocks in the editor depth-first, and executes a callback for each.
|
|
49
|
+
* @param callback The callback to execute for each block. Returning `false` stops the traversal.
|
|
50
|
+
* @param reverse Whether the blocks should be traversed in reverse order.
|
|
51
|
+
*/
|
|
52
|
+
forEachBlock(callback: (block: Block<BSchema, ISchema, SSchema>) => boolean, reverse?: boolean): void;
|
|
53
|
+
/**
|
|
54
|
+
* Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
|
|
55
|
+
* error if the reference block could not be found.
|
|
56
|
+
* @param blocksToInsert An array of partial blocks that should be inserted.
|
|
57
|
+
* @param referenceBlock An identifier for an existing block, at which the new blocks should be inserted.
|
|
58
|
+
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
59
|
+
* `referenceBlock`.
|
|
60
|
+
*/
|
|
61
|
+
insertBlocks(blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[], referenceBlock: BlockIdentifier, placement?: "before" | "after"): Block<BSchema, ISchema, SSchema>[];
|
|
62
|
+
/**
|
|
63
|
+
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
64
|
+
* defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
|
|
65
|
+
* not be found.
|
|
66
|
+
* @param blockToUpdate The block that should be updated.
|
|
67
|
+
* @param update A partial block which defines how the existing block should be changed.
|
|
68
|
+
*/
|
|
69
|
+
updateBlock(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, ISchema, SSchema>): Block<BSchema, ISchema, SSchema>;
|
|
70
|
+
/**
|
|
71
|
+
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
72
|
+
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
73
|
+
*/
|
|
74
|
+
removeBlocks(blocksToRemove: BlockIdentifier[]): Block<Record<string, import("../../index.js").BlockConfig<string, import("../../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
75
|
+
/**
|
|
76
|
+
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
77
|
+
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
78
|
+
* `blocksToRemove`. Throws an error if any of the blocks to remove could not be found.
|
|
79
|
+
* @param blocksToRemove An array of blocks that should be replaced.
|
|
80
|
+
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
81
|
+
*/
|
|
82
|
+
replaceBlocks(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[]): {
|
|
83
|
+
insertedBlocks: Block<BSchema, ISchema, SSchema>[];
|
|
84
|
+
removedBlocks: Block<BSchema, ISchema, SSchema>[];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Checks if the block containing the text cursor can be nested.
|
|
88
|
+
*/
|
|
89
|
+
canNestBlock(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Nests the block containing the text cursor into the block above it.
|
|
92
|
+
*/
|
|
93
|
+
nestBlock(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Checks if the block containing the text cursor is nested.
|
|
96
|
+
*/
|
|
97
|
+
canUnnestBlock(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Lifts the block containing the text cursor out of its parent.
|
|
100
|
+
*/
|
|
101
|
+
unnestBlock(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Moves the selected blocks up. If the previous block has children, moves
|
|
104
|
+
* them to the end of its children. If there is no previous block, but the
|
|
105
|
+
* current blocks share a common parent, moves them out of & before it.
|
|
106
|
+
*/
|
|
107
|
+
moveBlocksUp(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Moves the selected blocks down. If the next block has children, moves
|
|
110
|
+
* them to the start of its children. If there is no next block, but the
|
|
111
|
+
* current blocks share a common parent, moves them out of & after it.
|
|
112
|
+
*/
|
|
113
|
+
moveBlocksDown(): void;
|
|
114
|
+
}
|