diff --git a/package.json b/package.json index 829ffa5..8c88aaa 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,6 @@ "prettier": "3.2.5", "ts-node": "10.9.2", "ts-unused-exports": "10.0.1", - "typescript": "5.3.3" + "typescript": "5.4.2" } } diff --git a/src/constants.ts b/src/constants.ts index 1e4c11e..48d633a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,6 @@ import type { CueBlock, + Image, LineBlock, SectionBlock, SpacerBlock, @@ -152,6 +153,16 @@ export interface RichTextLinebreakNode extends RichTextNode { type: "linebreak"; } +export interface RichTextUploadNode extends RichTextNode { + type: "upload"; + relationTo: string; +} + +export interface RichTextUploadImageNode extends RichTextUploadNode { + relationTo: "images" | "background-images"; + value: Image; +} + export interface RichTextTextNode extends RichTextNode { type: "text"; format: number; @@ -211,6 +222,12 @@ export interface RichTextSpacerBlock extends RichTextBlockNode { export const isNodeParagraphNode = (node: RichTextNode): node is RichTextParagraphNode => node.type === "paragraph"; +export const isNodeUploadNode = (node: RichTextNode): node is RichTextUploadNode => + node.type === "upload"; + +export const isUploadNodeImageNode = (node: RichTextUploadNode): node is RichTextUploadImageNode => + node.relationTo === "images" || node.relationTo === "background-images"; + export const isNodeListNode = (node: RichTextNode): node is RichTextListNode => node.type === "list";