2020-09-26 05:22:21 +08:00
|
|
|
import { Extension } from '@tiptap/core'
|
|
|
|
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
|
|
|
import { keymap } from 'prosemirror-keymap'
|
|
|
|
|
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-09-26 16:43:08 +08:00
|
|
|
export default new Extension<CollaborationOptions>()
|
|
|
|
.name('collaboration')
|
2020-09-26 05:55:34 +08:00
|
|
|
.defaults({
|
2020-09-26 16:43:08 +08:00
|
|
|
provider: null,
|
|
|
|
type: null,
|
2020-09-26 05:22:21 +08:00
|
|
|
})
|
2020-09-26 05:55:34 +08:00
|
|
|
.plugins(({ options }) => [
|
2020-09-26 17:03:17 +08:00
|
|
|
ySyncPlugin(options.type),
|
2020-09-26 05:55:34 +08:00
|
|
|
yUndoPlugin(),
|
|
|
|
keymap({
|
|
|
|
'Mod-z': undo,
|
|
|
|
'Mod-y': redo,
|
|
|
|
'Mod-Shift-z': redo,
|
|
|
|
}),
|
|
|
|
])
|
2020-09-26 05:22:21 +08:00
|
|
|
.create()
|