Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultImageHandlerOptions = &ImageHandlerOptions{
StretchClass: "image-tool--stretched",
BorderClass: "image-tool--withBorder",
BackgroundClass: "image-tool--withBackground"}
DefaultImageHandlerOptions are the default options available to the ImageHandler
var ( //ErrBlockHandlerNotFound is returned from GenerateHTML when the HTML engine doesn't have a registered handler //for that type and the HTMLEngine is set to return on errors. ErrBlockHandlerNotFound = errors.New("Handler not found for block type") )
Functions ¶
This section is empty.
Types ¶
type CodeBoxHandler ¶
type CodeBoxHandler struct{}
CodeBoxHandler is the default CodeBoxHandler for EditorJS HTML generation
func (*CodeBoxHandler) GenerateHTML ¶
func (h *CodeBoxHandler) GenerateHTML(editorJSBlock EditorJSBlock) (string, error)
GenerateHTML generates html for CodeBoxBlocks
func (*CodeBoxHandler) GenerateMarkdown ¶
func (h *CodeBoxHandler) GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error)
GenerateMarkdown generates markdown for CodeBoxBlocks
type EditorJSBlock ¶
type EditorJSBlock struct { Type string `json:"type"` // Data is the Data for an editorJS block in the form of RawMessage ([]byte). It is left up to the Handler to parse the Data field Data json.RawMessage `json:"data"` }
EditorJSBlock type
type HTMLBlockHandler ¶
type HTMLBlockHandler interface { Type() string // Type returns the type the block handler supports as a string GenerateHTML(editorJSBlock EditorJSBlock) (string, error) }
HTMLBlockHandler is an interface for a plugable EditorJS HTML generator
type HTMLEngine ¶
type HTMLEngine struct {
BlockHandlers map[string]HTMLBlockHandler
}
HTMLEngine is the engine that creates the HTML from EditorJS blocks
func (*HTMLEngine) GenerateHTML ¶
func (htmlEngine *HTMLEngine) GenerateHTML(editorJSData string) (string, error)
GenerateHTML generates html from the editorJS using configured set of HTML handlers
func (*HTMLEngine) RegisterBlockHandlers ¶
func (htmlEngine *HTMLEngine) RegisterBlockHandlers(handlers ...HTMLBlockHandler)
RegisterBlockHandlers registers or overrides a block handlers for blockType given by HTMLBlockHandler.Type()
type HeaderHandler ¶
type HeaderHandler struct{}
HeaderHandler is the default HeaderHandler for EditorJS HTML generation
func (*HeaderHandler) GenerateHTML ¶
func (h *HeaderHandler) GenerateHTML(editorJSBlock EditorJSBlock) (string, error)
GenerateHTML generates html for HeaderBlocks
func (*HeaderHandler) GenerateMarkdown ¶
func (h *HeaderHandler) GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error)
GenerateMarkdown generates markdown for HeaderBlocks
type ImageHandler ¶
type ImageHandler struct { // Options are made available to the GenerateHTML and GenerateMarkdown functions. // If not provided, DefaultImageHandlerOptions will be used. Options *ImageHandlerOptions }
ImageHandler is the default ImageHandler for EditorJS HTML generation
func (*ImageHandler) GenerateHTML ¶
func (h *ImageHandler) GenerateHTML(editorJSBlock EditorJSBlock) (string, error)
GenerateHTML generates html for ImageBlocks
func (*ImageHandler) GenerateMarkdown ¶
func (h *ImageHandler) GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error)
GenerateMarkdown generates markdown for ImageBlocks
type ImageHandlerOptions ¶
ImageHandlerOptions are the options available to the ImageHandler
type ListHandler ¶
type ListHandler struct{}
ListHandler is the default ListHandler for EditorJS HTML generation
func (*ListHandler) GenerateHTML ¶
func (h *ListHandler) GenerateHTML(editorJSBlock EditorJSBlock) (string, error)
GenerateHTML generates html for ListBlocks
func (*ListHandler) GenerateMarkdown ¶
func (h *ListHandler) GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error)
GenerateMarkdown generates markdown for ListBlocks
type MarkdownBlockHandler ¶
type MarkdownBlockHandler interface { Type() string // Type returns the type the block handler supports as a string GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error) }
MarkdownBlockHandler is an interface for a plugable EditorJS HTML generator
type MarkdownEngine ¶
type MarkdownEngine struct {
BlockHandlers map[string]MarkdownBlockHandler
}
MarkdownEngine is the engine that creates the HTML from EditorJS blocks
func NewMarkdownEngine ¶
func NewMarkdownEngine() *MarkdownEngine
NewMarkdownEngine creates a new MarkdownEngine
func (*MarkdownEngine) GenerateMarkdown ¶
func (markdownEngine *MarkdownEngine) GenerateMarkdown(editorJSData string) (string, error)
GenerateMarkdown generates markdown from the editorJS using configured set of markdown handlers
func (*MarkdownEngine) RegisterBlockHandlers ¶
func (markdownEngine *MarkdownEngine) RegisterBlockHandlers(handlers ...MarkdownBlockHandler)
RegisterBlockHandlers registers or overrides a block handlers for blockType given by MarkdownBlockHandler.Type()
type ParagraphHandler ¶
type ParagraphHandler struct{}
ParagraphHandler is the default ParagraphHandler for EditorJS HTML generation
func (*ParagraphHandler) GenerateHTML ¶
func (h *ParagraphHandler) GenerateHTML(editorJSBlock EditorJSBlock) (string, error)
GenerateHTML generates html for ParagraphBlocks
func (*ParagraphHandler) GenerateMarkdown ¶
func (h *ParagraphHandler) GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error)
GenerateMarkdown generates markdown for ParagraphBlocks
type RawHTMLHandler ¶
type RawHTMLHandler struct{}
RawHTMLHandler is the default raw handler for EditorJS HTML generation
func (*RawHTMLHandler) GenerateHTML ¶
func (h *RawHTMLHandler) GenerateHTML(editorJSBlock EditorJSBlock) (string, error)
GenerateHTML generates html for rawBlocks
func (*RawHTMLHandler) GenerateMarkdown ¶
func (h *RawHTMLHandler) GenerateMarkdown(editorJSBlock EditorJSBlock) (string, error)
GenerateMarkdown generates markdown for rawBlocks