|
@@ -1,7 +1,6 @@
|
|
|
(ns frontend.modules.shortcut.config
|
|
(ns frontend.modules.shortcut.config
|
|
|
(:require [clojure.data :as data]
|
|
(:require [clojure.data :as data]
|
|
|
[clojure.string :as string]
|
|
[clojure.string :as string]
|
|
|
- [electron.ipc :as ipc]
|
|
|
|
|
[frontend.commands :as commands]
|
|
[frontend.commands :as commands]
|
|
|
[frontend.components.commit :as commit]
|
|
[frontend.components.commit :as commit]
|
|
|
[frontend.config :as config]
|
|
[frontend.config :as config]
|
|
@@ -14,7 +13,6 @@
|
|
|
[frontend.handler.history :as history]
|
|
[frontend.handler.history :as history]
|
|
|
[frontend.handler.journal :as journal-handler]
|
|
[frontend.handler.journal :as journal-handler]
|
|
|
[frontend.handler.jump :as jump-handler]
|
|
[frontend.handler.jump :as jump-handler]
|
|
|
- [frontend.handler.notification :as notification]
|
|
|
|
|
[frontend.handler.page :as page-handler]
|
|
[frontend.handler.page :as page-handler]
|
|
|
[frontend.handler.paste :as paste-handler]
|
|
[frontend.handler.paste :as paste-handler]
|
|
|
[frontend.handler.plugin :as plugin-handler]
|
|
[frontend.handler.plugin :as plugin-handler]
|
|
@@ -27,8 +25,7 @@
|
|
|
[frontend.modules.shortcut.before :as m]
|
|
[frontend.modules.shortcut.before :as m]
|
|
|
[frontend.state :as state]
|
|
[frontend.state :as state]
|
|
|
[frontend.util :refer [mac?] :as util]
|
|
[frontend.util :refer [mac?] :as util]
|
|
|
- [medley.core :as medley]
|
|
|
|
|
- [promesa.core :as p]))
|
|
|
|
|
|
|
+ [medley.core :as medley]))
|
|
|
|
|
|
|
|
(defn- search
|
|
(defn- search
|
|
|
[mode]
|
|
[mode]
|
|
@@ -50,8 +47,6 @@
|
|
|
;; * :fn - Fn or a qualified keyword that represents a fn
|
|
;; * :fn - Fn or a qualified keyword that represents a fn
|
|
|
;; * :inactive - Optional boolean to disable a shortcut for certain conditions
|
|
;; * :inactive - Optional boolean to disable a shortcut for certain conditions
|
|
|
;; e.g. a given platform or feature condition
|
|
;; e.g. a given platform or feature condition
|
|
|
-;; * :file-graph? - Optional boolean to identify a command to only be run in file graphs
|
|
|
|
|
-;; and warned gracefully in db graphs
|
|
|
|
|
(def ^:large-vars/data-var all-built-in-keyboard-shortcuts
|
|
(def ^:large-vars/data-var all-built-in-keyboard-shortcuts
|
|
|
{:pdf/previous-page {:binding "alt+p"
|
|
{:pdf/previous-page {:binding "alt+p"
|
|
|
:fn pdf-utils/prev-page}
|
|
:fn pdf-utils/prev-page}
|
|
@@ -273,42 +268,35 @@
|
|
|
:fn #(state/pub-event! [:editor/toggle-own-number-list (state/get-selection-block-ids)])}
|
|
:fn #(state/pub-event! [:editor/toggle-own-number-list (state/get-selection-block-ids)])}
|
|
|
|
|
|
|
|
:editor/add-property {:binding (if mac? "mod+p" "ctrl+alt+p")
|
|
:editor/add-property {:binding (if mac? "mod+p" "ctrl+alt+p")
|
|
|
- :db-graph? true
|
|
|
|
|
:fn (fn [e]
|
|
:fn (fn [e]
|
|
|
(when e (util/stop e))
|
|
(when e (util/stop e))
|
|
|
(state/pub-event! [:editor/new-property {}]))}
|
|
(state/pub-event! [:editor/new-property {}]))}
|
|
|
:editor/set-tags {:binding "p t"
|
|
:editor/set-tags {:binding "p t"
|
|
|
- :db-graph? true
|
|
|
|
|
:selection? true
|
|
:selection? true
|
|
|
:fn (fn []
|
|
:fn (fn []
|
|
|
(state/pub-event! [:editor/new-property {:property-key "Tags"}]))}
|
|
(state/pub-event! [:editor/new-property {:property-key "Tags"}]))}
|
|
|
|
|
|
|
|
:editor/add-property-deadline {:binding "p d"
|
|
:editor/add-property-deadline {:binding "p d"
|
|
|
- :db-graph? true
|
|
|
|
|
:selection? true
|
|
:selection? true
|
|
|
:fn (fn []
|
|
:fn (fn []
|
|
|
(state/pub-event! [:editor/new-property {:property-key "Deadline"}]))}
|
|
(state/pub-event! [:editor/new-property {:property-key "Deadline"}]))}
|
|
|
|
|
|
|
|
:editor/add-property-status {:binding "p s"
|
|
:editor/add-property-status {:binding "p s"
|
|
|
- :db-graph? true
|
|
|
|
|
:selection? true
|
|
:selection? true
|
|
|
:fn (fn []
|
|
:fn (fn []
|
|
|
(state/pub-event! [:editor/new-property {:property-key "Status"}]))}
|
|
(state/pub-event! [:editor/new-property {:property-key "Status"}]))}
|
|
|
|
|
|
|
|
:editor/add-property-priority {:binding "p p"
|
|
:editor/add-property-priority {:binding "p p"
|
|
|
- :db-graph? true
|
|
|
|
|
:selection? true
|
|
:selection? true
|
|
|
:fn (fn []
|
|
:fn (fn []
|
|
|
(state/pub-event! [:editor/new-property {:property-key "Priority"}]))}
|
|
(state/pub-event! [:editor/new-property {:property-key "Priority"}]))}
|
|
|
|
|
|
|
|
:editor/add-property-icon {:binding "p i"
|
|
:editor/add-property-icon {:binding "p i"
|
|
|
- :db-graph? true
|
|
|
|
|
:selection? true
|
|
:selection? true
|
|
|
:fn (fn []
|
|
:fn (fn []
|
|
|
(state/pub-event! [:editor/new-property {:property-key "Icon"}]))}
|
|
(state/pub-event! [:editor/new-property {:property-key "Icon"}]))}
|
|
|
|
|
|
|
|
:editor/toggle-display-hidden-properties {:binding "p a"
|
|
:editor/toggle-display-hidden-properties {:binding "p a"
|
|
|
- :db-graph? true
|
|
|
|
|
:fn ui-handler/toggle-show-empty-hidden-properties!}
|
|
:fn ui-handler/toggle-show-empty-hidden-properties!}
|
|
|
|
|
|
|
|
:ui/toggle-brackets {:binding "t b"
|
|
:ui/toggle-brackets {:binding "t b"
|
|
@@ -390,12 +378,6 @@
|
|
|
:inactive (not (util/electron?))
|
|
:inactive (not (util/electron?))
|
|
|
:binding "mod+s"}
|
|
:binding "mod+s"}
|
|
|
|
|
|
|
|
- :graph/re-index {:fn (fn []
|
|
|
|
|
- (p/let [multiple-windows? (ipc/ipc "graphHasMultipleWindows" (state/get-current-repo))]
|
|
|
|
|
- (state/pub-event! [:graph/ask-for-re-index (atom multiple-windows?) nil])))
|
|
|
|
|
- :file-graph? true
|
|
|
|
|
- :binding []}
|
|
|
|
|
-
|
|
|
|
|
:command/run {:binding "mod+shift+1"
|
|
:command/run {:binding "mod+shift+1"
|
|
|
:inactive (not (util/electron?))
|
|
:inactive (not (util/electron?))
|
|
|
:fn #(do
|
|
:fn #(do
|
|
@@ -457,25 +439,10 @@
|
|
|
:fn page-handler/toggle-favorite!}
|
|
:fn page-handler/toggle-favorite!}
|
|
|
|
|
|
|
|
:editor/quick-add {:binding (if mac? "mod+e" "mod+alt+e")
|
|
:editor/quick-add {:binding (if mac? "mod+e" "mod+alt+e")
|
|
|
- :db-graph? true
|
|
|
|
|
:inactive config/publishing?
|
|
:inactive config/publishing?
|
|
|
:fn editor-handler/quick-add}
|
|
:fn editor-handler/quick-add}
|
|
|
:editor/jump {:binding "mod+j"
|
|
:editor/jump {:binding "mod+j"
|
|
|
:fn jump-handler/jump-to}
|
|
:fn jump-handler/jump-to}
|
|
|
- :editor/open-file-in-default-app {:binding "mod+d mod+a"
|
|
|
|
|
- :inactive (not (util/electron?))
|
|
|
|
|
- :file-graph? true
|
|
|
|
|
- :fn page-handler/open-file-in-default-app}
|
|
|
|
|
-
|
|
|
|
|
- :editor/open-file-in-directory {:binding "mod+d mod+i"
|
|
|
|
|
- :inactive (not (util/electron?))
|
|
|
|
|
- :file-graph? true
|
|
|
|
|
- :fn page-handler/open-file-in-directory}
|
|
|
|
|
-
|
|
|
|
|
- :editor/copy-current-file {:binding false
|
|
|
|
|
- :inactive (not (util/electron?))
|
|
|
|
|
- :file-graph? true
|
|
|
|
|
- :fn page-handler/copy-current-file}
|
|
|
|
|
|
|
|
|
|
:editor/copy-page-url {:binding []
|
|
:editor/copy-page-url {:binding []
|
|
|
:inactive (not (util/electron?))
|
|
:inactive (not (util/electron?))
|
|
@@ -541,31 +508,24 @@
|
|
|
:fn :frontend.handler.common.developer/show-page-ast}
|
|
:fn :frontend.handler.common.developer/show-page-ast}
|
|
|
|
|
|
|
|
:misc/export-block-data {:binding []
|
|
:misc/export-block-data {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:fn :frontend.handler.db-based.export/export-block-data}
|
|
:fn :frontend.handler.db-based.export/export-block-data}
|
|
|
|
|
|
|
|
:misc/export-page-data {:binding []
|
|
:misc/export-page-data {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:fn :frontend.handler.db-based.export/export-page-data}
|
|
:fn :frontend.handler.db-based.export/export-page-data}
|
|
|
|
|
|
|
|
:misc/export-graph-ontology-data {:binding []
|
|
:misc/export-graph-ontology-data {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:fn :frontend.handler.db-based.export/export-graph-ontology-data}
|
|
:fn :frontend.handler.db-based.export/export-graph-ontology-data}
|
|
|
|
|
|
|
|
:misc/import-edn-data {:binding []
|
|
:misc/import-edn-data {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:fn :frontend.handler.db-based.import/import-edn-data-dialog}
|
|
:fn :frontend.handler.db-based.import/import-edn-data-dialog}
|
|
|
|
|
|
|
|
:dev/validate-db {:binding []
|
|
:dev/validate-db {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:inactive (not (state/developer-mode?))
|
|
:inactive (not (state/developer-mode?))
|
|
|
:fn :frontend.handler.common.developer/validate-db}
|
|
:fn :frontend.handler.common.developer/validate-db}
|
|
|
:dev/rtc-stop {:binding []
|
|
:dev/rtc-stop {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:inactive (not (state/developer-mode?))
|
|
:inactive (not (state/developer-mode?))
|
|
|
:fn :frontend.handler.common.developer/rtc-stop}
|
|
:fn :frontend.handler.common.developer/rtc-stop}
|
|
|
:dev/rtc-start {:binding []
|
|
:dev/rtc-start {:binding []
|
|
|
- :db-graph? true
|
|
|
|
|
:inactive (not (state/developer-mode?))
|
|
:inactive (not (state/developer-mode?))
|
|
|
:fn :frontend.handler.common.developer/rtc-start}})
|
|
:fn :frontend.handler.common.developer/rtc-start}})
|
|
|
|
|
|
|
@@ -591,24 +551,6 @@
|
|
|
(resolved-fn)
|
|
(resolved-fn)
|
|
|
(throw (ex-info (str "Unable to resolve " keyword-fn " to a fn") {})))))
|
|
(throw (ex-info (str "Unable to resolve " keyword-fn " to a fn") {})))))
|
|
|
|
|
|
|
|
-(defn- wrap-fn-with-db-graph-only-warning
|
|
|
|
|
- "Wraps DB graph only commands so they are only run in DB graphs and warned
|
|
|
|
|
- when in file graphs"
|
|
|
|
|
- [f]
|
|
|
|
|
- (fn []
|
|
|
|
|
- (if (config/db-based-graph? (state/get-current-repo))
|
|
|
|
|
- (f)
|
|
|
|
|
- (notification/show! "This command is only for DB graphs." :warning true nil 3000))))
|
|
|
|
|
-
|
|
|
|
|
-(defn- wrap-fn-with-file-graph-only-warning
|
|
|
|
|
- "Wraps file graph only commands so they are only run in file graphs and warned
|
|
|
|
|
- when in DB graphs"
|
|
|
|
|
- [f]
|
|
|
|
|
- (fn []
|
|
|
|
|
- (if (config/db-based-graph? (state/get-current-repo))
|
|
|
|
|
- (notification/show! "This command is only for file graphs." :warning true nil 3000)
|
|
|
|
|
- (f))))
|
|
|
|
|
-
|
|
|
|
|
(defn build-category-map [ks]
|
|
(defn build-category-map [ks]
|
|
|
(->> (if (sequential? ks)
|
|
(->> (if (sequential? ks)
|
|
|
ks (let [{:keys [ns includes excludes]} ks]
|
|
ks (let [{:keys [ns includes excludes]} ks]
|
|
@@ -626,13 +568,6 @@
|
|
|
[k (if (keyword? (:fn v))
|
|
[k (if (keyword? (:fn v))
|
|
|
(assoc v :fn (resolve-fn (:fn v)))
|
|
(assoc v :fn (resolve-fn (:fn v)))
|
|
|
v)]))
|
|
v)]))
|
|
|
- (map (fn [[k v]]
|
|
|
|
|
- [k (cond (:file-graph? v)
|
|
|
|
|
- (update v :fn wrap-fn-with-file-graph-only-warning)
|
|
|
|
|
- (:db-graph? v)
|
|
|
|
|
- (update v :fn wrap-fn-with-db-graph-only-warning)
|
|
|
|
|
- :else
|
|
|
|
|
- v)]))
|
|
|
|
|
(into {})))
|
|
(into {})))
|
|
|
|
|
|
|
|
;; This is the only var that should be publicly expose :fn functionality
|
|
;; This is the only var that should be publicly expose :fn functionality
|
|
@@ -690,7 +625,6 @@
|
|
|
:graph/add
|
|
:graph/add
|
|
|
:graph/db-add
|
|
:graph/db-add
|
|
|
:graph/db-save
|
|
:graph/db-save
|
|
|
- :graph/re-index
|
|
|
|
|
:editor/cycle-todo
|
|
:editor/cycle-todo
|
|
|
:editor/up
|
|
:editor/up
|
|
|
:editor/down
|
|
:editor/down
|
|
@@ -765,9 +699,6 @@
|
|
|
:ui/toggle-help
|
|
:ui/toggle-help
|
|
|
:ui/toggle-theme
|
|
:ui/toggle-theme
|
|
|
:ui/toggle-contents
|
|
:ui/toggle-contents
|
|
|
- :editor/open-file-in-default-app
|
|
|
|
|
- :editor/open-file-in-directory
|
|
|
|
|
- :editor/copy-current-file
|
|
|
|
|
:editor/copy-page-url
|
|
:editor/copy-page-url
|
|
|
:editor/set-tags
|
|
:editor/set-tags
|
|
|
:editor/add-property-deadline
|
|
:editor/add-property-deadline
|
|
@@ -935,14 +866,11 @@
|
|
|
:graph/open
|
|
:graph/open
|
|
|
:graph/remove
|
|
:graph/remove
|
|
|
:graph/add
|
|
:graph/add
|
|
|
- :graph/re-index
|
|
|
|
|
:sidebar/close-top
|
|
:sidebar/close-top
|
|
|
:sidebar/clear
|
|
:sidebar/clear
|
|
|
:sidebar/open-today-page
|
|
:sidebar/open-today-page
|
|
|
:search/re-index
|
|
:search/re-index
|
|
|
:editor/insert-youtube-timestamp
|
|
:editor/insert-youtube-timestamp
|
|
|
- :editor/open-file-in-default-app
|
|
|
|
|
- :editor/open-file-in-directory
|
|
|
|
|
:editor/copy-page-url
|
|
:editor/copy-page-url
|
|
|
:window/close
|
|
:window/close
|
|
|
:auto-complete/prev
|
|
:auto-complete/prev
|