@blocknote/core 0.6.2 → 0.7.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/blocknote.js +353 -318
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +2 -2
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +21 -21
- package/src/BlockNoteEditor.ts +44 -9
- package/src/BlockNoteExtensions.ts +50 -1
- package/src/editor.module.css +32 -2
- package/src/extensions/Blocks/nodes/Block.module.css +15 -11
- package/types/src/BlockNoteEditor.d.ts +34 -2
- package/types/src/BlockNoteExtensions.d.ts +10 -0
- package/types/src/CustomBlock.d.ts +15 -0
- package/types/src/extensions/Blocks/api/alertBlock.d.ts +13 -0
- package/types/src/extensions/Blocks/api/alertBlock2.d.ts +13 -0
- package/types/src/extensions/Blocks/api/block.d.ts +15 -0
- package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +81 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableCol.d.ts +2 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableContent.d.ts +2 -0
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableRow.d.ts +2 -0
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://github.com/TypeCellOS/BlockNote",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.7.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
9
|
"types",
|
|
@@ -51,23 +51,23 @@
|
|
|
51
51
|
"@emotion/cache": "^11.10.5",
|
|
52
52
|
"@emotion/serialize": "^1.1.1",
|
|
53
53
|
"@emotion/utils": "^1.2.0",
|
|
54
|
-
"@tiptap/core": "2.0.
|
|
55
|
-
"@tiptap/extension-bold": "2.0.
|
|
56
|
-
"@tiptap/extension-code": "2.0.
|
|
57
|
-
"@tiptap/extension-collaboration": "2.0.
|
|
58
|
-
"@tiptap/extension-collaboration-cursor": "2.0.
|
|
59
|
-
"@tiptap/extension-dropcursor": "2.0.
|
|
60
|
-
"@tiptap/extension-gapcursor": "2.0.
|
|
61
|
-
"@tiptap/extension-hard-break": "2.0.
|
|
62
|
-
"@tiptap/extension-history": "2.0.
|
|
63
|
-
"@tiptap/extension-horizontal-rule": "2.0.
|
|
64
|
-
"@tiptap/extension-italic": "2.0.
|
|
65
|
-
"@tiptap/extension-link": "2.0.
|
|
66
|
-
"@tiptap/extension-paragraph": "2.0.
|
|
67
|
-
"@tiptap/extension-strike": "2.0.
|
|
68
|
-
"@tiptap/extension-text": "2.0.
|
|
69
|
-
"@tiptap/extension-underline": "2.0.
|
|
70
|
-
"@tiptap/pm": "2.0.
|
|
54
|
+
"@tiptap/core": "^2.0.3",
|
|
55
|
+
"@tiptap/extension-bold": "^2.0.3",
|
|
56
|
+
"@tiptap/extension-code": "^2.0.3",
|
|
57
|
+
"@tiptap/extension-collaboration": "^2.0.3",
|
|
58
|
+
"@tiptap/extension-collaboration-cursor": "^2.0.3",
|
|
59
|
+
"@tiptap/extension-dropcursor": "^2.0.3",
|
|
60
|
+
"@tiptap/extension-gapcursor": "^2.0.3",
|
|
61
|
+
"@tiptap/extension-hard-break": "^2.0.3",
|
|
62
|
+
"@tiptap/extension-history": "^2.0.3",
|
|
63
|
+
"@tiptap/extension-horizontal-rule": "^2.0.3",
|
|
64
|
+
"@tiptap/extension-italic": "^2.0.3",
|
|
65
|
+
"@tiptap/extension-link": "^2.0.3",
|
|
66
|
+
"@tiptap/extension-paragraph": "^2.0.3",
|
|
67
|
+
"@tiptap/extension-strike": "^2.0.3",
|
|
68
|
+
"@tiptap/extension-text": "^2.0.3",
|
|
69
|
+
"@tiptap/extension-underline": "^2.0.3",
|
|
70
|
+
"@tiptap/pm": "^2.0.3",
|
|
71
71
|
"hast-util-from-dom": "^4.2.0",
|
|
72
72
|
"lodash": "^4.17.21",
|
|
73
73
|
"rehype-parse": "^8.0.4",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"unified": "^10.1.2",
|
|
81
81
|
"uuid": "^8.3.2",
|
|
82
82
|
"y-prosemirror": "1.0.20",
|
|
83
|
-
"y-protocols": "1.0.5",
|
|
84
|
-
"yjs": "13.
|
|
83
|
+
"y-protocols": "^1.0.5",
|
|
84
|
+
"yjs": "^13.6.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/hast": "^2.3.4",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"access": "public",
|
|
110
110
|
"registry": "https://registry.npmjs.org/"
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "c0fc174529fb2bcd23c53956818ad0f451c0e65c"
|
|
113
113
|
}
|
package/src/BlockNoteEditor.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Editor, EditorOptions } from "@tiptap/core";
|
|
|
2
2
|
import { Node } from "prosemirror-model";
|
|
3
3
|
// import "./blocknote.css";
|
|
4
4
|
import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
|
|
5
|
+
import * as Y from "yjs";
|
|
5
6
|
import {
|
|
6
7
|
insertBlocks,
|
|
7
8
|
removeBlocks,
|
|
@@ -23,12 +24,12 @@ import {
|
|
|
23
24
|
BlockIdentifier,
|
|
24
25
|
PartialBlock,
|
|
25
26
|
} from "./extensions/Blocks/api/blockTypes";
|
|
27
|
+
import { TextCursorPosition } from "./extensions/Blocks/api/cursorPositionTypes";
|
|
26
28
|
import {
|
|
27
29
|
ColorStyle,
|
|
28
30
|
Styles,
|
|
29
31
|
ToggledStyle,
|
|
30
32
|
} from "./extensions/Blocks/api/inlineContentTypes";
|
|
31
|
-
import { TextCursorPosition } from "./extensions/Blocks/api/cursorPositionTypes";
|
|
32
33
|
import { Selection } from "./extensions/Blocks/api/selectionTypes";
|
|
33
34
|
import { getBlockInfoFromPos } from "./extensions/Blocks/helpers/getBlockInfoFromPos";
|
|
34
35
|
import {
|
|
@@ -37,9 +38,9 @@ import {
|
|
|
37
38
|
} from "./extensions/SlashMenu";
|
|
38
39
|
|
|
39
40
|
export type BlockNoteEditorOptions = {
|
|
40
|
-
// TODO: Figure out if enableBlockNoteExtensions
|
|
41
|
+
// TODO: Figure out if enableBlockNoteExtensions is needed and document them.
|
|
41
42
|
enableBlockNoteExtensions: boolean;
|
|
42
|
-
|
|
43
|
+
|
|
43
44
|
/**
|
|
44
45
|
* UI element factories for creating a custom UI, including custom positioning
|
|
45
46
|
* & rendering.
|
|
@@ -97,6 +98,31 @@ export type BlockNoteEditorOptions = {
|
|
|
97
98
|
*/
|
|
98
99
|
theme: "light" | "dark";
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* When enabled, allows for collaboration between multiple users.
|
|
103
|
+
*/
|
|
104
|
+
collaboration: {
|
|
105
|
+
/**
|
|
106
|
+
* The Yjs XML fragment that's used for collaboration.
|
|
107
|
+
*/
|
|
108
|
+
fragment: Y.XmlFragment;
|
|
109
|
+
/**
|
|
110
|
+
* The user info for the current user that's shown to other collaborators.
|
|
111
|
+
*/
|
|
112
|
+
user: {
|
|
113
|
+
name: string;
|
|
114
|
+
color: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* A Yjs provider (used for awareness / cursor information)
|
|
118
|
+
*/
|
|
119
|
+
provider: any;
|
|
120
|
+
/**
|
|
121
|
+
* Optional function to customize how cursors of users are rendered
|
|
122
|
+
*/
|
|
123
|
+
renderCursor?: (user: any) => HTMLElement;
|
|
124
|
+
};
|
|
125
|
+
|
|
100
126
|
// tiptap options, undocumented
|
|
101
127
|
_tiptapOptions: any;
|
|
102
128
|
};
|
|
@@ -119,23 +145,20 @@ export class BlockNoteEditor {
|
|
|
119
145
|
this._tiptapEditor.view.focus();
|
|
120
146
|
}
|
|
121
147
|
|
|
122
|
-
constructor(options: Partial<BlockNoteEditorOptions> = {}) {
|
|
148
|
+
constructor(private readonly options: Partial<BlockNoteEditorOptions> = {}) {
|
|
123
149
|
// apply defaults
|
|
124
150
|
options = {
|
|
125
151
|
defaultStyles: true,
|
|
126
152
|
...options,
|
|
127
153
|
};
|
|
128
154
|
|
|
129
|
-
const
|
|
155
|
+
const extensions = getBlockNoteExtensions({
|
|
130
156
|
editor: this,
|
|
131
157
|
uiFactories: options.uiFactories || {},
|
|
132
158
|
slashCommands: options.slashCommands || defaultSlashMenuItems,
|
|
159
|
+
collaboration: options.collaboration,
|
|
133
160
|
});
|
|
134
161
|
|
|
135
|
-
let extensions = options.disableHistoryExtension
|
|
136
|
-
? blockNoteExtensions.filter((e) => e.name !== "history")
|
|
137
|
-
: blockNoteExtensions;
|
|
138
|
-
|
|
139
162
|
const tiptapOptions: EditorOptions = {
|
|
140
163
|
// TODO: This approach to setting initial content is "cleaner" but requires the PM editor schema, which is only
|
|
141
164
|
// created after initializing the TipTap editor. Not sure it's feasible.
|
|
@@ -644,4 +667,16 @@ export class BlockNoteEditor {
|
|
|
644
667
|
public async markdownToBlocks(markdown: string): Promise<Block[]> {
|
|
645
668
|
return markdownToBlocks(markdown, this._tiptapEditor.schema);
|
|
646
669
|
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Updates the user info for the current user that's shown to other collaborators.
|
|
673
|
+
*/
|
|
674
|
+
public updateCollaborationUserInfo(user: { name: string; color: string }) {
|
|
675
|
+
if (!this.options.collaboration) {
|
|
676
|
+
throw new Error(
|
|
677
|
+
"Cannot update collaboration user info when collaboration is disabled."
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
this._tiptapEditor.commands.updateUser(user);
|
|
681
|
+
}
|
|
647
682
|
}
|
|
@@ -4,6 +4,8 @@ import { BlockNoteEditor } from "./BlockNoteEditor";
|
|
|
4
4
|
|
|
5
5
|
import { Bold } from "@tiptap/extension-bold";
|
|
6
6
|
import { Code } from "@tiptap/extension-code";
|
|
7
|
+
import Collaboration from "@tiptap/extension-collaboration";
|
|
8
|
+
import CollaborationCursor from "@tiptap/extension-collaboration-cursor";
|
|
7
9
|
import { Dropcursor } from "@tiptap/extension-dropcursor";
|
|
8
10
|
import { Gapcursor } from "@tiptap/extension-gapcursor";
|
|
9
11
|
import { HardBreak } from "@tiptap/extension-hard-break";
|
|
@@ -13,6 +15,8 @@ import { Link } from "@tiptap/extension-link";
|
|
|
13
15
|
import { Strike } from "@tiptap/extension-strike";
|
|
14
16
|
import { Text } from "@tiptap/extension-text";
|
|
15
17
|
import { Underline } from "@tiptap/extension-underline";
|
|
18
|
+
import * as Y from "yjs";
|
|
19
|
+
import styles from "./editor.module.css";
|
|
16
20
|
import { BackgroundColorExtension } from "./extensions/BackgroundColor/BackgroundColorExtension";
|
|
17
21
|
import { BackgroundColorMark } from "./extensions/BackgroundColor/BackgroundColorMark";
|
|
18
22
|
import { blocks } from "./extensions/Blocks";
|
|
@@ -46,6 +50,15 @@ export const getBlockNoteExtensions = (opts: {
|
|
|
46
50
|
editor: BlockNoteEditor;
|
|
47
51
|
uiFactories: UiFactories;
|
|
48
52
|
slashCommands: BaseSlashMenuItem[];
|
|
53
|
+
collaboration?: {
|
|
54
|
+
fragment: Y.XmlFragment;
|
|
55
|
+
user: {
|
|
56
|
+
name: string;
|
|
57
|
+
color: string;
|
|
58
|
+
};
|
|
59
|
+
provider: any;
|
|
60
|
+
renderCursor?: (user: any) => HTMLElement;
|
|
61
|
+
};
|
|
49
62
|
}) => {
|
|
50
63
|
const ret: Extensions = [
|
|
51
64
|
extensions.ClipboardTextSerializer,
|
|
@@ -90,12 +103,48 @@ export const getBlockNoteExtensions = (opts: {
|
|
|
90
103
|
...blocks,
|
|
91
104
|
|
|
92
105
|
Dropcursor.configure({ width: 5, color: "#ddeeff" }),
|
|
93
|
-
History,
|
|
94
106
|
// This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
|
|
95
107
|
// should be handled before Enter handlers in other components like splitListItem
|
|
96
108
|
TrailingNode,
|
|
97
109
|
];
|
|
98
110
|
|
|
111
|
+
if (opts.collaboration) {
|
|
112
|
+
ret.push(
|
|
113
|
+
Collaboration.configure({
|
|
114
|
+
fragment: opts.collaboration.fragment,
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
const defaultRender = (user: { color: string; name: string }) => {
|
|
118
|
+
const cursor = document.createElement("span");
|
|
119
|
+
|
|
120
|
+
cursor.classList.add(styles["collaboration-cursor__caret"]);
|
|
121
|
+
cursor.setAttribute("style", `border-color: ${user.color}`);
|
|
122
|
+
|
|
123
|
+
const label = document.createElement("span");
|
|
124
|
+
|
|
125
|
+
label.classList.add(styles["collaboration-cursor__label"]);
|
|
126
|
+
label.setAttribute("style", `background-color: ${user.color}`);
|
|
127
|
+
label.insertBefore(document.createTextNode(user.name), null);
|
|
128
|
+
|
|
129
|
+
const nonbreakingSpace1 = document.createTextNode("\u2060");
|
|
130
|
+
const nonbreakingSpace2 = document.createTextNode("\u2060");
|
|
131
|
+
cursor.insertBefore(nonbreakingSpace1, null);
|
|
132
|
+
cursor.insertBefore(label, null);
|
|
133
|
+
cursor.insertBefore(nonbreakingSpace2, null);
|
|
134
|
+
return cursor;
|
|
135
|
+
};
|
|
136
|
+
ret.push(
|
|
137
|
+
CollaborationCursor.configure({
|
|
138
|
+
user: opts.collaboration.user,
|
|
139
|
+
render: opts.collaboration.renderCursor || defaultRender,
|
|
140
|
+
provider: opts.collaboration.provider,
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
// disable history extension when collaboration is enabled as Yjs takes care of undo / redo
|
|
145
|
+
ret.push(History);
|
|
146
|
+
}
|
|
147
|
+
|
|
99
148
|
if (opts.uiFactories.blockSideMenuFactory) {
|
|
100
149
|
ret.push(
|
|
101
150
|
DraggableBlocksExtension.configure({
|
package/src/editor.module.css
CHANGED
|
@@ -38,9 +38,12 @@ Tippy popups that are appended to document.body directly
|
|
|
38
38
|
.defaultStyles h3,
|
|
39
39
|
.defaultStyles li {
|
|
40
40
|
all: unset !important;
|
|
41
|
+
flex-grow: 1 !important;
|
|
41
42
|
margin: 0;
|
|
42
43
|
padding: 0;
|
|
43
44
|
font-size: inherit;
|
|
45
|
+
/* min width to make sure cursor is always visible */
|
|
46
|
+
min-width: 2px !important;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
.defaultStyles {
|
|
@@ -54,16 +57,43 @@ Tippy popups that are appended to document.body directly
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
[data-theme="light"] {
|
|
57
|
-
background-color: #
|
|
60
|
+
background-color: #ffffff;
|
|
58
61
|
color: #444444;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
[data-theme="dark"] {
|
|
62
65
|
background-color: #444444;
|
|
63
|
-
color: #
|
|
66
|
+
color: #dddddd;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
.dragPreview {
|
|
67
70
|
position: absolute;
|
|
68
71
|
top: -1000px;
|
|
69
72
|
}
|
|
73
|
+
|
|
74
|
+
/* Give a remote user a caret */
|
|
75
|
+
.collaboration-cursor__caret {
|
|
76
|
+
border-left: 1px solid #0d0d0d;
|
|
77
|
+
border-right: 1px solid #0d0d0d;
|
|
78
|
+
margin-left: -1px;
|
|
79
|
+
margin-right: -1px;
|
|
80
|
+
pointer-events: none;
|
|
81
|
+
position: relative;
|
|
82
|
+
word-break: normal;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* Render the username above the caret */
|
|
86
|
+
.collaboration-cursor__label {
|
|
87
|
+
border-radius: 3px 3px 3px 0;
|
|
88
|
+
color: #0d0d0d;
|
|
89
|
+
font-size: 12px;
|
|
90
|
+
font-style: normal;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
left: -1px;
|
|
93
|
+
line-height: normal;
|
|
94
|
+
padding: 0.1rem 0.3rem;
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: -1.4em;
|
|
97
|
+
user-select: none;
|
|
98
|
+
white-space: nowrap;
|
|
99
|
+
}
|
|
@@ -10,7 +10,11 @@ BASIC STYLES
|
|
|
10
10
|
.blockContent {
|
|
11
11
|
padding: 3px 0;
|
|
12
12
|
transition: font-size 0.2s;
|
|
13
|
-
/*
|
|
13
|
+
/*
|
|
14
|
+
because the content elements are display: block
|
|
15
|
+
we use flex to position them next to list markers
|
|
16
|
+
*/
|
|
17
|
+
display: flex;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
.blockContent::before {
|
|
@@ -40,13 +44,17 @@ NESTED BLOCKS
|
|
|
40
44
|
transition: all 0.2s 0.1s;
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
[data-theme="light"]
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
[data-theme="light"]
|
|
48
|
+
.blockGroup
|
|
49
|
+
.blockGroup
|
|
50
|
+
> .blockOuter:not([data-prev-depth-changed])::before {
|
|
51
|
+
border-left: 1px solid #cccccc;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
[data-theme="dark"]
|
|
49
|
-
|
|
54
|
+
[data-theme="dark"]
|
|
55
|
+
.blockGroup
|
|
56
|
+
.blockGroup
|
|
57
|
+
> .blockOuter:not([data-prev-depth-changed])::before {
|
|
50
58
|
border-left: 1px solid #999999;
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -217,10 +225,6 @@ NESTED BLOCKS
|
|
|
217
225
|
|
|
218
226
|
/* PLACEHOLDERS*/
|
|
219
227
|
|
|
220
|
-
.blockContent > :first-child {
|
|
221
|
-
display: inline;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
228
|
.blockContent.isEmpty > :first-child:before,
|
|
225
229
|
.blockContent.isFilter > :first-child:before {
|
|
226
230
|
/*float: left; */
|
|
@@ -234,7 +238,7 @@ NESTED BLOCKS
|
|
|
234
238
|
|
|
235
239
|
[data-theme="light"] .blockContent.isEmpty > :first-child:before,
|
|
236
240
|
.blockContent.isFilter > :first-child:before {
|
|
237
|
-
color: #
|
|
241
|
+
color: #cccccc;
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
[data-theme="dark"] .blockContent.isEmpty > :first-child:before,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
|
|
2
|
+
import * as Y from "yjs";
|
|
2
3
|
import { UiFactories } from "./BlockNoteExtensions";
|
|
3
4
|
import { Block, BlockIdentifier, PartialBlock } from "./extensions/Blocks/api/blockTypes";
|
|
4
|
-
import { Styles } from "./extensions/Blocks/api/inlineContentTypes";
|
|
5
5
|
import { TextCursorPosition } from "./extensions/Blocks/api/cursorPositionTypes";
|
|
6
|
+
import { Styles } from "./extensions/Blocks/api/inlineContentTypes";
|
|
6
7
|
import { Selection } from "./extensions/Blocks/api/selectionTypes";
|
|
7
8
|
import { BaseSlashMenuItem } from "./extensions/SlashMenu";
|
|
8
9
|
export type BlockNoteEditorOptions = {
|
|
9
10
|
enableBlockNoteExtensions: boolean;
|
|
10
|
-
disableHistoryExtension: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* UI element factories for creating a custom UI, including custom positioning
|
|
13
13
|
* & rendering.
|
|
@@ -63,9 +63,34 @@ export type BlockNoteEditorOptions = {
|
|
|
63
63
|
* @default "light"
|
|
64
64
|
*/
|
|
65
65
|
theme: "light" | "dark";
|
|
66
|
+
/**
|
|
67
|
+
* When enabled, allows for collaboration between multiple users.
|
|
68
|
+
*/
|
|
69
|
+
collaboration: {
|
|
70
|
+
/**
|
|
71
|
+
* The Yjs XML fragment that's used for collaboration.
|
|
72
|
+
*/
|
|
73
|
+
fragment: Y.XmlFragment;
|
|
74
|
+
/**
|
|
75
|
+
* The user info for the current user that's shown to other collaborators.
|
|
76
|
+
*/
|
|
77
|
+
user: {
|
|
78
|
+
name: string;
|
|
79
|
+
color: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* A Yjs provider (used for awareness / cursor information)
|
|
83
|
+
*/
|
|
84
|
+
provider: any;
|
|
85
|
+
/**
|
|
86
|
+
* Optional function to customize how cursors of users are rendered
|
|
87
|
+
*/
|
|
88
|
+
renderCursor?: (user: any) => HTMLElement;
|
|
89
|
+
};
|
|
66
90
|
_tiptapOptions: any;
|
|
67
91
|
};
|
|
68
92
|
export declare class BlockNoteEditor {
|
|
93
|
+
private readonly options;
|
|
69
94
|
readonly _tiptapEditor: TiptapEditor & {
|
|
70
95
|
contentComponent: any;
|
|
71
96
|
};
|
|
@@ -225,4 +250,11 @@ export declare class BlockNoteEditor {
|
|
|
225
250
|
* @returns The blocks parsed from the Markdown string.
|
|
226
251
|
*/
|
|
227
252
|
markdownToBlocks(markdown: string): Promise<Block[]>;
|
|
253
|
+
/**
|
|
254
|
+
* Updates the user info for the current user that's shown to other collaborators.
|
|
255
|
+
*/
|
|
256
|
+
updateCollaborationUserInfo(user: {
|
|
257
|
+
name: string;
|
|
258
|
+
color: string;
|
|
259
|
+
}): void;
|
|
228
260
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Extensions } from "@tiptap/core";
|
|
2
2
|
import { BlockNoteEditor } from "./BlockNoteEditor";
|
|
3
|
+
import * as Y from "yjs";
|
|
3
4
|
import { BlockSideMenuFactory } from "./extensions/DraggableBlocks/BlockSideMenuFactoryTypes";
|
|
4
5
|
import { FormattingToolbarFactory } from "./extensions/FormattingToolbar/FormattingToolbarFactoryTypes";
|
|
5
6
|
import { HyperlinkToolbarFactory } from "./extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes";
|
|
@@ -18,4 +19,13 @@ export declare const getBlockNoteExtensions: (opts: {
|
|
|
18
19
|
editor: BlockNoteEditor;
|
|
19
20
|
uiFactories: UiFactories;
|
|
20
21
|
slashCommands: BaseSlashMenuItem[];
|
|
22
|
+
collaboration?: {
|
|
23
|
+
fragment: Y.XmlFragment;
|
|
24
|
+
user: {
|
|
25
|
+
name: string;
|
|
26
|
+
color: string;
|
|
27
|
+
};
|
|
28
|
+
provider: any;
|
|
29
|
+
renderCursor?: ((user: any) => HTMLElement) | undefined;
|
|
30
|
+
} | undefined;
|
|
21
31
|
}) => Extensions;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
import { NodeViewRendererProps } from "@tiptap/core";
|
|
3
|
+
export type CustomBlock = {
|
|
4
|
+
name: string;
|
|
5
|
+
priority?: number;
|
|
6
|
+
atom?: boolean;
|
|
7
|
+
selectable?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
props?: Record<string, string>;
|
|
10
|
+
element: (props: NodeViewRendererProps) => {
|
|
11
|
+
element: HTMLElement;
|
|
12
|
+
editable?: HTMLElement;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function createCustomBlock(customBlock: CustomBlock): Node<CustomBlock, any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const Alert: import("./blockTypes").BlockSpec<"alert", {
|
|
2
|
+
readonly textAlignment: {
|
|
3
|
+
default: "left";
|
|
4
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
5
|
+
};
|
|
6
|
+
readonly textColor: {
|
|
7
|
+
default: "black";
|
|
8
|
+
};
|
|
9
|
+
readonly type: {
|
|
10
|
+
readonly default: "warning";
|
|
11
|
+
readonly values: readonly ["warning", "error", "info", "success"];
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const Alert2: import("./blockTypes").BlockSpec<"alert2", {
|
|
2
|
+
readonly textAlignment: {
|
|
3
|
+
default: "left";
|
|
4
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
5
|
+
};
|
|
6
|
+
readonly textColor: {
|
|
7
|
+
default: "black";
|
|
8
|
+
};
|
|
9
|
+
readonly type: {
|
|
10
|
+
readonly default: "warning";
|
|
11
|
+
readonly values: readonly ["warning", "error", "info", "success"];
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Attribute, Extension } from "@tiptap/core";
|
|
2
|
+
import { BlockConfig, BlockSchema, BlockSpec, PropSchema, TipTapNode, TipTapNodeConfig } from "./blockTypes";
|
|
3
|
+
export declare function propsToAttributes<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">): Record<string, Attribute>;
|
|
4
|
+
export declare function parse<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">): {
|
|
5
|
+
getAttrs: (node: HTMLElement | string) => false | import("./blockTypes").Props<PSchema>;
|
|
6
|
+
}[] | {
|
|
7
|
+
tag: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare function render<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: Omit<BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>, "render">, HTMLAttributes: Record<string, any>): {
|
|
10
|
+
dom: HTMLDivElement;
|
|
11
|
+
contentDOM: HTMLDivElement | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare function createBlockSpec<BType extends string, PSchema extends PropSchema, ContainsInlineContent extends boolean, BSchema extends BlockSchema>(blockConfig: BlockConfig<BType, PSchema, ContainsInlineContent, BSchema>): BlockSpec<BType, PSchema>;
|
|
14
|
+
export declare function createTipTapBlock<Type extends string>(config: TipTapNodeConfig<Type>): TipTapNode<Type>;
|
|
15
|
+
export declare const CustomBlockSerializerExtension: Extension<any, any>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TypesMatch } from "./blockTypes";
|
|
2
|
+
export declare const defaultProps: {
|
|
3
|
+
backgroundColor: {
|
|
4
|
+
default: "transparent";
|
|
5
|
+
};
|
|
6
|
+
textColor: {
|
|
7
|
+
default: "black";
|
|
8
|
+
};
|
|
9
|
+
textAlignment: {
|
|
10
|
+
default: "left";
|
|
11
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export type DefaultProps = typeof defaultProps;
|
|
15
|
+
export declare const defaultBlockSchema: {
|
|
16
|
+
readonly paragraph: {
|
|
17
|
+
readonly propSchema: {
|
|
18
|
+
backgroundColor: {
|
|
19
|
+
default: "transparent";
|
|
20
|
+
};
|
|
21
|
+
textColor: {
|
|
22
|
+
default: "black";
|
|
23
|
+
};
|
|
24
|
+
textAlignment: {
|
|
25
|
+
default: "left";
|
|
26
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly node: import("./blockTypes").TipTapNode<"paragraph">;
|
|
30
|
+
};
|
|
31
|
+
readonly heading: {
|
|
32
|
+
readonly propSchema: {
|
|
33
|
+
readonly level: {
|
|
34
|
+
readonly default: "1";
|
|
35
|
+
readonly values: readonly ["1", "2", "3"];
|
|
36
|
+
};
|
|
37
|
+
readonly backgroundColor: {
|
|
38
|
+
default: "transparent";
|
|
39
|
+
};
|
|
40
|
+
readonly textColor: {
|
|
41
|
+
default: "black";
|
|
42
|
+
};
|
|
43
|
+
readonly textAlignment: {
|
|
44
|
+
default: "left";
|
|
45
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
readonly node: import("./blockTypes").TipTapNode<"heading">;
|
|
49
|
+
};
|
|
50
|
+
readonly bulletListItem: {
|
|
51
|
+
readonly propSchema: {
|
|
52
|
+
backgroundColor: {
|
|
53
|
+
default: "transparent";
|
|
54
|
+
};
|
|
55
|
+
textColor: {
|
|
56
|
+
default: "black";
|
|
57
|
+
};
|
|
58
|
+
textAlignment: {
|
|
59
|
+
default: "left";
|
|
60
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly node: import("./blockTypes").TipTapNode<"bulletListItem">;
|
|
64
|
+
};
|
|
65
|
+
readonly numberedListItem: {
|
|
66
|
+
readonly propSchema: {
|
|
67
|
+
backgroundColor: {
|
|
68
|
+
default: "transparent";
|
|
69
|
+
};
|
|
70
|
+
textColor: {
|
|
71
|
+
default: "black";
|
|
72
|
+
};
|
|
73
|
+
textAlignment: {
|
|
74
|
+
default: "left";
|
|
75
|
+
values: readonly ["left", "center", "right", "justify"];
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly node: import("./blockTypes").TipTapNode<"numberedListItem">;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export type DefaultBlockSchema = TypesMatch<typeof defaultBlockSchema>;
|