@blocknote/core 0.3.0 → 0.4.2

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.
Files changed (95) hide show
  1. package/dist/blocknote.js +12698 -1341
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +50 -1
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +16 -5
  7. package/src/BlockNoteEditor.test.ts +12 -0
  8. package/src/BlockNoteEditor.ts +39 -15
  9. package/src/BlockNoteExtensions.ts +36 -32
  10. package/src/api/Editor.ts +226 -0
  11. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +616 -0
  12. package/src/api/blockManipulation/blockManipulation.test.ts +172 -0
  13. package/src/api/blockManipulation/blockManipulation.ts +125 -0
  14. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +346 -0
  15. package/src/api/formatConversions/formatConversions.test.ts +766 -0
  16. package/src/api/formatConversions/formatConversions.ts +86 -0
  17. package/src/api/formatConversions/removeUnderlinesRehypePlugin.ts +39 -0
  18. package/src/api/formatConversions/simplifyBlocksRehypePlugin.ts +125 -0
  19. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +268 -0
  20. package/src/api/nodeConversions/nodeConversions.test.ts +244 -0
  21. package/src/api/nodeConversions/nodeConversions.ts +279 -0
  22. package/src/api/nodeConversions/testUtil.ts +61 -0
  23. package/src/api/util/nodeUtil.ts +38 -0
  24. package/src/editor.module.css +8 -1
  25. package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +7 -1
  26. package/src/extensions/Blocks/api/blockTypes.ts +90 -0
  27. package/src/extensions/Blocks/api/cursorPositionTypes.ts +5 -0
  28. package/src/extensions/Blocks/api/inlineContentTypes.ts +35 -0
  29. package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +4 -4
  30. package/src/extensions/Blocks/nodes/Block.module.css +39 -36
  31. package/src/extensions/Blocks/nodes/BlockContainer.ts +74 -23
  32. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +23 -5
  33. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +28 -6
  34. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +149 -87
  35. package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +2 -2
  36. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +3 -3
  37. package/src/extensions/SlashMenu/SlashMenuExtension.ts +7 -12
  38. package/src/extensions/SlashMenu/SlashMenuItem.ts +4 -1
  39. package/src/extensions/SlashMenu/{defaultCommands.tsx → defaultSlashCommands.tsx} +34 -17
  40. package/src/extensions/SlashMenu/index.ts +7 -4
  41. package/src/extensions/UniqueID/UniqueID.ts +1 -1
  42. package/src/index.ts +4 -2
  43. package/src/shared/utils.ts +6 -0
  44. package/types/src/BlockNoteEditor.d.ts +13 -4
  45. package/types/src/BlockNoteEditor.test.d.ts +1 -0
  46. package/types/src/BlockNoteExtensions.d.ts +7 -3
  47. package/types/src/api/Editor.d.ts +93 -0
  48. package/types/src/api/blockManipulation/blockManipulation.d.ts +6 -0
  49. package/types/src/api/blockManipulation/blockManipulation.test.d.ts +1 -0
  50. package/types/src/api/formatConversions/formatConversions.d.ts +6 -0
  51. package/types/src/api/formatConversions/formatConversions.test.d.ts +1 -0
  52. package/types/src/api/formatConversions/removeUnderlinesRehypePlugin.d.ts +6 -0
  53. package/types/src/api/formatConversions/simplifyBlocksRehypePlugin.d.ts +16 -0
  54. package/types/src/api/nodeConversions/nodeConversions.d.ts +15 -0
  55. package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
  56. package/types/src/api/nodeConversions/testUtil.d.ts +2 -0
  57. package/types/src/api/util/nodeUtil.d.ts +8 -0
  58. package/types/src/extensions/Blocks/api/blockTypes.d.ts +37 -0
  59. package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +4 -0
  60. package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +29 -0
  61. package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +3 -3
  62. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +15 -0
  63. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +2 -2
  64. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +1 -3
  65. package/types/src/extensions/SlashMenu/SlashMenuItem.d.ts +4 -1
  66. package/types/src/extensions/SlashMenu/index.d.ts +3 -3
  67. package/types/src/index.d.ts +4 -2
  68. package/types/src/shared/utils.d.ts +3 -0
  69. package/src/extensions/Blocks/apiTypes.ts +0 -48
  70. package/types/src/EditorElement.d.ts +0 -7
  71. package/types/src/api/Document.d.ts +0 -5
  72. package/types/src/extensions/Blocks/BlockAttributes.d.ts +0 -2
  73. package/types/src/extensions/Blocks/MultipleNodeSelection.d.ts +0 -24
  74. package/types/src/extensions/Blocks/apiTypes.d.ts +0 -16
  75. package/types/src/extensions/Blocks/nodes/Block.d.ts +0 -24
  76. package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +0 -4
  77. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +0 -4
  78. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +0 -2
  79. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +0 -2
  80. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +0 -2
  81. package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +0 -8
  82. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +0 -8
  83. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +0 -2
  84. package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +0 -6
  85. package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +0 -8
  86. package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +0 -27
  87. package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +0 -44
  88. package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +0 -12
  89. package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +0 -18
  90. package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +0 -8
  91. package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +0 -11
  92. package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +0 -11
  93. package/types/src/extensions/Paragraph/FixedParagraph.d.ts +0 -1
  94. package/types/src/extensions/SlashMenu/defaultCommands.d.ts +0 -8
  95. package/types/src/utils.d.ts +0 -2
