Skip to content

Commit

Permalink
feat: add table block support
Browse files Browse the repository at this point in the history
  • Loading branch information
saltbo authored and jomei committed Jan 26, 2022
1 parent f5e3840 commit 3d7c16f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,27 @@ type Quote struct {
Children Blocks `json:"children,omitempty"`
}

type TableBlock struct {
BasicBlock
Table Table `json:"table"`
}

type Table struct {
TableWidth int `json:"table_width"`
HasColumnHeader bool `json:"has_column_header"`
HasRowHeader bool `json:"has_row_header"`
Children Blocks `json:"children,omitempty"`
}

type TableRowBlock struct {
BasicBlock
TableRow TableRow `json:"table_row"`
}

type TableRow struct {
Cells [][]RichText `json:"cells"`
}

type BulletedListItemBlock struct {
BasicBlock
BulletedListItem ListItem `json:"bulleted_list_item"`
Expand Down Expand Up @@ -582,6 +603,10 @@ func decodeBlock(raw map[string]interface{}) (Block, error) {
b = &TemplateBlock{}
case BlockTypeSyncedBlock:
b = &SyncedBlock{}
case BlockTypeTableBlock:
b = &TableBlock{}
case BlockTypeTableRowBlock:
b = &TableRowBlock{}

case BlockTypeUnsupported:
b = &UnsupportedBlock{}
Expand Down
2 changes: 2 additions & 0 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ const (
BlockTypeLinkToPage BlockType = "link_to_page"
BlockTypeTemplate BlockType = "template"
BlockTypeSyncedBlock BlockType = "synced_block"
BlockTypeTableBlock BlockType = "table"
BlockTypeTableRowBlock BlockType = "table_row"
BlockTypeUnsupported BlockType = "unsupported"
)

Expand Down

0 comments on commit 3d7c16f

Please sign in to comment.