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 {
|
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;
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user