add basic yjs extension with baked in web rtc support (wip)
This commit is contained in:
27
packages/extension-yjs/index.ts
Normal file
27
packages/extension-yjs/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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()
|
||||
22
packages/extension-yjs/package.json
Normal file
22
packages/extension-yjs/package.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@tiptap/extension-yjs",
|
||||
"version": "1.0.0",
|
||||
"source": "index.ts",
|
||||
"main": "dist/tiptap-extension-yjs.js",
|
||||
"umd:main": "dist/tiptap-extension-yjs.umd.js",
|
||||
"module": "dist/tiptap-extension-yjs.mjs",
|
||||
"unpkg": "dist/tiptap-extension-yjs.js",
|
||||
"jsdelivr": "dist/tiptap-extension-yjs.js",
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@tiptap/core": "2.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"y-prosemirror": "^0.3.7",
|
||||
"y-webrtc": "^10.1.6",
|
||||
"yjs": "^13.3.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user