@blocknote/core 0.19.1 → 0.20.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.
Files changed (109) hide show
  1. package/dist/blocknote.js +1791 -1483
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +6 -6
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js +6 -3
  6. package/dist/src/api/blockManipulation/commands/insertBlocks/insertBlocks.js.map +1 -1
  7. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js +219 -0
  8. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.js.map +1 -0
  9. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js +175 -0
  10. package/dist/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.js.map +1 -0
  11. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js +3 -0
  12. package/dist/src/api/blockManipulation/commands/splitBlock/splitBlock.test.js.map +1 -1
  13. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js +6 -3
  14. package/dist/src/api/blockManipulation/commands/updateBlock/updateBlock.js.map +1 -1
  15. package/dist/src/api/blockManipulation/getBlock/getBlock.js +56 -0
  16. package/dist/src/api/blockManipulation/getBlock/getBlock.js.map +1 -0
  17. package/dist/src/api/blockManipulation/selections/selection.js +149 -0
  18. package/dist/src/api/blockManipulation/selections/selection.js.map +1 -0
  19. package/dist/src/api/blockManipulation/selections/selection.test.js +39 -0
  20. package/dist/src/api/blockManipulation/selections/selection.test.js.map +1 -0
  21. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js +3 -0
  22. package/dist/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.js.map +1 -1
  23. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js +3 -3
  24. package/dist/src/api/clipboard/fromClipboard/handleVSCodePaste.js.map +1 -1
  25. package/dist/src/api/nodeUtil.js +1 -1
  26. package/dist/src/api/nodeUtil.js.map +1 -1
  27. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js +15 -7
  28. package/dist/src/blocks/CodeBlockContent/CodeBlockContent.js.map +1 -1
  29. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js +38 -18
  30. package/dist/src/blocks/CodeBlockContent/defaultSupportedLanguages.js.map +1 -1
  31. package/dist/src/blocks/TableBlockContent/TableExtension.js +8 -1
  32. package/dist/src/blocks/TableBlockContent/TableExtension.js.map +1 -1
  33. package/dist/src/editor/BlockNoteEditor.js +59 -57
  34. package/dist/src/editor/BlockNoteEditor.js.map +1 -1
  35. package/dist/src/editor/BlockNoteExtensions.js +2 -1
  36. package/dist/src/editor/BlockNoteExtensions.js.map +1 -1
  37. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js +4 -2
  38. package/dist/src/extensions/FormattingToolbar/FormattingToolbarPlugin.js.map +1 -1
  39. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js +10 -8
  40. package/dist/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.js.map +1 -1
  41. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js +7 -3
  42. package/dist/src/extensions/LinkToolbar/LinkToolbarPlugin.js.map +1 -1
  43. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js +13 -7
  44. package/dist/src/extensions/Placeholder/PlaceholderPlugin.js.map +1 -1
  45. package/dist/src/extensions/SideMenu/SideMenuPlugin.js +5 -1
  46. package/dist/src/extensions/SideMenu/SideMenuPlugin.js.map +1 -1
  47. package/dist/src/extensions/SideMenu/dragging.js +5 -1
  48. package/dist/src/extensions/SideMenu/dragging.js.map +1 -1
  49. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js +0 -3
  50. package/dist/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.js.map +1 -1
  51. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js +25 -8
  52. package/dist/src/extensions/TableHandles/TableHandlesPlugin.js.map +1 -1
  53. package/dist/src/i18n/locales/ru.js +1 -1
  54. package/dist/src/index.js +1 -0
  55. package/dist/src/index.js.map +1 -1
  56. package/dist/style.css +1 -1
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/dist/webpack-stats.json +1 -1
  59. package/package.json +3 -3
  60. package/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts +6 -6
  61. package/src/api/blockManipulation/commands/moveBlocks/__snapshots__/moveBlocks.test.ts.snap +9506 -0
  62. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.test.ts +295 -0
  63. package/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts +338 -0
  64. package/src/api/blockManipulation/commands/splitBlock/splitBlock.test.ts +4 -0
  65. package/src/api/blockManipulation/commands/updateBlock/updateBlock.ts +11 -3
  66. package/src/api/blockManipulation/getBlock/getBlock.ts +141 -0
  67. package/src/api/blockManipulation/selections/__snapshots__/selection.test.ts.snap +660 -0
  68. package/src/api/blockManipulation/selections/selection.test.ts +56 -0
  69. package/src/api/blockManipulation/selections/selection.ts +244 -0
  70. package/src/api/blockManipulation/selections/textCursorPosition/textCursorPosition.ts +4 -0
  71. package/src/api/clipboard/fromClipboard/handleVSCodePaste.ts +4 -4
  72. package/src/api/nodeUtil.ts +2 -2
  73. package/src/blocks/CodeBlockContent/CodeBlockContent.ts +18 -8
  74. package/src/blocks/CodeBlockContent/defaultSupportedLanguages.ts +38 -18
  75. package/src/blocks/TableBlockContent/TableExtension.ts +12 -1
  76. package/src/editor/Block.css +3 -0
  77. package/src/editor/BlockNoteEditor.ts +93 -85
  78. package/src/editor/BlockNoteExtensions.ts +3 -1
  79. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +4 -2
  80. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +11 -8
  81. package/src/extensions/LinkToolbar/LinkToolbarPlugin.ts +11 -4
  82. package/src/extensions/Placeholder/PlaceholderPlugin.ts +23 -15
  83. package/src/extensions/SideMenu/SideMenuPlugin.ts +5 -1
  84. package/src/extensions/SideMenu/dragging.ts +5 -1
  85. package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +0 -5
  86. package/src/extensions/TableHandles/TableHandlesPlugin.ts +34 -9
  87. package/src/i18n/locales/ru.ts +1 -1
  88. package/src/index.ts +1 -0
  89. package/types/src/api/blockManipulation/commands/moveBlocks/moveBlocks.d.ts +15 -0
  90. package/types/src/api/blockManipulation/getBlock/getBlock.d.ts +7 -0
  91. package/types/src/api/blockManipulation/selections/selection.d.ts +5 -0
  92. package/types/src/api/blockManipulation/selections/selection.test.d.ts +1 -0
  93. package/types/src/api/nodeUtil.d.ts +1 -1
  94. package/types/src/editor/BlockNoteEditor.d.ts +54 -10
  95. package/types/src/editor/BlockNoteExtensions.d.ts +1 -0
  96. package/types/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.d.ts +1 -0
  97. package/types/src/extensions/SideMenu/SideMenuPlugin.d.ts +1 -1
  98. package/types/src/index.d.ts +1 -0
  99. package/types/src/pm-nodes/BlockContainer.d.ts +2 -2
  100. package/types/src/pm-nodes/BlockGroup.d.ts +2 -2
  101. package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js +0 -116
  102. package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.js.map +0 -1
  103. package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js +0 -110
  104. package/dist/src/api/blockManipulation/commands/moveBlock/moveBlock.test.js.map +0 -1
  105. package/src/api/blockManipulation/commands/moveBlock/__snapshots__/moveBlock.test.ts.snap +0 -3799
  106. package/src/api/blockManipulation/commands/moveBlock/moveBlock.test.ts +0 -196
  107. package/src/api/blockManipulation/commands/moveBlock/moveBlock.ts +0 -176
  108. package/types/src/api/blockManipulation/commands/moveBlock/moveBlock.d.ts +0 -5
  109. /package/types/src/api/blockManipulation/commands/{moveBlock/moveBlock.test.d.ts → moveBlocks/moveBlocks.test.d.ts} +0 -0
