Documentation
¶
Overview ¶
draftjs exporter for go language
Index ¶
- func GetBlockEndTag(block *ContentBlock, config *Config) string
- func GetBlockStartTag(block *ContentBlock, config *Config) string
- func GetBlockTag(block *ContentBlock, config *Config) string
- func GetBlockWrapperEndTag(block *ContentBlock, config *Config) string
- func GetBlockWrapperStartTag(block *ContentBlock, config *Config) string
- func GetBlockWrapperTag(block *ContentBlock, config *Config) string
- func GetBreakPoints(block *ContentBlock) ([]int, int)
- func GetEntityDecorator(content *ContentState, entityRange *EntityRange, config *Config) (Decorator, *Entity)
- func GetEntityEndTag(content *ContentState, entityRange *EntityRange, config *Config) string
- func GetEntityStartTag(content *ContentState, entityRange *EntityRange, config *Config) string
- func GetStyleEndTag(style *InlineStyleRange, config *Config) string
- func GetStyleStartTag(style *InlineStyleRange, config *Config) string
- func GetStylemapElement(style *InlineStyleRange, config *Config) string
- func PerformInlineStylesAndEntities(content *ContentState, block *ContentBlock, config *Config, buf *bytes.Buffer)
- func Render(contentState *ContentState, config *Config) string
- func RenderWithBuf(contentState *ContentState, config *Config, buf *bytes.Buffer)
- func SetDefaultBlocks(config *Config)
- func SetDefaultDecorators(config *Config)
- func SetDefaultStyles(config *Config)
- type BlockIterator
- type Cache
- type CacheElement
- type Config
- func (config *Config) GetBlockMapElement(descriptorType string) *Descriptor
- func (config *Config) GetEntityDecorator(descriptorType string) *Descriptor
- func (config *Config) GetFromCache(key1, key2 string) (string, bool)
- func (config *Config) GetStyleMapElement(descriptorType string) *Descriptor
- func (config *Config) Precache()
- func (config *Config) PrecacheBlocks()
- func (config *Config) PrecacheStyles()
- func (config *Config) SetBlockMapElement(descriptor *Descriptor)
- func (config *Config) SetEntityDecorator(descriptor *Descriptor)
- func (config *Config) SetStyleMapElement(descriptor *Descriptor)
- func (config *Config) SetToCache(key1, key2, value string)
- type ContentBlock
- type ContentState
- type Decorator
- type Descriptor
- type Entity
- type EntityRange
- type ImageDecorator
- type InlineStyleRange
- type LinkDecorator
- type Range
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBlockEndTag ¶ added in v1.0.1
func GetBlockEndTag(block *ContentBlock, config *Config) string
func GetBlockStartTag ¶ added in v1.0.1
func GetBlockStartTag(block *ContentBlock, config *Config) string
func GetBlockTag ¶ added in v1.0.1
func GetBlockTag(block *ContentBlock, config *Config) string
func GetBlockWrapperEndTag ¶ added in v1.0.1
func GetBlockWrapperEndTag(block *ContentBlock, config *Config) string
func GetBlockWrapperStartTag ¶ added in v1.0.1
func GetBlockWrapperStartTag(block *ContentBlock, config *Config) string
func GetBlockWrapperTag ¶ added in v1.0.1
func GetBlockWrapperTag(block *ContentBlock, config *Config) string
func GetBreakPoints ¶
func GetBreakPoints(block *ContentBlock) ([]int, int)
func GetEntityDecorator ¶ added in v1.0.1
func GetEntityDecorator(content *ContentState, entityRange *EntityRange, config *Config) (Decorator, *Entity)
func GetEntityEndTag ¶ added in v1.0.1
func GetEntityEndTag(content *ContentState, entityRange *EntityRange, config *Config) string
func GetEntityStartTag ¶ added in v1.0.1
func GetEntityStartTag(content *ContentState, entityRange *EntityRange, config *Config) string
func GetStyleEndTag ¶ added in v1.0.1
func GetStyleEndTag(style *InlineStyleRange, config *Config) string
func GetStyleStartTag ¶ added in v1.0.1
func GetStyleStartTag(style *InlineStyleRange, config *Config) string
func GetStylemapElement ¶ added in v1.0.1
func GetStylemapElement(style *InlineStyleRange, config *Config) string
func PerformInlineStylesAndEntities ¶ added in v1.0.1
func PerformInlineStylesAndEntities(content *ContentState, block *ContentBlock, config *Config, buf *bytes.Buffer)
func Render ¶
func Render(contentState *ContentState, config *Config) string
Render renders Draft.js content state to string with config
func RenderWithBuf ¶ added in v1.0.1
func RenderWithBuf(contentState *ContentState, config *Config, buf *bytes.Buffer)
RenderWithBuf renders Draft.js content state to buffer with config
func SetDefaultBlocks ¶ added in v1.0.1
func SetDefaultBlocks(config *Config)
func SetDefaultDecorators ¶ added in v1.0.1
func SetDefaultDecorators(config *Config)
func SetDefaultStyles ¶ added in v1.0.1
func SetDefaultStyles(config *Config)
Types ¶
type BlockIterator ¶
type BlockIterator struct {
// contains filtered or unexported fields
}
func NewBlockIterator ¶
func NewBlockIterator(contentState *ContentState) *BlockIterator
func (*BlockIterator) HasNext ¶
func (bi *BlockIterator) HasNext() bool
func (BlockIterator) NextBlock ¶
func (bi BlockIterator) NextBlock() *ContentBlock
func (*BlockIterator) StepNext ¶
func (bi *BlockIterator) StepNext() *BlockIterator
type Cache ¶ added in v1.0.1
type Cache map[string]CacheElement
type CacheElement ¶ added in v1.0.1
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func NewDefaultConfig ¶ added in v1.0.1
func NewDefaultConfig() *Config
NewDefaultConfig Makes new config and fills it with default HTML elements
func (*Config) GetBlockMapElement ¶ added in v1.0.1
func (config *Config) GetBlockMapElement(descriptorType string) *Descriptor
func (*Config) GetEntityDecorator ¶ added in v1.0.1
func (config *Config) GetEntityDecorator(descriptorType string) *Descriptor
func (*Config) GetFromCache ¶ added in v1.0.1
func (*Config) GetStyleMapElement ¶ added in v1.0.1
func (config *Config) GetStyleMapElement(descriptorType string) *Descriptor
func (*Config) PrecacheBlocks ¶ added in v1.0.1
func (config *Config) PrecacheBlocks()
func (*Config) PrecacheStyles ¶ added in v1.0.1
func (config *Config) PrecacheStyles()
func (*Config) SetBlockMapElement ¶ added in v1.0.1
func (config *Config) SetBlockMapElement(descriptor *Descriptor)
func (*Config) SetEntityDecorator ¶ added in v1.0.1
func (config *Config) SetEntityDecorator(descriptor *Descriptor)
func (*Config) SetStyleMapElement ¶ added in v1.0.1
func (config *Config) SetStyleMapElement(descriptor *Descriptor)
func (*Config) SetToCache ¶ added in v1.0.1
type ContentBlock ¶
type ContentBlock struct { Key string `json:"key"` Type string `json:"type"` Text string `json:"text"` Depth int `json:"depth"` InlineStyleRanges []*InlineStyleRange `json:"inlineStyleRanges"` EntityRanges []*EntityRange `json:"entityRanges"` Data interface{} `json:"data"` }
ContentBlock https://github.com/facebook/draft-js/blob/master/src/model/encoding/RawDraftContentBlock.js
type ContentState ¶
type ContentState struct { Blocks []*ContentBlock `json:"blocks"` EntityMap map[string]*Entity `json:"entityMap"` }
ContentState https://github.com/facebook/draft-js/blob/master/src/model/encoding/RawDraftContentState.js
func (*ContentState) String ¶ added in v1.0.1
func (contentState *ContentState) String() string
Interface implementation
type Descriptor ¶ added in v1.0.1
func GetDescriptorFromMap ¶ added in v1.0.1
func GetDescriptorFromMap(key string, sourceMap map[string]*Descriptor) *Descriptor
type Entity ¶
type Entity struct { Type string `json:"type"` Mutability string `json:"mutability"` Data map[string]string `json:"data"` }
Entity https://github.com/facebook/draft-js/blob/master/src/model/encoding/RawDraftEntity.js
type EntityRange ¶
EntityRange https://github.com/facebook/draft-js/blob/master/src/model/encoding/EntityRange.js
func GetEntityForRange ¶
func GetEntityForRange(r *Range, block *ContentBlock) []*EntityRange
type ImageDecorator ¶ added in v1.0.1
type ImageDecorator struct { }
func (*ImageDecorator) RenderBeginning ¶ added in v1.0.1
func (decorator *ImageDecorator) RenderBeginning(data map[string]string) string
func (*ImageDecorator) RenderEnding ¶ added in v1.0.1
func (decorator *ImageDecorator) RenderEnding(data map[string]string) string
type InlineStyleRange ¶
InlineStyleRange https://github.com/facebook/draft-js/blob/master/src/model/encoding/InlineStyleRange.js
func GetStyleForRange ¶
func GetStyleForRange(r *Range, block *ContentBlock) []*InlineStyleRange
type LinkDecorator ¶
type LinkDecorator struct { }
func (*LinkDecorator) RenderBeginning ¶ added in v1.0.1
func (decorator *LinkDecorator) RenderBeginning(data map[string]string) string
func (*LinkDecorator) RenderEnding ¶ added in v1.0.1
func (decorator *LinkDecorator) RenderEnding(data map[string]string) string