Y.XmlText
Extends Y.Text to represent a Y.Xml node.
import * as Y from 'yjs'
const ydoc = new Y.Doc()
// You can define a Y.XmlText as a top-level type or a nested type
// Method 1: Define a top-level type
const yxmlText = ydoc.get('my xmltext type', Y.XmlText)
// Method 2: Define Y.XmlText that can be included into the Yjs document
const yxmltextNested = new Y.XmlText()
// Nested types can be included as content into any other shared type
yxmlText.set('my nested text', ytextNested)
// Common methods (also available in Y.Text)
yxmlText.insert(0, 'abc') // insert three elements
yxmlText.format(1, 2, { bold: true }) // delete second element
yxmlText.toDelta() // => [{ insert: 'a' }, { insert: 'bc', attributes: { bold: true }}]
// Methods specific to Y.XmlText
yxmlText.prevSibling
yxmlText.nextSibling
yxmlText.toString() // => "a<bold>bc</bold>"API
Last updated