@prismicio/types-internal 2.2.0-traverse.alpha-9 → 2.2.0-traverse.alpha-11
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 +117 -105
- 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/lib/import/converters/fields/nestable/RichText/textBlock.js +29 -16
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/ImportTextBlock.d.ts +9 -1
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.d.ts +18 -4
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/Span.js +9 -2
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.d.ts +12 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.js +16 -0
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.d.ts +0 -2
- package/lib/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.js +0 -2
- package/package.json +1 -1
- package/src/content/fields/nestable/RichTextContent/Blocks.ts +26 -25
- package/src/import/converters/fields/nestable/RichText/textBlock.ts +30 -16
- package/src/import/validators/fields/nestable/ImportRichText/blocks/Span.ts +9 -5
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/LabelSpan.ts +19 -0
- package/src/import/validators/fields/nestable/ImportRichText/blocks/spans/TextSpan.ts +0 -2
- 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;
|
|
328
|
+
start: number;
|
|
329
|
+
end: number;
|
|
330
|
+
type: "label";
|
|
331
|
+
} | {
|
|
326
332
|
start: number;
|
|
327
333
|
end: number;
|
|
328
|
-
type: "
|
|
334
|
+
type: "strong" | "em";
|
|
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;
|
|
380
|
+
start: number;
|
|
381
|
+
end: number;
|
|
382
|
+
type: "label";
|
|
383
|
+
} | {
|
|
372
384
|
start: number;
|
|
373
385
|
end: number;
|
|
374
|
-
type: "
|
|
386
|
+
type: "strong" | "em";
|
|
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;
|
|
695
|
+
start: number;
|
|
696
|
+
end: number;
|
|
697
|
+
type: "label";
|
|
698
|
+
} | {
|
|
681
699
|
start: number;
|
|
682
700
|
end: number;
|
|
683
|
-
type: "
|
|
701
|
+
type: "strong" | "em";
|
|
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: "strong" | "em";
|
|
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,26 @@ export declare const Span: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
106
106
|
preview?: {
|
|
107
107
|
title?: string;
|
|
108
108
|
} | null | undefined;
|
|
109
|
-
}, unknown>]
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
}, unknown>]>;
|
|
110
|
+
start: t.NumberC;
|
|
111
|
+
end: t.NumberC;
|
|
112
|
+
type: t.LiteralC<"hyperlink">;
|
|
113
|
+
}>>, t.ExactC<t.TypeC<{
|
|
114
|
+
data: t.StringC;
|
|
113
115
|
start: t.NumberC;
|
|
114
116
|
end: t.NumberC;
|
|
115
|
-
type: t.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
heading5: null;
|
|
121
|
-
heading6: null;
|
|
122
|
-
paragraph: null;
|
|
117
|
+
type: t.LiteralC<"label">;
|
|
118
|
+
}>>, t.ExactC<t.TypeC<{
|
|
119
|
+
start: t.NumberC;
|
|
120
|
+
end: t.NumberC;
|
|
121
|
+
type: t.KeyofC<{
|
|
123
122
|
strong: null;
|
|
124
123
|
em: null;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
image: null;
|
|
128
|
-
embed: null;
|
|
129
|
-
"list-item": null;
|
|
130
|
-
"o-list-item": null;
|
|
131
|
-
rtl: null;
|
|
132
|
-
}>, t.LiteralC<"label">]>;
|
|
133
|
-
}>]>>;
|
|
124
|
+
}>;
|
|
125
|
+
}>>]>;
|
|
134
126
|
export declare type Span = t.TypeOf<typeof Span>;
|
|
135
|
-
export declare const SpanLegacy: t.
|
|
136
|
-
data: t.UnionC<[t.
|
|
127
|
+
export declare const SpanLegacy: t.UnionC<[t.ExactC<t.TypeC<{
|
|
128
|
+
data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
137
129
|
__TYPE__: t.LiteralC<"ImageLink">;
|
|
138
130
|
}>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
139
131
|
id: t.StringC;
|
|
@@ -239,34 +231,26 @@ export declare const SpanLegacy: t.ExactC<t.IntersectionC<[t.PartialC<{
|
|
|
239
231
|
preview?: {
|
|
240
232
|
title?: string;
|
|
241
233
|
} | null | undefined;
|
|
242
|
-
}, unknown>]
|
|
243
|
-
label: t.StringC;
|
|
244
|
-
}>>]>;
|
|
245
|
-
}>, t.TypeC<{
|
|
234
|
+
}, unknown>]>;
|
|
246
235
|
start: t.NumberC;
|
|
247
236
|
end: t.NumberC;
|
|
248
|
-
type: t.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
237
|
+
type: t.LiteralC<"hyperlink">;
|
|
238
|
+
}>>, t.ExactC<t.TypeC<{
|
|
239
|
+
data: t.StringC;
|
|
240
|
+
start: t.NumberC;
|
|
241
|
+
end: t.NumberC;
|
|
242
|
+
type: t.LiteralC<"label">;
|
|
243
|
+
}>>, t.ExactC<t.TypeC<{
|
|
244
|
+
start: t.NumberC;
|
|
245
|
+
end: t.NumberC;
|
|
246
|
+
type: t.KeyofC<{
|
|
256
247
|
strong: null;
|
|
257
248
|
em: null;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
image: null;
|
|
261
|
-
embed: null;
|
|
262
|
-
"list-item": null;
|
|
263
|
-
"o-list-item": null;
|
|
264
|
-
rtl: null;
|
|
265
|
-
}>, t.LiteralC<"label">]>;
|
|
266
|
-
}>]>>;
|
|
249
|
+
}>;
|
|
250
|
+
}>>]>;
|
|
267
251
|
export declare type SpanLegacy = t.TypeOf<typeof SpanLegacy>;
|
|
268
|
-
export declare const ValidatedSpans: <C extends t.
|
|
269
|
-
data: t.UnionC<[t.
|
|
252
|
+
export declare const ValidatedSpans: <C extends t.UnionC<[t.ExactC<t.TypeC<{
|
|
253
|
+
data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
|
|
270
254
|
__TYPE__: t.LiteralC<"ImageLink">;
|
|
271
255
|
}>>, t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
272
256
|
id: t.StringC;
|
|
@@ -372,31 +356,23 @@ export declare const ValidatedSpans: <C extends t.ExactC<t.IntersectionC<[t.Part
|
|
|
372
356
|
preview?: {
|
|
373
357
|
title?: string;
|
|
374
358
|
} | null | undefined;
|
|
375
|
-
}, unknown>]
|
|
376
|
-
label: t.StringC;
|
|
377
|
-
}>>]>;
|
|
378
|
-
}>, t.TypeC<{
|
|
359
|
+
}, unknown>]>;
|
|
379
360
|
start: t.NumberC;
|
|
380
361
|
end: t.NumberC;
|
|
381
|
-
type: t.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
362
|
+
type: t.LiteralC<"hyperlink">;
|
|
363
|
+
}>>, t.ExactC<t.TypeC<{
|
|
364
|
+
data: t.StringC;
|
|
365
|
+
start: t.NumberC;
|
|
366
|
+
end: t.NumberC;
|
|
367
|
+
type: t.LiteralC<"label">;
|
|
368
|
+
}>>, t.ExactC<t.TypeC<{
|
|
369
|
+
start: t.NumberC;
|
|
370
|
+
end: t.NumberC;
|
|
371
|
+
type: t.KeyofC<{
|
|
389
372
|
strong: null;
|
|
390
373
|
em: null;
|
|
391
|
-
|
|
392
|
-
|
|
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>;
|
|
374
|
+
}>;
|
|
375
|
+
}>>]>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
|
|
400
376
|
export declare const ImageBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
401
377
|
type: t.LiteralC<"image">;
|
|
402
378
|
data: t.IntersectionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
@@ -529,7 +505,7 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
529
505
|
text: t.StringC;
|
|
530
506
|
}>, t.PartialC<{
|
|
531
507
|
spans: t.Type<({
|
|
532
|
-
data
|
|
508
|
+
data: ({
|
|
533
509
|
__TYPE__: "ImageLink";
|
|
534
510
|
} & {
|
|
535
511
|
id: string;
|
|
@@ -567,15 +543,21 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
567
543
|
preview?: {
|
|
568
544
|
title?: string;
|
|
569
545
|
} | null | undefined;
|
|
570
|
-
})
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
546
|
+
});
|
|
547
|
+
start: number;
|
|
548
|
+
end: number;
|
|
549
|
+
type: "hyperlink";
|
|
550
|
+
} | {
|
|
551
|
+
data: string;
|
|
574
552
|
start: number;
|
|
575
553
|
end: number;
|
|
576
|
-
type: "
|
|
554
|
+
type: "label";
|
|
555
|
+
} | {
|
|
556
|
+
start: number;
|
|
557
|
+
end: number;
|
|
558
|
+
type: "strong" | "em";
|
|
577
559
|
})[], ({
|
|
578
|
-
data
|
|
560
|
+
data: ({
|
|
579
561
|
__TYPE__: "ImageLink";
|
|
580
562
|
} & {
|
|
581
563
|
id: string;
|
|
@@ -613,13 +595,19 @@ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
613
595
|
preview?: {
|
|
614
596
|
title?: string;
|
|
615
597
|
} | null | undefined;
|
|
616
|
-
})
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
598
|
+
});
|
|
599
|
+
start: number;
|
|
600
|
+
end: number;
|
|
601
|
+
type: "hyperlink";
|
|
602
|
+
} | {
|
|
603
|
+
data: string;
|
|
620
604
|
start: number;
|
|
621
605
|
end: number;
|
|
622
|
-
type: "
|
|
606
|
+
type: "label";
|
|
607
|
+
} | {
|
|
608
|
+
start: number;
|
|
609
|
+
end: number;
|
|
610
|
+
type: "strong" | "em";
|
|
623
611
|
})[], unknown>;
|
|
624
612
|
}>]>;
|
|
625
613
|
}>, t.PartialC<{
|
|
@@ -725,7 +713,7 @@ export declare const BlockLegacy: t.Type<({
|
|
|
725
713
|
text: string;
|
|
726
714
|
} & {
|
|
727
715
|
spans?: ({
|
|
728
|
-
data
|
|
716
|
+
data: ({
|
|
729
717
|
__TYPE__: "ImageLink";
|
|
730
718
|
} & {
|
|
731
719
|
id: string;
|
|
@@ -763,13 +751,19 @@ export declare const BlockLegacy: t.Type<({
|
|
|
763
751
|
preview?: {
|
|
764
752
|
title?: string;
|
|
765
753
|
} | null | undefined;
|
|
766
|
-
})
|
|
767
|
-
label: string;
|
|
768
|
-
};
|
|
769
|
-
} & {
|
|
754
|
+
});
|
|
770
755
|
start: number;
|
|
771
756
|
end: number;
|
|
772
|
-
type: "
|
|
757
|
+
type: "hyperlink";
|
|
758
|
+
} | {
|
|
759
|
+
data: string;
|
|
760
|
+
start: number;
|
|
761
|
+
end: number;
|
|
762
|
+
type: "label";
|
|
763
|
+
} | {
|
|
764
|
+
start: number;
|
|
765
|
+
end: number;
|
|
766
|
+
type: "strong" | "em";
|
|
773
767
|
})[];
|
|
774
768
|
};
|
|
775
769
|
} & {
|
|
@@ -873,7 +867,7 @@ export declare const BlockLegacy: t.Type<({
|
|
|
873
867
|
text: string;
|
|
874
868
|
} & {
|
|
875
869
|
spans?: ({
|
|
876
|
-
data
|
|
870
|
+
data: ({
|
|
877
871
|
__TYPE__: "ImageLink";
|
|
878
872
|
} & {
|
|
879
873
|
id: string;
|
|
@@ -911,13 +905,19 @@ export declare const BlockLegacy: t.Type<({
|
|
|
911
905
|
preview?: {
|
|
912
906
|
title?: string;
|
|
913
907
|
} | null | undefined;
|
|
914
|
-
})
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
908
|
+
});
|
|
909
|
+
start: number;
|
|
910
|
+
end: number;
|
|
911
|
+
type: "hyperlink";
|
|
912
|
+
} | {
|
|
913
|
+
data: string;
|
|
914
|
+
start: number;
|
|
915
|
+
end: number;
|
|
916
|
+
type: "label";
|
|
917
|
+
} | {
|
|
918
918
|
start: number;
|
|
919
919
|
end: number;
|
|
920
|
-
type: "
|
|
920
|
+
type: "strong" | "em";
|
|
921
921
|
})[];
|
|
922
922
|
};
|
|
923
923
|
} & {
|
|
@@ -1050,7 +1050,7 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
1050
1050
|
text: t.StringC;
|
|
1051
1051
|
}>, t.PartialC<{
|
|
1052
1052
|
spans: t.Type<({
|
|
1053
|
-
data
|
|
1053
|
+
data: ({
|
|
1054
1054
|
__TYPE__: "ImageLink";
|
|
1055
1055
|
} & {
|
|
1056
1056
|
id: string;
|
|
@@ -1088,15 +1088,21 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
1088
1088
|
preview?: {
|
|
1089
1089
|
title?: string;
|
|
1090
1090
|
} | null | undefined;
|
|
1091
|
-
})
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1091
|
+
});
|
|
1092
|
+
start: number;
|
|
1093
|
+
end: number;
|
|
1094
|
+
type: "hyperlink";
|
|
1095
|
+
} | {
|
|
1096
|
+
data: string;
|
|
1097
|
+
start: number;
|
|
1098
|
+
end: number;
|
|
1099
|
+
type: "label";
|
|
1100
|
+
} | {
|
|
1095
1101
|
start: number;
|
|
1096
1102
|
end: number;
|
|
1097
|
-
type: "
|
|
1103
|
+
type: "strong" | "em";
|
|
1098
1104
|
})[], ({
|
|
1099
|
-
data
|
|
1105
|
+
data: ({
|
|
1100
1106
|
__TYPE__: "ImageLink";
|
|
1101
1107
|
} & {
|
|
1102
1108
|
id: string;
|
|
@@ -1134,13 +1140,19 @@ export declare const Block: t.UnionC<[t.ExactC<t.IntersectionC<[t.TypeC<{
|
|
|
1134
1140
|
preview?: {
|
|
1135
1141
|
title?: string;
|
|
1136
1142
|
} | null | undefined;
|
|
1137
|
-
})
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1143
|
+
});
|
|
1144
|
+
start: number;
|
|
1145
|
+
end: number;
|
|
1146
|
+
type: "hyperlink";
|
|
1147
|
+
} | {
|
|
1148
|
+
data: string;
|
|
1149
|
+
start: number;
|
|
1150
|
+
end: number;
|
|
1151
|
+
type: "label";
|
|
1152
|
+
} | {
|
|
1141
1153
|
start: number;
|
|
1142
1154
|
end: number;
|
|
1143
|
-
type: "
|
|
1155
|
+
type: "strong" | "em";
|
|
1144
1156
|
})[], unknown>;
|
|
1145
1157
|
}>]>;
|
|
1146
1158
|
}>, t.PartialC<{
|
|
@@ -6,27 +6,35 @@ 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
|
-
|
|
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 basicSpan = t.strict({
|
|
29
|
+
start: t.number,
|
|
30
|
+
end: t.number,
|
|
31
|
+
type: t.keyof({
|
|
32
|
+
[nestable_1.RichTextNodeType.strong]: null,
|
|
33
|
+
[nestable_1.RichTextNodeType.em]: null,
|
|
26
34
|
}),
|
|
27
|
-
|
|
28
|
-
exports.Span =
|
|
29
|
-
exports.SpanLegacy =
|
|
35
|
+
});
|
|
36
|
+
exports.Span = t.union([linkSpan(LinkContent_1.Link), labelSpan, basicSpan]);
|
|
37
|
+
exports.SpanLegacy = t.union([linkSpan(LinkContent_1.LinkLegacy), labelSpan, basicSpan]);
|
|
30
38
|
const ValidatedSpans = (spanCodec) => {
|
|
31
39
|
return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
|
|
32
40
|
if (Array.isArray(spans)) {
|
|
@@ -35,10 +43,6 @@ const ValidatedSpans = (spanCodec) => {
|
|
|
35
43
|
const decodedSpan = spanCodec.decode(maybeSpan);
|
|
36
44
|
if ((0, Either_1.isLeft)(decodedSpan))
|
|
37
45
|
return acc;
|
|
38
|
-
if ((decodedSpan.right.type === "hyperlink" ||
|
|
39
|
-
decodedSpan.right.type === "label") &&
|
|
40
|
-
!decodedSpan.right.data)
|
|
41
|
-
return acc;
|
|
42
46
|
return [...acc, decodedSpan.right];
|
|
43
47
|
}, [])
|
|
44
48
|
.sort((m1, m2) => m1.start - m2.start);
|
|
@@ -48,7 +52,8 @@ const ValidatedSpans = (spanCodec) => {
|
|
|
48
52
|
return t.failure(spans, c);
|
|
49
53
|
}, (m) => {
|
|
50
54
|
return m.reduce((acc, meta) => {
|
|
51
|
-
|
|
55
|
+
const encoded = spanCodec.encode(meta);
|
|
56
|
+
return [...acc, encoded];
|
|
52
57
|
}, []);
|
|
53
58
|
});
|
|
54
59
|
};
|