mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
show linked page instead of the block that the page has been added
This commit is contained in:
@@ -2348,6 +2348,9 @@
|
||||
(when-not plugin-slotted?
|
||||
[:div.flex-1.w-full
|
||||
(cond
|
||||
(:block/original-name block)
|
||||
(page-cp config block)
|
||||
|
||||
(or (seq title) (:block/marker block))
|
||||
(build-block-title config block)
|
||||
|
||||
@@ -2369,7 +2372,7 @@
|
||||
|
||||
(when-not (config/db-based-graph? repo)
|
||||
(when-let [invalid-properties (:block/invalid-properties block)]
|
||||
(invalid-properties-cp invalid-properties)))
|
||||
(invalid-properties-cp invalid-properties)))
|
||||
|
||||
(when (and (seq properties)
|
||||
(let [hidden? (file-property/properties-hidden? properties)]
|
||||
@@ -3343,7 +3346,8 @@
|
||||
|
||||
(defn- block-item
|
||||
[config blocks idx item]
|
||||
(let [item (->
|
||||
(let [item (or (:block/link item) item)
|
||||
item (->
|
||||
(dissoc item :block/meta)
|
||||
(assoc :block.temp/top? (zero? idx)
|
||||
:block.temp/bottom? (= (count blocks) (inc idx))))
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
[frontend.handler.file-based.property.util :as property-util]
|
||||
[frontend.handler.property.util :as pu]
|
||||
[frontend.db.rtc.op :as rtc-op]
|
||||
[clojure.core.async :as async]))
|
||||
[clojure.core.async :as async]
|
||||
[frontend.format.mldoc :as mldoc]))
|
||||
|
||||
(s/def ::block-map (s/keys :opt [:db/id :block/uuid :block/page :block/left :block/parent]))
|
||||
|
||||
@@ -131,21 +132,15 @@
|
||||
|
||||
(defn- assoc-linked-block-when-save
|
||||
[txs-state block-entity m]
|
||||
(let [tags (seq (:block/tags m))]
|
||||
(when (and (config/db-based-graph? (state/get-current-repo))
|
||||
(:block/page block-entity)
|
||||
tags)
|
||||
(let [tag-names (set (map :block/name tags))]
|
||||
(when-let [linked-block-id (:block/uuid
|
||||
(first (remove (fn [ref]
|
||||
(contains? tag-names (:block/name ref)))
|
||||
(:block/refs m))))]
|
||||
(swap! txs-state (fn [txs]
|
||||
(concat txs
|
||||
[{:block/uuid linked-block-id
|
||||
:block/tags (:block/tags m)}
|
||||
{:db/id (:db/id block-entity)
|
||||
:block/link [:block/uuid linked-block-id]}]))))))))
|
||||
(let [linked-page (some-> (:block/content m) mldoc/extract-plain)
|
||||
sanity-linked-page (util/page-name-sanity-lc linked-page)]
|
||||
(when-not (string/blank? sanity-linked-page)
|
||||
(let [page-m (block/page-name->map linked-page true)]
|
||||
(swap! txs-state (fn [txs]
|
||||
(concat txs
|
||||
[(assoc page-m :block/tags (:block/tags m))
|
||||
{:db/id (:db/id block-entity)
|
||||
:block/link [:block/uuid (:block/uuid page-m)]}])))))))
|
||||
|
||||
(defn rebuild-block-refs
|
||||
[block new-properties & {:keys [skip-content-parsing?]}]
|
||||
@@ -250,28 +245,31 @@
|
||||
(assert (ds/outliner-txs-state? txs-state)
|
||||
"db should be satisfied outliner-tx-state?")
|
||||
(let [m* (-> (:data this)
|
||||
(dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom?
|
||||
:block/title :block/body :block/level)
|
||||
gp-util/remove-nils
|
||||
block-with-timestamps
|
||||
fix-tag-ids)
|
||||
(dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom?
|
||||
:block/title :block/body :block/level)
|
||||
gp-util/remove-nils
|
||||
block-with-timestamps
|
||||
fix-tag-ids)
|
||||
repo (state/get-current-repo)
|
||||
db-based? (config/db-based-graph? repo)
|
||||
m (if db-based?
|
||||
(dissoc m* :block/properties :block/properties-order)
|
||||
m*)
|
||||
id (:db/id (:data this))
|
||||
block-entity (db/entity id)]
|
||||
block-entity (db/entity id)
|
||||
structured-tags? (and (config/db-based-graph? (state/get-current-repo))
|
||||
(:block/page block-entity)
|
||||
(seq (:block/tags m)))]
|
||||
(when id
|
||||
;; Retract attributes to prepare for tx which rewrites block attributes
|
||||
(let [retract-attributes (if db-based?
|
||||
(remove #{:block/properties :block/properties-order} db-schema/retract-attributes))]
|
||||
(swap! txs-state (fn [txs]
|
||||
(vec
|
||||
(concat txs
|
||||
(map (fn [attribute]
|
||||
[:db/retract id attribute])
|
||||
retract-attributes))))))
|
||||
(vec
|
||||
(concat txs
|
||||
(map (fn [attribute]
|
||||
[:db/retract id attribute])
|
||||
retract-attributes))))))
|
||||
|
||||
;; Update block's page attributes
|
||||
(update-page-when-save-block txs-state block-entity m)
|
||||
@@ -286,7 +284,8 @@
|
||||
(vec (concat txs other-tx)))))
|
||||
(swap! txs-state conj (dissoc m :db/other-tx)))
|
||||
|
||||
(assoc-linked-block-when-save txs-state block-entity m)
|
||||
(when structured-tags?
|
||||
(assoc-linked-block-when-save txs-state block-entity m))
|
||||
|
||||
(rebuild-refs txs-state block-entity m)
|
||||
|
||||
|
||||
@@ -171,8 +171,8 @@
|
||||
(not (contains? (:file/unlinked-dirs @state/state)
|
||||
(config/get-repo-dir repo)))))
|
||||
|
||||
;; (prn :debug "Outliner transact:")
|
||||
;; (frontend.util/pprint {:txs txs :opts opts})
|
||||
(prn :debug "Outliner transact:")
|
||||
(frontend.util/pprint {:txs txs :opts opts})
|
||||
|
||||
(try
|
||||
(let [repo (get opts :repo (state/get-current-repo))
|
||||
|
||||
Reference in New Issue
Block a user