Skip to content

BlockSuite API Documentation / @blocksuite/store / Y / XmlFragment

Class: XmlFragment

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.

Extends

Extended by

Constructors

new XmlFragment()

new XmlFragment(): XmlFragment

Returns

XmlFragment

Overrides

AbstractType.constructor

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:64

Properties

_dEH

_dEH: EventHandler<YEvent<any>[], Transaction>

Deep event handlers

Inherited from

AbstractType._dEH

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:46


_eH

_eH: EventHandler<YXmlEvent, Transaction>

Event handlers

Inherited from

AbstractType._eH

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:41


_item

_item: null | Item

Inherited from

AbstractType._item

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:23


_length

_length: number

Inherited from

AbstractType._length

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:36


_map

_map: Map<string, Item>

Inherited from

AbstractType._map

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:27


_prelimContent

_prelimContent: null | any[]

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:68


_searchMarker

_searchMarker: null | ArraySearchMarker[]

Inherited from

AbstractType._searchMarker

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:50


_start

_start: null | Item

Inherited from

AbstractType._start

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:31


doc

doc: null | Doc

Inherited from

AbstractType.doc

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:35

Accessors

_first

get _first(): null | Item

The first non-deleted item

Returns

null | Item

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:85


firstChild

get firstChild(): null | XmlText | XmlElement<object>

Returns

null | XmlText | XmlElement<object>

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:72


length

get length(): number

Returns

number

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:95


parent

get parent(): null | AbstractType<any>

Returns

null | AbstractType<any>

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:54

Methods

_callObserver()

_callObserver(transaction, _parentSubs): void

Creates YEvent and calls all type observers. Must be implemented by each type.

Parameters

transaction: Transaction

_parentSubs: Set<null | string>

Keys changed on this type. null if list was modified.

Returns

void

Inherited from

AbstractType._callObserver

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:93


_copy()

_copy(): XmlFragment

Returns

XmlFragment

Overrides

AbstractType._copy

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:86


_integrate()

_integrate(y, item): void

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

y: Doc

The Yjs instance

item: Item

Returns

void

Overrides

AbstractType._integrate

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:85


_write()

_write(_encoder): void

Parameters

_encoder: UpdateEncoderV1 | UpdateEncoderV2

Returns

void

Inherited from

AbstractType._write

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:81


clone()

clone(): XmlFragment

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.

Returns

XmlFragment

Overrides

AbstractType.clone

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:94


createTreeWalker()

createTreeWalker(filter): YXmlTreeWalker

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.

Example

ts
const walker = elem.createTreeWalker(dom => dom.nodeName === 'div')
for (let node in walker) {
  // `node` is a div node
  nop(node)
}

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:113


delete()

delete(index, length?): void

Deletes elements starting from an index.

Parameters

index: number

Index at which to start deleting elements

length?: number

The number of elements to remove. Defaults to 1.

Returns

void

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:192


forEach()

forEach(f): void

Executes a provided function on once on every child element.

Parameters

f

A function to execute on every element of this YArray.

Returns

void

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:231


get()

get(index): XmlElement<object> | XmlText

Returns the i-th element from a YArray.

Parameters

index: number

The index of the element to return from the YArray

Returns

XmlElement<object> | XmlText

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:217


insert()

insert(index, content): void

Inserts new content at an index.

Parameters

index: number

The index to insert content at

content: (XmlElement<object> | XmlText)[]

The array of content

Returns

void

Example

ts
// Insert character 'a' at position 0
 xml.insert(0, [new Y.XmlText('text')])

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:174


insertAfter()

insertAfter(ref, content): void

Inserts new content at an index.

Parameters

ref: null | Item | XmlElement<object> | XmlText

The index to insert content at

content: (XmlElement<object> | XmlText)[]

The array of content

Returns

void

Example

ts
// Insert character 'a' at position 0
 xml.insert(0, [new Y.XmlText('text')])

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:185


observe()

observe(f): void

Observe all events that are created on this type.

Parameters

f

Observer function

Returns

void

Inherited from

AbstractType.observe

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:99


observeDeep()

observeDeep(f): void

Observe all events that are created by this type and its children.

Parameters

f

Observer function

Returns

void

Inherited from

AbstractType.observeDeep

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:105


push()

push(content): void

Appends content to this YArray.

Parameters

content: (XmlElement<object> | XmlText)[]

Array of content to append.

Returns

void

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:204


querySelector()

querySelector(query): null | XmlElement<object> | XmlText | XmlHook

Returns the first YXmlElement that matches the query. Similar to DOM's querySelector.

Query support:

  • tagname TODO:
  • id
  • attribute

Parameters

query: string

The query on the children.

Returns

null | XmlElement<object> | XmlText | XmlHook

The first element that matches the query or null.

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:129


querySelectorAll()

querySelectorAll(query): (null | XmlElement<object> | XmlText | XmlHook)[]

Returns all YXmlElements that match the query. Similar to Dom's querySelectorAll.

Parameters

query: string

The query on the children

Returns

(null | XmlElement<object> | XmlText | XmlHook)[]

The elements that match this query.

Todo

Does not yet support all queries. Currently only query by tagName.

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:141


slice()

slice(start?, end?): (XmlElement<object> | XmlText)[]

Transforms this YArray to a JavaScript Array.

Parameters

start?: number

end?: number

Returns

(XmlElement<object> | XmlText)[]

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:225


toArray()

toArray(): (XmlElement<object> | XmlText | XmlHook)[]

Transforms this YArray to a JavaScript Array.

Returns

(XmlElement<object> | XmlText | XmlHook)[]

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:198


toDOM()

toDOM(_document?, hooks?, binding?): Node

Creates a Dom Element that mirrors this YXmlElement.

Parameters

_document?: Document

The document object (you must define this when calling this method in nodejs)

hooks?

Optional property to customize how hooks are presented in the DOM

binding?: any

You should not set this property. This is used if DomBinding wants to create a association to the created DOM type.

Returns

Node

The Element

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:161


toJSON()

toJSON(): string

Returns

string

Overrides

AbstractType.toJSON

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:145


unobserve()

unobserve(f): void

Unregister an observer function.

Parameters

f

Observer function

Returns

void

Inherited from

AbstractType.unobserve

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:111


unobserveDeep()

unobserveDeep(f): void

Unregister an observer function.

Parameters

f

Observer function

Returns

void

Inherited from

AbstractType.unobserveDeep

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/AbstractType.d.ts:117


unshift()

unshift(content): void

Preppends content to this YArray.

Parameters

content: (XmlElement<object> | XmlText)[]

Array of content to preppend.

Returns

void

Source

node_modules/.pnpm/yjs@13.6.15/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:210