Reset editor when entering new document view
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user