diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 746abd5ec..0546fe18b 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -240,10 +240,13 @@ (ptk/reify ::finalize-page ptk/UpdateEvent (update [_ state] - (let [local (:workspace-local state)] + (let [local (-> (:workspace-local state) + (dissoc :edition) + (dissoc :edit-path) + (dissoc :selected))] (-> state (assoc-in [:workspace-cache page-id] local) - (dissoc :current-page-id :workspace-local :trimmed-page)))))) + (dissoc :current-page-id :workspace-local :trimmed-page :workspace-drawing)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Workspace Page CRUD diff --git a/frontend/src/app/main/data/workspace/path/edition.cljs b/frontend/src/app/main/data/workspace/path/edition.cljs index ad4f5ce24..b2217ea5e 100644 --- a/frontend/src/app/main/data/workspace/path/edition.cljs +++ b/frontend/src/app/main/data/workspace/path/edition.cljs @@ -9,6 +9,7 @@ [app.common.data :as d] [app.common.geom.point :as gpt] [app.common.math :as mth] + [app.main.data.workspace.common :as dwc] [app.main.data.workspace.changes :as dch] [app.main.data.workspace.path.changes :as changes] [app.main.data.workspace.path.common :as common] @@ -63,9 +64,12 @@ [rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)] - (rx/of (dch/commit-changes rch uch {:commit-local? true}) - (selection/update-selection point-change) - (fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))) + (if (empty? new-content) + (rx/of (dch/commit-changes rch uch {:commit-local? true}) + dwc/clear-edition-mode) + (rx/of (dch/commit-changes rch uch {:commit-local? true}) + (selection/update-selection point-change) + (fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler)))))))) (defn modify-content-point [content {dx :x dy :y} modifiers point] diff --git a/frontend/src/app/main/data/workspace/path/helpers.cljs b/frontend/src/app/main/data/workspace/path/helpers.cljs index 9f5fb0621..a1185b421 100644 --- a/frontend/src/app/main/data/workspace/path/helpers.cljs +++ b/frontend/src/app/main/data/workspace/path/helpers.cljs @@ -21,6 +21,8 @@ (defn end-path-event? [{:keys [type shift] :as event}] (or (= (ptk/type event) ::common/finish-path) (= (ptk/type event) :esc-pressed) + (= :app.main.data.workspace.common/clear-edition-mode (ptk/type event)) + (= :app.main.data.workspace/finalize-page (ptk/type event)) (= event :interrupt) ;; ESC (and (ms/mouse-double-click? event)))) diff --git a/frontend/src/app/main/data/workspace/path/tools.cljs b/frontend/src/app/main/data/workspace/path/tools.cljs index b1c49f754..2db369397 100644 --- a/frontend/src/app/main/data/workspace/path/tools.cljs +++ b/frontend/src/app/main/data/workspace/path/tools.cljs @@ -8,6 +8,7 @@ (:require [app.common.geom.point :as gpt] [app.main.data.workspace.changes :as dch] + [app.main.data.workspace.common :as dwc] [app.main.data.workspace.path.changes :as changes] [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.state :as st] @@ -34,7 +35,9 @@ new-content (-> (tool-fn (:content shape) points) (ups/close-subpaths)) [rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)] - (rx/of (dch/commit-changes rch uch {:commit-local? true}))))))) + (rx/of (dch/commit-changes rch uch {:commit-local? true}) + (when (empty? new-content) + dwc/clear-edition-mode))))))) (defn make-corner ([] diff --git a/frontend/src/app/main/data/workspace/path/undo.cljs b/frontend/src/app/main/data/workspace/path/undo.cljs index 061de999d..74c8fcb34 100644 --- a/frontend/src/app/main/data/workspace/path/undo.cljs +++ b/frontend/src/app/main/data/workspace/path/undo.cljs @@ -124,7 +124,8 @@ dissoc :undo-lock :undo-stack))))) (defn- stop-undo? [event] - (= :app.main.data.workspace.common/clear-edition-mode (ptk/type event))) + (or (= :app.main.data.workspace.common/clear-edition-mode (ptk/type event)) + (= :app.main.data.workspace/finalize-page (ptk/type event)))) (def path-content-ref (letfn [(selector [state]