Skip to content

Commit de94684

Browse files
committed
fix: block refs that are hyperlinks are unable to be navigated to
fixes logseq/db-test#545
1 parent 5e0d52a commit de94684

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/main/frontend/components/block.cljs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@
836836
s (if (and tag? (not (:hide-tag-symbol? config))) (str "#" s) s)]
837837
(if (ldb/page? page-entity)
838838
s
839-
(block-title config page-entity {}))))]
839+
(block-title (assoc config :page-ref? true) page-entity {}))))]
840840
page-component))]]))
841841

842842
(rum/defc popup-preview-impl
@@ -1647,14 +1647,17 @@
16471647
(media-link config url href label metadata full_text)
16481648

16491649
:else
1650-
(->elem
1651-
:a.external-link
1652-
(cond->
1653-
{:href href
1654-
:target "_blank"}
1655-
title
1656-
(assoc :title title))
1657-
(map-inline config label)))))))
1650+
(if (:node-ref-link-only? config)
1651+
[:span
1652+
(map-inline config label)]
1653+
(->elem
1654+
:a.external-link
1655+
(cond->
1656+
{:target "_blank"
1657+
:href href}
1658+
title
1659+
(assoc :title title))
1660+
(map-inline config label))))))))
16581661

16591662
(declare ->hiccup inline)
16601663

@@ -2414,14 +2417,19 @@
24142417
(file-block/marker-cp block)
24152418
(file-block/priority-cp block)])
24162419

2417-
;; highlight ref block (inline)
2420+
;; highlight ref block (inline)
24182421
(when-not area? [(hl-ref)])
24192422

2420-
(conj
2421-
(map-inline config block-ast-title)
2422-
(when (= block-type :whiteboard-shape) [:span.mr-1 (ui/icon "whiteboard-element" {:extension? true})]))
2423+
(let [config' (cond-> config
2424+
(and (:page-ref? config)
2425+
(= 1 (count block-ast-title))
2426+
(= "Link" (ffirst block-ast-title)))
2427+
(assoc :node-ref-link-only? true))]
2428+
(conj
2429+
(map-inline config' block-ast-title)
2430+
(when (= block-type :whiteboard-shape) [:span.mr-1 (ui/icon "whiteboard-element" {:extension? true})])))
24232431

2424-
;; highlight ref block (area)
2432+
;; highlight ref block (area)
24252433
(when area? [(hl-ref)])
24262434

24272435
(when (and (seq block-ast-title) (ldb/class-instance?

0 commit comments

Comments
 (0)