@prismicio/types-internal 3.4.0-alpha.2 → 3.4.0-alpha.4

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 (55) hide show
  1. package/lib/content/Document.d.ts +3305 -3323
  2. package/lib/content/fields/RepeatableContent.d.ts +51 -123
  3. package/lib/content/fields/RepeatableContent.js +10 -14
  4. package/lib/content/fields/WidgetContent.d.ts +3046 -3064
  5. package/lib/content/fields/nestable/NestableContent.d.ts +501 -504
  6. package/lib/content/fields/nestable/NestableContent.js +0 -7
  7. package/lib/content/fields/nestable/RichTextContent/Block.d.ts +1036 -0
  8. package/lib/content/fields/nestable/RichTextContent/Block.js +31 -0
  9. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.d.ts +60 -0
  10. package/lib/content/fields/nestable/RichTextContent/EmbedBlock.js +53 -0
  11. package/lib/content/fields/nestable/RichTextContent/ImageBlock.d.ts +203 -0
  12. package/lib/content/fields/nestable/RichTextContent/ImageBlock.js +36 -0
  13. package/lib/content/fields/nestable/RichTextContent/TableBlock.d.ts +500 -0
  14. package/lib/content/fields/nestable/RichTextContent/TableBlock.js +21 -0
  15. package/lib/content/fields/nestable/RichTextContent/TextBlock.d.ts +590 -0
  16. package/lib/content/fields/nestable/RichTextContent/TextBlock.js +80 -0
  17. package/lib/content/fields/nestable/RichTextContent/index.d.ts +637 -9
  18. package/lib/content/fields/nestable/RichTextContent/index.js +4 -4
  19. package/lib/content/fields/nestable/TableContent.d.ts +245 -12
  20. package/lib/content/fields/nestable/TableContent.js +7 -7
  21. package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +1013 -1019
  22. package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +234 -235
  23. package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +1013 -1019
  24. package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +501 -504
  25. package/lib/content/fields/slices/Slice/SlicePrimaryContent.d.ts +499 -502
  26. package/lib/content/fields/slices/Slice/index.d.ts +1852 -1862
  27. package/lib/content/fields/slices/SliceItem.d.ts +1957 -1967
  28. package/lib/content/fields/slices/SlicesContent.d.ts +2619 -2634
  29. package/lib/customtypes/CustomType.d.ts +0 -108
  30. package/lib/customtypes/Section.d.ts +0 -108
  31. package/lib/customtypes/diff/SharedSlice.d.ts +0 -48
  32. package/lib/customtypes/diff/Variation.d.ts +0 -48
  33. package/lib/customtypes/widgets/Group.d.ts +0 -36
  34. package/lib/customtypes/widgets/Widget.d.ts +0 -126
  35. package/lib/customtypes/widgets/nestable/NestableWidget.d.ts +0 -6
  36. package/lib/customtypes/widgets/nestable/NestableWidget.js +0 -2
  37. package/lib/customtypes/widgets/nestable/RichText.d.ts +2 -0
  38. package/lib/customtypes/widgets/nestable/RichText.js +2 -0
  39. package/lib/customtypes/widgets/slices/CompositeSlice.d.ts +0 -12
  40. package/lib/customtypes/widgets/slices/LegacySlice.d.ts +0 -12
  41. package/lib/customtypes/widgets/slices/SharedSlice.d.ts +0 -48
  42. package/lib/customtypes/widgets/slices/SlicePrimaryWidget.d.ts +0 -36
  43. package/lib/customtypes/widgets/slices/Slices.d.ts +0 -168
  44. package/package.json +1 -1
  45. package/src/content/fields/nestable/NestableContent.ts +0 -12
  46. package/src/content/fields/nestable/RichTextContent/Block.ts +35 -0
  47. package/src/content/fields/nestable/RichTextContent/EmbedBlock.ts +81 -0
  48. package/src/content/fields/nestable/RichTextContent/ImageBlock.ts +42 -0
  49. package/src/content/fields/nestable/RichTextContent/TableBlock.ts +36 -0
  50. package/src/content/fields/nestable/RichTextContent/TextBlock.ts +108 -0
  51. package/src/content/fields/nestable/RichTextContent/index.ts +2 -2
  52. package/src/content/fields/nestable/TableContent.ts +6 -6
  53. package/src/customtypes/widgets/nestable/NestableWidget.ts +0 -2
  54. package/src/customtypes/widgets/nestable/RichText.ts +2 -0
  55. package/src/content/fields/nestable/RichTextContent/Blocks.ts +0 -238
