mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-19 13:47:51 +08:00
28 lines
654 B
TypeScript
28 lines
654 B
TypeScript
|
import { Extension } from '@tiptap/core'
|
||
|
import { keymap } from 'prosemirror-keymap'
|
||
|
import {
|
||
|
redo, undo, yCursorPlugin, ySyncPlugin, yUndoPlugin,
|
||
|
} from 'y-prosemirror'
|
||
|
import { WebrtcProvider } from 'y-webrtc'
|
||
|
import * as Y from 'yjs'
|
||
|
|
||
|
const ydoc = new Y.Doc()
|
||
|
const provider = new WebrtcProvider('tiptap', ydoc)
|
||
|
const type = ydoc.getXmlFragment('prosemirror')
|
||
|
|
||
|
export default new Extension()
|
||
|
.name('yjs')
|
||
|
.plugins(() => {
|
||
|
return [
|
||
|
ySyncPlugin(type),
|
||
|
yCursorPlugin(provider.awareness),
|
||
|
yUndoPlugin(),
|
||
|
keymap({
|
||
|
'Mod-z': undo,
|
||
|
'Mod-y': redo,
|
||
|
'Mod-Shift-z': redo,
|
||
|
}),
|
||
|
]
|
||
|
})
|
||
|
.create()
|