瀏覽代碼

fix: :node property values should show unique names by tag

Fixes logseq/db-test#44 and also a part of LOG-3191
Gabriel Horner 1 年之前
父節點
當前提交
47970ee4c6
共有 3 個文件被更改,包括 16 次插入9 次删除
  1. 1 0
      .clj-kondo/config.edn
  2. 6 2
      src/main/frontend/components/block.cljs
  3. 9 7
      src/main/frontend/components/property/value.cljs

+ 1 - 0
.clj-kondo/config.edn

@@ -64,6 +64,7 @@
              frontend.components.query.result query-result
              frontend.components.class class-component
              frontend.components.property property-component
+             frontend.components.title title
              frontend.common.date common-date
              frontend.common.file.core common-file
              frontend.common.file.util wfu

+ 6 - 2
src/main/frontend/components/block.cljs

@@ -90,7 +90,8 @@
             [electron.ipc :as ipc]
             [frontend.db.async :as db-async]
             [logseq.db.frontend.content :as db-content]
-            [logseq.db :as ldb]))
+            [logseq.db :as ldb]
+            [frontend.components.title :as title]))
 
 ;; local state
 (defonce *dragging?
@@ -546,7 +547,7 @@
    page-name-in-block is the overridable name of the page (legacy)
 
    All page-names are sanitized except page-name-in-block"
-  [state {:keys [contents-page? whiteboard-page? html-export? meta-click?] :as config} page-entity children label]
+  [state {:keys [contents-page? whiteboard-page? html-export? meta-click? show-unique-title?] :as config} page-entity children label]
   (let [*hover? (::hover? state)
         *mouse-down? (::mouse-down? state)
         tag? (:tag? config)
@@ -618,6 +619,9 @@
           (coll? label)
           (->elem :span (map-inline config label))
 
+          show-unique-title?
+          (title/block-unique-title page-entity)
+
           :else
           (let [title (:block/title page-entity)
                 s (cond untitled?

+ 9 - 7
src/main/frontend/components/property/value.cljs

@@ -27,7 +27,8 @@
             [logseq.db.frontend.property.type :as db-property-type]
             [dommy.core :as d]
             [frontend.search :as search]
-            [goog.functions :refer [debounce]]))
+            [goog.functions :refer [debounce]]
+            [frontend.components.title :as title]))
 
 (rum/defc property-empty-btn-value
   [& {:as opts}]
@@ -388,7 +389,7 @@
         options (map (fn [node]
                        (let [id (or (:value node) (:db/id node))
                              label (if (integer? id)
-                                     (let [title (subs (:block/title node) 0 256)
+                                     (let [title (subs (title/block-unique-title node) 0 256)
                                            node (or (db/entity id) node)
                                            icon (get-node-icon node)]
                                        [:div.flex.flex-row.items-center.gap-1
@@ -659,22 +660,23 @@
                             (shui/button {:variant :ghost
                                           :size :sm
                                           :class "px-0 py-0 h-4"}
-                              (ui/icon "edit" {:size 14})))])]
+                                         (ui/icon "edit" {:size 14})))])]
     [:div.select-item.cursor-pointer
      (cond
        (= value :logseq.property/empty-placeholder)
        (property-empty-btn-value)
 
        (or (ldb/page? value)
-         (and (seq (:block/tags value))
-           ;; FIXME: page-cp should be renamed to node-cp and
-           ;; support this case and maybe other complex cases.
-           (not (string/includes? (:block/title value) "[["))))
+           (and (seq (:block/tags value))
+                ;; FIXME: page-cp should be renamed to node-cp and
+                ;; support this case and maybe other complex cases.
+                (not (string/includes? (:block/title value) "[["))))
        (when value
          (rum/with-key
            (page-cp {:disable-preview? true
                      :tag? tag?
                      :hide-close-button? true
+                     :show-unique-title? true
                      :meta-click? other-position?} value)
            (:db/id value)))