From 16d9bc85738ddf54e9de53cec8f3d6a8d12bde14 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Sun, 29 May 2022 11:13:42 +0800 Subject: [PATCH] enhance: display an edit icon if a block only has a block ref --- src/main/frontend/components/block.cljs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index 087d05f57..28a0ef739 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -2090,7 +2090,11 @@ (let [*hide-block-refs? (get state :hide-block-refs?) editor-box (get config :editor-box) editor-id (str "editor-" edit-input-id) - slide? (:slide? config)] + slide? (:slide? config) + trimmed-content (string/trim (:block/content block)) + block-reference-only? (and (string/starts-with? trimmed-content "((") + (re-find (re-pattern util/uuid-pattern) trimmed-content) + (string/ends-with? trimmed-content "))"))] (if (and edit? editor-box) [:div.editor-wrapper {:id editor-id} (ui/catch-error @@ -2127,6 +2131,13 @@ (editor-handler/edit-block! block :max (:block/uuid block))))} svg/edit]) + (when block-reference-only? + [:a.opacity-30.hover:opacity-100.svg-small.inline + {:on-mouse-down (fn [e] + (util/stop e) + (editor-handler/edit-block! block :max (:block/uuid block)))} + svg/edit]) + (block-refs-count block *hide-block-refs?)]] (when (and (not @*hide-block-refs?) (> refs-count 0))