Home Reference Source

Function

Static Public Summary
public

createAssociation(domBinding: DomBinding, dom: Element, type: YXmlElement | YXmlHook)

Creates an association (the information that a DOM element belongs to a type).

public

Creates a mutual exclude function with the following property:

public

defaultFilter(nodeName: String, attrs: Map): Map | null

Default filter method (does nothing).

public

Try to merge all items in os with their successors.

public

domToType(element: Element | TextNode, _document: Document, hooks: Hooks, filter: Filter, binding: DomBinding): YXmlElement | YXmlText

Creates a Yjs type (YXml) based on the contents of a DOM Element.

public

domsToTypes(doms: *, _document: *, hooks: *, filter: *, binding: *): *

public

filterDomAttributes(dom: *, filter: *): *

public

fromBinary(y: Y, decoder: BinaryDecoder)

Read the Decoder and fill the Yjs instance with data in the decoder.

public

Transforms a relative position back to a relative position.

public
public

getListItemIDByPosition(type: *, i: *): *

public

getRelativePosition(type: YType, offset: Integer): string[]

Create a relativePosition based on a absolute position.

public

integrateRemoteStructs(y: *, decoder: *)

public

isParentOf(parent: Type, child: Type): Boolean

Check if parent is a parent of child.

public

logID(id: *): string

public

messageToRoomname(buffer: *): *

public

messageToString(arrayPattern: *[]): *

public

readDeleteSet(y: *, decoder: *)

public

readStateSet(decoder: *): *

public

readSyncStep1(decoder: *, encoder: *, y: *, senderConn: *, sender: *)

public

readSyncStep2(decoder: *, encoder: *, y: *, senderConn: *, sender: *)

public

registerStruct(reference: Number, structConstructor: class)

Register a new Yjs types.

public

removeAssociation(domBinding: DomBinding, dom: Element, type: YXmlElement | YXmlHook)

Removes an association (the information that a DOM element belongs to a type).

public

sendSyncStep1(connector: *, syncUser: *)

public

Create a diff between two strings.

public

stringifyDeleteSet(y: *, decoder: *, strBuilder: *): *

public

stringifyStructs(y: *, decoder: *, strBuilder: *)

public

stringifySyncStep1(y: *, decoder: *, strBuilder: *)

public

stringifySyncStep2(y: *, decoder: *, strBuilder: *)

public

switchAssociation(domBinding: DomBinding, oldDom: Element, newDom: Element)

If oldDom is associated with a type, associate newDom with the type and forget about oldDom.

public

Encode the Yjs model to binary format.

public

writeDeleteSet(y: *, encoder: *)

public

writeStateSet(y: *, encoder: *)

Static Public

public createAssociation(domBinding: DomBinding, dom: Element, type: YXmlElement | YXmlHook) source

import {createAssociation} from 'yjs/src/Bindings/DomBinding/util.js'

Creates an association (the information that a DOM element belongs to a type).

Params:

NameTypeAttributeDescription
domBinding DomBinding

The binding object

dom Element

The dom that is to be associated with type

type YXmlElement | YXmlHook

The type that is to be associated with dom

public createMutualExclude(): Function source

import {createMutualExclude} from 'yjs/src/Util/mutualExclude.js'

Creates a mutual exclude function with the following property:

Return:

Function

A mutual exclude function

Example:

const mutualExclude = createMutualExclude()
mutualExclude(function () {
  // This function is immediately executed
  mutualExclude(function () {
    // This function is never executed, as it is called with the same
    // mutualExclude
  })
})

public defaultFilter(nodeName: String, attrs: Map): Map | null source

import {defaultFilter} from 'yjs/src/Bindings/DomBinding/filter.js'

Default filter method (does nothing).

Params:

NameTypeAttributeDescription
nodeName String

The nodeName of the element

attrs Map

Map of key-value pairs that are attributes of the node.

Return:

Map | null

The allowed attributes or null, if the element should be filtered.

public defragmentItemContent(y: *) source

import {defragmentItemContent} from 'yjs/src/Util/defragmentItemContent.js'

Try to merge all items in os with their successors.

Some transformations (like delete) fragment items. Item(c: 'ab') + Delete(1,1) + Delete(0, 1) -> Item(c: 'a',deleted);Item(c: 'b',deleted)

