🐛 Fixed problem when editing paths

This commit is contained in:
alonso.torres 2021-04-05 11:23:46 +02:00
parent 88a3548d7e
commit 9e348ecc99
3 changed files with 12 additions and 11 deletions

View file

@ -547,8 +547,8 @@
(update [_ state] (update [_ state]
(let [id (get-in state [:workspace-local :edition])] (let [id (get-in state [:workspace-local :edition])]
(-> state (-> state
(update-in [:workspace-local :hover] disj id) (update :workspace-local dissoc :edition)
(update :workspace-local dissoc :edition)))))) (cond-> (some? id) (update-in [:workspace-local :edit-path] dissoc id)))))))
(defn get-shape-layer-position (defn get-shape-layer-position
[objects selected attrs] [objects selected attrs]

View file

@ -87,10 +87,11 @@
drawing-tool (:tool drawing) drawing-tool (:tool drawing)
drawing-obj (:object drawing) drawing-obj (:object drawing)
drawing-path? (and edition (= :draw (get-in edit-path [edition :edit-mode]))) drawing-path? (or (and edition (= :draw (get-in edit-path [edition :edit-mode])))
(and (some? drawing-obj) (= :path (:type drawing-obj))))
text-editing? (and edition (= :text (get-in objects [edition :type]))) text-editing? (and edition (= :text (get-in objects [edition :type])))
on-click (actions/on-click hover selected) on-click (actions/on-click hover selected edition drawing-path?)
on-context-menu (actions/on-context-menu hover) on-context-menu (actions/on-context-menu hover)
on-double-click (actions/on-double-click hover hover-ids drawing-path? objects) on-double-click (actions/on-double-click hover hover-ids drawing-path? objects)
on-drag-enter (actions/on-drag-enter) on-drag-enter (actions/on-drag-enter)
@ -115,7 +116,7 @@
show-draw-area? drawing-obj show-draw-area? drawing-obj
show-gradient-handlers? (= (count selected) 1) show-gradient-handlers? (= (count selected) 1)
show-grids? (contains? layout :display-grid) show-grids? (contains? layout :display-grid)
show-outlines? (and (nil? transform) (not edit-path)) show-outlines? (and (nil? transform) (not edition) (not drawing-obj))
show-pixel-grid? (>= zoom 8) show-pixel-grid? (>= zoom 8)
show-presence? page-id show-presence? page-id
show-prototypes? (= options-mode :prototype) show-prototypes? (= options-mode :prototype)

View file

@ -32,7 +32,7 @@
(defn on-mouse-down (defn on-mouse-down
[{:keys [id blocked hidden type]} drawing-tool text-editing? edition edit-path selected] [{:keys [id blocked hidden type]} drawing-tool text-editing? edition edit-path selected]
(mf/use-callback (mf/use-callback
(mf/deps id blocked hidden type drawing-tool text-editing? edition selected) (mf/deps id blocked hidden type drawing-tool text-editing? edition edit-path selected)
(fn [bevent] (fn [bevent]
(when (dom/class? (dom/get-target bevent) "viewport-controls") (when (dom/class? (dom/get-target bevent) "viewport-controls")
(dom/stop-propagation bevent) (dom/stop-propagation bevent)
@ -63,14 +63,14 @@
(and drawing-tool (not (#{:comments :path} drawing-tool))) (and drawing-tool (not (#{:comments :path} drawing-tool)))
(st/emit! (dd/start-drawing drawing-tool)) (st/emit! (dd/start-drawing drawing-tool))
edit-path (and edit-path (contains? edit-path edition))
;; Handle node select-drawing. NOP at the moment ;; Handle node select-drawing. NOP at the moment
nil nil
(or (not id) (and frame? (not selected?))) (or (not id) (and frame? (not selected?)))
(st/emit! (dw/handle-selection shift?)) (st/emit! (dw/handle-selection shift?))
:else (not drawing-tool)
(st/emit! (when (or shift? (not selected?)) (st/emit! (when (or shift? (not selected?))
(dw/select-shape id shift?)) (dw/select-shape id shift?))
(when (not shift?) (when (not shift?)
@ -119,9 +119,9 @@
(reset! frame-hover nil)))) (reset! frame-hover nil))))
(defn on-click (defn on-click
[hover selected] [hover selected edition drawing-path?]
(mf/use-callback (mf/use-callback
(mf/deps @hover selected) (mf/deps @hover selected edition drawing-path?)
(fn [event] (fn [event]
(when (dom/class? (dom/get-target event) "viewport-controls") (when (dom/class? (dom/get-target event) "viewport-controls")
(let [ctrl? (kbd/ctrl? event) (let [ctrl? (kbd/ctrl? event)
@ -133,7 +133,7 @@
selected? (contains? selected (:id @hover))] selected? (contains? selected (:id @hover))]
(st/emit! (ms/->MouseEvent :click ctrl? shift? alt?)) (st/emit! (ms/->MouseEvent :click ctrl? shift? alt?))
(when (and hovering? (not shift?) (not frame?) (not selected?)) (when (and hovering? (not shift?) (not frame?) (not selected?) (not edition) (not drawing-path?))
(st/emit! (dw/select-shape (:id @hover))))))))) (st/emit! (dw/select-shape (:id @hover)))))))))
(defn on-double-click (defn on-double-click