Documentation
¶
Index ¶
- func IsElementNode(value interface{}) bool
- func IsTextNode(value interface{}) bool
- func MergeElementNodesFromMaps(one, two map[string]interface{}) map[string]interface{}
- func MergeTextNodesFromMaps(one, two map[string]interface{}) map[string]interface{}
- func SplitElementNodeFromMap(nodeMap map[string]interface{}, pos int, props map[string]interface{}) []map[string]interface{}
- func SplitTextNodeFromMap(nodeMap map[string]interface{}, pos int, props map[string]interface{}) []map[string]interface{}
- type SlateElementNode
- type SlateNode
- func FromMap(data map[string]interface{}) *SlateNode
- func MergeElementNodes(one, two *SlateNode) *SlateNode
- func MergeTextNodes(one, two *SlateNode) *SlateNode
- func NewElementNode(children []SlateNode, properties map[string]interface{}) *SlateNode
- func NewTextNode(text string, properties map[string]interface{}) *SlateNode
- func SplitElementNode(node *SlateNode, pos int, props map[string]interface{}) []*SlateNode
- func SplitTextNode(node *SlateNode, pos int, props map[string]interface{}) []*SlateNode
- func (n *SlateNode) GetChildren() []SlateNode
- func (n *SlateNode) GetProperty(key string) interface{}
- func (n *SlateNode) GetText() string
- func (n *SlateNode) IsElement() bool
- func (n *SlateNode) IsText() bool
- func (n *SlateNode) SetChildren(children []SlateNode)
- func (n *SlateNode) SetProperty(key string, value interface{})
- func (n *SlateNode) SetText(text string)
- func (n *SlateNode) ToMap() map[string]interface{}
- type SlateTextNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsElementNode ¶
func IsElementNode(value interface{}) bool
IsElementNode checks if a value is a Slate.js element node
func IsTextNode ¶
func IsTextNode(value interface{}) bool
IsTextNode checks if a value is a Slate.js text node
func MergeElementNodesFromMaps ¶
MergeElementNodesFromMaps merges two Slate element nodes from maps (backward compatibility)
func MergeTextNodesFromMaps ¶
MergeTextNodesFromMaps merges two Slate text nodes from maps (backward compatibility)
Types ¶
type SlateElementNode ¶
type SlateElementNode = SlateNode
SlateElementNode is a type alias for better API clarity
type SlateNode ¶
type SlateNode struct {
// Text field is present only for text nodes
Text *string `json:"text,omitempty"`
// Children field is present only for element nodes
Children []SlateNode `json:"children,omitempty"`
// Properties contains additional properties (equivalent to [key: string]: unknown)
Properties map[string]interface{} `json:",inline"`
}
SlateNode represents a Slate.js node that can be either a text node or an element node. It uses a union-type approach similar to TypeScript's SlateNode.
func MergeElementNodes ¶
MergeElementNodes merges two Slate element nodes by concatenating their children and merging properties
func MergeTextNodes ¶
MergeTextNodes merges two Slate text nodes by concatenating their text and merging properties
func NewElementNode ¶
NewElementNode creates a new Slate element node
func NewTextNode ¶
NewTextNode creates a new Slate text node
func SplitElementNode ¶
SplitElementNode splits a Slate element node at the specified position in its children
func SplitTextNode ¶
SplitTextNode splits a Slate text node at the specified position
func (*SlateNode) GetChildren ¶
GetChildren returns the children (empty slice if not an element node)
func (*SlateNode) GetProperty ¶
GetProperty returns a property value
func (*SlateNode) SetChildren ¶
SetChildren sets the children and converts to element node
func (*SlateNode) SetProperty ¶
SetProperty sets a property value
type SlateTextNode ¶
type SlateTextNode = SlateNode
SlateTextNode is a type alias for better API clarity