Skip to content

Commit 4db0f8d

Browse files
Merge pull request #286 from nakaiyusaku/add-compat-simple-table-block
2 parents 08c6667 + 1f0ab29 commit 4db0f8d

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

packages/notion-compat/src/convert-block.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,36 @@ export function convertBlock({
317317
break
318318

319319
case 'table':
320-
// TODO
320+
if (blockDetails.table_width && blockDetails.table_width > 0) {
321+
// There is no API to get the column ID. Used the index instead.
322+
compatBlock.format.table_block_column_order = Array.from(
323+
{ length: blockDetails.table_width },
324+
(_, i) => '' + i
325+
)
326+
compatBlock.format.table_block_column_format =
327+
compatBlock.format.table_block_column_order.map((order) => {
328+
return {
329+
[order]: {
330+
// TODO: The SimpleTable column has no width and color. API is not supported.
331+
// width: 155,
332+
// color:
333+
}
334+
}
335+
})
336+
}
337+
if (blockDetails.has_column_header) {
338+
compatBlock.format.table_block_column_header =
339+
blockDetails.has_column_header
340+
}
341+
if (blockDetails.has_row_header) {
342+
compatBlock.format.table_block_row_header = blockDetails.has_row_header
343+
}
321344
break
322345

323346
case 'table_row':
324-
// TODO
347+
compatBlock.properties = {
348+
...block.table_row?.cells?.map((cell) => convertRichText(cell))
349+
}
325350
break
326351

327352
case 'pdf':

0 commit comments

Comments
 (0)