This functions merges the fragmented nodes together: Item(c: 'a',deleted);Item(c: 'b',deleted) -> Item(c: 'ab', deleted)

TODO: The Tree implementation does not support deletions in-spot. This is why all deletions must be performed after the traversal.

Params:

NameTypeAttributeDescription
y *

public domToType(element: Element | TextNode, _document: Document, hooks: Hooks, filter: Filter, binding: DomBinding): YXmlElement | YXmlText source

Creates a Yjs type (YXml) based on the contents of a DOM Element.

Params:

NameTypeAttributeDescription
element Element | TextNode

The DOM Element

_document Document
  • nullable: true

Optional. Provide the global document object

hooks Hooks
  • optional
  • default: {}

Optional. Set of Yjs Hooks

filter Filter
  • optional
  • default: defaultFilter

Optional. Dom element filter

binding DomBinding
  • nullable: true

Warning: This property is for internal use only!

Return:

YXmlElement | YXmlText

public domsToTypes(doms: *, _document: *, hooks: *, filter: *, binding: *): * source

import {domsToTypes} from 'yjs/src/Bindings/DomBinding/util.js'

Params:

NameTypeAttributeDescription
doms *
_document *
hooks *
filter *
binding *

Return:

*

public filterDomAttributes(dom: *, filter: *): * source

import {filterDomAttributes} from 'yjs/src/Bindings/DomBinding/filter.js'

Params:

NameTypeAttributeDescription
dom *
filter *

Return:

*

public fromBinary(y: Y, decoder: BinaryDecoder) source

import {fromBinary} from 'yjs/src/MessageHandler/binaryEncode.js'

Read the Decoder and fill the Yjs instance with data in the decoder.

Params:

NameTypeAttributeDescription
y Y

The Yjs instance

decoder BinaryDecoder

The BinaryDecoder to read from.

public fromRelativePosition(y: Y, rpos: RelativePosition): AbsolutePosition source

import {fromRelativePosition} from 'yjs/src/Util/relativePosition.js'

Transforms a relative position back to a relative position.

Params:

NameTypeAttributeDescription
y Y

The Yjs instance in which to query for the absolute position.

rpos RelativePosition

The relative position.

Return:

AbsolutePosition

The absolute position in the Yjs model (type + offset).

public generateRandomUint32(): * source

import {generateRandomUint32} from 'yjs/src/Util/generateRandomUint32.js'

Return:

*

public getListItemIDByPosition(type: *, i: *): * source

import {getListItemIDByPosition} from 'yjs/src/Struct/Type.js'

Params:

NameTypeAttributeDescription
type *
i *

Return:

*

public getRelativePosition(type: YType, offset: Integer): string[] source

import {getRelativePosition} from 'yjs/src/Util/relativePosition.js'

Create a relativePosition based on a absolute position.

Params:

NameTypeAttributeDescription
type YType

The base type (e.g. YText or YArray).

offset Integer

The absolute position.

Return:

string[]

public integrateRemoteStructs(y: *, decoder: *) source

import {integrateRemoteStructs} from 'yjs/src/MessageHandler/integrateRemoteStructs.js'

Params:

NameTypeAttributeDescription
y *
decoder *

public isParentOf(parent: Type, child: Type): Boolean source

import isParentOf from 'yjs/src/Util/isParentOf.js'

Check if parent is a parent of child.

Params:

NameTypeAttributeDescription
parent Type
child Type

Return:

Boolean

Whether parent is a parent of child.

public logID(id: *): string source

Params:

NameTypeAttributeDescription
id *

Return:

string

public messageToRoomname(buffer: *): * source

import {messageToRoomname} from 'yjs/src/MessageHandler/messageToString.js'

Params:

NameTypeAttributeDescription
buffer *

Return:

*

public messageToString(arrayPattern: *[]): * source

import {messageToString} from 'yjs/src/MessageHandler/messageToString.js'

Params:

NameTypeAttributeDescription
arrayPattern *[]
  • default: [null, null]

Return:

*

public readDeleteSet(y: *, decoder: *) source

import {readDeleteSet} from 'yjs/src/MessageHandler/deleteSet.js'

Params:

NameTypeAttributeDescription
y *
decoder *

