From 200df93c3d7e73ae0817641e07de4465e65505b8 Mon Sep 17 00:00:00 2001 From: Your name here Date: Tue, 20 Aug 2024 17:34:43 +0100 Subject: [PATCH 1/2] feat: use alt property for image blocks --- src/components/asset.tsx | 3 ++- src/types.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/asset.tsx b/src/components/asset.tsx index c03cac8..f91bef5 100644 --- a/src/components/asset.tsx +++ b/src/components/asset.tsx @@ -45,6 +45,7 @@ const Asset: React.FC<{ if (block.value.type === "image") { const src = mapImageUrl(value.properties.source[0][0], block); const caption = value.properties.caption?.[0][0]; + const altText = value.properties.alt_text?.[0][0]; if (block_aspect_ratio) { return ( @@ -56,7 +57,7 @@ const Asset: React.FC<{ > {caption diff --git a/src/types.ts b/src/types.ts index 7cf1d66..d721ea5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -197,6 +197,7 @@ export interface ContentValueType extends BaseValueType { properties: { source: string[][]; caption?: DecorationType[]; + alt_text?: string[][]; }; format?: { block_width: number; From 6099de611e22956cd77ca80576104d10493b1454 Mon Sep 17 00:00:00 2001 From: Kha Leo Date: Mon, 28 Oct 2024 14:19:10 +0700 Subject: [PATCH 2/2] fix: handle nonexistent field: value --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index b852d28..bd822d6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,7 +14,7 @@ const groupBlockContent = (blockMap: BlockMapType): string[][] => { let index = -1; Object.keys(blockMap).forEach(id => { - blockMap[id].value.content?.forEach(blockId => { + blockMap[id].value?.content?.forEach(blockId => { const blockType = blockMap[blockId]?.value?.type; if (blockType && blockType !== lastType) {