Yjs binding configuration

Hierarchy

  • YSyncConfig

Constructors

Properties

Methods

Constructors

  • Create a new binding configuration

    Parameters

    • ytext: YText

      Yjs text to synchronize

    Returns YSyncConfig

Properties

ytext: YText

Methods

  • Parameters

    Returns {
        assoc: number;
        pos: number;
    }

    • assoc: number
    • pos: number
  • Helper function to transform an absolute index position to a Yjs-based relative position (https://docs.yjs.dev/api/relative-positions).

    A relative position can be transformed back to an absolute position even after the document has changed. The position is automatically adapted. This does not require any position transformations. Relative positions are computed based on the internal Yjs document model. Peers that share content through Yjs are guaranteed that their positions will always synced up when using relative positions.

    import { ySyncFacet } from 'y-codemirror'

    ..
    const ysync = view.state.facet(ySyncFacet)
    // transform an absolute index position to a ypos
    const ypos = ysync.getYPos(3)
    // transform the ypos back to an absolute position
    ysync.fromYPos(ypos) // => 3

    It cannot be guaranteed that absolute index positions can be synced up between peers. This might lead to undesired behavior when implementing features that require that all peers see the same marked range (e.g. a comment plugin).

    Parameters

    • pos: number
    • Optional assoc: number

    Returns RelativePosition

  • Parameters

    Returns YRange

Generated using TypeDoc