From 8e676e0df83280c1532ee00088ce2a597a30704d Mon Sep 17 00:00:00 2001 From: David Stotijn Date: Fri, 17 Dec 2021 13:14:55 +0100 Subject: [PATCH] Add support for `link_preview` block type and rich text mentions --- block.go | 2 ++ rich_text.go | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/block.go b/block.go index 0f3971e..cf2f61c 100644 --- a/block.go +++ b/block.go @@ -40,6 +40,7 @@ type Block struct { Breadcrumb *Breadcrumb `json:"breadcrumb,omitempty"` ColumnList *ColumnList `json:"column_list,omitempty"` Column *Column `json:"column,omitempty"` + LinkPreview *LinkPreview `json:"link_preview,omitempty"` } type RichTextBlock struct { @@ -149,6 +150,7 @@ const ( BlockTypeBreadCrumb BlockType = "breadcrumb" BlockTypeColumnList BlockType = "column_list" BlockTypeColumn BlockType = "column" + BlockTypeLinkPreview BlockType = "link_preview" BlockTypeUnsupported BlockType = "unsupported" ) diff --git a/rich_text.go b/rich_text.go index 634de8c..1422303 100644 --- a/rich_text.go +++ b/rich_text.go @@ -27,10 +27,11 @@ type Annotations struct { type Mention struct { Type MentionType `json:"type"` - User *User `json:"user,omitempty"` - Page *ID `json:"page,omitempty"` - Database *ID `json:"database,omitempty"` - Date *Date `json:"date,omitempty"` + User *User `json:"user,omitempty"` + Page *ID `json:"page,omitempty"` + Database *ID `json:"database,omitempty"` + Date *Date `json:"date,omitempty"` + LinkPreview *LinkPreview `json:"link_preview,omitempty"` } type Date struct { @@ -38,6 +39,10 @@ type Date struct { End *DateTime `json:"end,omitempty"` } +type LinkPreview struct { + URL string `json:"url"` +} + type Text struct { Content string `json:"content"` Link *Link `json:"link,omitempty"` @@ -64,10 +69,11 @@ const ( ) const ( - MentionTypeUser MentionType = "user" - MentionTypePage MentionType = "page" - MentionTypeDatabase MentionType = "database" - MentionTypeDate MentionType = "date" + MentionTypeUser MentionType = "user" + MentionTypePage MentionType = "page" + MentionTypeDatabase MentionType = "database" + MentionTypeDate MentionType = "date" + MentionTypeLinkPreview MentionType = "link_preview" ) const (