From ce0ffc0ea22239abf121b73cadecf981215caff9 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Sat, 25 Apr 2026 20:31:16 +0800 Subject: [PATCH] fix: restore bottom property keyboard navigation --- src/main/frontend/components/block.cljs | 4 +--- src/main/frontend/components/container.cljs | 8 +++---- src/main/frontend/components/container.css | 8 +++---- src/main/frontend/components/editor.cljs | 2 -- src/main/frontend/handler/editor.cljs | 24 +++++++++++++++++++-- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index f2b24c5456..8fbbb7c3c1 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -2709,7 +2709,7 @@ (property-component/property-key-cp block property opts) [:div.select-none ":"]] [:div {:class (util/classnames - ["bottom-property-content ls-block property-value-container" + ["bottom-property-content property-value-container" {:bottom-property-content-wrap many-node?}]) :style {:min-height 20}} (pv/property-value block property opts) @@ -3380,8 +3380,6 @@ (when doc-mode? (dom/remove-class! node "hide-inner-bullet")))) (when (non-dragging? e) - (when-let [container (gdom/getElement "app-container-wrapper")] - (dom/add-class! container "blocks-selection-mode")) (editor-handler/highlight-selection-area! block-id block-dom-node {:append? true}))))) (defn- block-mouse-leave diff --git a/src/main/frontend/components/container.cljs b/src/main/frontend/components/container.cljs index 47de27a509..986d9111cd 100644 --- a/src/main/frontend/components/container.cljs +++ b/src/main/frontend/components/container.cljs @@ -440,11 +440,9 @@ :ls-fold-button-on-right fold-button-on-right? :ls-hl-colored ls-block-hl-colored?}]) :on-pointer-up (fn [] - (when-let [container (gdom/getElement "app-container-wrapper")] - (d/remove-class! container "blocks-selection-mode") - (when (and (> (count (state/get-selection-blocks)) 1) - (not (util/input? js/document.activeElement))) - (util/clear-selection!))))} + (when (and (> (count (state/get-selection-blocks)) 1) + (not (util/input? js/document.activeElement))) + (util/clear-selection!)))} [:button#skip-to-main {:on-click #(ui/focus-element (ui/main-node)) diff --git a/src/main/frontend/components/container.css b/src/main/frontend/components/container.css index 8f87d4191a..8bf0226389 100644 --- a/src/main/frontend/components/container.css +++ b/src/main/frontend/components/container.css @@ -765,9 +765,7 @@ html[data-theme='dark'] { } } -.blocks-selection-mode .page-title, -.blocks-selection-mode .block-content-inner, -.blocks-selection-mode .block-body, -.blocks-selection-mode .ls-properties-area { - @apply select-none; +.ls-block.selected, +.ls-block.selected * { + user-select: none; } diff --git a/src/main/frontend/components/editor.cljs b/src/main/frontend/components/editor.cljs index 5104eb75be..23b322a021 100644 --- a/src/main/frontend/components/editor.cljs +++ b/src/main/frontend/components/editor.cljs @@ -691,8 +691,6 @@ ;; exit editing mode :else (let [select? (= type :esc)] - (when-let [container (gdom/getElement "app-container")] - (dom/remove-class! container "blocks-selection-mode")) (p/do! (editor-handler/escape-editing {:select? select? :editing-another-block? editing-another-block?}) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 28d7c09494..3c9cbb69d6 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -2154,6 +2154,10 @@ [node] (some-> node (.closest ".bottom-properties-row"))) +(defn- bottom-properties-row-in-block + [block-node] + (some-> block-node (.querySelector ".bottom-properties-row"))) + (defn- focus-trigger [_current-block sibling-block] (if-let [trigger (first (dom/by-class sibling-block "jtrigger"))] @@ -2182,9 +2186,11 @@ (assoc :exclude-property? true))) {:block/keys [uuid title]} (state/get-edit-block) sibling-block (or (when (property-value-node? sibling-block) - (first (dom/by-class sibling-block "ls-block"))) + (util/rec-get-node sibling-block "ls-block")) sibling-block) + current-bottom-properties-row (bottom-properties-row-in-block current-block) bottom-properties-row (bottom-properties-row-node sibling-block) + sibling-bottom-properties-row (bottom-properties-row-in-block sibling-block) property-value-container? (property-value-node? sibling-block)] (if sibling-block (let [sibling-block-id (dom/attr sibling-block "blockid") @@ -2198,6 +2204,20 @@ (save-block! repo uuid value)) (cond + (and (= :down direction) + input + (= active-element input) + current-bottom-properties-row) + (do + (state/clear-edit!) + (.focus current-bottom-properties-row)) + + (and (= :up direction) + sibling-bottom-properties-row) + (do + (state/clear-edit!) + (.focus sibling-bottom-properties-row)) + (and (dom/has-class? sibling-block "block-add-button") (util/rec-get-node current-block "ls-page-title")) (.click sibling-block) @@ -2264,7 +2284,7 @@ sibling-block (or (when (and sibling-block (property-value-node? sibling-block)) (if (and up? editing-block (gdom/contains sibling-block editing-block)) (f sibling-block) - (first (dom/by-class sibling-block "ls-block")))) + (util/rec-get-node sibling-block "ls-block"))) sibling-block)] (when sibling-block (let [content (:block/title block)