Home Reference Source
public class | source

DomBinding

Extends:

Binding → DomBinding

A binding that binds the children of a YXmlFragment to a DOM element.

This binding is automatically destroyed when its parent is deleted.

Example:

const div = document.createElement('div')
const type = y.define('xml', Y.XmlFragment)
const binding = new Y.QuillBinding(type, div)

Constructor Summary

Public Constructor
public

constructor(type: YXmlFragment, target: Element, opts: Object)

Member Summary

Public Members
public

Maps each DOM element to the type that it is associated with.

public

Defines which DOM attributes and elements to filter out.

public

opts: *

public

Maps each YXml type to the DOM element that it is associated with.

Method Summary

Public Methods
public

Remove all properties that are handled by this class.

public

enableSmartScrolling(scrollElement: Element)

Enables the smart scrolling functionality for a Dom Binding.

public

NOTE: currently does not apply filter to existing elements!

Inherited Summary

From class Binding
public

target: *

The target that type is bound to.

public

type: YType

The Yjs type that is bound to target

public

Remove all data observers (both from the type and the target).

Public Constructors

public constructor(type: YXmlFragment, target: Element, opts: Object) source

Override:

Binding#constructor

Params:

NameTypeAttributeDescription
type YXmlFragment

The bind source. This is the ultimate source of truth.

target Element

The bind target. Mirrors the target.

opts Object
  • optional

Optional configurations

opts.filter FilterFunction
  • optional
  • default: defaultFilter

The filter function to use.

Public Members

public domToType: Map source

Maps each DOM element to the type that it is associated with.

public filter: FilterFunction source

Defines which DOM attributes and elements to filter out. Also filters remote changes.

public opts: * source

public typeToDom: Map source

Maps each YXml type to the DOM element that it is associated with.

Public Methods

public destroy() source

Remove all properties that are handled by this class.

Override:

Binding#destroy

public enableSmartScrolling(scrollElement: Element) source

Enables the smart scrolling functionality for a Dom Binding. This is useful when YXml is bound to a shared editor. When activated, the viewport will be changed to accommodate remote changes.

Params:

NameTypeAttributeDescription
scrollElement Element

The node that is

public setFilter(filter: FilterFunction) source

NOTE: currently does not apply filter to existing elements!

Params:

NameTypeAttributeDescription
filter FilterFunction

The filter function to use from now on.