@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
@@ -0,0 +1,590 @@
1
+ import * as t from "io-ts";
2
+ export declare const Span: t.UnionC<[t.ExactC<t.TypeC<{
3
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
4
+ __TYPE__: t.LiteralC<"ImageLink">;
5
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
6
+ kind: t.Type<"image", "image", unknown>;
7
+ id: t.StringC;
8
+ url: t.StringC;
9
+ height: t.StringC;
10
+ width: t.StringC;
11
+ size: t.StringC;
12
+ name: t.StringC;
13
+ }>>, t.ExactC<t.PartialC<{
14
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
15
+ }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
16
+ __TYPE__: t.LiteralC<"FileLink">;
17
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
18
+ kind: t.Type<"file", "file", unknown>;
19
+ id: t.StringC;
20
+ url: t.StringC;
21
+ name: t.StringC;
22
+ size: t.StringC;
23
+ }>, t.PartialC<{
24
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
25
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
26
+ __TYPE__: t.LiteralC<"DocumentLink">;
27
+ }>>, t.ExactC<t.TypeC<{
28
+ id: t.Type<string, string, unknown>;
29
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
30
+ __TYPE__: t.LiteralC<"ExternalLink">;
31
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
32
+ url: t.StringC;
33
+ }>, t.PartialC<{
34
+ kind: t.LiteralC<"web">;
35
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
36
+ preview: t.UnionC<[t.Type<{
37
+ title?: string;
38
+ }, {
39
+ title?: string;
40
+ }, unknown>, t.NullC, t.UndefinedC]>;
41
+ }>]>>]>]> | t.UnionC<[t.Type<{
42
+ __TYPE__: "ImageLink";
43
+ } & {
44
+ kind: "image";
45
+ id: string;
46
+ url: string;
47
+ height: string;
48
+ width: string;
49
+ size: string;
50
+ name: string;
51
+ } & {
52
+ date?: string | null | undefined;
53
+ }, {
54
+ kind: "image";
55
+ id: string;
56
+ url: string;
57
+ height: string;
58
+ width: string;
59
+ size: string;
60
+ name: string;
61
+ } & {
62
+ date?: string | null | undefined;
63
+ }, unknown>, t.Type<{
64
+ __TYPE__: "FileLink";
65
+ } & {
66
+ kind: "file";
67
+ id: string;
68
+ url: string;
69
+ name: string;
70
+ size: string;
71
+ } & {
72
+ date?: string | null | undefined;
73
+ }, {
74
+ kind: "file";
75
+ id: string;
76
+ url: string;
77
+ name: string;
78
+ size: string;
79
+ } & {
80
+ date?: string | null | undefined;
81
+ }, unknown>, t.Type<{
82
+ __TYPE__: "DocumentLink";
83
+ } & {
84
+ id: string;
85
+ }, {
86
+ id: string;
87
+ }, unknown>, t.Type<{
88
+ __TYPE__: "ExternalLink";
89
+ } & {
90
+ url: string;
91
+ } & {
92
+ kind?: "web";
93
+ target?: string | null | undefined;
94
+ preview?: {
95
+ title?: string;
96
+ } | null | undefined;
97
+ }, {
98
+ url: string;
99
+ } & {
100
+ kind?: "web";
101
+ target?: string | null | undefined;
102
+ preview?: {
103
+ title?: string;
104
+ } | null | undefined;
105
+ }, unknown>]>;
106
+ start: t.NumberC;
107
+ end: t.NumberC;
108
+ type: t.LiteralC<"hyperlink">;
109
+ }>>, t.ExactC<t.TypeC<{
110
+ data: t.StringC;
111
+ start: t.NumberC;
112
+ end: t.NumberC;
113
+ type: t.LiteralC<"label">;
114
+ }>>, t.ExactC<t.TypeC<{
115
+ start: t.NumberC;
116
+ end: t.NumberC;
117
+ type: t.KeyofC<{
118
+ strong: null;
119
+ em: null;
120
+ "list-item": null;
121
+ }>;
122
+ }>>]>;
123
+ export declare type Span = t.TypeOf<typeof Span>;
124
+ export declare const SpanLegacy: t.UnionC<[t.ExactC<t.TypeC<{
125
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
126
+ __TYPE__: t.LiteralC<"ImageLink">;
127
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
128
+ kind: t.Type<"image", "image", unknown>;
129
+ id: t.StringC;
130
+ url: t.StringC;
131
+ height: t.StringC;
132
+ width: t.StringC;
133
+ size: t.StringC;
134
+ name: t.StringC;
135
+ }>>, t.ExactC<t.PartialC<{
136
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
137
+ }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
138
+ __TYPE__: t.LiteralC<"FileLink">;
139
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
140
+ kind: t.Type<"file", "file", unknown>;
141
+ id: t.StringC;
142
+ url: t.StringC;
143
+ name: t.StringC;
144
+ size: t.StringC;
145
+ }>, t.PartialC<{
146
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
147
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
148
+ __TYPE__: t.LiteralC<"DocumentLink">;
149
+ }>>, t.ExactC<t.TypeC<{
150
+ id: t.Type<string, string, unknown>;
151
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
152
+ __TYPE__: t.LiteralC<"ExternalLink">;
153
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
154
+ url: t.StringC;
155
+ }>, t.PartialC<{
156
+ kind: t.LiteralC<"web">;
157
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
158
+ preview: t.UnionC<[t.Type<{
159
+ title?: string;
160
+ }, {
161
+ title?: string;
162
+ }, unknown>, t.NullC, t.UndefinedC]>;
163
+ }>]>>]>]> | t.UnionC<[t.Type<{
164
+ __TYPE__: "ImageLink";
165
+ } & {
166
+ kind: "image";
167
+ id: string;
168
+ url: string;
169
+ height: string;
170
+ width: string;
171
+ size: string;
172
+ name: string;
173
+ } & {
174
+ date?: string | null | undefined;
175
+ }, {
176
+ kind: "image";
177
+ id: string;
178
+ url: string;
179
+ height: string;
180
+ width: string;
181
+ size: string;
182
+ name: string;
183
+ } & {
184
+ date?: string | null | undefined;
185
+ }, unknown>, t.Type<{
186
+ __TYPE__: "FileLink";
187
+ } & {
188
+ kind: "file";
189
+ id: string;
190
+ url: string;
191
+ name: string;
192
+ size: string;
193
+ } & {
194
+ date?: string | null | undefined;
195
+ }, {
196
+ kind: "file";
197
+ id: string;
198
+ url: string;
199
+ name: string;
200
+ size: string;
201
+ } & {
202
+ date?: string | null | undefined;
203
+ }, unknown>, t.Type<{
204
+ __TYPE__: "DocumentLink";
205
+ } & {
206
+ id: string;
207
+ }, {
208
+ id: string;
209
+ }, unknown>, t.Type<{
210
+ __TYPE__: "ExternalLink";
211
+ } & {
212
+ url: string;
213
+ } & {
214
+ kind?: "web";
215
+ target?: string | null | undefined;
216
+ preview?: {
217
+ title?: string;
218
+ } | null | undefined;
219
+ }, {
220
+ url: string;
221
+ } & {
222
+ kind?: "web";
223
+ target?: string | null | undefined;
224
+ preview?: {
225
+ title?: string;
226
+ } | null | undefined;
227
+ }, unknown>]>;
228
+ start: t.NumberC;
229
+ end: t.NumberC;
230
+ type: t.LiteralC<"hyperlink">;
231
+ }>>, t.ExactC<t.TypeC<{
232
+ data: t.StringC;
233
+ start: t.NumberC;
234
+ end: t.NumberC;
235
+ type: t.LiteralC<"label">;
236
+ }>>, t.ExactC<t.TypeC<{
237
+ start: t.NumberC;
238
+ end: t.NumberC;
239
+ type: t.KeyofC<{
240
+ strong: null;
241
+ em: null;
242
+ "list-item": null;
243
+ }>;
244
+ }>>]>;
245
+ export declare type SpanLegacy = t.TypeOf<typeof SpanLegacy>;
246
+ export declare const ValidatedSpans: <C extends t.UnionC<[t.ExactC<t.TypeC<{
247
+ data: t.UnionC<[t.IntersectionC<[t.ExactC<t.TypeC<{
248
+ __TYPE__: t.LiteralC<"ImageLink">;
249
+ }>>, t.IntersectionC<[t.ExactC<t.TypeC<{
250
+ kind: t.Type<"image", "image", unknown>;
251
+ id: t.StringC;
252
+ url: t.StringC;
253
+ height: t.StringC;
254
+ width: t.StringC;
255
+ size: t.StringC;
256
+ name: t.StringC;
257
+ }>>, t.ExactC<t.PartialC<{
258
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
259
+ }>>]>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
260
+ __TYPE__: t.LiteralC<"FileLink">;
261
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
262
+ kind: t.Type<"file", "file", unknown>;
263
+ id: t.StringC;
264
+ url: t.StringC;
265
+ name: t.StringC;
266
+ size: t.StringC;
267
+ }>, t.PartialC<{
268
+ date: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
269
+ }>]>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
270
+ __TYPE__: t.LiteralC<"DocumentLink">;
271
+ }>>, t.ExactC<t.TypeC<{
272
+ id: t.Type<string, string, unknown>;
273
+ }>>]>, t.IntersectionC<[t.ExactC<t.TypeC<{
274
+ __TYPE__: t.LiteralC<"ExternalLink">;
275
+ }>>, t.ExactC<t.IntersectionC<[t.TypeC<{
276
+ url: t.StringC;
277
+ }>, t.PartialC<{
278
+ kind: t.LiteralC<"web">;
279
+ target: t.UnionC<[t.Type<string, string, unknown>, t.NullC, t.UndefinedC]>;
280
+ preview: t.UnionC<[t.Type<{
281
+ title?: string;
282
+ }, {
283
+ title?: string;
284
+ }, unknown>, t.NullC, t.UndefinedC]>;
285
+ }>]>>]>]> | t.UnionC<[t.Type<{
286
+ __TYPE__: "ImageLink";
287
+ } & {
288
+ kind: "image";
289
+ id: string;
290
+ url: string;
291
+ height: string;
292
+ width: string;
293
+ size: string;
294
+ name: string;
295
+ } & {
296
+ date?: string | null | undefined;
297
+ }, {
298
+ kind: "image";
299
+ id: string;
300
+ url: string;
301
+ height: string;
302
+ width: string;
303
+ size: string;
304
+ name: string;
305
+ } & {
306
+ date?: string | null | undefined;
307
+ }, unknown>, t.Type<{
308
+ __TYPE__: "FileLink";
309
+ } & {
310
+ kind: "file";
311
+ id: string;
312
+ url: string;
313
+ name: string;
314
+ size: string;
315
+ } & {
316
+ date?: string | null | undefined;
317
+ }, {
318
+ kind: "file";
319
+ id: string;
320
+ url: string;
321
+ name: string;
322
+ size: string;
323
+ } & {
324
+ date?: string | null | undefined;
325
+ }, unknown>, t.Type<{
326
+ __TYPE__: "DocumentLink";
327
+ } & {
328
+ id: string;
329
+ }, {
330
+ id: string;
331
+ }, unknown>, t.Type<{
332
+ __TYPE__: "ExternalLink";
333
+ } & {
334
+ url: string;
335
+ } & {
336
+ kind?: "web";
337
+ target?: string | null | undefined;
338
+ preview?: {
339
+ title?: string;
340
+ } | null | undefined;
341
+ }, {
342
+ url: string;
343
+ } & {
344
+ kind?: "web";
345
+ target?: string | null | undefined;
346
+ preview?: {
347
+ title?: string;
348
+ } | null | undefined;
349
+ }, unknown>]>;
350
+ start: t.NumberC;
351
+ end: t.NumberC;
352
+ type: t.LiteralC<"hyperlink">;
353
+ }>>, t.ExactC<t.TypeC<{
354
+ data: t.StringC;
355
+ start: t.NumberC;
356
+ end: t.NumberC;
357
+ type: t.LiteralC<"label">;
358
+ }>>, t.ExactC<t.TypeC<{
359
+ start: t.NumberC;
360
+ end: t.NumberC;
361
+ type: t.KeyofC<{
362
+ strong: null;
363
+ em: null;
364
+ "list-item": null;
365
+ }>;
366
+ }>>]>>(spanCodec: C) => t.Type<t.TypeOf<C>[], t.TypeOf<C>[], unknown>;
367
+ export declare const TextBlock: t.ExactC<t.IntersectionC<[t.TypeC<{
368
+ type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl" | "table", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl" | "table", unknown>;
369
+ content: t.IntersectionC<[t.TypeC<{
370
+ text: t.StringC;
371
+ }>, t.PartialC<{
372
+ spans: t.Type<({
373
+ data: ({
374
+ __TYPE__: "ImageLink";
375
+ } & {
376
+ kind: "image";
377
+ id: string;
378
+ url: string;
379
+ height: string;
380
+ width: string;
381
+ size: string;
382
+ name: string;
383
+ } & {
384
+ date?: string | null | undefined;
385
+ }) | ({
386
+ __TYPE__: "FileLink";
387
+ } & {
388
+ kind: "file";
389
+ id: string;
390
+ url: string;
391
+ name: string;
392
+ size: string;
393
+ } & {
394
+ date?: string | null | undefined;
395
+ }) | ({
396
+ __TYPE__: "DocumentLink";
397
+ } & {
398
+ id: string;
399
+ }) | ({
400
+ __TYPE__: "ExternalLink";
401
+ } & {
402
+ url: string;
403
+ } & {
404
+ kind?: "web";
405
+ target?: string | null | undefined;
406
+ preview?: {
407
+ title?: string;
408
+ } | null | undefined;
409
+ });
410
+ start: number;
411
+ end: number;
412
+ type: "hyperlink";
413
+ } | {
414
+ data: string;
415
+ start: number;
416
+ end: number;
417
+ type: "label";
418
+ } | {
419
+ start: number;
420
+ end: number;
421
+ type: "strong" | "em" | "list-item";
422
+ })[], ({
423
+ data: ({
424
+ __TYPE__: "ImageLink";
425
+ } & {
426
+ kind: "image";
427
+ id: string;
428
+ url: string;
429
+ height: string;
430
+ width: string;
431
+ size: string;
432
+ name: string;
433
+ } & {
434
+ date?: string | null | undefined;
435
+ }) | ({
436
+ __TYPE__: "FileLink";
437
+ } & {
438
+ kind: "file";
439
+ id: string;
440
+ url: string;
441
+ name: string;
442
+ size: string;
443
+ } & {
444
+ date?: string | null | undefined;
445
+ }) | ({
446
+ __TYPE__: "DocumentLink";
447
+ } & {
448
+ id: string;
449
+ }) | ({
450
+ __TYPE__: "ExternalLink";
451
+ } & {
452
+ url: string;
453
+ } & {
454
+ kind?: "web";
455
+ target?: string | null | undefined;
456
+ preview?: {
457
+ title?: string;
458
+ } | null | undefined;
459
+ });
460
+ start: number;
461
+ end: number;
462
+ type: "hyperlink";
463
+ } | {
464
+ data: string;
465
+ start: number;
466
+ end: number;
467
+ type: "label";
468
+ } | {
469
+ start: number;
470
+ end: number;
471
+ type: "strong" | "em" | "list-item";
472
+ })[], unknown>;
473
+ }>]>;
474
+ }>, t.PartialC<{
475
+ label: t.StringC;
476
+ direction: t.StringC;
477
+ }>]>>;
478
+ export declare type TextBlock = t.TypeOf<typeof TextBlock>;
479
+ export declare const TextBlockLegacy: t.ExactC<t.IntersectionC<[t.TypeC<{
480
+ type: t.Type<"image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl" | "table", "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "strong" | "em" | "preformatted" | "hyperlink" | "embed" | "list-item" | "o-list-item" | "rtl" | "table", unknown>;
481
+ content: t.IntersectionC<[t.TypeC<{
482
+ text: t.StringC;
483
+ }>, t.PartialC<{
484
+ spans: t.Type<({
485
+ data: ({
486
+ __TYPE__: "ImageLink";
487
+ } & {
488
+ kind: "image";
489
+ id: string;
490
+ url: string;
491
+ height: string;
492
+ width: string;
493
+ size: string;
494
+ name: string;
495
+ } & {
496
+ date?: string | null | undefined;
497
+ }) | ({
498
+ __TYPE__: "FileLink";
499
+ } & {
500
+ kind: "file";
501
+ id: string;
502
+ url: string;
503
+ name: string;
504
+ size: string;
505
+ } & {
506
+ date?: string | null | undefined;
507
+ }) | ({
508
+ __TYPE__: "DocumentLink";
509
+ } & {
510
+ id: string;
511
+ }) | ({
512
+ __TYPE__: "ExternalLink";
513
+ } & {
514
+ url: string;
515
+ } & {
516
+ kind?: "web";
517
+ target?: string | null | undefined;
518
+ preview?: {
519
+ title?: string;
520
+ } | null | undefined;
521
+ });
522
+ start: number;
523
+ end: number;
524
+ type: "hyperlink";
525
+ } | {
526
+ data: string;
527
+ start: number;
528
+ end: number;
529
+ type: "label";
530
+ } | {
531
+ start: number;
532
+ end: number;
533
+ type: "strong" | "em" | "list-item";
534
+ })[], ({
535
+ data: ({
536
+ __TYPE__: "ImageLink";
537
+ } & {
538
+ kind: "image";
539
+ id: string;
540
+ url: string;
541
+ height: string;
542
+ width: string;
543
+ size: string;
544
+ name: string;
545
+ } & {
546
+ date?: string | null | undefined;
547
+ }) | ({
548
+ __TYPE__: "FileLink";
549
+ } & {
550
+ kind: "file";
551
+ id: string;
552
+ url: string;
553
+ name: string;
554
+ size: string;
555
+ } & {
556
+ date?: string | null | undefined;
557
+ }) | ({
558
+ __TYPE__: "DocumentLink";
559
+ } & {
560
+ id: string;
561
+ }) | ({
562
+ __TYPE__: "ExternalLink";
563
+ } & {
564
+ url: string;
565
+ } & {
566
+ kind?: "web";
567
+ target?: string | null | undefined;
568
+ preview?: {
569
+ title?: string;
570
+ } | null | undefined;
571
+ });
572
+ start: number;
573
+ end: number;
574
+ type: "hyperlink";
575
+ } | {
576
+ data: string;
577
+ start: number;
578
+ end: number;
579
+ type: "label";
580
+ } | {
581
+ start: number;
582
+ end: number;
583
+ type: "strong" | "em" | "list-item";
584
+ })[], unknown>;
585
+ }>]>;
586
+ }>, t.PartialC<{
587
+ label: t.StringC;
588
+ direction: t.StringC;
589
+ }>]>>;
590
+ export declare type TextBlockLegacy = t.TypeOf<typeof TextBlockLegacy>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextBlockLegacy = exports.TextBlock = exports.ValidatedSpans = exports.SpanLegacy = exports.Span = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Either_1 = require("fp-ts/lib/Either");
6
+ const t = (0, tslib_1.__importStar)(require("io-ts"));
7
+ const io_ts_types_1 = require("io-ts-types");
8
+ const nestable_1 = require("../../../../customtypes/widgets/nestable");
9
+ const function_1 = require("../../../../validators/function");
10
+ const LinkContent_1 = require("../LinkContent");
11
+ const linkSpan = (linkCodec) => t.strict({
12
+ data: linkCodec,
13
+ start: t.number,
14
+ end: t.number,
15
+ type: t.literal(nestable_1.RichTextNodeType.hyperlink),
16
+ });
17
+ const labelSpan = t.strict({
18
+ data: (0, io_ts_types_1.withFallback)(t.string, ""),
19
+ start: t.number,
20
+ end: t.number,
21
+ type: t.literal("label"),
22
+ });
23
+ const basicSpan = t.strict({
24
+ start: t.number,
25
+ end: t.number,
26
+ type: t.keyof({
27
+ [nestable_1.RichTextNodeType.strong]: null,
28
+ [nestable_1.RichTextNodeType.em]: null,
29
+ "list-item": null, // legacy case that should not happen, we shouldn't support this in new page builder or migration API
30
+ }),
31
+ });
32
+ exports.Span = t.union([linkSpan(LinkContent_1.FilledLink), labelSpan, basicSpan]);
33
+ exports.SpanLegacy = t.union([
34
+ linkSpan(LinkContent_1.FilledLinkLegacy),
35
+ labelSpan,
36
+ basicSpan,
37
+ ]);
38
+ const ValidatedSpans = (spanCodec) => {
39
+ return new t.Type("ValidatedSpans", (spans) => Array.isArray(spans) && spans.every(spanCodec.is), (spans, c) => {
40
+ if (Array.isArray(spans)) {
41
+ const res = spans
42
+ .reduce((acc, maybeSpan) => {
43
+ const decodedSpan = spanCodec.decode(maybeSpan);
44
+ if ((0, Either_1.isLeft)(decodedSpan))
45
+ return acc;
46
+ return [...acc, decodedSpan.right];
47
+ }, [])
48
+ .sort((m1, m2) => m1.start - m2.start);
49
+ return t.success(res);
50
+ }
51
+ else
52
+ return t.failure(spans, c);
53
+ }, (m) => {
54
+ return m.reduce((acc, meta) => {
55
+ const encoded = spanCodec.encode(meta);
56
+ return [...acc, encoded];
57
+ }, []);
58
+ });
59
+ };
60
+ exports.ValidatedSpans = ValidatedSpans;
61
+ const TextBlockCodec = (spanCodec) => t.exact(t.intersection([
62
+ t.type({
63
+ type: (0, function_1.refineType)(nestable_1.RichTextNodeTypeCodec, `string which isn't ${nestable_1.RichTextNodeType.image} ${nestable_1.RichTextNodeType.embed}`, (s) => s !== nestable_1.RichTextNodeType.image && s !== nestable_1.RichTextNodeType.embed),
64
+ content: t.intersection([
65
+ t.type({
66
+ text: t.string,
67
+ }),
68
+ t.partial({
69
+ spans: (0, exports.ValidatedSpans)(spanCodec),
70
+ }),
71
+ ]),
72
+ }),
73
+ t.partial({
74
+ label: t.string,
75
+ direction: t.string,
76
+ }),
77
+ ]));
78
+ /* These Text block will decode codec A and encode from codec B to A */
79
+ exports.TextBlock = TextBlockCodec(exports.Span);
80
+ exports.TextBlockLegacy = TextBlockCodec(exports.SpanLegacy);