Files
outline/app/scenes/Document/components/Editor.js
Tom Moor 293c3b7b9c fix: Move references spacing directly below content (#1113)
* fix: Move references spacing directly below content

* Child document -> Nested document
2019-12-18 21:00:36 -08:00

47 lines
963 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}
grow={!readOnly}
{...this.props}
/>
{!readOnly && <ClickablePadding onClick={this.focusAtEnd} grow />}
</React.Fragment>
);
}
}
export default DocumentEditor;