@blocknote/core 0.11.2 → 0.12.1
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/README.md +13 -17
- package/dist/blocknote.js +1662 -1447
- 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/webpack-stats.json +1 -1
- package/package.json +7 -3
- package/src/api/blockManipulation/blockManipulation.test.ts +19 -15
- package/src/api/blockManipulation/blockManipulation.ts +107 -17
- package/src/api/exporters/html/externalHTMLExporter.ts +3 -7
- package/src/api/exporters/html/htmlConversion.test.ts +6 -3
- package/src/api/exporters/html/internalHTMLSerializer.ts +3 -7
- package/src/api/exporters/html/util/sharedHTMLConversion.ts +3 -3
- package/src/api/exporters/markdown/markdownExporter.test.ts +7 -3
- package/src/api/exporters/markdown/markdownExporter.ts +2 -6
- package/src/api/getCurrentBlockContentType.ts +14 -0
- package/src/api/nodeConversions/nodeConversions.test.ts +14 -7
- package/src/api/nodeConversions/nodeConversions.ts +1 -2
- package/src/api/parsers/html/parseHTML.test.ts +5 -1
- package/src/api/parsers/html/parseHTML.ts +2 -6
- package/src/api/parsers/html/util/nestedLists.ts +11 -1
- package/src/api/parsers/markdown/parseMarkdown.test.ts +3 -0
- package/src/api/parsers/markdown/parseMarkdown.ts +2 -6
- package/src/api/testUtil/cases/customBlocks.ts +18 -16
- package/src/api/testUtil/cases/customInlineContent.ts +12 -13
- package/src/api/testUtil/cases/customStyles.ts +12 -10
- package/src/api/testUtil/index.ts +4 -2
- package/src/api/testUtil/partialBlockTestUtil.ts +2 -6
- package/src/blocks/HeadingBlockContent/HeadingBlockContent.ts +50 -21
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +1 -2
- package/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +8 -1
- package/src/blocks/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +18 -5
- package/src/blocks/ListItemBlockContent/ListItemKeyboardShortcuts.ts +7 -1
- package/src/blocks/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +18 -5
- package/src/blocks/ParagraphBlockContent/ParagraphBlockContent.ts +14 -5
- package/src/blocks/defaultBlockHelpers.ts +3 -3
- package/src/blocks/defaultBlockTypeGuards.ts +84 -0
- package/src/blocks/defaultBlocks.ts +29 -3
- package/src/editor/Block.css +2 -31
- package/src/editor/BlockNoteEditor.ts +223 -267
- package/src/editor/BlockNoteExtensions.ts +5 -2
- package/src/editor/BlockNoteSchema.ts +98 -0
- package/src/editor/BlockNoteTipTapEditor.ts +162 -0
- package/src/editor/cursorPositionTypes.ts +2 -6
- package/src/editor/editor.css +0 -1
- package/src/editor/selectionTypes.ts +2 -6
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +22 -29
- package/src/extensions/{ImageToolbar → ImagePanel}/ImageToolbarPlugin.ts +54 -60
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +330 -0
- package/src/extensions/Placeholder/PlaceholderExtension.ts +81 -88
- package/src/extensions/SideMenu/SideMenuPlugin.ts +55 -56
- package/src/extensions/SuggestionMenu/DefaultSuggestionItem.ts +8 -0
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +353 -0
- package/src/extensions/{SlashMenu/defaultSlashMenuItems.ts → SuggestionMenu/getDefaultSlashMenuItems.ts} +119 -89
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +62 -45
- package/src/extensions-shared/UiElementPosition.ts +4 -0
- package/src/index.ts +8 -8
- package/src/pm-nodes/BlockContainer.ts +5 -5
- package/src/schema/blocks/types.ts +15 -15
- package/src/schema/inlineContent/createSpec.ts +2 -2
- package/src/schema/inlineContent/types.ts +1 -1
- package/src/util/browser.ts +6 -4
- package/src/util/typescript.ts +7 -4
- package/types/src/api/blockManipulation/blockManipulation.d.ts +6 -1
- package/types/src/api/exporters/html/externalHTMLExporter.d.ts +2 -1
- package/types/src/api/exporters/html/internalHTMLSerializer.d.ts +2 -1
- package/types/src/api/exporters/markdown/markdownExporter.d.ts +2 -1
- package/types/src/api/getCurrentBlockContentType.d.ts +2 -0
- package/types/src/api/nodeConversions/nodeConversions.d.ts +2 -1
- package/types/src/api/parsers/html/parseHTML.d.ts +2 -1
- package/types/src/api/parsers/markdown/parseMarkdown.d.ts +2 -1
- package/types/src/api/testUtil/cases/customBlocks.d.ts +72 -13
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +281 -6
- package/types/src/api/testUtil/cases/customStyles.d.ts +247 -13
- package/types/src/api/testUtil/index.d.ts +4 -2
- package/types/src/api/testUtil/partialBlockTestUtil.d.ts +2 -1
- package/types/src/blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +6 -1
- package/types/src/blocks/defaultBlockHelpers.d.ts +2 -2
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +24 -0
- package/types/src/blocks/defaultBlocks.d.ts +21 -15
- package/types/src/editor/BlockNoteEditor.d.ts +51 -56
- package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
- package/types/src/editor/BlockNoteSchema.d.ts +34 -0
- package/types/src/editor/BlockNoteTipTapEditor.d.ts +28 -0
- package/types/src/editor/cursorPositionTypes.d.ts +2 -1
- package/types/src/editor/selectionTypes.d.ts +2 -1
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +5 -6
- package/types/src/extensions/ImagePanel/ImageToolbarPlugin.d.ts +32 -0
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +40 -0
- package/types/src/extensions/Placeholder/PlaceholderExtension.d.ts +2 -15
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +8 -7
- package/types/src/extensions/SuggestionMenu/DefaultSuggestionItem.d.ts +8 -0
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +31 -0
- package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +10 -0
- package/types/src/extensions/TableHandles/TableHandlesPlugin.d.ts +7 -7
- package/types/src/extensions-shared/UiElementPosition.d.ts +4 -0
- package/types/src/index.d.ts +8 -8
- package/types/src/pm-nodes/BlockContainer.d.ts +3 -2
- package/types/src/pm-nodes/BlockGroup.d.ts +1 -1
- package/types/src/schema/blocks/types.d.ts +15 -15
- package/types/src/schema/inlineContent/types.d.ts +1 -1
- package/types/src/util/browser.d.ts +1 -0
- package/types/src/util/typescript.d.ts +1 -0
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +0 -335
- package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +0 -12
- package/src/extensions/SlashMenu/SlashMenuPlugin.ts +0 -53
- package/src/extensions-shared/BaseUiElementTypes.ts +0 -8
- package/src/extensions-shared/README.md +0 -3
- package/src/extensions-shared/suggestion/SuggestionItem.ts +0 -3
- package/src/extensions-shared/suggestion/SuggestionPlugin.ts +0 -448
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +0 -38
- package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +0 -31
- package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +0 -7
- package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +0 -13
- package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +0 -3
- package/types/src/extensions-shared/BaseUiElementTypes.d.ts +0 -7
- package/types/src/extensions-shared/suggestion/SuggestionItem.d.ts +0 -3
- package/types/src/extensions-shared/suggestion/SuggestionPlugin.d.ts +0 -36
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-100.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-100.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-200.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-200.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-300.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-300.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-500.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-500.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-600.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-600.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-700.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-700.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-800.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-800.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-900.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-900.woff2 +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-regular.woff +0 -0
- /package/src/{assets → fonts}/inter-v12-latin/inter-v12-latin-regular.woff2 +0 -0
- /package/src/{assets/fonts-inter.css → fonts/inter.css} +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNoDefaults, BlockSchema, InlineContentSchema, PartialBlockNoDefaults, StyleSchema } from "../schema";
|
|
1
2
|
export declare const defaultBlockSpecs: {
|
|
2
3
|
paragraph: {
|
|
3
4
|
config: {
|
|
@@ -31,7 +32,7 @@ export declare const defaultBlockSpecs: {
|
|
|
31
32
|
values: readonly ["left", "center", "right", "justify"];
|
|
32
33
|
};
|
|
33
34
|
};
|
|
34
|
-
}, any,
|
|
35
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
35
36
|
};
|
|
36
37
|
heading: {
|
|
37
38
|
config: {
|
|
@@ -73,7 +74,7 @@ export declare const defaultBlockSpecs: {
|
|
|
73
74
|
values: readonly ["left", "center", "right", "justify"];
|
|
74
75
|
};
|
|
75
76
|
};
|
|
76
|
-
}, any,
|
|
77
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
77
78
|
};
|
|
78
79
|
bulletListItem: {
|
|
79
80
|
config: {
|
|
@@ -107,7 +108,7 @@ export declare const defaultBlockSpecs: {
|
|
|
107
108
|
values: readonly ["left", "center", "right", "justify"];
|
|
108
109
|
};
|
|
109
110
|
};
|
|
110
|
-
}, any,
|
|
111
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
111
112
|
};
|
|
112
113
|
numberedListItem: {
|
|
113
114
|
config: {
|
|
@@ -141,7 +142,7 @@ export declare const defaultBlockSpecs: {
|
|
|
141
142
|
values: readonly ["left", "center", "right", "justify"];
|
|
142
143
|
};
|
|
143
144
|
};
|
|
144
|
-
}, any,
|
|
145
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
145
146
|
};
|
|
146
147
|
image: {
|
|
147
148
|
config: {
|
|
@@ -187,7 +188,7 @@ export declare const defaultBlockSpecs: {
|
|
|
187
188
|
};
|
|
188
189
|
};
|
|
189
190
|
content: "none";
|
|
190
|
-
}, any,
|
|
191
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
191
192
|
};
|
|
192
193
|
table: {
|
|
193
194
|
config: {
|
|
@@ -221,7 +222,7 @@ export declare const defaultBlockSpecs: {
|
|
|
221
222
|
values: readonly ["left", "center", "right", "justify"];
|
|
222
223
|
};
|
|
223
224
|
};
|
|
224
|
-
}, any,
|
|
225
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
225
226
|
};
|
|
226
227
|
};
|
|
227
228
|
export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpecs<{
|
|
@@ -257,7 +258,7 @@ export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpec
|
|
|
257
258
|
values: readonly ["left", "center", "right", "justify"];
|
|
258
259
|
};
|
|
259
260
|
};
|
|
260
|
-
}, any,
|
|
261
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
261
262
|
};
|
|
262
263
|
heading: {
|
|
263
264
|
config: {
|
|
@@ -299,7 +300,7 @@ export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpec
|
|
|
299
300
|
values: readonly ["left", "center", "right", "justify"];
|
|
300
301
|
};
|
|
301
302
|
};
|
|
302
|
-
}, any,
|
|
303
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
303
304
|
};
|
|
304
305
|
bulletListItem: {
|
|
305
306
|
config: {
|
|
@@ -333,7 +334,7 @@ export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpec
|
|
|
333
334
|
values: readonly ["left", "center", "right", "justify"];
|
|
334
335
|
};
|
|
335
336
|
};
|
|
336
|
-
}, any,
|
|
337
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
337
338
|
};
|
|
338
339
|
numberedListItem: {
|
|
339
340
|
config: {
|
|
@@ -367,7 +368,7 @@ export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpec
|
|
|
367
368
|
values: readonly ["left", "center", "right", "justify"];
|
|
368
369
|
};
|
|
369
370
|
};
|
|
370
|
-
}, any,
|
|
371
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
371
372
|
};
|
|
372
373
|
image: {
|
|
373
374
|
config: {
|
|
@@ -413,7 +414,7 @@ export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpec
|
|
|
413
414
|
};
|
|
414
415
|
};
|
|
415
416
|
content: "none";
|
|
416
|
-
}, any,
|
|
417
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
417
418
|
};
|
|
418
419
|
table: {
|
|
419
420
|
config: {
|
|
@@ -447,10 +448,11 @@ export declare const defaultBlockSchema: import("../schema").BlockSchemaFromSpec
|
|
|
447
448
|
values: readonly ["left", "center", "right", "justify"];
|
|
448
449
|
};
|
|
449
450
|
};
|
|
450
|
-
}, any,
|
|
451
|
+
}, any, InlineContentSchema, StyleSchema>;
|
|
451
452
|
};
|
|
452
453
|
}>;
|
|
453
|
-
export type
|
|
454
|
+
export type _DefaultBlockSchema = typeof defaultBlockSchema;
|
|
455
|
+
export type DefaultBlockSchema = _DefaultBlockSchema;
|
|
454
456
|
export declare const defaultStyleSpecs: {
|
|
455
457
|
bold: {
|
|
456
458
|
config: {
|
|
@@ -553,7 +555,8 @@ export declare const defaultStyleSchema: import("../schema").StyleSchemaFromSpec
|
|
|
553
555
|
implementation: import("../schema").StyleImplementation;
|
|
554
556
|
};
|
|
555
557
|
}>;
|
|
556
|
-
export type
|
|
558
|
+
export type _DefaultStyleSchema = typeof defaultStyleSchema;
|
|
559
|
+
export type DefaultStyleSchema = _DefaultStyleSchema;
|
|
557
560
|
export declare const defaultInlineContentSpecs: {
|
|
558
561
|
text: {
|
|
559
562
|
config: "text";
|
|
@@ -574,4 +577,7 @@ export declare const defaultInlineContentSchema: import("../schema").InlineConte
|
|
|
574
577
|
implementation: any;
|
|
575
578
|
};
|
|
576
579
|
}>;
|
|
577
|
-
export type
|
|
580
|
+
export type _DefaultInlineContentSchema = typeof defaultInlineContentSchema;
|
|
581
|
+
export type DefaultInlineContentSchema = _DefaultInlineContentSchema;
|
|
582
|
+
export type PartialBlock<BSchema extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> = PartialBlockNoDefaults<BSchema, I, S>;
|
|
583
|
+
export type Block<BSchema extends BlockSchema = DefaultBlockSchema, I extends InlineContentSchema = DefaultInlineContentSchema, S extends StyleSchema = DefaultStyleSchema> = BlockNoDefaults<BSchema, I, S>;
|
|
@@ -1,73 +1,41 @@
|
|
|
1
1
|
import { EditorOptions } from "@tiptap/core";
|
|
2
2
|
import { Node } from "prosemirror-model";
|
|
3
|
-
import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
|
|
4
3
|
import * as Y from "yjs";
|
|
5
|
-
import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema,
|
|
4
|
+
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/defaultBlocks";
|
|
6
5
|
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
7
|
-
import {
|
|
8
|
-
import { ImageToolbarProsemirrorPlugin } from "../extensions/ImageToolbar/ImageToolbarPlugin";
|
|
6
|
+
import { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkToolbarPlugin";
|
|
9
7
|
import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin";
|
|
9
|
+
import { ImagePanelProsemirrorPlugin } from "../extensions/ImagePanel/ImageToolbarPlugin";
|
|
12
10
|
import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin";
|
|
13
|
-
import {
|
|
11
|
+
import { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, InlineContentSchema, InlineContentSpecs, PartialInlineContent, StyleSchema, StyleSpecs, Styles } from "../schema";
|
|
12
|
+
import { NoInfer } from "../util/typescript";
|
|
14
13
|
import { TextCursorPosition } from "./cursorPositionTypes";
|
|
15
14
|
import { Selection } from "./selectionTypes";
|
|
15
|
+
import { BlockNoteSchema } from "./BlockNoteSchema";
|
|
16
|
+
import { BlockNoteTipTapEditor } from "./BlockNoteTipTapEditor";
|
|
16
17
|
import "./Block.css";
|
|
17
18
|
import "./editor.css";
|
|
18
|
-
export type BlockNoteEditorOptions<
|
|
19
|
+
export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> = {
|
|
19
20
|
enableBlockNoteExtensions: boolean;
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* (couldn't fix any type, see https://github.com/TypeCellOS/BlockNote/pull/191#discussion_r1210708771)
|
|
23
|
-
*
|
|
24
|
-
* @default defaultSlashMenuItems from `./extensions/SlashMenu`
|
|
25
|
-
*/
|
|
26
|
-
slashMenuItems: BaseSlashMenuItem<any, any, any>[];
|
|
27
|
-
/**
|
|
28
|
-
* The HTML element that should be used as the parent element for the editor.
|
|
29
|
-
*
|
|
30
|
-
* @default: undefined, the editor is not attached to the DOM
|
|
31
|
-
*/
|
|
32
|
-
parentElement: HTMLElement;
|
|
21
|
+
placeholders: Record<string | "default", string>;
|
|
33
22
|
/**
|
|
34
23
|
* An object containing attributes that should be added to HTML elements of the editor.
|
|
35
24
|
*
|
|
36
25
|
* @example { editor: { class: "my-editor-class" } }
|
|
37
26
|
*/
|
|
38
27
|
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
39
|
-
/**
|
|
40
|
-
* A callback function that runs when the editor is ready to be used.
|
|
41
|
-
*/
|
|
42
|
-
onEditorReady: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
|
|
43
|
-
/**
|
|
44
|
-
* A callback function that runs whenever the editor's contents change.
|
|
45
|
-
*/
|
|
46
|
-
onEditorContentChange: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
|
|
47
|
-
/**
|
|
48
|
-
* A callback function that runs whenever the text cursor position changes.
|
|
49
|
-
*/
|
|
50
|
-
onTextCursorPositionChange: (editor: BlockNoteEditor<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Locks the editor from being editable by the user if set to `false`.
|
|
53
|
-
*/
|
|
54
|
-
editable: boolean;
|
|
55
28
|
/**
|
|
56
29
|
* The content that should be in the editor when it's created, represented as an array of partial block objects.
|
|
57
30
|
*/
|
|
58
|
-
initialContent: PartialBlock<
|
|
31
|
+
initialContent: PartialBlock<NoInfer<BSchema>, NoInfer<ISchema>, NoInfer<SSchema>>[];
|
|
59
32
|
/**
|
|
60
33
|
* Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
|
|
61
34
|
*
|
|
62
35
|
* @default true
|
|
63
36
|
*/
|
|
64
37
|
defaultStyles: boolean;
|
|
65
|
-
|
|
66
|
-
* A list of block types that should be available in the editor.
|
|
67
|
-
*/
|
|
68
|
-
blockSpecs: BSpecs;
|
|
69
|
-
styleSpecs: SSpecs;
|
|
70
|
-
inlineContentSpecs: ISpecs;
|
|
38
|
+
schema: BlockNoteSchema<BSchema, ISchema, SSchema>;
|
|
71
39
|
/**
|
|
72
40
|
* A custom function to handle file uploads.
|
|
73
41
|
* @param file The file that should be uploaded.
|
|
@@ -102,35 +70,42 @@ export type BlockNoteEditorOptions<BSpecs extends BlockSpecs, ISpecs extends Inl
|
|
|
102
70
|
};
|
|
103
71
|
export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
104
72
|
private readonly options;
|
|
105
|
-
readonly _tiptapEditor:
|
|
73
|
+
readonly _tiptapEditor: BlockNoteTipTapEditor & {
|
|
106
74
|
contentComponent: any;
|
|
107
75
|
};
|
|
108
76
|
blockCache: WeakMap<Node, Block<any, any, any>>;
|
|
109
|
-
readonly
|
|
110
|
-
readonly inlineContentSchema: ISchema;
|
|
111
|
-
readonly styleSchema: SSchema;
|
|
77
|
+
readonly schema: BlockNoteSchema<BSchema, ISchema, SSchema>;
|
|
112
78
|
readonly blockImplementations: BlockSpecs;
|
|
113
79
|
readonly inlineContentImplementations: InlineContentSpecs;
|
|
114
80
|
readonly styleImplementations: StyleSpecs;
|
|
115
|
-
ready: boolean;
|
|
116
|
-
readonly sideMenu: SideMenuProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
117
81
|
readonly formattingToolbar: FormattingToolbarProsemirrorPlugin;
|
|
118
|
-
readonly
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
82
|
+
readonly linkToolbar: LinkToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
83
|
+
readonly sideMenu: SideMenuProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
84
|
+
readonly suggestionMenus: SuggestionMenuProseMirrorPlugin<BSchema, ISchema, SSchema>;
|
|
85
|
+
readonly imagePanel?: ImagePanelProsemirrorPlugin<ISchema, SSchema>;
|
|
86
|
+
readonly tableHandles?: TableHandlesProsemirrorPlugin<ISchema, SSchema>;
|
|
122
87
|
readonly uploadFile: ((file: File) => Promise<string>) | undefined;
|
|
123
|
-
static create<
|
|
88
|
+
static create<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema>(options?: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>): BlockNoteEditor<BSchema, ISchema, SSchema>;
|
|
124
89
|
private constructor();
|
|
90
|
+
/**
|
|
91
|
+
* Mount the editor to a parent DOM element. Call mount(undefined) to clean up
|
|
92
|
+
*
|
|
93
|
+
* @warning Not needed for React, use BlockNoteView to take care of this
|
|
94
|
+
*/
|
|
95
|
+
mount(parentElement?: HTMLElement | null): void;
|
|
125
96
|
get prosemirrorView(): import("prosemirror-view").EditorView;
|
|
126
97
|
get domElement(): HTMLDivElement;
|
|
127
98
|
isFocused(): boolean;
|
|
128
99
|
focus(): void;
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated, use `editor.document` instead
|
|
102
|
+
*/
|
|
103
|
+
get topLevelBlocks(): Block<BSchema, ISchema, SSchema>[];
|
|
129
104
|
/**
|
|
130
105
|
* Gets a snapshot of all top-level (non-nested) blocks in the editor.
|
|
131
106
|
* @returns A snapshot of all top-level (non-nested) blocks in the editor.
|
|
132
107
|
*/
|
|
133
|
-
get
|
|
108
|
+
get document(): Block<BSchema, ISchema, SSchema>[];
|
|
134
109
|
/**
|
|
135
110
|
* Gets a snapshot of an existing block from the editor.
|
|
136
111
|
* @param blockIdentifier The identifier of an existing block that should be retrieved.
|
|
@@ -212,6 +187,12 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
212
187
|
insertedBlocks: Block<BSchema, ISchema, SSchema>[];
|
|
213
188
|
removedBlocks: Block<BSchema, ISchema, SSchema>[];
|
|
214
189
|
};
|
|
190
|
+
/**
|
|
191
|
+
* Insert a piece of content at the current cursor position.
|
|
192
|
+
*
|
|
193
|
+
* @param content can be a string, or array of partial inline content elements
|
|
194
|
+
*/
|
|
195
|
+
insertInlineContent(content: PartialInlineContent<ISchema, SSchema>): void;
|
|
215
196
|
/**
|
|
216
197
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
217
198
|
*/
|
|
@@ -298,4 +279,18 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
298
279
|
name: string;
|
|
299
280
|
color: string;
|
|
300
281
|
}): void;
|
|
282
|
+
/**
|
|
283
|
+
* A callback function that runs whenever the editor's contents change.
|
|
284
|
+
*
|
|
285
|
+
* @param callback The callback to execute.
|
|
286
|
+
* @returns A function to remove the callback.
|
|
287
|
+
*/
|
|
288
|
+
onChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): () => void;
|
|
289
|
+
/**
|
|
290
|
+
* A callback function that runs whenever the text cursor position or selection changes.
|
|
291
|
+
*
|
|
292
|
+
* @param callback The callback to execute.
|
|
293
|
+
* @returns A function to remove the callback.
|
|
294
|
+
*/
|
|
295
|
+
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void): () => void;
|
|
301
296
|
}
|
|
@@ -7,6 +7,7 @@ import { BlockNoteDOMAttributes, BlockSpecs, InlineContentSchema, InlineContentS
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const getBlockNoteExtensions: <BSchema extends Record<string, import("../schema").BlockConfig>, I extends InlineContentSchema, S extends StyleSchema>(opts: {
|
|
9
9
|
editor: BlockNoteEditor<BSchema, I, S>;
|
|
10
|
+
placeholders?: Record<string, string> | undefined;
|
|
10
11
|
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
11
12
|
blockSchema: BSchema;
|
|
12
13
|
blockSpecs: BlockSpecs;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { defaultBlockSpecs, defaultInlineContentSpecs, defaultStyleSpecs } from "../blocks/defaultBlocks";
|
|
2
|
+
import { BlockSchema, BlockSchemaFromSpecs, BlockSpecs, InlineContentSchema, InlineContentSchemaFromSpecs, InlineContentSpecs, StyleSchema, StyleSchemaFromSpecs, StyleSpecs } from "../schema";
|
|
3
|
+
import type { BlockNoDefaults, PartialBlockNoDefaults } from "../schema/blocks/types";
|
|
4
|
+
import type { BlockNoteEditor } from "./BlockNoteEditor";
|
|
5
|
+
export declare class BlockNoteSchema<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> {
|
|
6
|
+
readonly blockSpecs: BlockSpecs;
|
|
7
|
+
readonly inlineContentSpecs: InlineContentSpecs;
|
|
8
|
+
readonly styleSpecs: StyleSpecs;
|
|
9
|
+
readonly blockSchema: BSchema;
|
|
10
|
+
readonly inlineContentSchema: ISchema;
|
|
11
|
+
readonly styleSchema: SSchema;
|
|
12
|
+
readonly BlockNoteEditor: BlockNoteEditor<BSchema, ISchema, SSchema>;
|
|
13
|
+
readonly Block: BlockNoDefaults<BSchema, ISchema, SSchema>;
|
|
14
|
+
readonly PartialBlock: PartialBlockNoDefaults<BSchema, ISchema, SSchema>;
|
|
15
|
+
static create<BSpecs extends BlockSpecs = typeof defaultBlockSpecs, ISpecs extends InlineContentSpecs = typeof defaultInlineContentSpecs, SSpecs extends StyleSpecs = typeof defaultStyleSpecs>(options?: {
|
|
16
|
+
/**
|
|
17
|
+
* A list of custom block types that should be available in the editor.
|
|
18
|
+
*/
|
|
19
|
+
blockSpecs?: BSpecs;
|
|
20
|
+
/**
|
|
21
|
+
* A list of custom InlineContent types that should be available in the editor.
|
|
22
|
+
*/
|
|
23
|
+
inlineContentSpecs?: ISpecs;
|
|
24
|
+
/**
|
|
25
|
+
* A list of custom Styles that should be available in the editor.
|
|
26
|
+
*/
|
|
27
|
+
styleSpecs?: SSpecs;
|
|
28
|
+
}): BlockNoteSchema<BlockSchemaFromSpecs<BSpecs>, InlineContentSchemaFromSpecs<ISpecs>, StyleSchemaFromSpecs<SSpecs>>;
|
|
29
|
+
constructor(opts?: {
|
|
30
|
+
blockSpecs?: BlockSpecs;
|
|
31
|
+
inlineContentSpecs?: InlineContentSpecs;
|
|
32
|
+
styleSpecs?: StyleSpecs;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EditorOptions } from "@tiptap/core";
|
|
2
|
+
import { Editor as TiptapEditor } from "@tiptap/core";
|
|
3
|
+
import { EditorState } from "prosemirror-state";
|
|
4
|
+
import { PartialBlock } from "../blocks/defaultBlocks";
|
|
5
|
+
import { StyleSchema } from "../schema";
|
|
6
|
+
export type BlockNoteTipTapEditorOptions = Partial<Omit<EditorOptions, "content">> & {
|
|
7
|
+
content: PartialBlock<any, any, any>[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Custom Editor class that extends TiptapEditor and separates
|
|
11
|
+
* the creation of the view from the constructor.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BlockNoteTipTapEditor extends TiptapEditor {
|
|
14
|
+
private _state;
|
|
15
|
+
constructor(options: BlockNoteTipTapEditorOptions, styleSchema: StyleSchema);
|
|
16
|
+
get state(): EditorState;
|
|
17
|
+
createView(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Replace the default `createView` method with a custom one - which we call on mount
|
|
20
|
+
*/
|
|
21
|
+
private createViewAlternative;
|
|
22
|
+
/**
|
|
23
|
+
* Mounts / unmounts the editor to a dom element
|
|
24
|
+
*
|
|
25
|
+
* @param element DOM element to mount to, ur null / undefined to destroy
|
|
26
|
+
*/
|
|
27
|
+
mount: (element?: HTMLElement | null) => void;
|
|
28
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Block
|
|
1
|
+
import { Block } from "../blocks/defaultBlocks";
|
|
2
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
|
|
2
3
|
export type TextCursorPosition<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
3
4
|
block: Block<BSchema, I, S>;
|
|
4
5
|
prevBlock: Block<BSchema, I, S> | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Block
|
|
1
|
+
import { Block } from "../blocks/defaultBlocks";
|
|
2
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../schema";
|
|
2
3
|
export type Selection<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = {
|
|
3
4
|
blocks: Block<BSchema, I, S>[];
|
|
4
5
|
};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
2
2
|
import { EditorView } from "prosemirror-view";
|
|
3
3
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
4
|
-
import {
|
|
4
|
+
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
5
5
|
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
6
6
|
import { EventEmitter } from "../../util/EventEmitter";
|
|
7
|
-
export type
|
|
8
|
-
export type FormattingToolbarState = BaseUiElementState;
|
|
7
|
+
export type FormattingToolbarState = UiElementPosition;
|
|
9
8
|
export declare class FormattingToolbarView {
|
|
10
9
|
private readonly editor;
|
|
11
10
|
private readonly pmView;
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
state?: FormattingToolbarState;
|
|
12
|
+
emitUpdate: () => void;
|
|
14
13
|
preventHide: boolean;
|
|
15
14
|
preventShow: boolean;
|
|
16
15
|
prevWasEditable: boolean | null;
|
|
@@ -20,7 +19,7 @@ export declare class FormattingToolbarView {
|
|
|
20
19
|
from: number;
|
|
21
20
|
to: number;
|
|
22
21
|
}) => boolean;
|
|
23
|
-
constructor(editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>, pmView: EditorView,
|
|
22
|
+
constructor(editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>, pmView: EditorView, emitUpdate: (state: FormattingToolbarState) => void);
|
|
24
23
|
viewMousedownHandler: () => void;
|
|
25
24
|
viewMouseupHandler: () => void;
|
|
26
25
|
dragHandler: () => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import { EditorView } from "prosemirror-view";
|
|
3
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
4
|
+
import type { BlockFromConfig, InlineContentSchema, StyleSchema } from "../../schema";
|
|
5
|
+
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
6
|
+
import { EventEmitter } from "../../util/EventEmitter";
|
|
7
|
+
import { DefaultBlockSchema } from "../../blocks/defaultBlocks";
|
|
8
|
+
export type ImagePanelState<I extends InlineContentSchema, S extends StyleSchema> = UiElementPosition & {
|
|
9
|
+
block: BlockFromConfig<DefaultBlockSchema["image"], I, S>;
|
|
10
|
+
};
|
|
11
|
+
export declare class ImagePanelView<I extends InlineContentSchema, S extends StyleSchema> {
|
|
12
|
+
private readonly pluginKey;
|
|
13
|
+
private readonly pmView;
|
|
14
|
+
state?: ImagePanelState<I, S>;
|
|
15
|
+
emitUpdate: () => void;
|
|
16
|
+
prevWasEditable: boolean | null;
|
|
17
|
+
constructor(pluginKey: PluginKey, pmView: EditorView, emitUpdate: (state: ImagePanelState<I, S>) => void);
|
|
18
|
+
mouseDownHandler: () => void;
|
|
19
|
+
dragstartHandler: () => void;
|
|
20
|
+
blurHandler: (event: FocusEvent) => void;
|
|
21
|
+
scrollHandler: () => void;
|
|
22
|
+
update(view: EditorView, prevState: EditorState): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class ImagePanelProsemirrorPlugin<I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
26
|
+
private view;
|
|
27
|
+
readonly plugin: Plugin;
|
|
28
|
+
constructor(_editor: BlockNoteEditor<{
|
|
29
|
+
image: DefaultBlockSchema["image"];
|
|
30
|
+
}, I, S>);
|
|
31
|
+
onUpdate(callback: (state: ImagePanelState<I, S>) => void): () => void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
5
|
+
import { EventEmitter } from "../../util/EventEmitter";
|
|
6
|
+
export type LinkToolbarState = UiElementPosition & {
|
|
7
|
+
url: string;
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const linkToolbarPluginKey: PluginKey<any>;
|
|
11
|
+
export declare class LinkToolbarProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
12
|
+
private view;
|
|
13
|
+
readonly plugin: Plugin;
|
|
14
|
+
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
15
|
+
onUpdate(callback: (state: LinkToolbarState) => void): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Edit the currently hovered link.
|
|
18
|
+
*/
|
|
19
|
+
editLink: (url: string, text: string) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Delete the currently hovered link.
|
|
22
|
+
*/
|
|
23
|
+
deleteLink: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
26
|
+
* open & close with a delay.
|
|
27
|
+
*
|
|
28
|
+
* This function starts the delay timer, and should be used for when the mouse
|
|
29
|
+
* cursor enters the link toolbar.
|
|
30
|
+
*/
|
|
31
|
+
startHideTimer: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* When hovering on/off links using the mouse cursor, the link toolbar will
|
|
34
|
+
* open & close with a delay.
|
|
35
|
+
*
|
|
36
|
+
* This function stops the delay timer, and should be used for when the mouse
|
|
37
|
+
* cursor exits the link toolbar.
|
|
38
|
+
*/
|
|
39
|
+
stopHideTimer: () => void;
|
|
40
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Node as ProsemirrorNode } from "prosemirror-model";
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
3
2
|
/**
|
|
4
3
|
* This is a modified version of the tiptap
|
|
5
4
|
* placeholder plugin, that also sets hasAnchorClass
|
|
@@ -8,18 +7,6 @@ import { Node as ProsemirrorNode } from "prosemirror-model";
|
|
|
8
7
|
*
|
|
9
8
|
*/
|
|
10
9
|
export interface PlaceholderOptions {
|
|
11
|
-
|
|
12
|
-
emptyNodeClass: string;
|
|
13
|
-
isFilterClass: string;
|
|
14
|
-
hasAnchorClass: string;
|
|
15
|
-
placeholder: ((PlaceholderProps: {
|
|
16
|
-
editor: Editor;
|
|
17
|
-
node: ProsemirrorNode;
|
|
18
|
-
pos: number;
|
|
19
|
-
hasAnchor: boolean;
|
|
20
|
-
}) => string) | string;
|
|
21
|
-
showOnlyWhenEditable: boolean;
|
|
22
|
-
showOnlyCurrent: boolean;
|
|
23
|
-
includeChildren: boolean;
|
|
10
|
+
placeholders: Record<string | "default", string>;
|
|
24
11
|
}
|
|
25
12
|
export declare const Placeholder: Extension<PlaceholderOptions, any>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { PluginView } from "@tiptap/pm/state";
|
|
2
2
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
3
|
import { EditorView } from "prosemirror-view";
|
|
4
|
+
import { Block } from "../../blocks/defaultBlocks";
|
|
4
5
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
7
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
7
8
|
import { EventEmitter } from "../../util/EventEmitter";
|
|
8
|
-
export type SideMenuState<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> =
|
|
9
|
+
export type SideMenuState<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> = UiElementPosition & {
|
|
9
10
|
block: Block<BSchema, I, S>;
|
|
10
11
|
};
|
|
11
12
|
export declare function getDraggableBlockFromCoords(coords: {
|
|
@@ -18,14 +19,14 @@ export declare function getDraggableBlockFromCoords(coords: {
|
|
|
18
19
|
export declare class SideMenuView<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> implements PluginView {
|
|
19
20
|
private readonly editor;
|
|
20
21
|
private readonly pmView;
|
|
21
|
-
private
|
|
22
|
-
private
|
|
22
|
+
private state?;
|
|
23
|
+
private readonly emitUpdate;
|
|
23
24
|
private horizontalPosAnchoredAtRoot;
|
|
24
25
|
private horizontalPosAnchor;
|
|
25
26
|
private hoveredBlock;
|
|
26
27
|
isDragging: boolean;
|
|
27
28
|
menuFrozen: boolean;
|
|
28
|
-
constructor(editor: BlockNoteEditor<BSchema, I, S>, pmView: EditorView,
|
|
29
|
+
constructor(editor: BlockNoteEditor<BSchema, I, S>, pmView: EditorView, emitUpdate: (state: SideMenuState<BSchema, I, S>) => void);
|
|
29
30
|
/**
|
|
30
31
|
* Sets isDragging when dragging text.
|
|
31
32
|
*/
|
|
@@ -52,7 +53,7 @@ export declare class SideMenuView<BSchema extends BlockSchema, I extends InlineC
|
|
|
52
53
|
export declare const sideMenuPluginKey: PluginKey<any>;
|
|
53
54
|
export declare class SideMenuProsemirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
54
55
|
private readonly editor;
|
|
55
|
-
|
|
56
|
+
view: SideMenuView<BSchema, I, S> | undefined;
|
|
56
57
|
readonly plugin: Plugin;
|
|
57
58
|
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
58
59
|
onUpdate(callback: (state: SideMenuState<BSchema, I, S>) => void): () => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
import { UiElementPosition } from "../../extensions-shared/UiElementPosition";
|
|
5
|
+
import { EventEmitter } from "../../util/EventEmitter";
|
|
6
|
+
export type SuggestionMenuState = UiElementPosition & {
|
|
7
|
+
query: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const suggestionMenuPluginKey: PluginKey<any>;
|
|
10
|
+
/**
|
|
11
|
+
* A ProseMirror plugin for suggestions, designed to make '/'-commands possible as well as mentions.
|
|
12
|
+
*
|
|
13
|
+
* This is basically a simplified version of TipTap's [Suggestions](https://github.com/ueberdosis/tiptap/tree/db92a9b313c5993b723c85cd30256f1d4a0b65e1/packages/suggestion) plugin.
|
|
14
|
+
*
|
|
15
|
+
* This version is adapted from the aforementioned version in the following ways:
|
|
16
|
+
* - This version supports generic items instead of only strings (to allow for more advanced filtering for example)
|
|
17
|
+
* - This version hides some unnecessary complexity from the user of the plugin.
|
|
18
|
+
* - This version handles key events differently
|
|
19
|
+
*/
|
|
20
|
+
export declare class SuggestionMenuProseMirrorPlugin<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<any> {
|
|
21
|
+
private view;
|
|
22
|
+
readonly plugin: Plugin;
|
|
23
|
+
private triggerCharacters;
|
|
24
|
+
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
25
|
+
onUpdate(triggerCharacter: string, callback: (state: SuggestionMenuState) => void): () => void;
|
|
26
|
+
addTriggerCharacter: (triggerCharacter: string) => void;
|
|
27
|
+
removeTriggerCharacter: (triggerCharacter: string) => void;
|
|
28
|
+
closeMenu: () => void;
|
|
29
|
+
clearQuery: () => void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createSuggestionMenu<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, triggerCharacter: string): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Block, PartialBlock } from "../../blocks/defaultBlocks";
|
|
2
|
+
import { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema";
|
|
4
|
+
import { DefaultSuggestionItem } from "./DefaultSuggestionItem";
|
|
5
|
+
export declare function insertOrUpdateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>, block: PartialBlock<BSchema, I, S>): Block<BSchema, I, S>;
|
|
6
|
+
export declare function getDefaultSlashMenuItems<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(editor: BlockNoteEditor<BSchema, I, S>): DefaultSuggestionItem[];
|
|
7
|
+
export declare function filterSuggestionItems<T extends {
|
|
8
|
+
title: string;
|
|
9
|
+
aliases?: readonly string[];
|
|
10
|
+
}>(items: T[], query: string): T[];
|