# Typedef

Static Public Summary
public | AbsolutePosition : Object |
public | CSS_Selector : string Define the elements to which a set of CSS queries apply. |
public | CSS_Selector : string Define the elements to which a set of CSS queries apply. |
public | Delta : Array<Object> The Quill Delta format represents changes on a text document with formatting information. |
public | FilterFunction : function (nodeName: String, attrs: Map): Map | null A filter defines which elements and attributes to share. |
public | RelativePosition : encodable A relative position that is based on the Yjs model. |
public | SimpleDiff : Object A SimpleDiff describes a change on a String. |
public | TextAttributes : Object Attributes that can be assigned to a selection of text. |
public | encodable : number | string Anything that can be encoded with `JSON.stringify` and can be decoded with `JSON.parse`. |

## Static Public

### public AbsolutePosition: Object source

#### Properties:

Name | Type | Attribute | Description
type | YType |  | The type on which to apply the absolute position.
offset | Integer |  | The absolute offset.r

### public CSS_Selector: string source

Define the elements to which a set of CSS queries apply. {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}

#### Example:

      query = '.classSelector'
      query = 'nodeSelector'
      query = '#idSelector'

### public CSS_Selector: string source

Define the elements to which a set of CSS queries apply. {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}

#### Example:

      query = '.classSelector'
      query = 'nodeSelector'
      query = '#idSelector'

### public Delta: Array<Object> source

The Quill Delta format represents changes on a text document with formatting information. For mor information visit {@link https://quilljs.com/docs/delta/|Quill Delta}

#### Example:

      {
        ops: [
          { insert: 'Gandalf', attributes: { bold: true } },
          { insert: ' the ' },
          { insert: 'Grey', attributes: { color: '#cccccc' } }
        ]
      }

### public FilterFunction: function (nodeName: String, attrs: Map): Map | null source

A filter defines which elements and attributes to share. Return null if the node should be filtered. Otherwise return the Map of accepted attributes.

### public RelativePosition: encodable source

A relative position that is based on the Yjs model. In contrast to an absolute position (position by index), the relative position can be recomputed when remote changes are received. For example:

`Insert(0, 'x')('a|bc') = 'xa|bc'` Where | is the cursor position.

A relative cursor position can be obtained with the function getRelativePosition and it can be transformed to an absolute position with fromRelativePosition.

Pro tip: Use this to implement shared cursor locations in YText or YXml! The relative position is encodable, so you can send it to other clients.

#### Example:

    // Current cursor position is at position 10
    let relativePosition = getRelativePosition(yText, 10)
    // modify yText
    yText.insert(0, 'abc')
    yText.delete(3, 10)
    // Compute the cursor position
    let absolutePosition = fromRelativePosition(y, relativePosition)
    absolutePosition.type // => yText
    console.log('cursor location is ' + absolutePosition.offset) // => cursor location is 3

### public SimpleDiff: Object source

A SimpleDiff describes a change on a String.

#### Properties:

Name | Type | Attribute | Description
pos | Number |  | The index where changes were applied
delete | Number |  | The number of characters to delete starting at `index`.
insert | String |  | The new text to insert at `index` after applying `delete`

#### Example:

    console.log(a) // the old value
    console.log(b) // the updated value
    // Apply changes of diff (pseudocode)
    a.remove(diff.pos, diff.remove) // Remove `diff.remove` characters
    a.insert(diff.pos, diff.insert) // Insert `diff.insert`
    a === b // values match

### public TextAttributes: Object source

Attributes that can be assigned to a selection of text.

#### Example:

      {
        bold: true,
        font-size: '40px'
      }

### public encodable: number | string source

Anything that can be encoded with `JSON.stringify` and can be decoded with `JSON.parse`.

The following property should hold: `JSON.parse(JSON.stringify(key))===key`

At the moment the only safe values are number and string.