mirror of
https://github.com/logseq/logseq.git
synced 2026-05-26 21:54:26 +00:00
Shortcut for copying a page url (#8538)
* fix: move primary directory to ~/.config/Logseq * feat: Add shortcut for copying a page url * Revert "fix: move primary directory to ~/.config/Logseq" This reverts commit 1991c60fbf236db93df96e0c0856d73df123a124. * fix(dev): remove import to pass lint checks * Address code review Also - Add :inactive to command to reflect page-menu platforms like other commands - Add improved current page like other current file/page commands - don't use state/sub in non component contexts --------- Co-authored-by: Gabriel Horner <gabriel@logseq.com>
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
[frontend.state :as state]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.util :as util]
|
||||
[frontend.util.url :as url-util]
|
||||
[frontend.util.page :as page-util]
|
||||
[frontend.handler.shell :as shell]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
@@ -107,8 +106,7 @@
|
||||
(when (or (util/electron?)
|
||||
(mobile-util/native-platform?))
|
||||
{:title (t :page/copy-page-url)
|
||||
:options {:on-click #(util/copy-to-clipboard!
|
||||
(url-util/get-logseq-graph-page-url nil repo page-original-name))}})
|
||||
:options {:on-click #(page-handler/copy-page-url page-original-name)}})
|
||||
|
||||
(when-not contents?
|
||||
{:title (t :page/delete)
|
||||
|
||||
@@ -9,41 +9,42 @@
|
||||
[frontend.context.i18n :refer [t]]
|
||||
[frontend.date :as date]
|
||||
[frontend.db :as db]
|
||||
[logseq.db.schema :as db-schema]
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.db.model :as model]
|
||||
[frontend.db.utils :as db-utils]
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.format.block :as block]
|
||||
[frontend.fs :as fs]
|
||||
[frontend.handler.common :as common-handler]
|
||||
[frontend.handler.config :as config-handler]
|
||||
[frontend.handler.editor :as editor-handler]
|
||||
[frontend.handler.notification :as notification]
|
||||
[frontend.handler.recent :as recent-handler]
|
||||
[frontend.handler.route :as route-handler]
|
||||
[frontend.handler.ui :as ui-handler]
|
||||
[frontend.handler.web.nfs :as web-nfs]
|
||||
[frontend.handler.config :as config-handler]
|
||||
[frontend.handler.recent :as recent-handler]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[frontend.modules.outliner.core :as outliner-core]
|
||||
[frontend.modules.outliner.file :as outliner-file]
|
||||
[frontend.modules.outliner.tree :as outliner-tree]
|
||||
[frontend.state :as state]
|
||||
[frontend.util :as util]
|
||||
[frontend.util.cursor :as cursor]
|
||||
[frontend.util.property :as property]
|
||||
[frontend.util.fs :as fs-util]
|
||||
[frontend.util.page-property :as page-property]
|
||||
[frontend.util.page :as page-util]
|
||||
[frontend.util.property :as property]
|
||||
[frontend.util.url :as url-util]
|
||||
[goog.functions :refer [debounce]]
|
||||
[goog.object :as gobj]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]
|
||||
[frontend.mobile.util :as mobile-util]
|
||||
[logseq.graph-parser.util :as gp-util]
|
||||
[logseq.graph-parser.text :as text]
|
||||
[logseq.graph-parser.config :as gp-config]
|
||||
[logseq.db.schema :as db-schema]
|
||||
[logseq.graph-parser.block :as gp-block]
|
||||
[logseq.graph-parser.config :as gp-config]
|
||||
[logseq.graph-parser.property :as gp-property]
|
||||
[logseq.graph-parser.text :as text]
|
||||
[logseq.graph-parser.util :as gp-util]
|
||||
[logseq.graph-parser.util.page-ref :as page-ref]
|
||||
[frontend.format.block :as block]
|
||||
[goog.functions :refer [debounce]]))
|
||||
[promesa.core :as p]))
|
||||
|
||||
;; FIXME: add whiteboard
|
||||
(defn- get-directory
|
||||
@@ -877,3 +878,11 @@
|
||||
(if-let [file-path (and (util/electron?) (page-util/get-page-file-path))]
|
||||
(js/window.apis.showItemInFolder file-path)
|
||||
(notification/show! "No file found" :warning)))
|
||||
|
||||
(defn copy-page-url
|
||||
([] (copy-page-url (page-util/get-current-page-name)))
|
||||
([page-name]
|
||||
(if page-name
|
||||
(util/copy-to-clipboard!
|
||||
(url-util/get-logseq-graph-page-url nil (state/get-current-repo) page-name))
|
||||
(notification/show! "No page found to copy" :warning))))
|
||||
|
||||
@@ -413,6 +413,10 @@
|
||||
:inactive (not (util/electron?))
|
||||
:fn page-handler/copy-current-file}
|
||||
|
||||
:editor/copy-page-url {:binding false
|
||||
:inactive (not (util/electron?))
|
||||
:fn page-handler/copy-page-url}
|
||||
|
||||
:ui/toggle-wide-mode {:binding "t w"
|
||||
:fn ui-handler/toggle-wide-mode!}
|
||||
|
||||
@@ -626,6 +630,7 @@
|
||||
:editor/open-file-in-default-app
|
||||
:editor/open-file-in-directory
|
||||
:editor/copy-current-file
|
||||
:editor/copy-page-url
|
||||
:editor/new-whiteboard
|
||||
:ui/toggle-wide-mode
|
||||
:ui/select-theme-color
|
||||
@@ -769,6 +774,7 @@
|
||||
:editor/insert-youtube-timestamp
|
||||
:editor/open-file-in-default-app
|
||||
:editor/open-file-in-directory
|
||||
:editor/copy-page-url
|
||||
:editor/new-whiteboard
|
||||
:auto-complete/prev
|
||||
:auto-complete/next
|
||||
|
||||
@@ -122,6 +122,7 @@
|
||||
:editor/open-file-in-default-app "Open file in default app"
|
||||
:editor/open-file-in-directory "Open file in parent directory"
|
||||
:editor/copy-current-file "Copy current file"
|
||||
:editor/copy-page-url "Copy page url"
|
||||
:ui/toggle-wide-mode "Toggle wide mode"
|
||||
:ui/select-theme-color "Select available theme colors"
|
||||
:ui/goto-plugins "Go to plugins dashboard"
|
||||
|
||||
@@ -4,6 +4,13 @@
|
||||
[frontend.util :as util]
|
||||
[frontend.db :as db]))
|
||||
|
||||
(defn get-current-page-name
|
||||
"Fetch the current page's original name with same approach as get-current-page-id"
|
||||
[]
|
||||
(or (state/get-current-page)
|
||||
(state/get-current-whiteboard)
|
||||
(get-in (first (state/get-editor-args)) [:block :block/page :block/original-name])))
|
||||
|
||||
(defn get-current-page-id
|
||||
"Fetches the current page id. Looks up page based on latest route and if
|
||||
nothing is found, gets page of last edited block"
|
||||
|
||||
Reference in New Issue
Block a user