Package io.keikai.doc.collab.types
Class YXmlFragment<T>
- Direct Known Subclasses:
YXmlElement
Represents a list of
YXmlElement.and YXmlText types.
A YxmlFragment is similar to a YXmlElement, but it does not have a
nodeName, and it does not have attributes. Though it can be bound to a DOM
element - in this case the attributes and the nodeName are not shared.-
Field Summary
Fields inherited from class io.keikai.doc.collab.types.AbstractType
_doc, _length, _map, _searchMarker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcallObserver(Transaction transaction, Set<String> parentSubs) Creates YXmlEvent and calls observers.clone()Makes a copy of this data type that can be included somewhere else.copy()createTreeWalker(Function<AbstractType, Boolean> filter) Create a subtree of childNodes.voiddelete(int index) Deletes elements starting from an index.voiddelete(int index, int length) Deletes elements starting from an index.voidExecutes a provided function once on every child element.get(int index) Returns the i-th element from a YArray.voidInserts new content at an index.voidinsertAfter(Object ref, List<T> content) Inserts new content after a reference element.voidIntegrate this type into the Yjs instanceintlength()voidAppends content to this YArray.querySelector(String query) Returns the first YXmlElement that matches the query.querySelectorAll(String query) Returns all YXmlElements that match the query.static YXmlFragmentreadYXmlFragment(UpdateDecoder decoder) slice(int start, int end) Returns a portion of this YXmlFragment into a JavaScript Array selected from start to end (end not included).Object[]toArray()Transforms this YArray to a Object Array.toJSON()Converts the type to a JSON object representation.toList()Transforms this YArray to a Object List.toString()Get the string representation of all the children of this YXmlFragment.voidPrepends content to this YArray.voidwrite(UpdateEncoder encoder) Transform the properties of this type to binary and write it to a BinaryEncoder.Methods inherited from class io.keikai.doc.collab.types.AbstractType
callTypeObservers, createMapIterator, getDeepEventHandler, getDoc, getFirst, getItem, getMap, getParent, getSearchMarker, getStart, getTypeChildren, isParentOf, observe, observe, observeDeep, setLength, setMap, setStart, typeListCreateIterator, typeListDelete, typeListForEach, typeListForEachSnapshot, typeListGet, typeListInsertGenerics, typeListInsertGenericsAfter, typeListMap, typeListPushGenerics, typeListSlice, typeListToArray, typeListToArraySnapshot, typeMapDelete, typeMapGet, typeMapGetAll, typeMapGetAllSnapshot, typeMapGetSnapshot, typeMapHas, typeMapSet, unobserve, unobserveDeep
-
Constructor Details
-
YXmlFragment
public YXmlFragment()
-
-
Method Details
-
getFirstChild
- Returns:
- YXmlElement or YXmlText|null
-
integrate
Integrate this type into the Yjs instance. * Save this struct in the os * This type is sent to other clients * Observer functions are fired- Overrides:
integratein classAbstractType<YXmlEvent>- Parameters:
y- The Yjs instance.item- The item to integrate.
-
copy
- Overrides:
copyin classAbstractType<YXmlEvent>
-
clone
Makes a copy of this data type that can be included somewhere else. Note that the content is only readable _after_ it has been included somewhere in the Ydoc.- Overrides:
clonein classAbstractType<YXmlEvent>- Returns:
- YXmlFragment
-
length
public int length()- Overrides:
lengthin classAbstractType<YXmlEvent>
-
createTreeWalker
Create a subtree of childNodes.- Parameters:
filter- 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.
-
querySelector
Returns the first YXmlElement that matches the query. Similar to DOM's querySelector.- Parameters:
query- The query on the children.- Returns:
- YXmlElement|YXmlText|YXmlHook|null The first element that matches the query or null.
-
querySelectorAll
Returns all YXmlElements that match the query. Similar to Dom's querySelectorAll.- Parameters:
query- The query on the children.- Returns:
- List of YXmlElement|YXmlText|YXmlHook|null. The elements that match this query.
-
callObserver
Creates YXmlEvent and calls observers.- Overrides:
callObserverin classAbstractType<YXmlEvent>- Parameters:
transaction- The transaction that occurred.parentSubs- Keys changed on this type. `null` if the list was modified.
-
toString
Get the string representation of all the children of this YXmlFragment. -
toJSON
Description copied from class:AbstractTypeConverts the type to a JSON object representation.- Overrides:
toJSONin classAbstractType<YXmlEvent>- Returns:
- JSON representation of the fragment.
-
insert
Inserts new content at an index.- Parameters:
index- The index to insert content at.content- The array of content.
-
insertAfter
Inserts new content after a reference element.- Parameters:
ref- The index to insert content at.content- The array of content.
-
delete
public void delete(int index) Deletes elements starting from an index.- Parameters:
index- Index at which to start deleting elements.
-
delete
public void delete(int index, int length) Deletes elements starting from an index.- Parameters:
index- Index at which to start deleting elements.length- The number of elements to remove. Defaults to 1.
-
toArray
Transforms this YArray to a Object Array.- Returns:
- Array of YXmlElement, YXmlText, or YXmlHook.
-
toList
Transforms this YArray to a Object List.- Returns:
- Array of YXmlElement, YXmlText, or YXmlHook.
-
push
Appends content to this YArray.- Parameters:
content- Array of content to append.
-
unshift
Prepends content to this YArray.- Parameters:
content- Array of content to prepend.
-
get
Returns the i-th element from a YArray.- Parameters:
index- The index of the element to return from the YArray.- Returns:
- YXmlElement or YXmlText.
-
slice
Returns a portion of this YXmlFragment into a JavaScript Array selected from start to end (end not included).- Parameters:
start- Starting index.end- Ending index (not included).- Returns:
- Array of YXmlElement or YXmlText.
-
forEach
Executes a provided function once on every child element.- Parameters:
f- A function to execute on every element of this YArray.
-
write
Transform the properties of this type to binary and write it to a BinaryEncoder. This is called when this Item is sent to a remote peer.- Overrides:
writein classAbstractType<YXmlEvent>- Parameters:
encoder- The encoder to write data to.
-
readYXmlFragment
- Parameters:
decoder- The decoder to read data from.- Returns:
- YXmlFragment
-