@prismicio/client 7.7.3 → 7.7.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.
- package/README.md +3 -3
- package/dist/buildQueryURL.cjs.map +1 -1
- package/dist/buildQueryURL.d.ts +1 -1
- package/dist/buildQueryURL.js.map +1 -1
- package/dist/cookie.cjs.map +1 -1
- package/dist/cookie.js.map +1 -1
- package/dist/createClient.cjs +31 -31
- package/dist/createClient.cjs.map +1 -1
- package/dist/createClient.d.ts +35 -35
- package/dist/createClient.js +31 -31
- package/dist/createClient.js.map +1 -1
- package/dist/errors/ForbiddenError.cjs.map +1 -1
- package/dist/errors/ForbiddenError.js.map +1 -1
- package/dist/errors/NotFoundError.cjs.map +1 -1
- package/dist/errors/NotFoundError.js.map +1 -1
- package/dist/errors/ParsingError.cjs.map +1 -1
- package/dist/errors/ParsingError.js.map +1 -1
- package/dist/errors/PreviewTokenExpired.cjs.map +1 -1
- package/dist/errors/PreviewTokenExpired.js.map +1 -1
- package/dist/errors/PrismicError.cjs.map +1 -1
- package/dist/errors/PrismicError.js.map +1 -1
- package/dist/errors/PrismicRichTextSerializerError.cjs.map +1 -1
- package/dist/errors/PrismicRichTextSerializerError.js.map +1 -1
- package/dist/errors/RefExpiredError.cjs.map +1 -1
- package/dist/errors/RefExpiredError.js.map +1 -1
- package/dist/errors/RefNotFoundError.cjs.map +1 -1
- package/dist/errors/RefNotFoundError.js.map +1 -1
- package/dist/errors/RepositoryNotFoundError.cjs.map +1 -1
- package/dist/errors/RepositoryNotFoundError.js.map +1 -1
- package/dist/filter.cjs.map +1 -1
- package/dist/filter.js.map +1 -1
- package/dist/getGraphQLEndpoint.cjs.map +1 -1
- package/dist/getGraphQLEndpoint.js.map +1 -1
- package/dist/getRepositoryEndpoint.cjs.map +1 -1
- package/dist/getRepositoryEndpoint.js.map +1 -1
- package/dist/getRepositoryName.cjs.map +1 -1
- package/dist/getRepositoryName.js.map +1 -1
- package/dist/getToolbarSrc.cjs.map +1 -1
- package/dist/getToolbarSrc.js.map +1 -1
- package/dist/helpers/asDate.cjs.map +1 -1
- package/dist/helpers/asDate.js.map +1 -1
- package/dist/helpers/asHTML.cjs.map +1 -1
- package/dist/helpers/asHTML.d.ts +2 -2
- package/dist/helpers/asHTML.js.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.cjs.map +1 -1
- package/dist/helpers/asImagePixelDensitySrcSet.d.ts +2 -2
- package/dist/helpers/asImagePixelDensitySrcSet.js.map +1 -1
- package/dist/helpers/asImageSrc.cjs.map +1 -1
- package/dist/helpers/asImageSrc.d.ts +2 -2
- package/dist/helpers/asImageSrc.js.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.cjs.map +1 -1
- package/dist/helpers/asImageWidthSrcSet.d.ts +2 -2
- package/dist/helpers/asImageWidthSrcSet.js.map +1 -1
- package/dist/helpers/asLink.cjs.map +1 -1
- package/dist/helpers/asLink.d.ts +2 -4
- package/dist/helpers/asLink.js.map +1 -1
- package/dist/helpers/asLinkAttrs.cjs.map +1 -1
- package/dist/helpers/asLinkAttrs.d.ts +2 -2
- package/dist/helpers/asLinkAttrs.js.map +1 -1
- package/dist/helpers/asText.cjs.map +1 -1
- package/dist/helpers/asText.d.ts +1 -1
- package/dist/helpers/asText.js.map +1 -1
- package/dist/helpers/documentToLinkField.cjs.map +1 -1
- package/dist/helpers/documentToLinkField.js.map +1 -1
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/helpers/mapSliceZone.cjs.map +1 -1
- package/dist/helpers/mapSliceZone.d.ts +1 -1
- package/dist/helpers/mapSliceZone.js.map +1 -1
- package/dist/helpers/unstable_htmlAsRichText.cjs.map +1 -1
- package/dist/helpers/unstable_htmlAsRichText.d.ts +4 -4
- package/dist/helpers/unstable_htmlAsRichText.js.map +1 -1
- package/dist/helpers/unstable_markdownAsRichText.cjs.map +1 -1
- package/dist/helpers/unstable_markdownAsRichText.d.ts +2 -2
- package/dist/helpers/unstable_markdownAsRichText.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isRepositoryEndpoint.cjs.map +1 -1
- package/dist/isRepositoryEndpoint.js.map +1 -1
- package/dist/isRepositoryName.cjs.map +1 -1
- package/dist/isRepositoryName.js.map +1 -1
- package/dist/lib/RichTextFieldBuilder.cjs.map +1 -1
- package/dist/lib/RichTextFieldBuilder.d.ts +1 -1
- package/dist/lib/RichTextFieldBuilder.js.map +1 -1
- package/dist/lib/appendFilters.cjs.map +1 -1
- package/dist/lib/appendFilters.js.map +1 -1
- package/dist/lib/castArray.cjs.map +1 -1
- package/dist/lib/castArray.js.map +1 -1
- package/dist/lib/castThunk.cjs.map +1 -1
- package/dist/lib/castThunk.js.map +1 -1
- package/dist/lib/devMsg.cjs.map +1 -1
- package/dist/lib/devMsg.d.ts +1 -1
- package/dist/lib/devMsg.js.map +1 -1
- package/dist/lib/escapeHTML.cjs.map +1 -1
- package/dist/lib/escapeHTML.js.map +1 -1
- package/dist/lib/everyTagFilter.cjs.map +1 -1
- package/dist/lib/everyTagFilter.js.map +1 -1
- package/dist/lib/filterRichTextField.cjs.map +1 -1
- package/dist/lib/filterRichTextField.d.ts +3 -3
- package/dist/lib/filterRichTextField.js.map +1 -1
- package/dist/lib/findMasterRef.cjs.map +1 -1
- package/dist/lib/findMasterRef.d.ts +1 -1
- package/dist/lib/findMasterRef.js.map +1 -1
- package/dist/lib/findRef.cjs.map +1 -1
- package/dist/lib/findRef.d.ts +1 -1
- package/dist/lib/findRef.js.map +1 -1
- package/dist/lib/findRefByID.cjs.map +1 -1
- package/dist/lib/findRefByID.d.ts +1 -1
- package/dist/lib/findRefByID.js.map +1 -1
- package/dist/lib/findRefByLabel.cjs.map +1 -1
- package/dist/lib/findRefByLabel.d.ts +1 -1
- package/dist/lib/findRefByLabel.js.map +1 -1
- package/dist/lib/getPreviewCookie.cjs.map +1 -1
- package/dist/lib/getPreviewCookie.js.map +1 -1
- package/dist/lib/hastSerializerHelpers.cjs.map +1 -1
- package/dist/lib/hastSerializerHelpers.d.ts +3 -3
- package/dist/lib/hastSerializerHelpers.js.map +1 -1
- package/dist/lib/hastToRichText.cjs +1 -2
- package/dist/lib/hastToRichText.cjs.map +1 -1
- package/dist/lib/hastToRichText.d.ts +4 -4
- package/dist/lib/hastToRichText.js +1 -2
- package/dist/lib/hastToRichText.js.map +1 -1
- package/dist/lib/isInternalURL.cjs.map +1 -1
- package/dist/lib/isInternalURL.js.map +1 -1
- package/dist/lib/minifyGraphQLQuery.cjs.map +1 -1
- package/dist/lib/minifyGraphQLQuery.js.map +1 -1
- package/dist/lib/rehypeRichText.cjs.map +1 -1
- package/dist/lib/rehypeRichText.d.ts +5 -5
- package/dist/lib/rehypeRichText.js.map +1 -1
- package/dist/lib/serializerHelpers.cjs.map +1 -1
- package/dist/lib/serializerHelpers.d.ts +2 -2
- package/dist/lib/serializerHelpers.js.map +1 -1
- package/dist/lib/someTagsFilter.cjs.map +1 -1
- package/dist/lib/someTagsFilter.js.map +1 -1
- package/dist/lib/typeFilter.cjs.map +1 -1
- package/dist/lib/typeFilter.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/richtext/asText.cjs.map +1 -1
- package/dist/richtext/asText.d.ts +1 -1
- package/dist/richtext/asText.js.map +1 -1
- package/dist/richtext/asTree.cjs.map +1 -1
- package/dist/richtext/asTree.d.ts +2 -2
- package/dist/richtext/asTree.js.map +1 -1
- package/dist/richtext/composeSerializers.cjs.map +1 -1
- package/dist/richtext/composeSerializers.d.ts +1 -1
- package/dist/richtext/composeSerializers.js.map +1 -1
- package/dist/richtext/serialize.cjs.map +1 -1
- package/dist/richtext/serialize.d.ts +1 -1
- package/dist/richtext/serialize.js.map +1 -1
- package/dist/richtext/types.cjs.map +1 -1
- package/dist/richtext/types.d.ts +1 -1
- package/dist/richtext/types.js.map +1 -1
- package/dist/richtext/wrapMapSerializer.cjs.map +1 -1
- package/dist/richtext/wrapMapSerializer.d.ts +1 -1
- package/dist/richtext/wrapMapSerializer.js.map +1 -1
- package/dist/types/api/query.d.ts +1 -1
- package/dist/types/api/release.d.ts +1 -1
- package/dist/types/api/repository.d.ts +1 -1
- package/dist/types/model/customType.d.ts +1 -1
- package/dist/types/model/link.cjs.map +1 -1
- package/dist/types/model/link.js.map +1 -1
- package/dist/types/model/slice.cjs.map +1 -1
- package/dist/types/model/slice.js.map +1 -1
- package/dist/types/model/sliceZone.cjs.map +1 -1
- package/dist/types/model/sliceZone.js.map +1 -1
- package/dist/types/model/title.d.ts +1 -1
- package/dist/types/model/types.cjs.map +1 -1
- package/dist/types/model/types.js.map +1 -1
- package/dist/types/value/document.d.ts +4 -4
- package/dist/types/value/embed.cjs.map +1 -1
- package/dist/types/value/embed.js.map +1 -1
- package/dist/types/value/link.cjs.map +1 -1
- package/dist/types/value/link.js.map +1 -1
- package/dist/types/value/richText.cjs.map +1 -1
- package/dist/types/value/richText.js.map +1 -1
- package/dist/types/webhook/apiUpdate.d.ts +1 -1
- package/dist/types/webhook/testTrigger.d.ts +1 -1
- package/dist/types/webhook/types.cjs.map +1 -1
- package/dist/types/webhook/types.d.ts +2 -2
- package/dist/types/webhook/types.js.map +1 -1
- package/package.json +1 -1
- package/src/buildQueryURL.ts +51 -51
- package/src/cookie.ts +1 -1
- package/src/createClient.ts +293 -293
- package/src/errors/ForbiddenError.ts +6 -6
- package/src/errors/NotFoundError.ts +1 -1
- package/src/errors/ParsingError.ts +8 -8
- package/src/errors/PreviewTokenExpired.ts +4 -4
- package/src/errors/PrismicError.ts +5 -5
- package/src/errors/PrismicRichTextSerializerError.ts +1 -1
- package/src/errors/RefExpiredError.ts +4 -4
- package/src/errors/RefNotFoundError.ts +4 -4
- package/src/errors/RepositoryNotFoundError.ts +1 -1
- package/src/filter.ts +22 -22
- package/src/getGraphQLEndpoint.ts +5 -5
- package/src/getRepositoryEndpoint.ts +5 -5
- package/src/getRepositoryName.ts +4 -4
- package/src/getToolbarSrc.ts +5 -5
- package/src/helpers/asDate.ts +7 -7
- package/src/helpers/asHTML.ts +54 -56
- package/src/helpers/asImagePixelDensitySrcSet.ts +14 -17
- package/src/helpers/asImageSrc.ts +9 -8
- package/src/helpers/asImageWidthSrcSet.ts +19 -22
- package/src/helpers/asLink.ts +26 -27
- package/src/helpers/asLinkAttrs.ts +30 -29
- package/src/helpers/asText.ts +15 -15
- package/src/helpers/documentToLinkField.ts +6 -6
- package/src/helpers/isFilled.ts +53 -53
- package/src/helpers/mapSliceZone.ts +34 -34
- package/src/helpers/unstable_htmlAsRichText.ts +23 -22
- package/src/helpers/unstable_markdownAsRichText.ts +14 -13
- package/src/index.ts +119 -119
- package/src/isRepositoryEndpoint.ts +4 -4
- package/src/isRepositoryName.ts +2 -2
- package/src/lib/RichTextFieldBuilder.ts +36 -41
- package/src/lib/appendFilters.ts +4 -4
- package/src/lib/castArray.ts +2 -2
- package/src/lib/castThunk.ts +2 -2
- package/src/lib/devMsg.ts +4 -4
- package/src/lib/escapeHTML.ts +24 -24
- package/src/lib/everyTagFilter.ts +4 -4
- package/src/lib/filterRichTextField.ts +31 -31
- package/src/lib/findMasterRef.ts +4 -4
- package/src/lib/findRef.ts +6 -6
- package/src/lib/findRefByID.ts +4 -4
- package/src/lib/findRefByLabel.ts +4 -4
- package/src/lib/getPreviewCookie.ts +11 -11
- package/src/lib/hastSerializerHelpers.ts +41 -37
- package/src/lib/hastToRichText.ts +74 -73
- package/src/lib/isInternalURL.ts +4 -4
- package/src/lib/minifyGraphQLQuery.ts +2 -2
- package/src/lib/rehypeRichText.ts +42 -41
- package/src/lib/serializerHelpers.ts +53 -54
- package/src/lib/someTagsFilter.ts +4 -4
- package/src/lib/typeFilter.ts +3 -3
- package/src/richtext/asText.ts +5 -5
- package/src/richtext/asTree.ts +53 -53
- package/src/richtext/composeSerializers.ts +6 -6
- package/src/richtext/index.ts +7 -7
- package/src/richtext/serialize.ts +11 -11
- package/src/richtext/types.ts +38 -38
- package/src/richtext/wrapMapSerializer.ts +6 -9
- package/src/types/api/query.ts +9 -9
- package/src/types/api/ref.ts +5 -5
- package/src/types/api/release.ts +2 -2
- package/src/types/api/repository.ts +24 -24
- package/src/types/api/tags.ts +1 -1
- package/src/types/model/boolean.ts +7 -7
- package/src/types/model/color.ts +5 -5
- package/src/types/model/contentRelationship.ts +9 -9
- package/src/types/model/customType.ts +9 -9
- package/src/types/model/date.ts +6 -6
- package/src/types/model/embed.ts +5 -5
- package/src/types/model/geoPoint.ts +4 -4
- package/src/types/model/group.ts +6 -6
- package/src/types/model/image.ts +9 -9
- package/src/types/model/integration.ts +6 -6
- package/src/types/model/keyText.ts +5 -5
- package/src/types/model/link.ts +8 -8
- package/src/types/model/linkToMedia.ts +7 -7
- package/src/types/model/number.ts +7 -7
- package/src/types/model/range.ts +8 -8
- package/src/types/model/richText.ts +16 -16
- package/src/types/model/select.ts +7 -7
- package/src/types/model/separator.ts +4 -4
- package/src/types/model/sharedSlice.ts +7 -7
- package/src/types/model/sharedSliceVariation.ts +9 -9
- package/src/types/model/slice.ts +12 -12
- package/src/types/model/sliceZone.ts +11 -11
- package/src/types/model/timestamp.ts +6 -6
- package/src/types/model/title.ts +2 -2
- package/src/types/model/types.ts +26 -26
- package/src/types/model/uid.ts +5 -5
- package/src/types/value/boolean.ts +1 -1
- package/src/types/value/color.ts +2 -2
- package/src/types/value/contentRelationship.ts +15 -15
- package/src/types/value/date.ts +2 -2
- package/src/types/value/document.ts +23 -23
- package/src/types/value/embed.ts +33 -33
- package/src/types/value/geoPoint.ts +4 -4
- package/src/types/value/group.ts +3 -3
- package/src/types/value/image.ts +21 -21
- package/src/types/value/integration.ts +2 -2
- package/src/types/value/keyText.ts +2 -2
- package/src/types/value/link.ts +12 -12
- package/src/types/value/linkToMedia.ts +11 -11
- package/src/types/value/number.ts +2 -2
- package/src/types/value/richText.ts +58 -58
- package/src/types/value/select.ts +2 -2
- package/src/types/value/sharedSlice.ts +5 -5
- package/src/types/value/sharedSliceVariation.ts +5 -5
- package/src/types/value/slice.ts +6 -6
- package/src/types/value/sliceZone.ts +4 -4
- package/src/types/value/timestamp.ts +3 -3
- package/src/types/value/title.ts +4 -4
- package/src/types/value/types.ts +22 -22
- package/src/types/webhook/apiUpdate.ts +18 -18
- package/src/types/webhook/testTrigger.ts +2 -2
- package/src/types/webhook/types.ts +8 -8
- package/dist/_node_modules/hast-util-whitespace/lib/index.cjs +0 -11
- package/dist/_node_modules/hast-util-whitespace/lib/index.cjs.map +0 -1
- package/dist/_node_modules/hast-util-whitespace/lib/index.js +0 -11
- package/dist/_node_modules/hast-util-whitespace/lib/index.js.map +0 -1
package/src/helpers/isFilled.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { ColorField } from "../types/value/color"
|
|
2
|
-
import type { ContentRelationshipField } from "../types/value/contentRelationship"
|
|
3
|
-
import type { DateField } from "../types/value/date"
|
|
4
|
-
import type { AnyOEmbed, EmbedField } from "../types/value/embed"
|
|
5
|
-
import type { GeoPointField } from "../types/value/geoPoint"
|
|
6
|
-
import type { GroupField, NestedGroupField } from "../types/value/group"
|
|
7
|
-
import type { ImageField, ImageFieldImage } from "../types/value/image"
|
|
8
|
-
import type { IntegrationField } from "../types/value/integration"
|
|
9
|
-
import type { KeyTextField } from "../types/value/keyText"
|
|
10
|
-
import type { LinkField } from "../types/value/link"
|
|
11
|
-
import type { LinkToMediaField } from "../types/value/linkToMedia"
|
|
12
|
-
import type { NumberField } from "../types/value/number"
|
|
13
|
-
import type { RichTextField } from "../types/value/richText"
|
|
14
|
-
import type { SelectField } from "../types/value/select"
|
|
15
|
-
import type { SharedSlice } from "../types/value/sharedSlice"
|
|
16
|
-
import type { Slice } from "../types/value/slice"
|
|
17
|
-
import type { SliceZone } from "../types/value/sliceZone"
|
|
18
|
-
import type { TimestampField } from "../types/value/timestamp"
|
|
19
|
-
import type { TitleField } from "../types/value/title"
|
|
20
|
-
import type { AnyRegularField } from "../types/value/types"
|
|
1
|
+
import type { ColorField } from "../types/value/color"
|
|
2
|
+
import type { ContentRelationshipField } from "../types/value/contentRelationship"
|
|
3
|
+
import type { DateField } from "../types/value/date"
|
|
4
|
+
import type { AnyOEmbed, EmbedField } from "../types/value/embed"
|
|
5
|
+
import type { GeoPointField } from "../types/value/geoPoint"
|
|
6
|
+
import type { GroupField, NestedGroupField } from "../types/value/group"
|
|
7
|
+
import type { ImageField, ImageFieldImage } from "../types/value/image"
|
|
8
|
+
import type { IntegrationField } from "../types/value/integration"
|
|
9
|
+
import type { KeyTextField } from "../types/value/keyText"
|
|
10
|
+
import type { LinkField } from "../types/value/link"
|
|
11
|
+
import type { LinkToMediaField } from "../types/value/linkToMedia"
|
|
12
|
+
import type { NumberField } from "../types/value/number"
|
|
13
|
+
import type { RichTextField } from "../types/value/richText"
|
|
14
|
+
import type { SelectField } from "../types/value/select"
|
|
15
|
+
import type { SharedSlice } from "../types/value/sharedSlice"
|
|
16
|
+
import type { Slice } from "../types/value/slice"
|
|
17
|
+
import type { SliceZone } from "../types/value/sliceZone"
|
|
18
|
+
import type { TimestampField } from "../types/value/timestamp"
|
|
19
|
+
import type { TitleField } from "../types/value/title"
|
|
20
|
+
import type { AnyRegularField } from "../types/value/types"
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Determines if a value is not nullish (i.e. not `null` or `undefined`). This
|
|
@@ -28,8 +28,8 @@ import type { AnyRegularField } from "../types/value/types";
|
|
|
28
28
|
* @returns `true` if `input` is not nullish, `false` otherwise.
|
|
29
29
|
*/
|
|
30
30
|
const isNonNullish = <T>(input: T): input is NonNullable<T> => {
|
|
31
|
-
return input != null
|
|
32
|
-
}
|
|
31
|
+
return input != null
|
|
32
|
+
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Determines if an array is not empty. This is used to check if array-based
|
|
@@ -40,8 +40,8 @@ const isNonNullish = <T>(input: T): input is NonNullable<T> => {
|
|
|
40
40
|
* @returns `true` if `input` has at least one element, `false` otherwise.
|
|
41
41
|
*/
|
|
42
42
|
const isNonEmptyArray = <T>(input: T[]): input is [T, ...T[]] => {
|
|
43
|
-
return !!input.length
|
|
44
|
-
}
|
|
43
|
+
return !!input.length
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Determines if a rich text field is filled.
|
|
@@ -54,13 +54,13 @@ export const richText = (
|
|
|
54
54
|
field: RichTextField | null | undefined,
|
|
55
55
|
): field is RichTextField<"filled"> => {
|
|
56
56
|
if (!isNonNullish(field)) {
|
|
57
|
-
return false
|
|
57
|
+
return false
|
|
58
58
|
} else if (field.length === 1 && "text" in field[0]) {
|
|
59
|
-
return !!field[0].text
|
|
59
|
+
return !!field[0].text
|
|
60
60
|
} else {
|
|
61
|
-
return !!field.length
|
|
61
|
+
return !!field.length
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Determines if a title field is filled.
|
|
@@ -71,7 +71,7 @@ export const richText = (
|
|
|
71
71
|
*/
|
|
72
72
|
export const title = richText as (
|
|
73
73
|
field: TitleField | null | undefined,
|
|
74
|
-
) => field is TitleField<"filled"
|
|
74
|
+
) => field is TitleField<"filled">
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* Determines if an Image thumbnail is filled.
|
|
@@ -83,8 +83,8 @@ export const title = richText as (
|
|
|
83
83
|
export const imageThumbnail = (
|
|
84
84
|
thumbnail: ImageFieldImage | null | undefined,
|
|
85
85
|
): thumbnail is ImageFieldImage<"filled"> => {
|
|
86
|
-
return isNonNullish(thumbnail) && !!thumbnail.url
|
|
87
|
-
}
|
|
86
|
+
return isNonNullish(thumbnail) && !!thumbnail.url
|
|
87
|
+
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
90
90
|
* Determines if an image field is filled.
|
|
@@ -97,7 +97,7 @@ export const image = imageThumbnail as <
|
|
|
97
97
|
ThumbnailNames extends string | null = never,
|
|
98
98
|
>(
|
|
99
99
|
field: ImageField<ThumbnailNames> | null | undefined,
|
|
100
|
-
) => field is ImageField<ThumbnailNames, "filled"
|
|
100
|
+
) => field is ImageField<ThumbnailNames, "filled">
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* Determines if a link field is filled.
|
|
@@ -115,8 +115,8 @@ export const link = <
|
|
|
115
115
|
>(
|
|
116
116
|
field: LinkField<TypeEnum, LangEnum, DataInterface> | null | undefined,
|
|
117
117
|
): field is LinkField<TypeEnum, LangEnum, DataInterface, "filled"> => {
|
|
118
|
-
return isNonNullish(field) && ("id" in field || "url" in field)
|
|
119
|
-
}
|
|
118
|
+
return isNonNullish(field) && ("id" in field || "url" in field)
|
|
119
|
+
}
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Determines if a link to media field is filled.
|
|
@@ -127,7 +127,7 @@ export const link = <
|
|
|
127
127
|
*/
|
|
128
128
|
export const linkToMedia = link as (
|
|
129
129
|
field: LinkToMediaField | null | undefined,
|
|
130
|
-
) => field is LinkToMediaField<"filled"
|
|
130
|
+
) => field is LinkToMediaField<"filled">
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* Determines if a content relationship field is filled.
|
|
@@ -152,7 +152,7 @@ export const contentRelationship = link as <
|
|
|
152
152
|
LangEnum,
|
|
153
153
|
DataInterface,
|
|
154
154
|
"filled"
|
|
155
|
-
|
|
155
|
+
>
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Determines if a date field is filled.
|
|
@@ -163,7 +163,7 @@ export const contentRelationship = link as <
|
|
|
163
163
|
*/
|
|
164
164
|
export const date = isNonNullish as (
|
|
165
165
|
field: DateField | null | undefined,
|
|
166
|
-
) => field is DateField<"filled"
|
|
166
|
+
) => field is DateField<"filled">
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Determines if a timestamp field is filled.
|
|
@@ -174,7 +174,7 @@ export const date = isNonNullish as (
|
|
|
174
174
|
*/
|
|
175
175
|
export const timestamp = isNonNullish as (
|
|
176
176
|
field: TimestampField | null | undefined,
|
|
177
|
-
) => field is TimestampField<"filled"
|
|
177
|
+
) => field is TimestampField<"filled">
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
180
|
* Determines if a color field is filled.
|
|
@@ -185,7 +185,7 @@ export const timestamp = isNonNullish as (
|
|
|
185
185
|
*/
|
|
186
186
|
export const color = isNonNullish as (
|
|
187
187
|
field: ColorField | null | undefined,
|
|
188
|
-
) => field is ColorField<"filled"
|
|
188
|
+
) => field is ColorField<"filled">
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
191
|
* Determines if a number field is filled.
|
|
@@ -196,7 +196,7 @@ export const color = isNonNullish as (
|
|
|
196
196
|
*/
|
|
197
197
|
export const number = isNonNullish as (
|
|
198
198
|
field: NumberField | null | undefined,
|
|
199
|
-
) => field is NumberField<"filled"
|
|
199
|
+
) => field is NumberField<"filled">
|
|
200
200
|
|
|
201
201
|
/**
|
|
202
202
|
* Determines if a key text field is filled.
|
|
@@ -208,8 +208,8 @@ export const number = isNonNullish as (
|
|
|
208
208
|
export const keyText = (
|
|
209
209
|
field: KeyTextField | null | undefined,
|
|
210
210
|
): field is KeyTextField<"filled"> => {
|
|
211
|
-
return isNonNullish(keyText) && !!field
|
|
212
|
-
}
|
|
211
|
+
return isNonNullish(keyText) && !!field
|
|
212
|
+
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
215
215
|
* Determines if a select field is filled.
|
|
@@ -220,7 +220,7 @@ export const keyText = (
|
|
|
220
220
|
*/
|
|
221
221
|
export const select = isNonNullish as <Enum extends string>(
|
|
222
222
|
field: SelectField<Enum> | null | undefined,
|
|
223
|
-
) => field is SelectField<Enum, "filled"
|
|
223
|
+
) => field is SelectField<Enum, "filled">
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* Determines if an embed field is filled.
|
|
@@ -232,8 +232,8 @@ export const select = isNonNullish as <Enum extends string>(
|
|
|
232
232
|
export const embed = <Field extends EmbedField<AnyOEmbed>>(
|
|
233
233
|
field: Field | null | undefined,
|
|
234
234
|
): field is Extract<Field, EmbedField<AnyOEmbed, "filled">> => {
|
|
235
|
-
return isNonNullish(field) && !!field.embed_url
|
|
236
|
-
}
|
|
235
|
+
return isNonNullish(field) && !!field.embed_url
|
|
236
|
+
}
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
239
|
* Determines if a geopoint field is filled.
|
|
@@ -245,8 +245,8 @@ export const embed = <Field extends EmbedField<AnyOEmbed>>(
|
|
|
245
245
|
export const geoPoint = (
|
|
246
246
|
field: GeoPointField | null | undefined,
|
|
247
247
|
): field is GeoPointField<"filled"> => {
|
|
248
|
-
return isNonNullish(field) && "longitude" in field
|
|
249
|
-
}
|
|
248
|
+
return isNonNullish(field) && "longitude" in field
|
|
249
|
+
}
|
|
250
250
|
|
|
251
251
|
/**
|
|
252
252
|
* Determines if an integration field is filled.
|
|
@@ -259,12 +259,12 @@ export const integrationField = isNonNullish as <
|
|
|
259
259
|
Data extends Record<string, unknown>,
|
|
260
260
|
>(
|
|
261
261
|
field: IntegrationField<Data> | null | undefined,
|
|
262
|
-
) => field is IntegrationField<Data, "filled"
|
|
262
|
+
) => field is IntegrationField<Data, "filled">
|
|
263
263
|
/**
|
|
264
264
|
* @deprecated Renamed to `integrationField`.
|
|
265
265
|
*/
|
|
266
266
|
// TODO: Remove when we remove support for deprecated `integrationFields` export.
|
|
267
|
-
export const integrationFields = integrationField
|
|
267
|
+
export const integrationFields = integrationField
|
|
268
268
|
|
|
269
269
|
/**
|
|
270
270
|
* Determines if a Group has at least one item.
|
|
@@ -278,8 +278,8 @@ export const group = <
|
|
|
278
278
|
>(
|
|
279
279
|
group: GroupField<Fields> | null | undefined,
|
|
280
280
|
): group is GroupField<Fields, "filled"> => {
|
|
281
|
-
return isNonNullish(group) && isNonEmptyArray(group)
|
|
282
|
-
}
|
|
281
|
+
return isNonNullish(group) && isNonEmptyArray(group)
|
|
282
|
+
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
285
|
* Determines if a Slice Zone has at least one Slice.
|
|
@@ -291,5 +291,5 @@ export const group = <
|
|
|
291
291
|
export const sliceZone = <Slices extends Slice | SharedSlice>(
|
|
292
292
|
slices: SliceZone<Slices> | null | undefined,
|
|
293
293
|
): slices is SliceZone<Slices, "filled"> => {
|
|
294
|
-
return isNonNullish(slices) && isNonEmptyArray(slices)
|
|
295
|
-
}
|
|
294
|
+
return isNonNullish(slices) && isNonEmptyArray(slices)
|
|
295
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Slice } from "../types/value/slice"
|
|
1
|
+
import type { Slice } from "../types/value/slice"
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Convert a value to a lazyily loaded module. This is useful when using
|
|
5
5
|
* functions like `() => import("...")`.
|
|
6
6
|
*/
|
|
7
|
-
type LazyModule<T> = () => Promise<T | { default: T }
|
|
7
|
+
type LazyModule<T> = () => Promise<T | { default: T }>
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Mark a type as potentially lazy-loaded via a module.
|
|
11
11
|
*/
|
|
12
|
-
type MaybeLazyModule<T> = T | LazyModule<T
|
|
12
|
+
type MaybeLazyModule<T> = T | LazyModule<T>
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
type AnyFunction = (...args: any[]) => any
|
|
15
|
+
type AnyFunction = (...args: any[]) => any
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Returns the type of a `SliceLike` type.
|
|
@@ -23,7 +23,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
|
|
|
23
23
|
? TSlice["slice_type"]
|
|
24
24
|
: TSlice extends SliceLikeGraphQL
|
|
25
25
|
? TSlice["type"]
|
|
26
|
-
: never
|
|
26
|
+
: never
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
@@ -34,7 +34,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
|
|
|
34
34
|
type SliceLikeRestV2<TSliceType extends string = string> = Pick<
|
|
35
35
|
Slice<TSliceType>,
|
|
36
36
|
"id" | "slice_type"
|
|
37
|
-
|
|
37
|
+
>
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
@@ -43,8 +43,8 @@ type SliceLikeRestV2<TSliceType extends string = string> = Pick<
|
|
|
43
43
|
* @typeParam SliceType - Type name of the Slice.
|
|
44
44
|
*/
|
|
45
45
|
type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
46
|
-
type: Slice<TSliceType>["slice_type"]
|
|
47
|
-
}
|
|
46
|
+
type: Slice<TSliceType>["slice_type"]
|
|
47
|
+
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* The minimum required properties to represent a Prismic Slice for the
|
|
@@ -57,7 +57,7 @@ type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
|
57
57
|
*/
|
|
58
58
|
type SliceLike<TSliceType extends string = string> =
|
|
59
59
|
| SliceLikeRestV2<TSliceType>
|
|
60
|
-
| SliceLikeGraphQL<TSliceType
|
|
60
|
+
| SliceLikeGraphQL<TSliceType>
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* A looser version of the `SliceZone` type from `@prismicio/client` using
|
|
@@ -68,7 +68,7 @@ type SliceLike<TSliceType extends string = string> =
|
|
|
68
68
|
*
|
|
69
69
|
* @typeParam TSlice - The type(s) of a Slice in the Slice Zone.
|
|
70
70
|
*/
|
|
71
|
-
type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]
|
|
71
|
+
type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlice[]
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* A set of properties that identify a Slice as having been mapped. Consumers of
|
|
@@ -82,8 +82,8 @@ type MappedSliceLike = {
|
|
|
82
82
|
*
|
|
83
83
|
* @internal
|
|
84
84
|
*/
|
|
85
|
-
__mapped: true
|
|
86
|
-
}
|
|
85
|
+
__mapped: true
|
|
86
|
+
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* Arguments for a function mapping content from a Prismic Slice using the
|
|
@@ -100,12 +100,12 @@ type SliceMapperArgs<
|
|
|
100
100
|
/**
|
|
101
101
|
* Slice data.
|
|
102
102
|
*/
|
|
103
|
-
slice: TSlice
|
|
103
|
+
slice: TSlice
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* The index of the Slice in the Slice Zone.
|
|
107
107
|
*/
|
|
108
|
-
index: number
|
|
108
|
+
index: number
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* All Slices from the Slice Zone to which the Slice belongs.
|
|
@@ -116,14 +116,14 @@ type SliceMapperArgs<
|
|
|
116
116
|
// throw a compilation error.
|
|
117
117
|
slices: SliceZoneLike<
|
|
118
118
|
TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2
|
|
119
|
-
|
|
119
|
+
>
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
122
|
* Arbitrary data passed to `mapSliceZone()` and made available to all Slice
|
|
123
123
|
* mappers.
|
|
124
124
|
*/
|
|
125
|
-
context: TContext
|
|
126
|
-
}
|
|
125
|
+
context: TContext
|
|
126
|
+
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* A record of mappers.
|
|
@@ -136,8 +136,8 @@ type SliceMappers<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
|
|
|
136
136
|
any,
|
|
137
137
|
TContext
|
|
138
138
|
>
|
|
139
|
-
|
|
140
|
-
}
|
|
139
|
+
>
|
|
140
|
+
}
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* A function that maps a Slice and its metadata to a modified version. The
|
|
@@ -152,7 +152,7 @@ export type SliceMapper<
|
|
|
152
152
|
TContext = unknown,
|
|
153
153
|
> = (
|
|
154
154
|
args: SliceMapperArgs<TSlice, TContext>,
|
|
155
|
-
) => TMappedSlice | Promise<TMappedSlice
|
|
155
|
+
) => TMappedSlice | Promise<TMappedSlice>
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Unwraps a lazily loaded mapper module.
|
|
@@ -163,11 +163,11 @@ type ResolveLazySliceMapperModule<
|
|
|
163
163
|
> =
|
|
164
164
|
TSliceMapper extends LazyModule<SliceMapper>
|
|
165
165
|
? Awaited<ReturnType<TSliceMapper>> extends {
|
|
166
|
-
default: unknown
|
|
166
|
+
default: unknown
|
|
167
167
|
}
|
|
168
168
|
? Awaited<ReturnType<TSliceMapper>>["default"]
|
|
169
169
|
: Awaited<ReturnType<TSliceMapper>>
|
|
170
|
-
: TSliceMapper
|
|
170
|
+
: TSliceMapper
|
|
171
171
|
|
|
172
172
|
/**
|
|
173
173
|
* Transforms a Slice into its mapped version.
|
|
@@ -206,7 +206,7 @@ type MapSliceLike<
|
|
|
206
206
|
>
|
|
207
207
|
: TSliceLike
|
|
208
208
|
: TSliceLike
|
|
209
|
-
: never
|
|
209
|
+
: never
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
212
|
* Transforms a Slice Zone using a set of mapping functions, one for each type
|
|
@@ -236,23 +236,23 @@ export function mapSliceZone<
|
|
|
236
236
|
): Promise<MapSliceLike<TSliceLike, TSliceMappers>[]> {
|
|
237
237
|
return Promise.all(
|
|
238
238
|
sliceZone.map(async (slice, index, slices) => {
|
|
239
|
-
const isRestSliceType = "slice_type" in slice
|
|
240
|
-
const sliceType = isRestSliceType ? slice.slice_type : slice.type
|
|
239
|
+
const isRestSliceType = "slice_type" in slice
|
|
240
|
+
const sliceType = isRestSliceType ? slice.slice_type : slice.type
|
|
241
241
|
|
|
242
|
-
const mapper = mappers[sliceType as keyof typeof mappers]
|
|
242
|
+
const mapper = mappers[sliceType as keyof typeof mappers]
|
|
243
243
|
|
|
244
244
|
if (!mapper) {
|
|
245
|
-
return slice
|
|
245
|
+
return slice
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
const mapperArgs = { slice, slices, index, context }
|
|
248
|
+
const mapperArgs = { slice, slices, index, context }
|
|
249
249
|
|
|
250
250
|
// `result` may be a mapper function OR a module
|
|
251
251
|
// containing a mapper function.
|
|
252
252
|
let result = await mapper(
|
|
253
253
|
// @ts-expect-error - I don't know how to fix this type
|
|
254
254
|
mapperArgs,
|
|
255
|
-
)
|
|
255
|
+
)
|
|
256
256
|
|
|
257
257
|
// `result` is a module containing a mapper function,
|
|
258
258
|
// we need to dig out the mapper function. `result`
|
|
@@ -265,8 +265,8 @@ export function mapSliceZone<
|
|
|
265
265
|
(typeof result === "function" ||
|
|
266
266
|
(typeof result === "object" && "default" in result))
|
|
267
267
|
) {
|
|
268
|
-
result = "default" in result ? result.default : result
|
|
269
|
-
result = await result(mapperArgs)
|
|
268
|
+
result = "default" in result ? result.default : result
|
|
269
|
+
result = await result(mapperArgs)
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
if (isRestSliceType) {
|
|
@@ -275,14 +275,14 @@ export function mapSliceZone<
|
|
|
275
275
|
id: slice.id,
|
|
276
276
|
slice_type: sliceType,
|
|
277
277
|
...result,
|
|
278
|
-
}
|
|
278
|
+
}
|
|
279
279
|
} else {
|
|
280
280
|
return {
|
|
281
281
|
__mapped: true,
|
|
282
282
|
type: sliceType,
|
|
283
283
|
...result,
|
|
284
|
-
}
|
|
284
|
+
}
|
|
285
285
|
}
|
|
286
286
|
}),
|
|
287
|
-
)
|
|
287
|
+
)
|
|
288
288
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { Element } from "hast"
|
|
2
|
-
import rehypeParse from "rehype-parse"
|
|
3
|
-
import { unified } from "unified"
|
|
1
|
+
import type { Element } from "hast"
|
|
2
|
+
import rehypeParse from "rehype-parse"
|
|
3
|
+
import { unified } from "unified"
|
|
4
4
|
|
|
5
|
-
import { RTPartialInlineNode } from "../lib/RichTextFieldBuilder"
|
|
6
|
-
import { RehypeRichTextConfig
|
|
5
|
+
import type { RTPartialInlineNode } from "../lib/RichTextFieldBuilder"
|
|
6
|
+
import type { RehypeRichTextConfig } from "../lib/rehypeRichText"
|
|
7
|
+
import { rehypeRichText } from "../lib/rehypeRichText"
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import type {
|
|
9
10
|
RTInlineNode,
|
|
10
11
|
RTNode,
|
|
11
12
|
RichTextField,
|
|
12
13
|
RichTextNodeTypes,
|
|
13
|
-
} from "../types/value/richText"
|
|
14
|
+
} from "../types/value/richText"
|
|
14
15
|
|
|
15
16
|
// Used for TSDocs only.
|
|
16
17
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
-
import type { HTMLRichTextMapSerializer, asHTML } from "./asHTML"
|
|
18
|
+
import type { HTMLRichTextMapSerializer, asHTML } from "./asHTML"
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* A shorthand definition for {@link RichTextHTMLMapSerializer} rich text node
|
|
@@ -30,7 +31,7 @@ import type { HTMLRichTextMapSerializer, asHTML } from "./asHTML";
|
|
|
30
31
|
*/
|
|
31
32
|
export type RichTextHTMLMapSerializerShorthand =
|
|
32
33
|
| Exclude<RichTextNodeTypes, "label" | "span">
|
|
33
|
-
| { label: string }
|
|
34
|
+
| { label: string }
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* The payload provided to a {@link RichTextHTMLMapSerializerFunction}.
|
|
@@ -39,7 +40,7 @@ type RichTextHTMLMapSerializerFunctionPayload = {
|
|
|
39
40
|
/**
|
|
40
41
|
* The hast {@link Element} node to serialize.
|
|
41
42
|
*/
|
|
42
|
-
node: Element
|
|
43
|
+
node: Element
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* Additional context information to help with the serialization.
|
|
@@ -48,9 +49,9 @@ type RichTextHTMLMapSerializerFunctionPayload = {
|
|
|
48
49
|
/**
|
|
49
50
|
* The list type of the last list node encountered if any.
|
|
50
51
|
*/
|
|
51
|
-
listType?: "group-list-item" | "group-o-list-item"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
52
|
+
listType?: "group-list-item" | "group-o-list-item"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
54
55
|
|
|
55
56
|
/**
|
|
56
57
|
* Serializes a hast {@link Element} node to a
|
|
@@ -68,7 +69,7 @@ export type RichTextHTMLMapSerializerFunction = (
|
|
|
68
69
|
| RTNode
|
|
69
70
|
| RTInlineNode
|
|
70
71
|
| RTPartialInlineNode
|
|
71
|
-
| undefined
|
|
72
|
+
| undefined
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* Serializes a hast {@link Element} node matching the given HTML tag name or CSS
|
|
@@ -82,20 +83,20 @@ export type RichTextHTMLMapSerializerFunction = (
|
|
|
82
83
|
export type RichTextHTMLMapSerializer = Record<
|
|
83
84
|
string,
|
|
84
85
|
RichTextHTMLMapSerializerShorthand | RichTextHTMLMapSerializerFunction
|
|
85
|
-
|
|
86
|
+
>
|
|
86
87
|
|
|
87
88
|
/**
|
|
88
89
|
* Configuration that determines the output of {@link htmlAsRichText}.
|
|
89
90
|
*/
|
|
90
|
-
export type HTMLAsRichTextConfig = RehypeRichTextConfig
|
|
91
|
+
export type HTMLAsRichTextConfig = RehypeRichTextConfig
|
|
91
92
|
|
|
92
93
|
/**
|
|
93
94
|
* The return type of {@link htmlAsRichText}.
|
|
94
95
|
*/
|
|
95
96
|
type HTMLAsRichTextReturnType = {
|
|
96
|
-
result: RichTextField
|
|
97
|
-
warnings: string[]
|
|
98
|
-
}
|
|
97
|
+
result: RichTextField
|
|
98
|
+
warnings: string[]
|
|
99
|
+
}
|
|
99
100
|
|
|
100
101
|
/**
|
|
101
102
|
* Converts an HTML string to a rich text field.
|
|
@@ -115,7 +116,7 @@ export const unstable_htmlAsRichText = (
|
|
|
115
116
|
const { result, messages } = unified()
|
|
116
117
|
.use(rehypeParse, { emitParseErrors: true, missingDoctype: 0 })
|
|
117
118
|
.use(rehypeRichText, config)
|
|
118
|
-
.processSync(html)
|
|
119
|
+
.processSync(html)
|
|
119
120
|
|
|
120
|
-
return { result, warnings: messages.map((message) => message.toString()) }
|
|
121
|
-
}
|
|
121
|
+
return { result, warnings: messages.map((message) => message.toString()) }
|
|
122
|
+
}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import remarkParse from "remark-parse"
|
|
2
|
-
import remarkRehype from "remark-rehype"
|
|
3
|
-
import { unified } from "unified"
|
|
1
|
+
import remarkParse from "remark-parse"
|
|
2
|
+
import remarkRehype from "remark-rehype"
|
|
3
|
+
import { unified } from "unified"
|
|
4
4
|
|
|
5
|
-
import { RehypeRichTextConfig
|
|
5
|
+
import type { RehypeRichTextConfig } from "../lib/rehypeRichText"
|
|
6
|
+
import { rehypeRichText } from "../lib/rehypeRichText"
|
|
6
7
|
|
|
7
|
-
import { RichTextField } from "../types/value/richText"
|
|
8
|
+
import type { RichTextField } from "../types/value/richText"
|
|
8
9
|
|
|
9
10
|
// Used for TSDocs only.
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
-
import type { unstable_htmlAsRichText } from "./unstable_htmlAsRichText"
|
|
12
|
+
import type { unstable_htmlAsRichText } from "./unstable_htmlAsRichText"
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Configuration that determines the output of {@link markdownAsRichText}.
|
|
15
16
|
*/
|
|
16
|
-
export type MarkdownAsRichTextConfig = RehypeRichTextConfig
|
|
17
|
+
export type MarkdownAsRichTextConfig = RehypeRichTextConfig
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* The return type of {@link markdownAsRichText}.
|
|
20
21
|
*/
|
|
21
22
|
type MarkdownAsRichTextReturnType = {
|
|
22
|
-
result: RichTextField
|
|
23
|
-
warnings: string[]
|
|
24
|
-
}
|
|
23
|
+
result: RichTextField
|
|
24
|
+
warnings: string[]
|
|
25
|
+
}
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Converts a markdown string to a rich text field.
|
|
@@ -46,7 +47,7 @@ export const unstable_markdownAsRichText = (
|
|
|
46
47
|
.use(remarkParse)
|
|
47
48
|
.use(remarkRehype)
|
|
48
49
|
.use(rehypeRichText, config)
|
|
49
|
-
.processSync(markdown)
|
|
50
|
+
.processSync(markdown)
|
|
50
51
|
|
|
51
|
-
return { result, warnings: messages.map((message) => message.toString()) }
|
|
52
|
-
}
|
|
52
|
+
return { result, warnings: messages.map((message) => message.toString()) }
|
|
53
|
+
}
|