draftjs

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2017 License: MIT Imports: 7 Imported by: 0

README

draftjs

A draftjs export tool.

Documentation

Index

Constants

View Source
const TAB = "  "

Variables

This section is empty.

Functions

func GetBlockAfter

func GetBlockAfter(block *ContentBlock, config *Config) string

func GetBlockBefore

func GetBlockBefore(block *ContentBlock, config *Config) string

func GetBlockParentAfter

func GetBlockParentAfter(block *ContentBlock, config *Config) string

func GetBlockParentBefore

func GetBlockParentBefore(block *ContentBlock, config *Config) string

func GetBreakPoints

func GetBreakPoints(block *ContentBlock) ([]int, int)

func GetEntityAfter

func GetEntityAfter(entity *Entity, config *Config) string

func GetEntityBefore

func GetEntityBefore(entity *Entity, config *Config) string

func GetStyleAfter

func GetStyleAfter(style *InlineStyleRange, config *Config) string

func GetStyleBefore

func GetStyleBefore(style *InlineStyleRange, config *Config) string

func Render

func Render(contentState *ContentState, config *Config) string

func RenderInlineStylesAndEntities

func RenderInlineStylesAndEntities(content *ContentState, block *ContentBlock, config *Config, buf *bytes.Buffer)

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 BlockOption

type BlockOption struct {
	Before       string
	After        string
	ParentBefore string
	ParentAfter  string
}

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewHTMLConfig

func NewHTMLConfig() *Config

func NewMarkdownConfig

func NewMarkdownConfig() *Config

func NewPlainTextConfig

func NewPlainTextConfig() *Config

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

type Entity

type Entity struct {
	Type       string                 `json:"type"`
	Mutability string                 `json:"mutability"`
	Data       map[string]interface{} `json:"data"`
}

Entity https://github.com/facebook/draft-js/blob/master/src/model/encoding/RawDraftEntity.js

func GetEntity

func GetEntity(contentState *ContentState, entityRange *EntityRange) *Entity

type EntityDecorator

type EntityDecorator interface {
	RenderBefore(data map[string]interface{}) string
	RenderAfter(data map[string]interface{}) string
}

type EntityRange

type EntityRange struct {
	Key int `json:"key"`
	Range
}

EntityRange https://github.com/facebook/draft-js/blob/master/src/model/encoding/EntityRange.js

func GetEntityForRange

func GetEntityForRange(r *Range, block *ContentBlock) []*EntityRange

type InlineStyleRange

type InlineStyleRange struct {
	Style string `json:"style"`
	Range
}

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) RenderAfter

func (d *LinkDecorator) RenderAfter(data map[string]interface{}) string

func (*LinkDecorator) RenderBefore

func (d *LinkDecorator) RenderBefore(data map[string]interface{}) string

type PlainTextLinkDecorator

type PlainTextLinkDecorator struct{}

func (*PlainTextLinkDecorator) RenderAfter

func (d *PlainTextLinkDecorator) RenderAfter(data map[string]interface{}) string

func (*PlainTextLinkDecorator) RenderBefore

func (d *PlainTextLinkDecorator) RenderBefore(data map[string]interface{}) string

type Range

type Range struct {
	Offset int `json:"offset"`
	Length int `json:"length"`
}

func GetRanges

func GetRanges(block *ContentBlock) ([]*Range, bool)

bool == fullstring (no styles)

type WrapperBlockStack

type WrapperBlockStack struct {
	// contains filtered or unexported fields
}

func (*WrapperBlockStack) CurrentBlock

func (s *WrapperBlockStack) CurrentBlock() *ContentBlock

func (*WrapperBlockStack) Pop

func (s *WrapperBlockStack) Pop() *ContentBlock

func (*WrapperBlockStack) Push

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL