@blocknote/core 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocknote.js +5282 -2785
- package/dist/blocknote.js.map +1 -1
- package/dist/blocknote.umd.cjs +7 -7
- 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/exporters/html/__snapshots__/file/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/button/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/button/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/nested/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/noCaption/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/noName/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/file/noName/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/basic/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/basic/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/button/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/button/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/external.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/nested/internal.html +1 -1
- package/src/api/exporters/html/__snapshots__/image/noCaption/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/noName/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/noName/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/noPreview/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleFile/basic/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleFile/basic/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleFile/button/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleFile/button/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleFile/nested/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleFile/nested/internal.html +1 -0
- 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/__snapshots__/simpleImage/noCaption/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +1 -0
- package/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +1 -0
- package/src/api/exporters/markdown/__snapshots__/file/basic/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/file/button/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/file/nested/markdown.md +7 -0
- package/src/api/exporters/markdown/__snapshots__/file/noCaption/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/file/noName/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/image/button/markdown.md +1 -1
- package/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md +2 -2
- package/src/api/exporters/markdown/__snapshots__/image/noCaption/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/image/noName/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/image/noPreview/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/simpleFile/basic/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/simpleFile/button/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleFile/nested/markdown.md +7 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +3 -1
- package/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +6 -2
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +1 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +3 -0
- package/src/api/exporters/markdown/__snapshots__/simpleImage/noPreview/markdown.md +3 -0
- package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +212 -4
- package/src/api/parsers/html/__snapshots__/paste/parse-basic-block-types.json +3 -1
- package/src/api/parsers/html/__snapshots__/paste/parse-fake-image-caption.json +3 -1
- package/src/api/testUtil/cases/customBlocks.ts +79 -33
- package/src/api/testUtil/cases/customInlineContent.ts +1 -1
- package/src/api/testUtil/cases/customStyles.ts +1 -1
- package/src/api/testUtil/cases/defaultSchema.ts +114 -4
- package/src/blocks/AudioBlockContent/AudioBlockContent.ts +162 -0
- package/src/blocks/AudioBlockContent/audioBlockHelpers.ts +5 -0
- package/src/blocks/FileBlockContent/FileBlockContent.ts +121 -0
- package/src/blocks/FileBlockContent/fileBlockHelpers.ts +377 -0
- package/src/blocks/ImageBlockContent/ImageBlockContent.ts +135 -356
- package/src/blocks/ImageBlockContent/imageBlockHelpers.ts +6 -0
- package/src/blocks/VideoBlockContent/VideoBlockContent.ts +182 -0
- package/src/blocks/VideoBlockContent/videoBlockHelpers.ts +6 -0
- package/src/blocks/defaultBlockTypeGuards.ts +53 -1
- package/src/blocks/defaultBlocks.ts +8 -2
- package/src/editor/Block.css +67 -27
- package/src/editor/BlockNoteEditor.ts +14 -10
- package/src/editor/BlockNoteSchema.ts +12 -3
- package/src/extensions/{ImagePanel/ImageToolbarPlugin.ts → FilePanel/FilePanelPlugin.ts} +22 -25
- package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +14 -2
- package/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts +59 -2
- package/src/i18n/locales/en.ts +102 -11
- package/src/i18n/locales/fr.ts +104 -11
- package/src/i18n/locales/index.ts +8 -2
- package/src/i18n/locales/is.ts +288 -0
- package/src/i18n/locales/ja.ts +300 -0
- package/src/i18n/locales/ko.ts +292 -0
- package/src/i18n/locales/nl.ts +101 -8
- package/src/i18n/locales/pl.ts +280 -0
- package/src/i18n/locales/pt.ts +281 -0
- package/src/i18n/locales/vi.ts +281 -0
- package/src/i18n/locales/zh.ts +107 -8
- package/src/index.ts +9 -2
- package/src/pm-nodes/BlockContainer.ts +2 -2
- package/src/schema/blocks/createSpec.ts +1 -0
- package/src/schema/blocks/internal.ts +10 -0
- package/src/schema/blocks/types.ts +41 -5
- package/src/util/string.ts +12 -0
- package/types/src/api/testUtil/cases/customBlocks.d.ts +228 -42
- package/types/src/api/testUtil/cases/customInlineContent.d.ts +178 -4
- package/types/src/api/testUtil/cases/customStyles.d.ts +178 -4
- package/types/src/blocks/AudioBlockContent/AudioBlockContent.d.ts +104 -0
- package/types/src/blocks/AudioBlockContent/audioBlockHelpers.d.ts +3 -0
- package/types/src/blocks/FileBlockContent/FileBlockContent.d.ts +96 -0
- package/types/src/blocks/FileBlockContent/fileBlockHelpers.d.ts +30 -0
- package/types/src/blocks/ImageBlockContent/ImageBlockContent.d.ts +53 -14
- package/types/src/blocks/ImageBlockContent/imageBlockHelpers.d.ts +4 -0
- package/types/src/blocks/VideoBlockContent/VideoBlockContent.d.ts +132 -0
- package/types/src/blocks/VideoBlockContent/videoBlockHelpers.d.ts +4 -0
- package/types/src/blocks/defaultBlockTypeGuards.d.ts +6 -1
- package/types/src/blocks/defaultBlocks.d.ts +356 -8
- package/types/src/editor/BlockNoteEditor.d.ts +5 -5
- package/types/src/extensions/{ImagePanel/ImageToolbarPlugin.d.ts → FilePanel/FilePanelPlugin.d.ts} +9 -12
- package/types/src/i18n/locales/en.d.ts +49 -7
- package/types/src/i18n/locales/fr.d.ts +2 -184
- package/types/src/i18n/locales/index.d.ts +7 -1
- package/types/src/i18n/locales/is.d.ts +2 -0
- package/types/src/i18n/locales/ja.d.ts +2 -0
- package/types/src/i18n/locales/ko.d.ts +2 -0
- package/types/src/i18n/locales/pl.d.ts +2 -0
- package/types/src/i18n/locales/pt.d.ts +2 -0
- package/types/src/i18n/locales/vi.d.ts +2 -0
- package/types/src/index.d.ts +8 -2
- package/types/src/schema/blocks/internal.d.ts +1 -1
- package/types/src/schema/blocks/types.d.ts +26 -1
- package/types/src/util/string.d.ts +1 -0
- /package/src/blocks/{ImageBlockContent → FileBlockContent}/uploadToTmpFilesDotOrg_DEV_ONLY.ts +0 -0
- /package/types/src/blocks/{ImageBlockContent → FileBlockContent}/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +0 -0
|
@@ -217,6 +217,134 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
217
217
|
}
|
|
218
218
|
`;
|
|
219
219
|
|
|
220
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/basic to/from prosemirror 1`] = `
|
|
221
|
+
{
|
|
222
|
+
"attrs": {
|
|
223
|
+
"backgroundColor": "default",
|
|
224
|
+
"id": "1",
|
|
225
|
+
"textColor": "default",
|
|
226
|
+
},
|
|
227
|
+
"content": [
|
|
228
|
+
{
|
|
229
|
+
"attrs": {
|
|
230
|
+
"caption": "Caption",
|
|
231
|
+
"name": "example",
|
|
232
|
+
"url": "exampleURL",
|
|
233
|
+
},
|
|
234
|
+
"type": "file",
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
"type": "blockContainer",
|
|
238
|
+
}
|
|
239
|
+
`;
|
|
240
|
+
|
|
241
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/button to/from prosemirror 1`] = `
|
|
242
|
+
{
|
|
243
|
+
"attrs": {
|
|
244
|
+
"backgroundColor": "default",
|
|
245
|
+
"id": "1",
|
|
246
|
+
"textColor": "default",
|
|
247
|
+
},
|
|
248
|
+
"content": [
|
|
249
|
+
{
|
|
250
|
+
"attrs": {
|
|
251
|
+
"caption": "",
|
|
252
|
+
"name": "",
|
|
253
|
+
"url": "",
|
|
254
|
+
},
|
|
255
|
+
"type": "file",
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
"type": "blockContainer",
|
|
259
|
+
}
|
|
260
|
+
`;
|
|
261
|
+
|
|
262
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/nested to/from prosemirror 1`] = `
|
|
263
|
+
{
|
|
264
|
+
"attrs": {
|
|
265
|
+
"backgroundColor": "default",
|
|
266
|
+
"id": "1",
|
|
267
|
+
"textColor": "default",
|
|
268
|
+
},
|
|
269
|
+
"content": [
|
|
270
|
+
{
|
|
271
|
+
"attrs": {
|
|
272
|
+
"caption": "Caption",
|
|
273
|
+
"name": "example",
|
|
274
|
+
"url": "exampleURL",
|
|
275
|
+
},
|
|
276
|
+
"type": "file",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"content": [
|
|
280
|
+
{
|
|
281
|
+
"attrs": {
|
|
282
|
+
"backgroundColor": "default",
|
|
283
|
+
"id": "2",
|
|
284
|
+
"textColor": "default",
|
|
285
|
+
},
|
|
286
|
+
"content": [
|
|
287
|
+
{
|
|
288
|
+
"attrs": {
|
|
289
|
+
"caption": "Caption",
|
|
290
|
+
"name": "example",
|
|
291
|
+
"url": "exampleURL",
|
|
292
|
+
},
|
|
293
|
+
"type": "file",
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
"type": "blockContainer",
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
"type": "blockGroup",
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
"type": "blockContainer",
|
|
303
|
+
}
|
|
304
|
+
`;
|
|
305
|
+
|
|
306
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/noCaption to/from prosemirror 1`] = `
|
|
307
|
+
{
|
|
308
|
+
"attrs": {
|
|
309
|
+
"backgroundColor": "default",
|
|
310
|
+
"id": "1",
|
|
311
|
+
"textColor": "default",
|
|
312
|
+
},
|
|
313
|
+
"content": [
|
|
314
|
+
{
|
|
315
|
+
"attrs": {
|
|
316
|
+
"caption": "",
|
|
317
|
+
"name": "example",
|
|
318
|
+
"url": "exampleURL",
|
|
319
|
+
},
|
|
320
|
+
"type": "file",
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
"type": "blockContainer",
|
|
324
|
+
}
|
|
325
|
+
`;
|
|
326
|
+
|
|
327
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/noName to/from prosemirror 1`] = `
|
|
328
|
+
{
|
|
329
|
+
"attrs": {
|
|
330
|
+
"backgroundColor": "default",
|
|
331
|
+
"id": "1",
|
|
332
|
+
"textColor": "default",
|
|
333
|
+
},
|
|
334
|
+
"content": [
|
|
335
|
+
{
|
|
336
|
+
"attrs": {
|
|
337
|
+
"caption": "Caption",
|
|
338
|
+
"name": "",
|
|
339
|
+
"url": "exampleURL",
|
|
340
|
+
},
|
|
341
|
+
"type": "file",
|
|
342
|
+
},
|
|
343
|
+
],
|
|
344
|
+
"type": "blockContainer",
|
|
345
|
+
}
|
|
346
|
+
`;
|
|
347
|
+
|
|
220
348
|
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/basic to/from prosemirror 1`] = `
|
|
221
349
|
{
|
|
222
350
|
"attrs": {
|
|
@@ -524,9 +652,11 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
524
652
|
{
|
|
525
653
|
"attrs": {
|
|
526
654
|
"caption": "Caption",
|
|
655
|
+
"name": "example",
|
|
656
|
+
"previewWidth": 256,
|
|
657
|
+
"showPreview": true,
|
|
527
658
|
"textAlignment": "left",
|
|
528
659
|
"url": "exampleURL",
|
|
529
|
-
"width": 256,
|
|
530
660
|
},
|
|
531
661
|
"type": "image",
|
|
532
662
|
},
|
|
@@ -546,9 +676,11 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
546
676
|
{
|
|
547
677
|
"attrs": {
|
|
548
678
|
"caption": "",
|
|
679
|
+
"name": "",
|
|
680
|
+
"previewWidth": 512,
|
|
681
|
+
"showPreview": true,
|
|
549
682
|
"textAlignment": "left",
|
|
550
683
|
"url": "",
|
|
551
|
-
"width": 512,
|
|
552
684
|
},
|
|
553
685
|
"type": "image",
|
|
554
686
|
},
|
|
@@ -568,9 +700,11 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
568
700
|
{
|
|
569
701
|
"attrs": {
|
|
570
702
|
"caption": "Caption",
|
|
703
|
+
"name": "",
|
|
704
|
+
"previewWidth": 256,
|
|
705
|
+
"showPreview": true,
|
|
571
706
|
"textAlignment": "left",
|
|
572
707
|
"url": "exampleURL",
|
|
573
|
-
"width": 256,
|
|
574
708
|
},
|
|
575
709
|
"type": "image",
|
|
576
710
|
},
|
|
@@ -586,9 +720,11 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
586
720
|
{
|
|
587
721
|
"attrs": {
|
|
588
722
|
"caption": "Caption",
|
|
723
|
+
"name": "",
|
|
724
|
+
"previewWidth": 256,
|
|
725
|
+
"showPreview": true,
|
|
589
726
|
"textAlignment": "left",
|
|
590
727
|
"url": "exampleURL",
|
|
591
|
-
"width": 256,
|
|
592
728
|
},
|
|
593
729
|
"type": "image",
|
|
594
730
|
},
|
|
@@ -603,6 +739,78 @@ exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert
|
|
|
603
739
|
}
|
|
604
740
|
`;
|
|
605
741
|
|
|
742
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/noCaption to/from prosemirror 1`] = `
|
|
743
|
+
{
|
|
744
|
+
"attrs": {
|
|
745
|
+
"backgroundColor": "default",
|
|
746
|
+
"id": "1",
|
|
747
|
+
"textColor": "default",
|
|
748
|
+
},
|
|
749
|
+
"content": [
|
|
750
|
+
{
|
|
751
|
+
"attrs": {
|
|
752
|
+
"caption": "",
|
|
753
|
+
"name": "example",
|
|
754
|
+
"previewWidth": 256,
|
|
755
|
+
"showPreview": true,
|
|
756
|
+
"textAlignment": "left",
|
|
757
|
+
"url": "exampleURL",
|
|
758
|
+
},
|
|
759
|
+
"type": "image",
|
|
760
|
+
},
|
|
761
|
+
],
|
|
762
|
+
"type": "blockContainer",
|
|
763
|
+
}
|
|
764
|
+
`;
|
|
765
|
+
|
|
766
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/noName to/from prosemirror 1`] = `
|
|
767
|
+
{
|
|
768
|
+
"attrs": {
|
|
769
|
+
"backgroundColor": "default",
|
|
770
|
+
"id": "1",
|
|
771
|
+
"textColor": "default",
|
|
772
|
+
},
|
|
773
|
+
"content": [
|
|
774
|
+
{
|
|
775
|
+
"attrs": {
|
|
776
|
+
"caption": "Caption",
|
|
777
|
+
"name": "",
|
|
778
|
+
"previewWidth": 256,
|
|
779
|
+
"showPreview": true,
|
|
780
|
+
"textAlignment": "left",
|
|
781
|
+
"url": "exampleURL",
|
|
782
|
+
},
|
|
783
|
+
"type": "image",
|
|
784
|
+
},
|
|
785
|
+
],
|
|
786
|
+
"type": "blockContainer",
|
|
787
|
+
}
|
|
788
|
+
`;
|
|
789
|
+
|
|
790
|
+
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/noPreview to/from prosemirror 1`] = `
|
|
791
|
+
{
|
|
792
|
+
"attrs": {
|
|
793
|
+
"backgroundColor": "default",
|
|
794
|
+
"id": "1",
|
|
795
|
+
"textColor": "default",
|
|
796
|
+
},
|
|
797
|
+
"content": [
|
|
798
|
+
{
|
|
799
|
+
"attrs": {
|
|
800
|
+
"caption": "Caption",
|
|
801
|
+
"name": "example",
|
|
802
|
+
"previewWidth": 256,
|
|
803
|
+
"showPreview": false,
|
|
804
|
+
"textAlignment": "left",
|
|
805
|
+
"url": "exampleURL",
|
|
806
|
+
},
|
|
807
|
+
"type": "image",
|
|
808
|
+
},
|
|
809
|
+
],
|
|
810
|
+
"type": "blockContainer",
|
|
811
|
+
}
|
|
812
|
+
`;
|
|
813
|
+
|
|
606
814
|
exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert link/adjacent to/from prosemirror 1`] = `
|
|
607
815
|
{
|
|
608
816
|
"attrs": {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { EditorTestCases } from "../index";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
imagePropSchema,
|
|
5
|
-
renderImage,
|
|
6
|
-
} from "../../../blocks/ImageBlockContent/ImageBlockContent";
|
|
7
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
8
4
|
import {
|
|
9
5
|
DefaultInlineContentSchema,
|
|
10
6
|
DefaultStyleSchema,
|
|
@@ -13,23 +9,29 @@ import {
|
|
|
13
9
|
import { defaultProps } from "../../../blocks/defaultProps";
|
|
14
10
|
import { BlockNoteEditor } from "../../../editor/BlockNoteEditor";
|
|
15
11
|
import { BlockNoteSchema } from "../../../editor/BlockNoteSchema";
|
|
16
|
-
import { createBlockSpec } from "../../../schema
|
|
12
|
+
import { createBlockSpec } from "../../../schema";
|
|
13
|
+
import {
|
|
14
|
+
imagePropSchema,
|
|
15
|
+
imageRender,
|
|
16
|
+
} from "../../../blocks/ImageBlockContent/ImageBlockContent";
|
|
17
17
|
|
|
18
18
|
// This is a modified version of the default image block that does not implement
|
|
19
|
-
// a `
|
|
20
|
-
// serializes custom blocks using their `render` function.
|
|
19
|
+
// a `toExternalHTML` function. It's used to test if the custom serializer by
|
|
20
|
+
// default serializes custom blocks using their `render` function.
|
|
21
21
|
const SimpleImage = createBlockSpec(
|
|
22
22
|
{
|
|
23
|
-
type: "simpleImage"
|
|
23
|
+
type: "simpleImage",
|
|
24
24
|
propSchema: imagePropSchema,
|
|
25
25
|
content: "none",
|
|
26
26
|
},
|
|
27
|
-
{
|
|
27
|
+
{
|
|
28
|
+
render: (block, editor) => imageRender(block as any, editor as any),
|
|
29
|
+
}
|
|
28
30
|
);
|
|
29
31
|
|
|
30
32
|
const CustomParagraph = createBlockSpec(
|
|
31
33
|
{
|
|
32
|
-
type: "customParagraph"
|
|
34
|
+
type: "customParagraph",
|
|
33
35
|
propSchema: defaultProps,
|
|
34
36
|
content: "inline",
|
|
35
37
|
},
|
|
@@ -57,7 +59,7 @@ const CustomParagraph = createBlockSpec(
|
|
|
57
59
|
|
|
58
60
|
const SimpleCustomParagraph = createBlockSpec(
|
|
59
61
|
{
|
|
60
|
-
type: "simpleCustomParagraph"
|
|
62
|
+
type: "simpleCustomParagraph",
|
|
61
63
|
propSchema: defaultProps,
|
|
62
64
|
content: "inline",
|
|
63
65
|
},
|
|
@@ -108,12 +110,54 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
108
110
|
name: "simpleImage/basic",
|
|
109
111
|
blocks: [
|
|
110
112
|
{
|
|
111
|
-
type: "simpleImage"
|
|
113
|
+
type: "simpleImage",
|
|
114
|
+
props: {
|
|
115
|
+
name: "example",
|
|
116
|
+
url: "exampleURL",
|
|
117
|
+
caption: "Caption",
|
|
118
|
+
previewWidth: 256,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "simpleImage/noName",
|
|
125
|
+
blocks: [
|
|
126
|
+
{
|
|
127
|
+
type: "simpleImage",
|
|
128
|
+
props: {
|
|
129
|
+
url: "exampleURL",
|
|
130
|
+
caption: "Caption",
|
|
131
|
+
previewWidth: 256,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "simpleImage/noCaption",
|
|
138
|
+
blocks: [
|
|
139
|
+
{
|
|
140
|
+
type: "simpleImage",
|
|
141
|
+
props: {
|
|
142
|
+
name: "example",
|
|
143
|
+
url: "exampleURL",
|
|
144
|
+
previewWidth: 256,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "simpleImage/noPreview",
|
|
151
|
+
blocks: [
|
|
152
|
+
{
|
|
153
|
+
type: "simpleImage",
|
|
112
154
|
props: {
|
|
155
|
+
name: "example",
|
|
113
156
|
url: "exampleURL",
|
|
114
157
|
caption: "Caption",
|
|
115
|
-
|
|
116
|
-
|
|
158
|
+
showPreview: false,
|
|
159
|
+
previewWidth: 256,
|
|
160
|
+
},
|
|
117
161
|
},
|
|
118
162
|
],
|
|
119
163
|
},
|
|
@@ -121,20 +165,22 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
121
165
|
name: "simpleImage/nested",
|
|
122
166
|
blocks: [
|
|
123
167
|
{
|
|
124
|
-
type: "simpleImage"
|
|
168
|
+
type: "simpleImage",
|
|
125
169
|
props: {
|
|
170
|
+
name: "example",
|
|
126
171
|
url: "exampleURL",
|
|
127
172
|
caption: "Caption",
|
|
128
|
-
|
|
129
|
-
}
|
|
173
|
+
previewWidth: 256,
|
|
174
|
+
},
|
|
130
175
|
children: [
|
|
131
176
|
{
|
|
132
|
-
type: "simpleImage"
|
|
177
|
+
type: "simpleImage",
|
|
133
178
|
props: {
|
|
179
|
+
name: "example",
|
|
134
180
|
url: "exampleURL",
|
|
135
181
|
caption: "Caption",
|
|
136
|
-
|
|
137
|
-
}
|
|
182
|
+
previewWidth: 256,
|
|
183
|
+
},
|
|
138
184
|
},
|
|
139
185
|
],
|
|
140
186
|
},
|
|
@@ -144,7 +190,7 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
144
190
|
name: "customParagraph/basic",
|
|
145
191
|
blocks: [
|
|
146
192
|
{
|
|
147
|
-
type: "customParagraph"
|
|
193
|
+
type: "customParagraph",
|
|
148
194
|
content: "Custom Paragraph",
|
|
149
195
|
},
|
|
150
196
|
],
|
|
@@ -153,12 +199,12 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
153
199
|
name: "customParagraph/styled",
|
|
154
200
|
blocks: [
|
|
155
201
|
{
|
|
156
|
-
type: "customParagraph"
|
|
202
|
+
type: "customParagraph",
|
|
157
203
|
props: {
|
|
158
204
|
textAlignment: "center",
|
|
159
205
|
textColor: "orange",
|
|
160
206
|
backgroundColor: "pink",
|
|
161
|
-
}
|
|
207
|
+
},
|
|
162
208
|
content: [
|
|
163
209
|
{
|
|
164
210
|
type: "text",
|
|
@@ -195,15 +241,15 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
195
241
|
name: "customParagraph/nested",
|
|
196
242
|
blocks: [
|
|
197
243
|
{
|
|
198
|
-
type: "customParagraph"
|
|
244
|
+
type: "customParagraph",
|
|
199
245
|
content: "Custom Paragraph",
|
|
200
246
|
children: [
|
|
201
247
|
{
|
|
202
|
-
type: "customParagraph"
|
|
248
|
+
type: "customParagraph",
|
|
203
249
|
content: "Nested Custom Paragraph 1",
|
|
204
250
|
},
|
|
205
251
|
{
|
|
206
|
-
type: "customParagraph"
|
|
252
|
+
type: "customParagraph",
|
|
207
253
|
content: "Nested Custom Paragraph 2",
|
|
208
254
|
},
|
|
209
255
|
],
|
|
@@ -214,7 +260,7 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
214
260
|
name: "simpleCustomParagraph/basic",
|
|
215
261
|
blocks: [
|
|
216
262
|
{
|
|
217
|
-
type: "simpleCustomParagraph"
|
|
263
|
+
type: "simpleCustomParagraph",
|
|
218
264
|
content: "Custom Paragraph",
|
|
219
265
|
},
|
|
220
266
|
],
|
|
@@ -223,12 +269,12 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
223
269
|
name: "simpleCustomParagraph/styled",
|
|
224
270
|
blocks: [
|
|
225
271
|
{
|
|
226
|
-
type: "simpleCustomParagraph"
|
|
272
|
+
type: "simpleCustomParagraph",
|
|
227
273
|
props: {
|
|
228
274
|
textAlignment: "center",
|
|
229
275
|
textColor: "orange",
|
|
230
276
|
backgroundColor: "pink",
|
|
231
|
-
}
|
|
277
|
+
},
|
|
232
278
|
content: [
|
|
233
279
|
{
|
|
234
280
|
type: "text",
|
|
@@ -265,15 +311,15 @@ export const customBlocksTestCases: EditorTestCases<
|
|
|
265
311
|
name: "simpleCustomParagraph/nested",
|
|
266
312
|
blocks: [
|
|
267
313
|
{
|
|
268
|
-
type: "simpleCustomParagraph"
|
|
314
|
+
type: "simpleCustomParagraph",
|
|
269
315
|
content: "Custom Paragraph",
|
|
270
316
|
children: [
|
|
271
317
|
{
|
|
272
|
-
type: "simpleCustomParagraph"
|
|
318
|
+
type: "simpleCustomParagraph",
|
|
273
319
|
content: "Nested Custom Paragraph 1",
|
|
274
320
|
},
|
|
275
321
|
{
|
|
276
|
-
type: "simpleCustomParagraph"
|
|
322
|
+
type: "simpleCustomParagraph",
|
|
277
323
|
content: "Nested Custom Paragraph 2",
|
|
278
324
|
},
|
|
279
325
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorTestCases } from "../index";
|
|
2
2
|
|
|
3
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
4
4
|
import {
|
|
5
5
|
DefaultBlockSchema,
|
|
6
6
|
DefaultStyleSchema,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EditorTestCases } from "../index";
|
|
2
2
|
|
|
3
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/
|
|
3
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
4
4
|
import {
|
|
5
5
|
DefaultBlockSchema,
|
|
6
6
|
DefaultInlineContentSchema,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
DefaultInlineContentSchema,
|
|
7
7
|
DefaultStyleSchema,
|
|
8
8
|
} from "../../../blocks/defaultBlocks";
|
|
9
|
-
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/
|
|
9
|
+
import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY";
|
|
10
10
|
|
|
11
11
|
export const defaultSchemaTestCases: EditorTestCases<
|
|
12
12
|
DefaultBlockSchema,
|
|
@@ -98,6 +98,74 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
98
98
|
},
|
|
99
99
|
],
|
|
100
100
|
},
|
|
101
|
+
{
|
|
102
|
+
name: "file/button",
|
|
103
|
+
blocks: [
|
|
104
|
+
{
|
|
105
|
+
type: "file",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "file/basic",
|
|
111
|
+
blocks: [
|
|
112
|
+
{
|
|
113
|
+
type: "file",
|
|
114
|
+
props: {
|
|
115
|
+
name: "example",
|
|
116
|
+
url: "exampleURL",
|
|
117
|
+
caption: "Caption",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "file/noName",
|
|
124
|
+
blocks: [
|
|
125
|
+
{
|
|
126
|
+
type: "file",
|
|
127
|
+
props: {
|
|
128
|
+
url: "exampleURL",
|
|
129
|
+
caption: "Caption",
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "file/noCaption",
|
|
136
|
+
blocks: [
|
|
137
|
+
{
|
|
138
|
+
type: "file",
|
|
139
|
+
props: {
|
|
140
|
+
name: "example",
|
|
141
|
+
url: "exampleURL",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "file/nested",
|
|
148
|
+
blocks: [
|
|
149
|
+
{
|
|
150
|
+
type: "file",
|
|
151
|
+
props: {
|
|
152
|
+
name: "example",
|
|
153
|
+
url: "exampleURL",
|
|
154
|
+
caption: "Caption",
|
|
155
|
+
},
|
|
156
|
+
children: [
|
|
157
|
+
{
|
|
158
|
+
type: "file",
|
|
159
|
+
props: {
|
|
160
|
+
name: "example",
|
|
161
|
+
url: "exampleURL",
|
|
162
|
+
caption: "Caption",
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
101
169
|
{
|
|
102
170
|
name: "image/button",
|
|
103
171
|
blocks: [
|
|
@@ -112,9 +180,51 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
112
180
|
{
|
|
113
181
|
type: "image",
|
|
114
182
|
props: {
|
|
183
|
+
name: "example",
|
|
184
|
+
url: "exampleURL",
|
|
185
|
+
caption: "Caption",
|
|
186
|
+
previewWidth: 256,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "image/noName",
|
|
193
|
+
blocks: [
|
|
194
|
+
{
|
|
195
|
+
type: "image",
|
|
196
|
+
props: {
|
|
197
|
+
url: "exampleURL",
|
|
198
|
+
caption: "Caption",
|
|
199
|
+
previewWidth: 256,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "image/noCaption",
|
|
206
|
+
blocks: [
|
|
207
|
+
{
|
|
208
|
+
type: "image",
|
|
209
|
+
props: {
|
|
210
|
+
name: "example",
|
|
211
|
+
url: "exampleURL",
|
|
212
|
+
previewWidth: 256,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "image/noPreview",
|
|
219
|
+
blocks: [
|
|
220
|
+
{
|
|
221
|
+
type: "image",
|
|
222
|
+
props: {
|
|
223
|
+
name: "example",
|
|
115
224
|
url: "exampleURL",
|
|
116
225
|
caption: "Caption",
|
|
117
|
-
|
|
226
|
+
showPreview: false,
|
|
227
|
+
previewWidth: 256,
|
|
118
228
|
},
|
|
119
229
|
},
|
|
120
230
|
],
|
|
@@ -127,7 +237,7 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
127
237
|
props: {
|
|
128
238
|
url: "exampleURL",
|
|
129
239
|
caption: "Caption",
|
|
130
|
-
|
|
240
|
+
previewWidth: 256,
|
|
131
241
|
},
|
|
132
242
|
children: [
|
|
133
243
|
{
|
|
@@ -135,7 +245,7 @@ export const defaultSchemaTestCases: EditorTestCases<
|
|
|
135
245
|
props: {
|
|
136
246
|
url: "exampleURL",
|
|
137
247
|
caption: "Caption",
|
|
138
|
-
|
|
248
|
+
previewWidth: 256,
|
|
139
249
|
},
|
|
140
250
|
},
|
|
141
251
|
],
|