فهرست منبع

enhance: display an edit icon if a block only has a block ref

Tienson Qin 3 سال پیش
والد
کامیت
16d9bc8573
1فایلهای تغییر یافته به همراه12 افزوده شده و 1 حذف شده
  1. 12 1
      src/main/frontend/components/block.cljs

+ 12 - 1
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))