@blocknote/core 0.8.2 → 0.8.3
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/README.md +4 -0
- package/dist/blocknote.js +1777 -1849
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +4 -4
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/BlockNoteEditor.ts +89 -39
- package/src/BlockNoteExtensions.ts +1 -58
- package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +10 -10
- package/src/api/formatConversions/formatConversions.test.ts +587 -605
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +15 -15
- package/src/api/nodeConversions/nodeConversions.test.ts +90 -94
- package/src/extensions/Blocks/api/blockTypes.ts +3 -2
- package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +6 -0
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +101 -114
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +184 -149
- package/src/extensions/Placeholder/PlaceholderExtension.ts +2 -2
- package/src/extensions/{DraggableBlocks/DraggableBlocksPlugin.ts → SideMenu/SideMenuPlugin.ts} +181 -164
- package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +7 -30
- package/src/extensions/SlashMenu/SlashMenuPlugin.ts +51 -0
- package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +109 -0
- package/src/extensions/UniqueID/UniqueID.ts +29 -30
- package/src/index.ts +9 -8
- package/src/node_modules/.vitest/results.json +1 -0
- package/src/shared/BaseUiElementTypes.ts +8 -0
- package/src/shared/EditorElement.ts +0 -16
- package/src/shared/EventEmitter.ts +58 -0
- package/src/shared/plugins/suggestion/SuggestionItem.ts +3 -6
- package/src/shared/plugins/suggestion/SuggestionPlugin.ts +341 -403
- package/types/src/BlockNoteEditor.d.ts +18 -11
- package/types/src/BlockNoteExtensions.d.ts +0 -19
- package/types/src/EventEmitter.d.ts +11 -0
- package/types/src/extensions/Blocks/api/blockTypes.d.ts +3 -2
- package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +0 -17
- package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +26 -20
- package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +18 -24
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +0 -12
- package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +37 -10
- package/types/src/extensions/SideMenu/MultipleNodeSelection.d.ts +24 -0
- package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +79 -0
- package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +5 -18
- package/types/src/extensions/SlashMenu/SlashMenuPlugin.d.ts +13 -0
- package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +1 -69
- package/types/src/extensions/SlashMenu/index.d.ts +2 -3
- package/types/src/index.d.ts +9 -8
- package/types/src/shared/BaseUiElementTypes.d.ts +7 -0
- package/types/src/shared/EditorElement.d.ts +0 -10
- package/types/src/shared/EventEmitter.d.ts +11 -0
- package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +2 -7
- package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +12 -43
- package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +0 -29
- package/src/extensions/DraggableBlocks/DraggableBlocksExtension.ts +0 -37
- package/src/extensions/FormattingToolbar/FormattingToolbarExtension.ts +0 -37
- package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +0 -18
- package/src/extensions/HyperlinkToolbar/HyperlinkMark.ts +0 -28
- package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +0 -19
- package/src/extensions/SlashMenu/SlashMenuExtension.ts +0 -53
- package/src/extensions/SlashMenu/defaultSlashMenuItems.tsx +0 -195
- package/src/extensions/SlashMenu/index.ts +0 -5
- package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +0 -21
- package/types/src/CustomBlock.d.ts +0 -15
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableCol.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableContent.d.ts +0 -2
- package/types/src/extensions/Blocks/nodes/BlockContent/TableContent/TableRow.d.ts +0 -2
- package/types/src/extensions/Placeholder/localisation/index.d.ts +0 -2
- package/types/src/extensions/Placeholder/localisation/translation.d.ts +0 -51
- /package/src/extensions/{DraggableBlocks → SideMenu}/MultipleNodeSelection.ts +0 -0
|
@@ -4,7 +4,7 @@ exports[`Complex ProseMirror Node Conversions > Convert complex block to node 1`
|
|
|
4
4
|
{
|
|
5
5
|
"attrs": {
|
|
6
6
|
"backgroundColor": "blue",
|
|
7
|
-
"id": "
|
|
7
|
+
"id": "1",
|
|
8
8
|
"textColor": "yellow",
|
|
9
9
|
},
|
|
10
10
|
"content": [
|
|
@@ -46,7 +46,7 @@ exports[`Complex ProseMirror Node Conversions > Convert complex block to node 1`
|
|
|
46
46
|
{
|
|
47
47
|
"attrs": {
|
|
48
48
|
"backgroundColor": "red",
|
|
49
|
-
"id": "
|
|
49
|
+
"id": "2",
|
|
50
50
|
"textColor": "default",
|
|
51
51
|
},
|
|
52
52
|
"content": [
|
|
@@ -68,7 +68,7 @@ exports[`Complex ProseMirror Node Conversions > Convert complex block to node 1`
|
|
|
68
68
|
{
|
|
69
69
|
"attrs": {
|
|
70
70
|
"backgroundColor": "default",
|
|
71
|
-
"id": "
|
|
71
|
+
"id": "3",
|
|
72
72
|
"textColor": "default",
|
|
73
73
|
},
|
|
74
74
|
"content": [
|
|
@@ -154,7 +154,7 @@ exports[`Simple ProseMirror Node Conversions > Convert simple block to node 1`]
|
|
|
154
154
|
{
|
|
155
155
|
"attrs": {
|
|
156
156
|
"backgroundColor": "default",
|
|
157
|
-
"id": "
|
|
157
|
+
"id": "1",
|
|
158
158
|
"textColor": "default",
|
|
159
159
|
},
|
|
160
160
|
"content": [
|
|
@@ -173,7 +173,7 @@ exports[`Simple ProseMirror Node Conversions > Convert simple node to block 1`]
|
|
|
173
173
|
{
|
|
174
174
|
"children": [],
|
|
175
175
|
"content": [],
|
|
176
|
-
"id": "
|
|
176
|
+
"id": "1",
|
|
177
177
|
"props": {
|
|
178
178
|
"backgroundColor": "default",
|
|
179
179
|
"textAlignment": "left",
|
|
@@ -187,7 +187,7 @@ exports[`hard breaks > Convert a block with a hard break 1`] = `
|
|
|
187
187
|
{
|
|
188
188
|
"attrs": {
|
|
189
189
|
"backgroundColor": "default",
|
|
190
|
-
"id": "
|
|
190
|
+
"id": "1",
|
|
191
191
|
"textColor": "default",
|
|
192
192
|
},
|
|
193
193
|
"content": [
|
|
@@ -219,7 +219,7 @@ exports[`hard breaks > Convert a block with a hard break and different styles 1`
|
|
|
219
219
|
{
|
|
220
220
|
"attrs": {
|
|
221
221
|
"backgroundColor": "default",
|
|
222
|
-
"id": "
|
|
222
|
+
"id": "1",
|
|
223
223
|
"textColor": "default",
|
|
224
224
|
},
|
|
225
225
|
"content": [
|
|
@@ -256,7 +256,7 @@ exports[`hard breaks > Convert a block with a hard break at the end 1`] = `
|
|
|
256
256
|
{
|
|
257
257
|
"attrs": {
|
|
258
258
|
"backgroundColor": "default",
|
|
259
|
-
"id": "
|
|
259
|
+
"id": "1",
|
|
260
260
|
"textColor": "default",
|
|
261
261
|
},
|
|
262
262
|
"content": [
|
|
@@ -284,7 +284,7 @@ exports[`hard breaks > Convert a block with a hard break at the start 1`] = `
|
|
|
284
284
|
{
|
|
285
285
|
"attrs": {
|
|
286
286
|
"backgroundColor": "default",
|
|
287
|
-
"id": "
|
|
287
|
+
"id": "1",
|
|
288
288
|
"textColor": "default",
|
|
289
289
|
},
|
|
290
290
|
"content": [
|
|
@@ -312,7 +312,7 @@ exports[`hard breaks > Convert a block with a hard break between links 1`] = `
|
|
|
312
312
|
{
|
|
313
313
|
"attrs": {
|
|
314
314
|
"backgroundColor": "default",
|
|
315
|
-
"id": "
|
|
315
|
+
"id": "1",
|
|
316
316
|
"textColor": "default",
|
|
317
317
|
},
|
|
318
318
|
"content": [
|
|
@@ -364,7 +364,7 @@ exports[`hard breaks > Convert a block with a hard break in a link 1`] = `
|
|
|
364
364
|
{
|
|
365
365
|
"attrs": {
|
|
366
366
|
"backgroundColor": "default",
|
|
367
|
-
"id": "
|
|
367
|
+
"id": "1",
|
|
368
368
|
"textColor": "default",
|
|
369
369
|
},
|
|
370
370
|
"content": [
|
|
@@ -416,7 +416,7 @@ exports[`hard breaks > Convert a block with multiple hard breaks 1`] = `
|
|
|
416
416
|
{
|
|
417
417
|
"attrs": {
|
|
418
418
|
"backgroundColor": "default",
|
|
419
|
-
"id": "
|
|
419
|
+
"id": "1",
|
|
420
420
|
"textColor": "default",
|
|
421
421
|
},
|
|
422
422
|
"content": [
|
|
@@ -455,7 +455,7 @@ exports[`hard breaks > Convert a block with only a hard break 1`] = `
|
|
|
455
455
|
{
|
|
456
456
|
"attrs": {
|
|
457
457
|
"backgroundColor": "default",
|
|
458
|
-
"id": "
|
|
458
|
+
"id": "1",
|
|
459
459
|
"textColor": "default",
|
|
460
460
|
},
|
|
461
461
|
"content": [
|
|
@@ -479,7 +479,7 @@ exports[`links > Convert a block with link 1`] = `
|
|
|
479
479
|
{
|
|
480
480
|
"attrs": {
|
|
481
481
|
"backgroundColor": "default",
|
|
482
|
-
"id": "
|
|
482
|
+
"id": "1",
|
|
483
483
|
"textColor": "default",
|
|
484
484
|
},
|
|
485
485
|
"content": [
|
|
@@ -514,7 +514,7 @@ exports[`links > Convert two adjacent links in a block 1`] = `
|
|
|
514
514
|
{
|
|
515
515
|
"attrs": {
|
|
516
516
|
"backgroundColor": "default",
|
|
517
|
-
"id": "
|
|
517
|
+
"id": "1",
|
|
518
518
|
"textColor": "default",
|
|
519
519
|
},
|
|
520
520
|
"content": [
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Editor } from "@tiptap/core";
|
|
2
|
-
import { Node } from "prosemirror-model";
|
|
3
2
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
4
3
|
import { BlockNoteEditor, PartialBlock } from "../..";
|
|
5
4
|
import UniqueID from "../../extensions/UniqueID/UniqueID";
|
|
@@ -13,98 +12,11 @@ import {
|
|
|
13
12
|
let editor: BlockNoteEditor;
|
|
14
13
|
let tt: Editor;
|
|
15
14
|
|
|
16
|
-
let simpleBlock: PartialBlock<DefaultBlockSchema>;
|
|
17
|
-
let simpleNode: Node;
|
|
18
|
-
|
|
19
|
-
let complexBlock: PartialBlock<DefaultBlockSchema>;
|
|
20
|
-
let complexNode: Node;
|
|
21
|
-
|
|
22
15
|
beforeEach(() => {
|
|
23
16
|
(window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
|
|
24
17
|
|
|
25
18
|
editor = new BlockNoteEditor();
|
|
26
19
|
tt = editor._tiptapEditor;
|
|
27
|
-
|
|
28
|
-
simpleBlock = {
|
|
29
|
-
type: "paragraph",
|
|
30
|
-
};
|
|
31
|
-
simpleNode = tt.schema.nodes["blockContainer"].create(
|
|
32
|
-
{ id: UniqueID.options.generateID() },
|
|
33
|
-
tt.schema.nodes["paragraph"].create()
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
complexBlock = {
|
|
37
|
-
type: "heading",
|
|
38
|
-
props: {
|
|
39
|
-
backgroundColor: "blue",
|
|
40
|
-
textColor: "yellow",
|
|
41
|
-
textAlignment: "right",
|
|
42
|
-
level: "2",
|
|
43
|
-
},
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
type: "text",
|
|
47
|
-
text: "Heading ",
|
|
48
|
-
styles: {
|
|
49
|
-
bold: true,
|
|
50
|
-
underline: true,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "text",
|
|
55
|
-
text: "2",
|
|
56
|
-
styles: {
|
|
57
|
-
italic: true,
|
|
58
|
-
strike: true,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
children: [
|
|
63
|
-
{
|
|
64
|
-
type: "paragraph",
|
|
65
|
-
props: {
|
|
66
|
-
backgroundColor: "red",
|
|
67
|
-
},
|
|
68
|
-
content: "Paragraph",
|
|
69
|
-
children: [],
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
type: "bulletListItem",
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
};
|
|
76
|
-
complexNode = tt.schema.nodes["blockContainer"].create(
|
|
77
|
-
{
|
|
78
|
-
id: UniqueID.options.generateID(),
|
|
79
|
-
backgroundColor: "blue",
|
|
80
|
-
textColor: "yellow",
|
|
81
|
-
},
|
|
82
|
-
[
|
|
83
|
-
tt.schema.nodes["heading"].create(
|
|
84
|
-
{ textAlignment: "right", level: "2" },
|
|
85
|
-
[
|
|
86
|
-
tt.schema.text("Heading ", [
|
|
87
|
-
tt.schema.mark("bold"),
|
|
88
|
-
tt.schema.mark("underline"),
|
|
89
|
-
]),
|
|
90
|
-
tt.schema.text("2", [
|
|
91
|
-
tt.schema.mark("italic"),
|
|
92
|
-
tt.schema.mark("strike"),
|
|
93
|
-
]),
|
|
94
|
-
]
|
|
95
|
-
),
|
|
96
|
-
tt.schema.nodes["blockGroup"].create({}, [
|
|
97
|
-
tt.schema.nodes["blockContainer"].create(
|
|
98
|
-
{ id: UniqueID.options.generateID(), backgroundColor: "red" },
|
|
99
|
-
[tt.schema.nodes["paragraph"].create({}, tt.schema.text("Paragraph"))]
|
|
100
|
-
),
|
|
101
|
-
tt.schema.nodes["blockContainer"].create(
|
|
102
|
-
{ id: UniqueID.options.generateID() },
|
|
103
|
-
[tt.schema.nodes["bulletListItem"].create()]
|
|
104
|
-
),
|
|
105
|
-
]),
|
|
106
|
-
]
|
|
107
|
-
);
|
|
108
20
|
});
|
|
109
21
|
|
|
110
22
|
afterEach(() => {
|
|
@@ -117,14 +29,21 @@ afterEach(() => {
|
|
|
117
29
|
|
|
118
30
|
describe("Simple ProseMirror Node Conversions", () => {
|
|
119
31
|
it("Convert simple block to node", async () => {
|
|
120
|
-
const
|
|
32
|
+
const block: PartialBlock = {
|
|
33
|
+
type: "paragraph",
|
|
34
|
+
};
|
|
35
|
+
const firstNodeConversion = blockToNode(block, tt.schema);
|
|
121
36
|
|
|
122
37
|
expect(firstNodeConversion).toMatchSnapshot();
|
|
123
38
|
});
|
|
124
39
|
|
|
125
40
|
it("Convert simple node to block", async () => {
|
|
41
|
+
const node = tt.schema.nodes["blockContainer"].create(
|
|
42
|
+
{ id: UniqueID.options.generateID() },
|
|
43
|
+
tt.schema.nodes["paragraph"].create()
|
|
44
|
+
);
|
|
126
45
|
const firstBlockConversion = nodeToBlock<DefaultBlockSchema>(
|
|
127
|
-
|
|
46
|
+
node,
|
|
128
47
|
defaultBlockSchema
|
|
129
48
|
);
|
|
130
49
|
|
|
@@ -132,20 +51,97 @@ describe("Simple ProseMirror Node Conversions", () => {
|
|
|
132
51
|
|
|
133
52
|
const firstNodeConversion = blockToNode(firstBlockConversion, tt.schema);
|
|
134
53
|
|
|
135
|
-
expect(firstNodeConversion).toStrictEqual(
|
|
54
|
+
expect(firstNodeConversion).toStrictEqual(node);
|
|
136
55
|
});
|
|
137
56
|
});
|
|
138
57
|
|
|
139
58
|
describe("Complex ProseMirror Node Conversions", () => {
|
|
140
59
|
it("Convert complex block to node", async () => {
|
|
141
|
-
const
|
|
60
|
+
const block: PartialBlock = {
|
|
61
|
+
type: "heading",
|
|
62
|
+
props: {
|
|
63
|
+
backgroundColor: "blue",
|
|
64
|
+
textColor: "yellow",
|
|
65
|
+
textAlignment: "right",
|
|
66
|
+
level: "2",
|
|
67
|
+
},
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: "text",
|
|
71
|
+
text: "Heading ",
|
|
72
|
+
styles: {
|
|
73
|
+
bold: true,
|
|
74
|
+
underline: true,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "text",
|
|
79
|
+
text: "2",
|
|
80
|
+
styles: {
|
|
81
|
+
italic: true,
|
|
82
|
+
strike: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
children: [
|
|
87
|
+
{
|
|
88
|
+
type: "paragraph",
|
|
89
|
+
props: {
|
|
90
|
+
backgroundColor: "red",
|
|
91
|
+
},
|
|
92
|
+
content: "Paragraph",
|
|
93
|
+
children: [],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: "bulletListItem",
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
const firstNodeConversion = blockToNode(block, tt.schema);
|
|
142
101
|
|
|
143
102
|
expect(firstNodeConversion).toMatchSnapshot();
|
|
144
103
|
});
|
|
145
104
|
|
|
146
105
|
it("Convert complex node to block", async () => {
|
|
106
|
+
const node = tt.schema.nodes["blockContainer"].create(
|
|
107
|
+
{
|
|
108
|
+
id: UniqueID.options.generateID(),
|
|
109
|
+
backgroundColor: "blue",
|
|
110
|
+
textColor: "yellow",
|
|
111
|
+
},
|
|
112
|
+
[
|
|
113
|
+
tt.schema.nodes["heading"].create(
|
|
114
|
+
{ textAlignment: "right", level: "2" },
|
|
115
|
+
[
|
|
116
|
+
tt.schema.text("Heading ", [
|
|
117
|
+
tt.schema.mark("bold"),
|
|
118
|
+
tt.schema.mark("underline"),
|
|
119
|
+
]),
|
|
120
|
+
tt.schema.text("2", [
|
|
121
|
+
tt.schema.mark("italic"),
|
|
122
|
+
tt.schema.mark("strike"),
|
|
123
|
+
]),
|
|
124
|
+
]
|
|
125
|
+
),
|
|
126
|
+
tt.schema.nodes["blockGroup"].create({}, [
|
|
127
|
+
tt.schema.nodes["blockContainer"].create(
|
|
128
|
+
{ id: UniqueID.options.generateID(), backgroundColor: "red" },
|
|
129
|
+
[
|
|
130
|
+
tt.schema.nodes["paragraph"].create(
|
|
131
|
+
{},
|
|
132
|
+
tt.schema.text("Paragraph")
|
|
133
|
+
),
|
|
134
|
+
]
|
|
135
|
+
),
|
|
136
|
+
tt.schema.nodes["blockContainer"].create(
|
|
137
|
+
{ id: UniqueID.options.generateID() },
|
|
138
|
+
[tt.schema.nodes["bulletListItem"].create()]
|
|
139
|
+
),
|
|
140
|
+
]),
|
|
141
|
+
]
|
|
142
|
+
);
|
|
147
143
|
const firstBlockConversion = nodeToBlock<DefaultBlockSchema>(
|
|
148
|
-
|
|
144
|
+
node,
|
|
149
145
|
defaultBlockSchema
|
|
150
146
|
);
|
|
151
147
|
|
|
@@ -153,7 +149,7 @@ describe("Complex ProseMirror Node Conversions", () => {
|
|
|
153
149
|
|
|
154
150
|
const firstNodeConversion = blockToNode(firstBlockConversion, tt.schema);
|
|
155
151
|
|
|
156
|
-
expect(firstNodeConversion).toStrictEqual(
|
|
152
|
+
expect(firstNodeConversion).toStrictEqual(node);
|
|
157
153
|
});
|
|
158
154
|
});
|
|
159
155
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Node, NodeConfig } from "@tiptap/core";
|
|
3
3
|
import { BlockNoteEditor } from "../../../BlockNoteEditor";
|
|
4
4
|
import { InlineContent, PartialInlineContent } from "./inlineContentTypes";
|
|
5
|
+
import { DefaultBlockSchema } from "./defaultBlocks";
|
|
5
6
|
|
|
6
7
|
// A configuration for a TipTap node, but with stricter type constraints on the
|
|
7
8
|
// "name" and "group" properties. The "name" property is now always a string
|
|
@@ -143,7 +144,7 @@ type BlocksWithoutChildren<BSchema extends BlockSchema> = {
|
|
|
143
144
|
|
|
144
145
|
// Converts each block spec into a Block object without children, merges them
|
|
145
146
|
// into a union type, and adds a children property
|
|
146
|
-
export type Block<BSchema extends BlockSchema> =
|
|
147
|
+
export type Block<BSchema extends BlockSchema = DefaultBlockSchema> =
|
|
147
148
|
BlocksWithoutChildren<BSchema>[keyof BlocksWithoutChildren<BSchema>] & {
|
|
148
149
|
children: Block<BSchema>[];
|
|
149
150
|
};
|
|
@@ -168,7 +169,7 @@ type PartialBlocksWithoutChildren<BSchema extends BlockSchema> = {
|
|
|
168
169
|
|
|
169
170
|
// Same as Block, but as a partial type with some changes to make it easier to
|
|
170
171
|
// create/update blocks in the editor.
|
|
171
|
-
export type PartialBlock<BSchema extends BlockSchema> =
|
|
172
|
+
export type PartialBlock<BSchema extends BlockSchema = DefaultBlockSchema> =
|
|
172
173
|
PartialBlocksWithoutChildren<BSchema>[keyof PartialBlocksWithoutChildren<BSchema>] &
|
|
173
174
|
Partial<{
|
|
174
175
|
children: PartialBlock<BSchema>[];
|
|
@@ -26,6 +26,12 @@ export function getBlockInfoFromPos(
|
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// This gets triggered when a node selection on a block is active, i.e. when
|
|
30
|
+
// you drag and drop a block.
|
|
31
|
+
if (doc.resolve(posInBlock).parent.type.name === "blockGroup") {
|
|
32
|
+
posInBlock++;
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
const $pos = doc.resolve(posInBlock);
|
|
30
36
|
|
|
31
37
|
const maxDepth = $pos.depth;
|