fix: wrong pos when pressing Backspace

Editor's state including last pos and cursor range need to be cleared
when callling block-handler/edit-block!
This commit is contained in:
Tienson Qin
2024-06-21 18:29:48 +08:00
parent 797b13ac78
commit f16e972709
2 changed files with 11 additions and 4 deletions

View File

@@ -1346,15 +1346,21 @@ Similar to re-frame subscriptions"
[]
(set-state! :editor/last-saved-cursor {}))
(defn clear-edit!
(defn clear-cursor-range!
[]
(set-state! :editor/cursor-range nil))
(defn clear-edit!
[& {:keys [clear-editing-block?]
:or {clear-editing-block? true}}]
(clear-editor-action!)
(set-state! :editor/editing? {})
(when clear-editing-block?
(set-state! :editor/editing? {})
(set-state! :editor/block nil))
(set-state! :editor/start-pos nil)
(clear-editor-last-pos!)
(set-state! :editor/cursor-range nil)
(clear-cursor-range!)
(set-state! :editor/content {})
(set-state! :editor/block nil)
(set-state! :ui/select-query-cache {}))
(defn into-code-editor-mode!