move history plugin to extension package

This commit is contained in:
Philipp Kühn
2018-08-25 21:33:06 +02:00
parent bf1a091c94
commit deb8cb33b0
21 changed files with 108 additions and 42 deletions

View File

@@ -20,6 +20,7 @@
"url": "https://github.com/heyscrumpy/tiptap/issues"
},
"dependencies": {
"prosemirror-history": "^1.0.2",
"tiptap": "^0.5.1",
"tiptap-commands": "^0.2.0"
}

View File

@@ -0,0 +1,30 @@
import { Extension } from 'tiptap'
import { history, undo, redo } from 'prosemirror-history'
export default class HistoryExtension extends Extension {
get name() {
return 'history'
}
keys() {
const isMac = typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false
const keymap = {
'Mod-z': undo,
'Shift-Mod-z': redo,
}
if (!isMac) {
keymap['Mod-y'] = redo
}
return keymap
}
get plugins() {
return [
history(),
]
}
}

View File

@@ -12,3 +12,5 @@ export { default as Bold } from './marks/Bold'
export { default as Code } from './marks/Code'
export { default as Italic } from './marks/Italic'
export { default as Link } from './marks/Link'
export { default as History } from './extensions/History'