Documentation
¶
Index ¶
- Constants
- func ApplyAlignmentParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyAnimationParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyBackgroundParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyBorderParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyDisplayParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyFlexBoxParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyFontParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyHTMLParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyMarginParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyPaddingParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyPositionParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplySizeParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyTextParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func ApplyTransitionParameters(block ui.BlockInterface, blockTag *hb.Tag)
- func FieldGroupEnd() form.FieldInterface
- func FieldGroupStart(groupId, groupName string, collapsed bool) form.FieldInterface
- func FieldsAlign() []form.FieldInterface
- func FieldsAnimation() []form.FieldInterface
- func FieldsBackground() []form.FieldInterface
- func FieldsBorder() []form.FieldInterface
- func FieldsDisplay() []form.FieldInterface
- func FieldsFlexBox() []form.FieldInterface
- func FieldsFont() []form.FieldInterface
- func FieldsHTML() []form.FieldInterface
- func FieldsMargin() []form.FieldInterface
- func FieldsPadding() []form.FieldInterface
- func FieldsPositioning() []form.FieldInterface
- func FieldsSize() []form.FieldInterface
- func FieldsText() []form.FieldInterface
- func FieldsTransition() []*form.Field
- func Handle(w http.ResponseWriter, r *http.Request, blockDefinitions []BlockDefinition) string
- func NewEditor(options NewEditorOptions) (*editor, error)
- type BlockDefinition
- type FlatBlock
- type FlatTree
- func (tree *FlatTree) Add(parentID string, flatBlock FlatBlock)
- func (tree *FlatTree) AddBlock(parentID string, block ui.BlockInterface)
- func (tree *FlatTree) Children(parentID string) []FlatBlock
- func (tree *FlatTree) Clone(flatBlock FlatBlock) FlatBlock
- func (tree *FlatTree) Duplicate(blockID string)
- func (tree *FlatTree) Exists(flatBlockID string) bool
- func (tree *FlatTree) Find(flatBlockID string) *FlatBlock
- func (tree *FlatTree) FindNextSibling(flatBlockID string) *FlatBlock
- func (tree *FlatTree) FindPreviousSibling(flatBlockID string) *FlatBlock
- func (tree *FlatTree) List() []FlatBlock
- func (tree *FlatTree) MoveDown(flatBlockID string)
- func (tree *FlatTree) MoveToParent(flatBlockID, parentID string)
- func (tree *FlatTree) MoveToPosition(flatBlockID, parentID string, position int)
- func (tree *FlatTree) MoveUp(flatBlockID string)
- func (tree *FlatTree) Parent(flatBlockID string) *FlatBlock
- func (tree *FlatTree) RecalculateSequences(blockID string)
- func (tree *FlatTree) Remove(flatBlockID string)
- func (tree *FlatTree) RemoveOrphans()
- func (tree *FlatTree) ToBlocks() []ui.BlockInterface
- func (tree *FlatTree) Traverse(blockID string) []FlatBlock
- func (tree *FlatTree) Update(flatBlock FlatBlock)
- type NewEditorOptions
Constants ¶
const ACTION = "blockeditor_action"
const ACTION_BLOCKS_SAVE = "blocks_save"
const ACTION_BLOCK_ADD = "block_add"
const ACTION_BLOCK_ADD_MODAL = "block_add_modal"
const ACTION_BLOCK_DELETE = "block_delete"
const ACTION_BLOCK_DUPLICATE = "block_duplicate"
const ACTION_BLOCK_MOVE_DOWN = "block_move_down"
const ACTION_BLOCK_MOVE_INTO = "block_move_into"
const ACTION_BLOCK_MOVE_OUT = "block_move_out"
const ACTION_BLOCK_MOVE_UP = "block_move_up"
const ACTION_BLOCK_SETTINGS = "block_settings"
const ACTION_BLOCK_SETTINGS_UPDATE = "block_settings_update"
const BLOCK_ID = "block_id"
const BLOCK_TYPE = "block_type"
const EDITOR_HANDLER_ENDPOINT = "editor_handler_endpoint"
const EDITOR_ID = "editor_id"
const EDITOR_NAME = "editor_name"
const SETTINGS_PREFIX = "blockeditor_settings_"
Variables ¶
This section is empty.
Functions ¶
func ApplyAlignmentParameters ¶
func ApplyAlignmentParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyAnimationParameters ¶
func ApplyAnimationParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyBackgroundParameters ¶
func ApplyBackgroundParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyBorderParameters ¶
func ApplyBorderParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyDisplayParameters ¶
func ApplyDisplayParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyFlexBoxParameters ¶
func ApplyFlexBoxParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyFontParameters ¶
func ApplyFontParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyHTMLParameters ¶
func ApplyHTMLParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyMarginParameters ¶
func ApplyMarginParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyPaddingParameters ¶
func ApplyPaddingParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyPositionParameters ¶
func ApplyPositionParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplySizeParameters ¶
func ApplySizeParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyTextParameters ¶
func ApplyTextParameters(block ui.BlockInterface, blockTag *hb.Tag)
func ApplyTransitionParameters ¶
func ApplyTransitionParameters(block ui.BlockInterface, blockTag *hb.Tag)
func FieldGroupEnd ¶
func FieldGroupEnd() form.FieldInterface
func FieldGroupStart ¶
func FieldGroupStart(groupId, groupName string, collapsed bool) form.FieldInterface
func FieldsAlign ¶
func FieldsAlign() []form.FieldInterface
FieldsAlign is a predefined set of alignment fields - Text Align (text_align) - Vertical Align (vertical_align)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsAnimation ¶
func FieldsAnimation() []form.FieldInterface
FieldsAnimation is a predefined set of animation fields
func FieldsBackground ¶
func FieldsBackground() []form.FieldInterface
FieldsBackground is a predefined set of background fields - Background Color (background_color) - Background Image URL (background_image_url) - Background Attachment (background_attachment) - Background Position (background_position) - Background Repeat (background_repeat) - Background Size (background_size)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsBorder ¶
func FieldsBorder() []form.FieldInterface
FieldsBorder is a predefined set of border fields - Border (border)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsDisplay ¶
func FieldsDisplay() []form.FieldInterface
FieldsDisplay is a predefined set of display fields - Display (display) - Visibility (visibility)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsFlexBox ¶
func FieldsFlexBox() []form.FieldInterface
func FieldsFont ¶
func FieldsFont() []form.FieldInterface
FieldsFont is a predefined set of font fields - Font Family (font_family) - Font Size (font_size) - Font Weight (font_weight) - Font Style (font_style)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsHTML ¶
func FieldsHTML() []form.FieldInterface
FieldsHTML is a predefined set of fields common to all HTML elements - HTML ID (html_id) - HTML Class (html_class) - HTML Style (html_style)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsMargin ¶
func FieldsMargin() []form.FieldInterface
FieldsMargin is a predefined set of margin fields - Margin Top (margin_top) - Margin Bottom (margin_bottom) - Margin Left (margin_left) - Margin Right (margin_right)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsPadding ¶
func FieldsPadding() []form.FieldInterface
FieldsPadding is a predefined set of padding fields - Padding Top (padding_top) - Padding Bottom (padding_bottom) - Padding Left (padding_left) - Padding Right (padding_right)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsPositioning ¶
func FieldsPositioning() []form.FieldInterface
FieldsPositioning is a predefined set of positioning fields - Position (position) - Top (top) - Right (right) - Bottom (bottom) - Left (left) - Z-Index (zindex)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsSize ¶
func FieldsSize() []form.FieldInterface
FieldsSize is a predefined set of size fields - Width (width) - Height (height)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsText ¶
func FieldsText() []form.FieldInterface
FieldsText is a predefined set of text fields - Text Color (text_color) - Line Height (line_height)
Parameters: - none
Returns: - []form.Field - The fields
func FieldsTransition ¶
func Handle ¶
func Handle(w http.ResponseWriter, r *http.Request, blockDefinitions []BlockDefinition) string
Handle handles the block editor
Business logic: - gets the action from the request - gets the editor id, name, content, and handler endpoint from the request - creates a new editor - if an action is provided, executes the action - if no action is provided, renders the editor
Parameters: - w: the http.ResponseWriter - r: the http.Request - blockDefinitions: the block definitions
Returns: - the response string
func NewEditor ¶
func NewEditor(options NewEditorOptions) (*editor, error)
Types ¶
type BlockDefinition ¶
type BlockDefinition struct {
// Icon is the icon of the block
Icon hb.TagInterface
// Type is the type of the block
Type string
// Fields are the fields for the paameters of the block which can be edited
Fields []form.FieldInterface
// AllowChildren determines if the block can have children
AllowChildren bool
// AllowedChildTypes is a list of block types that can be added as children
AllowedChildTypes []string
// Wrapper is a function that wraps the block's card in a custom tag
// suitable for a column that need to apply its width so that the
// card is displayed with the correct width
Wrapper func(block ui.BlockInterface) *hb.Tag
// ToTag is a function that converts a block to a tag to be displayed
// in the block's card body in the editor
ToTag func(block ui.BlockInterface) *hb.Tag
}
type FlatTree ¶
type FlatTree struct {
// contains filtered or unexported fields
}
func NewFlatTree ¶
func NewFlatTree(blocks []ui.BlockInterface) *FlatTree
func (*FlatTree) AddBlock ¶
func (tree *FlatTree) AddBlock(parentID string, block ui.BlockInterface)
AddBlock adds a new ui.BlockInterface to the FlatTree
func (*FlatTree) Clone ¶
Clone creates a shallow clone of a FlatBlock (no children)
This is used to create a clone of a FlatBlock, so that the original FlatBlock is not modified, but we can modify the clone safely
Remember to update the ID, Sequence, and ParentID of the copy with new values
func (*FlatTree) Duplicate ¶
Duplicate creates a deep clone of a FlatBlock (with children) and adds it to the tree, under the same parent
Business Logic: - travserses the tree to find all blocks to be duplicated - makes a map with current IDs as keys, newly generated IDs as values - clones each block, and replaces the ID with the new ID - assignes the correct mapped IDs and ParentIDs - adds the cloned blocks to the tree directly (using list) - moves the duplicated block under the block being duplicated
func (*FlatTree) FindNextSibling ¶
func (*FlatTree) FindPreviousSibling ¶
func (*FlatTree) MoveToParent ¶
func (*FlatTree) MoveToPosition ¶
func (*FlatTree) RecalculateSequences ¶
func (*FlatTree) Remove ¶
Remove removes the block with the given id
Buisiness Logic: - checks if the block exists, if not, do nothing - removes the block from the list - recalculates the sequences of the parent's children
func (*FlatTree) RemoveOrphans ¶
func (tree *FlatTree) RemoveOrphans()
RemoveOrphans removes all orphaned blocks that have no parent
Buisiness Logic: - finds and creates a new list without orphaned blocks - non orphaned blocks are the ones that have a parent or root blocks - updates the list with the new list
Parameters: - none
Returns: - none
func (*FlatTree) ToBlocks ¶
func (tree *FlatTree) ToBlocks() []ui.BlockInterface
type NewEditorOptions ¶
type NewEditorOptions struct {
ID string
Name string
Value string
HandleEndpoint string
BlockDefinitions []BlockDefinition
}
Source Files
¶
- BlockDefinition.go
- FlatTree.go
- Handle.go
- NewEditor.go
- PredefinedFields.go
- blockAdd.go
- blockAddModal.go
- blockDelete.go
- blockDivider.go
- blockDuplicate.go
- blockMoveDown.go
- blockMoveInto.go
- blockMoveOut.go
- blockMoveUp.go
- blockSettingsModal.go
- blockSettingsUpdate.go
- blockToCard.go
- blocksToCards.go
- buttonBlockInsert.go
- cardButtonDelete.go
- cardButtonDropdown.go
- cardButtonMoveDown.go
- cardButtonMoveUp.go
- cardButtonSettings.go
- consts.go
- editor.go
- findBlockByID.go
- findDefinitionByBlockID.go
- findDefinitionByBlockType.go
- funcs.go
- query.go