浏览代码

fix: cursor not jump back when undo a DELETE at the end action

It also remove built-in properties such as id from the editor content
Tienson Qin 2 年之前
父节点
当前提交
4211cdc984

+ 2 - 1
src/main/frontend/components/block.cljs

@@ -2309,7 +2309,8 @@
 
 (rum/defc block-content < rum/reactive
   [config {:block/keys [uuid content children properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?]
-  (let [{:block/keys [title body] :as block} (if (:block/title block) block
+  (let [content (property/remove-built-in-properties format content)
+        {:block/keys [title body] :as block} (if (:block/title block) block
                                                  (merge block (block/parse-title-and-body uuid format pre-block? content)))
         collapsed? (util/collapsed? block)
         plugin-slotted? (and config/lsp-enabled? (state/slot-hook-exist? uuid))

+ 2 - 3
src/main/frontend/handler/editor.cljs

@@ -2634,9 +2634,8 @@
         (outliner-tx/transact! transact-opts
           (delete-block-aux! next-block false)
           (save-block! repo edit-block' new-content))
-
-        (state/set-edit-content! input-id new-content)
-        (cursor/move-cursor-to input current-pos)))))
+        (let [block (if next-block-has-refs? next-block edit-block)]
+          (edit-block! block current-pos (:block/uuid block)))))))
 
 (defn keydown-delete-handler
   [_e]

+ 1 - 1
src/main/frontend/handler/history.cljs

@@ -46,7 +46,7 @@
   (let [{:keys [editor-cursor app-state]} (undo-redo/undo)]
     (restore-cursor! editor-cursor)
     (restore-app-state! app-state))
-  (state/set-editor-op! nil))
+  (js/setTimeout #(state/set-editor-op! nil) 100))
 
 (defn redo!
   [e]

+ 7 - 3
src/main/frontend/modules/editor/undo_redo.cljs

@@ -7,7 +7,9 @@
             [frontend.util.page :as page-util]
             [frontend.state :as state]
             [clojure.set :as set]
-            [medley.core :as medley]))
+            [medley.core :as medley]
+            [frontend.util.drawer :as drawer]
+            [frontend.util.property :as property]))
 
 ;;;; APIs
 
@@ -157,8 +159,10 @@
   "Prevent block auto-save during undo/redo."
   []
   (when-let [block (state/get-edit-block)]
-    (state/set-edit-content! (state/get-edit-input-id)
-                             (:block/content (db/entity (:db/id block))))))
+    (let [content (:block/content (db/entity (:db/id block)))
+          content' (-> (property/remove-built-in-properties (:block/format block) content)
+                       (drawer/remove-logbook))]
+      (state/set-edit-content! (state/get-edit-input-id) content'))))
 
 (defn- get-next-tx-editor-cursor
   [tx-id]

+ 1 - 1
src/main/frontend/state.cljs

@@ -261,7 +261,7 @@
      ;;                :file-sync/last-synced-at {}}
      :file-sync/graph-state                 {:current-graph-uuid nil}
                                              ;; graph-uuid -> ...
-                                             
+
      :user/info                             {:UserGroups (storage/get :user-groups)}
      :encryption/graph-parsing?             false