Files
outline/app/scenes/Document/components/Editor.js
Tom Moor d024d31f66 refactor: flow typing (#1012)
* fix: padding

* fix: Minor button alignment issues

* feat: Add icon to invite people button

* WIP
2019-08-08 23:09:09 -07:00

49 lines
973 B
JavaScript

// @flow
import * as React from 'react';
import Editor from 'components/Editor';
import ClickablePadding from 'components/ClickablePadding';
import plugins from './plugins';
type Props = {
defaultValue?: string,
readOnly?: boolean,
};
class DocumentEditor extends React.Component<Props> {
editor: ?Editor;
componentDidMount() {
if (!this.props.defaultValue) {
setImmediate(this.focusAtStart);
}
}
focusAtStart = () => {
if (this.editor) this.editor.focusAtStart();
};
focusAtEnd = () => {
if (this.editor) this.editor.focusAtEnd();
};
render() {
const { readOnly } = this.props;
return (
<React.Fragment>
<Editor
ref={ref => (this.editor = ref)}
plugins={plugins}
{...this.props}
/>
<ClickablePadding
onClick={!readOnly ? this.focusAtEnd : undefined}
grow
/>
</React.Fragment>
);
}
}
export default DocumentEditor;