2020-10-22 18:34:49 +08:00
|
|
|
import { createExtension } from '@tiptap/core'
|
2020-09-26 05:22:21 +08:00
|
|
|
import {
|
2020-09-26 17:03:17 +08:00
|
|
|
redo, undo, ySyncPlugin, yUndoPlugin,
|
2020-09-26 05:22:21 +08:00
|
|
|
} from 'y-prosemirror'
|
2020-09-26 05:55:34 +08:00
|
|
|
|
2020-09-26 16:43:08 +08:00
|
|
|
export interface CollaborationOptions {
|
2020-09-26 17:03:17 +08:00
|
|
|
provider: any,
|
|
|
|
type: any,
|
2020-09-26 05:55:34 +08:00
|
|
|
}
|
2020-09-26 05:22:21 +08:00
|
|
|
|
2020-10-23 04:40:40 +08:00
|
|
|
const Collaboration = createExtension({
|
2020-10-22 18:34:49 +08:00
|
|
|
defaultOptions: <CollaborationOptions>{
|
2020-09-26 16:43:08 +08:00
|
|
|
provider: null,
|
|
|
|
type: null,
|
2020-10-22 18:34:49 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
addProseMirrorPlugins() {
|
|
|
|
return [
|
|
|
|
ySyncPlugin(this.options.type),
|
|
|
|
yUndoPlugin(),
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
addKeyboardShortcuts() {
|
2020-09-26 17:28:48 +08:00
|
|
|
return {
|
2020-09-26 05:55:34 +08:00
|
|
|
'Mod-z': undo,
|
|
|
|
'Mod-y': redo,
|
|
|
|
'Mod-Shift-z': redo,
|
2020-09-26 17:28:48 +08:00
|
|
|
}
|
2020-10-22 18:34:49 +08:00
|
|
|
},
|
|
|
|
})
|
2020-10-23 04:40:40 +08:00
|
|
|
|
|
|
|
export default Collaboration
|
|
|
|
|
|
|
|
declare module '@tiptap/core/src/Editor' {
|
|
|
|
interface AllExtensions {
|
|
|
|
Collaboration: typeof Collaboration,
|
|
|
|
}
|
|
|
|
}
|