Enhance: don't move to the previous block when there's highlighted area and pressing `left`

pull/1547/head
Tienson Qin 2021-03-27 13:02:00 +08:00
parent b5d9200f82
commit 6b249aa865
2 changed files with 9 additions and 2 deletions

View File

@ -2369,8 +2369,9 @@
(defn- on-arrow-move-to-boundray
[state input e direction]
(when (or (and (= :left direction) (util/input-start? input))
(and (= :right direction) (util/input-end? input)))
(when (and (not (util/input-selected? input))
(or (and (= :left direction) (util/input-start? input))
(and (= :right direction) (util/input-end? input))))
(move-to-block-when-cross-boundrary state e direction)))
(defn keydown-arrow-handler

View File

@ -765,6 +765,12 @@
(= (count (.-value input))
(.-selectionStart input)))))
#?(:cljs
(defn input-selected?
[input]
(not= (.-selectionStart input)
(.-selectionEnd input))))
#?(:cljs
(defn get-selected-text
[]