@blocknote/core 0.10.1 → 0.11.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/README.md +1 -1
- package/dist/blocknote.js +1536 -1457
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +6 -6
- package/dist/blocknote.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +2 -2
- package/src/api/blockManipulation/blockManipulation.ts +144 -30
- package/src/api/exporters/copyExtension.ts +97 -24
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/button/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +1 -1
- package/src/api/exporters/html/util/sharedHTMLConversion.ts +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +0 -1
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +9 -0
- package/src/api/parsers/pasteExtension.ts +0 -1
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +19 -19
- package/src/editor/Block.css +19 -14
- package/src/editor/BlockNoteEditor.ts +11 -11
- package/src/extensions/NonEditableBlocks/NonEditableBlockPlugin.ts +12 -1
- package/src/extensions/SideMenu/SideMenuPlugin.ts +2 -2
- package/src/extensions/TableHandles/TableHandlesPlugin.ts +3 -1
- package/src/pm-nodes/BlockContainer.ts +1 -1
- package/types/src/api/blockManipulation/blockManipulation.d.ts +8 -6
- package/types/src/editor/BlockNoteEditor.d.ts +9 -6
|
@@ -268,6 +268,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
268
268
|
"attrs": {
|
|
269
269
|
"class": null,
|
|
270
270
|
"href": "https://www.website.com",
|
|
271
|
+
"rel": "noopener noreferrer nofollow",
|
|
271
272
|
"target": "_blank",
|
|
272
273
|
},
|
|
273
274
|
"type": "link",
|
|
@@ -285,6 +286,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
285
286
|
"attrs": {
|
|
286
287
|
"class": null,
|
|
287
288
|
"href": "https://www.website2.com",
|
|
289
|
+
"rel": "noopener noreferrer nofollow",
|
|
288
290
|
"target": "_blank",
|
|
289
291
|
},
|
|
290
292
|
"type": "link",
|
|
@@ -348,6 +350,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
348
350
|
"attrs": {
|
|
349
351
|
"class": null,
|
|
350
352
|
"href": "https://www.website.com",
|
|
353
|
+
"rel": "noopener noreferrer nofollow",
|
|
351
354
|
"target": "_blank",
|
|
352
355
|
},
|
|
353
356
|
"type": "link",
|
|
@@ -365,6 +368,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
365
368
|
"attrs": {
|
|
366
369
|
"class": null,
|
|
367
370
|
"href": "https://www.website.com",
|
|
371
|
+
"rel": "noopener noreferrer nofollow",
|
|
368
372
|
"target": "_blank",
|
|
369
373
|
},
|
|
370
374
|
"type": "link",
|
|
@@ -618,6 +622,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
618
622
|
"attrs": {
|
|
619
623
|
"class": null,
|
|
620
624
|
"href": "https://www.website.com",
|
|
625
|
+
"rel": "noopener noreferrer nofollow",
|
|
621
626
|
"target": "_blank",
|
|
622
627
|
},
|
|
623
628
|
"type": "link",
|
|
@@ -632,6 +637,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
632
637
|
"attrs": {
|
|
633
638
|
"class": null,
|
|
634
639
|
"href": "https://www.website2.com",
|
|
640
|
+
"rel": "noopener noreferrer nofollow",
|
|
635
641
|
"target": "_blank",
|
|
636
642
|
},
|
|
637
643
|
"type": "link",
|
|
@@ -667,6 +673,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
667
673
|
"attrs": {
|
|
668
674
|
"class": null,
|
|
669
675
|
"href": "https://www.website.com",
|
|
676
|
+
"rel": "noopener noreferrer nofollow",
|
|
670
677
|
"target": "_blank",
|
|
671
678
|
},
|
|
672
679
|
"type": "link",
|
|
@@ -705,6 +712,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
705
712
|
"attrs": {
|
|
706
713
|
"class": null,
|
|
707
714
|
"href": "https://www.website.com",
|
|
715
|
+
"rel": "noopener noreferrer nofollow",
|
|
708
716
|
"target": "_blank",
|
|
709
717
|
},
|
|
710
718
|
"type": "link",
|
|
@@ -719,6 +727,7 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
719
727
|
"attrs": {
|
|
720
728
|
"class": null,
|
|
721
729
|
"href": "https://www.website.com",
|
|
730
|
+
"rel": "noopener noreferrer nofollow",
|
|
722
731
|
"target": "_blank",
|
|
723
732
|
},
|
|
724
733
|
"type": "link",
|
|
@@ -69,7 +69,6 @@ export const renderImage = (
|
|
|
69
69
|
// Button element that acts as a placeholder for images with no src.
|
|
70
70
|
const addImageButton = document.createElement("div");
|
|
71
71
|
addImageButton.className = "bn-add-image-button";
|
|
72
|
-
addImageButton.style.display = block.props.url === "" ? "" : "none";
|
|
73
72
|
|
|
74
73
|
// Icon for the add image button.
|
|
75
74
|
const addImageButtonIcon = document.createElement("div");
|
|
@@ -83,12 +82,10 @@ export const renderImage = (
|
|
|
83
82
|
// Wrapper element for the image, resize handles and caption.
|
|
84
83
|
const imageAndCaptionWrapper = document.createElement("div");
|
|
85
84
|
imageAndCaptionWrapper.className = "bn-image-and-caption-wrapper";
|
|
86
|
-
imageAndCaptionWrapper.style.display = block.props.url !== "" ? "" : "none";
|
|
87
85
|
|
|
88
86
|
// Wrapper element for the image and resize handles.
|
|
89
87
|
const imageWrapper = document.createElement("div");
|
|
90
88
|
imageWrapper.className = "bn-image-wrapper";
|
|
91
|
-
imageWrapper.style.display = block.props.url !== "" ? "" : "none";
|
|
92
89
|
|
|
93
90
|
// Image element.
|
|
94
91
|
const image = document.createElement("img");
|
|
@@ -205,8 +202,8 @@ export const renderImage = (
|
|
|
205
202
|
imageWrapper.contains(leftResizeHandle) &&
|
|
206
203
|
imageWrapper.contains(rightResizeHandle)
|
|
207
204
|
) {
|
|
208
|
-
leftResizeHandle
|
|
209
|
-
rightResizeHandle
|
|
205
|
+
imageWrapper.removeChild(leftResizeHandle);
|
|
206
|
+
imageWrapper.removeChild(rightResizeHandle);
|
|
210
207
|
}
|
|
211
208
|
|
|
212
209
|
resizeParams = undefined;
|
|
@@ -236,11 +233,11 @@ export const renderImage = (
|
|
|
236
233
|
// Shows the resize handles when hovering over the image with the cursor.
|
|
237
234
|
const imageMouseEnterHandler = () => {
|
|
238
235
|
if (editor.isEditable) {
|
|
239
|
-
leftResizeHandle
|
|
240
|
-
rightResizeHandle
|
|
236
|
+
imageWrapper.appendChild(leftResizeHandle);
|
|
237
|
+
imageWrapper.appendChild(rightResizeHandle);
|
|
241
238
|
} else {
|
|
242
|
-
leftResizeHandle
|
|
243
|
-
rightResizeHandle
|
|
239
|
+
imageWrapper.removeChild(leftResizeHandle);
|
|
240
|
+
imageWrapper.removeChild(rightResizeHandle);
|
|
244
241
|
}
|
|
245
242
|
};
|
|
246
243
|
// Hides the resize handles when the cursor leaves the image, unless the
|
|
@@ -257,8 +254,8 @@ export const renderImage = (
|
|
|
257
254
|
return;
|
|
258
255
|
}
|
|
259
256
|
|
|
260
|
-
leftResizeHandle
|
|
261
|
-
rightResizeHandle
|
|
257
|
+
imageWrapper.removeChild(leftResizeHandle);
|
|
258
|
+
imageWrapper.removeChild(rightResizeHandle);
|
|
262
259
|
};
|
|
263
260
|
|
|
264
261
|
// Sets the resize params, allowing the user to begin resizing the image by
|
|
@@ -266,8 +263,8 @@ export const renderImage = (
|
|
|
266
263
|
const leftResizeHandleMouseDownHandler = (event: MouseEvent) => {
|
|
267
264
|
event.preventDefault();
|
|
268
265
|
|
|
269
|
-
leftResizeHandle
|
|
270
|
-
rightResizeHandle
|
|
266
|
+
imageWrapper.appendChild(leftResizeHandle);
|
|
267
|
+
imageWrapper.appendChild(rightResizeHandle);
|
|
271
268
|
|
|
272
269
|
resizeParams = {
|
|
273
270
|
handleUsed: "left",
|
|
@@ -278,8 +275,8 @@ export const renderImage = (
|
|
|
278
275
|
const rightResizeHandleMouseDownHandler = (event: MouseEvent) => {
|
|
279
276
|
event.preventDefault();
|
|
280
277
|
|
|
281
|
-
leftResizeHandle
|
|
282
|
-
rightResizeHandle
|
|
278
|
+
imageWrapper.appendChild(leftResizeHandle);
|
|
279
|
+
imageWrapper.appendChild(rightResizeHandle);
|
|
283
280
|
|
|
284
281
|
resizeParams = {
|
|
285
282
|
handleUsed: "right",
|
|
@@ -288,16 +285,19 @@ export const renderImage = (
|
|
|
288
285
|
};
|
|
289
286
|
};
|
|
290
287
|
|
|
291
|
-
wrapper.appendChild(addImageButton);
|
|
292
288
|
addImageButton.appendChild(addImageButtonIcon);
|
|
293
289
|
addImageButton.appendChild(addImageButtonText);
|
|
294
|
-
|
|
290
|
+
|
|
295
291
|
imageAndCaptionWrapper.appendChild(imageWrapper);
|
|
296
292
|
imageWrapper.appendChild(image);
|
|
297
|
-
imageWrapper.appendChild(leftResizeHandle);
|
|
298
|
-
imageWrapper.appendChild(rightResizeHandle);
|
|
299
293
|
imageAndCaptionWrapper.appendChild(caption);
|
|
300
294
|
|
|
295
|
+
if (block.props.url === "") {
|
|
296
|
+
wrapper.appendChild(addImageButton);
|
|
297
|
+
} else {
|
|
298
|
+
wrapper.appendChild(imageAndCaptionWrapper);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
301
|
window.addEventListener("mousemove", windowMouseMoveHandler);
|
|
302
302
|
window.addEventListener("mouseup", windowMouseUpHandler);
|
|
303
303
|
addImageButton.addEventListener("mousedown", addImageButtonMouseDownHandler);
|
package/src/editor/Block.css
CHANGED
|
@@ -48,7 +48,8 @@ NESTED BLOCKS
|
|
|
48
48
|
position: relative;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.bn-block-group
|
|
51
|
+
.bn-block-group
|
|
52
|
+
.bn-block-group
|
|
52
53
|
> .bn-block-outer:not([data-prev-depth-changed])::before {
|
|
53
54
|
content: " ";
|
|
54
55
|
display: inline;
|
|
@@ -58,7 +59,8 @@ NESTED BLOCKS
|
|
|
58
59
|
transition: all 0.2s 0.1s;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
.bn-block-group
|
|
62
|
+
.bn-block-group
|
|
63
|
+
.bn-block-group
|
|
62
64
|
> .bn-block-outer[data-prev-depth-change="-2"]::before {
|
|
63
65
|
height: 0;
|
|
64
66
|
}
|
|
@@ -147,6 +149,11 @@ NESTED BLOCKS
|
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
/* Ordered */
|
|
152
|
+
.bn-block-content[data-content-type="numberedListItem"] {
|
|
153
|
+
display: flex;
|
|
154
|
+
gap: 1.2em;
|
|
155
|
+
}
|
|
156
|
+
|
|
150
157
|
[data-content-type="numberedListItem"] {
|
|
151
158
|
--index: attr(data-index);
|
|
152
159
|
}
|
|
@@ -158,30 +165,31 @@ NESTED BLOCKS
|
|
|
158
165
|
.bn-block-outer[data-prev-type="numberedListItem"]:not([data-prev-index="none"])
|
|
159
166
|
> .bn-block
|
|
160
167
|
> .bn-block-content::before {
|
|
161
|
-
margin-right: 1.2em;
|
|
162
168
|
content: var(--prev-index) ".";
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
.bn-block-outer:not([data-prev-type])
|
|
166
172
|
> .bn-block
|
|
167
173
|
> .bn-block-content[data-content-type="numberedListItem"]::before {
|
|
168
|
-
margin-right: 1.2em;
|
|
169
174
|
content: var(--index) ".";
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
/* Unordered */
|
|
178
|
+
.bn-block-content[data-content-type="bulletListItem"] {
|
|
179
|
+
display: flex;
|
|
180
|
+
gap: 1.2em;
|
|
181
|
+
}
|
|
182
|
+
|
|
173
183
|
/* No list nesting */
|
|
174
184
|
.bn-block-outer[data-prev-type="bulletListItem"]
|
|
175
185
|
> .bn-block
|
|
176
186
|
> .bn-block-content::before {
|
|
177
|
-
margin-right: 1.2em;
|
|
178
187
|
content: "•";
|
|
179
188
|
}
|
|
180
189
|
|
|
181
190
|
.bn-block-outer:not([data-prev-type])
|
|
182
191
|
> .bn-block
|
|
183
192
|
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
184
|
-
margin-right: 1.2em;
|
|
185
193
|
content: "•";
|
|
186
194
|
}
|
|
187
195
|
|
|
@@ -191,7 +199,6 @@ NESTED BLOCKS
|
|
|
191
199
|
> .bn-block-outer[data-prev-type="bulletListItem"]
|
|
192
200
|
> .bn-block
|
|
193
201
|
> .bn-block-content::before {
|
|
194
|
-
margin-right: 1.2em;
|
|
195
202
|
content: "◦";
|
|
196
203
|
}
|
|
197
204
|
|
|
@@ -200,7 +207,6 @@ NESTED BLOCKS
|
|
|
200
207
|
> .bn-block-outer:not([data-prev-type])
|
|
201
208
|
> .bn-block
|
|
202
209
|
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
203
|
-
margin-right: 1.2em;
|
|
204
210
|
content: "◦";
|
|
205
211
|
}
|
|
206
212
|
|
|
@@ -212,7 +218,6 @@ NESTED BLOCKS
|
|
|
212
218
|
> .bn-block-outer[data-prev-type="bulletListItem"]
|
|
213
219
|
> .bn-block
|
|
214
220
|
> .bn-block-content::before {
|
|
215
|
-
margin-right: 1.2em;
|
|
216
221
|
content: "▪";
|
|
217
222
|
}
|
|
218
223
|
|
|
@@ -223,7 +228,6 @@ NESTED BLOCKS
|
|
|
223
228
|
> .bn-block-outer:not([data-prev-type])
|
|
224
229
|
> .bn-block
|
|
225
230
|
> .bn-block-content[data-content-type="bulletListItem"]::before {
|
|
226
|
-
margin-right: 1.2em;
|
|
227
231
|
content: "▪";
|
|
228
232
|
}
|
|
229
233
|
|
|
@@ -283,7 +287,6 @@ NESTED BLOCKS
|
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
[data-content-type="image"] .bn-image-resize-handle {
|
|
286
|
-
display: none;
|
|
287
290
|
position: absolute;
|
|
288
291
|
width: 8px;
|
|
289
292
|
height: 30px;
|
|
@@ -294,7 +297,7 @@ NESTED BLOCKS
|
|
|
294
297
|
}
|
|
295
298
|
|
|
296
299
|
[data-content-type="image"] .caption {
|
|
297
|
-
font-size: 0.8em
|
|
300
|
+
font-size: 0.8em;
|
|
298
301
|
}
|
|
299
302
|
|
|
300
303
|
/* PLACEHOLDERS*/
|
|
@@ -327,12 +330,14 @@ NESTED BLOCKS
|
|
|
327
330
|
|
|
328
331
|
.bn-block-content[data-content-type="bulletListItem"].bn-is-empty
|
|
329
332
|
.bn-inline-content:before,
|
|
330
|
-
|
|
333
|
+
.bn-block-content[data-content-type="numberedListItem"].bn-is-empty
|
|
331
334
|
.bn-inline-content:before {
|
|
332
335
|
content: "List";
|
|
333
336
|
}
|
|
334
337
|
|
|
335
|
-
.bn-is-empty
|
|
338
|
+
.bn-is-empty
|
|
339
|
+
.bn-block-content[data-content-type="captionedImage"]
|
|
340
|
+
.bn-inline-content:before {
|
|
336
341
|
content: "Caption";
|
|
337
342
|
}
|
|
338
343
|
|
|
@@ -21,11 +21,11 @@ import { HTMLToBlocks } from "../api/parsers/html/parseHTML";
|
|
|
21
21
|
import { markdownToBlocks } from "../api/parsers/markdown/parseMarkdown";
|
|
22
22
|
import {
|
|
23
23
|
DefaultBlockSchema,
|
|
24
|
-
DefaultInlineContentSchema,
|
|
25
|
-
DefaultStyleSchema,
|
|
26
24
|
defaultBlockSchema,
|
|
27
25
|
defaultBlockSpecs,
|
|
26
|
+
DefaultInlineContentSchema,
|
|
28
27
|
defaultInlineContentSpecs,
|
|
28
|
+
DefaultStyleSchema,
|
|
29
29
|
defaultStyleSpecs,
|
|
30
30
|
} from "../blocks/defaultBlocks";
|
|
31
31
|
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
@@ -45,17 +45,17 @@ import {
|
|
|
45
45
|
BlockSchemaFromSpecs,
|
|
46
46
|
BlockSchemaWithBlock,
|
|
47
47
|
BlockSpecs,
|
|
48
|
+
getBlockSchemaFromSpecs,
|
|
49
|
+
getInlineContentSchemaFromSpecs,
|
|
50
|
+
getStyleSchemaFromSpecs,
|
|
48
51
|
InlineContentSchema,
|
|
49
52
|
InlineContentSchemaFromSpecs,
|
|
50
53
|
InlineContentSpecs,
|
|
51
54
|
PartialBlock,
|
|
55
|
+
Styles,
|
|
52
56
|
StyleSchema,
|
|
53
57
|
StyleSchemaFromSpecs,
|
|
54
58
|
StyleSpecs,
|
|
55
|
-
Styles,
|
|
56
|
-
getBlockSchemaFromSpecs,
|
|
57
|
-
getInlineContentSchemaFromSpecs,
|
|
58
|
-
getStyleSchemaFromSpecs,
|
|
59
59
|
} from "../schema";
|
|
60
60
|
import { mergeCSSClasses } from "../util/browser";
|
|
61
61
|
import { UnreachableCaseError } from "../util/typescript";
|
|
@@ -775,8 +775,8 @@ export class BlockNoteEditor<
|
|
|
775
775
|
blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[],
|
|
776
776
|
referenceBlock: BlockIdentifier,
|
|
777
777
|
placement: "before" | "after" | "nested" = "before"
|
|
778
|
-
)
|
|
779
|
-
insertBlocks(blocksToInsert, referenceBlock, placement, this);
|
|
778
|
+
) {
|
|
779
|
+
return insertBlocks(blocksToInsert, referenceBlock, placement, this);
|
|
780
780
|
}
|
|
781
781
|
|
|
782
782
|
/**
|
|
@@ -790,7 +790,7 @@ export class BlockNoteEditor<
|
|
|
790
790
|
blockToUpdate: BlockIdentifier,
|
|
791
791
|
update: PartialBlock<BSchema, ISchema, SSchema>
|
|
792
792
|
) {
|
|
793
|
-
updateBlock(blockToUpdate, update, this
|
|
793
|
+
return updateBlock(blockToUpdate, update, this);
|
|
794
794
|
}
|
|
795
795
|
|
|
796
796
|
/**
|
|
@@ -798,7 +798,7 @@ export class BlockNoteEditor<
|
|
|
798
798
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
799
799
|
*/
|
|
800
800
|
public removeBlocks(blocksToRemove: BlockIdentifier[]) {
|
|
801
|
-
removeBlocks(blocksToRemove, this
|
|
801
|
+
return removeBlocks(blocksToRemove, this);
|
|
802
802
|
}
|
|
803
803
|
|
|
804
804
|
/**
|
|
@@ -812,7 +812,7 @@ export class BlockNoteEditor<
|
|
|
812
812
|
blocksToRemove: BlockIdentifier[],
|
|
813
813
|
blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[]
|
|
814
814
|
) {
|
|
815
|
-
replaceBlocks(blocksToRemove, blocksToInsert, this);
|
|
815
|
+
return replaceBlocks(blocksToRemove, blocksToInsert, this);
|
|
816
816
|
}
|
|
817
817
|
|
|
818
818
|
/**
|
|
@@ -8,8 +8,19 @@ export const NonEditableBlockPlugin = () => {
|
|
|
8
8
|
key: PLUGIN_KEY,
|
|
9
9
|
props: {
|
|
10
10
|
handleKeyDown: (view, event) => {
|
|
11
|
+
// Checks for node selection
|
|
11
12
|
if ("node" in view.state.selection) {
|
|
12
|
-
|
|
13
|
+
// Checks if key input will insert a character - we want to block this
|
|
14
|
+
// as it will convert the block into a paragraph.
|
|
15
|
+
if (
|
|
16
|
+
event.key.length === 1 &&
|
|
17
|
+
!event.ctrlKey &&
|
|
18
|
+
!event.altKey &&
|
|
19
|
+
!event.metaKey &&
|
|
20
|
+
!event.shiftKey
|
|
21
|
+
) {
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
}
|
|
13
24
|
}
|
|
14
25
|
},
|
|
15
26
|
},
|
|
@@ -547,7 +547,7 @@ export class SideMenuView<
|
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
-
const { contentNode, endPos } = blockInfo;
|
|
550
|
+
const { contentNode, startPos, endPos } = blockInfo;
|
|
551
551
|
|
|
552
552
|
// Creates a new block if current one is not empty for the suggestion menu to open in.
|
|
553
553
|
if (contentNode.textContent.length !== 0) {
|
|
@@ -561,7 +561,7 @@ export class SideMenuView<
|
|
|
561
561
|
.setTextSelection(newBlockContentPos)
|
|
562
562
|
.run();
|
|
563
563
|
} else {
|
|
564
|
-
this.editor._tiptapEditor.commands.setTextSelection(
|
|
564
|
+
this.editor._tiptapEditor.commands.setTextSelection(startPos + 1);
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
// Focuses and activates the suggestion menu.
|
|
@@ -24,7 +24,9 @@ function setHiddenDragImage() {
|
|
|
24
24
|
|
|
25
25
|
dragImageElement = document.createElement("div");
|
|
26
26
|
dragImageElement.innerHTML = "_";
|
|
27
|
-
dragImageElement.style.
|
|
27
|
+
dragImageElement.style.opacity = "0";
|
|
28
|
+
dragImageElement.style.height = "1px";
|
|
29
|
+
dragImageElement.style.width = "1px";
|
|
28
30
|
document.body.appendChild(dragImageElement);
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -567,7 +567,7 @@ export const BlockContainer = Node.create<{
|
|
|
567
567
|
state.selection.from
|
|
568
568
|
)!;
|
|
569
569
|
|
|
570
|
-
const blockAtDocEnd =
|
|
570
|
+
const blockAtDocEnd = endPos === state.doc.nodeSize - 4;
|
|
571
571
|
const selectionAtBlockEnd = state.selection.from === endPos - 1;
|
|
572
572
|
const selectionEmpty = state.selection.empty;
|
|
573
573
|
const hasChildBlocks = node.childCount === 2;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Editor } from "@tiptap/core";
|
|
2
1
|
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor";
|
|
3
|
-
import { BlockIdentifier, BlockSchema, InlineContentSchema, PartialBlock, StyleSchema } from "../../schema";
|
|
4
|
-
export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement: "before" | "after" | "nested" | undefined, editor: BlockNoteEditor<BSchema, I, S>):
|
|
5
|
-
export declare function updateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>, editor:
|
|
6
|
-
export declare function removeBlocks(blocksToRemove: BlockIdentifier[], editor:
|
|
7
|
-
export declare function replaceBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[], editor: BlockNoteEditor<BSchema, I, S>):
|
|
2
|
+
import { Block, BlockIdentifier, BlockSchema, InlineContentSchema, PartialBlock, StyleSchema } from "../../schema";
|
|
3
|
+
export declare function insertBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToInsert: PartialBlock<BSchema, I, S>[], referenceBlock: BlockIdentifier, placement: "before" | "after" | "nested" | undefined, editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>[];
|
|
4
|
+
export declare function updateBlock<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, I, S>, editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>;
|
|
5
|
+
export declare function removeBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToRemove: BlockIdentifier[], editor: BlockNoteEditor<BSchema, I, S>): Block<BSchema, I, S>[];
|
|
6
|
+
export declare function replaceBlocks<BSchema extends BlockSchema, I extends InlineContentSchema, S extends StyleSchema>(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, I, S>[], editor: BlockNoteEditor<BSchema, I, S>): {
|
|
7
|
+
insertedBlocks: Block<BSchema, I, S>[];
|
|
8
|
+
removedBlocks: Block<BSchema, I, S>[];
|
|
9
|
+
};
|
|
@@ -2,7 +2,7 @@ import { EditorOptions } from "@tiptap/core";
|
|
|
2
2
|
import { Node } from "prosemirror-model";
|
|
3
3
|
import { Editor as TiptapEditor } from "@tiptap/core/dist/packages/core/src/Editor";
|
|
4
4
|
import * as Y from "yjs";
|
|
5
|
-
import { DefaultBlockSchema,
|
|
5
|
+
import { DefaultBlockSchema, defaultBlockSpecs, DefaultInlineContentSchema, defaultInlineContentSpecs, DefaultStyleSchema, defaultStyleSpecs } from "../blocks/defaultBlocks";
|
|
6
6
|
import { FormattingToolbarProsemirrorPlugin } from "../extensions/FormattingToolbar/FormattingToolbarPlugin";
|
|
7
7
|
import { HyperlinkToolbarProsemirrorPlugin } from "../extensions/HyperlinkToolbar/HyperlinkToolbarPlugin";
|
|
8
8
|
import { ImageToolbarProsemirrorPlugin } from "../extensions/ImageToolbar/ImageToolbarPlugin";
|
|
@@ -10,7 +10,7 @@ import { SideMenuProsemirrorPlugin } from "../extensions/SideMenu/SideMenuPlugin
|
|
|
10
10
|
import { BaseSlashMenuItem } from "../extensions/SlashMenu/BaseSlashMenuItem";
|
|
11
11
|
import { SlashMenuProsemirrorPlugin } from "../extensions/SlashMenu/SlashMenuPlugin";
|
|
12
12
|
import { TableHandlesProsemirrorPlugin } from "../extensions/TableHandles/TableHandlesPlugin";
|
|
13
|
-
import { Block, BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSchemaFromSpecs, BlockSchemaWithBlock, BlockSpecs, InlineContentSchema, InlineContentSchemaFromSpecs, InlineContentSpecs, PartialBlock, StyleSchema, StyleSchemaFromSpecs, StyleSpecs
|
|
13
|
+
import { Block, BlockIdentifier, BlockNoteDOMAttributes, BlockSchema, BlockSchemaFromSpecs, BlockSchemaWithBlock, BlockSpecs, InlineContentSchema, InlineContentSchemaFromSpecs, InlineContentSpecs, PartialBlock, Styles, StyleSchema, StyleSchemaFromSpecs, StyleSpecs } from "../schema";
|
|
14
14
|
import { TextCursorPosition } from "./cursorPositionTypes";
|
|
15
15
|
import { Selection } from "./selectionTypes";
|
|
16
16
|
import "./Block.css";
|
|
@@ -187,7 +187,7 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
187
187
|
* @param placement Whether the blocks should be inserted just before, just after, or nested inside the
|
|
188
188
|
* `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
|
|
189
189
|
*/
|
|
190
|
-
insertBlocks(blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[], referenceBlock: BlockIdentifier, placement?: "before" | "after" | "nested"):
|
|
190
|
+
insertBlocks(blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[], referenceBlock: BlockIdentifier, placement?: "before" | "after" | "nested"): Block<BSchema, ISchema, SSchema>[];
|
|
191
191
|
/**
|
|
192
192
|
* Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
|
|
193
193
|
* defined. These undefined fields are kept as-is from the existing block. Throws an error if the block to update could
|
|
@@ -195,12 +195,12 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
195
195
|
* @param blockToUpdate The block that should be updated.
|
|
196
196
|
* @param update A partial block which defines how the existing block should be changed.
|
|
197
197
|
*/
|
|
198
|
-
updateBlock(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, ISchema, SSchema>):
|
|
198
|
+
updateBlock(blockToUpdate: BlockIdentifier, update: PartialBlock<BSchema, ISchema, SSchema>): Block<BSchema, ISchema, SSchema>;
|
|
199
199
|
/**
|
|
200
200
|
* Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
|
|
201
201
|
* @param blocksToRemove An array of identifiers for existing blocks that should be removed.
|
|
202
202
|
*/
|
|
203
|
-
removeBlocks(blocksToRemove: BlockIdentifier[]):
|
|
203
|
+
removeBlocks(blocksToRemove: BlockIdentifier[]): Block<BSchema, ISchema, SSchema>[];
|
|
204
204
|
/**
|
|
205
205
|
* Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
|
|
206
206
|
* are at different nesting levels, `blocksToInsert` will be inserted at the position of the first block in
|
|
@@ -208,7 +208,10 @@ export declare class BlockNoteEditor<BSchema extends BlockSchema = DefaultBlockS
|
|
|
208
208
|
* @param blocksToRemove An array of blocks that should be replaced.
|
|
209
209
|
* @param blocksToInsert An array of partial blocks to replace the old ones with.
|
|
210
210
|
*/
|
|
211
|
-
replaceBlocks(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[]):
|
|
211
|
+
replaceBlocks(blocksToRemove: BlockIdentifier[], blocksToInsert: PartialBlock<BSchema, ISchema, SSchema>[]): {
|
|
212
|
+
insertedBlocks: Block<BSchema, ISchema, SSchema>[];
|
|
213
|
+
removedBlocks: Block<BSchema, ISchema, SSchema>[];
|
|
214
|
+
};
|
|
212
215
|
/**
|
|
213
216
|
* Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
|
|
214
217
|
*/
|