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,
// }
// }
}

View File

@@ -0,0 +1,20 @@
{
"name": "@tiptap/history-extension",
"version": "1.0.0",
"source": "index.ts",
"main": "dist/tiptap-history-extension.js",
"umd:main": "dist/tiptap-history-extension.umd.js",
"module": "dist/tiptap-history-extension.mjs",
"unpkg": "dist/tiptap-history-extension.js",
"jsdelivr": "dist/tiptap-history-extension.js",
"files": [
"src",
"dist"
],
"peerDependencies": {
"@tiptap/core": "2.x"
},
"dependencies": {
"prosemirror-history": "^1.1.3"
}
}