mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-30 13:07:49 +08:00
28 lines
615 B
TypeScript
28 lines
615 B
TypeScript
|
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()
|