mirror of
https://github.com/penpot/penpot.git
synced 2025-07-22 14:17:13 +02:00
🐛 Fix problem with enter to edit paths
This commit is contained in:
parent
7c21624e09
commit
3cb9470db2
6 changed files with 59 additions and 52 deletions
|
@ -53,6 +53,7 @@
|
||||||
- Updates worksans font [#744](https://github.com/penpot/penpot/issues/744)
|
- Updates worksans font [#744](https://github.com/penpot/penpot/issues/744)
|
||||||
- Fix problem with team management in dashboard [Taiga #1475](https://tree.taiga.io/project/penpot/issue/1475)
|
- Fix problem with team management in dashboard [Taiga #1475](https://tree.taiga.io/project/penpot/issue/1475)
|
||||||
- Fix problem with blending modes in masks [Taiga #1476](https://tree.taiga.io/project/penpot/issue/1476)
|
- Fix problem with blending modes in masks [Taiga #1476](https://tree.taiga.io/project/penpot/issue/1476)
|
||||||
|
- Fix problem with enter to edit paths [Taiga #1481](https://tree.taiga.io/project/penpot/issue/1481)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
|
|
||||||
|
|
|
@ -1015,9 +1015,13 @@
|
||||||
{:keys [id type shapes]} (get objects (first selected))]
|
{:keys [id type shapes]} (get objects (first selected))]
|
||||||
|
|
||||||
(case type
|
(case type
|
||||||
(:text :path)
|
:text
|
||||||
(rx/of (dwc/start-edition-mode id))
|
(rx/of (dwc/start-edition-mode id))
|
||||||
|
|
||||||
|
:path
|
||||||
|
(rx/of (dwc/start-edition-mode id)
|
||||||
|
(dwdp/start-path-edit id))
|
||||||
|
|
||||||
:group
|
:group
|
||||||
(rx/of (dwc/select-shapes (into (d/ordered-set) [(last shapes)])))
|
(rx/of (dwc/select-shapes (into (d/ordered-set) [(last shapes)])))
|
||||||
|
|
||||||
|
|
|
@ -517,33 +517,6 @@
|
||||||
objects (lookup-page-objects state page-id)]
|
objects (lookup-page-objects state page-id)]
|
||||||
(rx/of (expand-all-parents ids objects))))))
|
(rx/of (expand-all-parents ids objects))))))
|
||||||
|
|
||||||
;; --- Start shape "edition mode"
|
|
||||||
(defn stop-path-edit []
|
|
||||||
(ptk/reify ::stop-path-edit
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(let [id (get-in state [:workspace-local :edition])]
|
|
||||||
(update state :workspace-local dissoc :edit-path id)))))
|
|
||||||
|
|
||||||
(defn start-path-edit
|
|
||||||
[id]
|
|
||||||
(ptk/reify ::start-path-edit
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
;; Only edit if the object has been created
|
|
||||||
(if-let [id (get-in state [:workspace-local :edition])]
|
|
||||||
(assoc-in state [:workspace-local :edit-path id] {:edit-mode :move
|
|
||||||
:selected #{}
|
|
||||||
:snap-toggled true})
|
|
||||||
state))
|
|
||||||
|
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ state stream]
|
|
||||||
(->> stream
|
|
||||||
(rx/filter #(= % :interrupt))
|
|
||||||
(rx/take 1)
|
|
||||||
(rx/map #(stop-path-edit))))))
|
|
||||||
|
|
||||||
(declare clear-edition-mode)
|
(declare clear-edition-mode)
|
||||||
|
|
||||||
(defn start-edition-mode
|
(defn start-edition-mode
|
||||||
|
@ -562,15 +535,11 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [objects (lookup-page-objects state)
|
(let [objects (lookup-page-objects state)]
|
||||||
path? (= :path (get-in objects [id :type]))]
|
(->> stream
|
||||||
(rx/merge
|
(rx/filter interrupt?)
|
||||||
(when path?
|
(rx/take 1)
|
||||||
(rx/of (start-path-edit id)))
|
(rx/map (constantly clear-edition-mode)))))))
|
||||||
(->> stream
|
|
||||||
(rx/filter interrupt?)
|
|
||||||
(rx/take 1)
|
|
||||||
(rx/map (constantly clear-edition-mode))))))))
|
|
||||||
|
|
||||||
(def clear-edition-mode
|
(def clear-edition-mode
|
||||||
(ptk/reify ::clear-edition-mode
|
(ptk/reify ::clear-edition-mode
|
||||||
|
|
|
@ -180,11 +180,7 @@
|
||||||
(or (= (ptk/type event) ::finish-path)
|
(or (= (ptk/type event) ::finish-path)
|
||||||
(= (ptk/type event) :esc-pressed)
|
(= (ptk/type event) :esc-pressed)
|
||||||
(= event :interrupt) ;; ESC
|
(= event :interrupt) ;; ESC
|
||||||
(and (ms/mouse-double-click? event))
|
(and (ms/mouse-double-click? event))))
|
||||||
(and (ms/keyboard-event? event)
|
|
||||||
(= type :down)
|
|
||||||
;; TODO: Enter now finish path but can finish drawing/editing as well
|
|
||||||
(= enter-keycode (:key event)))))
|
|
||||||
|
|
||||||
(defn generate-path-changes [page-id shape old-content new-content]
|
(defn generate-path-changes [page-id shape old-content new-content]
|
||||||
(us/verify ::content old-content)
|
(us/verify ::content old-content)
|
||||||
|
@ -572,11 +568,13 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [id (get-in state [:workspace-local :edition])
|
(let [id (get-in state [:workspace-local :edition])
|
||||||
shape (get-in state (get-path state))
|
old-content (get-in state [:workspace-local :edit-path id :old-content])]
|
||||||
page-id (:current-page-id state)
|
(if (some? old-content)
|
||||||
old-content (get-in state [:workspace-local :edit-path id :old-content])
|
(let [shape (get-in state (get-path state))
|
||||||
[rch uch] (generate-path-changes page-id shape old-content (:content shape))]
|
page-id (:current-page-id state)
|
||||||
(rx/of (dwc/commit-changes rch uch {:commit-local? true}))))))
|
[rch uch] (generate-path-changes page-id shape old-content (:content shape))]
|
||||||
|
(rx/of (dwc/commit-changes rch uch {:commit-local? true})))
|
||||||
|
(rx/empty))))))
|
||||||
|
|
||||||
(declare start-draw-mode)
|
(declare start-draw-mode)
|
||||||
(defn check-changed-content []
|
(defn check-changed-content []
|
||||||
|
@ -829,3 +827,37 @@
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/observe-on :async)
|
(rx/observe-on :async)
|
||||||
(rx/map #(handle-new-shape-result shape-id))))))))
|
(rx/map #(handle-new-shape-result shape-id))))))))
|
||||||
|
|
||||||
|
(defn stop-path-edit []
|
||||||
|
(ptk/reify ::stop-path-edit
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(let [id (get-in state [:workspace-local :edition])]
|
||||||
|
(update state :workspace-local dissoc :edit-path id)))))
|
||||||
|
|
||||||
|
(defn start-path-edit
|
||||||
|
[id]
|
||||||
|
(ptk/reify ::start-path-edit
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(let [edit-path (get-in state [:workspace-local :edit-path id])]
|
||||||
|
|
||||||
|
(cond-> state
|
||||||
|
(or (not edit-path) (= :draw (:edit-mode edit-path)))
|
||||||
|
(assoc-in [:workspace-local :edit-path id] {:edit-mode :move
|
||||||
|
:selected #{}
|
||||||
|
:snap-toggled true})
|
||||||
|
|
||||||
|
(and (some? edit-path) (= :move (:edit-mode edit-path)))
|
||||||
|
(assoc-in [:workspace-local :edit-path id :edit-mode] :draw))))
|
||||||
|
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [mode (get-in state [:workspace-local :edit-path id :edit-mode])]
|
||||||
|
(rx/concat
|
||||||
|
(rx/of (change-edit-mode mode))
|
||||||
|
(->> stream
|
||||||
|
(rx/take-until (->> stream (rx/filter (ptk/type? ::start-path-edit))))
|
||||||
|
(rx/filter #(= % :interrupt))
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/map #(stop-path-edit))))))))
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
|
|
||||||
on-click (actions/on-click hover selected)
|
on-click (actions/on-click hover selected)
|
||||||
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 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)
|
||||||
on-drag-over (actions/on-drag-over)
|
on-drag-over (actions/on-drag-over)
|
||||||
on-drop (actions/on-drop file viewport-ref zoom)
|
on-drop (actions/on-drop file viewport-ref zoom)
|
||||||
|
|
|
@ -135,9 +135,9 @@
|
||||||
(st/emit! (dw/select-shape (:id @hover))))))))
|
(st/emit! (dw/select-shape (:id @hover))))))))
|
||||||
|
|
||||||
(defn on-double-click
|
(defn on-double-click
|
||||||
[hover hover-ids objects]
|
[hover hover-ids drawing-path? objects]
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps @hover @hover-ids)
|
(mf/deps @hover @hover-ids drawing-path?)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(let [ctrl? (kbd/ctrl? event)
|
(let [ctrl? (kbd/ctrl? event)
|
||||||
|
@ -153,7 +153,7 @@
|
||||||
|
|
||||||
(st/emit! (ms/->MouseEvent :double-click ctrl? shift? alt?))
|
(st/emit! (ms/->MouseEvent :double-click ctrl? shift? alt?))
|
||||||
|
|
||||||
(when shape
|
(when (and (not drawing-path?) shape)
|
||||||
(cond frame?
|
(cond frame?
|
||||||
(st/emit! (dw/select-shape id shift?))
|
(st/emit! (dw/select-shape id shift?))
|
||||||
|
|
||||||
|
@ -164,7 +164,8 @@
|
||||||
(st/emit! (dw/select-shape (:id selected))))
|
(st/emit! (dw/select-shape (:id selected))))
|
||||||
|
|
||||||
(or text? path?)
|
(or text? path?)
|
||||||
(st/emit! (dw/start-edition-mode id))
|
(st/emit! (dw/select-shape id)
|
||||||
|
(dw/start-editing-selected))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
;; Do nothing
|
;; Do nothing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue