Skip to content

Commit

Permalink
Implement set elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kelseymills committed Nov 7, 2024
1 parent e7279fc commit bfa47f0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions block_rich_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ type RichTextElement interface {

type RichTextElementGenericSection interface {
RichTextElement
SectionElements() []RichTextSectionElement
GetElements() []RichTextSectionElement
SetElements([]RichTextSectionElement)
}

const (
Expand Down Expand Up @@ -193,10 +194,14 @@ func (s RichTextSection) RichTextElementType() RichTextElementType {
return s.Type
}

func (s RichTextSection) SectionElements() []RichTextSectionElement {
func (s RichTextSection) GetElements() []RichTextSectionElement {
return s.Elements
}

func (s *RichTextSection) SetElements(elements []RichTextSectionElement) {
s.Elements = elements
}

func (e *RichTextSection) UnmarshalJSON(b []byte) error {
var raw struct {
RawElements []json.RawMessage `json:"elements"`
Expand Down Expand Up @@ -499,10 +504,14 @@ func (s *RichTextQuote) RichTextElementType() RichTextElementType {
return s.Type
}

func (s RichTextQuote) SectionElements() []RichTextSectionElement {
func (s RichTextQuote) GetElements() []RichTextSectionElement {
return s.Elements
}

func (s *RichTextQuote) SetElements(elements []RichTextSectionElement) {
s.Elements = elements
}

func (s *RichTextQuote) UnmarshalJSON(b []byte) error {
// reusing the RichTextSection struct, as it's the same as RichTextQuote.
var rts RichTextSection
Expand Down Expand Up @@ -534,10 +543,14 @@ func (s *RichTextPreformatted) RichTextElementType() RichTextElementType {
return s.Type
}

func (s RichTextPreformatted) SectionElements() []RichTextSectionElement {
func (s RichTextPreformatted) GetElements() []RichTextSectionElement {
return s.Elements
}

func (s *RichTextPreformatted) SetElements(elements []RichTextSectionElement) {
s.Elements = elements
}

func (s *RichTextPreformatted) UnmarshalJSON(b []byte) error {
var rts RichTextSection
if err := json.Unmarshal(b, &rts); err != nil {
Expand Down

0 comments on commit bfa47f0

Please sign in to comment.