add new collaboration cursor plugin
This commit is contained in:
27
packages/extension-collaboration-cursor/index.ts
Normal file
27
packages/extension-collaboration-cursor/index.ts
Normal 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()
|
||||
Reference in New Issue
Block a user