@blocknote/core 0.39.0 → 0.39.1-capitol-test
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-DmZ6UQfY.cjs → BlockNoteSchema-Bsa_tSAC.cjs} +8 -8
- package/dist/BlockNoteSchema-Bsa_tSAC.cjs.map +1 -0
- package/dist/{BlockNoteSchema-oR047ACf.js → BlockNoteSchema-CZez1nQf.js} +586 -617
- package/dist/BlockNoteSchema-CZez1nQf.js.map +1 -0
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +1172 -1185
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +1 -2
- package/src/api/clipboard/fromClipboard/handleFileInsertion.ts +2 -2
- package/src/api/clipboard/fromClipboard/pasteExtension.ts +1 -1
- package/src/blocks/Code/block.ts +1 -5
- package/src/editor/BlockNoteEditor.ts +23 -19
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +6 -6
- package/src/extensions/SideMenu/SideMenuPlugin.ts +1 -3
- package/src/extensions/SideMenu/dragging.ts +2 -2
- package/src/extensions/SuggestionMenu/SuggestionPlugin.ts +4 -2
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +6 -6
- 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/blocks/Divider/block.d.ts +3 -0
- package/types/src/editor/BlockNoteEditor.d.ts +3 -1
- 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/dist/BlockNoteSchema-DmZ6UQfY.cjs.map +0 -1
- package/dist/BlockNoteSchema-oR047ACf.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/blocks/Code/shiki.ts +0 -73
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { CommentsPlugin } from "../../extensions/Comments/CommentsPlugin.js";
|
|
3
|
+
import { ForkYDocPlugin } from "../../extensions/Collaboration/ForkYDocPlugin.js";
|
|
4
|
+
import { SyncPlugin } from "../../extensions/Collaboration/SyncPlugin.js";
|
|
5
|
+
import { UndoPlugin } from "../../extensions/Collaboration/UndoPlugin.js";
|
|
6
|
+
import { CursorPlugin } from "../../extensions/Collaboration/CursorPlugin.js";
|
|
7
|
+
import type { ThreadStore, User } from "../../comments/index.js";
|
|
8
|
+
import type { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
9
|
+
import { CustomBlockNoteSchema } from "../../schema/schema.js";
|
|
10
|
+
export interface CollaborationOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The Yjs XML fragment that's used for collaboration.
|
|
13
|
+
*/
|
|
14
|
+
fragment: Y.XmlFragment;
|
|
15
|
+
/**
|
|
16
|
+
* The user info for the current user that's shown to other collaborators.
|
|
17
|
+
*/
|
|
18
|
+
user: {
|
|
19
|
+
name: string;
|
|
20
|
+
color: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A Yjs provider (used for awareness / cursor information)
|
|
24
|
+
* Can be null for comments-only mode
|
|
25
|
+
*/
|
|
26
|
+
provider: any;
|
|
27
|
+
/**
|
|
28
|
+
* Optional function to customize how cursors of users are rendered
|
|
29
|
+
*/
|
|
30
|
+
renderCursor?: (user: any) => HTMLElement;
|
|
31
|
+
/**
|
|
32
|
+
* Optional flag to set when the user label should be shown with the default
|
|
33
|
+
* collaboration cursor. Setting to "always" will always show the label,
|
|
34
|
+
* while "activity" will only show the label when the user moves the cursor
|
|
35
|
+
* or types. Defaults to "activity".
|
|
36
|
+
*/
|
|
37
|
+
showCursorLabels?: "always" | "activity";
|
|
38
|
+
/**
|
|
39
|
+
* Comments configuration - can be used with or without collaboration
|
|
40
|
+
*/
|
|
41
|
+
comments?: {
|
|
42
|
+
schema?: CustomBlockNoteSchema<any, any, any>;
|
|
43
|
+
threadStore: ThreadStore;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Function to resolve user IDs to user objects - required for comments
|
|
47
|
+
*/
|
|
48
|
+
resolveUsers?: (userIds: string[]) => Promise<User[]>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* CollaborationManager handles all collaboration-related functionality
|
|
52
|
+
* This manager is completely optional and can be tree-shaken if not used
|
|
53
|
+
*/
|
|
54
|
+
export declare class CollaborationManager {
|
|
55
|
+
private editor;
|
|
56
|
+
private options;
|
|
57
|
+
private _commentsPlugin?;
|
|
58
|
+
private _forkYDocPlugin?;
|
|
59
|
+
private _syncPlugin?;
|
|
60
|
+
private _undoPlugin?;
|
|
61
|
+
private _cursorPlugin?;
|
|
62
|
+
constructor(editor: BlockNoteEditor, options: CollaborationOptions);
|
|
63
|
+
/**
|
|
64
|
+
* Get the sync plugin instance
|
|
65
|
+
*/
|
|
66
|
+
get syncPlugin(): SyncPlugin | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Get the undo plugin instance
|
|
69
|
+
*/
|
|
70
|
+
get undoPlugin(): UndoPlugin | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Get the cursor plugin instance
|
|
73
|
+
*/
|
|
74
|
+
get cursorPlugin(): CursorPlugin | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Get the fork YDoc plugin instance
|
|
77
|
+
*/
|
|
78
|
+
get forkYDocPlugin(): ForkYDocPlugin | undefined;
|
|
79
|
+
initExtensions(): Record<string, unknown>;
|
|
80
|
+
/**
|
|
81
|
+
* Update the user info for the current user that's shown to other collaborators
|
|
82
|
+
*/
|
|
83
|
+
updateUserInfo(user: {
|
|
84
|
+
name: string;
|
|
85
|
+
color: string;
|
|
86
|
+
}): void;
|
|
87
|
+
/**
|
|
88
|
+
* Get the collaboration undo command
|
|
89
|
+
*/
|
|
90
|
+
getUndoCommand(): import("prosemirror-state").Command;
|
|
91
|
+
/**
|
|
92
|
+
* Get the collaboration redo command
|
|
93
|
+
*/
|
|
94
|
+
getRedoCommand(): import("prosemirror-state").Command;
|
|
95
|
+
/**
|
|
96
|
+
* Check if initial content should be avoided due to collaboration
|
|
97
|
+
*/
|
|
98
|
+
shouldAvoidInitialContent(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Get the collaboration options
|
|
101
|
+
*/
|
|
102
|
+
getOptions(): CollaborationOptions;
|
|
103
|
+
/**
|
|
104
|
+
* Get the comments plugin if available
|
|
105
|
+
*/
|
|
106
|
+
get comments(): CommentsPlugin | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Check if comments are enabled
|
|
109
|
+
*/
|
|
110
|
+
get hasComments(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Get the resolveUsers function
|
|
113
|
+
*/
|
|
114
|
+
get resolveUsers(): ((userIds: string[]) => Promise<User[]>) | undefined;
|
|
115
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
2
|
+
import { type BlocksChanged } from "../../api/getBlocksChangedByTransaction.js";
|
|
3
|
+
import { Transaction } from "prosemirror-state";
|
|
4
|
+
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
5
|
+
/**
|
|
6
|
+
* A function that can be used to unsubscribe from an event.
|
|
7
|
+
*/
|
|
8
|
+
export type Unsubscribe = () => void;
|
|
9
|
+
/**
|
|
10
|
+
* EventManager is a class which manages the events of the editor
|
|
11
|
+
*/
|
|
12
|
+
export declare class EventManager<Editor extends BlockNoteEditor> extends EventEmitter<{
|
|
13
|
+
onChange: [
|
|
14
|
+
editor: Editor,
|
|
15
|
+
ctx: {
|
|
16
|
+
getChanges(): BlocksChanged<Editor["schema"]["blockSchema"], Editor["schema"]["inlineContentSchema"], Editor["schema"]["styleSchema"]>;
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
onSelectionChange: [ctx: {
|
|
20
|
+
editor: Editor;
|
|
21
|
+
transaction: Transaction;
|
|
22
|
+
}];
|
|
23
|
+
onMount: [ctx: {
|
|
24
|
+
editor: Editor;
|
|
25
|
+
}];
|
|
26
|
+
onUnmount: [ctx: {
|
|
27
|
+
editor: Editor;
|
|
28
|
+
}];
|
|
29
|
+
}> {
|
|
30
|
+
private editor;
|
|
31
|
+
constructor(editor: Editor);
|
|
32
|
+
/**
|
|
33
|
+
* Register a callback that will be called when the editor changes.
|
|
34
|
+
*/
|
|
35
|
+
onChange(callback: (editor: Editor, ctx: {
|
|
36
|
+
getChanges(): BlocksChanged<Editor["schema"]["blockSchema"], Editor["schema"]["inlineContentSchema"], Editor["schema"]["styleSchema"]>;
|
|
37
|
+
}) => void): Unsubscribe;
|
|
38
|
+
/**
|
|
39
|
+
* Register a callback that will be called when the selection changes.
|
|
40
|
+
*/
|
|
41
|
+
onSelectionChange(callback: (editor: Editor) => void,
|
|
42
|
+
/**
|
|
43
|
+
* If true, the callback will be triggered when the selection changes due to a yjs sync (i.e.: other user was typing)
|
|
44
|
+
*/
|
|
45
|
+
includeSelectionChangedByRemote?: boolean): Unsubscribe;
|
|
46
|
+
/**
|
|
47
|
+
* Register a callback that will be called when the editor is mounted.
|
|
48
|
+
*/
|
|
49
|
+
onMount(callback: (ctx: {
|
|
50
|
+
editor: Editor;
|
|
51
|
+
}) => void): Unsubscribe;
|
|
52
|
+
/**
|
|
53
|
+
* Register a callback that will be called when the editor is unmounted.
|
|
54
|
+
*/
|
|
55
|
+
onUnmount(callback: (ctx: {
|
|
56
|
+
editor: Editor;
|
|
57
|
+
}) => void): Unsubscribe;
|
|
58
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Block, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../../blocks/defaultBlocks.js";
|
|
2
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
3
|
+
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
4
|
+
export declare class ExportManager<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
5
|
+
private editor;
|
|
6
|
+
constructor(editor: BlockNoteEditor<BSchema, ISchema, SSchema>);
|
|
7
|
+
/**
|
|
8
|
+
* Exports blocks into a simplified HTML string. To better conform to HTML standards, children of blocks which aren't list
|
|
9
|
+
* items are un-nested in the output HTML.
|
|
10
|
+
*
|
|
11
|
+
* @param blocks An array of blocks that should be serialized into HTML.
|
|
12
|
+
* @returns The blocks, serialized as an HTML string.
|
|
13
|
+
*/
|
|
14
|
+
blocksToHTMLLossy(blocks?: PartialBlock<BSchema, ISchema, SSchema>[]): string;
|
|
15
|
+
/**
|
|
16
|
+
* Serializes blocks into an HTML string in the format that would normally be rendered by the editor.
|
|
17
|
+
*
|
|
18
|
+
* Use this method if you want to server-side render HTML (for example, a blog post that has been edited in BlockNote)
|
|
19
|
+
* and serve it to users without loading the editor on the client (i.e.: displaying the blog post)
|
|
20
|
+
*
|
|
21
|
+
* @param blocks An array of blocks that should be serialized into HTML.
|
|
22
|
+
* @returns The blocks, serialized as an HTML string.
|
|
23
|
+
*/
|
|
24
|
+
blocksToFullHTML(blocks: PartialBlock<BSchema, ISchema, SSchema>[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
|
|
27
|
+
* `InlineNode` objects from any HTML inline elements, though not all element types are recognized. If BlockNote
|
|
28
|
+
* doesn't recognize an HTML element's tag, it will parse it as a paragraph or plain text.
|
|
29
|
+
* @param html The HTML string to parse blocks from.
|
|
30
|
+
* @returns The blocks parsed from the HTML string.
|
|
31
|
+
*/
|
|
32
|
+
tryParseHTMLToBlocks(html: string): Block<BSchema, ISchema, SSchema>[];
|
|
33
|
+
/**
|
|
34
|
+
* Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
|
|
35
|
+
* BlockNote - children of blocks which aren't list items are un-nested and certain styles are removed.
|
|
36
|
+
* @param blocks An array of blocks that should be serialized into Markdown.
|
|
37
|
+
* @returns The blocks, serialized as a Markdown string.
|
|
38
|
+
*/
|
|
39
|
+
blocksToMarkdownLossy(blocks?: PartialBlock<BSchema, ISchema, SSchema>[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
|
|
42
|
+
* Markdown syntax, though not all symbols are recognized. If BlockNote doesn't recognize a symbol, it will parse it
|
|
43
|
+
* as text.
|
|
44
|
+
* @param markdown The Markdown string to parse blocks from.
|
|
45
|
+
* @returns The blocks parsed from the Markdown string.
|
|
46
|
+
*/
|
|
47
|
+
tryParseMarkdownToBlocks(markdown: string): Block<BSchema, ISchema, SSchema>[];
|
|
48
|
+
/**
|
|
49
|
+
* Paste HTML into the editor. Defaults to converting HTML to BlockNote HTML.
|
|
50
|
+
* @param html The HTML to paste.
|
|
51
|
+
* @param raw Whether to paste the HTML as is, or to convert it to BlockNote HTML.
|
|
52
|
+
*/
|
|
53
|
+
pasteHTML(html: string, raw?: boolean): void;
|
|
54
|
+
/**
|
|
55
|
+
* Paste text into the editor. Defaults to interpreting text as markdown.
|
|
56
|
+
* @param text The text to paste.
|
|
57
|
+
*/
|
|
58
|
+
pasteText(text: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Paste markdown into the editor.
|
|
61
|
+
* @param markdown The markdown to paste.
|
|
62
|
+
*/
|
|
63
|
+
pasteMarkdown(markdown: string): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { FilePanelProsemirrorPlugin } from "../../extensions/FilePanel/FilePanelPlugin.js";
|
|
2
|
+
import { FormattingToolbarProsemirrorPlugin } from "../../extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
3
|
+
import { LinkToolbarProsemirrorPlugin } from "../../extensions/LinkToolbar/LinkToolbarPlugin.js";
|
|
4
|
+
import { ShowSelectionPlugin } from "../../extensions/ShowSelection/ShowSelectionPlugin.js";
|
|
5
|
+
import { SideMenuProsemirrorPlugin } from "../../extensions/SideMenu/SideMenuPlugin.js";
|
|
6
|
+
import { SuggestionMenuProseMirrorPlugin } from "../../extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
7
|
+
import { TableHandlesProsemirrorPlugin } from "../../extensions/TableHandles/TableHandlesPlugin.js";
|
|
8
|
+
import { BlockNoteExtension } from "../BlockNoteExtension.js";
|
|
9
|
+
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
10
|
+
export declare class ExtensionManager {
|
|
11
|
+
private editor;
|
|
12
|
+
constructor(editor: BlockNoteEditor);
|
|
13
|
+
/**
|
|
14
|
+
* Shorthand to get a typed extension from the editor, by
|
|
15
|
+
* just passing in the extension class.
|
|
16
|
+
*
|
|
17
|
+
* @param ext - The extension class to get
|
|
18
|
+
* @param key - optional, the key of the extension in the extensions object (defaults to the extension name)
|
|
19
|
+
* @returns The extension instance
|
|
20
|
+
*/
|
|
21
|
+
extension<T extends BlockNoteExtension>(ext: {
|
|
22
|
+
new (...args: any[]): T;
|
|
23
|
+
} & typeof BlockNoteExtension, key?: string): T;
|
|
24
|
+
/**
|
|
25
|
+
* Get all extensions
|
|
26
|
+
*/
|
|
27
|
+
getExtensions(): Record<string, import("../BlockNoteEditor.js").SupportedExtension>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a specific extension by key
|
|
30
|
+
*/
|
|
31
|
+
getExtension(key: string): import("../BlockNoteEditor.js").SupportedExtension;
|
|
32
|
+
/**
|
|
33
|
+
* Check if an extension exists
|
|
34
|
+
*/
|
|
35
|
+
hasExtension(key: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Get the formatting toolbar plugin
|
|
38
|
+
*/
|
|
39
|
+
get formattingToolbar(): FormattingToolbarProsemirrorPlugin;
|
|
40
|
+
/**
|
|
41
|
+
* Get the link toolbar plugin
|
|
42
|
+
*/
|
|
43
|
+
get linkToolbar(): LinkToolbarProsemirrorPlugin<any, any, any>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the side menu plugin
|
|
46
|
+
*/
|
|
47
|
+
get sideMenu(): SideMenuProsemirrorPlugin<any, any, any>;
|
|
48
|
+
/**
|
|
49
|
+
* Get the suggestion menus plugin
|
|
50
|
+
*/
|
|
51
|
+
get suggestionMenus(): SuggestionMenuProseMirrorPlugin<any, any, any>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the file panel plugin (if available)
|
|
54
|
+
*/
|
|
55
|
+
get filePanel(): FilePanelProsemirrorPlugin<any, any> | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Get the table handles plugin (if available)
|
|
58
|
+
*/
|
|
59
|
+
get tableHandles(): TableHandlesProsemirrorPlugin<any, any> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Get the show selection plugin
|
|
62
|
+
*/
|
|
63
|
+
get showSelectionPlugin(): ShowSelectionPlugin;
|
|
64
|
+
/**
|
|
65
|
+
* Check if collaboration is enabled (Yjs or Liveblocks)
|
|
66
|
+
*/
|
|
67
|
+
get isCollaborationEnabled(): boolean;
|
|
68
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BlockIdentifier, BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
2
|
+
import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../../blocks/defaultBlocks.js";
|
|
3
|
+
import { Selection } from "../selectionTypes.js";
|
|
4
|
+
import { TextCursorPosition } from "../cursorPositionTypes.js";
|
|
5
|
+
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
6
|
+
export declare class SelectionManager<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
7
|
+
private editor;
|
|
8
|
+
constructor(editor: BlockNoteEditor<BSchema, ISchema, SSchema>);
|
|
9
|
+
/**
|
|
10
|
+
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
11
|
+
* that the selection spans across.
|
|
12
|
+
*
|
|
13
|
+
* If the selection starts / ends halfway through a block, the returned data will contain the entire block.
|
|
14
|
+
*/
|
|
15
|
+
getSelection(): Selection<BSchema, ISchema, SSchema> | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Gets a snapshot of the current selection. This contains all blocks (included nested blocks)
|
|
18
|
+
* that the selection spans across.
|
|
19
|
+
*
|
|
20
|
+
* If the selection starts / ends halfway through a block, the returned block will be
|
|
21
|
+
* only the part of the block that is included in the selection.
|
|
22
|
+
*/
|
|
23
|
+
getSelectionCutBlocks(): {
|
|
24
|
+
blocks: import("../../index.js").Block<Record<string, import("../../index.js").BlockConfig<string, import("../../index.js").PropSchema, "inline" | "none" | "table">>, InlineContentSchema, StyleSchema>[];
|
|
25
|
+
blockCutAtStart: string | undefined;
|
|
26
|
+
blockCutAtEnd: string | undefined;
|
|
27
|
+
_meta: {
|
|
28
|
+
startPos: number;
|
|
29
|
+
endPos: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Sets the selection to a range of blocks.
|
|
34
|
+
* @param startBlock The identifier of the block that should be the start of the selection.
|
|
35
|
+
* @param endBlock The identifier of the block that should be the end of the selection.
|
|
36
|
+
*/
|
|
37
|
+
setSelection(startBlock: BlockIdentifier, endBlock: BlockIdentifier): void;
|
|
38
|
+
/**
|
|
39
|
+
* Gets a snapshot of the current text cursor position.
|
|
40
|
+
* @returns A snapshot of the current text cursor position.
|
|
41
|
+
*/
|
|
42
|
+
getTextCursorPosition(): TextCursorPosition<BSchema, ISchema, SSchema>;
|
|
43
|
+
/**
|
|
44
|
+
* Sets the text cursor position to the start or end of an existing block. Throws an error if the target block could
|
|
45
|
+
* not be found.
|
|
46
|
+
* @param targetBlock The identifier of an existing block that the text cursor should be moved to.
|
|
47
|
+
* @param placement Whether the text cursor should be placed at the start or end of the block.
|
|
48
|
+
*/
|
|
49
|
+
setTextCursorPosition(targetBlock: BlockIdentifier, placement?: "start" | "end"): void;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the bounding box of the current selection.
|
|
52
|
+
*/
|
|
53
|
+
getSelectionBoundingBox(): DOMRect | undefined;
|
|
54
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { redo, undo } from "@tiptap/pm/history";
|
|
2
|
+
import { Command, Transaction } from "prosemirror-state";
|
|
3
|
+
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
4
|
+
export declare class StateManager {
|
|
5
|
+
private editor;
|
|
6
|
+
private options?;
|
|
7
|
+
constructor(editor: BlockNoteEditor, options?: {
|
|
8
|
+
/**
|
|
9
|
+
* Swap the default undo command with a custom command.
|
|
10
|
+
*/
|
|
11
|
+
undo?: typeof undo;
|
|
12
|
+
/**
|
|
13
|
+
* Swap the default redo command with a custom command.
|
|
14
|
+
*/
|
|
15
|
+
redo?: typeof redo;
|
|
16
|
+
} | undefined);
|
|
17
|
+
/**
|
|
18
|
+
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
19
|
+
*/
|
|
20
|
+
private activeTransaction;
|
|
21
|
+
/**
|
|
22
|
+
* For any command that can be executed, you can check if it can be executed by calling `editor.can(command)`.
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* if (editor.can(editor.undo)) {
|
|
26
|
+
* // show button
|
|
27
|
+
* } else {
|
|
28
|
+
* // hide button
|
|
29
|
+
* }
|
|
30
|
+
*/
|
|
31
|
+
can(cb: () => boolean): boolean;
|
|
32
|
+
private isInCan;
|
|
33
|
+
/**
|
|
34
|
+
* Execute a prosemirror command. This is mostly for backwards compatibility with older code.
|
|
35
|
+
*
|
|
36
|
+
* @note You should prefer the {@link transact} method when possible, as it will automatically handle the dispatching of the transaction and work across blocknote transactions.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* editor.exec((state, dispatch, view) => {
|
|
41
|
+
* dispatch(state.tr.insertText("Hello, world!"));
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
exec(command: Command): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a command can be executed. A command should return `false` if it is not valid in the current state.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* if (editor.canExec(command)) {
|
|
52
|
+
* // show button
|
|
53
|
+
* } else {
|
|
54
|
+
* // hide button
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
canExec(command: Command): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Execute a function within a "blocknote transaction".
|
|
61
|
+
* All changes to the editor within the transaction will be grouped together, so that
|
|
62
|
+
* we can dispatch them as a single operation (thus creating only a single undo step)
|
|
63
|
+
*
|
|
64
|
+
* @note There is no need to dispatch the transaction, as it will be automatically dispatched when the callback is complete.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* // All changes to the editor will be grouped together
|
|
69
|
+
* editor.transact((tr) => {
|
|
70
|
+
* tr.insertText("Hello, world!");
|
|
71
|
+
* // These two operations will be grouped together in a single undo step
|
|
72
|
+
* editor.transact((tr) => {
|
|
73
|
+
* tr.insertText("Hello, world!");
|
|
74
|
+
* });
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
transact<T>(callback: (
|
|
79
|
+
/**
|
|
80
|
+
* The current active transaction, this will automatically be dispatched to the editor when the callback is complete
|
|
81
|
+
* If another `transact` call is made within the callback, it will be passed the same transaction as the parent call.
|
|
82
|
+
*/
|
|
83
|
+
tr: Transaction) => T): T;
|
|
84
|
+
/**
|
|
85
|
+
* Get the underlying prosemirror state
|
|
86
|
+
* @note Prefer using `editor.transact` to read the current editor state, as that will ensure the state is up to date
|
|
87
|
+
* @see https://prosemirror.net/docs/ref/#state.EditorState
|
|
88
|
+
*/
|
|
89
|
+
get prosemirrorState(): import("prosemirror-state").EditorState;
|
|
90
|
+
/**
|
|
91
|
+
* Get the underlying prosemirror view
|
|
92
|
+
* @see https://prosemirror.net/docs/ref/#view.EditorView
|
|
93
|
+
*/
|
|
94
|
+
get prosemirrorView(): import("prosemirror-view").EditorView;
|
|
95
|
+
isFocused(): boolean;
|
|
96
|
+
focus(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Checks if the editor is currently editable, or if it's locked.
|
|
99
|
+
* @returns True if the editor is editable, false otherwise.
|
|
100
|
+
*/
|
|
101
|
+
get isEditable(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Makes the editor editable or locks it, depending on the argument passed.
|
|
104
|
+
* @param editable True to make the editor editable, or false to lock it.
|
|
105
|
+
*/
|
|
106
|
+
set isEditable(editable: boolean);
|
|
107
|
+
/**
|
|
108
|
+
* Undo the last action.
|
|
109
|
+
*/
|
|
110
|
+
undo(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Redo the last action.
|
|
113
|
+
*/
|
|
114
|
+
redo(): boolean;
|
|
115
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BlockSchema, InlineContentSchema, PartialInlineContent, StyleSchema, Styles } from "../../schema/index.js";
|
|
2
|
+
import { DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema } from "../../blocks/defaultBlocks.js";
|
|
3
|
+
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
4
|
+
export declare class StyleManager<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> {
|
|
5
|
+
private editor;
|
|
6
|
+
constructor(editor: BlockNoteEditor<BSchema, ISchema, SSchema>);
|
|
7
|
+
/**
|
|
8
|
+
* Insert a piece of content at the current cursor position.
|
|
9
|
+
*
|
|
10
|
+
* @param content can be a string, or array of partial inline content elements
|
|
11
|
+
*/
|
|
12
|
+
insertInlineContent(content: PartialInlineContent<ISchema, SSchema>, { updateSelection }?: {
|
|
13
|
+
updateSelection?: boolean;
|
|
14
|
+
}): void;
|
|
15
|
+
/**
|
|
16
|
+
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
17
|
+
*/
|
|
18
|
+
getActiveStyles(): Styles<SSchema>;
|
|
19
|
+
/**
|
|
20
|
+
* Adds styles to the currently selected content.
|
|
21
|
+
* @param styles The styles to add.
|
|
22
|
+
*/
|
|
23
|
+
addStyles(styles: Styles<SSchema>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Removes styles from the currently selected content.
|
|
26
|
+
* @param styles The styles to remove.
|
|
27
|
+
*/
|
|
28
|
+
removeStyles(styles: Styles<SSchema>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Toggles styles on the currently selected content.
|
|
31
|
+
* @param styles The styles to toggle.
|
|
32
|
+
*/
|
|
33
|
+
toggleStyles(styles: Styles<SSchema>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the currently selected text.
|
|
36
|
+
*/
|
|
37
|
+
getSelectedText(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the URL of the last link in the current selection, or `undefined` if there are no links in the selection.
|
|
40
|
+
*/
|
|
41
|
+
getSelectedLinkUrl(): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new link to replace the selected content.
|
|
44
|
+
* @param url The link URL.
|
|
45
|
+
* @param text The text to display the link with.
|
|
46
|
+
*/
|
|
47
|
+
createLink(url: string, text?: string): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BlockManager } from "./BlockManager.js";
|
|
2
|
+
export { CollaborationManager, type CollaborationOptions, } from "./CollaborationManager.js";
|
|
3
|
+
export { EventManager } from "./EventManager.js";
|
|
4
|
+
export { ExportManager } from "./ExportManager.js";
|
|
5
|
+
export { ExtensionManager } from "./ExtensionManager.js";
|
|
6
|
+
export { SelectionManager } from "./SelectionManager.js";
|
|
7
|
+
export { StateManager } from "./StateManager.js";
|
|
8
|
+
export { StyleManager } from "./StyleManager.js";
|