feat: Add keyboard shortcut to publish document

closes #1073
This commit is contained in:
Tom Moor
2019-10-27 18:04:35 -07:00
parent 98cd93c99c
commit 9ef9c75c6b
3 changed files with 33 additions and 7 deletions

View File

@ -1,6 +1,7 @@
// @flow
import { Node, Editor } from 'slate';
import Placeholder from 'rich-markdown-editor/lib/plugins/Placeholder';
import isModKey from 'rich-markdown-editor/lib/lib/isModKey';
export default [
Placeholder({
@ -25,4 +26,13 @@ export default [
return true;
},
}),
{
onKeyDown(ev: SyntheticKeyboardEvent<>, editor: Editor, next: Function) {
if (ev.key === 'p' && ev.shiftKey && isModKey(ev)) {
return editor.props.onPublish(ev);
}
return next();
},
},
];