Skip to content

Commit

Permalink
add initProseMirrorState info to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jun 25, 2024
1 parent 150bcfb commit 8f48d63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ This binding maps a Y.XmlFragment to the ProseMirror state.
### Example

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

const type = ydocument.get('prosemirror', Y.XmlFragment)
const { doc, mapping } = initProseMirrorDoc(type, schema)

const prosemirrorView = new EditorView(document.querySelector('#editor'), {
state: EditorState.create({
doc,
schema,
plugins: [
ySyncPlugin(type),
ySyncPlugin(type, { mapping }),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
Expand Down

0 comments on commit 8f48d63

Please sign in to comment.