enhance(ux): improve blocks selection for the dummy block button

This commit is contained in:
charlie
2025-06-30 14:24:44 +08:00
committed by Tienson Qin
parent 702255adea
commit afc36f4549
2 changed files with 12 additions and 11 deletions

View File

@@ -110,7 +110,7 @@
(when page?
[:div.ls-block.block-add-button.flex-1.flex-col.rounded-sm.cursor-text.transition-opacity.ease-in.duration-100.!py-0
{:class opacity-class
:data-block-id (:db/id block)
:blockid (:db/id block)
:ref *ref
:on-click (fn [e]
(util/stop e)
@@ -130,11 +130,10 @@
:on-mouse-leave #(do
(dom/remove-class! (rum/deref *ref) "opacity-50")
(dom/remove-class! (rum/deref *ref) "opacity-100"))
:on-key-down (fn [e]
:on-key-down (fn [^js e]
(util/stop e)
(when (= "Enter" (util/ekey e))
(state/set-state! :editor/container-id container-id)
(editor-handler/api-insert-new-block! "" (merge config block))))
(-> e (.-target) (.click))))
:tab-index 0}
[:div.flex.flex-row
[:div.flex.items-center {:style {:height 28

View File

@@ -3380,13 +3380,15 @@
(let [selected-blocks (state/get-selection-blocks)
f (case direction :left first :right last)
node (some-> selected-blocks f)]
(when-let [block-id (some-> node (dom/attr "blockid") uuid)]
(util/stop e)
(let [block {:block/uuid block-id}
left? (= direction :left)
opts {:container-id (some-> node (dom/attr "containerid") (parse-long))
:event e}]
(edit-block! block (if left? 0 :max) opts)))))
(if (some-> node (dom/has-class? "block-add-button"))
(.click node)
(when-let [block-id (some-> node (dom/attr "blockid") uuid)]
(util/stop e)
(let [block {:block/uuid block-id}
left? (= direction :left)
opts {:container-id (some-> node (dom/attr "containerid") (parse-long))
:event e}]
(edit-block! block (if left? 0 :max) opts))))))
(defn shortcut-left-right [direction]
(fn [e]