estebanprimost / y-prosemirror

ProseMirror Binding for Yjs (v13)

Home Page:https://yjs-demos.now.sh/prosemirror/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

y-prosemirror

ProseMirror Binding for Yjs - Demo

This binding maps a Y.XmlFragment to the ProseMirror state.

Features

  • Sync ProseMirror state
  • Shared Cursors
  • Shared Undo / Redo (each client has its own undo-/redo-history)
  • Successfully recovers when concurrents edit result in an invalid document schema

Example

import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror'
import { exampleSetup } from 'prosemirror-example-setup'
import { keymap } from 'prosemirror-keymap'
..

const type = ydocument.get('prosemirror', Y.XmlFragment)

const prosemirrorView = new EditorView(document.querySelector('#editor'), {
  state: EditorState.create({
    schema,
    plugins: [
        ySyncPlugin(type),
        yCursorPlugin(provider.awareness),
        yUndoPlugin(),
        keymap({
          'Mod-z': undo,
          'Mod-y': redo,
          'Mod-Shift-z': redo
        })
      ].concat(exampleSetup({ schema }))
  })
})

Also look here for a working example.

License

The MIT License © Kevin Jahns

About

ProseMirror Binding for Yjs (v13)

https://yjs-demos.now.sh/prosemirror/

License:MIT License


Languages

Language:JavaScript 99.7%Language:HTML 0.3%