🎉 Add shortut Ctrl+Shift+K to detach instances

This commit is contained in:
Andrés Moya 2021-08-09 12:02:20 +02:00
parent 10db35eab4
commit 63259b3f92
4 changed files with 32 additions and 0 deletions

View file

@ -462,6 +462,31 @@
:undo-changes uchanges
:origin it}))))))
(def detach-selected-components
(ptk/reify ::detach-selected-components
ptk/WatchEvent
(watch [it state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
local-library (dwlh/get-local-file state)
container (cp/get-container page-id :page local-library)
selected (->> state
(wsh/lookup-selected)
(cp/clean-loops objects))
[rchanges uchanges]
(reduce (fn [changes id]
(dwlh/concat-changes
changes
(dwlh/generate-detach-instance id container)))
dwlh/empty-changes
selected)]
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges
:origin it}))))))
(defn nav-to-component-file
[file-id]
(us/assert ::us/uuid file-id)

View file

@ -93,6 +93,10 @@
:command (ds/c-mod "k")
:fn #(st/emit! dwl/add-component)}
:detach-component {:tooltip (ds/meta-shift "K")
:command (ds/c-mod "shift+k")
:fn #(st/emit! dwl/detach-selected-components)}
:flip-vertical {:tooltip (ds/shift "V")
:command "shift+v"
:fn #(st/emit! (dw/flip-vertical-selected))}

View file

@ -195,6 +195,7 @@
[:*
[:& menu-separator]
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instance")
:shortcut (sc/get-tooltip :detach-component)
:on-click do-detach-component}]
[:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides")
:on-click do-reset-component}]
@ -205,6 +206,7 @@
[:*
[:& menu-separator]
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instance")
:shortcut (sc/get-tooltip :detach-component)
:on-click do-detach-component}]
[:& menu-entry {:title (tr "workspace.shape.menu.reset-overrides")
:on-click do-reset-component}]