tiptap/packages/extension-collaboration/index.ts

29 lines
526 B
TypeScript
Raw Normal View History

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