import { Block } from '../Block' type ImageContentType = { caption: any[], type: string, [key:string]: any } function hasUrlType(arg:any): arg is { url: string} { return arg['url'] } export class Image extends Block { static tagName:string = 'img' toHTML(): string { const imageContent:ImageContentType = this.content as ImageContentType const type = imageContent.type const imageContentData = imageContent[type] let attachmentUrl = '#' if (hasUrlType(imageContentData)) { attachmentUrl = imageContentData.url || '#' } const classTag = ['notion', 'image'] return `<${Image.tagName} class="${classTag.join(' ')}" id="${this.id}" src="${attachmentUrl}" target="_blank">` } }