From 56e313610344eccb5848a25768c5251c09292c32 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 16 Dec 2024 11:16:35 +0800 Subject: [PATCH] enhance: skip property inner text when navigating properties --- src/main/frontend/handler/editor.cljs | 10 +++++++++- src/main/frontend/state.cljs | 12 ++++-------- src/main/frontend/util/cursor.cljs | 7 +++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 93a15f71d45..e09d8a7bc31 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -2720,7 +2720,15 @@ (= input element) (cond - (and property? right? (cursor/end? input) (not= (get-in block [:block/schema :type]) :default)) + (and property? right? (not (cursor/end? input))) + (cursor/move-cursor-to-end input) + + (and property? left? (not (cursor/start? input))) + (cursor/move-cursor-to-start input) + + (and property? right? (cursor/end? input) + (or (not= (get-in block [:block/schema :type]) :default) + (seq (:property/closed-values block)))) (let [pair (util/rec-get-node input "property-pair") jtrigger (when pair (dom/sel1 pair ".property-value-container .jtrigger"))] (when jtrigger diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 0cdeab30ae7..a0968abb737 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -1169,21 +1169,17 @@ Similar to re-frame subscriptions" (dom/remove-class! node "selected"))) (defn mark-dom-blocks-as-selected - ([] - (mark-dom-blocks-as-selected (get-selection-block-ids))) - ([ids] - (doseq [id ids] - (doseq [node (array-seq (gdom/getElementsByClass (str "id" id)))] - (dom/add-class! node "selected"))))) + [nodes] + (doseq [node nodes] + (dom/add-class! node "selected"))) (defn- set-selection-blocks-aux! [blocks] (let [selected-ids (set (get-selected-block-ids @(:selection/blocks @state))) _ (set-state! :selection/blocks blocks) new-ids (set (get-selection-block-ids)) - added (set/difference new-ids selected-ids) removed (set/difference selected-ids new-ids)] - (mark-dom-blocks-as-selected added) + (mark-dom-blocks-as-selected blocks) (doseq [id removed] (doseq [node (array-seq (gdom/getElementsByClass (str "id" id)))] (dom/remove-class! node "selected"))))) diff --git a/src/main/frontend/util/cursor.cljs b/src/main/frontend/util/cursor.cljs index e6564ae118a..94bf8086154 100644 --- a/src/main/frontend/util/cursor.cljs +++ b/src/main/frontend/util/cursor.cljs @@ -130,10 +130,9 @@ [input] (move-cursor-to input (line-beginning-pos input)))) -(comment - (defn move-cursor-to-start - [input] - (move-cursor-to input 0))) +(defn move-cursor-to-start + [input] + (move-cursor-to input 0)) (defn move-cursor-to-end [input]