mirror of
https://github.com/penpot/penpot.git
synced 2025-05-13 15:36:39 +02:00
🐛 Fixes problem with edition state and paths
This commit is contained in:
parent
2c96ecac87
commit
5e0101e424
5 changed files with 20 additions and 7 deletions
|
@ -240,10 +240,13 @@
|
||||||
(ptk/reify ::finalize-page
|
(ptk/reify ::finalize-page
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [local (:workspace-local state)]
|
(let [local (-> (:workspace-local state)
|
||||||
|
(dissoc :edition)
|
||||||
|
(dissoc :edit-path)
|
||||||
|
(dissoc :selected))]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:workspace-cache page-id] local)
|
(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
|
;; Workspace Page CRUD
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.path.changes :as changes]
|
[app.main.data.workspace.path.changes :as changes]
|
||||||
[app.main.data.workspace.path.common :as common]
|
[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)]
|
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
||||||
|
|
||||||
|
(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})
|
(rx/of (dch/commit-changes rch uch {:commit-local? true})
|
||||||
(selection/update-selection point-change)
|
(selection/update-selection point-change)
|
||||||
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler)))))))
|
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))
|
||||||
|
|
||||||
(defn modify-content-point
|
(defn modify-content-point
|
||||||
[content {dx :x dy :y} modifiers point]
|
[content {dx :x dy :y} modifiers point]
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
(defn end-path-event? [{:keys [type shift] :as event}]
|
(defn end-path-event? [{:keys [type shift] :as event}]
|
||||||
(or (= (ptk/type event) ::common/finish-path)
|
(or (= (ptk/type event) ::common/finish-path)
|
||||||
(= (ptk/type event) :esc-pressed)
|
(= (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
|
(= event :interrupt) ;; ESC
|
||||||
(and (ms/mouse-double-click? event))))
|
(and (ms/mouse-double-click? event))))
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[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.changes :as changes]
|
||||||
[app.main.data.workspace.path.common :as common]
|
[app.main.data.workspace.path.common :as common]
|
||||||
[app.main.data.workspace.path.state :as st]
|
[app.main.data.workspace.path.state :as st]
|
||||||
|
@ -34,7 +35,9 @@
|
||||||
new-content (-> (tool-fn (:content shape) points)
|
new-content (-> (tool-fn (:content shape) points)
|
||||||
(ups/close-subpaths))
|
(ups/close-subpaths))
|
||||||
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
[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
|
(defn make-corner
|
||||||
([]
|
([]
|
||||||
|
|
|
@ -124,7 +124,8 @@
|
||||||
dissoc :undo-lock :undo-stack)))))
|
dissoc :undo-lock :undo-stack)))))
|
||||||
|
|
||||||
(defn- stop-undo? [event]
|
(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
|
(def path-content-ref
|
||||||
(letfn [(selector [state]
|
(letfn [(selector [state]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue