mirror of https://github.com/logseq/logseq
fix: IME check refactor
parent
2eca2c3c75
commit
7a8527b3f8
|
@ -388,7 +388,7 @@
|
||||||
(when @search-timeout
|
(when @search-timeout
|
||||||
(js/clearTimeout @search-timeout))
|
(js/clearTimeout @search-timeout))
|
||||||
(let [value (util/evalue e)
|
(let [value (util/evalue e)
|
||||||
is-composing? (util/event-is-composing? e)]
|
is-composing? (util/onchange-event-is-composing? e)]
|
||||||
(if (and (string/blank? value) (not is-composing?))
|
(if (and (string/blank? value) (not is-composing?))
|
||||||
(search-handler/clear-search! false)
|
(search-handler/clear-search! false)
|
||||||
(let [search-mode (state/get-search-mode)
|
(let [search-mode (state/get-search-mode)
|
||||||
|
|
|
@ -1493,6 +1493,20 @@
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(defn event-is-composing?
|
(defn event-is-composing?
|
||||||
|
"Check if keydown event is a composing (IME) event.
|
||||||
|
Ignore the IME finishing keycode by default."
|
||||||
|
([e]
|
||||||
|
(event-is-composing? e true))
|
||||||
|
([e ignore-finish?]
|
||||||
|
(let [event-composing? (gobj/getValueByKeys e "event_" "isComposing")
|
||||||
|
finish-keycode? (= (.-keyCode e) 229)]
|
||||||
|
(if ignore-finish?
|
||||||
|
(and event-composing? (not finish-keycode?))
|
||||||
|
(or event-composing? finish-keycode?))))))
|
||||||
|
|
||||||
|
#?(:cljs
|
||||||
|
(defn onchange-event-is-composing?
|
||||||
|
"Check if onchange event of Input is a composing (IME) event.
|
||||||
|
Including IME finishing."
|
||||||
[e]
|
[e]
|
||||||
(or (gobj/getValueByKeys e "event_" "isComposing")
|
(gobj/getValueByKeys e "nativeEvent" "isComposing"))) ;; No keycode available
|
||||||
(= (.-keyCode e) 229))))
|
|
||||||
|
|
Loading…
Reference in New Issue