mirror of https://github.com/logseq/logseq
fix(fs): use rpath for more page path commands
parent
4419a7ee7e
commit
5d4dcff492
|
@ -73,7 +73,7 @@
|
|||
favorited? (contains? (set (map util/page-name-sanity-lc favorites))
|
||||
page-name)
|
||||
developer-mode? (state/sub [:ui/developer-mode?])
|
||||
file-path (when (util/electron?) (page-util/get-page-file-path page-name))
|
||||
file-rpath (when (util/electron?) (page-util/get-page-file-rpath page-name))
|
||||
_ (state/sub :auth/id-token)
|
||||
file-sync-graph-uuid (and (user-handler/logged-in?)
|
||||
(file-sync-handler/enable-sync?)
|
||||
|
@ -126,9 +126,9 @@
|
|||
;; (such as open-in-finder & open-with-default-app) into a sub-menu of
|
||||
;; this one. However this component doesn't yet exist. PRs are welcome!
|
||||
;; Details: https://github.com/logseq/logseq/pull/3003#issuecomment-952820676
|
||||
(when file-path
|
||||
(when file-rpath
|
||||
(let [repo-dir (config/get-repo-dir repo)
|
||||
file-fpath (path/path-join repo-dir file-path)]
|
||||
file-fpath (path/path-join repo-dir file-rpath)]
|
||||
[{:title (t :page/open-in-finder)
|
||||
:options {:on-click #(js/window.apis.showItemInFolder file-fpath)}}
|
||||
{:title (t :page/open-with-default-app)
|
||||
|
@ -149,12 +149,12 @@
|
|||
(if public? false true))
|
||||
(state/close-modal!))}})
|
||||
|
||||
(when (and (util/electron?) file-path
|
||||
(when (and (util/electron?) file-rpath
|
||||
(not (file-sync-handler/synced-file-graph? repo)))
|
||||
{:title (t :page/open-backup-directory)
|
||||
:options {:on-click
|
||||
(fn []
|
||||
(ipc/ipc "openFileBackupDir" (config/get-local-dir repo) file-path))}})
|
||||
(ipc/ipc "openFileBackupDir" (config/get-local-dir repo) file-rpath))}})
|
||||
|
||||
(when config/lsp-enabled?
|
||||
(for [[_ {:keys [label] :as cmd} action pid] (state/get-plugins-commands-with-type :page-menu-item)]
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
[logseq.graph-parser.text :as text]
|
||||
[logseq.graph-parser.util :as gp-util]
|
||||
[logseq.graph-parser.util.page-ref :as page-ref]
|
||||
[promesa.core :as p]))
|
||||
[promesa.core :as p]
|
||||
[logseq.common.path :as path]))
|
||||
|
||||
;; FIXME: add whiteboard
|
||||
(defn- get-directory
|
||||
|
@ -864,18 +865,26 @@
|
|||
:page)))
|
||||
|
||||
(defn open-file-in-default-app []
|
||||
(if-let [file-path (and (util/electron?) (page-util/get-page-file-path))]
|
||||
(js/window.apis.openPath file-path)
|
||||
(if-let [file-rpath (and (util/electron?) (page-util/get-page-file-rpath))]
|
||||
(let [repo-dir (config/get-repo-dir (state/get-current-repo))
|
||||
file-fpath (path/path-join repo-dir file-rpath)]
|
||||
(js/window.apis.openPath file-fpath))
|
||||
(notification/show! "No file found" :warning)))
|
||||
|
||||
(defn copy-current-file []
|
||||
(if-let [file-path (and (util/electron?) (page-util/get-page-file-path))]
|
||||
(util/copy-to-clipboard! file-path)
|
||||
(defn copy-current-file
|
||||
"FIXME: clarify usage, copy file or copy file path"
|
||||
[]
|
||||
(if-let [file-rpath (and (util/electron?) (page-util/get-page-file-rpath))]
|
||||
(let [repo-dir (config/get-repo-dir (state/get-current-repo))
|
||||
file-fpath (path/path-join repo-dir file-rpath)]
|
||||
(util/copy-to-clipboard! file-fpath))
|
||||
(notification/show! "No file found" :warning)))
|
||||
|
||||
(defn open-file-in-directory []
|
||||
(if-let [file-path (and (util/electron?) (page-util/get-page-file-path))]
|
||||
(js/window.apis.showItemInFolder file-path)
|
||||
(if-let [file-rpath (and (util/electron?) (page-util/get-page-file-rpath))]
|
||||
(let [repo-dir (config/get-repo-dir (state/get-current-repo))
|
||||
file-fpath (path/path-join repo-dir file-rpath)]
|
||||
(js/window.apis.showItemInFolder file-fpath))
|
||||
(notification/show! "No file found" :warning)))
|
||||
|
||||
(defn copy-page-url
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
(or (and page-name (:db/id (db/entity [:block/name page-name])))
|
||||
(get-in (first (state/get-editor-args)) [:block :block/page :db/id]))))
|
||||
|
||||
(defn get-page-file-path
|
||||
(defn get-page-file-rpath
|
||||
"Gets the file path of a page. If no page is given, detects the current page.
|
||||
Returns nil if no file path is found or no page is detected or given"
|
||||
([]
|
||||
|
|
Loading…
Reference in New Issue