add Commands interface
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Extension, Command } from '@tiptap/core'
|
||||
import { Extension, Command, AnyObject } from '@tiptap/core'
|
||||
import { yCursorPlugin } from 'y-prosemirror'
|
||||
|
||||
export interface CollaborationCursorOptions {
|
||||
@@ -8,6 +8,12 @@ export interface CollaborationCursorOptions {
|
||||
onUpdate: (users: { clientId: string, [key: string]: any }[]) => null,
|
||||
}
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
user: (attributes: AnyObject) => Command,
|
||||
}
|
||||
}
|
||||
|
||||
const awarenessStatesToArray = (states: Map<number, { [key: string]: any }>) => {
|
||||
return Array.from(states.entries()).map(([key, value]) => {
|
||||
return {
|
||||
@@ -47,7 +53,7 @@ export const CollaborationCursor = Extension.create({
|
||||
/**
|
||||
* Update details of the current user
|
||||
*/
|
||||
user: (attributes: { [key: string]: any }): Command => () => {
|
||||
user: attributes => () => {
|
||||
this.options.user = attributes
|
||||
|
||||
this.options.provider.awareness.setLocalStateField('user', this.options.user)
|
||||
@@ -87,9 +93,3 @@ export const CollaborationCursor = Extension.create({
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface AllExtensions {
|
||||
CollaborationCursor: typeof CollaborationCursor,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user