From 1b20c3e21432242f257b633f0925c572fabdaf06 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 7 Dec 2020 21:35:14 +0800 Subject: [PATCH] fix: restore the editing cursor after saving a block --- src/main/frontend/handler/editor.cljs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index fe949ab81..ffff0803a 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -1353,7 +1353,11 @@ (when (and block value db-content-without-heading (not= (string/trim db-content-without-heading) (string/trim value))) - (save-block-aux! block value (:block/format block))))))) + (let [cur-pos (util/get-input-pos elem)] + (save-block-aux! block value (:block/format block)) + ;; Restore the cursor after saving the block + (when (and elem cur-pos) + (util/set-caret-pos! elem cur-pos)))))))) (defn on-up-down [state e up?]