@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
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { either } from "fp-ts"
|
|
|
2
2
|
import { isLeft } from "fp-ts/lib/Either"
|
|
3
3
|
import { pipe } from "fp-ts/lib/function"
|
|
4
4
|
import * as t from "io-ts"
|
|
5
|
+
import { withFallback } from "io-ts-types"
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
RichTextNodeType,
|
|
@@ -18,28 +19,39 @@ import {
|
|
|
18
19
|
import { ImageContentView } from "../ImageContent"
|
|
19
20
|
import { Link, LinkLegacy } from "../LinkContent"
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
|
|
22
|
+
const linkSpan = (linkCodec: typeof Link | typeof LinkLegacy) =>
|
|
23
|
+
t.strict({
|
|
24
|
+
data: linkCodec,
|
|
25
|
+
start: t.number,
|
|
26
|
+
end: t.number,
|
|
27
|
+
type: t.literal(RichTextNodeType.hyperlink),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const labelSpan = t.strict({
|
|
31
|
+
data: withFallback(t.string, ""),
|
|
32
|
+
start: t.number,
|
|
33
|
+
end: t.number,
|
|
34
|
+
type: t.literal("label"),
|
|
23
35
|
})
|
|
24
36
|
|
|
25
|
-
const
|
|
26
|
-
t.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const span = t.strict({
|
|
38
|
+
start: t.number,
|
|
39
|
+
end: t.number,
|
|
40
|
+
type: t.keyof(
|
|
41
|
+
Object.entries(RichTextNodeType).reduce<Record<string, null>>(
|
|
42
|
+
(acc, [, name]) => {
|
|
43
|
+
if (name === RichTextNodeType.hyperlink) return acc
|
|
44
|
+
return { ...acc, [name]: null }
|
|
45
|
+
},
|
|
46
|
+
{},
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
})
|
|
38
50
|
|
|
39
|
-
export const Span =
|
|
51
|
+
export const Span = t.union([linkSpan(Link), labelSpan, span])
|
|
40
52
|
export type Span = t.TypeOf<typeof Span>
|
|
41
53
|
|
|
42
|
-
export const SpanLegacy =
|
|
54
|
+
export const SpanLegacy = t.union([linkSpan(LinkLegacy), labelSpan, span])
|
|
43
55
|
export type SpanLegacy = t.TypeOf<typeof SpanLegacy>
|
|
44
56
|
|
|
45
57
|
export const ValidatedSpans = <C extends typeof Span | typeof SpanLegacy>(
|
|
@@ -56,13 +68,6 @@ export const ValidatedSpans = <C extends typeof Span | typeof SpanLegacy>(
|
|
|
56
68
|
.reduce<Array<S>>((acc, maybeSpan) => {
|
|
57
69
|
const decodedSpan = spanCodec.decode(maybeSpan)
|
|
58
70
|
if (isLeft(decodedSpan)) return acc
|
|
59
|
-
if (
|
|
60
|
-
(decodedSpan.right.type === "hyperlink" ||
|
|
61
|
-
decodedSpan.right.type === "label") &&
|
|
62
|
-
!decodedSpan.right.data
|
|
63
|
-
)
|
|
64
|
-
return acc
|
|
65
|
-
|
|
66
71
|
return [...acc, decodedSpan.right]
|
|
67
72
|
}, [])
|
|
68
73
|
.sort((m1: S, m2: S) => m1.start - m2.start)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.geopointConverter = void 0;
|
|
4
|
-
const geopointConverter = (field) => {
|
|
5
|
-
if (field === null)
|
|
6
|
-
return;
|
|
7
|
-
return {
|
|
8
|
-
position: {
|
|
9
|
-
lat: field.latitude,
|
|
10
|
-
lng: field.longitude,
|
|
11
|
-
},
|
|
12
|
-
__TYPE__: "GeoPointContent",
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
exports.geopointConverter = geopointConverter;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Asset, Embed } from "../../../../common";
|
|
2
|
-
import type { RichTextContent } from "../../../../content";
|
|
3
|
-
import type { ImportRichText } from "../../../validators";
|
|
4
|
-
export declare const richTextConverter: (richTextField: ImportRichText["value"], assets: Record<Asset["id"], Asset | undefined>, embeds: Record<string, Embed | undefined>) => RichTextContent | undefined;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.richTextConverter = void 0;
|
|
4
|
-
const content_1 = require("../../../../content");
|
|
5
|
-
const Embed_1 = require("./Embed");
|
|
6
|
-
const Image_1 = require("./Image");
|
|
7
|
-
const Link_1 = require("./Link");
|
|
8
|
-
const richTextBlockConverter = (importBlock, assets, embeds) => {
|
|
9
|
-
var _a, _b, _c;
|
|
10
|
-
if (importBlock.type === "image") {
|
|
11
|
-
return {
|
|
12
|
-
type: importBlock.type,
|
|
13
|
-
data: (0, Image_1.imageBlockConverter)(importBlock, assets),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
else if (importBlock.type === "embed") {
|
|
17
|
-
const embedData = (0, Embed_1.embedConverter)(importBlock.oembed, embeds);
|
|
18
|
-
if (!embedData)
|
|
19
|
-
throw new Error("Failed to convert embed data");
|
|
20
|
-
return {
|
|
21
|
-
type: importBlock.type,
|
|
22
|
-
data: embedData,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// Text block
|
|
27
|
-
return {
|
|
28
|
-
type: importBlock.type,
|
|
29
|
-
direction: (_a = importBlock.direction) !== null && _a !== void 0 ? _a : "ltr",
|
|
30
|
-
content: {
|
|
31
|
-
text: importBlock.text,
|
|
32
|
-
spans: (_c = (_b = importBlock.spans) === null || _b === void 0 ? void 0 : _b.map((span) => {
|
|
33
|
-
const linkData = span.type === "hyperlink"
|
|
34
|
-
? (0, Link_1.linkConverter)(span.data, assets)
|
|
35
|
-
: undefined;
|
|
36
|
-
return {
|
|
37
|
-
type: span.type,
|
|
38
|
-
start: span.start,
|
|
39
|
-
end: span.end,
|
|
40
|
-
data: linkData,
|
|
41
|
-
};
|
|
42
|
-
})) !== null && _c !== void 0 ? _c : [],
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const richTextConverter = (richTextField, assets, embeds) => {
|
|
48
|
-
if (richTextField === null)
|
|
49
|
-
return;
|
|
50
|
-
return {
|
|
51
|
-
__TYPE__: content_1.RichTextContentType,
|
|
52
|
-
value: richTextField.map((block) => richTextBlockConverter(block, assets, embeds)),
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
exports.richTextConverter = richTextConverter;
|