mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
feat(Notion Node): Add image block (#5237)
This commit is contained in:
parent
a8637a0bc6
commit
36b1e6ef15
|
@ -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'),
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -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) : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue