@blocknote/core 0.4.0 → 0.4.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.
Files changed (87) hide show
  1. package/dist/blocknote.js +12371 -12268
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +20 -20
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +2 -2
  7. package/src/BlockNoteEditor.ts +237 -14
  8. package/src/BlockNoteExtensions.ts +19 -15
  9. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +616 -0
  10. package/src/api/blockManipulation/blockManipulation.test.ts +172 -0
  11. package/src/api/blockManipulation/blockManipulation.ts +25 -14
  12. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +346 -0
  13. package/src/api/formatConversions/formatConversions.test.ts +766 -0
  14. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +268 -0
  15. package/src/api/nodeConversions/nodeConversions.test.ts +244 -0
  16. package/src/api/nodeConversions/nodeConversions.ts +167 -58
  17. package/src/api/nodeConversions/testUtil.ts +61 -0
  18. package/src/api/util/nodeUtil.ts +38 -0
  19. package/src/editor.module.css +1 -0
  20. package/src/extensions/Blocks/api/blockTypes.ts +14 -9
  21. package/src/extensions/Blocks/api/cursorPositionTypes.ts +2 -0
  22. package/src/extensions/Blocks/api/inlineContentTypes.ts +27 -36
  23. package/src/extensions/Blocks/nodes/Block.module.css +39 -36
  24. package/src/extensions/Blocks/nodes/BlockContainer.ts +15 -14
  25. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +149 -87
  26. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +31 -0
  27. package/src/extensions/SlashMenu/SlashMenuExtension.ts +10 -7
  28. package/src/extensions/SlashMenu/{defaultSlashCommands.tsx → defaultSlashMenuItems.tsx} +59 -106
  29. package/src/extensions/SlashMenu/index.ts +3 -7
  30. package/src/index.ts +2 -3
  31. package/src/shared/plugins/suggestion/SuggestionItem.ts +2 -13
  32. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +31 -18
  33. package/src/shared/utils.ts +6 -0
  34. package/types/src/BlockNoteEditor.d.ts +82 -8
  35. package/types/src/BlockNoteExtensions.d.ts +5 -4
  36. package/types/src/api/Editor.d.ts +26 -6
  37. package/types/src/api/blockManipulation/blockManipulation.d.ts +5 -5
  38. package/types/src/api/blockManipulation/blockManipulation.test.d.ts +1 -0
  39. package/types/src/api/formatConversions/formatConversions.test.d.ts +1 -0
  40. package/types/src/api/nodeConversions/nodeConversions.d.ts +11 -4
  41. package/types/src/api/nodeConversions/nodeConversions.test.d.ts +1 -0
  42. package/types/src/api/nodeConversions/testUtil.d.ts +2 -0
  43. package/types/src/api/util/nodeUtil.d.ts +8 -0
  44. package/types/src/extensions/Blocks/api/blockTypes.d.ts +10 -9
  45. package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +2 -0
  46. package/types/src/extensions/Blocks/api/inlineContentTypes.d.ts +25 -19
  47. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +15 -0
  48. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +20 -0
  49. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +4 -2
  50. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +5 -0
  51. package/types/src/extensions/SlashMenu/index.d.ts +3 -3
  52. package/types/src/index.d.ts +2 -3
  53. package/types/src/shared/plugins/suggestion/SuggestionItem.d.ts +3 -11
  54. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +4 -4
  55. package/types/src/shared/utils.d.ts +3 -0
  56. package/src/api/Editor.ts +0 -142
  57. package/src/extensions/SlashMenu/SlashMenuItem.ts +0 -34
  58. package/types/src/EditorElement.d.ts +0 -7
  59. package/types/src/api/Document.d.ts +0 -5
  60. package/types/src/api/removeUnderlinesRehypePlugin.d.ts +0 -6
  61. package/types/src/api/simplifyBlocksRehypePlugin.d.ts +0 -16
  62. package/types/src/extensions/Blocks/BlockAttributes.d.ts +0 -2
  63. package/types/src/extensions/Blocks/MultipleNodeSelection.d.ts +0 -24
  64. package/types/src/extensions/Blocks/api/apiTypes.d.ts +0 -18
  65. package/types/src/extensions/Blocks/api/styleTypes.d.ts +0 -22
  66. package/types/src/extensions/Blocks/apiTypes.d.ts +0 -16
  67. package/types/src/extensions/Blocks/nodes/Block.d.ts +0 -24
  68. package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +0 -4
  69. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +0 -4
  70. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +0 -2
  71. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +0 -2
  72. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +0 -2
  73. package/types/src/extensions/Blocks/nodes/BlockTypes/HeadingBlock/HeadingContent.d.ts +0 -8
  74. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.d.ts +0 -8
  75. package/types/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.d.ts +0 -2
  76. package/types/src/extensions/Blocks/nodes/BlockTypes/TextBlock/TextContent.d.ts +0 -6
  77. package/types/src/extensions/BubbleMenu/BubbleMenuExtension.d.ts +0 -8
  78. package/types/src/extensions/BubbleMenu/BubbleMenuFactoryTypes.d.ts +0 -27
  79. package/types/src/extensions/BubbleMenu/BubbleMenuPlugin.d.ts +0 -44
  80. package/types/src/extensions/DraggableBlocks/BlockMenuFactoryTypes.d.ts +0 -12
  81. package/types/src/extensions/DraggableBlocks/DragMenuFactoryTypes.d.ts +0 -18
  82. package/types/src/extensions/Hyperlinks/HyperlinkMark.d.ts +0 -8
  83. package/types/src/extensions/Hyperlinks/HyperlinkMenuFactoryTypes.d.ts +0 -11
  84. package/types/src/extensions/Hyperlinks/HyperlinkMenuPlugin.d.ts +0 -11
  85. package/types/src/extensions/Paragraph/FixedParagraph.d.ts +0 -1
  86. package/types/src/extensions/SlashMenu/defaultCommands.d.ts +0 -8
  87. package/types/src/utils.d.ts +0 -2