@@ -113,12 +113,6 @@ export declare function slicesConfigReader<T extends SharedSlice | SharedSliceRe
113
113
  config: t.ExactC<t.PartialC<{
114
114
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
115
115
  }>>;
116
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
117
- type: t.LiteralC<"Table">;
118
- }>, t.PartialC<{
119
- config: t.ExactC<t.PartialC<{
120
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
121
- }>>;
122
116
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
123
117
  type: t.LiteralC<"Text">;
124
118
  }>, t.PartialC<{
@@ -287,12 +281,6 @@ export declare function slicesConfigReader<T extends SharedSlice | SharedSliceRe
287
281
  config: t.ExactC<t.PartialC<{
288
282
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
289
283
  }>>;
290
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
291
- type: t.LiteralC<"Table">;
292
- }>, t.PartialC<{
293
- config: t.ExactC<t.PartialC<{
294
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
295
- }>>;
296
284
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
297
285
  type: t.LiteralC<"Text">;
298
286
  }>, t.PartialC<{
@@ -461,12 +449,6 @@ export declare function slicesConfigReader<T extends SharedSlice | SharedSliceRe
461
449
  config: t.ExactC<t.PartialC<{
462
450
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
463
451
  }>>;
464
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
465
- type: t.LiteralC<"Table">;
466
- }>, t.PartialC<{
467
- config: t.ExactC<t.PartialC<{
468
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
469
- }>>;
470
452
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
471
453
  type: t.LiteralC<"Text">;
472
454
  }>, t.PartialC<{
@@ -627,12 +609,6 @@ export declare function slicesConfigReader<T extends SharedSlice | SharedSliceRe
627
609
  config: t.ExactC<t.PartialC<{
628
610
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
629
611
  }>>;
630
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
631
- type: t.LiteralC<"Table">;
632
- }>, t.PartialC<{
633
- config: t.ExactC<t.PartialC<{
634
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
635
- }>>;
636
612
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
637
613
  type: t.LiteralC<"Text">;
638
614
  }>, t.PartialC<{
@@ -805,12 +781,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
805
781
  config: t.ExactC<t.PartialC<{
806
782
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
807
783
  }>>;
808
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
809
- type: t.LiteralC<"Table">;
810
- }>, t.PartialC<{
811
- config: t.ExactC<t.PartialC<{
812
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
813
- }>>;
814
784
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
815
785
  type: t.LiteralC<"Text">;
816
786
  }>, t.PartialC<{
@@ -979,12 +949,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
979
949
  config: t.ExactC<t.PartialC<{
980
950
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
981
951
  }>>;
982
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
983
- type: t.LiteralC<"Table">;
984
- }>, t.PartialC<{
985
- config: t.ExactC<t.PartialC<{
986
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
987
- }>>;
988
952
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
989
953
  type: t.LiteralC<"Text">;
990
954
  }>, t.PartialC<{
@@ -1153,12 +1117,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
1153
1117
  config: t.ExactC<t.PartialC<{
1154
1118
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1155
1119
  }>>;
1156
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
1157
- type: t.LiteralC<"Table">;
1158
- }>, t.PartialC<{
1159
- config: t.ExactC<t.PartialC<{
1160
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1161
- }>>;
1162
1120
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
1163
1121
  type: t.LiteralC<"Text">;
1164
1122
  }>, t.PartialC<{
@@ -1319,12 +1277,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
1319
1277
  config: t.ExactC<t.PartialC<{
1320
1278
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1321
1279
  }>>;
1322
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
1323
- type: t.LiteralC<"Table">;
1324
- }>, t.PartialC<{
1325
- config: t.ExactC<t.PartialC<{
1326
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
1327
- }>>;
1328
1280
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
1329
1281
  type: t.LiteralC<"Text">;
1330
1282
  }>, t.PartialC<{
@@ -1546,12 +1498,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
1546
1498
  config?: {
1547
1499
  label?: string | null | undefined;
1548
1500
  };
1549
- }) | ({
1550
- type: "Table";
1551
- } & {
1552
- config?: {
1553
- label?: string | null | undefined;
1554
- };
1555
1501
  }) | ({
1556
1502
  type: "Text";
1557
1503
  } & {
@@ -1721,12 +1667,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
1721
1667
  config?: {
1722
1668
  label?: string | null | undefined;
1723
1669
  };
1724
- }) | ({
1725
- type: "Table";
1726
- } & {
1727
- config?: {
1728
- label?: string | null | undefined;
1729
- };
1730
1670
  }) | ({
1731
1671
  type: "Text";
1732
1672
  } & {
@@ -1896,12 +1836,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
1896
1836
  config?: {
1897
1837
  label?: string | null | undefined;
1898
1838
  };
1899
- }) | ({
1900
- type: "Table";
1901
- } & {
1902
- config?: {
1903
- label?: string | null | undefined;
1904
- };
1905
1839
  }) | ({
1906
1840
  type: "Text";
1907
1841
  } & {
@@ -2070,12 +2004,6 @@ export declare const StaticSlicesConfig: t.ExactC<t.PartialC<{
2070
2004
  config?: {
2071
2005
  label?: string | null | undefined;
2072
2006
  };
2073
- }) | ({
2074
- type: "Table";
2075
- } & {
2076
- config?: {
2077
- label?: string | null | undefined;
2078
- };
2079
2007
  }) | ({
2080
2008
  type: "Text";
2081
2009
  } & {
@@ -2209,12 +2137,6 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
2209
2137
  config: t.ExactC<t.PartialC<{
2210
2138
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2211
2139
  }>>;
2212
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2213
- type: t.LiteralC<"Table">;
2214
- }>, t.PartialC<{
2215
- config: t.ExactC<t.PartialC<{
2216
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2217
- }>>;
2218
2140
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2219
2141
  type: t.LiteralC<"Text">;
2220
2142
  }>, t.PartialC<{
@@ -2383,12 +2305,6 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
2383
2305
  config: t.ExactC<t.PartialC<{
2384
2306
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2385
2307
  }>>;
2386
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2387
- type: t.LiteralC<"Table">;
2388
- }>, t.PartialC<{
2389
- config: t.ExactC<t.PartialC<{
2390
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2391
- }>>;
2392
2308
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2393
2309
  type: t.LiteralC<"Text">;
2394
2310
  }>, t.PartialC<{
@@ -2557,12 +2473,6 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
2557
2473
  config: t.ExactC<t.PartialC<{
2558
2474
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2559
2475
  }>>;
2560
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2561
- type: t.LiteralC<"Table">;
2562
- }>, t.PartialC<{
2563
- config: t.ExactC<t.PartialC<{
2564
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2565
- }>>;
2566
2476
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2567
2477
  type: t.LiteralC<"Text">;
2568
2478
  }>, t.PartialC<{
@@ -2723,12 +2633,6 @@ export declare const DynamicSlicesConfig: t.ExactC<t.PartialC<{
2723
2633
  config: t.ExactC<t.PartialC<{
2724
2634
  label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2725
2635
  }>>;
2726
- }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2727
- type: t.LiteralC<"Table">;
2728
- }>, t.PartialC<{
2729
- config: t.ExactC<t.PartialC<{
2730
- label: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
2731
- }>>;
2732
2636
  }>]>>, t.ExactC<t.IntersectionC<[t.TypeC<{
2733
2637
  type: t.LiteralC<"Text">;
2734
2638
  }>, t.PartialC<{
@@ -2967,12 +2871,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
2967
2871
  config?: {
2968
2872
  label?: string | null | undefined;
2969
2873
  };
2970
- }) | ({
2971
- type: "Table";
2972
- } & {
2973
- config?: {
2974
- label?: string | null | undefined;
2975
- };
2976
2874
  }) | ({
2977
2875
  type: "Text";
2978
2876
  } & {
@@ -3142,12 +3040,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
3142
3040
  config?: {
3143
3041
  label?: string | null | undefined;
3144
3042
  };
3145
- }) | ({
3146
- type: "Table";
3147
- } & {
3148
- config?: {
3149
- label?: string | null | undefined;
3150
- };
3151
3043
  }) | ({
3152
3044
  type: "Text";
3153
3045
  } & {
@@ -3318,12 +3210,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
3318
3210
  config?: {
3319
3211
  label?: string | null | undefined;
3320
3212
  };
3321
- }) | ({
3322
- type: "Table";
3323
- } & {
3324
- config?: {
3325
- label?: string | null | undefined;
3326
- };
3327
3213
  }) | ({
3328
3214
  type: "Text";
3329
3215
  } & {
@@ -3486,12 +3372,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
3486
3372
  config?: {
3487
3373
  label?: string | null | undefined;
3488
3374
  };
3489
- }) | ({
3490
- type: "Table";
3491
- } & {
3492
- config?: {
3493
- label?: string | null | undefined;
3494
- };
3495
3375
  }) | ({
3496
3376
  type: "Text";
3497
3377
  } & {
@@ -3670,12 +3550,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
3670
3550
  config?: {
3671
3551
  label?: string | null | undefined;
3672
3552
  };
3673
- }) | ({
3674
- type: "Table";
3675
- } & {
3676
- config?: {
3677
- label?: string | null | undefined;
3678
- };
3679
3553
  }) | ({
3680
3554
  type: "Text";
3681
3555
  } & {
@@ -3845,12 +3719,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
3845
3719
  config?: {
3846
3720
  label?: string | null | undefined;
3847
3721
  };
3848
- }) | ({
3849
- type: "Table";
3850
- } & {
3851
- config?: {
3852
- label?: string | null | undefined;
3853
- };
3854
3722
  }) | ({
3855
3723
  type: "Text";
3856
3724
  } & {
@@ -4020,12 +3888,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4020
3888
  config?: {
4021
3889
  label?: string | null | undefined;
4022
3890
  };
4023
- }) | ({
4024
- type: "Table";
4025
- } & {
4026
- config?: {
4027
- label?: string | null | undefined;
4028
- };
4029
3891
  }) | ({
4030
3892
  type: "Text";
4031
3893
  } & {
@@ -4194,12 +4056,6 @@ export declare const StaticSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4194
4056
  config?: {
4195
4057
  label?: string | null | undefined;
4196
4058
  };
4197
- }) | ({
4198
- type: "Table";
4199
- } & {
4200
- config?: {
4201
- label?: string | null | undefined;
4202
- };
4203
4059
  }) | ({
4204
4060
  type: "Text";
4205
4061
  } & {
@@ -4389,12 +4245,6 @@ export declare const DynamicSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4389
4245
  config?: {
4390
4246
  label?: string | null | undefined;
4391
4247
  };
4392
- }) | ({
4393
- type: "Table";
4394
- } & {
4395
- config?: {
4396
- label?: string | null | undefined;
4397
- };
4398
4248
  }) | ({
4399
4249
  type: "Text";
4400
4250
  } & {
@@ -4564,12 +4414,6 @@ export declare const DynamicSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4564
4414
  config?: {
4565
4415
  label?: string | null | undefined;
4566
4416
  };
4567
- }) | ({
4568
- type: "Table";
4569
- } & {
4570
- config?: {
4571
- label?: string | null | undefined;
4572
- };
4573
4417
  }) | ({
4574
4418
  type: "Text";
4575
4419
  } & {
@@ -4740,12 +4584,6 @@ export declare const DynamicSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4740
4584
  config?: {
4741
4585
  label?: string | null | undefined;
4742
4586
  };
4743
- }) | ({
4744
- type: "Table";
4745
- } & {
4746
- config?: {
4747
- label?: string | null | undefined;
4748
- };
4749
4587
  }) | ({
4750
4588
  type: "Text";
4751
4589
  } & {
@@ -4908,12 +4746,6 @@ export declare const DynamicSlices: t.ExactC<t.IntersectionC<[t.TypeC<{
4908
4746
  config?: {
4909
4747
  label?: string | null | undefined;
4910
4748
  };
4911
- }) | ({
4912
- type: "Table";
4913
- } & {
4914
- config?: {
4915
- label?: string | null | undefined;
4916
- };
4917
4749
  }) | ({
4918
4750
  type: "Text";
4919
4751
  } & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/types-internal",
3
- "version": "3.4.0-alpha.2",
3
+ "version": "3.4.0-alpha.4",
4
4
  "description": "Prismic types for Custom Types and Prismic Data",
5
5
  "keywords": [
6
6
  "typescript",
@@ -83,12 +83,6 @@ import {
83
83
  SeparatorContentType,
84
84
  SeparatorLegacy,
85
85
  } from "./SeparatorContent"
86
- import {
87
- isTableContent,
88
- TableContent,
89
- TableContentType,
90
- TableLegacy,
91
- } from "./TableContent"
92
86
 
93
87
  export const NestableContent = t.union([
94
88
  EmptyContent,
@@ -107,7 +101,6 @@ export const NestableContent = t.union([
107
101
  LinkContent,
108
102
  RichTextContent,
109
103
  SeparatorContent,
110
- TableContent,
111
104
  RepeatableContent,
112
105
  ])
113
106
  export type NestableContent = t.TypeOf<typeof NestableContent>
@@ -142,7 +135,6 @@ export const isNestableContent = (u: unknown): u is NestableContent =>
142
135
  isIntegrationFieldContent(u) ||
143
136
  isLinkContent(u) ||
144
137
  isSeparatorContent(u) ||
145
- isTableContent(u) ||
146
138
  isEmptyContent(u) ||
147
139
  isRepeatableContent(u)
148
140
 
@@ -186,8 +178,6 @@ export const NestableLegacy = (ctx: LegacyContentCtx) => {
186
178
  return LinkContentLegacy(ctx)
187
179
  case "Separator":
188
180
  return SeparatorLegacy(ctx)
189
- case "Table":
190
- return TableLegacy(ctx)
191
181
  case "Repeatable.Link":
192
182
  return RepeatableLegacy(ctx, "Link")
193
183
  default:
@@ -228,8 +218,6 @@ export const NestableLegacy = (ctx: LegacyContentCtx) => {
228
218
  return LinkContentLegacy(ctx).encode(value)
229
219
  case SeparatorContentType:
230
220
  return SeparatorLegacy(ctx).encode(value)
231
- case TableContentType:
232
- return TableLegacy(ctx).encode(value)
233
221
  case "RepeatableContent":
234
222
  return RepeatableLegacy(ctx, value.type).encode(value)
235
223
 
@@ -0,0 +1,35 @@
1
+ import * as t from "io-ts"
2
+
3
+ import { EmbedBlock, EmbedBlockLegacy } from "./EmbedBlock"
4
+ import { ImageBlock, ImageBlockLegacy } from "./ImageBlock"
5
+ import { TableBlock, TableBlockLegacy } from "./TableBlock"
6
+ import { TextBlock, TextBlockLegacy } from "./TextBlock"
7
+
8
+ const legacyBlockCodec = t.union([
9
+ EmbedBlockLegacy,
10
+ ImageBlockLegacy,
11
+ TextBlockLegacy,
12
+ TableBlockLegacy,
13
+ ])
14
+ type BlockLegacy = t.TypeOf<typeof legacyBlockCodec>
15
+
16
+ export const BlockLegacy = new t.Type<Block, BlockLegacy, unknown>(
17
+ "BlockLegacy",
18
+ (u): u is Block =>
19
+ EmbedBlockLegacy.is(u) ||
20
+ ImageBlockLegacy.is(u) ||
21
+ TextBlockLegacy.is(u) ||
22
+ TableBlockLegacy.is(u),
23
+ (legacyBlock) => legacyBlockCodec.decode(legacyBlock),
24
+ (block: Block) => {
25
+ return (() => {
26
+ if (ImageBlock.is(block)) return ImageBlockLegacy.encode(block)
27
+ else if (EmbedBlock.is(block)) return EmbedBlockLegacy.encode(block)
28
+ else if (TableBlock.is(block)) return TableBlockLegacy.encode(block)
29
+ else return TextBlockLegacy.encode(block)
30
+ })() as BlockLegacy
31
+ },
32
+ )
33
+
34
+ export const Block = t.union([ImageBlock, EmbedBlock, TextBlock, TableBlock])
35
+ export type Block = t.TypeOf<typeof Block>
@@ -0,0 +1,81 @@
1
+ import { either } from "fp-ts"
2
+ import { pipe } from "fp-ts/lib/function"
3
+ import * as t from "io-ts"
4
+
5
+ import { RichTextNodeType } from "../../../../customtypes/widgets/nestable"
6
+ import { StringOrNull } from "../../../../validators"
7
+ import {
8
+ EmbedContent,
9
+ EmbedContentLegacy,
10
+ EmbedContentType,
11
+ EmbedLegacy,
12
+ } from "../EmbedContent"
13
+ import type { Block } from "./Block"
14
+
15
+ const embedBlockLegacyCodec = t.exact(
16
+ t.intersection([
17
+ t.type({
18
+ type: t.literal(RichTextNodeType.embed),
19
+ data: t.unknown,
20
+ }),
21
+ t.partial({
22
+ label: StringOrNull,
23
+ direction: StringOrNull,
24
+ }),
25
+ ]),
26
+ )
27
+
28
+ type EmbedBlockLegacy = t.TypeOf<typeof embedBlockLegacyCodec>
29
+
30
+ export const EmbedBlockLegacy = new t.Type<
31
+ EmbedBlock,
32
+ EmbedBlockLegacy,
33
+ unknown
34
+ >(
35
+ "EmbedBlockLegacy",
36
+ (u): u is EmbedBlock => (u as EmbedBlock).type === "embed",
37
+ (block) =>
38
+ pipe(
39
+ embedBlockLegacyCodec.decode(block),
40
+ either.chain((decodedBlock) => {
41
+ return either.map<EmbedLegacy, [EmbedBlockLegacy, EmbedLegacy]>(
42
+ (decodedData: EmbedLegacy) => {
43
+ return [decodedBlock, decodedData]
44
+ },
45
+ )(EmbedContentLegacy.decode(decodedBlock.data))
46
+ }),
47
+ either.map(([block, parsedData]) => {
48
+ return EmbedBlock.encode({
49
+ ...block,
50
+ data: {
51
+ ...parsedData,
52
+ __TYPE__: EmbedContentType,
53
+ all: block.data,
54
+ },
55
+ })
56
+ }),
57
+ ),
58
+ (embedBlock: EmbedBlock): EmbedBlockLegacy => {
59
+ return {
60
+ ...embedBlockLegacyCodec.encode(embedBlock),
61
+ data: EmbedContentLegacy.encode(embedBlock.data),
62
+ }
63
+ },
64
+ )
65
+ export const EmbedBlock = t.exact(
66
+ t.intersection([
67
+ t.type({
68
+ type: t.literal(RichTextNodeType.embed),
69
+ data: EmbedContent,
70
+ }),
71
+ t.partial({
72
+ label: StringOrNull,
73
+ direction: StringOrNull,
74
+ }),
75
+ ]),
76
+ )
77
+ export type EmbedBlock = t.TypeOf<typeof EmbedBlock>
78
+
79
+ export function checkEmbedBlock(block: Block): block is EmbedBlock {
80
+ return block.type === RichTextNodeType.embed
81
+ }
@@ -0,0 +1,42 @@
1
+ import * as t from "io-ts"
2
+
3
+ import { RichTextNodeType } from "../../../../customtypes/widgets/nestable"
4
+ import { StringOrNull } from "../../../../validators"
5
+ import { nullable } from "../../../../validators/function"
6
+ import { ImageContentView } from "../ImageContent"
7
+ import { FilledLink, FilledLinkLegacy } from "../LinkContent"
8
+ import type { Block } from "./Block"
9
+
10
+ // We allow any codec here and let TypeScript infer the resulting codec.
11
+ // Typing it more precisely creates conflicts.
12
+ //
13
+ // Using `t.Mixed` rather than `t.Type<A, O>` causes `data.linkTo` to be
14
+ // typed as `any`. It seems to be an issue with the `nullable` helper.
15
+ const ImageBlockCodec = <A, O>(linkCodec: t.Type<A, O>) =>
16
+ t.exact(
17
+ t.intersection([
18
+ t.type({
19
+ type: t.literal(RichTextNodeType.image),
20
+ data: t.intersection([
21
+ ImageContentView,
22
+ t.partial({
23
+ linkTo: nullable(linkCodec),
24
+ }),
25
+ ]),
26
+ }),
27
+ t.partial({
28
+ label: StringOrNull,
29
+ direction: StringOrNull,
30
+ }),
31
+ ]),
32
+ )
33
+
34
+ export const ImageBlock = ImageBlockCodec(FilledLink)
35
+ export type ImageBlock = t.TypeOf<typeof ImageBlock>
36
+
37
+ export const ImageBlockLegacy = ImageBlockCodec(FilledLinkLegacy)
38
+ export type ImageBlockLegacy = t.TypeOf<typeof ImageBlockLegacy>
39
+
40
+ export function checkImageBlock(block: Block): block is ImageBlock {
41
+ return block.type === RichTextNodeType.image
42
+ }
@@ -0,0 +1,36 @@
1
+ import { either } from "fp-ts"
2
+ import { pipe } from "fp-ts/lib/function"
3
+ import * as t from "io-ts"
4
+
5
+ import { RichTextNodeType } from "../../../../customtypes/widgets/nestable"
6
+ import { tableContentLegacyCodec, TableLegacy, TableRow } from "../TableContent"
7
+
8
+ export const TableBlockLegacy = new t.Type<TableBlock, TableLegacy, unknown>(
9
+ "TableBlockLegacy",
10
+ (u): u is TableBlock => (u as TableBlock).type === "table",
11
+ (block: unknown) => {
12
+ return pipe(
13
+ tableContentLegacyCodec.decode(block),
14
+ either.map(
15
+ (parseBlock: TableLegacy): TableBlock => ({
16
+ type: RichTextNodeType.table,
17
+ content: parseBlock.content.map(TableRow.encode),
18
+ }),
19
+ ),
20
+ )
21
+ },
22
+ (tableBlock: TableBlock): TableLegacy => {
23
+ return tableContentLegacyCodec.encode(tableBlock)
24
+ },
25
+ )
26
+
27
+ export type TableBlockLegacy = t.TypeOf<typeof TableBlockLegacy>
28
+
29
+ export const TableBlock = t.exact(
30
+ t.type({
31
+ type: t.literal(RichTextNodeType.table),
32
+ content: t.array(TableRow),
33
+ }),
34
+ )
35
+
36
+ export type TableBlock = t.TypeOf<typeof TableBlock>