浏览代码

Add command to copy current file

Gabriel Horner 3 年之前
父节点
当前提交
6e1708b7ba
共有 2 个文件被更改,包括 11 次插入1 次删除
  1. 4 0
      src/main/frontend/handler/page.cljs
  2. 7 1
      src/main/frontend/modules/shortcut/config.cljs

+ 4 - 0
src/main/frontend/handler/page.cljs

@@ -756,6 +756,10 @@
   (when-let [file-path (and (util/electron?) (get-page-file-path))]
     (js/window.apis.openPath file-path)))
 
+(defn copy-current-file []
+  (when-let [file-path (and (util/electron?) (get-page-file-path))]
+    (util/copy-to-clipboard! file-path)))
+
 (defn open-file-in-directory []
   (when-let [file-path (and (util/electron?) (get-page-file-path))]
     (js/window.apis.showItemInFolder file-path)))

+ 7 - 1
src/main/frontend/modules/shortcut/config.cljs

@@ -18,7 +18,7 @@
             [medley.core :as medley]))
 
 ;; Note – when you change this file, you will need to do a hard reset.
-;; The commands are registered when the Clojurescript code runs for the fir
+;; The commands are registered when the Clojurescript code runs for the first time
 (defonce all-default-keyboard-shortcuts
   {:date-picker/complete         {:desc    "Date picker: Choose selected day"
                                   :binding "enter"
@@ -406,6 +406,11 @@
                                        :binding false
                                        :fn      page-handler/open-file-in-directory})
 
+   :editor/copy-current-file        (when (util/electron?)
+                                      {:desc    "Copy current file"
+                                       :binding false
+                                       :fn      page-handler/copy-current-file})
+
    :ui/toggle-wide-mode             {:desc    "Toggle wide mode"
                                      :binding "t w"
                                      :fn      ui-handler/toggle-wide-mode!}
@@ -559,6 +564,7 @@
                           :ui/open-new-window
                           :editor/open-file-in-default-app
                           :editor/open-file-in-directory
+                          :editor/copy-current-file
                           :ui/toggle-wide-mode
                           :ui/select-theme-color
                           :ui/goto-plugins