mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 15:09:10 -05:00
Implement backspace / supr shortcut for delete selected shapes.
This commit is contained in:
parent
34abb7eb27
commit
6693c8bc9b
2 changed files with 27 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
(ns uxbox.data.workspace
|
(ns uxbox.data.workspace
|
||||||
(:require [bouncer.validators :as v]
|
(:require [bouncer.validators :as v]
|
||||||
|
[beicon.core :as rx]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.state :as st]
|
[uxbox.state :as st]
|
||||||
|
@ -140,6 +141,31 @@
|
||||||
(update-in $ [:pages-by-id pid :shapes] conj sid)
|
(update-in $ [:pages-by-id pid :shapes] conj sid)
|
||||||
(assoc-in $ [:shapes-by-id sid] shape))))))
|
(assoc-in $ [:shapes-by-id sid] shape))))))
|
||||||
|
|
||||||
|
(defn delete-shape
|
||||||
|
"Remove the shape using its id."
|
||||||
|
[sid]
|
||||||
|
(reify
|
||||||
|
rs/UpdateEvent
|
||||||
|
(-apply-update [_ state]
|
||||||
|
(let [pageid (get-in state [:shapes-by-id sid :page])
|
||||||
|
shapes (as-> state $
|
||||||
|
(get-in $ [:pages-by-id pageid :shapes])
|
||||||
|
(remove #(= % sid) $)
|
||||||
|
(into [] $))]
|
||||||
|
(as-> state $
|
||||||
|
(assoc-in $ [:pages-by-id pageid :shapes] shapes)
|
||||||
|
(update-in $ [:shapes-by-id] dissoc sid))))))
|
||||||
|
|
||||||
|
(defn remove-selected
|
||||||
|
"Deselect all and remove all selected shapes."
|
||||||
|
[]
|
||||||
|
(reify
|
||||||
|
rs/WatchEvent
|
||||||
|
(-apply-watch [_ state]
|
||||||
|
(let [selected (get-in state [:workspace :selected])]
|
||||||
|
(rx/from-coll
|
||||||
|
(into [(deselect-all)] (mapv #(delete-shape %) selected)))))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
"Initialize the workspace state."
|
"Initialize the workspace state."
|
||||||
[projectid pageid]
|
[projectid pageid]
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
:ctrl+shift+i #(rs/emit! (dw/toggle-toolbox :icons))
|
:ctrl+shift+i #(rs/emit! (dw/toggle-toolbox :icons))
|
||||||
:ctrl+shift+l #(rs/emit! (dw/toggle-toolbox :layers))
|
:ctrl+shift+l #(rs/emit! (dw/toggle-toolbox :layers))
|
||||||
:esc (constantly nil)
|
:esc (constantly nil)
|
||||||
:backspace (constantly nil)})
|
:backspace #(rs/emit! (dw/remove-selected))})
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Keyboard Shortcuts Watcher
|
;; Keyboard Shortcuts Watcher
|
||||||
|
|
Loading…
Add table
Reference in a new issue