Reset editor when entering new document view

This commit is contained in:
Jori Lallo
2016-06-05 19:31:08 -07:00
parent 984140c3ca
commit 3b09d85da8
2 changed files with 8 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ const cx = classNames.bind(styles);
class DocumentEdit extends Component {
componentDidMount = () => {
// This is a bit hacky, should find a better way
store.reset();
if (this.props.route.newDocument) {
store.atlasId = this.props.params.id;
store.newDocument = true;

View File

@@ -17,8 +17,8 @@ const parseHeader = (text) => {
const documentEditStore = new class DocumentEditStore {
@observable documentId = null;
@observable atlasId = null;
@observable title = 'Lets start with a title';
@observable text = '# Lets start with a title\n\nAnd continue from there...';
@observable title;
@observable text;
@observable newDocument;
@observable preview;
@@ -97,6 +97,11 @@ const documentEditStore = new class DocumentEditStore {
this.preview = !this.preview;
}
@action reset = () => {
this.title = 'Lets start with a title';
this.text = '# Lets start with a title\n\nAnd continue from there...';
}
constructor() {
// Rehydrate settings
localforage.getItem(DOCUMENT_EDIT_SETTINGS)