@blocknote/core 0.42.3 → 0.44.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-B4gm-Qco.cjs +2 -0
- package/dist/BlockNoteSchema-B4gm-Qco.cjs.map +1 -0
- package/dist/BlockNoteSchema-C-l154WP.js +270 -0
- package/dist/BlockNoteSchema-C-l154WP.js.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-B_zPMWxw.js +2098 -0
- package/dist/TrailingNode-B_zPMWxw.js.map +1 -0
- package/dist/TrailingNode-CRHrgOnK.cjs +2 -0
- package/dist/TrailingNode-CRHrgOnK.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 +2496 -5686
- 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/defaultBlocks-DLJ4Q1_J.cjs +6 -0
- package/dist/defaultBlocks-DLJ4Q1_J.cjs.map +1 -0
- package/dist/{BlockNoteSchema-Bi-eeHal.js → defaultBlocks-DgA_mtQV.js} +974 -1027
- package/dist/defaultBlocks-DgA_mtQV.js.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,5 +1,5 @@
|
|
|
1
|
-
import { Extension } from "@tiptap/core";
|
|
2
1
|
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import { createExtension } from "../../editor/BlockNoteExtension.js";
|
|
3
3
|
|
|
4
4
|
// based on https://github.com/ueberdosis/tiptap/blob/40a9404c94c7fef7900610c195536384781ae101/demos/src/Experiments/TrailingNode/Vue/trailing-node.ts
|
|
5
5
|
|
|
@@ -8,24 +8,15 @@ import { Plugin, PluginKey } from "prosemirror-state";
|
|
|
8
8
|
* - https://github.com/ueberdosis/tiptap/blob/v1/packages/tiptap-extensions/src/extensions/TrailingNode.js
|
|
9
9
|
* - https://github.com/remirror/remirror/blob/e0f1bec4a1e8073ce8f5500d62193e52321155b9/packages/prosemirror-trailing-node/src/trailing-node-plugin.ts
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
export interface TrailingNodeOptions {
|
|
13
|
-
node: string;
|
|
14
|
-
}
|
|
11
|
+
const plugin = new PluginKey("trailingNode");
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* Add a trailing node to the document so the user can always click at the bottom of the document and start typing
|
|
18
15
|
*/
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const plugin = new PluginKey(this.name);
|
|
24
|
-
// const disabledNodes = Object.entries(this.editor.schema.nodes)
|
|
25
|
-
// .map(([, value]) => value)
|
|
26
|
-
// .filter((node) => this.options.notAfter.includes(node.name));
|
|
27
|
-
|
|
28
|
-
return [
|
|
16
|
+
export const TrailingNodeExtension = createExtension(() => {
|
|
17
|
+
return {
|
|
18
|
+
key: "trailingNode",
|
|
19
|
+
prosemirrorPlugins: [
|
|
29
20
|
new Plugin({
|
|
30
21
|
key: plugin,
|
|
31
22
|
appendTransaction: (_, __, state) => {
|
|
@@ -80,6 +71,6 @@ export const TrailingNode = Extension.create<TrailingNodeOptions>({
|
|
|
80
71
|
},
|
|
81
72
|
},
|
|
82
73
|
}),
|
|
83
|
-
]
|
|
84
|
-
}
|
|
74
|
+
],
|
|
75
|
+
} as const;
|
|
85
76
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from "./BlockChange/BlockChange.js";
|
|
2
|
+
export * from "./Collaboration/ForkYDoc.js";
|
|
3
|
+
export * from "./Collaboration/schemaMigration/SchemaMigration.js";
|
|
4
|
+
export * from "./Collaboration/YCursorPlugin.js";
|
|
5
|
+
export * from "./Collaboration/YSync.js";
|
|
6
|
+
export * from "./Collaboration/YUndo.js";
|
|
7
|
+
export * from "./DropCursor/DropCursor.js";
|
|
8
|
+
export * from "./FilePanel/FilePanel.js";
|
|
9
|
+
export * from "./FormattingToolbar/FormattingToolbar.js";
|
|
10
|
+
export * from "./History/History.js";
|
|
11
|
+
export * from "./LinkToolbar/LinkToolbar.js";
|
|
12
|
+
export * from "./LinkToolbar/protocols.js";
|
|
13
|
+
export * from "./NodeSelectionKeyboard/NodeSelectionKeyboard.js";
|
|
14
|
+
export * from "./Placeholder/Placeholder.js";
|
|
15
|
+
export * from "./PreviousBlockType/PreviousBlockType.js";
|
|
16
|
+
export * from "./ShowSelection/ShowSelection.js";
|
|
17
|
+
export * from "./SideMenu/SideMenu.js";
|
|
18
|
+
export * from "./SuggestionMenu/SuggestionMenu.js";
|
|
19
|
+
export * from "./SuggestionMenu/getDefaultSlashMenuItems.js";
|
|
20
|
+
export * from "./SuggestionMenu/getDefaultEmojiPickerItems.js";
|
|
21
|
+
export * from "./SuggestionMenu/DefaultSuggestionItem.js";
|
|
22
|
+
export * from "./SuggestionMenu/DefaultGridSuggestionItem.js";
|
|
23
|
+
export * from "./TableHandles/TableHandles.js";
|
|
24
|
+
export * from "./TrailingNode/TrailingNode.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { getBackgroundColorAttribute } from "
|
|
2
|
+
import { getBackgroundColorAttribute } from "../../../blocks/defaultProps.js";
|
|
3
3
|
|
|
4
4
|
export const BackgroundColorExtension = Extension.create({
|
|
5
5
|
name: "blockBackgroundColor",
|
|
@@ -5,13 +5,15 @@ import {
|
|
|
5
5
|
getBottomNestedBlockInfo,
|
|
6
6
|
getPrevBlockInfo,
|
|
7
7
|
mergeBlocksCommand,
|
|
8
|
-
} from "
|
|
9
|
-
import { nestBlock } from "
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
8
|
+
} from "../../../api/blockManipulation/commands/mergeBlocks/mergeBlocks.js";
|
|
9
|
+
import { nestBlock } from "../../../api/blockManipulation/commands/nestBlock/nestBlock.js";
|
|
10
|
+
import { fixColumnList } from "../../../api/blockManipulation/commands/replaceBlocks/util/fixColumnList.js";
|
|
11
|
+
import { splitBlockCommand } from "../../../api/blockManipulation/commands/splitBlock/splitBlock.js";
|
|
12
|
+
import { updateBlockCommand } from "../../../api/blockManipulation/commands/updateBlock/updateBlock.js";
|
|
13
|
+
import { getBlockInfoFromSelection } from "../../../api/getBlockInfoFromPos.js";
|
|
14
|
+
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js";
|
|
15
|
+
import { FormattingToolbarExtension } from "../../FormattingToolbar/FormattingToolbar.js";
|
|
16
|
+
import { FilePanelExtension } from "../../FilePanel/FilePanel.js";
|
|
15
17
|
|
|
16
18
|
export const KeyboardShortcutsExtension = Extension.create<{
|
|
17
19
|
editor: BlockNoteEditor<any, any, any>;
|
|
@@ -489,28 +491,31 @@ export const KeyboardShortcutsExtension = Extension.create<{
|
|
|
489
491
|
Tab: () => {
|
|
490
492
|
if (
|
|
491
493
|
this.options.tabBehavior !== "prefer-indent" &&
|
|
492
|
-
(this.options.editor.
|
|
493
|
-
|
|
494
|
-
this.options.editor.
|
|
494
|
+
(this.options.editor.getExtension(FormattingToolbarExtension)?.store
|
|
495
|
+
.state ||
|
|
496
|
+
this.options.editor.getExtension(FilePanelExtension)?.store
|
|
497
|
+
.state !== undefined)
|
|
498
|
+
// TODO need to check if the link toolbar is open or another alternative entirely
|
|
495
499
|
) {
|
|
496
500
|
// don't handle tabs if a toolbar is shown, so we can tab into / out of it
|
|
497
501
|
return false;
|
|
498
502
|
}
|
|
499
503
|
return nestBlock(this.options.editor);
|
|
500
|
-
// return true;
|
|
501
504
|
},
|
|
502
505
|
"Shift-Tab": () => {
|
|
503
506
|
if (
|
|
504
507
|
this.options.tabBehavior !== "prefer-indent" &&
|
|
505
|
-
(this.options.editor.
|
|
506
|
-
|
|
507
|
-
this.options.editor.
|
|
508
|
+
(this.options.editor.getExtension(FormattingToolbarExtension)?.store
|
|
509
|
+
.state ||
|
|
510
|
+
this.options.editor.getExtension(FilePanelExtension)?.store
|
|
511
|
+
.state !== undefined)
|
|
512
|
+
// TODO need to check if the link toolbar is open or another alternative entirely
|
|
513
|
+
// other menu types?
|
|
508
514
|
) {
|
|
509
515
|
// don't handle tabs if a toolbar is shown, so we can tab into / out of it
|
|
510
516
|
return false;
|
|
511
517
|
}
|
|
512
|
-
this.editor.commands.liftListItem("blockContainer");
|
|
513
|
-
return true;
|
|
518
|
+
return this.editor.commands.liftListItem("blockContainer");
|
|
514
519
|
},
|
|
515
520
|
"Shift-Mod-ArrowUp": () => {
|
|
516
521
|
this.options.editor.moveBlocksUp();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { getTextColorAttribute } from "
|
|
2
|
+
import { getTextColorAttribute } from "../../../blocks/defaultProps.js";
|
|
3
3
|
|
|
4
4
|
export const TextColorExtension = Extension.create({
|
|
5
5
|
name: "blockTextColor",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BackgroundColorExtension } from "./BackgroundColor/BackgroundColorExtension.js";
|
|
2
|
+
import { HardBreak } from "./HardBreak/HardBreak.js";
|
|
3
|
+
import { KeyboardShortcutsExtension } from "./KeyboardShortcuts/KeyboardShortcutsExtension.js";
|
|
4
|
+
import {
|
|
5
|
+
SuggestionAddMark,
|
|
6
|
+
SuggestionDeleteMark,
|
|
7
|
+
SuggestionModificationMark,
|
|
8
|
+
} from "./Suggestions/SuggestionMarks.js";
|
|
9
|
+
import { TextAlignmentExtension } from "./TextAlignment/TextAlignmentExtension.js";
|
|
10
|
+
import { TextColorExtension } from "./TextColor/TextColorExtension.js";
|
|
11
|
+
import { UniqueID } from "./UniqueID/UniqueID.js";
|
|
12
|
+
|
|
13
|
+
export * from "./BackgroundColor/BackgroundColorExtension.js";
|
|
14
|
+
export * from "./HardBreak/HardBreak.js";
|
|
15
|
+
export * from "./KeyboardShortcuts/KeyboardShortcutsExtension.js";
|
|
16
|
+
export * from "./Suggestions/SuggestionMarks.js";
|
|
17
|
+
export * from "./TextAlignment/TextAlignmentExtension.js";
|
|
18
|
+
export * from "./TextColor/TextColorExtension.js";
|
|
19
|
+
export * from "./UniqueID/UniqueID.js";
|
|
20
|
+
|
|
21
|
+
export const DEFAULT_TIP_TAP_EXTENSIONS = [
|
|
22
|
+
BackgroundColorExtension,
|
|
23
|
+
HardBreak,
|
|
24
|
+
KeyboardShortcutsExtension,
|
|
25
|
+
SuggestionAddMark,
|
|
26
|
+
SuggestionDeleteMark,
|
|
27
|
+
SuggestionModificationMark,
|
|
28
|
+
TextAlignmentExtension,
|
|
29
|
+
TextColorExtension,
|
|
30
|
+
UniqueID,
|
|
31
|
+
];
|
package/src/index.ts
CHANGED
|
@@ -11,22 +11,10 @@ export * from "./api/pmUtil.js";
|
|
|
11
11
|
export * from "./blocks/index.js";
|
|
12
12
|
export * from "./editor/BlockNoteEditor.js";
|
|
13
13
|
export * from "./editor/BlockNoteExtension.js";
|
|
14
|
-
export * from "./editor/BlockNoteExtensions.js";
|
|
15
14
|
export * from "./editor/defaultColors.js";
|
|
16
15
|
export * from "./editor/selectionTypes.js";
|
|
17
16
|
export * from "./exporter/index.js";
|
|
18
17
|
export * from "./extensions-shared/UiElementPosition.js";
|
|
19
|
-
export * from "./extensions/FilePanel/FilePanelPlugin.js";
|
|
20
|
-
export * from "./extensions/FormattingToolbar/FormattingToolbarPlugin.js";
|
|
21
|
-
export * from "./extensions/LinkToolbar/LinkToolbarPlugin.js";
|
|
22
|
-
export * from "./extensions/LinkToolbar/protocols.js";
|
|
23
|
-
export * from "./extensions/SideMenu/SideMenuPlugin.js";
|
|
24
|
-
export * from "./extensions/SuggestionMenu/DefaultGridSuggestionItem.js";
|
|
25
|
-
export * from "./extensions/SuggestionMenu/DefaultSuggestionItem.js";
|
|
26
|
-
export * from "./extensions/SuggestionMenu/getDefaultEmojiPickerItems.js";
|
|
27
|
-
export * from "./extensions/SuggestionMenu/getDefaultSlashMenuItems.js";
|
|
28
|
-
export * from "./extensions/SuggestionMenu/SuggestionPlugin.js";
|
|
29
|
-
export * from "./extensions/TableHandles/TableHandlesPlugin.js";
|
|
30
18
|
export * from "./i18n/dictionary.js";
|
|
31
19
|
export * from "./schema/index.js";
|
|
32
20
|
export * from "./util/browser.js";
|
|
@@ -46,7 +34,7 @@ export { selectedFragmentToHTML } from "./api/clipboard/toClipboard/copyExtensio
|
|
|
46
34
|
// Node conversions
|
|
47
35
|
export * from "./api/nodeConversions/blockToNode.js";
|
|
48
36
|
export * from "./api/nodeConversions/nodeToBlock.js";
|
|
49
|
-
export * from "./extensions/UniqueID/UniqueID.js";
|
|
37
|
+
export * from "./extensions/tiptap-extensions/UniqueID/UniqueID.js";
|
|
50
38
|
|
|
51
39
|
// for server-util (TODO: maybe move):
|
|
52
40
|
export * from "./api/exporters/markdown/markdownExporter.js";
|
|
@@ -2,7 +2,10 @@ import { Editor, Node } from "@tiptap/core";
|
|
|
2
2
|
import { DOMParser, Fragment, TagParseRule } from "@tiptap/pm/model";
|
|
3
3
|
import { NodeView } from "@tiptap/pm/view";
|
|
4
4
|
import { mergeParagraphs } from "../../blocks/defaultBlockHelpers.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Extension,
|
|
7
|
+
ExtensionFactoryInstance,
|
|
8
|
+
} from "../../editor/BlockNoteExtension.js";
|
|
6
9
|
import { PropSchema } from "../propTypes.js";
|
|
7
10
|
import {
|
|
8
11
|
getBlockFromPos,
|
|
@@ -131,7 +134,7 @@ export function addNodeAndExtensionsToSpec<
|
|
|
131
134
|
>(
|
|
132
135
|
blockConfig: BlockConfig<TName, TProps, TContent>,
|
|
133
136
|
blockImplementation: BlockImplementation<TName, TProps, TContent>,
|
|
134
|
-
extensions?:
|
|
137
|
+
extensions?: (ExtensionFactoryInstance | Extension)[],
|
|
135
138
|
priority?: number,
|
|
136
139
|
): LooseBlockSpec<TName, TProps, TContent> {
|
|
137
140
|
const node =
|
|
@@ -296,10 +299,10 @@ export function createBlockSpec<
|
|
|
296
299
|
options: Partial<TOptions>,
|
|
297
300
|
) => BlockImplementation<TName, TProps, TContent>),
|
|
298
301
|
extensionsOrCreator?:
|
|
299
|
-
|
|
|
302
|
+
| ExtensionFactoryInstance[]
|
|
300
303
|
| (TOptions extends undefined
|
|
301
|
-
? () =>
|
|
302
|
-
: (options: Partial<TOptions>) =>
|
|
304
|
+
? () => ExtensionFactoryInstance[]
|
|
305
|
+
: (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
|
|
303
306
|
): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;
|
|
304
307
|
export function createBlockSpec<
|
|
305
308
|
const TName extends string,
|
|
@@ -329,10 +332,10 @@ export function createBlockSpec<
|
|
|
329
332
|
BlockConf["content"]
|
|
330
333
|
>),
|
|
331
334
|
extensionsOrCreator?:
|
|
332
|
-
|
|
|
335
|
+
| ExtensionFactoryInstance[]
|
|
333
336
|
| (TOptions extends undefined
|
|
334
|
-
? () =>
|
|
335
|
-
: (options: Partial<TOptions>) =>
|
|
337
|
+
? () => ExtensionFactoryInstance[]
|
|
338
|
+
: (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
|
|
336
339
|
): (
|
|
337
340
|
options?: Partial<TOptions>,
|
|
338
341
|
) => BlockSpec<
|
|
@@ -359,10 +362,10 @@ export function createBlockSpec<
|
|
|
359
362
|
options: Partial<TOptions>,
|
|
360
363
|
) => BlockImplementation<TName, TProps, TContent>),
|
|
361
364
|
extensionsOrCreator?:
|
|
362
|
-
|
|
|
365
|
+
| ExtensionFactoryInstance[]
|
|
363
366
|
| (TOptions extends undefined
|
|
364
|
-
? () =>
|
|
365
|
-
: (options: Partial<TOptions>) =>
|
|
367
|
+
? () => ExtensionFactoryInstance[]
|
|
368
|
+
: (options: Partial<TOptions>) => ExtensionFactoryInstance[]),
|
|
366
369
|
): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent> {
|
|
367
370
|
return (options = {} as TOptions) => {
|
|
368
371
|
const blockConfig =
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Attribute, Attributes, Editor, Node } from "@tiptap/core";
|
|
2
2
|
import { defaultBlockToHTML } from "../../blocks/defaultBlockHelpers.js";
|
|
3
3
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { ExtensionFactoryInstance } from "../../editor/BlockNoteExtension.js";
|
|
5
5
|
import { mergeCSSClasses } from "../../util/browser.js";
|
|
6
6
|
import { camelToDataKebab } from "../../util/string.js";
|
|
7
7
|
import { InlineContentSchema } from "../inlineContent/types.js";
|
|
@@ -203,7 +203,7 @@ export function createBlockSpecFromTiptapNode<
|
|
|
203
203
|
>(
|
|
204
204
|
config: T,
|
|
205
205
|
propSchema: P,
|
|
206
|
-
extensions?:
|
|
206
|
+
extensions?: ExtensionFactoryInstance[],
|
|
207
207
|
): LooseBlockSpec<T["type"], P, T["content"]> {
|
|
208
208
|
return {
|
|
209
209
|
config: {
|
|
@@ -4,7 +4,10 @@ import type { Node, NodeViewRendererProps } from "@tiptap/core";
|
|
|
4
4
|
import type { Fragment, Schema } from "prosemirror-model";
|
|
5
5
|
import type { ViewMutationRecord } from "prosemirror-view";
|
|
6
6
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
Extension,
|
|
9
|
+
ExtensionFactoryInstance,
|
|
10
|
+
} from "../../editor/BlockNoteExtension.js";
|
|
8
11
|
import type {
|
|
9
12
|
InlineContent,
|
|
10
13
|
InlineContentSchema,
|
|
@@ -98,7 +101,7 @@ export type BlockSpec<
|
|
|
98
101
|
> = {
|
|
99
102
|
config: BlockConfig<T, PS, C>;
|
|
100
103
|
implementation: BlockImplementation<T, PS, C>;
|
|
101
|
-
extensions?:
|
|
104
|
+
extensions?: (Extension | ExtensionFactoryInstance)[];
|
|
102
105
|
};
|
|
103
106
|
|
|
104
107
|
/**
|
|
@@ -145,7 +148,7 @@ export type LooseBlockSpec<
|
|
|
145
148
|
|
|
146
149
|
node: Node;
|
|
147
150
|
};
|
|
148
|
-
extensions?:
|
|
151
|
+
extensions?: (Extension | ExtensionFactoryInstance)[];
|
|
149
152
|
};
|
|
150
153
|
|
|
151
154
|
// Utility type. For a given object block schema, ensures that the key of each
|
|
@@ -197,7 +200,7 @@ export type BlockSpecs = {
|
|
|
197
200
|
}
|
|
198
201
|
| undefined;
|
|
199
202
|
};
|
|
200
|
-
extensions?:
|
|
203
|
+
extensions?: BlockSpec<k>["extensions"];
|
|
201
204
|
};
|
|
202
205
|
};
|
|
203
206
|
|
|
@@ -218,7 +221,7 @@ export type BlockSpecsFromSchema<BS extends BlockSchema> = {
|
|
|
218
221
|
BS[K]["propSchema"],
|
|
219
222
|
BS[K]["content"]
|
|
220
223
|
>;
|
|
221
|
-
extensions?:
|
|
224
|
+
extensions?: (Extension | ExtensionFactoryInstance)[];
|
|
222
225
|
};
|
|
223
226
|
};
|
|
224
227
|
|
package/src/schema/schema.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
|
|
2
|
-
import {
|
|
2
|
+
import { sortByDependencies } from "../util/topo-sort.js";
|
|
3
3
|
import {
|
|
4
4
|
BlockNoDefaults,
|
|
5
5
|
BlockSchema,
|
|
@@ -80,41 +80,16 @@ export class CustomBlockNoteSchema<
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
private init() {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
dag.set(key, new Set(specDef.implementation.runsBefore));
|
|
94
|
-
} else {
|
|
95
|
-
defaultSet.add(key);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const sortedSpecs = toposortReverse(dag);
|
|
99
|
-
const defaultIndex = sortedSpecs.findIndex((set) => set.has("default"));
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The priority of a block is described relative to the "default" block (an arbitrary block which can be used as the reference)
|
|
103
|
-
*
|
|
104
|
-
* Since blocks are topologically sorted, we can see what their relative position is to the "default" block
|
|
105
|
-
* Each layer away from the default block is 10 priority points (arbitrarily chosen)
|
|
106
|
-
* The default block is fixed at 101 (1 point higher than any tiptap extension, giving priority to custom blocks than any defaults)
|
|
107
|
-
*
|
|
108
|
-
* This is a bit of a hack, but it's a simple way to ensure that custom blocks are always rendered with higher priority than default blocks
|
|
109
|
-
* and that custom blocks are rendered in the order they are defined in the schema
|
|
110
|
-
*/
|
|
111
|
-
const getPriority = (key: string) => {
|
|
112
|
-
const index = sortedSpecs.findIndex((set) => set.has(key));
|
|
113
|
-
// the default index should map to 101
|
|
114
|
-
// one before the default index is 91
|
|
115
|
-
// one after is 111
|
|
116
|
-
return 91 + (index + defaultIndex) * 10;
|
|
117
|
-
};
|
|
83
|
+
const getPriority = sortByDependencies(
|
|
84
|
+
Object.entries({
|
|
85
|
+
...this.opts.blockSpecs,
|
|
86
|
+
...this.opts.inlineContentSpecs,
|
|
87
|
+
...this.opts.styleSpecs,
|
|
88
|
+
}).map(([key, val]) => ({
|
|
89
|
+
key: key,
|
|
90
|
+
runsBefore: val.implementation?.runsBefore ?? [],
|
|
91
|
+
})),
|
|
92
|
+
);
|
|
118
93
|
|
|
119
94
|
const blockSpecs = Object.fromEntries(
|
|
120
95
|
Object.entries(this.opts.blockSpecs).map(([key, blockSpec]) => {
|
package/src/util/topo-sort.ts
CHANGED
|
@@ -158,3 +158,49 @@ export function hasDependency(
|
|
|
158
158
|
const dependents = graph.get(from);
|
|
159
159
|
return dependents ? dependents.has(to) : false;
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Sorts a list of items by their dependencies
|
|
164
|
+
* @returns A function which can retrieve the priority of an item
|
|
165
|
+
*/
|
|
166
|
+
export function sortByDependencies(
|
|
167
|
+
items: { key: string; runsBefore?: ReadonlyArray<string> }[],
|
|
168
|
+
) {
|
|
169
|
+
const dag = createDependencyGraph();
|
|
170
|
+
|
|
171
|
+
for (const item of items) {
|
|
172
|
+
if (Array.isArray(item.runsBefore) && item.runsBefore.length > 0) {
|
|
173
|
+
item.runsBefore.forEach((runBefore) => {
|
|
174
|
+
addDependency(dag, item.key, runBefore);
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
addDependency(dag, "default", item.key);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const sortedSpecs = toposortReverse(dag);
|
|
181
|
+
const defaultIndex = sortedSpecs.findIndex((set) => set.has("default"));
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The priority of an item is described relative to the "default" (an arbitrary string which can be used as the reference)
|
|
185
|
+
*
|
|
186
|
+
* Since items are topologically sorted, we can see what their relative position is to the "default"
|
|
187
|
+
* Each layer away from the default is 10 priority points (arbitrarily chosen)
|
|
188
|
+
* The default is fixed at 101 (1 point higher than any tiptap extension, giving priority to custom blocks than any defaults)
|
|
189
|
+
*
|
|
190
|
+
* This is a bit of a hack, but it's a simple way to ensure that custom items are always rendered with higher priority than default items
|
|
191
|
+
* and that custom items are rendered in the order they are defined in the list
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Retrieves the priority of an item based on its position in the topologically sorted list
|
|
196
|
+
* @param key - The key of the item to get the priority of
|
|
197
|
+
* @returns The priority of the item
|
|
198
|
+
*/
|
|
199
|
+
return (key: string) => {
|
|
200
|
+
const index = sortedSpecs.findIndex((set) => set.has(key));
|
|
201
|
+
// the default index should map to 101
|
|
202
|
+
// one before the default index is 91
|
|
203
|
+
// one after is 111
|
|
204
|
+
return 91 + (index + defaultIndex) * 10;
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
2
|
+
import { DecorationSet } from "prosemirror-view";
|
|
3
|
+
import { CustomBlockNoteSchema } from "../schema/schema.js";
|
|
4
|
+
import type { ThreadStore } from "./threadstore/ThreadStore.js";
|
|
5
|
+
import type { CommentBody } from "./types.js";
|
|
6
|
+
import { User } from "./types.js";
|
|
7
|
+
import { UserStore } from "./userstore/UserStore.js";
|
|
8
|
+
type CommentsPluginState = {
|
|
9
|
+
/**
|
|
10
|
+
* Decorations to be rendered, specifically to indicate the selected thread
|
|
11
|
+
*/
|
|
12
|
+
decorations: DecorationSet;
|
|
13
|
+
};
|
|
14
|
+
export declare const CommentsExtension: (options: {
|
|
15
|
+
/**
|
|
16
|
+
* The thread store implementation to use for storing and retrieving comment threads
|
|
17
|
+
*/
|
|
18
|
+
threadStore: ThreadStore;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve user information for comments.
|
|
21
|
+
*
|
|
22
|
+
* See [Comments](https://www.blocknotejs.org/docs/features/collaboration/comments) for more info.
|
|
23
|
+
*/
|
|
24
|
+
resolveUsers: (userIds: string[]) => Promise<User[]>;
|
|
25
|
+
/**
|
|
26
|
+
* A schema to use for the comment editor (which allows you to customize the blocks and styles that are available in the comment editor)
|
|
27
|
+
*/
|
|
28
|
+
schema?: CustomBlockNoteSchema<any, any, any>;
|
|
29
|
+
}) => import("../index.js").ExtensionFactoryInstance<{
|
|
30
|
+
readonly key: "comments";
|
|
31
|
+
readonly store: import("@tanstack/store").Store<{
|
|
32
|
+
pendingComment: boolean;
|
|
33
|
+
selectedThreadId: string | undefined;
|
|
34
|
+
threadPositions: Map<string, {
|
|
35
|
+
from: number;
|
|
36
|
+
to: number;
|
|
37
|
+
}>;
|
|
38
|
+
}, (cb: {
|
|
39
|
+
pendingComment: boolean;
|
|
40
|
+
selectedThreadId: string | undefined;
|
|
41
|
+
threadPositions: Map<string, {
|
|
42
|
+
from: number;
|
|
43
|
+
to: number;
|
|
44
|
+
}>;
|
|
45
|
+
}) => {
|
|
46
|
+
pendingComment: boolean;
|
|
47
|
+
selectedThreadId: string | undefined;
|
|
48
|
+
threadPositions: Map<string, {
|
|
49
|
+
from: number;
|
|
50
|
+
to: number;
|
|
51
|
+
}>;
|
|
52
|
+
}>;
|
|
53
|
+
readonly prosemirrorPlugins: readonly [Plugin<CommentsPluginState>];
|
|
54
|
+
readonly threadStore: ThreadStore;
|
|
55
|
+
readonly mount: () => () => void;
|
|
56
|
+
readonly selectThread: (threadId: string | undefined, scrollToThread?: boolean) => void;
|
|
57
|
+
readonly startPendingComment: () => void;
|
|
58
|
+
readonly stopPendingComment: () => void;
|
|
59
|
+
readonly createThread: (options: {
|
|
60
|
+
initialComment: {
|
|
61
|
+
body: CommentBody;
|
|
62
|
+
metadata?: any;
|
|
63
|
+
};
|
|
64
|
+
metadata?: any;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
readonly userStore: UserStore<User>;
|
|
67
|
+
readonly commentEditorSchema: CustomBlockNoteSchema<any, any, any> | undefined;
|
|
68
|
+
readonly tiptapExtensions: readonly [import("@tiptap/core").Mark<any, any>];
|
|
69
|
+
}>;
|
|
70
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { User } from "
|
|
2
|
-
import { EventEmitter } from "
|
|
1
|
+
import type { User } from "../types.js";
|
|
2
|
+
import { EventEmitter } from "../../util/EventEmitter.js";
|
|
3
3
|
/**
|
|
4
4
|
* The `UserStore` is used to retrieve and cache information about users.
|
|
5
5
|
*
|