@blocknote/core 0.8.5 → 0.9.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 +614 -520
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +4 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +11 -15
- package/src/BlockNoteExtensions.ts +18 -5
- package/src/editor.module.css +0 -11
- package/src/extensions/Blocks/api/block.ts +55 -22
- package/src/extensions/Blocks/api/blockTypes.ts +22 -3
- package/src/extensions/Blocks/index.ts +7 -12
- package/src/extensions/Blocks/nodes/Block.module.css +1 -1
- package/src/extensions/Blocks/nodes/BlockContainer.ts +19 -18
- package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +20 -2
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +20 -2
- package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +20 -2
- package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +29 -6
- package/src/extensions/Blocks/nodes/BlockGroup.ts +19 -11
- package/src/index.ts +1 -0
- package/src/shared/utils.ts +4 -0
- package/types/src/BlockNoteEditor.d.ts +4 -10
- package/types/src/BlockNoteExtensions.d.ts +2 -0
- package/types/src/extensions/Blocks/api/block.d.ts +6 -1
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +15 -3
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +36 -4
- package/types/src/extensions/Blocks/index.d.ts +4 -1
- package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +9 -4
- package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +9 -1
- package/types/src/extensions/Blocks/nodes/BlockGroup.d.ts +9 -1
- package/types/src/index.d.ts +1 -0
- package/types/src/shared/utils.d.ts +1 -0
- package/src/node_modules/.vitest/results.json +0 -1
package/src/index.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { getDefaultSlashMenuItems } from "./extensions/SlashMenu/defaultSlashMen
|
|
|
15
15
|
export * from "./shared/BaseUiElementTypes";
|
|
16
16
|
export type { SuggestionItem } from "./shared/plugins/suggestion/SuggestionItem";
|
|
17
17
|
export * from "./shared/plugins/suggestion/SuggestionPlugin";
|
|
18
|
+
export * from "./shared/utils";
|
package/src/shared/utils.ts
CHANGED
|
@@ -11,6 +11,10 @@ export function formatKeyboardShortcut(shortcut: string) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export function mergeCSSClasses(...classes: string[]) {
|
|
15
|
+
return classes.filter((c) => c).join(" ");
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
export class UnreachableCaseError extends Error {
|
|
15
19
|
constructor(val: never) {
|
|
16
20
|
super(`Unreachable case: ${val}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Node } from "prosemirror-model";
|
|
2
2
|
import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
|
|
3
3
|
import * as Y from "yjs";
|
|
4
|
-
import { Block, BlockIdentifier, BlockSchema, PartialBlock } from "./extensions/Blocks/api/blockTypes";
|
|
4
|
+
import { Block, BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, PartialBlock } from "./extensions/Blocks/api/blockTypes";
|
|
5
5
|
import { TextCursorPosition } from "./extensions/Blocks/api/cursorPositionTypes";
|
|
6
6
|
import { DefaultBlockSchema } from "./extensions/Blocks/api/defaultBlocks";
|
|
7
7
|
import { Styles } from "./extensions/Blocks/api/inlineContentTypes";
|
|
@@ -27,11 +27,11 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
|
|
|
27
27
|
*/
|
|
28
28
|
parentElement: HTMLElement;
|
|
29
29
|
/**
|
|
30
|
-
* An object containing attributes that should be added to the editor
|
|
30
|
+
* An object containing attributes that should be added to HTML elements of the editor.
|
|
31
31
|
*
|
|
32
|
-
* @example { class: "my-editor-class" }
|
|
32
|
+
* @example { editor: { class: "my-editor-class" } }
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
35
35
|
/**
|
|
36
36
|
* A callback function that runs when the editor is ready to be used.
|
|
37
37
|
*/
|
|
@@ -58,12 +58,6 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema> = {
|
|
|
58
58
|
* @default true
|
|
59
59
|
*/
|
|
60
60
|
defaultStyles: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Whether to use the light or dark theme.
|
|
63
|
-
*
|
|
64
|
-
* @default "light"
|
|
65
|
-
*/
|
|
66
|
-
theme: "light" | "dark";
|
|
67
61
|
/**
|
|
68
62
|
* A list of block types that should be available in the editor.
|
|
69
63
|
*/
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Extensions } from "@tiptap/core";
|
|
2
2
|
import { BlockNoteEditor } from "./BlockNoteEditor";
|
|
3
3
|
import * as Y from "yjs";
|
|
4
|
+
import { BlockNoteDOMAttributes } from "./extensions/Blocks/api/blockTypes";
|
|
4
5
|
/**
|
|
5
6
|
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
6
7
|
*/
|
|
7
8
|
export declare const getBlockNoteExtensions: <BSchema extends Record<string, import("./extensions/Blocks/api/blockTypes").BlockSpec<string, import("./extensions/Blocks/api/blockTypes").PropSchema>>>(opts: {
|
|
8
9
|
editor: BlockNoteEditor<BSchema>;
|
|
10
|
+
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
9
11
|
blockSchema: BSchema;
|
|
10
12
|
collaboration?: {
|
|
11
13
|
fragment: Y.XmlFragment;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Attribute } from "@tiptap/core";
|
|
2
|
+
import { BlockNoteDOMAttributes } from "../../..";
|
|
2
3
|
import { BlockConfig, BlockSchema, BlockSpec, PropSchema, TipTapNode, TipTapNodeConfig } from "./blockTypes";
|
|
3
4
|
export declare function camelToDataKebab(str: string): string;
|
|
4
5
|
export declare function propsToAttributes<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">): Record<string, Attribute>;
|
|
@@ -13,4 +14,8 @@ export declare function render<BType extends string, PSchema extends PropSchema,
|
|
|
13
14
|
contentDOM?: undefined;
|
|
14
15
|
};
|
|
15
16
|
export declare function createBlockSpec<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>): BlockSpec<BType, PSchema>;
|
|
16
|
-
export declare function createTipTapBlock<Type extends string
|
|
17
|
+
export declare function createTipTapBlock<Type extends string, Options extends {
|
|
18
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
19
|
+
} = {
|
|
20
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
21
|
+
}, Storage = any>(config: TipTapNodeConfig<Type, Options, Storage>): TipTapNode<Type, Options, Storage>;
|
|
@@ -3,10 +3,22 @@ import { Node, NodeConfig } from "@tiptap/core";
|
|
|
3
3
|
import { BlockNoteEditor } from "../../../BlockNoteEditor";
|
|
4
4
|
import { InlineContent, PartialInlineContent } from "./inlineContentTypes";
|
|
5
5
|
import { DefaultBlockSchema } from "./defaultBlocks";
|
|
6
|
-
export type
|
|
6
|
+
export type BlockNoteDOMElement = "editor" | "blockContainer" | "blockGroup" | "blockContent" | "inlineContent";
|
|
7
|
+
export type BlockNoteDOMAttributes = Partial<{
|
|
8
|
+
[DOMElement in BlockNoteDOMElement]: Record<string, string>;
|
|
9
|
+
}>;
|
|
10
|
+
export type TipTapNodeConfig<Name extends string, Options extends {
|
|
11
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
12
|
+
} = {
|
|
13
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
14
|
+
}, Storage = any> = {
|
|
7
15
|
[K in keyof NodeConfig<Options, Storage>]: K extends "name" ? Name : K extends "group" ? never : NodeConfig<Options, Storage>[K];
|
|
8
16
|
};
|
|
9
|
-
export type TipTapNode<Name extends string, Options
|
|
17
|
+
export type TipTapNode<Name extends string, Options extends {
|
|
18
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
19
|
+
} = {
|
|
20
|
+
domAttributes?: BlockNoteDOMAttributes;
|
|
21
|
+
}, Storage = any> = Node<Options, Storage> & {
|
|
10
22
|
name: Name;
|
|
11
23
|
group: "blockContent";
|
|
12
24
|
};
|
|
@@ -45,7 +57,7 @@ export type BlockConfig<Type extends string, PSchema extends PropSchema, Contain
|
|
|
45
57
|
};
|
|
46
58
|
export type BlockSpec<Type extends string, PSchema extends PropSchema> = {
|
|
47
59
|
readonly propSchema: PSchema;
|
|
48
|
-
node: TipTapNode<Type>;
|
|
60
|
+
node: TipTapNode<Type, any>;
|
|
49
61
|
};
|
|
50
62
|
export type TypesMatch<Blocks extends Record<string, BlockSpec<string, PropSchema>>> = Blocks extends {
|
|
51
63
|
[Type in keyof Blocks]: Type extends string ? Blocks[Type] extends BlockSpec<Type, PropSchema> ? Blocks[Type] : never : never;
|
|
@@ -26,7 +26,15 @@ export declare const defaultBlockSchema: {
|
|
|
26
26
|
values: readonly ["left", "center", "right", "justify"];
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
readonly node: import("./blockTypes").TipTapNode<"paragraph"
|
|
29
|
+
readonly node: import("./blockTypes").TipTapNode<"paragraph", {
|
|
30
|
+
domAttributes?: Partial<{
|
|
31
|
+
blockContainer: Record<string, string>;
|
|
32
|
+
blockGroup: Record<string, string>;
|
|
33
|
+
editor: Record<string, string>;
|
|
34
|
+
blockContent: Record<string, string>;
|
|
35
|
+
inlineContent: Record<string, string>;
|
|
36
|
+
}> | undefined;
|
|
37
|
+
}, any>;
|
|
30
38
|
};
|
|
31
39
|
readonly heading: {
|
|
32
40
|
readonly propSchema: {
|
|
@@ -45,7 +53,15 @@ export declare const defaultBlockSchema: {
|
|
|
45
53
|
values: readonly ["left", "center", "right", "justify"];
|
|
46
54
|
};
|
|
47
55
|
};
|
|
48
|
-
readonly node: import("./blockTypes").TipTapNode<"heading"
|
|
56
|
+
readonly node: import("./blockTypes").TipTapNode<"heading", {
|
|
57
|
+
domAttributes?: Partial<{
|
|
58
|
+
blockContainer: Record<string, string>;
|
|
59
|
+
blockGroup: Record<string, string>;
|
|
60
|
+
editor: Record<string, string>;
|
|
61
|
+
blockContent: Record<string, string>;
|
|
62
|
+
inlineContent: Record<string, string>;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
}, any>;
|
|
49
65
|
};
|
|
50
66
|
readonly bulletListItem: {
|
|
51
67
|
readonly propSchema: {
|
|
@@ -60,7 +76,15 @@ export declare const defaultBlockSchema: {
|
|
|
60
76
|
values: readonly ["left", "center", "right", "justify"];
|
|
61
77
|
};
|
|
62
78
|
};
|
|
63
|
-
readonly node: import("./blockTypes").TipTapNode<"bulletListItem"
|
|
79
|
+
readonly node: import("./blockTypes").TipTapNode<"bulletListItem", {
|
|
80
|
+
domAttributes?: Partial<{
|
|
81
|
+
blockContainer: Record<string, string>;
|
|
82
|
+
blockGroup: Record<string, string>;
|
|
83
|
+
editor: Record<string, string>;
|
|
84
|
+
blockContent: Record<string, string>;
|
|
85
|
+
inlineContent: Record<string, string>;
|
|
86
|
+
}> | undefined;
|
|
87
|
+
}, any>;
|
|
64
88
|
};
|
|
65
89
|
readonly numberedListItem: {
|
|
66
90
|
readonly propSchema: {
|
|
@@ -75,7 +99,15 @@ export declare const defaultBlockSchema: {
|
|
|
75
99
|
values: readonly ["left", "center", "right", "justify"];
|
|
76
100
|
};
|
|
77
101
|
};
|
|
78
|
-
readonly node: import("./blockTypes").TipTapNode<"numberedListItem"
|
|
102
|
+
readonly node: import("./blockTypes").TipTapNode<"numberedListItem", {
|
|
103
|
+
domAttributes?: Partial<{
|
|
104
|
+
blockContainer: Record<string, string>;
|
|
105
|
+
blockGroup: Record<string, string>;
|
|
106
|
+
editor: Record<string, string>;
|
|
107
|
+
blockContent: Record<string, string>;
|
|
108
|
+
inlineContent: Record<string, string>;
|
|
109
|
+
}> | undefined;
|
|
110
|
+
}, any>;
|
|
79
111
|
};
|
|
80
112
|
};
|
|
81
113
|
export type DefaultBlockSchema = TypesMatch<typeof defaultBlockSchema>;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
2
|
import { BlockSchema, PartialBlock } from "../api/blockTypes";
|
|
3
|
-
export interface IBlock {
|
|
4
|
-
HTMLAttributes: Record<string, any>;
|
|
5
|
-
}
|
|
6
3
|
declare module "@tiptap/core" {
|
|
7
4
|
interface Commands<ReturnType> {
|
|
8
5
|
block: {
|
|
@@ -18,4 +15,12 @@ declare module "@tiptap/core" {
|
|
|
18
15
|
/**
|
|
19
16
|
* The main "Block node" documents consist of
|
|
20
17
|
*/
|
|
21
|
-
export declare const BlockContainer: Node<
|
|
18
|
+
export declare const BlockContainer: Node<{
|
|
19
|
+
domAttributes?: Partial<{
|
|
20
|
+
blockContainer: Record<string, string>;
|
|
21
|
+
blockGroup: Record<string, string>;
|
|
22
|
+
editor: Record<string, string>;
|
|
23
|
+
blockContent: Record<string, string>;
|
|
24
|
+
inlineContent: Record<string, string>;
|
|
25
|
+
}> | undefined;
|
|
26
|
+
}, any>;
|
package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export declare const HeadingBlockContent: import("../../../api/blockTypes").TipTapNode<"heading"
|
|
1
|
+
export declare const HeadingBlockContent: import("../../../api/blockTypes").TipTapNode<"heading", {
|
|
2
|
+
domAttributes?: Partial<{
|
|
3
|
+
blockContainer: Record<string, string>;
|
|
4
|
+
blockGroup: Record<string, string>;
|
|
5
|
+
editor: Record<string, string>;
|
|
6
|
+
blockContent: Record<string, string>;
|
|
7
|
+
inlineContent: Record<string, string>;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
}, any>;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export declare const BulletListItemBlockContent: import("../../../../api/blockTypes").TipTapNode<"bulletListItem"
|
|
1
|
+
export declare const BulletListItemBlockContent: import("../../../../api/blockTypes").TipTapNode<"bulletListItem", {
|
|
2
|
+
domAttributes?: Partial<{
|
|
3
|
+
blockContainer: Record<string, string>;
|
|
4
|
+
blockGroup: Record<string, string>;
|
|
5
|
+
editor: Record<string, string>;
|
|
6
|
+
blockContent: Record<string, string>;
|
|
7
|
+
inlineContent: Record<string, string>;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
}, any>;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export declare const NumberedListItemBlockContent: import("../../../../api/blockTypes").TipTapNode<"numberedListItem"
|
|
1
|
+
export declare const NumberedListItemBlockContent: import("../../../../api/blockTypes").TipTapNode<"numberedListItem", {
|
|
2
|
+
domAttributes?: Partial<{
|
|
3
|
+
blockContainer: Record<string, string>;
|
|
4
|
+
blockGroup: Record<string, string>;
|
|
5
|
+
editor: Record<string, string>;
|
|
6
|
+
blockContent: Record<string, string>;
|
|
7
|
+
inlineContent: Record<string, string>;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
}, any>;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export declare const ParagraphBlockContent: import("../../../api/blockTypes").TipTapNode<"paragraph"
|
|
1
|
+
export declare const ParagraphBlockContent: import("../../../api/blockTypes").TipTapNode<"paragraph", {
|
|
2
|
+
domAttributes?: Partial<{
|
|
3
|
+
blockContainer: Record<string, string>;
|
|
4
|
+
blockGroup: Record<string, string>;
|
|
5
|
+
editor: Record<string, string>;
|
|
6
|
+
blockContent: Record<string, string>;
|
|
7
|
+
inlineContent: Record<string, string>;
|
|
8
|
+
}> | undefined;
|
|
9
|
+
}, any>;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
|
-
export declare const BlockGroup: Node<
|
|
2
|
+
export declare const BlockGroup: Node<{
|
|
3
|
+
domAttributes?: Partial<{
|
|
4
|
+
blockContainer: Record<string, string>;
|
|
5
|
+
blockGroup: Record<string, string>;
|
|
6
|
+
editor: Record<string, string>;
|
|
7
|
+
blockContent: Record<string, string>;
|
|
8
|
+
inlineContent: Record<string, string>;
|
|
9
|
+
}> | undefined;
|
|
10
|
+
}, any>;
|
package/types/src/index.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export { getDefaultSlashMenuItems } from "./extensions/SlashMenu/defaultSlashMen
|
|
|
15
15
|
export * from "./shared/BaseUiElementTypes";
|
|
16
16
|
export type { SuggestionItem } from "./shared/plugins/suggestion/SuggestionItem";
|
|
17
17
|
export * from "./shared/plugins/suggestion/SuggestionPlugin";
|
|
18
|
+
export * from "./shared/utils";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const isAppleOS: () => boolean;
|
|
2
2
|
export declare function formatKeyboardShortcut(shortcut: string): string;
|
|
3
|
+
export declare function mergeCSSClasses(...classes: string[]): string;
|
|
3
4
|
export declare class UnreachableCaseError extends Error {
|
|
4
5
|
constructor(val: never);
|
|
5
6
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"0.28.5","results":[["/api/formatConversions/formatConversions.test.ts",{"duration":109,"failed":false}],["/api/nodeConversions/nodeConversions.test.ts",{"duration":32,"failed":false}],["/api/blockManipulation/blockManipulation.test.ts",{"duration":38,"failed":false}],["/BlockNoteEditor.test.ts",{"duration":4,"failed":false}]]}
|