mirror of https://github.com/logseq/logseq
enhance: show icons for class, property and node
parent
404116f080
commit
dafa090fdc
|
@ -35,7 +35,8 @@
|
||||||
[electron.ipc :as ipc]
|
[electron.ipc :as ipc]
|
||||||
[frontend.util.text :as text-util]
|
[frontend.util.text :as text-util]
|
||||||
[goog.userAgent]
|
[goog.userAgent]
|
||||||
[frontend.db.async :as db-async]))
|
[frontend.db.async :as db-async]
|
||||||
|
[logseq.db :as ldb]))
|
||||||
|
|
||||||
(defn translate [t {:keys [id desc]}]
|
(defn translate [t {:keys [id desc]}]
|
||||||
(when id
|
(when id
|
||||||
|
@ -48,7 +49,7 @@
|
||||||
|
|
||||||
(def search-actions
|
(def search-actions
|
||||||
[{:filter {:group :current-page} :text "Search only current page" :info "Add filter to search" :icon-theme :gray :icon "page"}
|
[{:filter {:group :current-page} :text "Search only current page" :info "Add filter to search" :icon-theme :gray :icon "page"}
|
||||||
{:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "block"}
|
{:filter {:group :nodes} :text "Search only nodes" :info "Add filter to search" :icon-theme :gray :icon "letter-n"}
|
||||||
{:filter {:group :commands} :text "Search only commands" :info "Add filter to search" :icon-theme :gray :icon "command"}
|
{:filter {:group :commands} :text "Search only commands" :info "Add filter to search" :icon-theme :gray :icon "command"}
|
||||||
{:filter {:group :files} :text "Search only files" :info "Add filter to search" :icon-theme :gray :icon "file"}
|
{:filter {:group :files} :text "Search only files" :info "Add filter to search" :icon-theme :gray :icon "file"}
|
||||||
{:filter {:group :themes} :text "Search only themes" :info "Add filter to search" :icon-theme :gray :icon "palette"}])
|
{:filter {:group :themes} :text "Search only themes" :info "Add filter to search" :icon-theme :gray :icon "palette"}])
|
||||||
|
@ -220,9 +221,17 @@
|
||||||
(defn- page-item
|
(defn- page-item
|
||||||
[repo page]
|
[repo page]
|
||||||
(let [entity (db/entity [:block/uuid (:block/uuid page)])
|
(let [entity (db/entity [:block/uuid (:block/uuid page)])
|
||||||
whiteboard? (contains? (:block/type entity) "whiteboard")
|
source-page (model/get-alias-source-page repo (:db/id entity))
|
||||||
source-page (model/get-alias-source-page repo (:db/id entity))]
|
icon (cond
|
||||||
(hash-map :icon (if whiteboard? "whiteboard" "page")
|
(ldb/class? entity)
|
||||||
|
"hash"
|
||||||
|
(ldb/property? entity)
|
||||||
|
"letter-p"
|
||||||
|
(ldb/whiteboard-page? entity)
|
||||||
|
"whiteboard"
|
||||||
|
:else
|
||||||
|
"page")]
|
||||||
|
(hash-map :icon icon
|
||||||
:icon-theme :gray
|
:icon-theme :gray
|
||||||
:text (title/block-unique-title page)
|
:text (title/block-unique-title page)
|
||||||
:source-page (or source-page page))))
|
:source-page (or source-page page))))
|
||||||
|
@ -231,8 +240,9 @@
|
||||||
[repo block current-page !input]
|
[repo block current-page !input]
|
||||||
(let [id (:block/uuid block)
|
(let [id (:block/uuid block)
|
||||||
object? (seq (:block/tags block))
|
object? (seq (:block/tags block))
|
||||||
text (title/block-unique-title block)]
|
text (title/block-unique-title block)
|
||||||
{:icon (if object? "topology-star" "block")
|
icon "letter-n"]
|
||||||
|
{:icon icon
|
||||||
:icon-theme :gray
|
:icon-theme :gray
|
||||||
:text (highlight-content-query text @!input)
|
:text (highlight-content-query text @!input)
|
||||||
:header (when-not object? (block/breadcrumb {:search? true} repo id {}))
|
:header (when-not object? (block/breadcrumb {:search? true} repo id {}))
|
||||||
|
@ -335,7 +345,7 @@
|
||||||
(let [id (if (uuid? (:block/uuid block))
|
(let [id (if (uuid? (:block/uuid block))
|
||||||
(:block/uuid block)
|
(:block/uuid block)
|
||||||
(uuid (:block/uuid block)))]
|
(uuid (:block/uuid block)))]
|
||||||
{:icon "block"
|
{:icon "node"
|
||||||
:icon-theme :gray
|
:icon-theme :gray
|
||||||
:text (highlight-content-query (:block/title block) @!input)
|
:text (highlight-content-query (:block/title block) @!input)
|
||||||
:header (block/breadcrumb {:search? true} repo id {})
|
:header (block/breadcrumb {:search? true} repo id {})
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
[frontend.components.title :as title]
|
[frontend.components.title :as title]
|
||||||
[frontend.context.i18n :refer [t]]
|
[frontend.context.i18n :refer [t]]
|
||||||
[frontend.db :as db]
|
[frontend.db :as db]
|
||||||
|
[logseq.db :as ldb]
|
||||||
[frontend.db.model :as db-model]
|
[frontend.db.model :as db-model]
|
||||||
[frontend.extensions.zotero :as zotero]
|
[frontend.extensions.zotero :as zotero]
|
||||||
[frontend.handler.editor :as editor-handler :refer [get-state]]
|
[frontend.handler.editor :as editor-handler :refer [get-state]]
|
||||||
|
@ -171,17 +172,19 @@
|
||||||
[:div.flex.flex-row.items-center.gap-1
|
[:div.flex.flex-row.items-center.gap-1
|
||||||
(when-not db-tag?
|
(when-not db-tag?
|
||||||
(cond
|
(cond
|
||||||
|
(ldb/class? block)
|
||||||
|
[:div (ui/icon "hash" {:size 14})]
|
||||||
|
(ldb/property? block)
|
||||||
|
[:div (ui/icon "letter-p" {:size 14})]
|
||||||
(db-model/whiteboard-page? block)
|
(db-model/whiteboard-page? block)
|
||||||
[:div (ui/icon "whiteboard" {:extension? true})]
|
[:div (ui/icon "whiteboard" {:extension? true})]
|
||||||
(db/page? block)
|
(db/page? block)
|
||||||
[:div (ui/icon "page" {:extension? true})]
|
[:div (ui/icon "page" {:extension? true})]
|
||||||
(seq (:block/tags block))
|
|
||||||
[:div.flex (ui/icon "topology-star" {:size 14})]
|
|
||||||
(or (string/starts-with? (:block/title block) (t :new-class))
|
(or (string/starts-with? (:block/title block) (t :new-class))
|
||||||
(string/starts-with? (:block/title block) (t :new-page)))
|
(string/starts-with? (:block/title block) (t :new-page)))
|
||||||
nil
|
nil
|
||||||
:else
|
:else
|
||||||
[:div (ui/icon "block" {:extension? true})]))
|
[:div (ui/icon "letter-n" {:size 14})]))
|
||||||
|
|
||||||
(let [title (if db-tag?
|
(let [title (if db-tag?
|
||||||
(:block/title block)
|
(:block/title block)
|
||||||
|
|
|
@ -32,12 +32,14 @@
|
||||||
(defn get-node-icon
|
(defn get-node-icon
|
||||||
[node-entity opts]
|
[node-entity opts]
|
||||||
(let [default-icon-id (cond
|
(let [default-icon-id (cond
|
||||||
(and (:block/tags node-entity) (not (ldb/page? node-entity)))
|
(ldb/class? node-entity)
|
||||||
"topology-star"
|
"hash"
|
||||||
|
(ldb/property? node-entity)
|
||||||
|
"letter-p"
|
||||||
(ldb/page? node-entity)
|
(ldb/page? node-entity)
|
||||||
"page"
|
"page"
|
||||||
:else
|
:else
|
||||||
"block")
|
"letter-n")
|
||||||
default-icon (ui/icon default-icon-id (assoc opts :size 14))
|
default-icon (ui/icon default-icon-id (assoc opts :size 14))
|
||||||
node-icon (get node-entity (pu/get-pid :logseq.property/icon))]
|
node-icon (get node-entity (pu/get-pid :logseq.property/icon))]
|
||||||
(or
|
(or
|
||||||
|
|
|
@ -331,12 +331,20 @@
|
||||||
(let [page (db/sub-block (:db/id page))
|
(let [page (db/sub-block (:db/id page))
|
||||||
title (:block/title page)]
|
title (:block/title page)]
|
||||||
(when title
|
(when title
|
||||||
(let [journal? (ldb/journal-page? page)
|
(let [repo (state/get-current-repo)
|
||||||
icon (get page (pu/get-pid :logseq.property/icon))
|
db-based? (config/db-based-graph? repo)
|
||||||
|
journal? (ldb/journal-page? page)
|
||||||
|
icon (or (get page (pu/get-pid :logseq.property/icon))
|
||||||
|
(when db-based?
|
||||||
|
(or (when (ldb/class? page)
|
||||||
|
{:type :tabler-icon
|
||||||
|
:id "hash"})
|
||||||
|
(when (ldb/property? page)
|
||||||
|
{:type :tabler-icon
|
||||||
|
:id "letter-p"}))))
|
||||||
*title-value (get state ::title-value)
|
*title-value (get state ::title-value)
|
||||||
*edit? (get state ::edit?)
|
*edit? (get state ::edit?)
|
||||||
*input-value (get state ::input-value)
|
*input-value (get state ::input-value)
|
||||||
repo (state/get-current-repo)
|
|
||||||
hls-page? (pdf-utils/hls-file? title)
|
hls-page? (pdf-utils/hls-file? title)
|
||||||
whiteboard-page? (model/whiteboard-page? page)
|
whiteboard-page? (model/whiteboard-page? page)
|
||||||
untitled? (and whiteboard-page? (parse-uuid title)) ;; normal page cannot be untitled right?
|
untitled? (and whiteboard-page? (parse-uuid title)) ;; normal page cannot be untitled right?
|
||||||
|
@ -345,15 +353,15 @@
|
||||||
(if fmt-journal?
|
(if fmt-journal?
|
||||||
(date/journal-title->custom-format title)
|
(date/journal-title->custom-format title)
|
||||||
title))
|
title))
|
||||||
old-name title
|
old-name title]
|
||||||
db-based? (config/db-based-graph? repo)]
|
|
||||||
[:div.ls-page-title.flex.flex-1.flex-row.flex-wrap.w-full.relative.items-center.gap-2
|
[:div.ls-page-title.flex.flex-1.flex-row.flex-wrap.w-full.relative.items-center.gap-2
|
||||||
{:on-mouse-over #(when-not @*edit? (reset! *hover? true))
|
{:on-mouse-over #(when-not @*edit? (reset! *hover? true))
|
||||||
:on-mouse-out #(reset! *hover? false)}
|
:on-mouse-out #(reset! *hover? false)}
|
||||||
(when icon
|
(when icon
|
||||||
[:div.page-icon
|
[:div.page-icon
|
||||||
{:on-pointer-down util/stop-propagation}
|
{:on-pointer-down util/stop-propagation}
|
||||||
(if (and (map? icon) db-based?)
|
(cond
|
||||||
|
(and (map? icon) db-based?)
|
||||||
(icon-component/icon-picker icon
|
(icon-component/icon-picker icon
|
||||||
{:on-chosen (fn [_e icon]
|
{:on-chosen (fn [_e icon]
|
||||||
(db-property-handler/set-block-property!
|
(db-property-handler/set-block-property!
|
||||||
|
@ -361,6 +369,8 @@
|
||||||
(pu/get-pid :logseq.property/icon)
|
(pu/get-pid :logseq.property/icon)
|
||||||
(select-keys icon [:id :type :color])))
|
(select-keys icon [:id :type :color])))
|
||||||
:icon-props {:size 38}})
|
:icon-props {:size 38}})
|
||||||
|
|
||||||
|
:else
|
||||||
icon)])
|
icon)])
|
||||||
[:h1.page-title.flex-1.cursor-pointer.gap-1
|
[:h1.page-title.flex-1.cursor-pointer.gap-1
|
||||||
{:class (when-not whiteboard-page? "title")
|
{:class (when-not whiteboard-page? "title")
|
||||||
|
|
|
@ -445,7 +445,7 @@
|
||||||
:checkbox "checkbox"
|
:checkbox "checkbox"
|
||||||
:url "link"
|
:url "link"
|
||||||
:page "page"
|
:page "page"
|
||||||
:node "topology-star"
|
:node "letter-n"
|
||||||
"letter-t"))]
|
"letter-t"))]
|
||||||
(ui/icon icon {:class "opacity-50"
|
(ui/icon icon {:class "opacity-50"
|
||||||
:size 15})))
|
:size 15})))
|
||||||
|
|
|
@ -311,12 +311,14 @@
|
||||||
(defn- get-node-icon
|
(defn- get-node-icon
|
||||||
[node]
|
[node]
|
||||||
(cond
|
(cond
|
||||||
(db/page? node)
|
(ldb/class? node)
|
||||||
|
"hash"
|
||||||
|
(ldb/property? node)
|
||||||
|
"letter-p"
|
||||||
|
(ldb/page? node)
|
||||||
"page"
|
"page"
|
||||||
(seq (:block/tags node))
|
|
||||||
"topology-star"
|
|
||||||
:else
|
:else
|
||||||
"block"))
|
"letter-n"))
|
||||||
|
|
||||||
(rum/defc select-node < rum/reactive db-mixins/query
|
(rum/defc select-node < rum/reactive db-mixins/query
|
||||||
[property
|
[property
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
[repo block idx sidebar-key ref?]
|
[repo block idx sidebar-key ref?]
|
||||||
(when-let [block-id (:block/uuid block)]
|
(when-let [block-id (:block/uuid block)]
|
||||||
[[:.flex.items-center {:class (when ref? "ml-2")}
|
[[:.flex.items-center {:class (when ref? "ml-2")}
|
||||||
(ui/icon "block" {:class "text-md mr-2"})
|
(ui/icon "letter-n" {:class "text-md mr-2"})
|
||||||
(block/breadcrumb {:id "block-parent"
|
(block/breadcrumb {:id "block-parent"
|
||||||
:block? true
|
:block? true
|
||||||
:sidebar-key sidebar-key} repo block-id {:indent? false})]
|
:sidebar-key sidebar-key} repo block-id {:indent? false})]
|
||||||
|
|
|
@ -638,8 +638,8 @@
|
||||||
:header/go-back "Go back"
|
:header/go-back "Go back"
|
||||||
:header/go-forward "Go forward"
|
:header/go-forward "Go forward"
|
||||||
|
|
||||||
;; E.g. 1 Object or 2 Objects
|
;; E.g. 1 node or 2 nodes
|
||||||
:views.table/default-title (fn [total] (str total (if (= total 1) " Object" " Objects")))
|
:views.table/default-title (fn [total] (str total (if (= total 1) " Node" " Nodes")))
|
||||||
|
|
||||||
;; Commands are nested for now to stay in sync with the shortcuts system.
|
;; Commands are nested for now to stay in sync with the shortcuts system.
|
||||||
;; Other languages should not nest keys under :commands
|
;; Other languages should not nest keys under :commands
|
||||||
|
|
Loading…
Reference in New Issue