@@ -0,0 +1,766 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
+ import { Block, BlockNoteEditor } from "../..";
3
+ import UniqueID from "../../extensions/UniqueID/UniqueID";
4
+
5
+ let editor: BlockNoteEditor;
6
+
7
+ let nonNestedBlocks: Block[];
8
+ let nonNestedHTML: string;
9
+ let nonNestedMarkdown: string;
10
+
11
+ let nestedBlocks: Block[];
12
+ // let nestedHTML: string;
13
+ // let nestedMarkdown: string;
14
+
15
+ let styledBlocks: Block[];
16
+ let styledHTML: string;
17
+ let styledMarkdown: string;
18
+
19
+ let complexBlocks: Block[];
20
+ // let complexHTML: string;
21
+ // let complexMarkdown: string;
22
+
23
+ beforeEach(() => {
24
+ (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS = {};
25
+
26
+ editor = new BlockNoteEditor();
27
+
28
+ nonNestedBlocks = [
29
+ {
30
+ id: UniqueID.options.generateID(),
31
+ type: "heading",
32
+ props: {
33
+ backgroundColor: "default",
34
+ textColor: "default",
35
+ textAlignment: "left",
36
+ level: "1",
37
+ },
38
+ content: [
39
+ {
40
+ type: "text",
41
+ text: "Heading",
42
+ styles: {},
43
+ },
44
+ ],
45
+ children: [],
46
+ },
47
+ {
48
+ id: UniqueID.options.generateID(),
49
+ type: "paragraph",
50
+ props: {
51
+ backgroundColor: "default",
52
+ textColor: "default",
53
+ textAlignment: "left",
54
+ },
55
+ content: [
56
+ {
57
+ type: "text",
58
+ text: "Paragraph",
59
+ styles: {},
60
+ },
61
+ ],
62
+ children: [],
63
+ },
64
+ {
65
+ id: UniqueID.options.generateID(),
66
+ type: "bulletListItem",
67
+ props: {
68
+ backgroundColor: "default",
69
+ textColor: "default",
70
+ textAlignment: "left",
71
+ },
72
+ content: [
73
+ {
74
+ type: "text",
75
+ text: "Bullet List Item",
76
+ styles: {},
77
+ },
78
+ ],
79
+ children: [],
80
+ },
81
+ {
82
+ id: UniqueID.options.generateID(),
83
+ type: "numberedListItem",
84
+ props: {
85
+ backgroundColor: "default",
86
+ textColor: "default",
87
+ textAlignment: "left",
88
+ },
89
+ content: [
90
+ {
91
+ type: "text",
92
+ text: "Numbered List Item",
93
+ styles: {},
94
+ },
95
+ ],
96
+ children: [],
97
+ },
98
+ ];
99
+ nonNestedHTML = `<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p></li></ul><ol><li><p>Numbered List Item</p></li></ol>`;
100
+ nonNestedMarkdown = `# Heading
101
+
102
+ Paragraph
103
+
104
+ * Bullet List Item
105
+
106
+ 1. Numbered List Item
107
+ `;
108
+
109
+ nestedBlocks = [
110
+ {
111
+ id: UniqueID.options.generateID(),
112
+ type: "heading",
113
+ props: {
114
+ backgroundColor: "default",
115
+ textColor: "default",
116
+ textAlignment: "left",
117
+ level: "1",
118
+ },
119
+ content: [
120
+ {
121
+ type: "text",
122
+ text: "Heading",
123
+ styles: {},
124
+ },
125
+ ],
126
+ children: [
127
+ {
128
+ id: UniqueID.options.generateID(),
129
+ type: "paragraph",
130
+ props: {
131
+ backgroundColor: "default",
132
+ textColor: "default",
133
+ textAlignment: "left",
134
+ },
135
+ content: [
136
+ {
137
+ type: "text",
138
+ text: "Paragraph",
139
+ styles: {},
140
+ },
141
+ ],
142
+ children: [
143
+ {
144
+ id: UniqueID.options.generateID(),
145
+ type: "bulletListItem",
146
+ props: {
147
+ backgroundColor: "default",
148
+ textColor: "default",
149
+ textAlignment: "left",
150
+ },
151
+ content: [
152
+ {
153
+ type: "text",
154
+ text: "Bullet List Item",
155
+ styles: {},
156
+ },
157
+ ],
158
+ children: [
159
+ {
160
+ id: UniqueID.options.generateID(),
161
+ type: "numberedListItem",
162
+ props: {
163
+ backgroundColor: "default",
164
+ textColor: "default",
165
+ textAlignment: "left",
166
+ },
167
+ content: [
168
+ {
169
+ type: "text",
170
+ text: "Numbered List Item",
171
+ styles: {},
172
+ },
173
+ ],
174
+ children: [],
175
+ },
176
+ ],
177
+ },
178
+ ],
179
+ },
180
+ ],
181
+ },
182
+ ];
183
+ // nestedHTML = `<h1>Heading</h1><p>Paragraph</p><ul><li><p>Bullet List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ul>`;
184
+ // nestedMarkdown = `# Heading
185
+ //
186
+ // Paragraph
187
+ //
188
+ // * Bullet List Item
189
+ //
190
+ // 1. Numbered List Item
191
+ // `;
192
+
193
+ styledBlocks = [
194
+ {
195
+ id: UniqueID.options.generateID(),
196
+ type: "paragraph",
197
+ props: {
198
+ backgroundColor: "default",
199
+ textColor: "default",
200
+ textAlignment: "left",
201
+ },
202
+ content: [
203
+ {
204
+ type: "text",
205
+ text: "Bold",
206
+ styles: {
207
+ bold: true,
208
+ },
209
+ },
210
+ {
211
+ type: "text",
212
+ text: "Italic",
213
+ styles: {
214
+ italic: true,
215
+ },
216
+ },
217
+ {
218
+ type: "text",
219
+ text: "Underline",
220
+ styles: {
221
+ underline: true,
222
+ },
223
+ },
224
+ {
225
+ type: "text",
226
+ text: "Strikethrough",
227
+ styles: {
228
+ strike: true,
229
+ },
230
+ },
231
+ {
232
+ type: "text",
233
+ text: "TextColor",
234
+ styles: {
235
+ textColor: "red",
236
+ },
237
+ },
238
+ {
239
+ type: "text",
240
+ text: "BackgroundColor",
241
+ styles: {
242
+ backgroundColor: "red",
243
+ },
244
+ },
245
+ {
246
+ type: "text",
247
+ text: "Multiple",
248
+ styles: {
249
+ bold: true,
250
+ italic: true,
251
+ },
252
+ },
253
+ ],
254
+ children: [],
255
+ },
256
+ ];
257
+ styledHTML = `<p><strong>Bold</strong><em>Italic</em><u>Underline</u><s>Strikethrough</s><span data-text-color="red">TextColor</span><span data-background-color="red">BackgroundColor</span><strong><em>Multiple</em></strong></p>`;
258
+ styledMarkdown = `**Bold***Italic*Underline~~Strikethrough~~TextColorBackgroundColor***Multiple***`;
259
+
260
+ complexBlocks = [
261
+ {
262
+ id: UniqueID.options.generateID(),
263
+ type: "heading",
264
+ props: {
265
+ backgroundColor: "red",
266
+ textColor: "yellow",
267
+ textAlignment: "right",
268
+ level: "1",
269
+ },
270
+ content: [
271
+ {
272
+ type: "text",
273
+ text: "Heading 1",
274
+ styles: {},
275
+ },
276
+ ],
277
+ children: [
278
+ {
279
+ id: UniqueID.options.generateID(),
280
+ type: "heading",
281
+ props: {
282
+ backgroundColor: "orange",
283
+ textColor: "orange",
284
+ textAlignment: "center",
285
+ level: "2",
286
+ },
287
+ content: [
288
+ {
289
+ type: "text",
290
+ text: "Heading 2",
291
+ styles: {},
292
+ },
293
+ ],
294
+ children: [
295
+ {
296
+ id: UniqueID.options.generateID(),
297
+ type: "heading",
298
+ props: {
299
+ backgroundColor: "yellow",
300
+ textColor: "red",
301
+ textAlignment: "left",
302
+ level: "3",
303
+ },
304
+ content: [
305
+ {
306
+ type: "text",
307
+ text: "Heading 3",
308
+ styles: {},
309
+ },
310
+ ],
311
+ children: [],
312
+ },
313
+ ],
314
+ },
315
+ ],
316
+ },
317
+ {
318
+ id: UniqueID.options.generateID(),
319
+ type: "paragraph",
320
+ props: {
321
+ backgroundColor: "default",
322
+ textColor: "default",
323
+ textAlignment: "left",
324
+ },
325
+ content: [
326
+ {
327
+ type: "text",
328
+ text: "Paragraph",
329
+ styles: {
330
+ textColor: "purple",
331
+ backgroundColor: "green",
332
+ },
333
+ },
334
+ ],
335
+ children: [],
336
+ },
337
+ {
338
+ id: UniqueID.options.generateID(),
339
+ type: "paragraph",
340
+ props: {
341
+ backgroundColor: "default",
342
+ textColor: "default",
343
+ textAlignment: "left",
344
+ },
345
+ content: [
346
+ {
347
+ type: "text",
348
+ text: "P",
349
+ styles: {},
350
+ },
351
+ {
352
+ type: "text",
353
+ text: "ara",
354
+ styles: {
355
+ bold: true,
356
+ },
357
+ },
358
+ {
359
+ type: "text",
360
+ text: "grap",
361
+ styles: {
362
+ italic: true,
363
+ },
364
+ },
365
+ {
366
+ type: "text",
367
+ text: "h",
368
+ styles: {},
369
+ },
370
+ ],
371
+ children: [],
372
+ },
373
+ {
374
+ id: UniqueID.options.generateID(),
375
+ type: "paragraph",
376
+ props: {
377
+ backgroundColor: "default",
378
+ textColor: "default",
379
+ textAlignment: "left",
380
+ },
381
+ content: [
382
+ {
383
+ type: "text",
384
+ text: "P",
385
+ styles: {},
386
+ },
387
+ {
388
+ type: "text",
389
+ text: "ara",
390
+ styles: {
391
+ underline: true,
392
+ },
393
+ },
394
+ {
395
+ type: "text",
396
+ text: "grap",
397
+ styles: {
398
+ strike: true,
399
+ },
400
+ },
401
+ {
402
+ type: "text",
403
+ text: "h",
404
+ styles: {},
405
+ },
406
+ ],
407
+ children: [],
408
+ },
409
+ {
410
+ id: UniqueID.options.generateID(),
411
+ type: "bulletListItem",
412
+ props: {
413
+ backgroundColor: "default",
414
+ textColor: "default",
415
+ textAlignment: "left",
416
+ },
417
+ content: [
418
+ {
419
+ type: "text",
420
+ text: "Bullet List Item",
421
+ styles: {},
422
+ },
423
+ ],
424
+ children: [],
425
+ },
426
+ {
427
+ id: UniqueID.options.generateID(),
428
+ type: "bulletListItem",
429
+ props: {
430
+ backgroundColor: "default",
431
+ textColor: "default",
432
+ textAlignment: "left",
433
+ },
434
+ content: [
435
+ {
436
+ type: "text",
437
+ text: "Bullet List Item",
438
+ styles: {},
439
+ },
440
+ ],
441
+ children: [
442
+ {
443
+ id: UniqueID.options.generateID(),
444
+ type: "bulletListItem",
445
+ props: {
446
+ backgroundColor: "default",
447
+ textColor: "default",
448
+ textAlignment: "left",
449
+ },
450
+ content: [
451
+ {
452
+ type: "text",
453
+ text: "Bullet List Item",
454
+ styles: {},
455
+ },
456
+ ],
457
+ children: [
458
+ {
459
+ id: UniqueID.options.generateID(),
460
+ type: "bulletListItem",
461
+ props: {
462
+ backgroundColor: "default",
463
+ textColor: "default",
464
+ textAlignment: "left",
465
+ },
466
+ content: [
467
+ {
468
+ type: "text",
469
+ text: "Bullet List Item",
470
+ styles: {},
471
+ },
472
+ ],
473
+ children: [],
474
+ },
475
+ {
476
+ id: UniqueID.options.generateID(),
477
+ type: "paragraph",
478
+ props: {
479
+ backgroundColor: "default",
480
+ textColor: "default",
481
+ textAlignment: "left",
482
+ },
483
+ content: [
484
+ {
485
+ type: "text",
486
+ text: "Paragraph",
487
+ styles: {},
488
+ },
489
+ ],
490
+ children: [],
491
+ },
492
+ {
493
+ id: UniqueID.options.generateID(),
494
+ type: "numberedListItem",
495
+ props: {
496
+ backgroundColor: "default",
497
+ textColor: "default",
498
+ textAlignment: "left",
499
+ },
500
+ content: [
501
+ {
502
+ type: "text",
503
+ text: "Numbered List Item",
504
+ styles: {},
505
+ },
506
+ ],
507
+ children: [],
508
+ },
509
+ {
510
+ id: UniqueID.options.generateID(),
511
+ type: "numberedListItem",
512
+ props: {
513
+ backgroundColor: "default",
514
+ textColor: "default",
515
+ textAlignment: "left",
516
+ },
517
+ content: [
518
+ {
519
+ type: "text",
520
+ text: "Numbered List Item",
521
+ styles: {},
522
+ },
523
+ ],
524
+ children: [],
525
+ },
526
+ {
527
+ id: UniqueID.options.generateID(),
528
+ type: "numberedListItem",
529
+ props: {
530
+ backgroundColor: "default",
531
+ textColor: "default",
532
+ textAlignment: "left",
533
+ },
534
+ content: [
535
+ {
536
+ type: "text",
537
+ text: "Numbered List Item",
538
+ styles: {},
539
+ },
540
+ ],
541
+ children: [
542
+ {
543
+ id: UniqueID.options.generateID(),
544
+ type: "numberedListItem",
545
+ props: {
546
+ backgroundColor: "default",
547
+ textColor: "default",
548
+ textAlignment: "left",
549
+ },
550
+ content: [
551
+ {
552
+ type: "text",
553
+ text: "Numbered List Item",
554
+ styles: {},
555
+ },
556
+ ],
557
+ children: [],
558
+ },
559
+ ],
560
+ },
561
+ {
562
+ id: UniqueID.options.generateID(),
563
+ type: "bulletListItem",
564
+ props: {
565
+ backgroundColor: "default",
566
+ textColor: "default",
567
+ textAlignment: "left",
568
+ },
569
+ content: [
570
+ {
571
+ type: "text",
572
+ text: "Bullet List Item",
573
+ styles: {},
574
+ },
575
+ ],
576
+ children: [],
577
+ },
578
+ ],
579
+ },
580
+ {
581
+ id: UniqueID.options.generateID(),
582
+ type: "bulletListItem",
583
+ props: {
584
+ backgroundColor: "default",
585
+ textColor: "default",
586
+ textAlignment: "left",
587
+ },
588
+ content: [
589
+ {
590
+ type: "text",
591
+ text: "Bullet List Item",
592
+ styles: {},
593
+ },
594
+ ],
595
+ children: [],
596
+ },
597
+ ],
598
+ },
599
+ {
600
+ id: UniqueID.options.generateID(),
601
+ type: "bulletListItem",
602
+ props: {
603
+ backgroundColor: "default",
604
+ textColor: "default",
605
+ textAlignment: "left",
606
+ },
607
+ content: [
608
+ {
609
+ type: "text",
610
+ text: "Bullet List Item",
611
+ styles: {},
612
+ },
613
+ ],
614
+ children: [],
615
+ },
616
+ ];
617
+
618
+ // complexHTML = `<h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><p><span data-text-color="purple"><span data-background-color="green">Paragraph</span></span></p><p>P<strong>ara</strong><em>grap</em>h</p><p>P<u>ara</u><s>grap</s>h</p><ul><li><p>Bullet List Item</p></li><li><p>Bullet List Item</p><ul><li><p>Bullet List Item</p><ul><li><p>Bullet List Item</p></li></ul><p>Paragraph</p><ol><li><p>Numbered List Item</p></li><li><p>Numbered List Item</p></li><li><p>Numbered List Item</p><ol><li><p>Numbered List Item</p></li></ol></li></ol><ul><li><p>Bullet List Item</p></li></ul></li><li><p>Bullet List Item</p></li></ul></li><li><p>Bullet List Item</p></li></ul>`;
619
+ // complexMarkdown = `# Heading 1
620
+ //
621
+ // ## Heading 2
622
+ //
623
+ // ### Heading 3
624
+ //
625
+ // Paragraph
626
+ //
627
+ // P**ara***grap*h
628
+ //
629
+ // P*ara*~~grap~~h
630
+ //
631
+ // * Bullet List Item
632
+ //
633
+ // * Bullet List Item
634
+ //
635
+ // * Bullet List Item
636
+ //
637
+ // * Bullet List Item
638
+ //
639
+ // Paragraph
640
+ //
641
+ // 1. Numbered List Item
642
+ //
643
+ // 2. Numbered List Item
644
+ //
645
+ // 3. Numbered List Item
646
+ //
647
+ // 1. Numbered List Item
648
+ //
649
+ // * Bullet List Item
650
+ //
651
+ // * Bullet List Item
652
+ //
653
+ // * Bullet List Item
654
+ // `;
655
+ });
656
+
657
+ afterEach(() => {
658
+ editor._tiptapEditor.destroy();
659
+ editor = undefined as any;
660
+
661
+ delete (window as Window & { __TEST_OPTIONS?: {} }).__TEST_OPTIONS;
662
+ });
663
+
664
+ describe("Non-Nested Block/HTML/Markdown Conversions", () => {
665
+ it("Convert non-nested blocks to HTML", async () => {
666
+ const output = await editor.blocksToHTML(nonNestedBlocks);
667
+
668
+ expect(output).toMatchSnapshot();
669
+ });
670
+
671
+ it("Convert non-nested blocks to Markdown", async () => {
672
+ const output = await editor.blocksToMarkdown(nonNestedBlocks);
673
+
674
+ expect(output).toMatchSnapshot();
675
+ });
676
+
677
+ it("Convert non-nested HTML to blocks", async () => {
678
+ const output = await editor.HTMLToBlocks(nonNestedHTML);
679
+
680
+ expect(output).toMatchSnapshot();
681
+ });
682
+
683
+ it("Convert non-nested Markdown to blocks", async () => {
684
+ const output = await editor.markdownToBlocks(nonNestedMarkdown);
685
+
686
+ expect(output).toMatchSnapshot();
687
+ });
688
+ });
689
+
690
+ describe("Nested Block/HTML/Markdown Conversions", () => {
691
+ it("Convert nested blocks to HTML", async () => {
692
+ const output = await editor.blocksToHTML(nestedBlocks);
693
+
694
+ expect(output).toMatchSnapshot();
695
+ });
696
+
697
+ it("Convert nested blocks to Markdown", async () => {
698
+ const output = await editor.blocksToMarkdown(nestedBlocks);
699
+
700
+ expect(output).toMatchSnapshot();
701
+ });
702
+ // // Failing due to nested block parsing bug.
703
+ // it("Convert nested HTML to blocks", async () => {
704
+ // const output = await editor.HTMLToBlocks(nestedHTML);
705
+ //
706
+ // expect(output).toMatchSnapshot();
707
+ // });
708
+ // // Failing due to nested block parsing bug.
709
+ // it("Convert nested Markdown to blocks", async () => {
710
+ // const output = await editor.markdownToBlocks(nestedMarkdown);
711
+ //
712
+ // expect(output).toMatchSnapshot();
713
+ // });
714
+ });
715
+
716
+ describe("Styled Block/HTML/Markdown Conversions", () => {
717
+ it("Convert styled blocks to HTML", async () => {
718
+ const output = await editor.blocksToHTML(styledBlocks);
719
+
720
+ expect(output).toMatchSnapshot();
721
+ });
722
+
723
+ it("Convert styled blocks to Markdown", async () => {
724
+ const output = await editor.blocksToMarkdown(styledBlocks);
725
+
726
+ expect(output).toMatchSnapshot();
727
+ });
728
+
729
+ it("Convert styled HTML to blocks", async () => {
730
+ const output = await editor.HTMLToBlocks(styledHTML);
731
+
732
+ expect(output).toMatchSnapshot();
733
+ });
734
+
735
+ it("Convert styled Markdown to blocks", async () => {
736
+ const output = await editor.markdownToBlocks(styledMarkdown);
737
+
738
+ expect(output).toMatchSnapshot();
739
+ });
740
+ });
741
+
742
+ describe("Complex Block/HTML/Markdown Conversions", () => {
743
+ it("Convert complex blocks to HTML", async () => {
744
+ const output = await editor.blocksToHTML(complexBlocks);
745
+
746
+ expect(output).toMatchSnapshot();
747
+ });
748
+
749
+ it("Convert complex blocks to Markdown", async () => {
750
+ const output = await editor.blocksToMarkdown(complexBlocks);
751
+
752
+ expect(output).toMatchSnapshot();
753
+ });
754
+ // // Failing due to nested block parsing bug.
755
+ // it("Convert complex HTML to blocks", async () => {
756
+ // const output = await editor.HTMLToBlocks(complexHTML);
757
+ //
758
+ // expect(output).toMatchSnapshot();
759
+ // });
760
+ // // Failing due to nested block parsing bug.
761
+ // it("Convert complex Markdown to blocks", async () => {
762
+ // const output = await editor.markdownToBlocks(complexMarkdown);
763
+ //
764
+ // expect(output).toMatchSnapshot();
765
+ // });
766
+ });