Skip to content

Commit

Permalink
enhance: skip property inner text when navigating properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Dec 16, 2024
1 parent f30879a commit 56e3136
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 9 additions & 1 deletion src/main/frontend/handler/editor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))))
Expand Down
7 changes: 3 additions & 4 deletions src/main/frontend/util/cursor.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 56e3136

Please sign in to comment.