JsonTree

JsonTree is a CRDT-based tree structure that is used to represent the document tree of text-based editor such as ProseMirror.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class ElementNode(val type: String, val attributes: Map<String, String> = emptyMap(), val children: List<JsonTree.TreeNode> = emptyList()) : JsonTree.TreeNode
Link copied to clipboard
data class TextNode(val value: String) : JsonTree.TreeNode
Link copied to clipboard
interface TreeNode

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val size: Int

Functions

Link copied to clipboard
fun edit(fromIndex: Int, toIndex: Int, vararg contents: JsonTree.TreeNode, splitLevel: Int = 0)

Edits this tree with the given node.

Link copied to clipboard
fun editByPath(fromPath: List<Int>, toPath: List<Int>, vararg contents: JsonTree.TreeNode, splitLevel: Int = 0)

Edits this tree with the given node and path.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Converts the index range into the TreePosStructRange.

Link copied to clipboard
fun indexToPath(index: Int): List<Int>

Returns the path of the given index.

Link copied to clipboard

Converts the path range into the TreePosStructRange.

Link copied to clipboard
fun pathToIndex(path: List<Int>): Int

Returns the index of given path.

Link copied to clipboard

Converts the position range into the index range.

Link copied to clipboard

Converts the position range into the path range.

Link copied to clipboard
fun removeStyle(fromIndex: Int, toIndex: Int, attributesToRemove: List<String>)
Link copied to clipboard
fun style(fromIndex: Int, toIndex: Int, attributes: Map<String, String>)

Sets the attributes to the elements of the given range.

Link copied to clipboard
fun styleByPath(path: List<Int>, attributes: Map<String, String>)

Sets the attributes to the elements of the given path.

Link copied to clipboard
fun toJson(): String
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun toXml(): String

Returns the XML string of this tree.