* WIP: Slate editor
* WIP
* Focus at start / end working
* ah ha
* Super basic floating toolbar
* Nested list editing
* Pulling more logic into plugins
* inline code markdown
* Backspace at end of code block should remove mark
* Ensure there is always an empty line at editor end
* Add keyboard shortcuts for bold, italic, underline
* Add strikethrough shortcode and toolbar
* Toolbar to declarative
Fixed paragraph styling
Removed unused stuffs
* Super basic link editing
* Split Toolbar, now possible to edit and remove links
* Add new link to selection from toolbar working
* Ensure toolbar doesn't extend off screen
* Fix minor js issues, disable formatting of document title
* Boom, icons
* Remove codemirror, fix MD parsing issues
* CMD+S now saves inplace
* Add --- shortcut for horizontal rule
* Improved styling for link editor
* Add header anchors in readOnly
* More readable core text color
* Restored image file uploading 🎉
* Add support for inline md syntax, ** __ etc
* Centered
* Flooooow
* Checklist support
* Upgrade edit list plugin
* Finally. Allow keydown within rich textarea
* Update Markdown serializer
* Cleanup, remove async editor loading
* Editor > MarkdownEditor
Fixed unsaved changes warning triggered when all changes are saved
* MOAR typing
* Combine edit and view
* Fixed checkboxes still editable in readOnly
* wip
* Breadcrumb
Restored scroll
* Move document scene actions to menu
* Added: Support for code blocks, syntax highlighting
* Cleanup
* > styled component
* Prevent CMD+Enter from adding linebreak
* Show image uploading in layout activity indicator
* Upgrade editor deps
* Improve link toolbar. Only one scenario where it's not working now
122 lines
3.3 KiB
JavaScript
122 lines
3.3 KiB
JavaScript
// @flow
|
|
import React from 'react';
|
|
import { browserHistory, Link } from 'react-router';
|
|
import Helmet from 'react-helmet';
|
|
import styled from 'styled-components';
|
|
import { observer, inject } from 'mobx-react';
|
|
import _ from 'lodash';
|
|
import keydown from 'react-keydown';
|
|
import classNames from 'classnames/bind';
|
|
import searchIcon from 'assets/icons/search.svg';
|
|
import { Flex } from 'reflexbox';
|
|
import styles from './Layout.scss';
|
|
import DropdownMenu, { MenuItem } from 'components/DropdownMenu';
|
|
import LoadingIndicator from 'components/LoadingIndicator';
|
|
import UserStore from 'stores/UserStore';
|
|
|
|
const cx = classNames.bind(styles);
|
|
|
|
type Props = {
|
|
children?: ?React.Element<any>,
|
|
actions?: ?React.Element<any>,
|
|
title?: ?React.Element<any>,
|
|
titleText?: string,
|
|
loading?: boolean,
|
|
user: UserStore,
|
|
search: ?boolean,
|
|
notifications?: React.Element<any>,
|
|
};
|
|
|
|
@observer class Layout extends React.Component {
|
|
props: Props;
|
|
|
|
static defaultProps = {
|
|
search: true,
|
|
};
|
|
|
|
@keydown(['/', 't'])
|
|
search() {
|
|
// if (!this.props.user) return;
|
|
_.defer(() => browserHistory.push('/search'));
|
|
}
|
|
|
|
@keydown(['d'])
|
|
dashboard() {
|
|
// if (!this.props.user) return;
|
|
_.defer(() => browserHistory.push('/'));
|
|
}
|
|
|
|
render() {
|
|
const user = this.props.user;
|
|
|
|
return (
|
|
<div className={styles.container}>
|
|
<Helmet
|
|
title={
|
|
this.props.titleText ? `${this.props.titleText} - Atlas` : 'Atlas'
|
|
}
|
|
meta={[
|
|
{
|
|
name: 'viewport',
|
|
content: 'width=device-width, initial-scale=1.0',
|
|
},
|
|
]}
|
|
/>
|
|
|
|
{this.props.loading && <LoadingIndicator />}
|
|
|
|
{this.props.notifications}
|
|
|
|
<div className={cx(styles.header)}>
|
|
<div className={styles.headerLeft}>
|
|
<Link to="/" className={styles.team}>Atlas</Link>
|
|
<span className={styles.title}>
|
|
{this.props.title}
|
|
</span>
|
|
</div>
|
|
<Flex className={styles.headerRight}>
|
|
<Flex>
|
|
<Flex align="center" className={styles.actions}>
|
|
{this.props.actions}
|
|
</Flex>
|
|
{user.user &&
|
|
<Flex>
|
|
{this.props.search &&
|
|
<Flex>
|
|
<div
|
|
onClick={this.search}
|
|
className={styles.search}
|
|
title="Search (/)"
|
|
>
|
|
<img src={searchIcon} alt="Search" />
|
|
</div>
|
|
</Flex>}
|
|
<DropdownMenu label={<Avatar src={user.user.avatarUrl} />}>
|
|
<MenuItem to="/settings">Settings</MenuItem>
|
|
<MenuItem to="/keyboard-shortcuts">
|
|
Keyboard shortcuts
|
|
</MenuItem>
|
|
<MenuItem to="/developers">API</MenuItem>
|
|
<MenuItem onClick={user.logout}>Logout</MenuItem>
|
|
</DropdownMenu>
|
|
</Flex>}
|
|
</Flex>
|
|
</Flex>
|
|
</div>
|
|
|
|
<div className={cx(styles.content)}>
|
|
{this.props.children}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
const Avatar = styled.img`
|
|
width: 24px;
|
|
height: 24px;
|
|
border-radius: 50%;
|
|
`;
|
|
|
|
export default inject('user')(Layout);
|