public readStateSet(decoder: *): * source

import {readStateSet} from 'yjs/src/MessageHandler/stateSet.js'

Params:

NameTypeAttributeDescription
decoder *

Return:

*

public readSyncStep1(decoder: *, encoder: *, y: *, senderConn: *, sender: *) source

import {readSyncStep1} from 'yjs/src/MessageHandler/syncStep1.js'

Params:

NameTypeAttributeDescription
decoder *
encoder *
y *
senderConn *
sender *

public readSyncStep2(decoder: *, encoder: *, y: *, senderConn: *, sender: *) source

import {readSyncStep2} from 'yjs/src/MessageHandler/syncStep2.js'

Params:

NameTypeAttributeDescription
decoder *
encoder *
y *
senderConn *
sender *

public registerStruct(reference: Number, structConstructor: class) source

import {registerStruct} from 'yjs/src/Util/structReferences.js'

Register a new Yjs types. The same type must be defined with the same reference on all clients!

Params:

NameTypeAttributeDescription
reference Number
structConstructor class

public removeAssociation(domBinding: DomBinding, dom: Element, type: YXmlElement | YXmlHook) source

import {removeAssociation} from 'yjs/src/Bindings/DomBinding/util.js'

Removes an association (the information that a DOM element belongs to a type).

Params:

NameTypeAttributeDescription
domBinding DomBinding

The binding object

dom Element

The dom that is to be associated with type

type YXmlElement | YXmlHook

The type that is to be associated with dom

public sendSyncStep1(connector: *, syncUser: *) source

import {sendSyncStep1} from 'yjs/src/MessageHandler/syncStep1.js'

Params:

NameTypeAttributeDescription
connector *
syncUser *

public simpleDiff(a: String, b: String): SimpleDiff source

import simpleDiff from 'yjs/src/Util/simpleDiff.js'

Create a diff between two strings. This diff implementation is highly efficient, but not very sophisticated.

Params:

NameTypeAttributeDescription
a String

The old version of the string

b String

The updated version of the string

Return:

SimpleDiff

The diff description.

public stringifyDeleteSet(y: *, decoder: *, strBuilder: *): * source

import {stringifyDeleteSet} from 'yjs/src/MessageHandler/deleteSet.js'

Params:

NameTypeAttributeDescription
y *
decoder *
strBuilder *

Return:

*

public stringifyStructs(y: *, decoder: *, strBuilder: *) source

import {stringifyStructs} from 'yjs/src/MessageHandler/integrateRemoteStructs.js'

Params:

NameTypeAttributeDescription
y *
decoder *
strBuilder *

public stringifySyncStep1(y: *, decoder: *, strBuilder: *) source

import {stringifySyncStep1} from 'yjs/src/MessageHandler/syncStep1.js'

Params:

NameTypeAttributeDescription
y *
decoder *
strBuilder *

public stringifySyncStep2(y: *, decoder: *, strBuilder: *) source

import {stringifySyncStep2} from 'yjs/src/MessageHandler/syncStep2.js'

Params:

NameTypeAttributeDescription
y *
decoder *
strBuilder *

public switchAssociation(domBinding: DomBinding, oldDom: Element, newDom: Element) source

import {switchAssociation} from 'yjs/src/Bindings/DomBinding/util.js'

If oldDom is associated with a type, associate newDom with the type and forget about oldDom. If oldDom is not associated with any type, nothing happens.

Params:

NameTypeAttributeDescription
domBinding DomBinding

The binding object

oldDom Element

The existing dom

newDom Element

The new dom object

public toBinary(y: Y): BinaryEncoder source

Encode the Yjs model to binary format.

Params:

NameTypeAttributeDescription
y Y

The Yjs instance

Return:

BinaryEncoder

The encoder instance that can be transformed to ArrayBuffer or Buffer.

public writeDeleteSet(y: *, encoder: *) source

import {writeDeleteSet} from 'yjs/src/MessageHandler/deleteSet.js'

Params:

NameTypeAttributeDescription
y *
encoder *

public writeStateSet(y: *, encoder: *) source

import {writeStateSet} from 'yjs/src/MessageHandler/stateSet.js'

Params:

NameTypeAttributeDescription
y *
encoder *