@@ -0,0 +1,616 @@
1
+ // Vitest Snapshot v1
2
+
3
+ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blocks 1`] = `
4
+ [
5
+ {
6
+ "children": [
7
+ {
8
+ "children": [],
9
+ "content": [
10
+ {
11
+ "styles": {},
12
+ "text": "Nested Heading 1",
13
+ "type": "text",
14
+ },
15
+ ],
16
+ "id": 2,
17
+ "props": {
18
+ "backgroundColor": "default",
19
+ "level": "1",
20
+ "textAlignment": "left",
21
+ "textColor": "default",
22
+ },
23
+ "type": "heading",
24
+ },
25
+ ],
26
+ "content": [
27
+ {
28
+ "styles": {},
29
+ "text": "Heading 1",
30
+ "type": "text",
31
+ },
32
+ ],
33
+ "id": 1,
34
+ "props": {
35
+ "backgroundColor": "default",
36
+ "level": "1",
37
+ "textAlignment": "left",
38
+ "textColor": "default",
39
+ },
40
+ "type": "heading",
41
+ },
42
+ {
43
+ "children": [
44
+ {
45
+ "children": [],
46
+ "content": [
47
+ {
48
+ "styles": {},
49
+ "text": "Nested Heading 2",
50
+ "type": "text",
51
+ },
52
+ ],
53
+ "id": 4,
54
+ "props": {
55
+ "backgroundColor": "default",
56
+ "level": "2",
57
+ "textAlignment": "left",
58
+ "textColor": "default",
59
+ },
60
+ "type": "heading",
61
+ },
62
+ ],
63
+ "content": [
64
+ {
65
+ "styles": {},
66
+ "text": "Heading 2",
67
+ "type": "text",
68
+ },
69
+ ],
70
+ "id": 3,
71
+ "props": {
72
+ "backgroundColor": "default",
73
+ "level": "2",
74
+ "textAlignment": "left",
75
+ "textColor": "default",
76
+ },
77
+ "type": "heading",
78
+ },
79
+ {
80
+ "children": [],
81
+ "content": [],
82
+ "id": 0,
83
+ "props": {
84
+ "backgroundColor": "default",
85
+ "textAlignment": "left",
86
+ "textColor": "default",
87
+ },
88
+ "type": "paragraph",
89
+ },
90
+ ]
91
+ `;
92
+
93
+ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blocks 2`] = `
94
+ [
95
+ {
96
+ "children": [
97
+ {
98
+ "children": [],
99
+ "content": [
100
+ {
101
+ "styles": {},
102
+ "text": "Nested Heading 1",
103
+ "type": "text",
104
+ },
105
+ ],
106
+ "id": 2,
107
+ "props": {
108
+ "backgroundColor": "default",
109
+ "level": "1",
110
+ "textAlignment": "left",
111
+ "textColor": "default",
112
+ },
113
+ "type": "heading",
114
+ },
115
+ ],
116
+ "content": [
117
+ {
118
+ "styles": {},
119
+ "text": "Heading 1",
120
+ "type": "text",
121
+ },
122
+ ],
123
+ "id": 1,
124
+ "props": {
125
+ "backgroundColor": "default",
126
+ "textAlignment": "left",
127
+ "textColor": "default",
128
+ },
129
+ "type": "paragraph",
130
+ },
131
+ {
132
+ "children": [
133
+ {
134
+ "children": [],
135
+ "content": [
136
+ {
137
+ "styles": {},
138
+ "text": "Nested Heading 2",
139
+ "type": "text",
140
+ },
141
+ ],
142
+ "id": 4,
143
+ "props": {
144
+ "backgroundColor": "default",
145
+ "level": "2",
146
+ "textAlignment": "left",
147
+ "textColor": "default",
148
+ },
149
+ "type": "heading",
150
+ },
151
+ ],
152
+ "content": [
153
+ {
154
+ "styles": {},
155
+ "text": "Heading 2",
156
+ "type": "text",
157
+ },
158
+ ],
159
+ "id": 3,
160
+ "props": {
161
+ "backgroundColor": "default",
162
+ "level": "2",
163
+ "textAlignment": "left",
164
+ "textColor": "default",
165
+ },
166
+ "type": "heading",
167
+ },
168
+ {
169
+ "children": [],
170
+ "content": [],
171
+ "id": 0,
172
+ "props": {
173
+ "backgroundColor": "default",
174
+ "textAlignment": "left",
175
+ "textColor": "default",
176
+ },
177
+ "type": "paragraph",
178
+ },
179
+ ]
180
+ `;
181
+
182
+ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete multiple blocks 3`] = `
183
+ [
184
+ {
185
+ "children": [],
186
+ "content": [
187
+ {
188
+ "styles": {},
189
+ "text": "Heading 1",
190
+ "type": "text",
191
+ },
192
+ ],
193
+ "id": 1,
194
+ "props": {
195
+ "backgroundColor": "default",
196
+ "textAlignment": "left",
197
+ "textColor": "default",
198
+ },
199
+ "type": "paragraph",
200
+ },
201
+ {
202
+ "children": [],
203
+ "content": [],
204
+ "id": 0,
205
+ "props": {
206
+ "backgroundColor": "default",
207
+ "textAlignment": "left",
208
+ "textColor": "default",
209
+ },
210
+ "type": "paragraph",
211
+ },
212
+ ]
213
+ `;
214
+
215
+ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete single block 1`] = `
216
+ [
217
+ {
218
+ "children": [],
219
+ "content": [
220
+ {
221
+ "styles": {},
222
+ "text": "Paragraph",
223
+ "type": "text",
224
+ },
225
+ ],
226
+ "id": 1,
227
+ "props": {
228
+ "backgroundColor": "default",
229
+ "textAlignment": "left",
230
+ "textColor": "default",
231
+ },
232
+ "type": "paragraph",
233
+ },
234
+ {
235
+ "children": [],
236
+ "content": [],
237
+ "id": 0,
238
+ "props": {
239
+ "backgroundColor": "default",
240
+ "textAlignment": "left",
241
+ "textColor": "default",
242
+ },
243
+ "type": "paragraph",
244
+ },
245
+ ]
246
+ `;
247
+
248
+ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete single block 2`] = `
249
+ [
250
+ {
251
+ "children": [
252
+ {
253
+ "children": [],
254
+ "content": [
255
+ {
256
+ "styles": {},
257
+ "text": "Paragraph",
258
+ "type": "text",
259
+ },
260
+ ],
261
+ "id": 2,
262
+ "props": {
263
+ "backgroundColor": "default",
264
+ "textAlignment": "left",
265
+ "textColor": "default",
266
+ },
267
+ "type": "paragraph",
268
+ },
269
+ ],
270
+ "content": [
271
+ {
272
+ "styles": {
273
+ "textColor": "red",
274
+ },
275
+ "text": "Heading ",
276
+ "type": "text",
277
+ },
278
+ {
279
+ "styles": {
280
+ "backgroundColor": "red",
281
+ },
282
+ "text": "3",
283
+ "type": "text",
284
+ },
285
+ ],
286
+ "id": 1,
287
+ "props": {
288
+ "backgroundColor": "default",
289
+ "level": "3",
290
+ "textAlignment": "right",
291
+ "textColor": "default",
292
+ },
293
+ "type": "heading",
294
+ },
295
+ {
296
+ "children": [],
297
+ "content": [],
298
+ "id": 0,
299
+ "props": {
300
+ "backgroundColor": "default",
301
+ "textAlignment": "left",
302
+ "textColor": "default",
303
+ },
304
+ "type": "paragraph",
305
+ },
306
+ ]
307
+ `;
308
+
309
+ exports[`Insert, Update, & Delete Blocks > Insert, update, & delete single block 3`] = `
310
+ [
311
+ {
312
+ "children": [],
313
+ "content": [],
314
+ "id": 0,
315
+ "props": {
316
+ "backgroundColor": "default",
317
+ "textAlignment": "left",
318
+ "textColor": "default",
319
+ },
320
+ "type": "paragraph",
321
+ },
322
+ ]
323
+ `;
324
+
325
+ exports[`Inserting Blocks with Different Placements > Insert after existing block 1`] = `
326
+ [
327
+ {
328
+ "children": [],
329
+ "content": [],
330
+ "id": 0,
331
+ "props": {
332
+ "backgroundColor": "default",
333
+ "textAlignment": "left",
334
+ "textColor": "default",
335
+ },
336
+ "type": "paragraph",
337
+ },
338
+ {
339
+ "children": [
340
+ {
341
+ "children": [],
342
+ "content": [
343
+ {
344
+ "styles": {},
345
+ "text": "Nested Heading 1",
346
+ "type": "text",
347
+ },
348
+ ],
349
+ "id": 2,
350
+ "props": {
351
+ "backgroundColor": "default",
352
+ "level": "1",
353
+ "textAlignment": "left",
354
+ "textColor": "default",
355
+ },
356
+ "type": "heading",
357
+ },
358
+ ],
359
+ "content": [
360
+ {
361
+ "styles": {},
362
+ "text": "Heading 1",
363
+ "type": "text",
364
+ },
365
+ ],
366
+ "id": 1,
367
+ "props": {
368
+ "backgroundColor": "default",
369
+ "level": "1",
370
+ "textAlignment": "left",
371
+ "textColor": "default",
372
+ },
373
+ "type": "heading",
374
+ },
375
+ {
376
+ "children": [
377
+ {
378
+ "children": [],
379
+ "content": [
380
+ {
381
+ "styles": {},
382
+ "text": "Nested Heading 2",
383
+ "type": "text",
384
+ },
385
+ ],
386
+ "id": 4,
387
+ "props": {
388
+ "backgroundColor": "default",
389
+ "level": "2",
390
+ "textAlignment": "left",
391
+ "textColor": "default",
392
+ },
393
+ "type": "heading",
394
+ },
395
+ ],
396
+ "content": [
397
+ {
398
+ "styles": {},
399
+ "text": "Heading 2",
400
+ "type": "text",
401
+ },
402
+ ],
403
+ "id": 3,
404
+ "props": {
405
+ "backgroundColor": "default",
406
+ "level": "2",
407
+ "textAlignment": "left",
408
+ "textColor": "default",
409
+ },
410
+ "type": "heading",
411
+ },
412
+ {
413
+ "children": [],
414
+ "content": [],
415
+ "id": 5,
416
+ "props": {
417
+ "backgroundColor": "default",
418
+ "textAlignment": "left",
419
+ "textColor": "default",
420
+ },
421
+ "type": "paragraph",
422
+ },
423
+ ]
424
+ `;
425
+
426
+ exports[`Inserting Blocks with Different Placements > Insert before existing block 1`] = `
427
+ [
428
+ {
429
+ "children": [
430
+ {
431
+ "children": [],
432
+ "content": [
433
+ {
434
+ "styles": {},
435
+ "text": "Nested Heading 1",
436
+ "type": "text",
437
+ },
438
+ ],
439
+ "id": 2,
440
+ "props": {
441
+ "backgroundColor": "default",
442
+ "level": "1",
443
+ "textAlignment": "left",
444
+ "textColor": "default",
445
+ },
446
+ "type": "heading",
447
+ },
448
+ ],
449
+ "content": [
450
+ {
451
+ "styles": {},
452
+ "text": "Heading 1",
453
+ "type": "text",
454
+ },
455
+ ],
456
+ "id": 1,
457
+ "props": {
458
+ "backgroundColor": "default",
459
+ "level": "1",
460
+ "textAlignment": "left",
461
+ "textColor": "default",
462
+ },
463
+ "type": "heading",
464
+ },
465
+ {
466
+ "children": [
467
+ {
468
+ "children": [],
469
+ "content": [
470
+ {
471
+ "styles": {},
472
+ "text": "Nested Heading 2",
473
+ "type": "text",
474
+ },
475
+ ],
476
+ "id": 4,
477
+ "props": {
478
+ "backgroundColor": "default",
479
+ "level": "2",
480
+ "textAlignment": "left",
481
+ "textColor": "default",
482
+ },
483
+ "type": "heading",
484
+ },
485
+ ],
486
+ "content": [
487
+ {
488
+ "styles": {},
489
+ "text": "Heading 2",
490
+ "type": "text",
491
+ },
492
+ ],
493
+ "id": 3,
494
+ "props": {
495
+ "backgroundColor": "default",
496
+ "level": "2",
497
+ "textAlignment": "left",
498
+ "textColor": "default",
499
+ },
500
+ "type": "heading",
501
+ },
502
+ {
503
+ "children": [],
504
+ "content": [],
505
+ "id": 0,
506
+ "props": {
507
+ "backgroundColor": "default",
508
+ "textAlignment": "left",
509
+ "textColor": "default",
510
+ },
511
+ "type": "paragraph",
512
+ },
513
+ ]
514
+ `;
515
+
516
+ exports[`Inserting Blocks with Different Placements > Insert nested inside existing block 1`] = `
517
+ [
518
+ {
519
+ "children": [
520
+ {
521
+ "children": [
522
+ {
523
+ "children": [],
524
+ "content": [
525
+ {
526
+ "styles": {},
527
+ "text": "Nested Heading 1",
528
+ "type": "text",
529
+ },
530
+ ],
531
+ "id": 2,
532
+ "props": {
533
+ "backgroundColor": "default",
534
+ "level": "1",
535
+ "textAlignment": "left",
536
+ "textColor": "default",
537
+ },
538
+ "type": "heading",
539
+ },
540
+ ],
541
+ "content": [
542
+ {
543
+ "styles": {},
544
+ "text": "Heading 1",
545
+ "type": "text",
546
+ },
547
+ ],
548
+ "id": 1,
549
+ "props": {
550
+ "backgroundColor": "default",
551
+ "level": "1",
552
+ "textAlignment": "left",
553
+ "textColor": "default",
554
+ },
555
+ "type": "heading",
556
+ },
557
+ {
558
+ "children": [
559
+ {
560
+ "children": [],
561
+ "content": [
562
+ {
563
+ "styles": {},
564
+ "text": "Nested Heading 2",
565
+ "type": "text",
566
+ },
567
+ ],
568
+ "id": 4,
569
+ "props": {
570
+ "backgroundColor": "default",
571
+ "level": "2",
572
+ "textAlignment": "left",
573
+ "textColor": "default",
574
+ },
575
+ "type": "heading",
576
+ },
577
+ ],
578
+ "content": [
579
+ {
580
+ "styles": {},
581
+ "text": "Heading 2",
582
+ "type": "text",
583
+ },
584
+ ],
585
+ "id": 3,
586
+ "props": {
587
+ "backgroundColor": "default",
588
+ "level": "2",
589
+ "textAlignment": "left",
590
+ "textColor": "default",
591
+ },
592
+ "type": "heading",
593
+ },
594
+ ],
595
+ "content": [],
596
+ "id": 0,
597
+ "props": {
598
+ "backgroundColor": "default",
599
+ "textAlignment": "left",
600
+ "textColor": "default",
601
+ },
602
+ "type": "paragraph",
603
+ },
604
+ {
605
+ "children": [],
606
+ "content": [],
607
+ "id": 5,
608
+ "props": {
609
+ "backgroundColor": "default",
610
+ "textAlignment": "left",
611
+ "textColor": "default",
612
+ },
613
+ "type": "paragraph",
614
+ },
615
+ ]
616
+ `;