fix(mobile): commit composing text before cycle todo

Close #10879
Close #8503
Close #10013
pull/10940/head
Andelf 2024-01-25 13:09:16 +08:00
parent 402ee7870d
commit 7bad07d2bf
2 changed files with 22 additions and 9 deletions

View File

@ -740,17 +740,21 @@
(let [[new-content _] (marker/cycle-marker content marker new-marker format (state/get-preferred-workflow))]
(save-block-if-changed! block new-content))))
(defn cycle-todo-by-block-ids!
[ids]
(when-let [ids (filter uuid? (distinct ids))]
(outliner-tx/transact! {:outliner-op :cycle-todos}
(doseq [id ids]
(let [block (db/pull [:block/uuid id])]
(when (not-empty (:block/content block))
(set-marker block)))))))
(defn cycle-todos!
[]
(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}
(doseq [id ids]
(let [block (db/pull [:block/uuid id])]
(when (not-empty (:block/content block))
(set-marker block))))))))
(let [ids (map #(when-let [id (dom/attr % "blockid")]
(uuid id)) blocks)]
(cycle-todo-by-block-ids! ids))))
(defn cycle-todo!
[]

View File

@ -91,7 +91,16 @@
(command #(if (state/sub :document/mode?)
(editor-handler/insert-new-block! nil)
(commands/simple-insert! parent-id "\n" {})) {:icon "arrow-back"})
(command editor-handler/cycle-todo! {:icon "checkbox"} true)
;; On mobile devies, some IME(keyboard) uses composing mode.
;; The composing text can be committed by losing focus.
;; 100ms is enough to commit the composing text to db.
(command #(when-let [block-id (:block/uuid (state/get-edit-block))]
(editor-handler/escape-editing true)
(js/setTimeout
(fn []
(editor-handler/cycle-todo-by-block-ids! [block-id]))
100))
{:icon "checkbox"} true)
(command #(mobile-camera/embed-photo parent-id) {:icon "camera"} true)
(command history/undo! {:icon "rotate" :class "rotate-180"} true)
(command history/redo! {:icon "rotate-clockwise" :class "rotate-180"} true)