From 38f3cef2c56236abae2e157088238b7a4e55cdd4 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Tue, 27 Feb 2024 23:29:11 +0800 Subject: [PATCH] fix: copy with parent+child blocks loses the parent block fixed LOG-3056 --- src/main/frontend/handler/editor.cljs | 11 +++++------ src/main/frontend/handler/editor/lifecycle.cljs | 11 +++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 4f8f5d101..e582c0be2 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/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' diff --git a/src/main/frontend/handler/editor/lifecycle.cljs b/src/main/frontend/handler/editor/lifecycle.cljs index 7154afadc..24151926f 100644 --- a/src/main/frontend/handler/editor/lifecycle.cljs +++ b/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)