'e' to Edit Shortcut
authorAdam Dullage <redacted>
Thu, 17 Feb 2022 13:16:37 +0000 (13:16 +0000)
committerAdam Dullage <redacted>
Thu, 17 Feb 2022 13:16:37 +0000 (13:16 +0000)
README.md
flatnotes/src/components/App.js

index 2c1d3594447c29d9ff4a88f70b983627b852ed30..29fb72fc1954550e403f9d4c15fc7b4f0094205a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -35,10 +35,10 @@ This is what flatnotes aims to achieve.
 * [x] Ability to Create a Note
 * [x] Ability to Rename a Note
 * [x] Routing
+* [x] e to edit
 * [ ] Loading & Not Found Indicators
 * [ ] Ability to Delete a Note
 * [ ] / to search
-* [ ] e to edit
 * [ ] CTRL-S to save
 * [ ] Drafts
 * [ ] Image Embedding
index 393c7e1eef69d07f65c6e5cd593c9c3dca800958..675517a337f2d46f47da9252118939b743c83fb2 100644 (file)
@@ -228,10 +228,34 @@ export default {
       history.replaceState(null, "", this.currentNote.href);
       this.toggleEditMode();
     },
+
+    keyboardShortcuts: function(e) {
+      // 'e' to Edit
+      if (
+        e.key == "e" &&
+        this.currentView == this.views.note &&
+        this.editMode == false
+      ) {
+        e.preventDefault();
+        this.toggleEditMode();
+      }
+
+      // 'CTRL + s' to Save
+      // else if (
+      //   e.key == "s" &&
+      //   e.ctrlKey == true &&
+      //   this.currentView == this.views.note &&
+      //   this.editMode == true
+      // ) {
+      //   e.preventDefault();
+      //   this.saveNote();
+      // }
+    },
   },
 
   created: function() {
     EventBus.$on("logout", this.logout);
+    document.addEventListener("keydown", this.keyboardShortcuts);
 
     let token = localStorage.getItem("token");
     if (token != null) {
git clone https://git.99rst.org/PROJECT