@@ -0,0 +1,660 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`Test getSelection & setSelection > Basic 1`] = `
4
+ {
5
+ "blocks": [
6
+ {
7
+ "children": [],
8
+ "content": [
9
+ {
10
+ "styles": {},
11
+ "text": "Paragraph 0",
12
+ "type": "text",
13
+ },
14
+ ],
15
+ "id": "paragraph-0",
16
+ "props": {
17
+ "backgroundColor": "default",
18
+ "textAlignment": "left",
19
+ "textColor": "default",
20
+ },
21
+ "type": "paragraph",
22
+ },
23
+ {
24
+ "children": [],
25
+ "content": [
26
+ {
27
+ "styles": {},
28
+ "text": "Paragraph 1",
29
+ "type": "text",
30
+ },
31
+ ],
32
+ "id": "paragraph-1",
33
+ "props": {
34
+ "backgroundColor": "default",
35
+ "textAlignment": "left",
36
+ "textColor": "default",
37
+ },
38
+ "type": "paragraph",
39
+ },
40
+ ],
41
+ }
42
+ `;
43
+
44
+ exports[`Test getSelection & setSelection > Contains block with children 1`] = `
45
+ {
46
+ "blocks": [
47
+ {
48
+ "children": [],
49
+ "content": [
50
+ {
51
+ "styles": {},
52
+ "text": "Paragraph 1",
53
+ "type": "text",
54
+ },
55
+ ],
56
+ "id": "paragraph-1",
57
+ "props": {
58
+ "backgroundColor": "default",
59
+ "textAlignment": "left",
60
+ "textColor": "default",
61
+ },
62
+ "type": "paragraph",
63
+ },
64
+ {
65
+ "children": [
66
+ {
67
+ "children": [
68
+ {
69
+ "children": [],
70
+ "content": [
71
+ {
72
+ "styles": {},
73
+ "text": "Double Nested Paragraph 0",
74
+ "type": "text",
75
+ },
76
+ ],
77
+ "id": "double-nested-paragraph-0",
78
+ "props": {
79
+ "backgroundColor": "default",
80
+ "textAlignment": "left",
81
+ "textColor": "default",
82
+ },
83
+ "type": "paragraph",
84
+ },
85
+ ],
86
+ "content": [
87
+ {
88
+ "styles": {},
89
+ "text": "Nested Paragraph 0",
90
+ "type": "text",
91
+ },
92
+ ],
93
+ "id": "nested-paragraph-0",
94
+ "props": {
95
+ "backgroundColor": "default",
96
+ "textAlignment": "left",
97
+ "textColor": "default",
98
+ },
99
+ "type": "paragraph",
100
+ },
101
+ ],
102
+ "content": [
103
+ {
104
+ "styles": {},
105
+ "text": "Paragraph with children",
106
+ "type": "text",
107
+ },
108
+ ],
109
+ "id": "paragraph-with-children",
110
+ "props": {
111
+ "backgroundColor": "default",
112
+ "textAlignment": "left",
113
+ "textColor": "default",
114
+ },
115
+ "type": "paragraph",
116
+ },
117
+ {
118
+ "children": [],
119
+ "content": [
120
+ {
121
+ "styles": {},
122
+ "text": "Paragraph 2",
123
+ "type": "text",
124
+ },
125
+ ],
126
+ "id": "paragraph-2",
127
+ "props": {
128
+ "backgroundColor": "default",
129
+ "textAlignment": "left",
130
+ "textColor": "default",
131
+ },
132
+ "type": "paragraph",
133
+ },
134
+ ],
135
+ }
136
+ `;
137
+
138
+ exports[`Test getSelection & setSelection > Ends in block with children 1`] = `
139
+ {
140
+ "blocks": [
141
+ {
142
+ "children": [],
143
+ "content": [
144
+ {
145
+ "styles": {},
146
+ "text": "Paragraph 1",
147
+ "type": "text",
148
+ },
149
+ ],
150
+ "id": "paragraph-1",
151
+ "props": {
152
+ "backgroundColor": "default",
153
+ "textAlignment": "left",
154
+ "textColor": "default",
155
+ },
156
+ "type": "paragraph",
157
+ },
158
+ {
159
+ "children": [
160
+ {
161
+ "children": [
162
+ {
163
+ "children": [],
164
+ "content": [
165
+ {
166
+ "styles": {},
167
+ "text": "Double Nested Paragraph 0",
168
+ "type": "text",
169
+ },
170
+ ],
171
+ "id": "double-nested-paragraph-0",
172
+ "props": {
173
+ "backgroundColor": "default",
174
+ "textAlignment": "left",
175
+ "textColor": "default",
176
+ },
177
+ "type": "paragraph",
178
+ },
179
+ ],
180
+ "content": [
181
+ {
182
+ "styles": {},
183
+ "text": "Nested Paragraph 0",
184
+ "type": "text",
185
+ },
186
+ ],
187
+ "id": "nested-paragraph-0",
188
+ "props": {
189
+ "backgroundColor": "default",
190
+ "textAlignment": "left",
191
+ "textColor": "default",
192
+ },
193
+ "type": "paragraph",
194
+ },
195
+ ],
196
+ "content": [
197
+ {
198
+ "styles": {},
199
+ "text": "Paragraph with children",
200
+ "type": "text",
201
+ },
202
+ ],
203
+ "id": "paragraph-with-children",
204
+ "props": {
205
+ "backgroundColor": "default",
206
+ "textAlignment": "left",
207
+ "textColor": "default",
208
+ },
209
+ "type": "paragraph",
210
+ },
211
+ ],
212
+ }
213
+ `;
214
+
215
+ exports[`Test getSelection & setSelection > Ends in nested block 1`] = `
216
+ {
217
+ "blocks": [
218
+ {
219
+ "children": [],
220
+ "content": [
221
+ {
222
+ "styles": {},
223
+ "text": "Paragraph 1",
224
+ "type": "text",
225
+ },
226
+ ],
227
+ "id": "paragraph-1",
228
+ "props": {
229
+ "backgroundColor": "default",
230
+ "textAlignment": "left",
231
+ "textColor": "default",
232
+ },
233
+ "type": "paragraph",
234
+ },
235
+ {
236
+ "children": [
237
+ {
238
+ "children": [
239
+ {
240
+ "children": [],
241
+ "content": [
242
+ {
243
+ "styles": {},
244
+ "text": "Double Nested Paragraph 0",
245
+ "type": "text",
246
+ },
247
+ ],
248
+ "id": "double-nested-paragraph-0",
249
+ "props": {
250
+ "backgroundColor": "default",
251
+ "textAlignment": "left",
252
+ "textColor": "default",
253
+ },
254
+ "type": "paragraph",
255
+ },
256
+ ],
257
+ "content": [
258
+ {
259
+ "styles": {},
260
+ "text": "Nested Paragraph 0",
261
+ "type": "text",
262
+ },
263
+ ],
264
+ "id": "nested-paragraph-0",
265
+ "props": {
266
+ "backgroundColor": "default",
267
+ "textAlignment": "left",
268
+ "textColor": "default",
269
+ },
270
+ "type": "paragraph",
271
+ },
272
+ ],
273
+ "content": [
274
+ {
275
+ "styles": {},
276
+ "text": "Paragraph with children",
277
+ "type": "text",
278
+ },
279
+ ],
280
+ "id": "paragraph-with-children",
281
+ "props": {
282
+ "backgroundColor": "default",
283
+ "textAlignment": "left",
284
+ "textColor": "default",
285
+ },
286
+ "type": "paragraph",
287
+ },
288
+ ],
289
+ }
290
+ `;
291
+
292
+ exports[`Test getSelection & setSelection > Ends in table 1`] = `
293
+ {
294
+ "blocks": [
295
+ {
296
+ "children": [],
297
+ "content": [
298
+ {
299
+ "styles": {},
300
+ "text": "Paragraph 6",
301
+ "type": "text",
302
+ },
303
+ ],
304
+ "id": "paragraph-6",
305
+ "props": {
306
+ "backgroundColor": "default",
307
+ "textAlignment": "left",
308
+ "textColor": "default",
309
+ },
310
+ "type": "paragraph",
311
+ },
312
+ {
313
+ "children": [],
314
+ "content": {
315
+ "columnWidths": [
316
+ undefined,
317
+ undefined,
318
+ undefined,
319
+ ],
320
+ "rows": [
321
+ {
322
+ "cells": [
323
+ [
324
+ {
325
+ "styles": {},
326
+ "text": "Cell 1",
327
+ "type": "text",
328
+ },
329
+ ],
330
+ [
331
+ {
332
+ "styles": {},
333
+ "text": "Cell 2",
334
+ "type": "text",
335
+ },
336
+ ],
337
+ [
338
+ {
339
+ "styles": {},
340
+ "text": "Cell 3",
341
+ "type": "text",
342
+ },
343
+ ],
344
+ ],
345
+ },
346
+ {
347
+ "cells": [
348
+ [
349
+ {
350
+ "styles": {},
351
+ "text": "Cell 4",
352
+ "type": "text",
353
+ },
354
+ ],
355
+ [
356
+ {
357
+ "styles": {},
358
+ "text": "Cell 5",
359
+ "type": "text",
360
+ },
361
+ ],
362
+ [
363
+ {
364
+ "styles": {},
365
+ "text": "Cell 6",
366
+ "type": "text",
367
+ },
368
+ ],
369
+ ],
370
+ },
371
+ {
372
+ "cells": [
373
+ [
374
+ {
375
+ "styles": {},
376
+ "text": "Cell 7",
377
+ "type": "text",
378
+ },
379
+ ],
380
+ [
381
+ {
382
+ "styles": {},
383
+ "text": "Cell 8",
384
+ "type": "text",
385
+ },
386
+ ],
387
+ [
388
+ {
389
+ "styles": {},
390
+ "text": "Cell 9",
391
+ "type": "text",
392
+ },
393
+ ],
394
+ ],
395
+ },
396
+ ],
397
+ "type": "tableContent",
398
+ },
399
+ "id": "table-0",
400
+ "props": {
401
+ "textColor": "default",
402
+ },
403
+ "type": "table",
404
+ },
405
+ ],
406
+ }
407
+ `;
408
+
409
+ exports[`Test getSelection & setSelection > Starts in block with children 1`] = `
410
+ {
411
+ "blocks": [
412
+ {
413
+ "children": [
414
+ {
415
+ "children": [
416
+ {
417
+ "children": [],
418
+ "content": [
419
+ {
420
+ "styles": {},
421
+ "text": "Double Nested Paragraph 0",
422
+ "type": "text",
423
+ },
424
+ ],
425
+ "id": "double-nested-paragraph-0",
426
+ "props": {
427
+ "backgroundColor": "default",
428
+ "textAlignment": "left",
429
+ "textColor": "default",
430
+ },
431
+ "type": "paragraph",
432
+ },
433
+ ],
434
+ "content": [
435
+ {
436
+ "styles": {},
437
+ "text": "Nested Paragraph 0",
438
+ "type": "text",
439
+ },
440
+ ],
441
+ "id": "nested-paragraph-0",
442
+ "props": {
443
+ "backgroundColor": "default",
444
+ "textAlignment": "left",
445
+ "textColor": "default",
446
+ },
447
+ "type": "paragraph",
448
+ },
449
+ ],
450
+ "content": [
451
+ {
452
+ "styles": {},
453
+ "text": "Paragraph with children",
454
+ "type": "text",
455
+ },
456
+ ],
457
+ "id": "paragraph-with-children",
458
+ "props": {
459
+ "backgroundColor": "default",
460
+ "textAlignment": "left",
461
+ "textColor": "default",
462
+ },
463
+ "type": "paragraph",
464
+ },
465
+ {
466
+ "children": [],
467
+ "content": [
468
+ {
469
+ "styles": {},
470
+ "text": "Paragraph 2",
471
+ "type": "text",
472
+ },
473
+ ],
474
+ "id": "paragraph-2",
475
+ "props": {
476
+ "backgroundColor": "default",
477
+ "textAlignment": "left",
478
+ "textColor": "default",
479
+ },
480
+ "type": "paragraph",
481
+ },
482
+ ],
483
+ }
484
+ `;
485
+
486
+ exports[`Test getSelection & setSelection > Starts in nested block 1`] = `
487
+ {
488
+ "blocks": [
489
+ {
490
+ "children": [
491
+ {
492
+ "children": [],
493
+ "content": [
494
+ {
495
+ "styles": {},
496
+ "text": "Double Nested Paragraph 0",
497
+ "type": "text",
498
+ },
499
+ ],
500
+ "id": "double-nested-paragraph-0",
501
+ "props": {
502
+ "backgroundColor": "default",
503
+ "textAlignment": "left",
504
+ "textColor": "default",
505
+ },
506
+ "type": "paragraph",
507
+ },
508
+ ],
509
+ "content": [
510
+ {
511
+ "styles": {},
512
+ "text": "Nested Paragraph 0",
513
+ "type": "text",
514
+ },
515
+ ],
516
+ "id": "nested-paragraph-0",
517
+ "props": {
518
+ "backgroundColor": "default",
519
+ "textAlignment": "left",
520
+ "textColor": "default",
521
+ },
522
+ "type": "paragraph",
523
+ },
524
+ {
525
+ "children": [],
526
+ "content": [
527
+ {
528
+ "styles": {},
529
+ "text": "Paragraph 2",
530
+ "type": "text",
531
+ },
532
+ ],
533
+ "id": "paragraph-2",
534
+ "props": {
535
+ "backgroundColor": "default",
536
+ "textAlignment": "left",
537
+ "textColor": "default",
538
+ },
539
+ "type": "paragraph",
540
+ },
541
+ ],
542
+ }
543
+ `;
544
+
545
+ exports[`Test getSelection & setSelection > Starts in table 1`] = `
546
+ {
547
+ "blocks": [
548
+ {
549
+ "children": [],
550
+ "content": {
551
+ "columnWidths": [
552
+ undefined,
553
+ undefined,
554
+ undefined,
555
+ ],
556
+ "rows": [
557
+ {
558
+ "cells": [
559
+ [
560
+ {
561
+ "styles": {},
562
+ "text": "Cell 1",
563
+ "type": "text",
564
+ },
565
+ ],
566
+ [
567
+ {
568
+ "styles": {},
569
+ "text": "Cell 2",
570
+ "type": "text",
571
+ },
572
+ ],
573
+ [
574
+ {
575
+ "styles": {},
576
+ "text": "Cell 3",
577
+ "type": "text",
578
+ },
579
+ ],
580
+ ],
581
+ },
582
+ {
583
+ "cells": [
584
+ [
585
+ {
586
+ "styles": {},
587
+ "text": "Cell 4",
588
+ "type": "text",
589
+ },
590
+ ],
591
+ [
592
+ {
593
+ "styles": {},
594
+ "text": "Cell 5",
595
+ "type": "text",
596
+ },
597
+ ],
598
+ [
599
+ {
600
+ "styles": {},
601
+ "text": "Cell 6",
602
+ "type": "text",
603
+ },
604
+ ],
605
+ ],
606
+ },
607
+ {
608
+ "cells": [
609
+ [
610
+ {
611
+ "styles": {},
612
+ "text": "Cell 7",
613
+ "type": "text",
614
+ },
615
+ ],
616
+ [
617
+ {
618
+ "styles": {},
619
+ "text": "Cell 8",
620
+ "type": "text",
621
+ },
622
+ ],
623
+ [
624
+ {
625
+ "styles": {},
626
+ "text": "Cell 9",
627
+ "type": "text",
628
+ },
629
+ ],
630
+ ],
631
+ },
632
+ ],
633
+ "type": "tableContent",
634
+ },
635
+ "id": "table-0",
636
+ "props": {
637
+ "textColor": "default",
638
+ },
639
+ "type": "table",
640
+ },
641
+ {
642
+ "children": [],
643
+ "content": [
644
+ {
645
+ "styles": {},
646
+ "text": "Paragraph 7",
647
+ "type": "text",
648
+ },
649
+ ],
650
+ "id": "paragraph-7",
651
+ "props": {
652
+ "backgroundColor": "default",
653
+ "textAlignment": "left",
654
+ "textColor": "default",
655
+ },
656
+ "type": "paragraph",
657
+ },
658
+ ],
659
+ }
660
+ `;
@@ -0,0 +1,56 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { setupTestEnv } from "../setupTestEnv.js";
4
+ import { getSelection, setSelection } from "./selection.js";
5
+
6
+ const getEditor = setupTestEnv();
7
+
8
+ describe("Test getSelection & setSelection", () => {
9
+ it("Basic", () => {
10
+ setSelection(getEditor(), "paragraph-0", "paragraph-1");
11
+
12
+ expect(getSelection(getEditor())).toMatchSnapshot();
13
+ });
14
+
15
+ it("Starts in block with children", () => {
16
+ setSelection(getEditor(), "paragraph-with-children", "paragraph-2");
17
+
18
+ expect(getSelection(getEditor())).toMatchSnapshot();
19
+ });
20
+
21
+ it("Starts in nested block", () => {
22
+ setSelection(getEditor(), "nested-paragraph-0", "paragraph-2");
23
+
24
+ expect(getSelection(getEditor())).toMatchSnapshot();
25
+ });
26
+
27
+ it("Ends in block with children", () => {
28
+ setSelection(getEditor(), "paragraph-1", "paragraph-with-children");
29
+
30
+ expect(getSelection(getEditor())).toMatchSnapshot();
31
+ });
32
+
33
+ it("Ends in nested block", () => {
34
+ setSelection(getEditor(), "paragraph-1", "nested-paragraph-0");
35
+
36
+ expect(getSelection(getEditor())).toMatchSnapshot();
37
+ });
38
+
39
+ it("Contains block with children", () => {
40
+ setSelection(getEditor(), "paragraph-1", "paragraph-2");
41
+
42
+ expect(getSelection(getEditor())).toMatchSnapshot();
43
+ });
44
+
45
+ it("Starts in table", () => {
46
+ setSelection(getEditor(), "table-0", "paragraph-7");
47
+
48
+ expect(getSelection(getEditor())).toMatchSnapshot();
49
+ });
50
+
51
+ it("Ends in table", () => {
52
+ setSelection(getEditor(), "paragraph-6", "table-0");
53
+
54
+ expect(getSelection(getEditor())).toMatchSnapshot();
55
+ });
56
+ });