@ -155,6 +155,14 @@ class DocumentScene extends React.Component<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
@keydown('meta+shift+p')
|
||||
onPublish(ev) {
|
||||
ev.preventDefault();
|
||||
if (!this.document) return;
|
||||
if (this.document.publishedAt) return;
|
||||
this.onSave({ publish: true, done: true });
|
||||
}
|
||||
|
||||
loadDocument = async props => {
|
||||
const { shareId, revisionId } = props.match.params;
|
||||
|
||||
@ -409,6 +417,7 @@ class DocumentScene extends React.Component<Props> {
|
||||
onSearchLink={this.onSearchLink}
|
||||
onChange={this.onChange}
|
||||
onSave={this.onSave}
|
||||
onPublish={this.onPublish}
|
||||
onCancel={this.onDiscard}
|
||||
readOnly={!this.isEditing || document.isArchived}
|
||||
toc={!revision}
|
||||
|
@ -189,6 +189,12 @@ class Header extends React.Component<Props> {
|
||||
{can.update &&
|
||||
isDraft && (
|
||||
<Action>
|
||||
<Tooltip
|
||||
tooltip="Publish"
|
||||
shortcut={`${meta}+shift+p`}
|
||||
delay={500}
|
||||
placement="bottom"
|
||||
>
|
||||
<Button
|
||||
onClick={this.handlePublish}
|
||||
title="Publish document"
|
||||
@ -197,6 +203,7 @@ class Header extends React.Component<Props> {
|
||||
>
|
||||
{isPublishing ? 'Publishing…' : 'Publish'}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Action>
|
||||
)}
|
||||
{canEdit && (
|
||||
|
@ -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();
|
||||
},
|
||||
},
|
||||
];
|
||||
|
Reference in New Issue
Block a user