diff --git a/packages/nodes-base/nodes/Notion/Blocks.ts b/packages/nodes-base/nodes/Notion/Blocks.ts index c739801193..1947cfa7c2 100644 --- a/packages/nodes-base/nodes/Notion/Blocks.ts +++ b/packages/nodes-base/nodes/Notion/Blocks.ts @@ -471,6 +471,21 @@ const textContent = (displayOptions: IDisplayOptions): INodeProperties[] => [ }, ]; +const imageBlock = (type: string): INodeProperties[] => [ + { + displayName: 'Image URL', + name: 'url', + type: 'string', + displayOptions: { + show: { + type: [type], + }, + }, + default: '', + description: 'Image file reference', + }, +]; + const block = (blockType: string): INodeProperties[] => { const data: INodeProperties[] = []; switch (blockType) { @@ -503,6 +518,9 @@ const block = (blockType: string): INodeProperties[] => { case 'child_page': data.push(...title(blockType)); break; + case 'image': + data.push(...imageBlock(blockType)); + break; default: data.push( ...richText({ @@ -573,6 +591,7 @@ export const blocks = (resource: string, operation: string): INodeProperties[] = ...block('child_page'), ...block('bulleted_list_item'), ...block('numbered_list_item'), + ...block('image'), ], }, ], diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index b1cf56232d..949c540e3b 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -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) : {}), }, }); }