@blocknote/core 0.42.3 → 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 +2402 -5594
- 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 +9 -3
- 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 +60 -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,325 +0,0 @@
|
|
|
1
|
-
import { AnyExtension, Extension, extensions, Node } from "@tiptap/core";
|
|
2
|
-
import { Gapcursor } from "@tiptap/extension-gapcursor";
|
|
3
|
-
import { History } from "@tiptap/extension-history";
|
|
4
|
-
import { Link } from "@tiptap/extension-link";
|
|
5
|
-
import { Text } from "@tiptap/extension-text";
|
|
6
|
-
import { Plugin } from "prosemirror-state";
|
|
7
|
-
import * as Y from "yjs";
|
|
8
|
-
|
|
9
|
-
import { createDropFileExtension } from "../api/clipboard/fromClipboard/fileDropExtension.js";
|
|
10
|
-
import { createPasteFromClipboardExtension } from "../api/clipboard/fromClipboard/pasteExtension.js";
|
|
11
|
-
import { createCopyToClipboardExtension } from "../api/clipboard/toClipboard/copyExtension.js";
|
|
12
|
-
import type { ThreadStore, User } from "../comments/index.js";
|
|
13
|
-
import { BackgroundColorExtension } from "../extensions/BackgroundColor/BackgroundColorExtension.js";
|
|
14
|
-
import { BlockChangePlugin } from "../extensions/BlockChange/BlockChangePlugin.js";
|
|
15
|
-
import { CursorPlugin } from "../extensions/Collaboration/CursorPlugin.js";
|
|
16
|
-
import { ForkYDocPlugin } from "../extensions/Collaboration/ForkYDocPlugin.js";
|
|
17
|
-
import { SyncPlugin } from "../extensions/Collaboration/SyncPlugin.js";
|
|
18
|
-
import { UndoPlugin } from "../extensions/Collaboration/UndoPlugin.js";
|
|
19
|
-
import { SchemaMigrationPlugin } from "../extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.js";
|
|
20
|
-
import { CommentMark } from "../extensions/Comments/CommentMark.js";
|
|
21
|
-
import { CommentsPlugin } from "../extensions/Comments/CommentsPlugin.js";
|
|
22
|
-
import { FilePanelProsemirrorPlugin } from "../extensions/FilePanel/FilePanelPlugin.js";
|
|
23
|
-
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
24
|
-
import { HardBreak } from "../extensions/HardBreak/HardBreak.js";
|
|
25
|
-
import { KeyboardShortcutsExtension } from "../extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js";
|
|
26
|
-
import { LinkToolbarProsemirrorPlugin } from "../extensions/LinkToolbar/LinkToolbarPlugin.js";
|
|
27
|
-
import {
|
|
28
|
-
DEFAULT_LINK_PROTOCOL,
|
|
29
|
-
VALID_LINK_PROTOCOLS,
|
|
30
|
-
} from "../extensions/LinkToolbar/protocols.js";
|
|
31
|
-
import { NodeSelectionKeyboardPlugin } from "../extensions/NodeSelectionKeyboard/NodeSelectionKeyboardPlugin.js";
|
|
32
|
-
import { PlaceholderPlugin } from "../extensions/Placeholder/PlaceholderPlugin.js";
|
|
33
|
-
import { PreviousBlockTypePlugin } from "../extensions/PreviousBlockType/PreviousBlockTypePlugin.js";
|
|
34
|
-
import { ShowSelectionPlugin } from "../extensions/ShowSelection/ShowSelectionPlugin.js";
|
|
35
|
-
import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin.js";
|
|
36
|
-
import { SuggestionMenuProseMirrorPlugin } from "../extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
37
|
-
import {
|
|
38
|
-
SuggestionAddMark,
|
|
39
|
-
SuggestionDeleteMark,
|
|
40
|
-
SuggestionModificationMark,
|
|
41
|
-
} from "../extensions/Suggestions/SuggestionMarks.js";
|
|
42
|
-
import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin.js";
|
|
43
|
-
import { TextAlignmentExtension } from "../extensions/TextAlignment/TextAlignmentExtension.js";
|
|
44
|
-
import { TextColorExtension } from "../extensions/TextColor/TextColorExtension.js";
|
|
45
|
-
import { TrailingNode } from "../extensions/TrailingNode/TrailingNodeExtension.js";
|
|
46
|
-
import UniqueID from "../extensions/UniqueID/UniqueID.js";
|
|
47
|
-
import { BlockContainer, BlockGroup, Doc } from "../pm-nodes/index.js";
|
|
48
|
-
import {
|
|
49
|
-
BlockNoteDOMAttributes,
|
|
50
|
-
BlockSchema,
|
|
51
|
-
BlockSpecs,
|
|
52
|
-
InlineContentSchema,
|
|
53
|
-
InlineContentSpecs,
|
|
54
|
-
StyleSchema,
|
|
55
|
-
StyleSpecs,
|
|
56
|
-
} from "../schema/index.js";
|
|
57
|
-
import type {
|
|
58
|
-
BlockNoteEditor,
|
|
59
|
-
BlockNoteEditorOptions,
|
|
60
|
-
SupportedExtension,
|
|
61
|
-
} from "./BlockNoteEditor.js";
|
|
62
|
-
import { BlockNoteSchema } from "../blocks/BlockNoteSchema.js";
|
|
63
|
-
|
|
64
|
-
type ExtensionOptions<
|
|
65
|
-
BSchema extends BlockSchema,
|
|
66
|
-
I extends InlineContentSchema,
|
|
67
|
-
S extends StyleSchema,
|
|
68
|
-
> = {
|
|
69
|
-
editor: BlockNoteEditor<BSchema, I, S>;
|
|
70
|
-
domAttributes: Partial<BlockNoteDOMAttributes>;
|
|
71
|
-
blockSpecs: BlockSpecs;
|
|
72
|
-
inlineContentSpecs: InlineContentSpecs;
|
|
73
|
-
styleSpecs: StyleSpecs;
|
|
74
|
-
trailingBlock: boolean | undefined;
|
|
75
|
-
collaboration?: {
|
|
76
|
-
fragment: Y.XmlFragment;
|
|
77
|
-
user: {
|
|
78
|
-
name: string;
|
|
79
|
-
color: string;
|
|
80
|
-
[key: string]: string;
|
|
81
|
-
};
|
|
82
|
-
provider: any;
|
|
83
|
-
renderCursor?: (user: any) => HTMLElement;
|
|
84
|
-
showCursorLabels?: "always" | "activity";
|
|
85
|
-
};
|
|
86
|
-
disableExtensions: string[] | undefined;
|
|
87
|
-
setIdAttribute?: boolean;
|
|
88
|
-
animations: boolean;
|
|
89
|
-
tableHandles: boolean;
|
|
90
|
-
dropCursor: (opts: any) => Plugin;
|
|
91
|
-
placeholders: Record<
|
|
92
|
-
string | "default" | "emptyDocument",
|
|
93
|
-
string | undefined
|
|
94
|
-
>;
|
|
95
|
-
tabBehavior?: "prefer-navigate-ui" | "prefer-indent";
|
|
96
|
-
comments?: {
|
|
97
|
-
schema?: BlockNoteSchema<any, any, any>;
|
|
98
|
-
threadStore: ThreadStore;
|
|
99
|
-
resolveUsers?: (userIds: string[]) => Promise<User[]>;
|
|
100
|
-
};
|
|
101
|
-
pasteHandler: BlockNoteEditorOptions<any, any, any>["pasteHandler"];
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
106
|
-
*/
|
|
107
|
-
export const getBlockNoteExtensions = <
|
|
108
|
-
BSchema extends BlockSchema,
|
|
109
|
-
I extends InlineContentSchema,
|
|
110
|
-
S extends StyleSchema,
|
|
111
|
-
>(
|
|
112
|
-
opts: ExtensionOptions<BSchema, I, S>,
|
|
113
|
-
) => {
|
|
114
|
-
const ret: Record<string, SupportedExtension> = {};
|
|
115
|
-
const tiptapExtensions = getTipTapExtensions(opts);
|
|
116
|
-
|
|
117
|
-
for (const ext of tiptapExtensions) {
|
|
118
|
-
ret[ext.name] = ext;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (opts.collaboration) {
|
|
122
|
-
ret["ySyncPlugin"] = new SyncPlugin(opts.collaboration.fragment);
|
|
123
|
-
ret["yUndoPlugin"] = new UndoPlugin({ editor: opts.editor });
|
|
124
|
-
|
|
125
|
-
if (opts.collaboration.provider?.awareness) {
|
|
126
|
-
ret["yCursorPlugin"] = new CursorPlugin(opts.collaboration);
|
|
127
|
-
}
|
|
128
|
-
ret["forkYDocPlugin"] = new ForkYDocPlugin({
|
|
129
|
-
editor: opts.editor,
|
|
130
|
-
collaboration: opts.collaboration,
|
|
131
|
-
});
|
|
132
|
-
ret["schemaMigrationPlugin"] = new SchemaMigrationPlugin(
|
|
133
|
-
opts.collaboration.fragment,
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Note: this is pretty hardcoded and will break when user provides plugins with same keys.
|
|
138
|
-
// Define name on plugins instead and not make this a map?
|
|
139
|
-
ret["formattingToolbar"] = new FormattingToolbarProsemirrorPlugin(
|
|
140
|
-
opts.editor,
|
|
141
|
-
);
|
|
142
|
-
ret["linkToolbar"] = new LinkToolbarProsemirrorPlugin(opts.editor);
|
|
143
|
-
ret["sideMenu"] = new SideMenuProsemirrorPlugin(opts.editor);
|
|
144
|
-
ret["suggestionMenus"] = new SuggestionMenuProseMirrorPlugin(opts.editor);
|
|
145
|
-
ret["filePanel"] = new FilePanelProsemirrorPlugin(opts.editor as any);
|
|
146
|
-
ret["placeholder"] = new PlaceholderPlugin(opts.editor, opts.placeholders);
|
|
147
|
-
|
|
148
|
-
if (opts.animations ?? true) {
|
|
149
|
-
ret["animations"] = new PreviousBlockTypePlugin();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (opts.tableHandles) {
|
|
153
|
-
ret["tableHandles"] = new TableHandlesProsemirrorPlugin(opts.editor as any);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
ret["nodeSelectionKeyboard"] = new NodeSelectionKeyboardPlugin();
|
|
157
|
-
ret["blockChange"] = new BlockChangePlugin();
|
|
158
|
-
|
|
159
|
-
ret["showSelection"] = new ShowSelectionPlugin(opts.editor);
|
|
160
|
-
|
|
161
|
-
if (opts.comments) {
|
|
162
|
-
ret["comments"] = new CommentsPlugin(
|
|
163
|
-
opts.editor,
|
|
164
|
-
opts.comments.threadStore,
|
|
165
|
-
CommentMark.name,
|
|
166
|
-
opts.comments.resolveUsers,
|
|
167
|
-
opts.comments.schema,
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const disableExtensions: string[] = opts.disableExtensions || [];
|
|
172
|
-
for (const ext of disableExtensions) {
|
|
173
|
-
delete ret[ext];
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return ret;
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
let LINKIFY_INITIALIZED = false;
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Get all the Tiptap extensions BlockNote is configured with by default
|
|
183
|
-
*/
|
|
184
|
-
const getTipTapExtensions = <
|
|
185
|
-
BSchema extends BlockSchema,
|
|
186
|
-
I extends InlineContentSchema,
|
|
187
|
-
S extends StyleSchema,
|
|
188
|
-
>(
|
|
189
|
-
opts: ExtensionOptions<BSchema, I, S>,
|
|
190
|
-
) => {
|
|
191
|
-
const tiptapExtensions: AnyExtension[] = [
|
|
192
|
-
extensions.ClipboardTextSerializer,
|
|
193
|
-
extensions.Commands,
|
|
194
|
-
extensions.Editable,
|
|
195
|
-
extensions.FocusEvents,
|
|
196
|
-
extensions.Tabindex,
|
|
197
|
-
|
|
198
|
-
// DevTools,
|
|
199
|
-
Gapcursor,
|
|
200
|
-
|
|
201
|
-
// DropCursor,
|
|
202
|
-
Extension.create({
|
|
203
|
-
name: "dropCursor",
|
|
204
|
-
addProseMirrorPlugins: () => [
|
|
205
|
-
opts.dropCursor({
|
|
206
|
-
width: 5,
|
|
207
|
-
color: "#ddeeff",
|
|
208
|
-
editor: opts.editor,
|
|
209
|
-
}),
|
|
210
|
-
],
|
|
211
|
-
}),
|
|
212
|
-
|
|
213
|
-
UniqueID.configure({
|
|
214
|
-
// everything from bnBlock group (nodes that represent a BlockNote block should have an id)
|
|
215
|
-
types: ["blockContainer", "columnList", "column"],
|
|
216
|
-
setIdAttribute: opts.setIdAttribute,
|
|
217
|
-
}),
|
|
218
|
-
HardBreak,
|
|
219
|
-
// Comments,
|
|
220
|
-
|
|
221
|
-
// basics:
|
|
222
|
-
Text,
|
|
223
|
-
|
|
224
|
-
// marks:
|
|
225
|
-
SuggestionAddMark,
|
|
226
|
-
SuggestionDeleteMark,
|
|
227
|
-
SuggestionModificationMark,
|
|
228
|
-
Link.extend({
|
|
229
|
-
inclusive: false,
|
|
230
|
-
}).configure({
|
|
231
|
-
defaultProtocol: DEFAULT_LINK_PROTOCOL,
|
|
232
|
-
// only call this once if we have multiple editors installed. Or fix https://github.com/ueberdosis/tiptap/issues/5450
|
|
233
|
-
protocols: LINKIFY_INITIALIZED ? [] : VALID_LINK_PROTOCOLS,
|
|
234
|
-
}),
|
|
235
|
-
...(Object.values(opts.styleSpecs).map((styleSpec) => {
|
|
236
|
-
return styleSpec.implementation.mark.configure({
|
|
237
|
-
editor: opts.editor as any,
|
|
238
|
-
});
|
|
239
|
-
}) as any[]),
|
|
240
|
-
|
|
241
|
-
TextColorExtension,
|
|
242
|
-
|
|
243
|
-
BackgroundColorExtension,
|
|
244
|
-
TextAlignmentExtension,
|
|
245
|
-
|
|
246
|
-
// make sure escape blurs editor, so that we can tab to other elements in the host page (accessibility)
|
|
247
|
-
Extension.create({
|
|
248
|
-
name: "OverrideEscape",
|
|
249
|
-
addKeyboardShortcuts() {
|
|
250
|
-
return {
|
|
251
|
-
Escape: () => {
|
|
252
|
-
if (opts.editor.suggestionMenus.shown) {
|
|
253
|
-
// escape is handled by suggestionmenu
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
return this.editor.commands.blur();
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
},
|
|
260
|
-
}),
|
|
261
|
-
|
|
262
|
-
// nodes
|
|
263
|
-
Doc,
|
|
264
|
-
BlockContainer.configure({
|
|
265
|
-
editor: opts.editor,
|
|
266
|
-
domAttributes: opts.domAttributes,
|
|
267
|
-
}),
|
|
268
|
-
KeyboardShortcutsExtension.configure({
|
|
269
|
-
editor: opts.editor,
|
|
270
|
-
tabBehavior: opts.tabBehavior,
|
|
271
|
-
}),
|
|
272
|
-
BlockGroup.configure({
|
|
273
|
-
domAttributes: opts.domAttributes,
|
|
274
|
-
}),
|
|
275
|
-
...Object.values(opts.inlineContentSpecs)
|
|
276
|
-
.filter((a) => a.config !== "link" && a.config !== "text")
|
|
277
|
-
.map((inlineContentSpec) => {
|
|
278
|
-
return inlineContentSpec.implementation!.node.configure({
|
|
279
|
-
editor: opts.editor as any,
|
|
280
|
-
});
|
|
281
|
-
}),
|
|
282
|
-
|
|
283
|
-
...Object.values(opts.blockSpecs).flatMap((blockSpec) => {
|
|
284
|
-
return [
|
|
285
|
-
// the node extension implementations
|
|
286
|
-
...("node" in blockSpec.implementation
|
|
287
|
-
? [
|
|
288
|
-
(blockSpec.implementation.node as Node).configure({
|
|
289
|
-
editor: opts.editor,
|
|
290
|
-
domAttributes: opts.domAttributes,
|
|
291
|
-
}),
|
|
292
|
-
]
|
|
293
|
-
: []),
|
|
294
|
-
];
|
|
295
|
-
}),
|
|
296
|
-
createCopyToClipboardExtension(opts.editor),
|
|
297
|
-
createPasteFromClipboardExtension(
|
|
298
|
-
opts.editor,
|
|
299
|
-
opts.pasteHandler ||
|
|
300
|
-
((context: {
|
|
301
|
-
defaultPasteHandler: (context?: {
|
|
302
|
-
prioritizeMarkdownOverHTML?: boolean;
|
|
303
|
-
plainTextAsMarkdown?: boolean;
|
|
304
|
-
}) => boolean | undefined;
|
|
305
|
-
}) => context.defaultPasteHandler()),
|
|
306
|
-
),
|
|
307
|
-
createDropFileExtension(opts.editor),
|
|
308
|
-
|
|
309
|
-
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
310
|
-
// should be handled before Enter handlers in other components like splitListItem
|
|
311
|
-
...(opts.trailingBlock === undefined || opts.trailingBlock
|
|
312
|
-
? [TrailingNode]
|
|
313
|
-
: []),
|
|
314
|
-
...(opts.comments ? [CommentMark] : []),
|
|
315
|
-
];
|
|
316
|
-
|
|
317
|
-
LINKIFY_INITIALIZED = true;
|
|
318
|
-
|
|
319
|
-
if (!opts.collaboration) {
|
|
320
|
-
// disable history extension when collaboration is enabled as y-prosemirror takes care of undo / redo
|
|
321
|
-
tiptapExtensions.push(History);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
return tiptapExtensions;
|
|
325
|
-
};
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import * as Y from "yjs";
|
|
2
|
-
import { redoCommand, undoCommand } from "y-prosemirror";
|
|
3
|
-
import { CommentsPlugin } from "../../extensions/Comments/CommentsPlugin.js";
|
|
4
|
-
import { CommentMark } from "../../extensions/Comments/CommentMark.js";
|
|
5
|
-
import { ForkYDocPlugin } from "../../extensions/Collaboration/ForkYDocPlugin.js";
|
|
6
|
-
import { SyncPlugin } from "../../extensions/Collaboration/SyncPlugin.js";
|
|
7
|
-
import { UndoPlugin } from "../../extensions/Collaboration/UndoPlugin.js";
|
|
8
|
-
import { CursorPlugin } from "../../extensions/Collaboration/CursorPlugin.js";
|
|
9
|
-
import type { ThreadStore, User } from "../../comments/index.js";
|
|
10
|
-
import type { BlockNoteEditor } from "../BlockNoteEditor.js";
|
|
11
|
-
import { CustomBlockNoteSchema } from "../../schema/schema.js";
|
|
12
|
-
|
|
13
|
-
export interface CollaborationOptions {
|
|
14
|
-
/**
|
|
15
|
-
* The Yjs XML fragment that's used for collaboration.
|
|
16
|
-
*/
|
|
17
|
-
fragment: Y.XmlFragment;
|
|
18
|
-
/**
|
|
19
|
-
* The user info for the current user that's shown to other collaborators.
|
|
20
|
-
*/
|
|
21
|
-
user: {
|
|
22
|
-
name: string;
|
|
23
|
-
color: string;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* A Yjs provider (used for awareness / cursor information)
|
|
27
|
-
* Can be null for comments-only mode
|
|
28
|
-
*/
|
|
29
|
-
provider: any;
|
|
30
|
-
/**
|
|
31
|
-
* Optional function to customize how cursors of users are rendered
|
|
32
|
-
*/
|
|
33
|
-
renderCursor?: (user: any) => HTMLElement;
|
|
34
|
-
/**
|
|
35
|
-
* Optional flag to set when the user label should be shown with the default
|
|
36
|
-
* collaboration cursor. Setting to "always" will always show the label,
|
|
37
|
-
* while "activity" will only show the label when the user moves the cursor
|
|
38
|
-
* or types. Defaults to "activity".
|
|
39
|
-
*/
|
|
40
|
-
showCursorLabels?: "always" | "activity";
|
|
41
|
-
/**
|
|
42
|
-
* Comments configuration - can be used with or without collaboration
|
|
43
|
-
*/
|
|
44
|
-
comments?: {
|
|
45
|
-
schema?: CustomBlockNoteSchema<any, any, any>;
|
|
46
|
-
threadStore: ThreadStore;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Function to resolve user IDs to user objects - required for comments
|
|
50
|
-
*/
|
|
51
|
-
resolveUsers?: (userIds: string[]) => Promise<User[]>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* CollaborationManager handles all collaboration-related functionality
|
|
56
|
-
* This manager is completely optional and can be tree-shaken if not used
|
|
57
|
-
*/
|
|
58
|
-
export class CollaborationManager {
|
|
59
|
-
private editor: BlockNoteEditor;
|
|
60
|
-
private options: CollaborationOptions;
|
|
61
|
-
private _commentsPlugin?: CommentsPlugin;
|
|
62
|
-
private _forkYDocPlugin?: ForkYDocPlugin;
|
|
63
|
-
private _syncPlugin?: SyncPlugin;
|
|
64
|
-
private _undoPlugin?: UndoPlugin;
|
|
65
|
-
private _cursorPlugin?: CursorPlugin;
|
|
66
|
-
|
|
67
|
-
constructor(editor: BlockNoteEditor, options: CollaborationOptions) {
|
|
68
|
-
this.editor = editor;
|
|
69
|
-
this.options = options;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get the sync plugin instance
|
|
74
|
-
*/
|
|
75
|
-
public get syncPlugin(): SyncPlugin | undefined {
|
|
76
|
-
return this._syncPlugin;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get the undo plugin instance
|
|
81
|
-
*/
|
|
82
|
-
public get undoPlugin(): UndoPlugin | undefined {
|
|
83
|
-
return this._undoPlugin;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get the cursor plugin instance
|
|
88
|
-
*/
|
|
89
|
-
public get cursorPlugin(): CursorPlugin | undefined {
|
|
90
|
-
return this._cursorPlugin;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Get the fork YDoc plugin instance
|
|
95
|
-
*/
|
|
96
|
-
public get forkYDocPlugin(): ForkYDocPlugin | undefined {
|
|
97
|
-
return this._forkYDocPlugin;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Initialize collaboration plugins
|
|
101
|
-
public initExtensions(): Record<string, unknown> {
|
|
102
|
-
// Only create collaboration plugins when real-time collaboration is enabled
|
|
103
|
-
const extensions: Record<string, unknown> = {};
|
|
104
|
-
|
|
105
|
-
// Initialize sync plugin
|
|
106
|
-
this._syncPlugin = new SyncPlugin(this.options.fragment);
|
|
107
|
-
extensions.ySyncPlugin = this._syncPlugin;
|
|
108
|
-
|
|
109
|
-
// Initialize undo plugin
|
|
110
|
-
this._undoPlugin = new UndoPlugin({ editor: this.editor });
|
|
111
|
-
extensions.yUndoPlugin = this._undoPlugin;
|
|
112
|
-
|
|
113
|
-
// Initialize cursor plugin if provider has awareness
|
|
114
|
-
if (this.options.provider?.awareness) {
|
|
115
|
-
this._cursorPlugin = new CursorPlugin(this.options);
|
|
116
|
-
extensions.yCursorPlugin = this._cursorPlugin;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Initialize fork YDoc plugin
|
|
120
|
-
this._forkYDocPlugin = new ForkYDocPlugin({
|
|
121
|
-
editor: this.editor,
|
|
122
|
-
collaboration: this.options,
|
|
123
|
-
});
|
|
124
|
-
extensions.forkYDocPlugin = this._forkYDocPlugin;
|
|
125
|
-
|
|
126
|
-
if (this.options.comments) {
|
|
127
|
-
if (!this.options.resolveUsers) {
|
|
128
|
-
throw new Error("resolveUsers is required when using comments");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Create CommentsPlugin instance and add it to editor extensions
|
|
132
|
-
this._commentsPlugin = new CommentsPlugin(
|
|
133
|
-
this.editor,
|
|
134
|
-
this.options.comments.threadStore,
|
|
135
|
-
CommentMark.name,
|
|
136
|
-
this.options.resolveUsers,
|
|
137
|
-
this.options.comments.schema,
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
// Add the comments plugin to the editor's extensions
|
|
141
|
-
extensions.comments = this._commentsPlugin;
|
|
142
|
-
extensions.commentMark = CommentMark;
|
|
143
|
-
}
|
|
144
|
-
return extensions;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Update the user info for the current user that's shown to other collaborators
|
|
149
|
-
*/
|
|
150
|
-
public updateUserInfo(user: { name: string; color: string }) {
|
|
151
|
-
const cursor = this.cursorPlugin;
|
|
152
|
-
if (!cursor) {
|
|
153
|
-
throw new Error(
|
|
154
|
-
"Cannot update collaboration user info when collaboration is disabled.",
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
cursor.updateUser(user);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Get the collaboration undo command
|
|
162
|
-
*/
|
|
163
|
-
public getUndoCommand() {
|
|
164
|
-
return undoCommand;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get the collaboration redo command
|
|
169
|
-
*/
|
|
170
|
-
public getRedoCommand() {
|
|
171
|
-
return redoCommand;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Check if initial content should be avoided due to collaboration
|
|
176
|
-
*/
|
|
177
|
-
public shouldAvoidInitialContent(): boolean {
|
|
178
|
-
// Only avoid initial content when real-time collaboration is enabled
|
|
179
|
-
// (i.e., when we have a provider)
|
|
180
|
-
return !!this.options.provider;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Get the collaboration options
|
|
185
|
-
*/
|
|
186
|
-
public getOptions(): CollaborationOptions {
|
|
187
|
-
return this.options;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Get the comments plugin if available
|
|
192
|
-
*/
|
|
193
|
-
public get comments(): CommentsPlugin | undefined {
|
|
194
|
-
return this._commentsPlugin;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Check if comments are enabled
|
|
199
|
-
*/
|
|
200
|
-
public get hasComments(): boolean {
|
|
201
|
-
return !!this.options.comments;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Get the resolveUsers function
|
|
206
|
-
*/
|
|
207
|
-
public get resolveUsers():
|
|
208
|
-
| ((userIds: string[]) => Promise<User[]>)
|
|
209
|
-
| undefined {
|
|
210
|
-
return this.options.resolveUsers;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
@@ -1,130 +0,0 @@
|
|
|
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
|
-
|
|
11
|
-
export class ExtensionManager {
|
|
12
|
-
constructor(private editor: BlockNoteEditor) {}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Shorthand to get a typed extension from the editor, by
|
|
16
|
-
* just passing in the extension class.
|
|
17
|
-
*
|
|
18
|
-
* @param ext - The extension class to get
|
|
19
|
-
* @param key - optional, the key of the extension in the extensions object (defaults to the extension name)
|
|
20
|
-
* @returns The extension instance
|
|
21
|
-
*/
|
|
22
|
-
public extension<T extends BlockNoteExtension>(
|
|
23
|
-
ext: { new (...args: any[]): T } & typeof BlockNoteExtension,
|
|
24
|
-
key = ext.key(),
|
|
25
|
-
): T {
|
|
26
|
-
const extension = this.editor.extensions[key] as T;
|
|
27
|
-
if (!extension) {
|
|
28
|
-
throw new Error(`Extension ${key} not found`);
|
|
29
|
-
}
|
|
30
|
-
return extension;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Get all extensions
|
|
35
|
-
*/
|
|
36
|
-
public getExtensions() {
|
|
37
|
-
return this.editor.extensions;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get a specific extension by key
|
|
42
|
-
*/
|
|
43
|
-
public getExtension(key: string) {
|
|
44
|
-
return this.editor.extensions[key];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Check if an extension exists
|
|
49
|
-
*/
|
|
50
|
-
public hasExtension(key: string): boolean {
|
|
51
|
-
return key in this.editor.extensions;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Plugin getters - these provide access to the core BlockNote plugins
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get the formatting toolbar plugin
|
|
58
|
-
*/
|
|
59
|
-
public get formattingToolbar(): FormattingToolbarProsemirrorPlugin {
|
|
60
|
-
return this.editor.extensions[
|
|
61
|
-
"formattingToolbar"
|
|
62
|
-
] as FormattingToolbarProsemirrorPlugin;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get the link toolbar plugin
|
|
67
|
-
*/
|
|
68
|
-
public get linkToolbar(): LinkToolbarProsemirrorPlugin<any, any, any> {
|
|
69
|
-
return this.editor.extensions[
|
|
70
|
-
"linkToolbar"
|
|
71
|
-
] as LinkToolbarProsemirrorPlugin<any, any, any>;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get the side menu plugin
|
|
76
|
-
*/
|
|
77
|
-
public get sideMenu(): SideMenuProsemirrorPlugin<any, any, any> {
|
|
78
|
-
return this.editor.extensions["sideMenu"] as SideMenuProsemirrorPlugin<
|
|
79
|
-
any,
|
|
80
|
-
any,
|
|
81
|
-
any
|
|
82
|
-
>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get the suggestion menus plugin
|
|
87
|
-
*/
|
|
88
|
-
public get suggestionMenus(): SuggestionMenuProseMirrorPlugin<any, any, any> {
|
|
89
|
-
return this.editor.extensions[
|
|
90
|
-
"suggestionMenus"
|
|
91
|
-
] as SuggestionMenuProseMirrorPlugin<any, any, any>;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get the file panel plugin (if available)
|
|
96
|
-
*/
|
|
97
|
-
public get filePanel(): FilePanelProsemirrorPlugin<any, any> | undefined {
|
|
98
|
-
return this.editor.extensions["filePanel"] as
|
|
99
|
-
| FilePanelProsemirrorPlugin<any, any>
|
|
100
|
-
| undefined;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Get the table handles plugin (if available)
|
|
105
|
-
*/
|
|
106
|
-
public get tableHandles():
|
|
107
|
-
| TableHandlesProsemirrorPlugin<any, any>
|
|
108
|
-
| undefined {
|
|
109
|
-
return this.editor.extensions["tableHandles"] as
|
|
110
|
-
| TableHandlesProsemirrorPlugin<any, any>
|
|
111
|
-
| undefined;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get the show selection plugin
|
|
116
|
-
*/
|
|
117
|
-
public get showSelectionPlugin(): ShowSelectionPlugin {
|
|
118
|
-
return this.editor.extensions["showSelection"] as ShowSelectionPlugin;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Check if collaboration is enabled (Yjs or Liveblocks)
|
|
123
|
-
*/
|
|
124
|
-
public get isCollaborationEnabled(): boolean {
|
|
125
|
-
return (
|
|
126
|
-
this.hasExtension("ySyncPlugin") ||
|
|
127
|
-
this.hasExtension("liveblocksExtension")
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
}
|