Kaynağa Gözat

chore: rename :block/instance to :block/link

Tienson Qin 2 yıl önce
ebeveyn
işleme
d75e5c6e72

+ 3 - 3
deps/db/src/logseq/db/schema.cljs

@@ -43,9 +43,9 @@
    :block/tags {:db/valueType :db.type/ref
                 :db/cardinality :db.cardinality/many}
 
-   ;; an instance created by this block
-   :block/instance {:db/valueType :db.type/ref
-                    :db/index true}
+   ;; which block this block links to, used for tag, embeds
+   :block/link {:db/valueType :db.type/ref
+                :db/index true}
 
    ;; for pages
    :block/alias {:db/valueType :db.type/ref

+ 5 - 5
src/main/frontend/components/property.cljs

@@ -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))

+ 1 - 1
src/main/frontend/db/model.cljs

@@ -40,7 +40,7 @@
     :block/_refs
     :block/path-refs
     :block/tags
-    :block/instance
+    :block/link
     :block/content
     :block/marker
     :block/priority

+ 5 - 6
src/main/frontend/modules/outliner/core.cljs

@@ -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)