diff --git a/decorators.go b/decorators.go index db3f5fa..c187ddf 100644 --- a/decorators.go +++ b/decorators.go @@ -3,31 +3,31 @@ package draftjs import "fmt" type Decorator interface { - RenderBeginning(data map[string]string) string - RenderEnding(data map[string]string) string + RenderBeginning(data map[string]interface{}) string + RenderEnding(data map[string]interface{}) string } type LinkDecorator struct { } -func (decorator *LinkDecorator) RenderBeginning(data map[string]string) string { +func (decorator *LinkDecorator) RenderBeginning(data map[string]interface{}) string { return fmt.Sprintf("", data["url"]) } -func (decorator *LinkDecorator) RenderEnding(data map[string]string) string { +func (decorator *LinkDecorator) RenderEnding(data map[string]interface{}) string { return "" } type ImageDecorator struct { } -func (decorator *ImageDecorator) RenderBeginning(data map[string]string) string { +func (decorator *ImageDecorator) RenderBeginning(data map[string]interface{}) string { if alt, ok := data["alt"]; ok { return fmt.Sprintf("\"%s\"", data["src"], alt) } return fmt.Sprintf("", data["src"]) } -func (decorator *ImageDecorator) RenderEnding(data map[string]string) string { +func (decorator *ImageDecorator) RenderEnding(data map[string]interface{}) string { return "" } diff --git a/types.go b/types.go index bb88b55..a7c4b87 100644 --- a/types.go +++ b/types.go @@ -22,9 +22,9 @@ type ContentBlock struct { // Entity // https://github.com/facebook/draft-js/blob/master/src/model/encoding/RawDraftEntity.js type Entity struct { - Type string `json:"type"` - Mutability string `json:"mutability"` - Data map[string]string `json:"data"` + Type string `json:"type"` + Mutability string `json:"mutability"` + Data map[string]interface{} `json:"data"` } type Range struct {