Versions in this module Expand all Collapse all v0 v0.4.9 May 27, 2020 v0.4.8 May 27, 2020 v0.4.7 May 27, 2020 Changes in this version + var EmptyContentMatch = NewContentMatch(true) + var EmptyFragment = &Fragment + var EmptySlice = NewSlice(EmptyFragment, 0, 0) + var NoMarks = []*Mark + func SameMarkSet(a, b []*Mark) bool + type Attribute struct + Default interface{} + HasDefault bool + func NewAttribute(options *AttributeSpec) *Attribute + type AttributeSpec struct + Default interface{} + type ContentMatch struct + ValidEnd bool + func NewContentMatch(validEnd bool) *ContentMatch + func ParseContentMatch(str string, nodeTypes []*NodeType) (*ContentMatch, error) + func (cm *ContentMatch) FillBefore(after *Fragment, toEnd ...bool) *Fragment + func (cm *ContentMatch) MatchFragment(frag *Fragment, args ...int) *ContentMatch + func (cm *ContentMatch) MatchType(typ *NodeType) *ContentMatch + type DiffEnd struct + A int + B int + type Fragment struct + Content []*Node + Size int + func FragmentFrom(nodes interface{}) (*Fragment, error) + func FragmentFromArray(array []*Node) *Fragment + func FragmentFromJSON(schema *Schema, value interface{}) (*Fragment, error) + func NewFragment(content []*Node, size ...int) *Fragment + func (f *Fragment) Append(other *Fragment) *Fragment + func (f *Fragment) Child(index int) (*Node, error) + func (f *Fragment) ChildCount() int + func (f *Fragment) Cut(from int, to ...int) *Fragment + func (f *Fragment) Eq(other *Fragment) bool + func (f *Fragment) FindDiffEnd(other *Fragment, pos ...int) *DiffEnd + func (f *Fragment) FindDiffStart(other *Fragment, pos ...int) *int + func (f *Fragment) FirstChild() *Node + func (f *Fragment) ForEach(fn func(node *Node, offset, index int)) + func (f *Fragment) LastChild() *Node + func (f *Fragment) MaybeChild(index int) *Node + func (f *Fragment) NodesBetween(from, to int, fn NBCallback, nodeStart int, parent *Node) *int + func (f *Fragment) ReplaceChild(index int, node *Node) *Fragment + func (f *Fragment) String() string + func (f *Fragment) ToJSON() interface{} + type Mark struct + Attrs map[string]interface{} + Type *MarkType + func MarkFromJSON(schema *Schema, raw map[string]interface{}) (*Mark, error) + func MarkSetFrom(marks ...interface{}) []*Mark + func NewMark(typ *MarkType, attrs map[string]interface{}) *Mark + func (m *Mark) AddToSet(set []*Mark) []*Mark + func (m *Mark) Eq(other *Mark) bool + func (m *Mark) IsInSet(set []*Mark) bool + func (m *Mark) RemoveFromSet(set []*Mark) []*Mark + func (m *Mark) ToJSON() map[string]interface{} + type MarkSpec struct + Attrs map[string]*AttributeSpec + Excludes *string + Group string + Inclusive *bool + Key string + type MarkType struct + Attrs map[string]*Attribute + Excluded []*MarkType + Instance *Mark + Name string + Rank int + Schema *Schema + Spec *MarkSpec + func NewMarkType(name string, rank int, schema *Schema, spec *MarkSpec) *MarkType + func (mt *MarkType) Create(attrs map[string]interface{}) *Mark + func (mt *MarkType) Excludes(other *MarkType) bool + func (mt *MarkType) IsInSet(set []*Mark) *Mark + type NBCallback func(*Node, int, *Node, int) bool + type Node struct + Attrs map[string]interface{} + Content *Fragment + Marks []*Mark + Text *string + Type *NodeType + func NewNode(typ *NodeType, attrs map[string]interface{}, content *Fragment, marks []*Mark) *Node + func NewTextNode(typ *NodeType, attrs map[string]interface{}, text string, marks []*Mark) *Node + func NodeFromJSON(schema *Schema, raw map[string]interface{}) (*Node, error) + func (n *Node) CanReplace(from, to int, args ...interface{}) bool + func (n *Node) Child(index int) (*Node, error) + func (n *Node) ChildCount() int + func (n *Node) ContentMatchAt(index int) (*ContentMatch, error) + func (n *Node) Copy(content ...*Fragment) *Node + func (n *Node) Cut(from int, to ...int) *Node + func (n *Node) Eq(other *Node) bool + func (n *Node) FirstChild() *Node + func (n *Node) ForEach(fn func(node *Node, offset, index int)) + func (n *Node) HasMarkup(typ *NodeType, args ...interface{}) bool + func (n *Node) IsBlock() bool + func (n *Node) IsInline() bool + func (n *Node) IsLeaf() bool + func (n *Node) IsText() bool + func (n *Node) LastChild() *Node + func (n *Node) Mark(marks []*Mark) *Node + func (n *Node) MaybeChild(index int) *Node + func (n *Node) NodeAt(pos int) *Node + func (n *Node) NodeSize() int + func (n *Node) NodesBetween(from, to int, fn NBCallback, startPos ...int) + func (n *Node) Replace(from, to int, slice *Slice) (*Node, error) + func (n *Node) Resolve(pos int) (*ResolvedPos, error) + func (n *Node) SameMarkup(other *Node) bool + func (n *Node) Slice(from int, args ...interface{}) *Slice + func (n *Node) String() string + func (n *Node) TextBetween(from, to int, args ...string) string + func (n *Node) TextContent() string + func (n *Node) ToJSON() map[string]interface{} + func (n *Node) UnitCodeAt(pos int) uint16 + func (n *Node) WithText(text string) *Node + type NodeSpec struct + Attrs map[string]*AttributeSpec + Content string + Group string + Inline bool + Key string + Marks *string + ToDebugString func(*Node) string + type NodeType struct + Attrs map[string]*Attribute + ContentMatch *ContentMatch + DefaultAttrs map[string]interface{} + Groups []string + InlineContent bool + MarkSet *[]*MarkType + Name string + Schema *Schema + Spec *NodeSpec + func NewNodeType(name string, schema *Schema, spec *NodeSpec) *NodeType + func (nt *NodeType) AllowsMarkType(markType *MarkType) bool + func (nt *NodeType) AllowsMarks(marks []*Mark) bool + func (nt *NodeType) Create(attrs map[string]interface{}, content interface{}, marks []*Mark) (*Node, error) + func (nt *NodeType) CreateAndFill(args ...interface{}) (*Node, error) + func (nt *NodeType) CreateChecked(args ...interface{}) (*Node, error) + func (nt *NodeType) HasRequiredAttrs() bool + func (nt *NodeType) IsBlock() bool + func (nt *NodeType) IsInline() bool + func (nt *NodeType) IsLeaf() bool + func (nt *NodeType) IsText() bool + func (nt *NodeType) ValidContent(content *Fragment) bool + type ReplaceError struct + Message string + func NewReplaceError(message string, args ...interface{}) *ReplaceError + func (e *ReplaceError) Error() string + type ResolvedPos struct + Depth int + ParentOffset int + Path []interface{} + Pos int + func NewResolvedPos(pos int, path []interface{}, parentOffset int) *ResolvedPos + func (r *ResolvedPos) After(depth ...int) (int, error) + func (r *ResolvedPos) Before(depth ...int) (int, error) + func (r *ResolvedPos) Doc() *Node + func (r *ResolvedPos) End(depth ...int) int + func (r *ResolvedPos) Index(depth ...int) int + func (r *ResolvedPos) IndexAfter(depth ...int) int + func (r *ResolvedPos) Marks() []*Mark + func (r *ResolvedPos) Node(depth ...int) *Node + func (r *ResolvedPos) NodeAfter() (*Node, error) + func (r *ResolvedPos) NodeBefore() (*Node, error) + func (r *ResolvedPos) Parent() *Node + func (r *ResolvedPos) SharedDepth(pos int) int + func (r *ResolvedPos) Start(depth ...int) int + func (r *ResolvedPos) TextOffset() int + type Schema struct + Marks []*MarkType + Nodes []*NodeType + Spec *SchemaSpec + func NewSchema(spec *SchemaSpec) (*Schema, error) + func (s *Schema) Mark(typ interface{}, args ...map[string]interface{}) *Mark + func (s *Schema) MarkFromJSON(raw []byte) (*Mark, error) + func (s *Schema) MarkType(name string) (*MarkType, error) + func (s *Schema) Node(typ interface{}, args ...interface{}) (*Node, error) + func (s *Schema) NodeFromJSON(raw []byte) (*Node, error) + func (s *Schema) NodeType(name string) (*NodeType, error) + func (s *Schema) Text(text string, marks ...[]*Mark) *Node + type SchemaSpec struct + Marks []*MarkSpec + Nodes []*NodeSpec + TopNode string + func SchemaSpecFromJSON(raw map[string]interface{}) SchemaSpec + func (s *SchemaSpec) UnmarshalJSON(buf []byte) error + func (s SchemaSpec) MarshalJSON() ([]byte, error) + type Slice struct + Content *Fragment + OpenEnd int + OpenStart int + func NewSlice(content *Fragment, openStart, openEnd int) *Slice + func SliceFromJSON(schema *Schema, obj interface{}) (*Slice, error) + func (s *Slice) Eq(other *Slice) bool + func (s *Slice) InsertAt(pos int, fragment *Fragment) *Slice + func (s *Slice) RemoveBetween(from, to int) (*Slice, error) + func (s *Slice) Size() int + func (s *Slice) String() string + func (s *Slice) ToJSON() interface{} v0.4.6-c May 27, 2020 v0.4.6-b May 27, 2020 v0.4.6-a May 27, 2020