new YXmlFragment()
Extends
Members
-
_prelimContent :Array.<any>|null
-
-
_prelimContent :Array.<any>
-
Methods
-
_callObserver(transaction, parentSubs)
-
Creates YXmlEvent and calls observers.
Parameters:
Name Type Description transactionTransaction parentSubsSet.<(null|string)> Keys changed on this type.
nullif list was modified. -
_integrate(y, item)
-
Integrate this type into the Yjs instance.
- Save this struct in the os
- This type is sent to other client
- Observer functions are fired
Parameters:
Name Type Description yDoc The Yjs instance
itemItem -
_write(encoder)
-
Transform the properties of this type to binary and write it to an BinaryEncoder.
This is called when this Item is sent to a remote peer.
Parameters:
Name Type Description encoderAbstractUpdateEncoder The encoder to write data to.
-
createTreeWalker(filter) → {YXmlTreeWalker}
-
Create a subtree of childNodes.
Parameters:
Name Type Description filterfunction Function that is called on each child element and returns a Boolean indicating whether the child is to be included in the subtree.
Returns:
YXmlTreeWalker -A subtree and a position within it.
Example
const walker = elem.createTreeWalker(dom => dom.nodeName === 'div') for (let node in walker) { // `node` is a div node nop(node) } -
delete(index, lengthopt)
-
Deletes elements starting from an index.
Parameters:
Name Type Attributes Default Description indexnumber Index at which to start deleting elements
lengthnumber <optional>
1 The number of elements to remove. Defaults to 1.
-
insert(index, content)
-
Inserts new content at an index.
Parameters:
Name Type Description indexnumber The index to insert content at
contentArray.<(YXmlElement|YXmlText)> The array of content
Example
// Insert character 'a' at position 0 xml.insert(0, [new Y.XmlText('text')]) -
querySelector(query) → {YXmlElement|YXmlText|YXmlHook|null}
-
Returns the first YXmlElement that matches the query. Similar to DOM's querySelector.
Query support:
- tagname TODO:
- id
- attribute
Parameters:
Name Type Description queryCSS_Selector The query on the children.
Returns:
YXmlElement | YXmlText | YXmlHook | null -The first element that matches the query or null.
-
querySelectorAll(query) → {Array.<(YXmlElement|YXmlText|YXmlHook|null)>}
-
Returns all YXmlElements that match the query. Similar to Dom's querySelectorAll.
Parameters:
Name Type Description queryCSS_Selector The query on the children
- To Do:
-
- Does not yet support all queries. Currently only query by tagName.
-
toArray() → {Array.<(YXmlElement|YXmlText|YXmlHook)>}
-
Transforms this YArray to a JavaScript Array.
Returns:
Array.<(YXmlElement|YXmlText|YXmlHook)> -
toDOM(_documentopt, hooksopt, bindingopt) → {Node}
-
Creates a Dom Element that mirrors this YXmlElement.
Parameters:
Name Type Attributes Default Description _documentDocument <optional>
document The document object (you must define this when calling this method in nodejs)
hooksObject.<string, any> <optional>
{} Optional property to customize how hooks are presented in the DOM
bindingany <optional>
You should not set this property. This is used if DomBinding wants to create a association to the created DOM type.
-
toJSON() → {string}
-
Returns:
string -
toString() → {string}
-
Get the string representation of all the children of this YXmlFragment.
Returns:
string -The string representation of all children.