bindings/dom.DomBinding(type, target, optsopt)

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

This binding is automatically destroyed when its parent is deleted.

new DomBinding(type, target, optsopt)

Parameters:
Name Type Attributes Description
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

Properties
Name Type Attributes Default Description
filter DomFilter <optional>
defaultFilter

The filter function to use.

document Document <optional>
document

The filter function to use.

hooks Object <optional>

The filter function to use.

scrollingElement Element <optional>
null

The filter function to use.

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

Members

domToType :Map

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

filter :DomFilter

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

target :Element

The target that type is bound to.

type :YXmlFragment

The Yjs type that is bound to target

typeToDom :Map

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

Methods

destroy()

Remove all properties that are handled by this class.

setFilter(filter)

NOTE:

  • does not apply filter to existing elements!
  • only guarantees that changes are filtered locally. Remote sites may see different content.
Parameters:
Name Type Description
filter DomFilter

The filter function to use from now on.