Skip to content

Commit 1cf4fa9

Browse files
committed
enhance(ux): add highlights to unlinked references
1 parent d1bbb5a commit 1cf4fa9

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

src/main/frontend/components/block.cljs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
[frontend.handler.property :as property-handler]
5050
[frontend.handler.property.util :as pu]
5151
[frontend.handler.route :as route-handler]
52+
[frontend.handler.search :as search-handler]
5253
[frontend.handler.ui :as ui-handler]
5354
[frontend.mixins :as mixins]
5455
[frontend.mobile.haptics :as haptics]
@@ -1544,10 +1545,21 @@
15441545
(hiccups.core/html)
15451546
(security/sanitize-html))))
15461547

1548+
(defn- highlight-query-text
1549+
[content query]
1550+
(if (and (string? content)
1551+
(not (string/blank? query))
1552+
(string/includes? (string/lower-case content)
1553+
(string/lower-case query)))
1554+
(search-handler/highlight-exact-query content query)
1555+
content))
1556+
15471557
(defn ^:large-vars/cleanup-todo inline
15481558
[{:keys [html-export?] :as config} item]
15491559
(match item
1550-
[(:or "Plain" "Spaces") s]
1560+
["Plain" s]
1561+
(highlight-query-text s (:highlight-query config))
1562+
["Spaces" s]
15511563
s
15521564

15531565
["Superscript" l]

src/main/frontend/components/reference.cljs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@
8383
(set-has-references! result))))
8484
[])
8585
(when has-references?
86-
[:div.unlinked-references
87-
(views/view
88-
{:view-parent entity
89-
:view-feature-type :unlinked-references
90-
:columns (views/build-columns config [] {})
91-
:foldable-options {:default-collapsed? true}
92-
:config config})]))))
86+
(let [config (assoc config :highlight-query (:block/title entity))]
87+
[:div.unlinked-references
88+
(views/view
89+
{:view-parent entity
90+
:view-feature-type :unlinked-references
91+
:columns (views/build-columns config [] {})
92+
:foldable-options {:default-collapsed? true}
93+
:config config})])))))

0 commit comments

Comments
 (0)