@blocknote/core 0.42.2 → 0.43.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 +2 -0
- package/dist/BlockNoteExtension-BWw0r8Gy.cjs.map +1 -0
- package/dist/BlockNoteExtension-C2X7LW-V.js +25 -0
- package/dist/BlockNoteExtension-C2X7LW-V.js.map +1 -0
- package/dist/BlockNoteSchema-CbSavEwr.js +270 -0
- package/dist/BlockNoteSchema-CbSavEwr.js.map +1 -0
- package/dist/BlockNoteSchema-D8TyvlfU.cjs +2 -0
- package/dist/BlockNoteSchema-D8TyvlfU.cjs.map +1 -0
- package/dist/EventEmitter-CLwfmbqG.cjs +2 -0
- package/dist/EventEmitter-CLwfmbqG.cjs.map +1 -0
- package/dist/EventEmitter-CjSwpTbz.js +27 -0
- package/dist/EventEmitter-CjSwpTbz.js.map +1 -0
- package/dist/ShowSelection-BW37oJ6h.cjs +2 -0
- package/dist/ShowSelection-BW37oJ6h.cjs.map +1 -0
- package/dist/ShowSelection-Dz-NEase.js +43 -0
- package/dist/ShowSelection-Dz-NEase.js.map +1 -0
- package/dist/TrailingNode-BUhuMJrB.js +2096 -0
- package/dist/TrailingNode-BUhuMJrB.js.map +1 -0
- package/dist/TrailingNode-CaT_wbho.cjs +2 -0
- package/dist/TrailingNode-CaT_wbho.cjs.map +1 -0
- package/dist/{blockToNode-DIfPWLH8.js → blockToNode-DBNbhwwC.js} +33 -33
- package/dist/blockToNode-DBNbhwwC.js.map +1 -0
- package/dist/blockToNode-w7H99R6p.cjs.map +1 -1
- package/dist/blocknote.cjs +4 -4
- package/dist/blocknote.cjs.map +1 -1
- package/dist/blocknote.js +2401 -5592
- package/dist/blocknote.js.map +1 -1
- package/dist/blocks.cjs +1 -1
- package/dist/blocks.js +71 -70
- package/dist/blocks.js.map +1 -1
- package/dist/comments.cjs +1 -1
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +451 -137
- package/dist/comments.js.map +1 -1
- package/dist/{BlockNoteSchema-Bi-eeHal.js → defaultBlocks-BJtxTOM2.js} +991 -1047
- package/dist/defaultBlocks-BJtxTOM2.js.map +1 -0
- package/dist/defaultBlocks-BxFclIGP.cjs +6 -0
- package/dist/defaultBlocks-BxFclIGP.cjs.map +1 -0
- package/dist/extensions.cjs +2 -0
- package/dist/extensions.cjs.map +1 -0
- package/dist/extensions.js +57 -0
- package/dist/extensions.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/webpack-stats.json +1 -1
- package/dist/yjs.js +1 -1
- package/package.json +12 -6
- package/src/api/nodeConversions/blockToNode.ts +1 -1
- package/src/api/nodeConversions/nodeToBlock.ts +1 -1
- package/src/blocks/Code/block.ts +4 -4
- package/src/blocks/Divider/block.ts +2 -2
- package/src/blocks/File/helpers/render/createAddFileButton.ts +7 -5
- package/src/blocks/Heading/block.ts +23 -20
- package/src/blocks/ListItem/BulletListItem/block.ts +2 -2
- package/src/blocks/ListItem/CheckListItem/block.ts +2 -2
- package/src/blocks/ListItem/NumberedListItem/block.ts +3 -3
- package/src/blocks/ListItem/ToggleListItem/block.ts +2 -2
- package/src/blocks/PageBreak/getPageBreakSlashMenuItems.ts +2 -2
- package/src/blocks/Paragraph/block.ts +2 -2
- package/src/blocks/Quote/block.ts +2 -2
- package/src/blocks/Table/block.ts +4 -3
- package/src/blocks/ToggleWrapper/createToggleWrapper.ts +2 -1
- package/src/comments/extension.ts +353 -0
- package/src/comments/index.ts +2 -1
- package/src/comments/types.ts +8 -0
- package/src/{extensions/Comments → comments}/userstore/UserStore.ts +2 -2
- package/src/editor/BlockNoteEditor.test.ts +2 -23
- package/src/editor/BlockNoteEditor.ts +66 -453
- package/src/editor/BlockNoteExtension.test.ts +103 -0
- package/src/editor/BlockNoteExtension.ts +174 -56
- package/src/editor/managers/EventManager.ts +64 -35
- package/src/editor/managers/ExtensionManager/extensions.ts +214 -0
- package/src/editor/managers/ExtensionManager/index.ts +514 -0
- package/src/editor/managers/ExtensionManager/symbol.ts +6 -0
- package/src/editor/managers/SelectionManager.ts +5 -1
- package/src/editor/managers/StateManager.ts +29 -17
- package/src/editor/managers/index.ts +1 -5
- package/src/extensions/BlockChange/{BlockChangePlugin.ts → BlockChange.ts} +27 -29
- package/src/extensions/Collaboration/{ForkYDocPlugin.test.ts → ForkYDoc.test.ts} +6 -5
- package/src/extensions/Collaboration/ForkYDoc.ts +158 -0
- package/src/extensions/Collaboration/YCursorPlugin.ts +183 -0
- package/src/extensions/Collaboration/YSync.ts +16 -0
- package/src/extensions/Collaboration/YUndo.ts +12 -0
- package/src/extensions/Collaboration/schemaMigration/SchemaMigration.ts +59 -0
- package/src/extensions/DropCursor/DropCursor.ts +26 -0
- package/src/extensions/FilePanel/FilePanel.ts +41 -0
- package/src/extensions/FormattingToolbar/FormattingToolbar.ts +119 -0
- package/src/extensions/History/History.ts +11 -0
- package/src/extensions/LinkToolbar/LinkToolbar.ts +121 -0
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.ts +74 -0
- package/src/extensions/Placeholder/Placeholder.ts +148 -0
- package/src/extensions/PreviousBlockType/{PreviousBlockTypePlugin.ts → PreviousBlockType.ts} +9 -13
- package/src/extensions/ShowSelection/{ShowSelectionPlugin.ts → ShowSelection.ts} +27 -33
- package/src/extensions/SideMenu/{SideMenuPlugin.ts → SideMenu.ts} +63 -83
- package/src/extensions/SuggestionMenu/{SuggestionPlugin.ts → SuggestionMenu.ts} +71 -77
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +29 -44
- package/src/extensions/TableHandles/{TableHandlesPlugin.ts → TableHandles.ts} +416 -437
- package/src/extensions/TrailingNode/{TrailingNodeExtension.ts → TrailingNode.ts} +8 -17
- package/src/extensions/index.ts +24 -0
- package/src/extensions/{BackgroundColor → tiptap-extensions/BackgroundColor}/BackgroundColorExtension.ts +1 -1
- package/src/extensions/{KeyboardShortcuts → tiptap-extensions/KeyboardShortcuts}/KeyboardShortcutsExtension.ts +21 -16
- package/src/extensions/{TextColor → tiptap-extensions/TextColor}/TextColorExtension.ts +1 -1
- package/src/extensions/tiptap-extensions/index.ts +31 -0
- package/src/index.ts +1 -13
- package/src/schema/blocks/createSpec.ts +14 -11
- package/src/schema/blocks/internal.ts +2 -2
- package/src/schema/blocks/types.ts +8 -5
- package/src/schema/schema.ts +11 -36
- package/src/util/topo-sort.ts +46 -0
- package/types/src/comments/extension.d.ts +70 -0
- package/types/src/comments/index.d.ts +2 -1
- package/types/src/comments/types.d.ts +8 -0
- package/types/src/{extensions/Comments → comments}/userstore/UserStore.d.ts +2 -2
- package/types/src/editor/BlockNoteEditor.d.ts +34 -105
- package/types/src/editor/BlockNoteExtension.d.ts +87 -22
- package/types/src/editor/managers/EventManager.d.ts +25 -16
- package/types/src/editor/managers/ExtensionManager/extensions.d.ts +8 -0
- package/types/src/editor/managers/ExtensionManager/index.d.ts +83 -0
- package/types/src/editor/managers/ExtensionManager/symbol.d.ts +5 -0
- package/types/src/editor/managers/StateManager.d.ts +1 -12
- package/types/src/editor/managers/index.d.ts +1 -2
- package/types/src/extensions/BlockChange/BlockChange.d.ts +16 -0
- package/types/src/extensions/Collaboration/ForkYDoc.d.ts +34 -0
- package/types/src/extensions/Collaboration/ForkYDoc.test.d.ts +1 -0
- package/types/src/extensions/Collaboration/YCursorPlugin.d.ts +24 -0
- package/types/src/extensions/Collaboration/YSync.d.ts +8 -0
- package/types/src/extensions/Collaboration/YUndo.d.ts +12 -0
- package/types/src/extensions/Collaboration/schemaMigration/SchemaMigration.d.ts +8 -0
- package/types/src/extensions/DropCursor/DropCursor.d.ts +5 -0
- package/types/src/extensions/FilePanel/FilePanel.d.ts +11 -0
- package/types/src/extensions/FormattingToolbar/FormattingToolbar.d.ts +9 -0
- package/types/src/extensions/History/History.d.ts +6 -0
- package/types/src/extensions/LinkToolbar/LinkToolbar.d.ts +24 -0
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboard.d.ts +5 -0
- package/types/src/extensions/Placeholder/Placeholder.d.ts +6 -0
- package/types/src/extensions/PreviousBlockType/{PreviousBlockTypePlugin.d.ts → PreviousBlockType.d.ts} +9 -5
- package/types/src/extensions/ShowSelection/ShowSelection.d.ts +21 -0
- package/types/src/extensions/SideMenu/{SideMenuPlugin.d.ts → SideMenu.d.ts} +11 -15
- package/types/src/extensions/SuggestionMenu/SuggestionMenu.d.ts +54 -0
- package/types/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.d.ts +1 -1
- package/types/src/extensions/TableHandles/{TableHandlesPlugin.d.ts → TableHandles.d.ts} +28 -31
- package/types/src/extensions/TrailingNode/TrailingNode.d.ts +8 -0
- package/types/src/extensions/index.d.ts +24 -0
- package/types/src/extensions/{KeyboardShortcuts → tiptap-extensions/KeyboardShortcuts}/KeyboardShortcutsExtension.d.ts +1 -1
- package/types/src/extensions/tiptap-extensions/index.d.ts +11 -0
- package/types/src/index.d.ts +1 -13
- package/types/src/schema/blocks/createSpec.d.ts +4 -4
- package/types/src/schema/blocks/internal.d.ts +2 -2
- package/types/src/schema/blocks/types.d.ts +5 -5
- package/types/src/util/topo-sort.d.ts +8 -0
- package/dist/BlockNoteSchema-Bi-eeHal.js.map +0 -1
- package/dist/BlockNoteSchema-DjDaA2C3.cjs +0 -6
- package/dist/BlockNoteSchema-DjDaA2C3.cjs.map +0 -1
- package/dist/blockToNode-DIfPWLH8.js.map +0 -1
- package/src/comments/models/User.ts +0 -8
- package/src/editor/BlockNoteExtensions.ts +0 -325
- package/src/editor/managers/CollaborationManager.ts +0 -212
- package/src/editor/managers/ExtensionManager.ts +0 -130
- package/src/extensions/Collaboration/CursorPlugin.ts +0 -189
- package/src/extensions/Collaboration/ForkYDocPlugin.ts +0 -192
- package/src/extensions/Collaboration/SyncPlugin.ts +0 -18
- package/src/extensions/Collaboration/UndoPlugin.ts +0 -18
- package/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.ts +0 -59
- package/src/extensions/Comments/CommentsPlugin.ts +0 -392
- package/src/extensions/FilePanel/FilePanelPlugin.ts +0 -206
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +0 -363
- package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +0 -380
- package/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.ts +0 -75
- package/src/extensions/Placeholder/PlaceholderPlugin.ts +0 -147
- package/types/src/comments/models/User.d.ts +0 -8
- package/types/src/editor/BlockNoteExtensions.d.ts +0 -43
- package/types/src/editor/managers/CollaborationManager.d.ts +0 -115
- package/types/src/editor/managers/ExtensionManager.d.ts +0 -68
- package/types/src/extensions/BlockChange/BlockChangePlugin.d.ts +0 -15
- package/types/src/extensions/Collaboration/CursorPlugin.d.ts +0 -37
- package/types/src/extensions/Collaboration/ForkYDocPlugin.d.ts +0 -41
- package/types/src/extensions/Collaboration/SyncPlugin.d.ts +0 -7
- package/types/src/extensions/Collaboration/UndoPlugin.d.ts +0 -9
- package/types/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.d.ts +0 -7
- package/types/src/extensions/Comments/CommentsPlugin.d.ts +0 -66
- package/types/src/extensions/FilePanel/FilePanelPlugin.d.ts +0 -31
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +0 -41
- package/types/src/extensions/LinkToolbar/LinkToolbarPlugin.d.ts +0 -42
- package/types/src/extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.d.ts +0 -5
- package/types/src/extensions/Placeholder/PlaceholderPlugin.d.ts +0 -6
- package/types/src/extensions/ShowSelection/ShowSelectionPlugin.d.ts +0 -15
- package/types/src/extensions/SuggestionMenu/SuggestionPlugin.d.ts +0 -31
- package/types/src/extensions/TrailingNode/TrailingNodeExtension.d.ts +0 -13
- /package/src/{extensions/Comments/CommentMark.ts → comments/mark.ts} +0 -0
- /package/src/extensions/{HardBreak → tiptap-extensions/HardBreak}/HardBreak.ts +0 -0
- /package/src/extensions/{Suggestions → tiptap-extensions/Suggestions}/SuggestionMarks.ts +0 -0
- /package/src/extensions/{TextAlignment → tiptap-extensions/TextAlignment}/TextAlignmentExtension.ts +0 -0
- /package/src/extensions/{UniqueID → tiptap-extensions/UniqueID}/UniqueID.ts +0 -0
- /package/types/src/{extensions/Comments/CommentMark.d.ts → comments/mark.d.ts} +0 -0
- /package/types/src/{extensions/Collaboration/ForkYDocPlugin.test.d.ts → editor/BlockNoteExtension.test.d.ts} +0 -0
- /package/types/src/extensions/{BackgroundColor → tiptap-extensions/BackgroundColor}/BackgroundColorExtension.d.ts +0 -0
- /package/types/src/extensions/{HardBreak → tiptap-extensions/HardBreak}/HardBreak.d.ts +0 -0
- /package/types/src/extensions/{Suggestions → tiptap-extensions/Suggestions}/SuggestionMarks.d.ts +0 -0
- /package/types/src/extensions/{TextAlignment → tiptap-extensions/TextAlignment}/TextAlignmentExtension.d.ts +0 -0
- /package/types/src/extensions/{TextColor → tiptap-extensions/TextColor}/TextColorExtension.d.ts +0 -0
- /package/types/src/extensions/{UniqueID → tiptap-extensions/UniqueID}/UniqueID.d.ts +0 -0
|
@@ -1,38 +1,20 @@
|
|
|
1
|
-
import {
|
|
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
4
|
import * as Y from "yjs";
|
|
5
5
|
import type { BlocksChanged } from "../api/getBlocksChangedByTransaction.js";
|
|
6
6
|
import { Block, BlockNoteSchema, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from "../blocks/index.js";
|
|
7
|
-
import type { ThreadStore, User } from "../comments/index.js";
|
|
8
|
-
import type { CommentsPlugin } from "../extensions/Comments/CommentsPlugin.js";
|
|
9
|
-
import type { FilePanelProsemirrorPlugin } from "../extensions/FilePanel/FilePanelPlugin.js";
|
|
10
|
-
import type { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
11
|
-
import type { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkToolbarPlugin.js";
|
|
12
|
-
import type { ShowSelectionPlugin } from "../extensions/ShowSelection/ShowSelectionPlugin.js";
|
|
13
|
-
import type { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin.js";
|
|
14
|
-
import type { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
15
|
-
import type { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin.js";
|
|
16
7
|
import type { Dictionary } from "../i18n/dictionary.js";
|
|
17
8
|
import type { BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSpecs, CustomBlockNoteSchema, InlineContentSchema, InlineContentSpecs, PartialInlineContent, Styles, StyleSchema, StyleSpecs } from "../schema/index.js";
|
|
9
|
+
import "../style.css";
|
|
18
10
|
import { EventEmitter } from "../util/EventEmitter.js";
|
|
19
11
|
import type { NoInfer } from "../util/typescript.js";
|
|
20
|
-
import {
|
|
12
|
+
import { ExtensionFactoryInstance } from "./BlockNoteExtension.js";
|
|
21
13
|
import type { TextCursorPosition } from "./cursorPositionTypes.js";
|
|
14
|
+
import { ExtensionManager } from "./managers/index.js";
|
|
22
15
|
import type { Selection } from "./selectionTypes.js";
|
|
23
|
-
import "../style.css";
|
|
24
|
-
/**
|
|
25
|
-
* A factory function that returns a BlockNoteExtension
|
|
26
|
-
* This is useful so we can create extensions that require an editor instance
|
|
27
|
-
* in the constructor
|
|
28
|
-
*/
|
|
29
|
-
export type BlockNoteExtensionFactory = (editor: BlockNoteEditor<any, any, any>) => BlockNoteExtension;
|
|
30
|
-
/**
|
|
31
|
-
* We support Tiptap extensions and BlockNoteExtension based extensions
|
|
32
|
-
*/
|
|
33
|
-
export type SupportedExtension = AnyExtension | BlockNoteExtension;
|
|
34
16
|
export type BlockCache<BSchema extends BlockSchema = any, ISchema extends InlineContentSchema = any, SSchema extends StyleSchema = any> = WeakMap<Node, Block<BSchema, ISchema, SSchema>>;
|
|
35
|
-
export
|
|
17
|
+
export interface BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends InlineContentSchema, SSchema extends StyleSchema> {
|
|
36
18
|
/**
|
|
37
19
|
* Whether changes to blocks (like indentation, creating lists, changing headings) should be animated or not. Defaults to `true`.
|
|
38
20
|
*
|
|
@@ -79,16 +61,6 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
79
61
|
*/
|
|
80
62
|
showCursorLabels?: "always" | "activity";
|
|
81
63
|
};
|
|
82
|
-
/**
|
|
83
|
-
* Configuration for the comments feature, requires a `threadStore`.
|
|
84
|
-
*
|
|
85
|
-
* See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.
|
|
86
|
-
* @remarks `CommentsOptions`
|
|
87
|
-
*/
|
|
88
|
-
comments?: {
|
|
89
|
-
schema?: BlockNoteSchema<any, any, any>;
|
|
90
|
-
threadStore: ThreadStore;
|
|
91
|
-
};
|
|
92
64
|
/**
|
|
93
65
|
* Use default BlockNote font and reset the styles of <p> <li> <h1> elements etc., that are used in BlockNote.
|
|
94
66
|
*
|
|
@@ -183,12 +155,6 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
183
155
|
* @returns The URL that's
|
|
184
156
|
*/
|
|
185
157
|
resolveFileUrl?: (url: string) => Promise<string>;
|
|
186
|
-
/**
|
|
187
|
-
* Resolve user information for comments.
|
|
188
|
-
*
|
|
189
|
-
* See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.
|
|
190
|
-
*/
|
|
191
|
-
resolveUsers?: (userIds: string[]) => Promise<User[]>;
|
|
192
158
|
/**
|
|
193
159
|
* The schema of the editor. The schema defines which Blocks, InlineContent, and Styles are available in the editor.
|
|
194
160
|
*
|
|
@@ -267,28 +233,15 @@ export type BlockNoteEditorOptions<BSchema extends BlockSchema, ISchema extends
|
|
|
267
233
|
* @internal
|
|
268
234
|
*/
|
|
269
235
|
_tiptapOptions?: Partial<EditorOptions>;
|
|
270
|
-
/**
|
|
271
|
-
* (experimental) add extra extensions to the editor
|
|
272
|
-
*
|
|
273
|
-
* @deprecated, should use `extensions` instead
|
|
274
|
-
* @internal
|
|
275
|
-
*/
|
|
276
|
-
_extensions?: Record<string, {
|
|
277
|
-
plugin: Plugin;
|
|
278
|
-
priority?: number;
|
|
279
|
-
} | ((editor: BlockNoteEditor<any, any, any>) => {
|
|
280
|
-
plugin: Plugin;
|
|
281
|
-
priority?: number;
|
|
282
|
-
})>;
|
|
283
236
|
/**
|
|
284
237
|
* Register extensions to the editor.
|
|
285
238
|
*
|
|
286
239
|
* See [Extensions](/docs/features/extensions) for more info.
|
|
287
240
|
*
|
|
288
|
-
* @remarks `
|
|
241
|
+
* @remarks `ExtensionFactory[]`
|
|
289
242
|
*/
|
|
290
|
-
extensions?: Array<
|
|
291
|
-
}
|
|
243
|
+
extensions?: Array<ExtensionFactoryInstance>;
|
|
244
|
+
}
|
|
292
245
|
export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockSchema, ISchema extends InlineContentSchema = DefaultInlineContentSchema, SSchema extends StyleSchema = DefaultStyleSchema> extends EventEmitter<{
|
|
293
246
|
create: void;
|
|
294
247
|
}> {
|
|
@@ -297,10 +250,6 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
297
250
|
* The underlying prosemirror schema
|
|
298
251
|
*/
|
|
299
252
|
readonly pmSchema: Schema;
|
|
300
|
-
/**
|
|
301
|
-
* extensions that are added to the editor, can be tiptap extensions or prosemirror plugins
|
|
302
|
-
*/
|
|
303
|
-
extensions: Record<string, SupportedExtension>;
|
|
304
253
|
readonly _tiptapEditor: TiptapEditor & {
|
|
305
254
|
contentComponent: any;
|
|
306
255
|
};
|
|
@@ -326,18 +275,6 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
326
275
|
readonly blockImplementations: BlockSpecs;
|
|
327
276
|
readonly inlineContentImplementations: InlineContentSpecs;
|
|
328
277
|
readonly styleImplementations: StyleSpecs;
|
|
329
|
-
get formattingToolbar(): FormattingToolbarProsemirrorPlugin;
|
|
330
|
-
get linkToolbar(): LinkToolbarProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
331
|
-
get sideMenu(): SideMenuProsemirrorPlugin<BSchema, ISchema, SSchema>;
|
|
332
|
-
get suggestionMenus(): SuggestionMenuProseMirrorPlugin<BSchema, ISchema, SSchema>;
|
|
333
|
-
get filePanel(): FilePanelProsemirrorPlugin<ISchema, SSchema> | undefined;
|
|
334
|
-
get tableHandles(): TableHandlesProsemirrorPlugin<ISchema, SSchema> | undefined;
|
|
335
|
-
get comments(): CommentsPlugin | undefined;
|
|
336
|
-
get showSelectionPlugin(): ShowSelectionPlugin;
|
|
337
|
-
/**
|
|
338
|
-
* The plugin for forking a document, only defined if in collaboration mode
|
|
339
|
-
*/
|
|
340
|
-
get forkYDocPlugin(): import("../extensions/Collaboration/ForkYDocPlugin.js").ForkYDocPlugin | undefined;
|
|
341
278
|
/**
|
|
342
279
|
* The `uploadFile` method is what the editor uses when files need to be uploaded (for example when selecting an image to upload).
|
|
343
280
|
* This method should set when creating the editor as this is application-specific.
|
|
@@ -351,7 +288,6 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
351
288
|
private onUploadStartCallbacks;
|
|
352
289
|
private onUploadEndCallbacks;
|
|
353
290
|
readonly resolveFileUrl?: (url: string) => Promise<string>;
|
|
354
|
-
readonly resolveUsers?: (userIds: string[]) => Promise<User[]>;
|
|
355
291
|
/**
|
|
356
292
|
* Editor settings
|
|
357
293
|
*/
|
|
@@ -368,13 +304,16 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
368
304
|
} ? BlockNoteEditor<BSchema, ISchema, SSchema> : BlockNoteEditor<DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;
|
|
369
305
|
protected constructor(options: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>>);
|
|
370
306
|
private readonly _blockManager;
|
|
371
|
-
private readonly _collaborationManager?;
|
|
372
307
|
private readonly _eventManager;
|
|
373
308
|
private readonly _exportManager;
|
|
374
309
|
private readonly _extensionManager;
|
|
375
310
|
private readonly _selectionManager;
|
|
376
311
|
private readonly _stateManager;
|
|
377
312
|
private readonly _styleManager;
|
|
313
|
+
/**
|
|
314
|
+
* BlockNote extensions that are added to the editor, keyed by the extension key
|
|
315
|
+
*/
|
|
316
|
+
get extensions(): Map<string, import("./BlockNoteExtension.js").Extension<any, string>>;
|
|
378
317
|
/**
|
|
379
318
|
* Execute a prosemirror command. This is mostly for backwards compatibility with older code.
|
|
380
319
|
*
|
|
@@ -427,16 +366,17 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
427
366
|
*/
|
|
428
367
|
tr: Transaction) => T): T;
|
|
429
368
|
/**
|
|
430
|
-
*
|
|
431
|
-
* just passing in the extension class.
|
|
432
|
-
*
|
|
433
|
-
* @param ext - The extension class to get
|
|
434
|
-
* @param key - optional, the key of the extension in the extensions object (defaults to the extension name)
|
|
435
|
-
* @returns The extension instance
|
|
369
|
+
* Remove extension(s) from the editor
|
|
436
370
|
*/
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
371
|
+
unregisterExtension: ExtensionManager["unregisterExtension"];
|
|
372
|
+
/**
|
|
373
|
+
* Register extension(s) to the editor
|
|
374
|
+
*/
|
|
375
|
+
registerExtension: ExtensionManager["registerExtension"];
|
|
376
|
+
/**
|
|
377
|
+
* Get an extension from the editor
|
|
378
|
+
*/
|
|
379
|
+
getExtension: ExtensionManager["getExtension"];
|
|
440
380
|
/**
|
|
441
381
|
* Mount the editor to a DOM element.
|
|
442
382
|
*
|
|
@@ -461,7 +401,13 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
461
401
|
get domElement(): HTMLDivElement | undefined;
|
|
462
402
|
isFocused(): boolean;
|
|
463
403
|
get headless(): boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Focus on the editor
|
|
406
|
+
*/
|
|
464
407
|
focus(): void;
|
|
408
|
+
/**
|
|
409
|
+
* Blur the editor
|
|
410
|
+
*/
|
|
465
411
|
blur(): void;
|
|
466
412
|
onUploadStart(callback: (blockId?: string) => void): () => void;
|
|
467
413
|
onUploadEnd(callback: (blockId?: string) => void): () => void;
|
|
@@ -731,13 +677,6 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
731
677
|
* @returns The blocks parsed from the Markdown string.
|
|
732
678
|
*/
|
|
733
679
|
tryParseMarkdownToBlocks(markdown: string): Block<BSchema, ISchema, SSchema>[];
|
|
734
|
-
/**
|
|
735
|
-
* Updates the user info for the current user that's shown to other collaborators.
|
|
736
|
-
*/
|
|
737
|
-
updateCollaborationUserInfo(user: {
|
|
738
|
-
name: string;
|
|
739
|
-
color: string;
|
|
740
|
-
}): void;
|
|
741
680
|
/**
|
|
742
681
|
* A callback function that runs whenever the editor's contents change.
|
|
743
682
|
*
|
|
@@ -749,23 +688,19 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
749
688
|
* Returns the blocks that were inserted, updated, or deleted by the change that occurred.
|
|
750
689
|
*/
|
|
751
690
|
getChanges(): BlocksChanged<BSchema, ISchema, SSchema>;
|
|
752
|
-
}) => void
|
|
691
|
+
}) => void,
|
|
753
692
|
/**
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
* @param callback The callback to execute.
|
|
757
|
-
* @returns A function to remove the callback.
|
|
693
|
+
* If true, the callback will be triggered when the changes are caused by a remote user
|
|
694
|
+
* @default true
|
|
758
695
|
*/
|
|
759
|
-
|
|
696
|
+
includeUpdatesFromRemote?: boolean): import("./managers/EventManager.js").Unsubscribe;
|
|
760
697
|
/**
|
|
761
|
-
* A callback function that runs
|
|
762
|
-
*
|
|
763
|
-
* This can be useful for plugins to initialize themselves after the editor has been initialized.
|
|
698
|
+
* A callback function that runs whenever the text cursor position or selection changes.
|
|
764
699
|
*
|
|
765
700
|
* @param callback The callback to execute.
|
|
766
701
|
* @returns A function to remove the callback.
|
|
767
702
|
*/
|
|
768
|
-
|
|
703
|
+
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, ISchema, SSchema>) => void, includeSelectionChangedByRemote?: boolean): import("./managers/EventManager.js").Unsubscribe;
|
|
769
704
|
/**
|
|
770
705
|
* A callback function that runs when the editor has been mounted.
|
|
771
706
|
*
|
|
@@ -794,12 +729,6 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
794
729
|
*/
|
|
795
730
|
getSelectionBoundingBox(): DOMRect | undefined;
|
|
796
731
|
get isEmpty(): boolean;
|
|
797
|
-
openSuggestionMenu(triggerCharacter: string, pluginState?: {
|
|
798
|
-
deleteTriggerCharacter?: boolean;
|
|
799
|
-
ignoreQueryLength?: boolean;
|
|
800
|
-
}): void;
|
|
801
|
-
getForceSelectionVisible(): boolean;
|
|
802
|
-
setForceSelectionVisible(forceSelectionVisible: boolean): void;
|
|
803
732
|
/**
|
|
804
733
|
* Paste HTML into the editor. Defaults to converting HTML to BlockNote HTML.
|
|
805
734
|
* @param html The HTML to paste.
|
|
@@ -1,18 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { BlockNoteEditor } from "./BlockNoteEditor.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { Store, StoreOptions } from "@tanstack/store";
|
|
2
|
+
import { type AnyExtension } from "@tiptap/core";
|
|
3
|
+
import type { Plugin as ProsemirrorPlugin } from "prosemirror-state";
|
|
4
|
+
import type { PartialBlockNoDefaults } from "../schema/index.js";
|
|
5
|
+
import type { BlockNoteEditor } from "./BlockNoteEditor.js";
|
|
6
|
+
/**
|
|
7
|
+
* This function is called when the extension is destroyed.
|
|
8
|
+
*/
|
|
9
|
+
type OnDestroy = () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Describes a BlockNote extension.
|
|
12
|
+
*/
|
|
13
|
+
export interface Extension<State = any, Key extends string = string> {
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
15
|
+
* The unique identifier for the extension.
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
readonly key: Key;
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when the extension is mounted to the editor.
|
|
20
|
+
*/
|
|
21
|
+
readonly mount?: (ctx: {
|
|
22
|
+
/**
|
|
23
|
+
* The DOM element that the editor is mounted to.
|
|
24
|
+
*/
|
|
25
|
+
dom: HTMLElement;
|
|
26
|
+
/**
|
|
27
|
+
* The root document of the {@link document} that the editor is mounted to.
|
|
28
|
+
*/
|
|
29
|
+
root: Document | ShadowRoot;
|
|
30
|
+
/**
|
|
31
|
+
* An {@link AbortSignal} that will be aborted when the extension is destroyed.
|
|
32
|
+
*/
|
|
33
|
+
signal: AbortSignal;
|
|
34
|
+
}) => void | OnDestroy;
|
|
35
|
+
/**
|
|
36
|
+
* The store for the extension.
|
|
37
|
+
*/
|
|
38
|
+
readonly store?: Store<State>;
|
|
39
|
+
/**
|
|
40
|
+
* Declares what {@link Extension}s that this extension depends on.
|
|
41
|
+
*/
|
|
42
|
+
readonly runsBefore?: ReadonlyArray<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Input rules for a block: An input rule is what is used to replace text in a block when a regular expression match is found.
|
|
45
|
+
* As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.
|
|
46
|
+
*/
|
|
47
|
+
readonly inputRules?: ReadonlyArray<InputRule>;
|
|
16
48
|
/**
|
|
17
49
|
* A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed
|
|
18
50
|
*
|
|
@@ -35,12 +67,23 @@ export declare abstract class BlockNoteExtension<TEvent extends Record<string, a
|
|
|
35
67
|
* }
|
|
36
68
|
* ```
|
|
37
69
|
*/
|
|
38
|
-
keyboardShortcuts?: Record<string, (ctx: {
|
|
39
|
-
editor: BlockNoteEditor<
|
|
70
|
+
readonly keyboardShortcuts?: Record<string, (ctx: {
|
|
71
|
+
editor: BlockNoteEditor<any, any, any>;
|
|
40
72
|
}) => boolean>;
|
|
41
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Add additional prosemirror plugins to the editor.
|
|
75
|
+
*/
|
|
76
|
+
readonly prosemirrorPlugins?: ReadonlyArray<ProsemirrorPlugin>;
|
|
77
|
+
/**
|
|
78
|
+
* Add additional tiptap extensions to the editor.
|
|
79
|
+
*/
|
|
80
|
+
readonly tiptapExtensions?: ReadonlyArray<AnyExtension>;
|
|
42
81
|
}
|
|
43
|
-
|
|
82
|
+
/**
|
|
83
|
+
* An input rule is what is used to replace text in a block when a regular expression match is found.
|
|
84
|
+
* As an example, typing `#` in a paragraph block will trigger an input rule to replace the text with a heading block.
|
|
85
|
+
*/
|
|
86
|
+
type InputRule = {
|
|
44
87
|
/**
|
|
45
88
|
* The regex to match when to trigger the input rule
|
|
46
89
|
*/
|
|
@@ -68,9 +111,31 @@ export type InputRule = {
|
|
|
68
111
|
}) => undefined | PartialBlockNoDefaults<any, any, any>;
|
|
69
112
|
};
|
|
70
113
|
/**
|
|
71
|
-
*
|
|
72
|
-
|
|
114
|
+
* These are the arguments that are passed to an {@link ExtensionFactoryInstance}.
|
|
115
|
+
*/
|
|
116
|
+
export interface ExtensionOptions<Options extends Record<string, any> | undefined = Record<string, any> | undefined> {
|
|
117
|
+
options: Options;
|
|
118
|
+
editor: BlockNoteEditor<any, any, any>;
|
|
119
|
+
}
|
|
120
|
+
export type ExtensionMap<T extends ReadonlyArray<ExtensionFactoryInstance>> = {
|
|
121
|
+
[K in T[number] extends ExtensionFactoryInstance<infer Ext> ? Ext["key"] : never]: T[number] extends ExtensionFactoryInstance<infer Ext> ? Ext : never;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* This is a type that represents the function which will actually create the extension.
|
|
125
|
+
* It requires the editor instance to be passed in, but will already have the options applied automatically.
|
|
126
|
+
*
|
|
127
|
+
* @note Only the BlockNoteEditor should instantiate this function, not the user. Look at {@link createExtension} for user-facing functions.
|
|
128
|
+
*/
|
|
129
|
+
export type ExtensionFactoryInstance<Ext extends Extension<any, any> = Extension<any, any>> = (ctx: Omit<ExtensionOptions<any>, "options">) => Ext;
|
|
130
|
+
/**
|
|
131
|
+
* This is the return type of the {@link createExtension} function.
|
|
132
|
+
* It is a function that can be invoked with the extension's options to create a new extension factory.
|
|
133
|
+
*/
|
|
134
|
+
export type ExtensionFactory<State = any, Key extends string = string, Factory extends (ctx: any) => Extension<State, Key> = (ctx: ExtensionOptions<any>) => Extension<State, Key>> = Parameters<Factory>[0] extends ExtensionOptions<infer Options> ? undefined extends Options ? (options?: Exclude<Options, undefined>) => ExtensionFactoryInstance<ReturnType<Factory>> : (options: Options) => ExtensionFactoryInstance<ReturnType<Factory>> : () => ExtensionFactoryInstance<ReturnType<Factory>>;
|
|
135
|
+
/**
|
|
136
|
+
* Constructs a BlockNote {@link ExtensionFactory} from a factory function or object
|
|
73
137
|
*/
|
|
74
|
-
export declare function
|
|
75
|
-
|
|
76
|
-
|
|
138
|
+
export declare function createExtension<const State = any, const Key extends string = string, const Ext extends Extension<State, Key> = Extension<State, Key>>(factory: Ext): ExtensionFactoryInstance<Ext>;
|
|
139
|
+
export declare function createExtension<const State = any, const Options extends Record<string, any> | undefined = any, const Key extends string = string, const Factory extends (ctx: any) => Extension<State, Key> = (ctx: ExtensionOptions<Options>) => Extension<State, Key>>(factory: Factory): ExtensionFactory<State, Key, Factory>;
|
|
140
|
+
export declare function createStore<T = any>(initialState: T, options?: StoreOptions<T>): Store<T>;
|
|
141
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import type { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
|
2
2
|
import { type BlocksChanged } from "../../api/getBlocksChangedByTransaction.js";
|
|
3
3
|
import { Transaction } from "prosemirror-state";
|
|
4
4
|
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
5
|
+
import { BlockSchema, InlineContentSchema, StyleSchema } from "../../schema/index.js";
|
|
5
6
|
/**
|
|
6
7
|
* A function that can be used to unsubscribe from an event.
|
|
7
8
|
*/
|
|
@@ -9,36 +10,44 @@ export type Unsubscribe = () => void;
|
|
|
9
10
|
/**
|
|
10
11
|
* EventManager is a class which manages the events of the editor
|
|
11
12
|
*/
|
|
12
|
-
export declare class EventManager<
|
|
13
|
+
export declare class EventManager<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema> extends EventEmitter<{
|
|
13
14
|
onChange: [
|
|
14
|
-
editor: Editor,
|
|
15
15
|
ctx: {
|
|
16
|
-
|
|
16
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
17
|
+
transaction: Transaction;
|
|
18
|
+
appendedTransactions: Transaction[];
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
onSelectionChange: [
|
|
22
|
+
ctx: {
|
|
23
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
24
|
+
transaction: Transaction;
|
|
17
25
|
}
|
|
18
26
|
];
|
|
19
|
-
onSelectionChange: [ctx: {
|
|
20
|
-
editor: Editor;
|
|
21
|
-
transaction: Transaction;
|
|
22
|
-
}];
|
|
23
27
|
onMount: [ctx: {
|
|
24
|
-
editor:
|
|
28
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
25
29
|
}];
|
|
26
30
|
onUnmount: [ctx: {
|
|
27
|
-
editor:
|
|
31
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
28
32
|
}];
|
|
29
33
|
}> {
|
|
30
34
|
private editor;
|
|
31
|
-
constructor(editor:
|
|
35
|
+
constructor(editor: BlockNoteEditor<BSchema, I, S>);
|
|
32
36
|
/**
|
|
33
37
|
* Register a callback that will be called when the editor changes.
|
|
34
38
|
*/
|
|
35
|
-
onChange(callback: (editor:
|
|
36
|
-
getChanges(): BlocksChanged<
|
|
37
|
-
}) => void
|
|
39
|
+
onChange(callback: (editor: BlockNoteEditor<BSchema, I, S>, ctx: {
|
|
40
|
+
getChanges(): BlocksChanged<BSchema, I, S>;
|
|
41
|
+
}) => void,
|
|
42
|
+
/**
|
|
43
|
+
* If true, the callback will be triggered when the changes are caused by a remote user
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
includeUpdatesFromRemote?: boolean): Unsubscribe;
|
|
38
47
|
/**
|
|
39
48
|
* Register a callback that will be called when the selection changes.
|
|
40
49
|
*/
|
|
41
|
-
onSelectionChange(callback: (editor:
|
|
50
|
+
onSelectionChange(callback: (editor: BlockNoteEditor<BSchema, I, S>) => void,
|
|
42
51
|
/**
|
|
43
52
|
* If true, the callback will be triggered when the selection changes due to a yjs sync (i.e.: other user was typing)
|
|
44
53
|
*/
|
|
@@ -47,12 +56,12 @@ export declare class EventManager<Editor extends BlockNoteEditor> extends EventE
|
|
|
47
56
|
* Register a callback that will be called when the editor is mounted.
|
|
48
57
|
*/
|
|
49
58
|
onMount(callback: (ctx: {
|
|
50
|
-
editor:
|
|
59
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
51
60
|
}) => void): Unsubscribe;
|
|
52
61
|
/**
|
|
53
62
|
* Register a callback that will be called when the editor is unmounted.
|
|
54
63
|
*/
|
|
55
64
|
onUnmount(callback: (ctx: {
|
|
56
|
-
editor:
|
|
65
|
+
editor: BlockNoteEditor<BSchema, I, S>;
|
|
57
66
|
}) => void): Unsubscribe;
|
|
58
67
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AnyExtension as AnyTiptapExtension } from "@tiptap/core";
|
|
2
|
+
import { BlockNoteEditor, BlockNoteEditorOptions } from "../../BlockNoteEditor.js";
|
|
3
|
+
import { ExtensionFactoryInstance } from "../../BlockNoteExtension.js";
|
|
4
|
+
/**
|
|
5
|
+
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDefaultTiptapExtensions(editor: BlockNoteEditor<any, any, any>, options: BlockNoteEditorOptions<any, any, any>): AnyTiptapExtension[];
|
|
8
|
+
export declare function getDefaultExtensions(editor: BlockNoteEditor<any, any, any>, options: BlockNoteEditorOptions<any, any, any>): ExtensionFactoryInstance[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AnyExtension as AnyTiptapExtension } from "@tiptap/core";
|
|
2
|
+
import type { BlockNoteEditor, BlockNoteEditorOptions } from "../../BlockNoteEditor.js";
|
|
3
|
+
import type { Extension, ExtensionFactoryInstance, ExtensionFactory } from "../../BlockNoteExtension.js";
|
|
4
|
+
export declare class ExtensionManager {
|
|
5
|
+
private editor;
|
|
6
|
+
private options;
|
|
7
|
+
/**
|
|
8
|
+
* A set of extension keys which are disabled by the options
|
|
9
|
+
*/
|
|
10
|
+
private disabledExtensions;
|
|
11
|
+
/**
|
|
12
|
+
* A list of all the extensions that are registered to the editor
|
|
13
|
+
*/
|
|
14
|
+
private extensions;
|
|
15
|
+
/**
|
|
16
|
+
* A map of all the abort controllers for each extension that has an init method defined
|
|
17
|
+
*/
|
|
18
|
+
private abortMap;
|
|
19
|
+
/**
|
|
20
|
+
* A map of all the extension factories that are registered to the editor
|
|
21
|
+
*/
|
|
22
|
+
private extensionFactories;
|
|
23
|
+
/**
|
|
24
|
+
* Because a single blocknote extension can both have it's own prosemirror plugins & additional generated ones (e.g. keymap & input rules plugins)
|
|
25
|
+
* We need to keep track of all the plugins for each extension, so that we can remove them when the extension is unregistered
|
|
26
|
+
*/
|
|
27
|
+
private extensionPlugins;
|
|
28
|
+
constructor(editor: BlockNoteEditor<any, any, any>, options: BlockNoteEditorOptions<any, any, any>);
|
|
29
|
+
/**
|
|
30
|
+
* Register one or more extensions to the editor after the editor is initialized.
|
|
31
|
+
*
|
|
32
|
+
* This allows users to switch on & off extensions "at runtime".
|
|
33
|
+
*/
|
|
34
|
+
registerExtension(extension: Extension | ExtensionFactoryInstance | (Extension | ExtensionFactoryInstance)[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Register an extension to the editor
|
|
37
|
+
* @param extension - The extension to register
|
|
38
|
+
* @returns The extension instance
|
|
39
|
+
*/
|
|
40
|
+
private addExtension;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve an extension or a list of extensions into a list of extension instances
|
|
43
|
+
* @param toResolve - The extension or list of extensions to resolve
|
|
44
|
+
* @returns A list of extension instances
|
|
45
|
+
*/
|
|
46
|
+
private resolveExtensions;
|
|
47
|
+
/**
|
|
48
|
+
* Unregister an extension from the editor
|
|
49
|
+
* @param toUnregister - The extension to unregister
|
|
50
|
+
* @returns void
|
|
51
|
+
*/
|
|
52
|
+
unregisterExtension(toUnregister: undefined | string | Extension | ExtensionFactory | (Extension | ExtensionFactory | string | undefined)[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Allows resetting the current prosemirror state's plugins
|
|
55
|
+
* @param update - A function that takes the current plugins and returns the new plugins
|
|
56
|
+
* @returns void
|
|
57
|
+
*/
|
|
58
|
+
private updatePlugins;
|
|
59
|
+
/**
|
|
60
|
+
* Get all the extensions that are registered to the editor
|
|
61
|
+
*/
|
|
62
|
+
getTiptapExtensions(): AnyTiptapExtension[];
|
|
63
|
+
/**
|
|
64
|
+
* This maps a blocknote extension into an array of Prosemirror plugins if it has any of the following:
|
|
65
|
+
* - plugins
|
|
66
|
+
* - keyboard shortcuts
|
|
67
|
+
* - input rules
|
|
68
|
+
*/
|
|
69
|
+
private getProsemirrorPluginsFromExtension;
|
|
70
|
+
/**
|
|
71
|
+
* Get all extensions
|
|
72
|
+
*/
|
|
73
|
+
getExtensions(): Map<string, Extension>;
|
|
74
|
+
/**
|
|
75
|
+
* Get a specific extension by it's instance
|
|
76
|
+
*/
|
|
77
|
+
getExtension<const Ext extends Extension | ExtensionFactory = Extension>(extension: string): (Ext extends Extension ? Ext : Ext extends ExtensionFactory ? ReturnType<ReturnType<Ext>> : never) | undefined;
|
|
78
|
+
getExtension<const T extends ExtensionFactory>(extension: T): ReturnType<ReturnType<T>> | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Check if an extension exists
|
|
81
|
+
*/
|
|
82
|
+
hasExtension(key: string | Extension | ExtensionFactory): boolean;
|
|
83
|
+
}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import { redo, undo } from "@tiptap/pm/history";
|
|
2
1
|
import { Command, Transaction } from "prosemirror-state";
|
|
3
2
|
import { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
4
3
|
export declare class StateManager {
|
|
5
4
|
private editor;
|
|
6
|
-
|
|
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);
|
|
5
|
+
constructor(editor: BlockNoteEditor<any, any, any>);
|
|
17
6
|
/**
|
|
18
7
|
* Stores the currently active transaction, which is the accumulated transaction from all {@link dispatch} calls during a {@link transact} calls
|
|
19
8
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { BlockManager } from "./BlockManager.js";
|
|
2
|
-
export { CollaborationManager, type CollaborationOptions, } from "./CollaborationManager.js";
|
|
3
2
|
export { EventManager } from "./EventManager.js";
|
|
4
3
|
export { ExportManager } from "./ExportManager.js";
|
|
5
|
-
export { ExtensionManager } from "./ExtensionManager.js";
|
|
4
|
+
export { ExtensionManager } from "./ExtensionManager/index.js";
|
|
6
5
|
export { SelectionManager } from "./SelectionManager.js";
|
|
7
6
|
export { StateManager } from "./StateManager.js";
|
|
8
7
|
export { StyleManager } from "./StyleManager.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Plugin, Transaction } from "prosemirror-state";
|
|
2
|
+
import { BlocksChanged } from "../../api/getBlocksChangedByTransaction.js";
|
|
3
|
+
/**
|
|
4
|
+
* This plugin can filter transactions before they are applied to the editor, but with a higher-level API than `filterTransaction` from prosemirror.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BlockChangeExtension: () => import("../../index.js").ExtensionFactoryInstance<{
|
|
7
|
+
readonly key: "blockChange";
|
|
8
|
+
readonly prosemirrorPlugins: readonly [Plugin<any>];
|
|
9
|
+
/**
|
|
10
|
+
* Subscribe to the block change events.
|
|
11
|
+
*/
|
|
12
|
+
readonly subscribe: (callback: (context: {
|
|
13
|
+
getChanges: () => BlocksChanged<any, any, any>;
|
|
14
|
+
tr: Transaction;
|
|
15
|
+
}) => boolean | void) => () => void;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
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<{
|
|
12
|
+
readonly key: "yForkDoc";
|
|
13
|
+
readonly store: import("@tanstack/store").Store<{
|
|
14
|
+
isForked: boolean;
|
|
15
|
+
}, (cb: {
|
|
16
|
+
isForked: boolean;
|
|
17
|
+
}) => {
|
|
18
|
+
isForked: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Fork the Y.js document from syncing to the remote,
|
|
22
|
+
* allowing modifications to the document without affecting the remote.
|
|
23
|
+
* These changes can later be rolled back or applied to the remote.
|
|
24
|
+
*/
|
|
25
|
+
readonly fork: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Resume syncing the Y.js document to the remote
|
|
28
|
+
* If `keepChanges` is true, any changes that have been made to the forked document will be applied to the original document.
|
|
29
|
+
* Otherwise, the original document will be restored and the changes will be discarded.
|
|
30
|
+
*/
|
|
31
|
+
readonly merge: ({ keepChanges }: {
|
|
32
|
+
keepChanges: boolean;
|
|
33
|
+
}) => void;
|
|
34
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|