* [x] Routing
* [x] e to edit
* [x] Ability to Delete a Note
-* [ ] Exclude extension when renaming
+* [x] Exclude extension when renaming
* [ ] Loading & Not Found Indicators
* [ ] / to search
* [ ] CTRL-S to save
searchTimeout: null,
searchResults: null,
currentNote: null,
- newFilename: null,
+ titleInput: null,
editMode: false,
};
},
response.data.lastModified,
response.data.content
);
- parent.newFilename = parent.currentNote.filename;
+ parent.titleInput = parent.currentNote.title;
parent.updateDocumentTitle();
});
},
if (this.currentNote.lastModified == null) {
api
.post(`/api/notes`, {
- filename: this.newFilename,
+ filename: `${this.titleInput}.${constants.markdownExt}`,
content: newContent,
})
.then(this.saveNoteResponseHandler);
// Modified Note
else if (
newContent != this.currentNote.content ||
- this.newFilename != this.currentNote.filename
+ this.titleInput != this.currentNote.title
) {
api
.patch(`/api/notes/${this.currentNote.filename}`, {
- newFilename: this.newFilename,
+ newFilename: `${this.titleInput}.${this.currentNote.ext}`,
newContent: newContent,
})
.then(this.saveNoteResponseHandler);
response.data.lastModified,
response.data.content
);
- this.newFilename = this.currentNote.filename;
+ this.titleInput = this.currentNote.title;
this.updateDocumentTitle();
history.replaceState(null, "", this.currentNote.href);
this.toggleEditMode();
}
get title() {
- return this.filename.slice(0, -3);
+ return this.filename.substring(0, this.filename.lastIndexOf("."));
+ }
+
+ get ext() {
+ return this.filename.substring(this.filename.lastIndexOf(".") + 1);
}
get href() {
- return `/${constants.basePaths.note}/${this.title}`
+ return `/${constants.basePaths.note}/${this.title}`;
}
}