Skip to content

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

Class: XmlElement<KV> ​

An YXmlElement imitates the behavior of a Element.

  • An YXmlElement has attributes (key value pairs)
  • An YXmlElement has childElements that must inherit from YXmlElement

Contents ​

Extends ​

Type parameters ​

• KV extends Object = Object

Constructors ​

new XmlElement(nodeName) ​

new XmlElement<KV>(nodeName?): XmlElement<KV>

Parameters ​

• nodeName?: string

Returns ​

XmlElement<KV>

Overrides ​

@blocksuite/store.Y.XmlFragment.constructor

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:18

Properties ​

_dEH ​

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

Deep event handlers

Inherited from ​

@blocksuite/store.Y.XmlFragment._dEH

Source ​

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


_eH ​

_eH: EventHandler<YXmlEvent, Transaction>

Event handlers

Inherited from ​

@blocksuite/store.Y.XmlFragment._eH

Source ​

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


_item ​

_item: null | Item

Inherited from ​

@blocksuite/store.Y.XmlFragment._item

Source ​

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


_length ​

_length: number

Inherited from ​

@blocksuite/store.Y.XmlFragment._length

Source ​

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


_map ​

_map: Map<string, Item>

Inherited from ​

@blocksuite/store.Y.XmlFragment._map

Source ​

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


_prelimAttrs ​

_prelimAttrs: null | Map<string, any>

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:23


_prelimContent ​

_prelimContent: null | any[]

Inherited from ​

@blocksuite/store.Y.XmlFragment._prelimContent

Source ​

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


_searchMarker ​

_searchMarker: null | ArraySearchMarker[]

Inherited from ​

@blocksuite/store.Y.XmlFragment._searchMarker

Source ​

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


_start ​

_start: null | Item

Inherited from ​

@blocksuite/store.Y.XmlFragment._start

Source ​

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


doc ​

doc: null | Doc

Inherited from ​

@blocksuite/store.Y.XmlFragment.doc

Source ​

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


nodeName ​

nodeName: string

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:19

Accessors ​

_first ​

get _first(): null | Item

The first non-deleted item

Returns ​

null | Item

Source ​

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


firstChild ​

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

Returns ​

null | XmlText | XmlElement<Object>

Source ​

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


length ​

get length(): number

Returns ​

number

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:91


nextSibling ​

get nextSibling(): null | XmlText | XmlElement<Object>

Returns ​

null | XmlText | XmlElement<Object>

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:27


parent ​

get parent(): null | AbstractType<any>

Returns ​

null | AbstractType<any>

Source ​

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


prevSibling ​

get prevSibling(): null | XmlText | XmlElement<Object>

Returns ​

null | XmlText | XmlElement<Object>

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:33

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 ​

@blocksuite/store.Y.XmlFragment._callObserver

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/AbstractType.d.ts:89


_copy() ​

_copy(): XmlElement<Object>

Creates an Item with the same effect as this Item (without position effect)

Returns ​

XmlElement<Object>

Overrides ​

@blocksuite/store.Y.XmlFragment._copy

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:41


_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

Inherited from ​

@blocksuite/store.Y.XmlFragment._integrate

Source ​

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


_write() ​

_write(_encoder): void

Parameters ​

• _encoder: UpdateEncoderV1 | UpdateEncoderV2

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment._write

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/AbstractType.d.ts:77


clone() ​

clone(): XmlElement<KV>

Returns ​

XmlElement<KV>

Overrides ​

@blocksuite/store.Y.XmlFragment.clone

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:45


createTreeWalker() ​

createTreeWalker(filter): YXmlTreeWalker

Create a subtree of childNodes.

Parameters ​

• filter: (arg0) => boolean

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.

Inherited from ​

@blocksuite/store.Y.XmlFragment.createTreeWalker

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.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:109


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

Inherited from ​

@blocksuite/store.Y.XmlFragment.delete

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:188


forEach() ​

forEach(f): void

Executes a provided function on once on overy child element.

Parameters ​

• f: (arg0, arg1, arg2) => void

A function to execute on every element of this YArray.

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.forEach

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:227


get() ​

get(index): XmlText | XmlElement<Object>

Returns the i-th element from a YArray.

Parameters ​

• index: number

The index of the element to return from the YArray

Returns ​

XmlText | XmlElement<Object>

Inherited from ​

@blocksuite/store.Y.XmlFragment.get

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:213


getAttribute() ​

getAttribute<KEY_1>(attributeName): undefined | KV[KEY_1]

