@prismicio/client 7.7.2 → 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 +3 -4
- package/dist/lib/hastToRichText.cjs.map +1 -1
- package/dist/lib/hastToRichText.d.ts +4 -4
- package/dist/lib/hastToRichText.js +3 -4
- 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/index.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
// Imports are used for deprecations.
|
|
2
|
-
import type { CustomTypeModelIntegrationField } from "./types/model/integration"
|
|
3
|
-
import type { IntegrationField } from "./types/value/integration"
|
|
4
|
-
import { RichTextNodeType } from "./types/value/richText"
|
|
2
|
+
import type { CustomTypeModelIntegrationField } from "./types/model/integration"
|
|
3
|
+
import type { IntegrationField } from "./types/value/integration"
|
|
4
|
+
import { RichTextNodeType } from "./types/value/richText"
|
|
5
5
|
|
|
6
6
|
import type {
|
|
7
7
|
HTMLRichTextFunctionSerializer,
|
|
8
8
|
HTMLRichTextMapSerializer,
|
|
9
|
-
} from "./helpers/asHTML"
|
|
10
|
-
import { mapSliceZone } from "./helpers/mapSliceZone"
|
|
9
|
+
} from "./helpers/asHTML"
|
|
10
|
+
import { mapSliceZone } from "./helpers/mapSliceZone"
|
|
11
11
|
|
|
12
|
-
import { filter } from "./filter"
|
|
12
|
+
import { filter } from "./filter"
|
|
13
13
|
|
|
14
14
|
//=============================================================================
|
|
15
15
|
// Client - Query content from Prismic.
|
|
16
16
|
//=============================================================================
|
|
17
17
|
|
|
18
18
|
// Primary Client API.
|
|
19
|
-
export { createClient, Client } from "./createClient"
|
|
19
|
+
export { createClient, Client } from "./createClient"
|
|
20
20
|
|
|
21
21
|
// API endpoint helpers.
|
|
22
|
-
export { getRepositoryEndpoint } from "./getRepositoryEndpoint"
|
|
23
|
-
export { getRepositoryName } from "./getRepositoryName"
|
|
24
|
-
export { getGraphQLEndpoint } from "./getGraphQLEndpoint"
|
|
25
|
-
export { isRepositoryName } from "./isRepositoryName"
|
|
26
|
-
export { isRepositoryEndpoint } from "./isRepositoryEndpoint"
|
|
27
|
-
export { buildQueryURL } from "./buildQueryURL"
|
|
22
|
+
export { getRepositoryEndpoint } from "./getRepositoryEndpoint"
|
|
23
|
+
export { getRepositoryName } from "./getRepositoryName"
|
|
24
|
+
export { getGraphQLEndpoint } from "./getGraphQLEndpoint"
|
|
25
|
+
export { isRepositoryName } from "./isRepositoryName"
|
|
26
|
+
export { isRepositoryEndpoint } from "./isRepositoryEndpoint"
|
|
27
|
+
export { buildQueryURL } from "./buildQueryURL"
|
|
28
28
|
|
|
29
29
|
// Toolbar helpers.
|
|
30
|
-
export { getToolbarSrc } from "./getToolbarSrc"
|
|
30
|
+
export { getToolbarSrc } from "./getToolbarSrc"
|
|
31
31
|
|
|
32
32
|
// Query filters API.
|
|
33
33
|
/**
|
|
34
34
|
* @deprecated Renamed to `filter`
|
|
35
35
|
*/
|
|
36
36
|
// TODO: Remove when we remove support for deprecated `predicate` export.
|
|
37
|
-
const predicate = filter
|
|
38
|
-
export { filter, predicate }
|
|
37
|
+
const predicate = filter
|
|
38
|
+
export { filter, predicate }
|
|
39
39
|
|
|
40
40
|
// A collection of well-known cookie names shared between Prismic libraries and systems.
|
|
41
|
-
export * as cookie from "./cookie"
|
|
41
|
+
export * as cookie from "./cookie"
|
|
42
42
|
|
|
43
43
|
// General types used to query content from Prismic. These are made public to allow users to better type their projects.
|
|
44
44
|
export type {
|
|
@@ -49,79 +49,79 @@ export type {
|
|
|
49
49
|
HttpRequestLike,
|
|
50
50
|
RequestInitLike,
|
|
51
51
|
ResponseLike,
|
|
52
|
-
} from "./createClient"
|
|
52
|
+
} from "./createClient"
|
|
53
53
|
export type {
|
|
54
54
|
BuildQueryURLArgs,
|
|
55
55
|
Ordering,
|
|
56
56
|
QueryParams,
|
|
57
57
|
Route,
|
|
58
|
-
} from "./buildQueryURL"
|
|
58
|
+
} from "./buildQueryURL"
|
|
59
59
|
|
|
60
60
|
//=============================================================================
|
|
61
61
|
// Helpers - Manipulate content from Prismic.
|
|
62
62
|
//=============================================================================
|
|
63
63
|
|
|
64
64
|
// Primary Helpers API.
|
|
65
|
-
export { asDate } from "./helpers/asDate"
|
|
66
|
-
export { asLink } from "./helpers/asLink"
|
|
67
|
-
export { asLinkAttrs } from "./helpers/asLinkAttrs"
|
|
68
|
-
export { asText } from "./helpers/asText"
|
|
69
|
-
export { asHTML } from "./helpers/asHTML"
|
|
70
|
-
export { asImageSrc } from "./helpers/asImageSrc"
|
|
71
|
-
export { asImageWidthSrcSet } from "./helpers/asImageWidthSrcSet"
|
|
72
|
-
export { asImagePixelDensitySrcSet } from "./helpers/asImagePixelDensitySrcSet"
|
|
73
|
-
export * as isFilled from "./helpers/isFilled"
|
|
65
|
+
export { asDate } from "./helpers/asDate"
|
|
66
|
+
export { asLink } from "./helpers/asLink"
|
|
67
|
+
export { asLinkAttrs } from "./helpers/asLinkAttrs"
|
|
68
|
+
export { asText } from "./helpers/asText"
|
|
69
|
+
export { asHTML } from "./helpers/asHTML"
|
|
70
|
+
export { asImageSrc } from "./helpers/asImageSrc"
|
|
71
|
+
export { asImageWidthSrcSet } from "./helpers/asImageWidthSrcSet"
|
|
72
|
+
export { asImagePixelDensitySrcSet } from "./helpers/asImagePixelDensitySrcSet"
|
|
73
|
+
export * as isFilled from "./helpers/isFilled"
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* @deprecated Renamed to `mapSliceZone`
|
|
77
77
|
*/
|
|
78
|
-
const unstable_mapSliceZone = mapSliceZone
|
|
79
|
-
export { mapSliceZone, unstable_mapSliceZone }
|
|
78
|
+
const unstable_mapSliceZone = mapSliceZone
|
|
79
|
+
export { mapSliceZone, unstable_mapSliceZone }
|
|
80
80
|
|
|
81
81
|
// Conversion helper.
|
|
82
|
-
export { documentToLinkField } from "./helpers/documentToLinkField"
|
|
83
|
-
export { unstable_htmlAsRichText } from "./helpers/unstable_htmlAsRichText"
|
|
84
|
-
export { unstable_markdownAsRichText } from "./helpers/unstable_markdownAsRichText"
|
|
82
|
+
export { documentToLinkField } from "./helpers/documentToLinkField"
|
|
83
|
+
export { unstable_htmlAsRichText } from "./helpers/unstable_htmlAsRichText"
|
|
84
|
+
export { unstable_markdownAsRichText } from "./helpers/unstable_markdownAsRichText"
|
|
85
85
|
|
|
86
|
-
export type { LinkResolverFunction } from "./helpers/asLink"
|
|
87
|
-
export type { AsLinkAttrsConfig } from "./helpers/asLinkAttrs"
|
|
88
|
-
export type { SliceMapper } from "./helpers/mapSliceZone"
|
|
86
|
+
export type { LinkResolverFunction } from "./helpers/asLink"
|
|
87
|
+
export type { AsLinkAttrsConfig } from "./helpers/asLinkAttrs"
|
|
88
|
+
export type { SliceMapper } from "./helpers/mapSliceZone"
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* @deprecated Renamed to `HTMLRichTextMapSerializer`
|
|
92
92
|
*/
|
|
93
|
-
type HTMLMapSerializer = HTMLRichTextMapSerializer
|
|
93
|
+
type HTMLMapSerializer = HTMLRichTextMapSerializer
|
|
94
94
|
/**
|
|
95
95
|
* @deprecated Renamed to `HTMLRichTextFunctionSerializer`
|
|
96
96
|
*/
|
|
97
|
-
type HTMLFunctionSerializer = HTMLRichTextFunctionSerializer
|
|
97
|
+
type HTMLFunctionSerializer = HTMLRichTextFunctionSerializer
|
|
98
98
|
export type {
|
|
99
99
|
HTMLRichTextMapSerializer,
|
|
100
100
|
HTMLRichTextFunctionSerializer,
|
|
101
101
|
HTMLMapSerializer,
|
|
102
102
|
HTMLFunctionSerializer,
|
|
103
|
-
}
|
|
104
|
-
export type { HTMLRichTextSerializer } from "./helpers/asHTML"
|
|
103
|
+
}
|
|
104
|
+
export type { HTMLRichTextSerializer } from "./helpers/asHTML"
|
|
105
105
|
|
|
106
|
-
export type { RichTextHTMLMapSerializer } from "./helpers/unstable_htmlAsRichText"
|
|
106
|
+
export type { RichTextHTMLMapSerializer } from "./helpers/unstable_htmlAsRichText"
|
|
107
107
|
|
|
108
108
|
//=============================================================================
|
|
109
109
|
// Errors - Custom errors for Prismic APIs.
|
|
110
110
|
//=============================================================================
|
|
111
111
|
|
|
112
112
|
// Client Errors
|
|
113
|
-
export { PrismicError } from "./errors/PrismicError"
|
|
114
|
-
export { ForbiddenError } from "./errors/ForbiddenError"
|
|
115
|
-
export { NotFoundError } from "./errors/NotFoundError"
|
|
116
|
-
export { RefNotFoundError } from "./errors/RefNotFoundError"
|
|
117
|
-
export { RefExpiredError } from "./errors/RefExpiredError"
|
|
118
|
-
export { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired"
|
|
119
|
-
export { ParsingError } from "./errors/ParsingError"
|
|
120
|
-
export { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError"
|
|
113
|
+
export { PrismicError } from "./errors/PrismicError"
|
|
114
|
+
export { ForbiddenError } from "./errors/ForbiddenError"
|
|
115
|
+
export { NotFoundError } from "./errors/NotFoundError"
|
|
116
|
+
export { RefNotFoundError } from "./errors/RefNotFoundError"
|
|
117
|
+
export { RefExpiredError } from "./errors/RefExpiredError"
|
|
118
|
+
export { PreviewTokenExpiredError } from "./errors/PreviewTokenExpired"
|
|
119
|
+
export { ParsingError } from "./errors/ParsingError"
|
|
120
|
+
export { RepositoryNotFoundError } from "./errors/RepositoryNotFoundError"
|
|
121
121
|
|
|
122
122
|
// Rich Text Errors
|
|
123
|
-
export { PrismicRichTextError } from "./errors/PrismicRichTextError"
|
|
124
|
-
export { PrismicRichTextSerializerError } from "./errors/PrismicRichTextSerializerError"
|
|
123
|
+
export { PrismicRichTextError } from "./errors/PrismicRichTextError"
|
|
124
|
+
export { PrismicRichTextSerializerError } from "./errors/PrismicRichTextSerializerError"
|
|
125
125
|
|
|
126
126
|
//=============================================================================
|
|
127
127
|
// Types - Types representing Prismic content, models, and API payloads.
|
|
@@ -132,10 +132,10 @@ export { PrismicRichTextSerializerError } from "./errors/PrismicRichTextSerializ
|
|
|
132
132
|
* @deprecated Use {@link RichTextNodeType} instead.
|
|
133
133
|
*/
|
|
134
134
|
// TODO: Remove in v8.
|
|
135
|
-
const Element = RichTextNodeType
|
|
136
|
-
export { RichTextNodeType, Element }
|
|
137
|
-
export { LinkType } from "./types/value/link"
|
|
138
|
-
export { OEmbedType } from "./types/value/embed"
|
|
135
|
+
const Element = RichTextNodeType
|
|
136
|
+
export { RichTextNodeType, Element }
|
|
137
|
+
export { LinkType } from "./types/value/link"
|
|
138
|
+
export { OEmbedType } from "./types/value/embed"
|
|
139
139
|
|
|
140
140
|
export type {
|
|
141
141
|
PrismicDocument,
|
|
@@ -143,7 +143,7 @@ export type {
|
|
|
143
143
|
PrismicDocumentWithoutUID,
|
|
144
144
|
PrismicDocumentHeader,
|
|
145
145
|
AlternateLanguage,
|
|
146
|
-
} from "./types/value/document"
|
|
146
|
+
} from "./types/value/document"
|
|
147
147
|
|
|
148
148
|
export type {
|
|
149
149
|
// RichText & Title
|
|
@@ -181,29 +181,29 @@ export type {
|
|
|
181
181
|
RTInlineNode,
|
|
182
182
|
RTAnyNode,
|
|
183
183
|
RichTextNodeTypes,
|
|
184
|
-
} from "./types/value/richText"
|
|
185
|
-
export type { TitleField } from "./types/value/title"
|
|
184
|
+
} from "./types/value/richText"
|
|
185
|
+
export type { TitleField } from "./types/value/title"
|
|
186
186
|
|
|
187
187
|
export type {
|
|
188
188
|
ImageField,
|
|
189
189
|
ImageFieldImage,
|
|
190
190
|
FilledImageFieldImage,
|
|
191
191
|
EmptyImageFieldImage,
|
|
192
|
-
} from "./types/value/image"
|
|
192
|
+
} from "./types/value/image"
|
|
193
193
|
|
|
194
194
|
export type {
|
|
195
195
|
EmptyLinkField,
|
|
196
196
|
LinkField,
|
|
197
197
|
FilledLinkToWebField,
|
|
198
|
-
} from "./types/value/link"
|
|
198
|
+
} from "./types/value/link"
|
|
199
199
|
export type {
|
|
200
200
|
ContentRelationshipField,
|
|
201
201
|
FilledContentRelationshipField,
|
|
202
|
-
} from "./types/value/contentRelationship"
|
|
202
|
+
} from "./types/value/contentRelationship"
|
|
203
203
|
export type {
|
|
204
204
|
LinkToMediaField,
|
|
205
205
|
FilledLinkToMediaField,
|
|
206
|
-
} from "./types/value/linkToMedia"
|
|
206
|
+
} from "./types/value/linkToMedia"
|
|
207
207
|
|
|
208
208
|
export type {
|
|
209
209
|
OEmbedExtra,
|
|
@@ -213,135 +213,135 @@ export type {
|
|
|
213
213
|
RichOEmbed,
|
|
214
214
|
AnyOEmbed,
|
|
215
215
|
EmbedField,
|
|
216
|
-
} from "./types/value/embed"
|
|
216
|
+
} from "./types/value/embed"
|
|
217
217
|
|
|
218
|
-
export type { BooleanField } from "./types/value/boolean"
|
|
219
|
-
export type { ColorField } from "./types/value/color"
|
|
220
|
-
export type { DateField } from "./types/value/date"
|
|
221
|
-
export type { KeyTextField } from "./types/value/keyText"
|
|
222
|
-
export type { NumberField } from "./types/value/number"
|
|
223
|
-
export type { SelectField } from "./types/value/select"
|
|
224
|
-
export type { TimestampField } from "./types/value/timestamp"
|
|
225
|
-
export type { GeoPointField } from "./types/value/geoPoint"
|
|
218
|
+
export type { BooleanField } from "./types/value/boolean"
|
|
219
|
+
export type { ColorField } from "./types/value/color"
|
|
220
|
+
export type { DateField } from "./types/value/date"
|
|
221
|
+
export type { KeyTextField } from "./types/value/keyText"
|
|
222
|
+
export type { NumberField } from "./types/value/number"
|
|
223
|
+
export type { SelectField } from "./types/value/select"
|
|
224
|
+
export type { TimestampField } from "./types/value/timestamp"
|
|
225
|
+
export type { GeoPointField } from "./types/value/geoPoint"
|
|
226
226
|
|
|
227
227
|
/**
|
|
228
228
|
* @deprecated Renamed to `IntegrationField`
|
|
229
229
|
*/
|
|
230
230
|
// TODO: Remove when we remove support for deprecated `IntegrationFields` export.
|
|
231
|
-
type IntegrationFields = IntegrationField
|
|
232
|
-
export { IntegrationField, IntegrationFields }
|
|
231
|
+
type IntegrationFields = IntegrationField
|
|
232
|
+
export { IntegrationField, IntegrationFields }
|
|
233
233
|
|
|
234
|
-
export type { GroupField, NestedGroupField } from "./types/value/group"
|
|
234
|
+
export type { GroupField, NestedGroupField } from "./types/value/group"
|
|
235
235
|
|
|
236
|
-
export type { SliceZone } from "./types/value/sliceZone"
|
|
237
|
-
export type { Slice } from "./types/value/slice"
|
|
238
|
-
export type { SharedSlice } from "./types/value/sharedSlice"
|
|
239
|
-
export type { SharedSliceVariation } from "./types/value/sharedSliceVariation"
|
|
236
|
+
export type { SliceZone } from "./types/value/sliceZone"
|
|
237
|
+
export type { Slice } from "./types/value/slice"
|
|
238
|
+
export type { SharedSlice } from "./types/value/sharedSlice"
|
|
239
|
+
export type { SharedSliceVariation } from "./types/value/sharedSliceVariation"
|
|
240
240
|
|
|
241
241
|
export type {
|
|
242
242
|
FieldState,
|
|
243
243
|
AnyRegularField,
|
|
244
244
|
AnySlicePrimaryField,
|
|
245
|
-
} from "./types/value/types"
|
|
245
|
+
} from "./types/value/types"
|
|
246
246
|
|
|
247
247
|
// Models - Types representing Prismic content models.
|
|
248
|
-
export { CustomTypeModelFieldType } from "./types/model/types"
|
|
249
|
-
export { CustomTypeModelLinkSelectType } from "./types/model/link"
|
|
250
|
-
export { CustomTypeModelSliceType } from "./types/model/sliceZone"
|
|
251
|
-
export { CustomTypeModelSliceDisplay } from "./types/model/slice"
|
|
248
|
+
export { CustomTypeModelFieldType } from "./types/model/types"
|
|
249
|
+
export { CustomTypeModelLinkSelectType } from "./types/model/link"
|
|
250
|
+
export { CustomTypeModelSliceType } from "./types/model/sliceZone"
|
|
251
|
+
export { CustomTypeModelSliceDisplay } from "./types/model/slice"
|
|
252
252
|
|
|
253
253
|
export type {
|
|
254
254
|
CustomTypeModel,
|
|
255
255
|
CustomTypeModelDefinition,
|
|
256
256
|
CustomTypeModelTab,
|
|
257
|
-
} from "./types/model/customType"
|
|
257
|
+
} from "./types/model/customType"
|
|
258
258
|
|
|
259
259
|
export type {
|
|
260
260
|
CustomTypeModelRichTextField,
|
|
261
261
|
CustomTypeModelRichTextMultiField,
|
|
262
262
|
CustomTypeModelRichTextSingleField,
|
|
263
|
-
} from "./types/model/richText"
|
|
264
|
-
export type { CustomTypeModelTitleField } from "./types/model/title"
|
|
263
|
+
} from "./types/model/richText"
|
|
264
|
+
export type { CustomTypeModelTitleField } from "./types/model/title"
|
|
265
265
|
|
|
266
266
|
export type {
|
|
267
267
|
CustomTypeModelImageField,
|
|
268
268
|
CustomTypeModelImageConstraint,
|
|
269
269
|
CustomTypeModelImageThumbnail,
|
|
270
|
-
} from "./types/model/image"
|
|
270
|
+
} from "./types/model/image"
|
|
271
271
|
|
|
272
|
-
export type { CustomTypeModelContentRelationshipField } from "./types/model/contentRelationship"
|
|
273
|
-
export type { CustomTypeModelLinkField } from "./types/model/link"
|
|
274
|
-
export type { CustomTypeModelLinkToMediaField } from "./types/model/linkToMedia"
|
|
272
|
+
export type { CustomTypeModelContentRelationshipField } from "./types/model/contentRelationship"
|
|
273
|
+
export type { CustomTypeModelLinkField } from "./types/model/link"
|
|
274
|
+
export type { CustomTypeModelLinkToMediaField } from "./types/model/linkToMedia"
|
|
275
275
|
|
|
276
|
-
export type { CustomTypeModelEmbedField } from "./types/model/embed"
|
|
276
|
+
export type { CustomTypeModelEmbedField } from "./types/model/embed"
|
|
277
277
|
|
|
278
|
-
export type { CustomTypeModelBooleanField } from "./types/model/boolean"
|
|
279
|
-
export type { CustomTypeModelColorField } from "./types/model/color"
|
|
280
|
-
export type { CustomTypeModelDateField } from "./types/model/date"
|
|
281
|
-
export type { CustomTypeModelKeyTextField } from "./types/model/keyText"
|
|
282
|
-
export type { CustomTypeModelNumberField } from "./types/model/number"
|
|
283
|
-
export type { CustomTypeModelSelectField } from "./types/model/select"
|
|
284
|
-
export type { CustomTypeModelTimestampField } from "./types/model/timestamp"
|
|
285
|
-
export type { CustomTypeModelGeoPointField } from "./types/model/geoPoint"
|
|
278
|
+
export type { CustomTypeModelBooleanField } from "./types/model/boolean"
|
|
279
|
+
export type { CustomTypeModelColorField } from "./types/model/color"
|
|
280
|
+
export type { CustomTypeModelDateField } from "./types/model/date"
|
|
281
|
+
export type { CustomTypeModelKeyTextField } from "./types/model/keyText"
|
|
282
|
+
export type { CustomTypeModelNumberField } from "./types/model/number"
|
|
283
|
+
export type { CustomTypeModelSelectField } from "./types/model/select"
|
|
284
|
+
export type { CustomTypeModelTimestampField } from "./types/model/timestamp"
|
|
285
|
+
export type { CustomTypeModelGeoPointField } from "./types/model/geoPoint"
|
|
286
286
|
|
|
287
287
|
/**
|
|
288
288
|
* @deprecated Renamed to `CustomTypeModelIntegrationField`.
|
|
289
289
|
*/
|
|
290
290
|
// TODO: Remove when we remove support for deprecated `CustomTypeModelIntegrationField` export.
|
|
291
|
-
type CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField
|
|
291
|
+
type CustomTypeModelIntegrationFieldsField = CustomTypeModelIntegrationField
|
|
292
292
|
export {
|
|
293
293
|
CustomTypeModelIntegrationField,
|
|
294
294
|
CustomTypeModelIntegrationFieldsField,
|
|
295
|
-
}
|
|
295
|
+
}
|
|
296
296
|
export type {
|
|
297
297
|
CustomTypeModelGroupField,
|
|
298
298
|
CustomTypeModelNestedGroupField,
|
|
299
|
-
} from "./types/model/group"
|
|
299
|
+
} from "./types/model/group"
|
|
300
300
|
export type {
|
|
301
301
|
CustomTypeModelSliceZoneField,
|
|
302
302
|
CustomTypeModelSliceLabel,
|
|
303
303
|
CustomTypeModelSharedSlice,
|
|
304
|
-
} from "./types/model/sliceZone"
|
|
304
|
+
} from "./types/model/sliceZone"
|
|
305
305
|
export type {
|
|
306
306
|
CustomTypeModelSlice,
|
|
307
307
|
CustomTypeModelLegacySlice,
|
|
308
|
-
} from "./types/model/slice"
|
|
309
|
-
export type { SharedSliceModel } from "./types/model/sharedSlice"
|
|
310
|
-
export type { SharedSliceModelVariation } from "./types/model/sharedSliceVariation"
|
|
308
|
+
} from "./types/model/slice"
|
|
309
|
+
export type { SharedSliceModel } from "./types/model/sharedSlice"
|
|
310
|
+
export type { SharedSliceModelVariation } from "./types/model/sharedSliceVariation"
|
|
311
311
|
|
|
312
|
-
export type { CustomTypeModelUIDField } from "./types/model/uid"
|
|
312
|
+
export type { CustomTypeModelUIDField } from "./types/model/uid"
|
|
313
313
|
|
|
314
|
-
export type { CustomTypeModelRangeField } from "./types/model/range"
|
|
315
|
-
export type { CustomTypeModelSeparatorField } from "./types/model/separator"
|
|
314
|
+
export type { CustomTypeModelRangeField } from "./types/model/range"
|
|
315
|
+
export type { CustomTypeModelSeparatorField } from "./types/model/separator"
|
|
316
316
|
|
|
317
317
|
export type {
|
|
318
318
|
CustomTypeModelField,
|
|
319
319
|
CustomTypeModelFieldForGroup,
|
|
320
320
|
CustomTypeModelFieldForNestedGroup,
|
|
321
321
|
CustomTypeModelFieldForSlicePrimary,
|
|
322
|
-
} from "./types/model/types"
|
|
322
|
+
} from "./types/model/types"
|
|
323
323
|
|
|
324
324
|
// API - Types representing Prismic Rest API V2 responses.
|
|
325
|
-
export type { Query } from "./types/api/query"
|
|
325
|
+
export type { Query } from "./types/api/query"
|
|
326
326
|
|
|
327
|
-
export type { Ref } from "./types/api/ref"
|
|
327
|
+
export type { Ref } from "./types/api/ref"
|
|
328
328
|
|
|
329
|
-
export type { Release } from "./types/api/release"
|
|
329
|
+
export type { Release } from "./types/api/release"
|
|
330
330
|
|
|
331
331
|
export type {
|
|
332
332
|
Repository,
|
|
333
333
|
Language,
|
|
334
334
|
Form,
|
|
335
335
|
FormField,
|
|
336
|
-
} from "./types/api/repository"
|
|
336
|
+
} from "./types/api/repository"
|
|
337
337
|
|
|
338
|
-
export type { Tags } from "./types/api/tags"
|
|
338
|
+
export type { Tags } from "./types/api/tags"
|
|
339
339
|
|
|
340
340
|
// Webhook - Types representing Prismic webhooks.
|
|
341
|
-
export { WebhookType } from "./types/webhook/types"
|
|
341
|
+
export { WebhookType } from "./types/webhook/types"
|
|
342
342
|
|
|
343
|
-
export type { WebhookBody } from "./types/webhook/types"
|
|
343
|
+
export type { WebhookBody } from "./types/webhook/types"
|
|
344
344
|
|
|
345
|
-
export type { WebhookBodyAPIUpdate } from "./types/webhook/apiUpdate"
|
|
345
|
+
export type { WebhookBodyAPIUpdate } from "./types/webhook/apiUpdate"
|
|
346
346
|
|
|
347
|
-
export type { WebhookBodyTestTrigger } from "./types/webhook/testTrigger"
|
|
347
|
+
export type { WebhookBodyTestTrigger } from "./types/webhook/testTrigger"
|
package/src/isRepositoryName.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
RTInlineNode,
|
|
3
3
|
RTLinkNode,
|
|
4
4
|
RTNode,
|
|
5
5
|
RTTextNode,
|
|
6
6
|
RichTextField,
|
|
7
|
-
} from "../types/value/richText"
|
|
7
|
+
} from "../types/value/richText"
|
|
8
8
|
|
|
9
|
-
import { PrismicRichTextError } from "../errors/PrismicRichTextError"
|
|
9
|
+
import { PrismicRichTextError } from "../errors/PrismicRichTextError"
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Omits keys from a type, distributing the operation over a union.
|
|
@@ -18,27 +18,24 @@ import { PrismicRichTextError } from "../errors/PrismicRichTextError";
|
|
|
18
18
|
type DistributedOmit<
|
|
19
19
|
ObjectType,
|
|
20
20
|
KeyType extends keyof ObjectType,
|
|
21
|
-
> = ObjectType extends unknown ? Omit<ObjectType, KeyType> : never
|
|
21
|
+
> = ObjectType extends unknown ? Omit<ObjectType, KeyType> : never
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* An inline node without its `start` and `end` properties.
|
|
25
25
|
*/
|
|
26
|
-
export type RTPartialInlineNode = DistributedOmit<
|
|
27
|
-
RTInlineNode,
|
|
28
|
-
"start" | "end"
|
|
29
|
-
>;
|
|
26
|
+
export type RTPartialInlineNode = DistributedOmit<RTInlineNode, "start" | "end">
|
|
30
27
|
|
|
31
28
|
export class RichTextFieldBuilder {
|
|
32
|
-
#nodes: RTNode[] = []
|
|
29
|
+
#nodes: RTNode[] = []
|
|
33
30
|
|
|
34
31
|
get #last(): RTNode | undefined {
|
|
35
|
-
return this.#nodes[this.#nodes.length - 1]
|
|
32
|
+
return this.#nodes[this.#nodes.length - 1]
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
appendNode(node: RTNode): void {
|
|
39
|
-
this.cleanupLast()
|
|
36
|
+
this.cleanupLast()
|
|
40
37
|
|
|
41
|
-
this.#nodes.push(node)
|
|
38
|
+
this.#nodes.push(node)
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
appendTextNode(
|
|
@@ -50,48 +47,48 @@ export class RichTextFieldBuilder {
|
|
|
50
47
|
text: "",
|
|
51
48
|
spans: [],
|
|
52
49
|
direction,
|
|
53
|
-
})
|
|
50
|
+
})
|
|
54
51
|
}
|
|
55
52
|
|
|
56
|
-
appendSpan(span: RTInlineNode): void
|
|
57
|
-
appendSpan(partialSpan: RTPartialInlineNode, length: number): void
|
|
53
|
+
appendSpan(span: RTInlineNode): void
|
|
54
|
+
appendSpan(partialSpan: RTPartialInlineNode, length: number): void
|
|
58
55
|
appendSpan(
|
|
59
56
|
spanOrPartialSpan: RTInlineNode | RTPartialInlineNode,
|
|
60
57
|
length?: number,
|
|
61
58
|
): void {
|
|
62
59
|
if (!this.isTextNode(this.#last)) {
|
|
63
|
-
throw new PrismicRichTextError("Cannot add span to non-text last node")
|
|
60
|
+
throw new PrismicRichTextError("Cannot add span to non-text last node")
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
let span: RTInlineNode
|
|
63
|
+
let span: RTInlineNode
|
|
67
64
|
if ("start" in spanOrPartialSpan && "end" in spanOrPartialSpan) {
|
|
68
|
-
span = spanOrPartialSpan
|
|
65
|
+
span = spanOrPartialSpan
|
|
69
66
|
} else {
|
|
70
|
-
const lastLength = this.#last.text.length
|
|
67
|
+
const lastLength = this.#last.text.length
|
|
71
68
|
|
|
72
69
|
span = {
|
|
73
70
|
...spanOrPartialSpan,
|
|
74
71
|
start: lastLength,
|
|
75
72
|
end: lastLength + length!,
|
|
76
|
-
}
|
|
73
|
+
}
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
let lastIdenticalSpanIndex = -1
|
|
76
|
+
let lastIdenticalSpanIndex = -1
|
|
80
77
|
for (let i = this.#last.spans.length - 1; i >= 0; i--) {
|
|
81
|
-
const lastSpan = this.#last.spans[i]
|
|
78
|
+
const lastSpan = this.#last.spans[i]
|
|
82
79
|
|
|
83
80
|
if (span.type === "strong" || span.type === "em") {
|
|
84
81
|
if (lastSpan.type === span.type) {
|
|
85
|
-
lastIdenticalSpanIndex = i
|
|
86
|
-
break
|
|
82
|
+
lastIdenticalSpanIndex = i
|
|
83
|
+
break
|
|
87
84
|
}
|
|
88
85
|
} else if (span.type === "label") {
|
|
89
86
|
if (
|
|
90
87
|
lastSpan.type === "label" &&
|
|
91
88
|
lastSpan.data.label === span.data.label
|
|
92
89
|
) {
|
|
93
|
-
lastIdenticalSpanIndex = i
|
|
94
|
-
break
|
|
90
|
+
lastIdenticalSpanIndex = i
|
|
91
|
+
break
|
|
95
92
|
}
|
|
96
93
|
} else if (span.type === "hyperlink") {
|
|
97
94
|
if (lastSpan.type === "hyperlink") {
|
|
@@ -100,11 +97,11 @@ export class RichTextFieldBuilder {
|
|
|
100
97
|
// match with content relationship.
|
|
101
98
|
const isSameLink = (
|
|
102
99
|
Object.entries(span.data) as [keyof RTLinkNode["data"], unknown][]
|
|
103
|
-
).every(([key, value]) => lastSpan.data[key] === value)
|
|
100
|
+
).every(([key, value]) => lastSpan.data[key] === value)
|
|
104
101
|
|
|
105
102
|
if (isSameLink) {
|
|
106
|
-
lastIdenticalSpanIndex = i
|
|
107
|
-
break
|
|
103
|
+
lastIdenticalSpanIndex = i
|
|
104
|
+
break
|
|
108
105
|
}
|
|
109
106
|
}
|
|
110
107
|
}
|
|
@@ -112,39 +109,37 @@ export class RichTextFieldBuilder {
|
|
|
112
109
|
|
|
113
110
|
// Ignore empty spans.
|
|
114
111
|
if (span.start === span.end) {
|
|
115
|
-
return
|
|
112
|
+
return
|
|
116
113
|
}
|
|
117
114
|
|
|
118
115
|
// Prefer to extend the last span of the same type end
|
|
119
116
|
// position if it ends at the start of the new span.
|
|
120
117
|
if (this.#last.spans[lastIdenticalSpanIndex]?.end === span.start) {
|
|
121
|
-
this.#last.spans[lastIdenticalSpanIndex].end = span.end
|
|
118
|
+
this.#last.spans[lastIdenticalSpanIndex].end = span.end
|
|
122
119
|
} else {
|
|
123
|
-
this.#last.spans.push(span)
|
|
120
|
+
this.#last.spans.push(span)
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
123
|
|
|
127
124
|
appendText(text: string): void {
|
|
128
125
|
if (!this.isTextNode(this.#last)) {
|
|
129
|
-
throw new PrismicRichTextError(
|
|
130
|
-
"Cannot append text to non-text last node",
|
|
131
|
-
);
|
|
126
|
+
throw new PrismicRichTextError("Cannot append text to non-text last node")
|
|
132
127
|
}
|
|
133
128
|
|
|
134
129
|
if (this.#last.text) {
|
|
135
|
-
this.#last.text += text
|
|
130
|
+
this.#last.text += text
|
|
136
131
|
} else {
|
|
137
|
-
this.#last.text = text.trimStart()
|
|
132
|
+
this.#last.text = text.trimStart()
|
|
138
133
|
}
|
|
139
134
|
}
|
|
140
135
|
|
|
141
136
|
build(): RichTextField {
|
|
142
137
|
// Ensure that the last text node is trimmed.
|
|
143
|
-
this.cleanupLast()
|
|
138
|
+
this.cleanupLast()
|
|
144
139
|
|
|
145
140
|
// Because `RichTextField` is defined as a non-empty
|
|
146
141
|
// array, we have to cast `RTNode[]` to `RichTextField`.
|
|
147
|
-
return this.#nodes as RichTextField
|
|
142
|
+
return this.#nodes as RichTextField
|
|
148
143
|
}
|
|
149
144
|
|
|
150
145
|
/**
|
|
@@ -152,7 +147,7 @@ export class RichTextFieldBuilder {
|
|
|
152
147
|
*/
|
|
153
148
|
private cleanupLast(): void {
|
|
154
149
|
if (this.isTextNode(this.#last)) {
|
|
155
|
-
this.#last.text = this.#last.text.trimEnd()
|
|
150
|
+
this.#last.text = this.#last.text.trimEnd()
|
|
156
151
|
}
|
|
157
152
|
}
|
|
158
153
|
|
|
@@ -164,6 +159,6 @@ export class RichTextFieldBuilder {
|
|
|
164
159
|
* @returns `true` if `node` is a text node, `false` otherwise.
|
|
165
160
|
*/
|
|
166
161
|
private isTextNode(node?: RTNode): node is RTTextNode {
|
|
167
|
-
return !!node && node.type !== "image" && node.type !== "embed"
|
|
162
|
+
return !!node && node.type !== "image" && node.type !== "embed"
|
|
168
163
|
}
|
|
169
164
|
}
|
package/src/lib/appendFilters.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { castArray } from "./castArray"
|
|
1
|
+
import { castArray } from "./castArray"
|
|
2
2
|
|
|
3
3
|
interface WithFilters {
|
|
4
|
-
filters?: string | string[]
|
|
4
|
+
filters?: string | string[]
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -22,5 +22,5 @@ export const appendFilters = <T extends WithFilters>(
|
|
|
22
22
|
return {
|
|
23
23
|
...objWithFilters,
|
|
24
24
|
filters: [...(objWithFilters.filters || []), ...castArray(filters)],
|
|
25
|
-
}
|
|
26
|
-
}
|
|
25
|
+
}
|
|
26
|
+
}
|