Browse Source

enhance: g a to all pages, g g to graph view, g f to open flashcards

close #3393
Tienson Qin 4 years ago
parent
commit
f50b048776

+ 8 - 0
src/main/frontend/handler/route.cljs

@@ -27,6 +27,14 @@
    (when pub-event? (state/pub-event! [:redirect-to-home]))
    (redirect! {:to :home})))
 
+(defn redirect-to-all-pages!
+  []
+  (redirect! {:to :all-pages}))
+
+(defn redirect-to-graph-view!
+  []
+  (redirect! {:to :graph}))
+
 (defn redirect-to-page!
   ([page-name]
    (recent-handler/add-page-to-recent! (state/get-current-repo) page-name)

+ 28 - 5
src/main/frontend/modules/shortcut/config.cljs

@@ -285,8 +285,8 @@
                                     :binding "mod+k"
                                     :fn      #(route-handler/go-to-search! :global)}
 
-   :go/journals                    {:desc    "Jump to journals"
-                                    :binding (if mac? "mod+j" "alt+j")
+   :go/journals                    {:desc    "Go to journals"
+                                    :binding "g j"
                                     :fn      route-handler/go-to-journals!}
 
    :go/backward                    {:desc    "Backwards"
@@ -325,7 +325,16 @@
 
    :go/home                        {:desc    "Go to home"
                                     :binding "g h"
-                                    :fn      #(route-handler/redirect-to-home!)}
+                                    :fn      route-handler/redirect-to-home!}
+
+   :go/all-pages                   {:desc    "Go to all pages"
+                                    :binding "g a"
+                                    :fn      route-handler/redirect-to-all-pages!}
+
+   :go/graph-view                  {:desc    "Go to graph view"
+                                    :binding "g g"
+                                    :fn      route-handler/redirect-to-graph-view!}
+
 
    :go/keyboard-shortcuts          {:desc    "Go to keyboard shortcuts"
                                     :binding "g s"
@@ -343,6 +352,13 @@
                                     :binding "g p"
                                     :fn      journal-handler/go-to-prev-journal!}
 
+   :go/flashcards                  {:desc    "Toggle flashcards"
+                                    :binding "g f"
+                                    :fn      (fn []
+                                               (if (state/modal-opened?)
+                                                 (state/close-modal!)
+                                                 (state/pub-event! [:modal/show-cards])))}
+
    :ui/toggle-document-mode        {:desc    "Toggle document mode"
                                     :binding "t d"
                                     :fn      state/toggle-document-mode!}
@@ -367,8 +383,8 @@
                                      :binding "t t"
                                      :fn      state/toggle-theme!}
 
-   :ui/toggle-contents              {:desc    "Toggle Favorites in sidebar"
-                                     :binding "t f"
+   :ui/toggle-contents              {:desc    "Toggle Contents in sidebar"
+                                     :binding "mod+shift+c"
                                      :fn      ui-handler/toggle-contents!}
 
    :command/toggle-favorite         {:desc    "Add to/remove from favorites"
@@ -517,6 +533,10 @@
     (->
      (build-category-map [:command/run
                           :go/home
+                          :go/journals
+                          :go/all-pages
+                          :go/flashcards
+                          :go/graph-view
                           :go/keyboard-shortcuts
                           :go/tomorrow
                           :go/next-journal
@@ -633,6 +653,9 @@
    ^{:doc "Others"}
    [:go/home
     :go/journals
+    :go/all-pages
+    :go/graph-view
+    :go/flashcards
     :go/tomorrow
     :go/next-journal
     :go/prev-journal