mirror of https://github.com/logseq/logseq
fix(android): blur input when composing
parent
7bad07d2bf
commit
03d4b272b2
|
@ -740,21 +740,17 @@
|
||||||
(let [[new-content _] (marker/cycle-marker content marker new-marker format (state/get-preferred-workflow))]
|
(let [[new-content _] (marker/cycle-marker content marker new-marker format (state/get-preferred-workflow))]
|
||||||
(save-block-if-changed! block new-content))))
|
(save-block-if-changed! block new-content))))
|
||||||
|
|
||||||
(defn cycle-todo-by-block-ids!
|
(defn cycle-todos!
|
||||||
[ids]
|
[]
|
||||||
(when-let [ids (filter uuid? (distinct ids))]
|
(when-let [blocks (seq (get-selected-blocks))]
|
||||||
|
(let [ids (->> (distinct (map #(when-let [id (dom/attr % "blockid")]
|
||||||
|
(uuid id)) blocks))
|
||||||
|
(remove nil?))]
|
||||||
(outliner-tx/transact! {:outliner-op :cycle-todos}
|
(outliner-tx/transact! {:outliner-op :cycle-todos}
|
||||||
(doseq [id ids]
|
(doseq [id ids]
|
||||||
(let [block (db/pull [:block/uuid id])]
|
(let [block (db/pull [:block/uuid id])]
|
||||||
(when (not-empty (:block/content block))
|
(when (not-empty (:block/content block))
|
||||||
(set-marker block)))))))
|
(set-marker block))))))))
|
||||||
|
|
||||||
(defn cycle-todos!
|
|
||||||
[]
|
|
||||||
(when-let [blocks (seq (get-selected-blocks))]
|
|
||||||
(let [ids (map #(when-let [id (dom/attr % "blockid")]
|
|
||||||
(uuid id)) blocks)]
|
|
||||||
(cycle-todo-by-block-ids! ids))))
|
|
||||||
|
|
||||||
(defn cycle-todo!
|
(defn cycle-todo!
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -13,11 +13,21 @@
|
||||||
[goog.dom :as gdom]
|
[goog.dom :as gdom]
|
||||||
[rum.core :as rum]))
|
[rum.core :as rum]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn- blur-if-compositing
|
||||||
|
"Call blur on the textarea if it is in composition mode, let the IME commit the composing text"
|
||||||
|
[]
|
||||||
|
(when-let [edit-input-id (and (state/editor-in-composition?)
|
||||||
|
(state/get-edit-input-id))]
|
||||||
|
(let [textarea-el (gdom/getElement edit-input-id)]
|
||||||
|
(.blur textarea-el))))
|
||||||
|
|
||||||
(rum/defc indent-outdent [indent? icon]
|
(rum/defc indent-outdent [indent? icon]
|
||||||
[:div
|
[:div
|
||||||
[:button.bottom-action
|
[:button.bottom-action
|
||||||
{:on-mouse-down (fn [e]
|
{:on-mouse-down (fn [e]
|
||||||
(util/stop e)
|
(util/stop e)
|
||||||
|
(blur-if-compositing)
|
||||||
(editor-handler/indent-outdent indent?))}
|
(editor-handler/indent-outdent indent?))}
|
||||||
(ui/icon icon {:size ui/icon-size})]])
|
(ui/icon icon {:size ui/icon-size})]])
|
||||||
|
|
||||||
|
@ -94,12 +104,9 @@
|
||||||
;; On mobile devies, some IME(keyboard) uses composing mode.
|
;; On mobile devies, some IME(keyboard) uses composing mode.
|
||||||
;; The composing text can be committed by losing focus.
|
;; The composing text can be committed by losing focus.
|
||||||
;; 100ms is enough to commit the composing text to db.
|
;; 100ms is enough to commit the composing text to db.
|
||||||
(command #(when-let [block-id (:block/uuid (state/get-edit-block))]
|
(command #(do
|
||||||
(editor-handler/escape-editing true)
|
(blur-if-compositing)
|
||||||
(js/setTimeout
|
(editor-handler/cycle-todo!))
|
||||||
(fn []
|
|
||||||
(editor-handler/cycle-todo-by-block-ids! [block-id]))
|
|
||||||
100))
|
|
||||||
{:icon "checkbox"} true)
|
{:icon "checkbox"} true)
|
||||||
(command #(mobile-camera/embed-photo parent-id) {:icon "camera"} true)
|
(command #(mobile-camera/embed-photo parent-id) {:icon "camera"} true)
|
||||||
(command history/undo! {:icon "rotate" :class "rotate-180"} true)
|
(command history/undo! {:icon "rotate" :class "rotate-180"} true)
|
||||||
|
|
Loading…
Reference in New Issue