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 { class DocumentEdit extends Component {
componentDidMount = () => { componentDidMount = () => {
// This is a bit hacky, should find a better way // This is a bit hacky, should find a better way
store.reset();
if (this.props.route.newDocument) { if (this.props.route.newDocument) {
store.atlasId = this.props.params.id; store.atlasId = this.props.params.id;
store.newDocument = true; store.newDocument = true;

View File

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