diff --git a/src/value/image.ts b/src/value/image.ts index 92e5481..7cdd90a 100644 --- a/src/value/image.ts +++ b/src/value/image.ts @@ -11,18 +11,27 @@ export type ImageFieldImage = State extends "empty" ? EmptyImageFieldImage : FilledImageFieldImage; export interface FilledImageFieldImage { + id: string; url: string; dimensions: { width: number; height: number; }; + edit: { + x: number; + y: number; + zoom: number; + background: string; + }; alt: string | null; copyright: string | null; } export interface EmptyImageFieldImage { + id?: null; url?: null; dimensions?: null; + edit?: null; alt?: null; copyright?: null; } diff --git a/src/value/linkToMedia.ts b/src/value/linkToMedia.ts index a34d9fb..b28faa2 100644 --- a/src/value/linkToMedia.ts +++ b/src/value/linkToMedia.ts @@ -15,6 +15,7 @@ export type LinkToMediaField = * Link that points to media */ export interface FilledLinkToMediaField { + id: string; link_type: typeof LinkType.Media; name: string; kind: string; diff --git a/src/value/richText.ts b/src/value/richText.ts index d3370d7..9733ee7 100644 --- a/src/value/richText.ts +++ b/src/value/richText.ts @@ -152,6 +152,7 @@ export interface RTLabelNode extends RTSpanNodeBase { */ export type RTImageNode = { type: typeof RichTextNodeType.image; + id: string; url: string; alt: string | null; copyright: string | null; @@ -159,6 +160,12 @@ export type RTImageNode = { width: number; height: number; }; + edit: { + x: number; + y: number; + zoom: number; + background: string; + }; linkTo?: | FilledContentRelationshipField | FilledLinkToWebField diff --git a/test/fields-image.types.ts b/test/fields-image.types.ts index 7c1ce01..6b43282 100644 --- a/test/fields-image.types.ts +++ b/test/fields-image.types.ts @@ -22,23 +22,31 @@ import * as prismicT from "../src"; * Filled state. */ expectType({ + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", }); expectType>({ + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", }); expectType>({ + // @ts-expect-error - Empty fields cannot contain an empty value. + id: "id", // @ts-expect-error - Empty fields cannot contain a filled value. url: "url", // @ts-expect-error - Empty fields cannot contain a filled value. dimensions: { width: 1, height: 1 }, // @ts-expect-error - Empty fields cannot contain a filled value. + edit: { x: 0, y: 0, zoom: 1, background: "background" }, + // @ts-expect-error - Empty fields cannot contain a filled value. alt: "alt", // @ts-expect-error - Empty fields cannot contain a filled value. copyright: "copyright", @@ -61,10 +69,14 @@ expectType>({ copyright: null, }); expectType>({ + // @ts-expect-error - Filled fields cannot contain an empty value. + id: null, // @ts-expect-error - Filled fields cannot contain an empty value. url: null, // @ts-expect-error - Filled fields cannot contain an empty value. dimensions: null, + // @ts-expect-error - Filled fields cannot contain an empty value. + edit: null, alt: null, copyright: null, }); @@ -73,8 +85,10 @@ expectType>({ * Allows null alt and copyright. */ expectType({ + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: null, copyright: null, }); @@ -95,19 +109,25 @@ expectType({ * Supports thumbnails. */ expectType>({ + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", Foo: { + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", }, Bar: { + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", }, @@ -180,13 +200,17 @@ expectType({ }, }); expectType>({ + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", length: { + id: "id", url: "url", dimensions: { width: 1, height: 1 }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, alt: "alt", copyright: "copyright", }, diff --git a/test/fields-linkToMedia.types.ts b/test/fields-linkToMedia.types.ts index 51dbc95..cb8700f 100644 --- a/test/fields-linkToMedia.types.ts +++ b/test/fields-linkToMedia.types.ts @@ -23,6 +23,7 @@ import * as prismicT from "../src"; */ expectType({ link_type: prismicT.LinkType.Media, + id: "string", name: "string", kind: "string", url: "string", @@ -32,6 +33,7 @@ expectType({ }); expectType>({ link_type: prismicT.LinkType.Media, + id: "string", name: "string", kind: "string", url: "string", @@ -42,6 +44,7 @@ expectType>({ expectType>({ link_type: prismicT.LinkType.Media, // @ts-expect-error - Empty fields cannot contain a filled value. + id: "string", name: "string", kind: "string", url: "string", diff --git a/test/fields-richText.types.ts b/test/fields-richText.types.ts index 4847b97..fb5fa09 100644 --- a/test/fields-richText.types.ts +++ b/test/fields-richText.types.ts @@ -116,6 +116,7 @@ expectType([ { type: prismicT.RichTextNodeType.oListItem, text: "string", spans: [] }, { type: prismicT.RichTextNodeType.image, + id: "string", alt: "string", url: "string", copyright: "string", @@ -123,6 +124,7 @@ expectType([ width: 0, height: 0, }, + edit: { x: 0, y: 0, zoom: 1, background: "background" }, linkTo: { link_type: prismicT.LinkType.Web, url: "string",