Skip to content

Commit

Permalink
Add support for Indent field
Browse files Browse the repository at this point in the history
Co-authored-by: SimonLiuRoblox <84740141+SimonLiuRoblox@users.noreply.github.com>
  • Loading branch information
daniel-pieper-personio and SimonLiuRoblox committed Nov 14, 2023
1 parent fd060b6 commit 0f23d87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion block_rich_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@ type RichTextList struct {
Type RichTextElementType `json:"type"`
Elements []RichTextElement `json:"elements"`
Style RichTextListElementType `json:"style"`
Indent int `json:"indent"`
}

// NewRichTextList returns a new rich text list element.
func NewRichTextList(style RichTextListElementType, elements ...RichTextElement) *RichTextList {
func NewRichTextList(style RichTextListElementType, indent int, elements ...RichTextElement) *RichTextList {
return &RichTextList{
Type: RTEList,
Elements: elements,
Style: style,
Indent: indent,
}
}

Expand All @@ -126,6 +128,7 @@ func (e *RichTextList) UnmarshalJSON(b []byte) error {
var raw struct {
RawElements []json.RawMessage `json:"elements"`
Style RichTextListElementType `json:"style"`
Indent int `json:"indent"`
}
if string(b) == "{}" {
return nil
Expand Down Expand Up @@ -163,6 +166,7 @@ func (e *RichTextList) UnmarshalJSON(b []byte) error {
Type: RTEList,
Elements: elems,
Style: raw.Style,
Indent: raw.Indent,
}
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions block_rich_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ func TestRichTextList_UnmarshalJSON(t *testing.T) {
},
nil,
},
{
[]byte(`{"type": "rich_text_list","elements":[],"indent":2}`),
RichTextList{
Type: RTEList,
Indent: 2,

Check failure on line 179 in block_rich_text_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed (goimports)
Elements: []RichTextElement{},
},
nil,
},
}
for _, tc := range cases {
var actual RichTextList
Expand Down

0 comments on commit 0f23d87

Please sign in to comment.