@blocknote/core 0.44.2 → 0.45.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/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -1
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -1
- package/dist/{BlockNoteSchema-BsTi0fNS.js → BlockNoteSchema-BOW16JHv.js} +2 -2
- package/dist/{BlockNoteSchema-BsTi0fNS.js.map → BlockNoteSchema-BOW16JHv.js.map} +1 -1
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs → BlockNoteSchema-CzZbr4Ed.cjs} +2 -2
- package/dist/{BlockNoteSchema-CBNkNhkw.cjs.map → BlockNoteSchema-CzZbr4Ed.cjs.map} +1 -1
- package/dist/{TrailingNode-CG2a-HDA.js → TrailingNode-8cXFaQUm.js} +484 -487
- package/dist/TrailingNode-8cXFaQUm.js.map +1 -0
- package/dist/TrailingNode-DPu6X9ym.cjs +2 -0
- package/dist/TrailingNode-DPu6X9ym.cjs.map +1 -0
- package/dist/{blockToNode-DBNbhwwC.js → blockToNode-BNoNIXU7.js} +2 -2
- package/dist/{blockToNode-DBNbhwwC.js.map → blockToNode-BNoNIXU7.js.map} +1 -1
- package/dist/{blockToNode-w7H99R6p.cjs → blockToNode-CumVjgem.cjs} +2 -2
- package/dist/{blockToNode-w7H99R6p.cjs.map → blockToNode-CumVjgem.cjs.map} +1 -1
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1118 -1077
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +2 -2
- package/dist/defaultBlocks-D1cc0lV9.cjs +6 -0
- package/dist/defaultBlocks-D1cc0lV9.cjs.map +1 -0
- package/dist/{defaultBlocks-B63ufZ5N.js → defaultBlocks-DvCGYzqu.js} +168 -206
- package/dist/defaultBlocks-DvCGYzqu.js.map +1 -0
- package/dist/extensions.cjs +1 -1
- package/dist/extensions.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.cjs +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +15 -15
- package/src/api/blockManipulation/selections/selection.ts +9 -4
- package/src/api/blockManipulation/tables/tables.test.ts +140 -0
- package/src/api/blockManipulation/tables/tables.ts +1 -1
- package/src/api/parsers/markdown/parseMarkdown.ts +11 -0
- package/src/blocks/ListItem/CheckListItem/block.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/block.ts +5 -1
- package/src/editor/BlockNoteEditor.test.ts +0 -1
- package/src/editor/BlockNoteEditor.ts +9 -39
- package/src/editor/BlockNoteExtension.ts +5 -0
- package/src/editor/managers/EventManager.ts +1 -1
- package/src/editor/managers/ExtensionManager/extensions.ts +2 -12
- package/src/editor/managers/ExtensionManager/index.ts +7 -2
- package/src/editor/managers/SelectionManager.ts +10 -10
- package/src/extensions/BlockChange/BlockChange.ts +2 -2
- package/src/extensions/Collaboration/Collaboration.ts +55 -0
- package/src/extensions/Collaboration/ForkYDoc.ts +4 -9
- package/src/extensions/Collaboration/YCursorPlugin.ts +56 -60
- package/src/extensions/Collaboration/YSync.ts +2 -2
- package/src/extensions/Collaboration/YUndo.ts +2 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +40 -68
- package/src/extensions/TableHandles/TableHandles.ts +9 -5
- package/src/index.ts +2 -1
- package/src/schema/blocks/createSpec.ts +3 -0
- package/src/util/expandToWords.ts +38 -0
- package/types/src/api/blockManipulation/selections/selection.d.ts +1 -1
- package/types/src/editor/BlockNoteEditor.d.ts +5 -34
- package/types/src/editor/BlockNoteExtension.d.ts +4 -0
- package/types/src/editor/managers/SelectionManager.d.ts +4 -4
- package/types/src/extensions/Collaboration/Collaboration.d.ts +76 -0
- package/types/src/extensions/Collaboration/ForkYDoc.d.ts +2 -11
- package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +3 -11
- package/types/src/extensions/Collaboration/YSync.d.ts +2 -4
- package/types/src/extensions/Collaboration/YUndo.d.ts +1 -1
- package/types/src/index.d.ts +2 -1
- package/types/src/util/expandToWords.d.ts +13 -0
- package/dist/TrailingNode-CG2a-HDA.js.map +0 -1
- package/dist/TrailingNode-Du4SNHun.cjs +0 -2
- package/dist/TrailingNode-Du4SNHun.cjs.map +0 -1
- package/dist/defaultBlocks-B63ufZ5N.js.map +0 -1
- package/dist/defaultBlocks-BX6UxQa8.cjs +0 -6
- package/dist/defaultBlocks-BX6UxQa8.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EditorOptions, FocusPosition, Editor as TiptapEditor } from "@tiptap/core";
|
|
2
2
|
import { type Command, type Plugin, type Transaction } from "@tiptap/pm/state";
|
|
3
3
|
import { Node, Schema } from "prosemirror-model";
|
|
4
|
-
import * as Y from "yjs";
|
|
5
4
|
import type { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
|
|
6
5
|
import { Block, BlockNoteSchema, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/index.js";
|
|
6
|
+
import type { CollaborationOptions } from "../extensions/Collaboration/Collaboration.js";
|
|
7
7
|
import type { Dictionary } from "../i18n/dictionary.js";
|
|
8
8
|
import type { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, CustomBlockNoteSchema, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema/index.js";
|
|
9
9
|
import "../style.css";
|
|
@@ -30,37 +30,8 @@ export interface BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema ext
|
|
|
30
30
|
/**
|
|
31
31
|
* When enabled, allows for collaboration between multiple users.
|
|
32
32
|
* See [Real-time Collaboration](https://www.blocknotejs.org/docs/advanced/real-time-collaboration) for more info.
|
|
33
|
-
*
|
|
34
|
-
* @remarks `CollaborationOptions`
|
|
35
33
|
*/
|
|
36
|
-
collaboration?:
|
|
37
|
-
/**
|
|
38
|
-
* The Yjs XML fragment that's used for collaboration.
|
|
39
|
-
*/
|
|
40
|
-
fragment: Y.XmlFragment;
|
|
41
|
-
/**
|
|
42
|
-
* The user info for the current user that's shown to other collaborators.
|
|
43
|
-
*/
|
|
44
|
-
user: {
|
|
45
|
-
name: string;
|
|
46
|
-
color: string;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* A Yjs provider (used for awareness / cursor information)
|
|
50
|
-
*/
|
|
51
|
-
provider: any;
|
|
52
|
-
/**
|
|
53
|
-
* Optional function to customize how cursors of users are rendered
|
|
54
|
-
*/
|
|
55
|
-
renderCursor?: (user: any) => HTMLElement;
|
|
56
|
-
/**
|
|
57
|
-
* Optional flag to set when the user label should be shown with the default
|
|
58
|
-
* collaboration cursor. Setting to "always" will always show the label,
|
|
59
|
-
* while "activity" will only show the label when the user moves the cursor
|
|
60
|
-
* or types. Defaults to "activity".
|
|
61
|
-
*/
|
|
62
|
-
showCursorLabels?: "always" | "activity";
|
|
63
|
-
};
|
|
34
|
+
collaboration?: CollaborationOptions;
|
|
64
35
|
/**
|
|
65
36
|
* Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
|
|
66
37
|
*
|
|
@@ -481,9 +452,9 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
481
452
|
* @returns A function to remove the callback.
|
|
482
453
|
*/
|
|
483
454
|
onBeforeChange(callback: (context: {
|
|
484
|
-
getChanges: () => BlocksChanged<
|
|
455
|
+
getChanges: () => BlocksChanged<BSchema, ISchema, SSchema>;
|
|
485
456
|
tr: Transaction;
|
|
486
|
-
}) => boolean | void): (
|
|
457
|
+
}) => boolean | void): () => void;
|
|
487
458
|
/**
|
|
488
459
|
* Gets a snapshot of the current text cursor position.
|
|
489
460
|
* @returns A snapshot of the current text cursor position.
|
|
@@ -510,7 +481,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
510
481
|
* If the selection starts / ends halfway through a block, the returned block will be
|
|
511
482
|
* only the part of the block that is included in the selection.
|
|
512
483
|
*/
|
|
513
|
-
getSelectionCutBlocks(): {
|
|
484
|
+
getSelectionCutBlocks(expandToWords?: boolean): {
|
|
514
485
|
blocks: Block<Record<string, import("../index.js").BlockConfig<string, import("../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
515
486
|
blockCutAtStart: string | undefined;
|
|
516
487
|
blockCutAtEnd: string | undefined;
|
|
@@ -78,6 +78,10 @@ export interface Extension<State = any, Key extends string = string> {
|
|
|
78
78
|
* Add additional tiptap extensions to the editor.
|
|
79
79
|
*/
|
|
80
80
|
readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;
|
|
81
|
+
/**
|
|
82
|
+
* Add additional BlockNote extensions to the editor.
|
|
83
|
+
*/
|
|
84
|
+
readonly blockNoteExtensions?: ReadonlyArray<ExtensionFactoryInstance>;
|
|
81
85
|
}
|
|
82
86
|
/**
|
|
83
87
|
* An input rule is what is used to replace text in a block when a regular expression match is found.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
2
1
|
import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../../blocks/defaultBlocks.js";
|
|
3
|
-
import {
|
|
4
|
-
import { TextCursorPosition } from "../cursorPositionTypes.js";
|
|
2
|
+
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
5
3
|
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
4
|
+
import { TextCursorPosition } from "../cursorPositionTypes.js";
|
|
5
|
+
import { Selection } from "../selectionTypes.js";
|
|
6
6
|
export declare class SelectionManager<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
7
7
|
private editor;
|
|
8
8
|
constructor(editor: BlockNoteEditor<BSchema, ISchema, SSchema>);
|
|
@@ -20,7 +20,7 @@ export declare class SelectionManager<BSchema extends BlockSchema = DefaultBlock
|
|
|
20
20
|
* If the selection starts / ends halfway through a block, the returned block will be
|
|
21
21
|
* only the part of the block that is included in the selection.
|
|
22
22
|
*/
|
|
23
|
-
getSelectionCutBlocks(): {
|
|
23
|
+
getSelectionCutBlocks(expandToWords?: boolean): {
|
|
24
24
|
blocks: import("../../index.js").Block<Record<string, import("../../index.js").BlockConfig<string, import("../../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
25
25
|
blockCutAtStart: string | undefined;
|
|
26
26
|
blockCutAtEnd: string | undefined;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type * as Y from "yjs";
|
|
2
|
+
import type { Awareness } from "y-protocols/awareness";
|
|
3
|
+
export type CollaborationOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* The Yjs XML fragment that's used for collaboration.
|
|
6
|
+
*/
|
|
7
|
+
fragment: Y.XmlFragment;
|
|
8
|
+
/**
|
|
9
|
+
* The user info for the current user that's shown to other collaborators.
|
|
10
|
+
*/
|
|
11
|
+
user: {
|
|
12
|
+
name: string;
|
|
13
|
+
color: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* A Yjs provider (used for awareness / cursor information)
|
|
17
|
+
*/
|
|
18
|
+
provider?: {
|
|
19
|
+
awareness?: Awareness;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Optional function to customize how cursors of users are rendered
|
|
23
|
+
*/
|
|
24
|
+
renderCursor?: (user: any) => HTMLElement;
|
|
25
|
+
/**
|
|
26
|
+
* Optional flag to set when the user label should be shown with the default
|
|
27
|
+
* collaboration cursor. Setting to "always" will always show the label,
|
|
28
|
+
* while "activity" will only show the label when the user moves the cursor
|
|
29
|
+
* or types. Defaults to "activity".
|
|
30
|
+
*/
|
|
31
|
+
showCursorLabels?: "always" | "activity";
|
|
32
|
+
};
|
|
33
|
+
export declare const CollaborationExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
|
|
34
|
+
readonly key: "collaboration";
|
|
35
|
+
readonly blockNoteExtensions: readonly [import("../../index.js").ExtensionFactoryInstance<{
|
|
36
|
+
readonly key: "yForkDoc";
|
|
37
|
+
readonly store: import("@tanstack/store").Store<{
|
|
38
|
+
isForked: boolean;
|
|
39
|
+
}, (cb: {
|
|
40
|
+
isForked: boolean;
|
|
41
|
+
}) => {
|
|
42
|
+
isForked: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
readonly fork: () => void;
|
|
45
|
+
readonly merge: ({ keepChanges }: {
|
|
46
|
+
keepChanges: boolean;
|
|
47
|
+
}) => void;
|
|
48
|
+
}>, import("../../index.js").ExtensionFactoryInstance<{
|
|
49
|
+
readonly key: "yCursor";
|
|
50
|
+
readonly prosemirrorPlugins: any[];
|
|
51
|
+
readonly dependsOn: readonly ["ySync"];
|
|
52
|
+
readonly updateUser: (user: {
|
|
53
|
+
name: string;
|
|
54
|
+
color: string;
|
|
55
|
+
[key: string]: string;
|
|
56
|
+
}) => void;
|
|
57
|
+
}>, import("../../index.js").ExtensionFactoryInstance<{
|
|
58
|
+
readonly key: "ySync";
|
|
59
|
+
readonly prosemirrorPlugins: readonly [any];
|
|
60
|
+
readonly runsBefore: readonly ["default"];
|
|
61
|
+
}>, import("../../index.js").ExtensionFactoryInstance<{
|
|
62
|
+
readonly key: "yUndo";
|
|
63
|
+
readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<{
|
|
64
|
+
undoManager: Y.UndoManager;
|
|
65
|
+
prevSel: any;
|
|
66
|
+
hasUndoOps: boolean;
|
|
67
|
+
hasRedoOps: boolean;
|
|
68
|
+
}>];
|
|
69
|
+
readonly dependsOn: readonly ["yCursor", "ySync"];
|
|
70
|
+
readonly undoCommand: import("prosemirror-state").Command;
|
|
71
|
+
readonly redoCommand: import("prosemirror-state").Command;
|
|
72
|
+
}>, import("../../index.js").ExtensionFactoryInstance<{
|
|
73
|
+
readonly key: "schemaMigration";
|
|
74
|
+
readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<any>];
|
|
75
|
+
}>];
|
|
76
|
+
}>;
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const ForkYDocExtension: (options: {
|
|
3
|
-
fragment: Y.XmlFragment;
|
|
4
|
-
user: {
|
|
5
|
-
name: string;
|
|
6
|
-
color: string;
|
|
7
|
-
};
|
|
8
|
-
provider: any;
|
|
9
|
-
renderCursor?: (user: any) => HTMLElement;
|
|
10
|
-
showCursorLabels?: "always" | "activity";
|
|
11
|
-
}) => import("../../index.js").ExtensionFactoryInstance<{
|
|
1
|
+
import { CollaborationOptions } from "./Collaboration.js";
|
|
2
|
+
export declare const ForkYDocExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
|
|
12
3
|
readonly key: "yForkDoc";
|
|
13
4
|
readonly store: import("@tanstack/store").Store<{
|
|
14
5
|
isForked: boolean;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
|
+
import { CollaborationOptions } from "./Collaboration.js";
|
|
1
2
|
export type CollaborationUser = {
|
|
2
3
|
name: string;
|
|
3
4
|
color: string;
|
|
4
5
|
[key: string]: string;
|
|
5
6
|
};
|
|
6
|
-
export declare const YCursorExtension: (options: {
|
|
7
|
-
fragment: import("yjs").XmlFragment;
|
|
8
|
-
user: {
|
|
9
|
-
name: string;
|
|
10
|
-
color: string;
|
|
11
|
-
};
|
|
12
|
-
provider: any;
|
|
13
|
-
renderCursor?: (user: any) => HTMLElement;
|
|
14
|
-
showCursorLabels?: "always" | "activity";
|
|
15
|
-
}) => import("../../index.js").ExtensionFactoryInstance<{
|
|
7
|
+
export declare const YCursorExtension: (options: CollaborationOptions) => import("../../index.js").ExtensionFactoryInstance<{
|
|
16
8
|
readonly key: "yCursor";
|
|
17
|
-
readonly prosemirrorPlugins:
|
|
9
|
+
readonly prosemirrorPlugins: any[];
|
|
18
10
|
readonly dependsOn: readonly ["ySync"];
|
|
19
11
|
readonly updateUser: (user: {
|
|
20
12
|
name: string;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const YSyncExtension: (options: {
|
|
3
|
-
fragment: XmlFragment;
|
|
4
|
-
}) => import("../../index.js").ExtensionFactoryInstance<{
|
|
1
|
+
import { CollaborationOptions } from "./Collaboration.js";
|
|
2
|
+
export declare const YSyncExtension: (options: Pick<CollaborationOptions, "fragment">) => import("../../index.js").ExtensionFactoryInstance<{
|
|
5
3
|
readonly key: "ySync";
|
|
6
4
|
readonly prosemirrorPlugins: readonly [any];
|
|
7
5
|
readonly runsBefore: readonly ["default"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const YUndoExtension: (
|
|
1
|
+
export declare const YUndoExtension: () => import("../../index.js").ExtensionFactoryInstance<{
|
|
2
2
|
readonly key: "yUndo";
|
|
3
3
|
readonly prosemirrorPlugins: readonly [import("prosemirror-state").Plugin<{
|
|
4
4
|
undoManager: import("yjs").UndoManager;
|
package/types/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./api/blockManipulation/commands/insertBlocks/insertBlocks.js";
|
|
2
2
|
export * from "./api/blockManipulation/commands/replaceBlocks/replaceBlocks.js";
|
|
3
|
-
export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
4
3
|
export * from "./api/blockManipulation/commands/replaceBlocks/util/fixColumnList.js";
|
|
4
|
+
export * from "./api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
5
5
|
export * from "./api/exporters/html/externalHTMLExporter.js";
|
|
6
6
|
export * from "./api/exporters/html/internalHTMLSerializer.js";
|
|
7
7
|
export * from "./api/getBlockInfoFromPos.js";
|
|
@@ -19,6 +19,7 @@ export * from "./i18n/dictionary.js";
|
|
|
19
19
|
export * from "./schema/index.js";
|
|
20
20
|
export * from "./util/browser.js";
|
|
21
21
|
export * from "./util/combineByGroup.js";
|
|
22
|
+
export * from "./util/expandToWords.js";
|
|
22
23
|
export * from "./util/string.js";
|
|
23
24
|
export * from "./util/table.js";
|
|
24
25
|
export * from "./util/typescript.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Node, ResolvedPos } from "prosemirror-model";
|
|
2
|
+
/**
|
|
3
|
+
* Expands a range (start to end) to include the rest of the word if it starts or ends within a word
|
|
4
|
+
*/
|
|
5
|
+
export declare function expandPMRangeToWords(doc: Node, range: {
|
|
6
|
+
$from: ResolvedPos;
|
|
7
|
+
$to: ResolvedPos;
|
|
8
|
+
}): {
|
|
9
|
+
$from: ResolvedPos;
|
|
10
|
+
$to: ResolvedPos;
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
};
|