Returns an attribute value that belongs to the attribute name.

Type parameters ​

• KEY_1 extends string

Parameters ​

• attributeName: KEY_1

The attribute name that identifies the queried value.

Returns ​

undefined | KV[KEY_1]

The queried attribute value.

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:76


getAttributes() ​

getAttributes(snapshot?): { [Key in string]?: KV[Key] }

Returns all attribute name/value pairs in a JSON Object.

Parameters ​

• snapshot?: Snapshot

Returns ​

{ [Key in string]?: KV[Key] }

A JSON Object that describes the attributes.

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:94


hasAttribute() ​

hasAttribute(attributeName): boolean

Returns whether an attribute exists

Parameters ​

• attributeName: string

The attribute name to check for existence.

Returns ​

boolean

whether the attribute exists.

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:85


insert() ​

insert(index, content): void

Inserts new content at an index.

Parameters ​

• index: number

The index to insert content at

• content: (XmlText | XmlElement<Object>)[]

The array of content

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.insert

Example ​

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

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:170


insertAfter() ​

insertAfter(ref, content): void

Inserts new content at an index.

Parameters ​

• ref: null | Item | XmlText | XmlElement<Object>

The index to insert content at

• content: (XmlText | XmlElement<Object>)[]

The array of content

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.insertAfter

Example ​

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

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:181


observe() ​

observe(f): void

Observe all events that are created on this type.

Parameters ​

• f: (arg0, arg1) => void

Observer function

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.observe

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/AbstractType.d.ts:95


observeDeep() ​

observeDeep(f): void

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

Parameters ​

• f: (arg0, arg1) => void

Observer function

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.observeDeep

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/AbstractType.d.ts:101


push() ​

push(content): void

Appends content to this YArray.

Parameters ​

• content: (XmlText | XmlElement<Object>)[]

Array of content to append.

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.push

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:200


querySelector() ​

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

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 | XmlText | XmlHook | XmlElement<Object>

The first element that matches the query or null.

Inherited from ​

@blocksuite/store.Y.XmlFragment.querySelector

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:125


querySelectorAll() ​

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

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

Parameters ​

• query: string

The query on the children

Returns ​

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

The elements that match this query.

Inherited from ​

@blocksuite/store.Y.XmlFragment.querySelectorAll

Todo ​

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

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:137


removeAttribute() ​

removeAttribute(attributeName): void

Removes an attribute from this YXmlElement.

Parameters ​

• attributeName: string

The attribute name that is to be removed.

Returns ​

void

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:53


setAttribute() ​

setAttribute<KEY>(attributeName, attributeValue): void

Sets or updates an attribute.

Type parameters ​

• KEY extends string

Parameters ​

• attributeName: KEY

The attribute name that is to be set.

• attributeValue: KV[KEY]

The attribute value that is to be set.

Returns ​

void

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlElement.d.ts:64


slice() ​

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

Transforms this YArray to a JavaScript Array.

Parameters ​

• start?: number

• end?: number

Returns ​

(XmlText | XmlElement<Object>)[]

Inherited from ​

@blocksuite/store.Y.XmlFragment.slice

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:221


toArray() ​

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

Transforms this YArray to a JavaScript Array.

Returns ​

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

Inherited from ​

@blocksuite/store.Y.XmlFragment.toArray

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:194


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?: Object

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

Inherited from ​

@blocksuite/store.Y.XmlFragment.toDOM

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:157


toJSON() ​

toJSON(): string

Returns ​

string

Inherited from ​

@blocksuite/store.Y.XmlFragment.toJSON

Source ​

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


unobserve() ​

unobserve(f): void

Unregister an observer function.

Parameters ​

• f: (arg0, arg1) => void

Observer function

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.unobserve

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/AbstractType.d.ts:107


unobserveDeep() ​

unobserveDeep(f): void

Unregister an observer function.

Parameters ​

• f: (arg0, arg1) => void

Observer function

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.unobserveDeep

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/AbstractType.d.ts:113


unshift() ​

unshift(content): void

Preppends content to this YArray.

Parameters ​

• content: (XmlText | XmlElement<Object>)[]

Array of content to preppend.

Returns ​

void

Inherited from ​

@blocksuite/store.Y.XmlFragment.unshift

Source ​

node_modules/.pnpm/yjs@13.6.10/node_modules/yjs/dist/src/types/YXmlFragment.d.ts:206


Generated using typedoc-plugin-markdown and TypeDoc