Documentation
¶
Overview ¶
templ: version: v0.3.833
Index ¶
- Constants
- Variables
- func EditorJSField(features []string, opts ...func(fields.Field)) fields.Field
- func FeatureNames(f ...BaseFeature) []string
- func JSONMarshalEditorData(d *EditorJSBlockData) ([]byte, error)
- func NewAppConfig() django.AppConfig
- type BaseFeature
- type BlockData
- type BlockTuneFeature
- type EditorJSBlockData
- type EditorJSData
- type EditorJSFormField
- func (e *EditorJSFormField) HasChanged(initial, data interface{}) bool
- func (e *EditorJSFormField) SetWidget(widget widgets.Widget)
- func (e *EditorJSFormField) ValueToForm(value interface{}) interface{}
- func (e *EditorJSFormField) ValueToGo(value interface{}) (interface{}, error)
- func (e *EditorJSFormField) Widget() widgets.Widget
- type EditorJSWidget
- func (b *EditorJSWidget) Component(id, name, value string, errors []error, attrs map[string]string, ...) templ.Component
- func (b *EditorJSWidget) GetContextData(id, name string, value interface{}, attrs map[string]string) ctx.Context
- func (b *EditorJSWidget) Media() media.Media
- func (b *EditorJSWidget) Render(w io.Writer, id, name string, value interface{}, attrs map[string]string) error
- func (b *EditorJSWidget) RenderWithErrors(w io.Writer, id, name string, value interface{}, errors []error, ...) error
- func (b *EditorJSWidget) ValueToForm(value interface{}) interface{}
- func (b *EditorJSWidget) ValueToGo(value interface{}) (interface{}, error)
- type FeatureBlock
- type FeatureBlockRenderer
- type InlineFeature
Constants ¶
const (
ROUTE_PATH = "/__go-editorjs__"
)
Variables ¶
var ( EditorRegistry = newEditorRegistry() ValueToForm = EditorRegistry.ValueToForm ValueToGo = EditorRegistry.ValueToGo Features = EditorRegistry.Features Register = EditorRegistry.Register TuneFeature = EditorRegistry.TuneFeature Tune = EditorRegistry.Tune )
var (
RENDER_ERRORS = true
)
Functions ¶
func FeatureNames ¶ added in v1.6.6
func FeatureNames(f ...BaseFeature) []string
func JSONMarshalEditorData ¶ added in v1.6.6
func JSONMarshalEditorData(d *EditorJSBlockData) ([]byte, error)
func NewAppConfig ¶ added in v1.6.9
Types ¶
type BaseFeature ¶
type BaseFeature interface { // Name returns the name of the feature. Name() string // Config returns the configuration of the feature. Config(widgetContext ctx.Context) map[string]interface{} // OnRegister is called when the feature is registered. // // It is allowed to add custom routes or do other setup here. OnRegister(django.Mux) error // OnValidate is called when the feature is validated. OnValidate(BlockData) error // Constructor returns the JS class name of the feature. Constructor() string // Media return's the feature's static / media files. Media() media.Media }
type BlockTuneFeature ¶
type BlockTuneFeature interface { BaseFeature Tune(FeatureBlock, interface{}) FeatureBlock }
BlockTuneFeature is a feature that can tune a block.
This is used to tune the block after it has been converted from JSON to Go.
The tune method should return a new block, or the same block if no changes were made.
The tune object should wrap the provided block or make changes to it.
type EditorJSBlockData ¶
type EditorJSBlockData struct { Time int64 `json:"time"` Blocks []FeatureBlock `json:"blocks"` Version string `json:"version"` Features []BaseFeature `json:"-"` }
The main datatype to use in structs.
This will automatically assign the appropriate form widget for the field.
It will also allow for simple rendering of the field's data by calling the `Render()` method.
If the struct which the field belongs to defines a `Get<FieldName>Features() []string` method, then these features will be used to build the editorjs widget.
func JSONUnmarshalEditorData ¶ added in v1.6.6
func JSONUnmarshalEditorData(features []string, data []byte) (*EditorJSBlockData, error)
func (*EditorJSBlockData) MustRender ¶ added in v1.7.0
func (e *EditorJSBlockData) MustRender() template.HTML
func (*EditorJSBlockData) Scan ¶ added in v1.7.0
func (e *EditorJSBlockData) Scan(src interface{}) error
func (*EditorJSBlockData) String ¶
func (e *EditorJSBlockData) String() string
type EditorJSData ¶
type EditorJSFormField ¶
type EditorJSFormField struct { *fields.JSONFormField[EditorJSData] Features []string // contains filtered or unexported fields }
func (*EditorJSFormField) HasChanged ¶
func (e *EditorJSFormField) HasChanged(initial, data interface{}) bool
func (*EditorJSFormField) SetWidget ¶
func (e *EditorJSFormField) SetWidget(widget widgets.Widget)
func (*EditorJSFormField) ValueToForm ¶
func (e *EditorJSFormField) ValueToForm(value interface{}) interface{}
func (*EditorJSFormField) ValueToGo ¶
func (e *EditorJSFormField) ValueToGo(value interface{}) (interface{}, error)
func (*EditorJSFormField) Widget ¶
func (e *EditorJSFormField) Widget() widgets.Widget
type EditorJSWidget ¶
type EditorJSWidget struct { widgets.BaseWidget Features []string }
func NewEditorJSWidget ¶
func NewEditorJSWidget(features ...string) *EditorJSWidget
func (*EditorJSWidget) GetContextData ¶
func (*EditorJSWidget) Media ¶
func (b *EditorJSWidget) Media() media.Media
func (*EditorJSWidget) RenderWithErrors ¶
func (*EditorJSWidget) ValueToForm ¶
func (b *EditorJSWidget) ValueToForm(value interface{}) interface{}
func (*EditorJSWidget) ValueToGo ¶
func (b *EditorJSWidget) ValueToGo(value interface{}) (interface{}, error)
type FeatureBlock ¶
type FeatureBlockRenderer ¶
type FeatureBlockRenderer interface { BaseFeature // Render should return a new block object that can be used to render // the HTML. Render(BlockData) FeatureBlock }
FeatureBlockRenderer is a feature that can render a block.
This is used to render the block after it has been converted from JSON to Go.
The render method should return an object based on the provided data. This object will be used to render the HTML.
type InlineFeature ¶
type InlineFeature interface { BaseFeature ParseInlineData(soup *goquery.Document) error }