import { Block } from '../Block' type TableContentType = { table_width: number, has_column_header: boolean, has_row_header: boolean } export class Table extends Block { static tagName:string = 'table' toHTML(): string { const tableContent:TableContentType = this.content as TableContentType const tableWidth = tableContent.table_width || 'all' const hasTableColumnHeader = tableContent.has_column_header const hasTableRowHeader = tableContent.has_row_header const classTag = ['notion', 'table', `table_width_${tableWidth}`] if (hasTableColumnHeader) { classTag.push('has_table_column_header') } if (hasTableRowHeader) { classTag.push('has_table_row_header') } const childrenContext = this.children.map(childrenItem => { return childrenItem.toHTML() }).join('') return `<${Table.tagName} class="${classTag.join(' ')}">${childrenContext}` } }