@prismicio/types-internal 2.2.0-traverse.alpha-9 → 2.2.0-traverse.alpha-10
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/lib/content/Document.d.ts +384 -192
- package/lib/content/fields/GroupContent.d.ts +84 -42
- package/lib/content/fields/WidgetContent.d.ts +384 -192
- package/lib/content/fields/nestable/NestableContent.d.ts +48 -24
- package/lib/content/fields/nestable/RichTextContent/Blocks.d.ts +114 -111
- package/lib/content/fields/nestable/RichTextContent/Blocks.js +23 -18
- package/lib/content/fields/nestable/RichTextContent/index.d.ts +60 -30
- package/lib/content/fields/slices/Slice/CompositeSliceContent.d.ts +96 -48
- package/lib/content/fields/slices/Slice/RepeatableContent.d.ts +36 -18
- package/lib/content/fields/slices/Slice/SharedSliceContent.d.ts +96 -48
- package/lib/content/fields/slices/Slice/SimpleSliceContent.d.ts +96 -48
- package/lib/content/fields/slices/Slice/index.d.ts +216 -108
- package/lib/content/fields/slices/SliceItem.d.ts +216 -108
- package/lib/content/fields/slices/SlicesContent.d.ts +288 -144
- package/package.json +1 -1
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +29 -24
- package/lib/import/converters/fields/nestable/GeooPoint.d.ts +0 -3
- package/lib/import/converters/fields/nestable/GeooPoint.js +0 -15
- package/lib/import/converters/fields/nestable/RichText.d.ts +0 -4
- package/lib/import/converters/fields/nestable/RichText.js +0 -55
|
@@ -281,7 +281,7 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
|
|
|
281
281
|
text: t.StringC;
|
|
282
282
|
}>, t.PartialC<{
|
|
283
283
|
spans: t.Type<({
|
|
284
|
-
data
|
|
284
|
+
data: ({
|
|
285
285
|
__TYPE__: "ImageLink";
|
|
286
286
|
} & {
|
|
287
287
|
id: string;
|
|
@@ -319,15 +319,21 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
|
|
|
319
319
|
preview?: {
|
|
320
320
|
title?: string;
|
|
321
321
|
} | null | undefined;
|
|
322
|
-
})
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
322
|
+
});
|
|
323
|
+
start: number;
|
|
324
|
+
end: number;
|
|
325
|
+
type: "hyperlink";
|
|
326
|
+
} | {
|
|
327
|
+
data: string;
|
|
326
328
|
start: number;
|
|
327
329
|
end: number;
|
|
328
|
-
type: "
|
|
330
|
+
type: "label";
|
|
331
|
+
} | {
|
|
332
|
+
start: number;
|
|
333
|
+
end: number;
|
|
334
|
+
type: string;
|
|
329
335
|
})[], ({
|
|
330
|
-
data
|
|
336
|
+
data: ({
|
|
331
337
|
__TYPE__: "ImageLink";
|
|
332
338
|
} & {
|
|
333
339
|
id: string;
|
|
@@ -365,13 +371,19 @@ export declare const NestableContent: t.UnionC<[t.ExactC<t.TypeC<{
|
|
|
365
371
|
preview?: {
|
|
366
372
|
title?: string;
|
|
367
373
|
} | null | undefined;
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
374
|
+
});
|
|
375
|
+
start: number;
|
|
376
|
+
end: number;
|
|
377
|
+
type: "hyperlink";
|
|
378
|
+
} | {
|
|
379
|
+
data: string;
|
|
372
380
|
start: number;
|
|
373
381
|
end: number;
|
|
374
|
-
type: "
|
|
382
|
+
type: "label";
|
|
383
|
+
} | {
|
|
384
|
+
start: number;
|
|
385
|
+
end: number;
|
|
386
|
+
type: string;
|
|
375
387
|
})[], unknown>;
|
|
376
388
|
}>]>;
|
|
377
389
|
}>, t.PartialC<{
|
|
@@ -636,7 +648,7 @@ export declare const isNestableContent: (u: unknown) => u is {
|
|
|
636
648
|
text: string;
|
|
637
649
|
} & {
|
|
638
650
|
spans?: ({
|
|
639
|
-
data
|
|
651
|
+
data: ({
|
|
640
652
|
__TYPE__: "ImageLink";
|
|
641
653
|
} & {
|
|
642
654
|
id: string;
|
|
@@ -674,13 +686,19 @@ export declare const isNestableContent: (u: unknown) => u is {
|
|
|
674
686
|
preview?: {
|
|
675
687
|
title?: string;
|
|
676
688
|
} | null | undefined;
|
|
677
|
-
})
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
689
|
+
});
|
|
690
|
+
start: number;
|
|
691
|
+
end: number;
|
|
692
|
+
type: "hyperlink";
|
|
693
|
+
} | {
|
|
694
|
+
data: string;
|
|
681
695
|
start: number;
|
|
682
696
|
end: number;
|
|
683
|
-
type: "
|
|
697
|
+
type: "label";
|
|
698
|
+
} | {
|
|
699
|
+
start: number;
|
|
700
|
+
end: number;
|
|
701
|
+
type: string;
|
|
684
702
|
})[];
|
|
685
703
|
};
|
|
686
704
|
} & {
|
|
@@ -944,7 +962,7 @@ export declare const NestableLegacy: (ctx: LegacyContentCtx) => {
|
|
|
944
962
|
text: string;
|
|
945
963
|
} & {
|
|
946
964
|
spans?: ({
|
|
947
|
-
data
|
|
965
|
+
data: ({
|
|
948
966
|
__TYPE__: "ImageLink";
|
|
949
967
|
} & {
|
|
950
968
|
id: string;
|
|
@@ -982,13 +1000,19 @@ export declare const NestableLegacy: (ctx: LegacyContentCtx) => {
|
|
|
982
1000
|
preview?: {
|
|
983
1001
|
title?: string;
|
|
984
1002
|
} | null | undefined;
|
|
985
|
-
})
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1003
|
+
});
|
|
1004
|
+
start: number;
|
|
1005
|
+
end: number;
|
|
1006
|
+
type: "hyperlink";
|
|
1007
|
+
} | {
|
|
1008
|
+
data: string;
|
|
1009
|
+
start: number;
|
|
1010
|
+
end: number;
|
|
1011
|
+
type: "label";
|
|
1012
|
+
} | {
|
|
989
1013
|
start: number;
|
|
990
1014
|
end: number;
|
|
991
|
-
type:
|
|
1015
|
+
type: string;
|
|
992
1016
|
})[];
|
|
993
1017
|
};
|
|
994
1018
|
} & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from "io-ts";
|
|
2
|
-
export declare const Span: t.
|
|
3
|
-
data: t.UnionC<[t.
|
|
2
|
+
export declare const Span: t.UnionC<[t.ExactC<t.TypeC<{
|
|
3
|
+
data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
4
4
|
__TYPE__: t.LiteralC<"ImageLink">;
|
|
5
5
|
}>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
6
6
|
id: t.StringC;
|
|
@@ -106,34 +106,23 @@ export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
106
106
|
preview?: {
|
|
107
107
|
title?: string;
|
|
108
108
|
} | null | undefined;
|
|
109
|
-
}, unknown>]
|
|
110
|
-
label: t.StringC;
|
|
111
|
-
}>>]>;
|
|
112
|
-
}>, t.TypeC<{
|
|
109
|
+
}, unknown>]>;
|
|
113
110
|
start: t.NumberC;
|
|
114
111
|
end: t.NumberC;
|
|
115
|
-
type: t.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
hyperlink: null;
|
|
127
|
-
image: null;
|
|
128
|
-
embed: null;
|
|
129
|
-
"list-item": null;
|
|
130
|
-
"o-list-item": null;
|
|
131
|
-
rtl: null;
|
|
132
|
-
}>, t.LiteralC<"label">]>;
|
|
133
|
-
}>]>>;
|
|
112
|
+
type: t.LiteralC<"hyperlink">;
|
|
113
|
+
}>>, t.ExactC<t.TypeC<{
|
|
114
|
+
data: t.StringC;
|
|
115
|
+
start: t.NumberC;
|
|
116
|
+
end: t.NumberC;
|
|
117
|
+
type: t.LiteralC<"label">;
|
|
118
|
+
}>>, t.ExactC<t.TypeC<{
|
|
119
|
+
start: t.NumberC;
|
|
120
|
+
end: t.NumberC;
|
|
121
|
+
type: t.KeyofC<Record<string, null>>;
|
|
122
|
+
}>>]>;
|
|
134
123
|
export declare type Span = t.TypeOf<typeof Span>;
|
|
135
|
-
export declare const SpanLegacy: t.
|
|
136
|
-
data: t.UnionC<[t.
|
|
124
|
+
export declare const SpanLegacy: t.UnionC<[t.ExactC<t.TypeC<{
|
|
125
|
+
data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
137
126
|
__TYPE__: t.LiteralC<"ImageLink">;
|
|
138
127
|
}>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
139
128
|
id: t.StringC;
|
|
@@ -239,34 +228,23 @@ export declare const SpanLegacy: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
239
228
|
preview?: {
|
|
240
229
|
title?: string;
|
|
241
230
|
} | null | undefined;
|
|
242
|
-
}, unknown>]
|
|
243
|
-
label: t.StringC;
|
|
244
|
-
}>>]>;
|
|
245
|
-
}>, t.TypeC<{
|
|
231
|
+
}, unknown>]>;
|
|
246
232
|
start: t.NumberC;
|
|
247
233
|
end: t.NumberC;
|
|
248
|
-
type: t.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
hyperlink: null;
|
|
260
|
-
image: null;
|
|
261
|
-
embed: null;
|
|
262
|
-
"list-item": null;
|
|
263
|
-
"o-list-item": null;
|
|
264
|
-
rtl: null;
|
|
265
|
-
}>, t.LiteralC<"label">]>;
|
|
266
|
-
}>]>>;
|
|
234
|
+
type: t.LiteralC<"hyperlink">;
|
|
235
|
+
}>>, t.ExactC<t.TypeC<{
|
|
236
|
+
data: t.StringC;
|
|
237
|
+
start: t.NumberC;
|
|
238
|
+
end: t.NumberC;
|
|
239
|
+
type: t.LiteralC<"label">;
|
|
240
|
+
}>>, t.ExactC<t.TypeC<{
|
|
241
|
+
start: t.NumberC;
|
|
242
|
+
end: t.NumberC;
|
|
243
|
+
type: t.KeyofC<Record<string, null>>;
|
|
244
|
+
}>>]>;
|
|
267
245
|
export declare type SpanLegacy = t.TypeOf<typeof SpanLegacy>;
|
|
268
|
-
export declare const ValidatedSpans: <C extends t.
|
|
269
|
-
data: t.UnionC<[t.
|
|
246
|
+
export declare const ValidatedSpans: <C extends t.UnionC<[t.ExactC<t.TypeC<{
|
|
247
|
+
data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
270
248
|
__TYPE__: t.LiteralC<"ImageLink">;
|
|
271
249
|
}>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
272
250
|
id: t.StringC;
|
|
@@ -372,31 +350,20 @@ export declare const ValidatedSpans: <C extends t.ExactC<t.IntersectionC<[t.Part
|
|
|
372
350
|
preview?: {
|
|
373
351
|
title?: string;
|
|
374
352
|
} | null | undefined;
|
|
375
|
-
}, unknown>]
|
|
376
|
-
label: t.StringC;
|
|
377
|
-
}>>]>;
|
|
378
|
-
}>, t.TypeC<{
|
|
353
|
+
}, unknown>]>;
|
|
379
354
|
start: t.NumberC;
|
|
380
355
|
end: t.NumberC;
|
|
381
|
-
type: t.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
hyperlink: null;
|
|
393
|
-
image: null;
|
|
394
|
-
embed: null;
|
|
395
|
-
"list-item": null;
|
|
396
|
-
"o-list-item": null;
|
|
397
|
-
rtl: null;
|
|
398
|
-
}>, t.LiteralC<"label">]>;
|
|
399
|
-
}>]>>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
|
|
356
|
+
type: t.LiteralC<"hyperlink">;
|
|
357
|
+
}>>, t.ExactC<t.TypeC<{
|
|
358
|
+
data: t.StringC;
|
|
359
|
+
start: t.NumberC;
|
|
360
|
+
end: t.NumberC;
|
|
361
|
+
type: t.LiteralC<"label">;
|
|
362
|
+
}>>, t.ExactC<t.TypeC<{
|
|
363
|
+
start: t.NumberC;
|
|
364
|
+
end: t.NumberC;
|
|
365
|
+
type: t.KeyofC<Record<string, null>>;
|
|
366
|
+
}>>]>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
|
|
400
367
|
export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
401
368
|
type: t.LiteralC<"image">;
|
|
402
369
|
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
@@ -529,7 +496,7 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
529
496
|
text: t.StringC;
|
|
530
497
|
}>, t.PartialC<{
|
|
531
498
|
spans: t.Type<({
|
|
532
|
-
data
|
|
499
|
+
data: ({
|
|
533
500
|
__TYPE__: "ImageLink";
|
|
534
501
|
} & {
|
|
535
502
|
id: string;
|
|
@@ -567,15 +534,21 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
567
534
|
preview?: {
|
|
568
535
|
title?: string;
|
|
569
536
|
} | null | undefined;
|
|
570
|
-
})
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
537
|
+
});
|
|
538
|
+
start: number;
|
|
539
|
+
end: number;
|
|
540
|
+
type: "hyperlink";
|
|
541
|
+
} | {
|
|
542
|
+
data: string;
|
|
574
543
|
start: number;
|
|
575
544
|
end: number;
|
|
576
|
-
type: "
|
|
545
|
+
type: "label";
|
|
546
|
+
} | {
|
|
547
|
+
start: number;
|
|
548
|
+
end: number;
|
|
549
|
+
type: string;
|
|
577
550
|
})[], ({
|
|
578
|
-
data
|
|
551
|
+
data: ({
|
|
579
552
|
__TYPE__: "ImageLink";
|
|
580
553
|
} & {
|
|
581
554
|
id: string;
|
|
@@ -613,13 +586,19 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
613
586
|
preview?: {
|
|
614
587
|
title?: string;
|
|
615
588
|
} | null | undefined;
|
|
616
|
-
})
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
589
|
+
});
|
|
590
|
+
start: number;
|
|
591
|
+
end: number;
|
|
592
|
+
type: "hyperlink";
|
|
593
|
+
} | {
|
|
594
|
+
data: string;
|
|
620
595
|
start: number;
|
|
621
596
|
end: number;
|
|
622
|
-
type: "
|
|
597
|
+
type: "label";
|
|
598
|
+
} | {
|
|
599
|
+
start: number;
|
|
600
|
+
end: number;
|
|
601
|
+
type: string;
|
|
623
602
|
})[], unknown>;
|
|
624
603
|
}>]>;
|
|
625
604
|
}>, t.PartialC<{
|
|
@@ -725,7 +704,7 @@ export declare const BlockLegacy: t.Type<({
|
|
|
725
704
|
text: string;
|
|
726
705
|
} & {
|
|
727
706
|
spans?: ({
|
|
728
|
-
data
|
|
707
|
+
data: ({
|
|
729
708
|
__TYPE__: "ImageLink";
|
|
730
709
|
} & {
|
|
731
710
|
id: string;
|
|
@@ -763,13 +742,19 @@ export declare const BlockLegacy: t.Type<({
|
|
|
763
742
|
preview?: {
|
|
764
743
|
title?: string;
|
|
765
744
|
} | null | undefined;
|
|
766
|
-
})
|
|
767
|
-
label: string;
|
|
768
|
-
};
|
|
769
|
-
} & {
|
|
745
|
+
});
|
|
770
746
|
start: number;
|
|
771
747
|
end: number;
|
|
772
|
-
type: "
|
|
748
|
+
type: "hyperlink";
|
|
749
|
+
} | {
|
|
750
|
+
data: string;
|
|
751
|
+
start: number;
|
|
752
|
+
end: number;
|
|
753
|
+
type: "label";
|
|
754
|
+
} | {
|
|
755
|
+
start: number;
|
|
756
|
+
end: number;
|
|
757
|
+
type: string;
|
|
773
758
|
})[];
|
|
774
759
|
};
|
|
775
760
|
} & {
|
|
@@ -873,7 +858,7 @@ export declare const BlockLegacy: t.Type<({
|
|
|
873
858
|
text: string;
|
|
874
859
|
} & {
|
|
875
860
|
spans?: ({
|
|
876
|
-
data
|
|
861
|
+
data: ({
|
|
877
862
|
__TYPE__: "ImageLink";
|
|
878
863
|
} & {
|
|
879
864
|
id: string;
|
|
@@ -911,13 +896,19 @@ export declare const BlockLegacy: t.Type<({
|
|
|
911
896
|
preview?: {
|
|
912
897
|
title?: string;
|
|
913
898
|
} | null | undefined;
|
|
914
|
-
})
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
899
|
+
});
|
|
900
|
+
start: number;
|
|
901
|
+
end: number;
|
|
902
|
+
type: "hyperlink";
|
|
903
|
+
} | {
|
|
904
|
+
data: string;
|
|
905
|
+
start: number;
|
|
906
|
+
end: number;
|
|
907
|
+
type: "label";
|
|
908
|
+
} | {
|
|
918
909
|
start: number;
|
|
919
910
|
end: number;
|
|
920
|
-
type:
|
|
911
|
+
type: string;
|
|
921
912
|
})[];
|
|
922
913
|
};
|
|
923
914
|
} & {
|
|
@@ -1050,7 +1041,7 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
1050
1041
|
text: t.StringC;
|
|
1051
1042
|
}>, t.PartialC<{
|
|
1052
1043
|
spans: t.Type<({
|
|
1053
|
-
data
|
|
1044
|
+
data: ({
|
|
1054
1045
|
__TYPE__: "ImageLink";
|
|
1055
1046
|
} & {
|
|
1056
1047
|
id: string;
|
|
@@ -1088,15 +1079,21 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
1088
1079
|
preview?: {
|
|
1089
1080
|
title?: string;
|
|
1090
1081
|
} | null | undefined;
|
|
1091
|
-
})
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1082
|
+
});
|
|
1083
|
+
start: number;
|
|
1084
|
+
end: number;
|
|
1085
|
+
type: "hyperlink";
|
|
1086
|
+
} | {
|
|
1087
|
+
data: string;
|
|
1088
|
+
start: number;
|
|
1089
|
+
end: number;
|
|
1090
|
+
type: "label";
|
|
1091
|
+
} | {
|
|
1095
1092
|
start: number;
|
|
1096
1093
|
end: number;
|
|
1097
|
-
type:
|
|
1094
|
+
type: string;
|
|
1098
1095
|
})[], ({
|
|
1099
|
-
data
|
|
1096
|
+
data: ({
|
|
1100
1097
|
__TYPE__: "ImageLink";
|
|
1101
1098
|
} & {
|
|
1102
1099
|
id: string;
|
|
@@ -1134,13 +1131,19 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
1134
1131
|
preview?: {
|
|
1135
1132
|
title?: string;
|
|
1136
1133
|
} | null | undefined;
|
|
1137
|
-
})
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1134
|
+
});
|
|
1135
|
+
start: number;
|
|
1136
|
+
end: number;
|
|
1137
|
+
type: "hyperlink";
|
|
1138
|
+
} | {
|
|
1139
|
+
data: string;
|
|
1140
|
+
start: number;
|
|
1141
|
+
end: number;
|
|
1142
|
+
type: "label";
|
|
1143
|
+
} | {
|
|
1141
1144
|
start: number;
|
|
1142
1145
|
end: number;
|
|
1143
|
-
type:
|
|
1146
|
+
type: string;
|
|
1144
1147
|
})[], unknown>;
|
|
1145
1148
|
}>]>;
|
|
1146
1149
|
}>, t.PartialC<{
|
|
@@ -6,27 +6,36 @@ const fp_ts_1 = require("fp-ts");
|
|
|
6
6
|
const Either_1 = require("fp-ts/lib/Either");
|
|
7
7
|
const function_1 = require("fp-ts/lib/function");
|
|
8
8
|
const t = (0, tslib_1.__importStar)(require("io-ts"));
|
|
9
|
+
const io_ts_types_1 = require("io-ts-types");
|
|
9
10
|
const nestable_1 = require("../../../../customtypes/widgets/nestable");
|
|
10
11
|
const validators_1 = require("../../../../validators");
|
|
11
12
|
const function_2 = require("../../../../validators/function");
|
|
12
13
|
const EmbedContent_1 = require("../EmbedContent");
|
|
13
14
|
const ImageContent_1 = require("../ImageContent");
|
|
14
15
|
const LinkContent_1 = require("../LinkContent");
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const linkSpan = (linkCodec) => t.strict({
|
|
17
|
+
data: linkCodec,
|
|
18
|
+
start: t.number,
|
|
19
|
+
end: t.number,
|
|
20
|
+
type: t.literal(nestable_1.RichTextNodeType.hyperlink),
|
|
17
21
|
});
|
|
18
|
-
const
|
|
19
|
-
t.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
t.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
])
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const labelSpan = t.strict({
|
|
23
|
+
data: (0, io_ts_types_1.withFallback)(t.string, ""),
|
|
24
|
+
start: t.number,
|
|
25
|
+
end: t.number,
|
|
26
|
+
type: t.literal("label"),
|
|
27
|
+
});
|
|
28
|
+
const span = t.strict({
|
|
29
|
+
start: t.number,
|
|
30
|
+
end: t.number,
|
|
31
|
+
type: t.keyof(Object.entries(nestable_1.RichTextNodeType).reduce((acc, [, name]) => {
|
|
32
|
+
if (name === nestable_1.RichTextNodeType.hyperlink)
|
|
33
|
+
return acc;
|
|
34
|
+
return { ...acc, [name]: null };
|
|
35
|
+
}, {})),
|
|
36
|
+
});
|
|
37
|
+
exports.Span = t.union([linkSpan(LinkContent_1.Link), labelSpan, span]);
|
|
38
|
+
exports.SpanLegacy = t.union([linkSpan(LinkContent_1.LinkLegacy), labelSpan, span]);
|
|
30
39
|
const ValidatedSpans = (spanCodec) => {
|
|
31
40
|
return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
|
|
32
41
|
if (Array.isArray(spans)) {
|
|
@@ -35,10 +44,6 @@ const ValidatedSpans = (spanCodec) => {
|
|
|
35
44
|
const decodedSpan = spanCodec.decode(maybeSpan);
|
|
36
45
|
if ((0, Either_1.isLeft)(decodedSpan))
|
|
37
46
|
return acc;
|
|
38
|
-
if ((decodedSpan.right.type === "hyperlink" ||
|
|
39
|
-
decodedSpan.right.type === "label") &&
|
|
40
|
-
!decodedSpan.right.data)
|
|
41
|
-
return acc;
|
|
42
47
|
return [...acc, decodedSpan.right];
|
|
43
48
|
}, [])
|
|
44
49
|
.sort((m1, m2) => m1.start - m2.start);
|