From 1cf4fa9efdf9d75dba477d143a6fa74bac09b311 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 5 Jan 2026 18:22:01 +0800 Subject: [PATCH] enhance(ux): add highlights to unlinked references --- src/main/frontend/components/block.cljs | 14 +++++++++++++- src/main/frontend/components/reference.cljs | 15 ++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 5bdb4e9c59..b10508206a 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -49,6 +49,7 @@ [frontend.handler.property :as property-handler] [frontend.handler.property.util :as pu] [frontend.handler.route :as route-handler] + [frontend.handler.search :as search-handler] [frontend.handler.ui :as ui-handler] [frontend.mixins :as mixins] [frontend.mobile.haptics :as haptics] @@ -1544,10 +1545,21 @@ (hiccups.core/html) (security/sanitize-html)))) +(defn- highlight-query-text + [content query] + (if (and (string? content) + (not (string/blank? query)) + (string/includes? (string/lower-case content) + (string/lower-case query))) + (search-handler/highlight-exact-query content query) + content)) + (defn ^:large-vars/cleanup-todo inline [{:keys [html-export?] :as config} item] (match item - [(:or "Plain" "Spaces") s] + ["Plain" s] + (highlight-query-text s (:highlight-query config)) + ["Spaces" s] s ["Superscript" l] diff --git a/src/main/frontend/components/reference.cljs b/src/main/frontend/components/reference.cljs index 462b6ae755..934e919174 100644 --- a/src/main/frontend/components/reference.cljs +++ b/src/main/frontend/components/reference.cljs @@ -83,10 +83,11 @@ (set-has-references! result)))) []) (when has-references? - [:div.unlinked-references - (views/view - {:view-parent entity - :view-feature-type :unlinked-references - :columns (views/build-columns config [] {}) - :foldable-options {:default-collapsed? true} - :config config})])))) + (let [config (assoc config :highlight-query (:block/title entity))] + [:div.unlinked-references + (views/view + {:view-parent entity + :view-feature-type :unlinked-references + :columns (views/build-columns config [] {}) + :foldable-options {:default-collapsed? true} + :config config})])))))