Documentation
¶
Overview ¶
Package slate provides types for working with Slate.js editor nodes.
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 ElementNode
- type Node
- func FromMap(data map[string]interface{}) *Node
- func MergeElementNodes(one, two *Node) *Node
- func MergeTextNodes(one, two *Node) *Node
- func NewElementNode(children []Node, properties map[string]interface{}) *Node
- func NewTextNode(text string, properties map[string]interface{}) *Node
- func SplitElementNode(node *Node, pos int, props map[string]interface{}) []*Node
- func SplitTextNode(node *Node, pos int, props map[string]interface{}) []*Node
- func (n *Node) GetChildren() []Node
- func (n *Node) GetProperty(key string) interface{}
- func (n *Node) GetText() string
- func (n *Node) IsElement() bool
- func (n *Node) IsText() bool
- func (n *Node) SetChildren(children []Node)
- func (n *Node) SetProperty(key string, value interface{})
- func (n *Node) SetText(text string)
- func (n *Node) ToMap() map[string]interface{}
- type SlateElementNode
- type SlateNode
- type SlateTextNode
- type TextNode
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 ElementNode ¶ added in v0.4.3
type ElementNode = Node
ElementNode is a type alias for better API clarity
type Node ¶ added in v0.4.3
type Node struct {
// Text field is present only for text nodes
Text *string `json:"text,omitempty"`
// Children field is present only for element nodes
Children []Node `json:"children,omitempty"`
// Properties contains additional properties (equivalent to [key: string]: unknown)
Properties map[string]interface{} `json:",inline"`
}
Node 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 (*Node) GetChildren ¶ added in v0.4.3
GetChildren returns the children (empty slice if not an element node)
func (*Node) GetProperty ¶ added in v0.4.3
GetProperty returns a property value
func (*Node) GetText ¶ added in v0.4.3
GetText returns the text content (empty string if not a text node)
func (*Node) SetChildren ¶ added in v0.4.3
SetChildren sets the children and converts to element node
func (*Node) SetProperty ¶ added in v0.4.3
SetProperty sets a property value
type SlateElementNode ¶
type SlateElementNode = ElementNode //nolint:revive // Backward compatibility alias
type SlateTextNode ¶
type SlateTextNode = TextNode //nolint:revive // Backward compatibility alias