Y.XmlFragment
A shared type to manage a collection of Y.Xml* Nodes
import * as Y from 'yjs'
const ydoc = new Y.Doc()
// You can define a Y.XmlFragment as a top-level type or a nested type
// Method 1: Define a top-level type
const yxmlFragment = ydoc.getXmlFragment('my xml fragment')
// Method 2: Define Y.XmlFragment that can be included into the Yjs document
const yxmlNested = new Y.XmlFragment()
// Common methods
const yxmlText = new Y.XmlText()
yxmlFragment.insert(0, [yxmlText])
yxmlFragment.firstChild === yxmlText
yxmlFragment.insertAfter(yxmlText, [new Y.XmlElement('node-name')])
yxmlFragment.get(0) === yxmlText // => true
//show result in dev console
console.log(yxmlFragment.toDOM())API
Observing changes: Y.XmlEvent
Y.XmlEvent API
Last updated
