feat(Notion Node): Add image block (#5237)

This commit is contained in:
Ricardo Espinoza
2023-01-31 04:17:45 -05:00
committed by GitHub
parent a8637a0bc6
commit 36b1e6ef15
2 changed files with 35 additions and 3 deletions

View File

@@ -154,6 +154,10 @@ export function getBlockTypes() {
name: 'Numbered List Item',
value: 'numbered_list_item',
},
{
name: 'Image',
value: 'image',
},
];
}
@@ -252,6 +256,15 @@ function getTexts(
return results;
}
function getTextBlocks(block: IDataObject) {
return {
text:
block.richText === false
? formatText(block.textContent as string).text
: getTexts(((block.text as IDataObject).text as any) || []),
};
}
export function formatBlocks(blocks: IDataObject[]) {
const results = [];
for (const block of blocks) {
@@ -260,9 +273,9 @@ export function formatBlocks(blocks: IDataObject[]) {
type: block.type,
[block.type as string]: {
...(block.type === 'to_do' ? { checked: block.checked } : {}),
// prettier-ignore
text: (block.richText === false) ? formatText(block.textContent as string).text : getTexts((block.text as IDataObject).text as any || []),
...(block.type === 'image' ? { type: 'external', external: { url: block.url } } : {}),
// prettier-ignore,
...(!['to_do', 'image'].includes(block.type as string) ? getTextBlocks(block) : {}),
},
});
}