mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
chore: rename :block/instance to :block/link
This commit is contained in:
@@ -309,8 +309,8 @@
|
||||
{:modal-class (util/hiccup->class
|
||||
"origin-top-right.absolute.left-0.rounded-md.shadow-lg")})]))
|
||||
|
||||
(defn- resolve-instance-page-if-exists
|
||||
"Properties will be updated for the instance page instead of the refed block.
|
||||
(defn- resolve-linked-block-if-exists
|
||||
"Properties will be updated for the linked page instead of the refed block.
|
||||
For example, the block below has a reference to the page \"How to solve it\",
|
||||
we'd like the properties of the class \"book\" (e.g. Authors, Published year)
|
||||
to be assigned for the page `How to solve it` instead of the referenced block.
|
||||
@@ -319,8 +319,8 @@
|
||||
- [[How to solve it]] #book
|
||||
"
|
||||
[block]
|
||||
(if-let [instance (:block/instance block)]
|
||||
(db/sub-block (:db/id instance))
|
||||
(if-let [linked-block (:block/link block)]
|
||||
(db/sub-block (:db/id linked-block))
|
||||
(db/sub-block (:db/id block))))
|
||||
|
||||
(rum/defcs properties-area < rum/reactive
|
||||
@@ -328,7 +328,7 @@
|
||||
(assoc state ::blocks-container-id (or (:blocks-container-id (last (:rum/args state)))
|
||||
(state/next-blocks-container-id))))}
|
||||
[state target-block edit-input-id opts]
|
||||
(let [block (resolve-instance-page-if-exists target-block)
|
||||
(let [block (resolve-linked-block-if-exists target-block)
|
||||
properties (if (and (:class-schema? opts) (:block/schema block))
|
||||
(let [properties (:properties (:block/schema block))]
|
||||
(map (fn [k] [k nil]) properties))
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
:block/_refs
|
||||
:block/path-refs
|
||||
:block/tags
|
||||
:block/instance
|
||||
:block/link
|
||||
:block/content
|
||||
:block/marker
|
||||
:block/priority
|
||||
|
||||
@@ -129,24 +129,23 @@
|
||||
new-refs (remove-self-page (:block/refs m))]
|
||||
(remove-orphaned-page-refs! (:db/id block-entity) txs-state old-refs new-refs))))
|
||||
|
||||
|
||||
(defn- assoc-instance-when-save
|
||||
(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 [instance-id (:block/uuid
|
||||
(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 instance-id
|
||||
[{:block/uuid linked-block-id
|
||||
:block/tags (:block/tags m)}
|
||||
{:db/id (:db/id block-entity)
|
||||
:block/instance [:block/uuid instance-id]}]))))))))
|
||||
:block/link [:block/uuid linked-block-id]}]))))))))
|
||||
|
||||
(defn rebuild-block-refs
|
||||
[block new-properties & {:keys [skip-content-parsing?]}]
|
||||
@@ -287,7 +286,7 @@
|
||||
(vec (concat txs other-tx)))))
|
||||
(swap! txs-state conj (dissoc m :db/other-tx)))
|
||||
|
||||
(assoc-instance-when-save txs-state block-entity m)
|
||||
(assoc-linked-block-when-save txs-state block-entity m)
|
||||
|
||||
(rebuild-refs txs-state block-entity m)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user