add new collaboration cursor plugin

This commit is contained in:
Hans Pagel
2020-09-26 11:03:17 +02:00
parent 90f127b8a6
commit 6190380e75
4 changed files with 69 additions and 22 deletions

View File

@@ -0,0 +1,27 @@
import { Extension } from '@tiptap/core'
import { yCursorPlugin } from 'y-prosemirror'
export interface CollaborationCursorOptions {
name: string,
color: string,
provider: any,
}
export default new Extension<CollaborationCursorOptions>()
.name('collaboration_cursor')
.defaults({
provider: null,
name: 'Someone',
color: '#cccccc',
})
.plugins(({ options }) => [
yCursorPlugin((() => {
options.provider.awareness.setLocalStateField('user', {
name: options.name,
color: options.color,
})
return options.provider.awareness
})()),
])
.create()