How to use the y-protocols/history.js.writeHistorySnapshot function in y-protocols

To help you get started, we’ve selected a few y-protocols examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yjs / yjs / examples / prosemirror-history.js View on Github external
snapshot (updatedUserMap = new Map()) {
    const y = prosemirrorPluginKey.getState(this.editorView.state).y
    const history = y.define('history', Y.Array)
    const encoder = encoding.createEncoder()
    historyProtocol.writeHistorySnapshot(encoder, y, updatedUserMap)
    encoding.writeUint32(encoder, Math.floor(Date.now() / 1000))
    history.push([encoding.toUint8Array(encoder)])
  }
}