Add 'n' shortcut for new doc

Fixed cmd+enter shortcut to publish doc
Fixed keyboard shortcut display on non-mac
Fixed heading alignment
Fixed documents smaller than page should not scroll
This commit is contained in:
Tom Moor
2019-03-09 20:00:45 -08:00
parent f75783c2f1
commit fc7c485ba9
10 changed files with 53 additions and 20 deletions

View File

@@ -1,8 +1,11 @@
// @flow
import * as React from 'react';
import { observer, inject } from 'mobx-react';
import { withRouter } from 'react-router-dom';
import keydown from 'react-keydown';
import Flex from 'shared/components/Flex';
import { PlusIcon } from 'outline-icons';
import { newDocumentUrl } from 'utils/routeHelpers';
import Header from './Header';
import SidebarLink from './SidebarLink';
@@ -14,6 +17,7 @@ import UiStore from 'stores/UiStore';
import DocumentsStore from 'stores/DocumentsStore';
type Props = {
history: Object,
collections: CollectionsStore,
documents: DocumentsStore,
onCreateCollection: () => void,
@@ -28,8 +32,17 @@ class Collections extends React.Component<Props> {
this.props.collections.fetchPage({ limit: 100 });
}
@keydown('n')
goToNewDocument() {
const activeCollection = this.props.collections.active;
if (!activeCollection) return;
this.props.history.push(newDocumentUrl(activeCollection));
}
render() {
const { collections, ui, documents } = this.props;
const content = (
<Flex column>
<Header>Collections</Header>
@@ -57,4 +70,6 @@ class Collections extends React.Component<Props> {
}
}
export default inject('collections', 'ui', 'documents')(Collections);
export default inject('collections', 'ui', 'documents')(
withRouter(Collections)
);