add basic history extension

This commit is contained in:
Philipp Kühn
2020-03-06 11:02:35 +01:00
parent cb6a723d57
commit f7b62be436
7 changed files with 85 additions and 3 deletions

View File

@@ -0,0 +1,43 @@
import Editor, { Extension } from '@tiptap/core'
import {
history,
undo,
redo,
undoDepth,
redoDepth,
} from 'prosemirror-history'
declare module '@tiptap/core/src/Editor' {
interface Editor {
undo(): Editor,
}
}
export default class History extends Extension {
name = 'history'
init() {
// @ts-ignore
this.editor.registerCommand('undo', (next, { view }) => {
undo(view.state, view.dispatch)
next()
})
}
get plugins() {
return [
history()
]
}
// commands() {
// return {
// undo: () => undo,
// redo: () => redo,
// undoDepth: () => undoDepth,
// redoDepth: () => redoDepth,
// }
// }
}