Просмотр исходного кода

fix: copy with parent+child blocks loses the parent block

fixed LOG-3056
Tienson Qin 1 год назад
Родитель
Сommit
38f3cef2c5

+ 5 - 6
src/main/frontend/handler/editor.cljs

@@ -2080,12 +2080,11 @@
                    :else
                    true)]
 
-    (when has-unsaved-edits
-      (ui-outliner-tx/transact!
-       {:outliner-op :save-block}
-       (outliner-save-block! editing-block)))
-
-    (p/let [result (ui-outliner-tx/transact!
+    (p/let [_ (when has-unsaved-edits
+                (ui-outliner-tx/transact!
+                 {:outliner-op :save-block}
+                 (outliner-save-block! editing-block)))
+            result (ui-outliner-tx/transact!
                     {:outliner-op :insert-blocks
                      :additional-tx revert-cut-txs}
                     (when target-block'

+ 9 - 2
src/main/frontend/handler/editor/lifecycle.cljs

@@ -5,7 +5,8 @@
             [frontend.util :as util]
             [frontend.util.cursor :as cursor]
             [goog.dom :as gdom]
-            [frontend.db :as db]))
+            [frontend.db :as db]
+            [frontend.handler.block :as block-handler]))
 
 (defn did-mount!
   [state]
@@ -30,7 +31,13 @@
   state)
 
 (defn will-remount!
-  [_old-state state]
+  [old-state state]
+  (let [old-block (:block (first (:rum/args old-state)))
+        new-block (:block (first (:rum/args state)))
+        repo (state/get-current-repo)]
+    (when (not= (:block/content old-block) (:block/content new-block))
+      (util/set-change-value (state/get-input)
+                             (block-handler/sanity-block-content repo (get new-block :block/format :markdown) (:block/content new-block)))))
   (keyboards-handler/esc-save! state)
   state)