Skip to content

Commit

Permalink
update prosemirror demo to use initProseMirrorState
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jun 25, 2024
1 parent 537f37b commit 888b14e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 39 deletions.
81 changes: 45 additions & 36 deletions prosemirror/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prosemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "UNLICENSE",
"dependencies": {
"yjs": "^13.5.8",
"y-prosemirror": "^1.0.5",
"y-prosemirror": "^1.2.8",
"y-websocket": "^1.3.15",
"prosemirror-example-setup": "^1.1.2",
"prosemirror-model": "^1.13.1",
Expand Down
6 changes: 4 additions & 2 deletions prosemirror/prosemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'
import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo } from 'y-prosemirror'
import { ySyncPlugin, yCursorPlugin, yUndoPlugin, undo, redo, initProseMirrorDoc } from 'y-prosemirror'
import { EditorState } from 'prosemirror-state'
import { EditorView } from 'prosemirror-view'
import { schema } from './schema.js'
Expand All @@ -23,11 +23,13 @@ window.addEventListener('load', () => {
editor.setAttribute('id', 'editor')
const editorContainer = document.createElement('div')
editorContainer.insertBefore(editor, null)
const { doc, mapping } = initProseMirrorDoc(yXmlFragment, schema)
const prosemirrorView = new EditorView(editor, {
state: EditorState.create({
doc,
schema,
plugins: [
ySyncPlugin(yXmlFragment),
ySyncPlugin(yXmlFragment, { mapping }),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
Expand Down

0 comments on commit 888b14e

Please sign in to comment.