mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 18:36:43 +00:00
fix: redirect to alias
This commit is contained in:
@@ -611,11 +611,14 @@
|
||||
|
||||
(declare page-reference)
|
||||
|
||||
(defn open-page-ref
|
||||
(defn <open-page-ref
|
||||
[config page-entity e page-name contents-page?]
|
||||
(when (not (util/right-click? e))
|
||||
(let [ignore-alias? (:ignore-alias? config)
|
||||
page (or (and (not ignore-alias?) (first (:block/_alias page-entity))) page-entity)]
|
||||
(p/let [ignore-alias? (:ignore-alias? config)
|
||||
page (or (and (not ignore-alias?)
|
||||
(or (first (:block/_alias page-entity))
|
||||
(db-async/<get-block-source (state/get-current-repo) (:db/id page-entity))))
|
||||
page-entity)]
|
||||
(cond
|
||||
(gobj/get e "shiftKey")
|
||||
(when page
|
||||
@@ -708,12 +711,12 @@
|
||||
(util/stop e)
|
||||
(state/clear-edit!)
|
||||
(when-not (:disable-click? config)
|
||||
(open-page-ref config page-entity e page-name contents-page?))
|
||||
(<open-page-ref config page-entity e page-name contents-page?))
|
||||
(reset! *mouse-down? false)))
|
||||
:on-key-up (fn [e] (when (and e (= (.-key e) "Enter") (not other-position?))
|
||||
(util/stop e)
|
||||
(state/clear-edit!)
|
||||
(open-page-ref config page-entity e page-name contents-page?)))}
|
||||
(<open-page-ref config page-entity e page-name contents-page?)))}
|
||||
on-context-menu
|
||||
(assoc :on-context-menu on-context-menu))
|
||||
(when (and show-icon? (not tag?))
|
||||
|
||||
@@ -281,15 +281,16 @@
|
||||
(defn- page-item
|
||||
[repo page]
|
||||
(let [entity (db/entity [:block/uuid (:block/uuid page)])
|
||||
source-page (or (:block/title (model/get-alias-source-page repo (:db/id entity)))
|
||||
source-page (or (model/get-alias-source-page repo (:db/id entity))
|
||||
(:alias page))
|
||||
icon (get-page-icon entity)
|
||||
title (block-handler/block-unique-title page)
|
||||
title' (if source-page (str title " -> alias: " source-page) title)]
|
||||
title' (if source-page (str title " -> alias: " (:block/title source-page)) title)]
|
||||
(hash-map :icon icon
|
||||
:icon-theme :gray
|
||||
:text title'
|
||||
:source-page (or source-page page))))
|
||||
:source-page (or source-page page)
|
||||
:alias (:alias page))))
|
||||
|
||||
(defn- block-item
|
||||
[repo block current-page !input]
|
||||
@@ -437,9 +438,11 @@
|
||||
|
||||
(defn- get-highlighted-page-uuid-or-name
|
||||
[state]
|
||||
(let [highlighted-item (some-> state state->highlighted-item)]
|
||||
(or (:block/uuid (:source-block highlighted-item))
|
||||
(:block/uuid (:source-page highlighted-item)))))
|
||||
(let [highlighted-item (some-> state state->highlighted-item)
|
||||
block (or (:alias highlighted-item)
|
||||
(:source-block highlighted-item)
|
||||
(:source-page highlighted-item))]
|
||||
(:block/uuid block)))
|
||||
|
||||
(defmethod handle-action :open-page [_ state _event]
|
||||
(when-let [page-name (get-highlighted-page-uuid-or-name state)]
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
:else
|
||||
(ui/icon "letter-n" {:size 14}))])
|
||||
|
||||
(let [title (let [alias (:alias block')
|
||||
(let [title (let [alias (get-in block' [:alias :block/title])
|
||||
title (if (and db-based? (not (ldb/built-in? block')))
|
||||
(block-handler/block-unique-title block')
|
||||
(:block/title block'))]
|
||||
|
||||
@@ -151,6 +151,13 @@
|
||||
_ (d/transact! conn result)]
|
||||
result)))
|
||||
|
||||
(defn <get-block-source
|
||||
[graph id]
|
||||
(assert (integer? id))
|
||||
(p/let [source-id (state/<invoke-db-worker :thread-api/get-block-source graph id)]
|
||||
(when source-id
|
||||
(<get-block graph source-id {:children? false}))))
|
||||
|
||||
(defn <get-block-refs
|
||||
[graph eid]
|
||||
(assert (integer? eid))
|
||||
|
||||
@@ -469,6 +469,11 @@
|
||||
(when-let [conn (worker-state/get-datascript-conn repo)]
|
||||
(ldb/get-block-refs-count @conn id)))
|
||||
|
||||
(def-thread-api :thread-api/get-block-source
|
||||
[repo id]
|
||||
(when-let [conn (worker-state/get-datascript-conn repo)]
|
||||
(:db/id (first (:block/_alias (d/entity @conn id))))))
|
||||
|
||||
(def-thread-api :thread-api/block-refs-check
|
||||
[repo id {:keys [unlinked?]}]
|
||||
(when-let [conn (worker-state/get-datascript-conn repo)]
|
||||
|
||||
@@ -326,7 +326,8 @@ DROP TRIGGER IF EXISTS blocks_au;
|
||||
nil)
|
||||
:block/tags (seq (map :db/id (:block/tags block)))
|
||||
:page? (ldb/page? block)
|
||||
:alias (:block/title (first (:block/_alias block)))}))))))
|
||||
:alias (some-> (first (:block/_alias block))
|
||||
(select-keys [:block/uuid :block/title]))}))))))
|
||||
page-or-object-result (filter (fn [b] (or (:page? b) (:block/tags result))) result)]
|
||||
(->>
|
||||
(concat page-or-object-result
|
||||
|
||||
Reference in New Issue
Block a user