mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 16:21:57 -05:00
🐛 Remove duplicate component context menu item
This commit is contained in:
parent
610e34e05b
commit
2c007e7303
3 changed files with 10 additions and 19 deletions
|
@ -134,8 +134,7 @@
|
|||
(let [main-instance-page (ctf/get-component-page library-data component)
|
||||
main-instance-shape (ctf/get-component-root library-data component)
|
||||
|
||||
position (gpt/add (gpt/point (:x main-instance-shape) (:y main-instance-shape))
|
||||
(gpt/point (+ (:width main-instance-shape) 50) 0))
|
||||
position (gpt/point (:x main-instance-shape) (:y main-instance-shape))
|
||||
|
||||
component-instance-extra-data (if components-v2 {:main-instance? true} {})
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.common.types.page :as ctp]
|
||||
[app.common.types.shape.interactions :as ctsi]
|
||||
|
@ -565,7 +566,9 @@
|
|||
(defn calc-duplicate-delta
|
||||
[obj state objects]
|
||||
(let [{:keys [id-original id-duplicated]}
|
||||
(get-in state [:workspace-local :duplicated])]
|
||||
(get-in state [:workspace-local :duplicated])
|
||||
move? (and (cph/frame-shape? obj)
|
||||
(not (ctk/instance-head? obj)))]
|
||||
(if (or (and (not= id-original (:id obj))
|
||||
(not= id-duplicated (:id obj)))
|
||||
;; As we can remove duplicated elements may be we can still caching a deleted id
|
||||
|
@ -574,7 +577,7 @@
|
|||
|
||||
;; The default is leave normal shapes in place, but put
|
||||
;; new frames to the right of the original.
|
||||
(if (cph/frame-shape? obj)
|
||||
(if move?
|
||||
(gpt/point (+ (:width obj) 50) 0)
|
||||
(gpt/point 0 0))
|
||||
|
||||
|
|
|
@ -149,23 +149,12 @@
|
|||
(dom/classnames :separator true))}]))
|
||||
|
||||
(mf/defc context-menu-edit
|
||||
[props]
|
||||
(let [shapes (:shapes props)
|
||||
main-component-id (when (and (= 1 (count shapes))
|
||||
(:main-instance? (first shapes)))
|
||||
(:component-id (first shapes)))
|
||||
do-copy #(st/emit! (dw/copy-selected))
|
||||
[_]
|
||||
(let [do-copy #(st/emit! (dw/copy-selected))
|
||||
do-cut #(st/emit! (dw/copy-selected)
|
||||
(dw/delete-selected))
|
||||
do-paste #(st/emit! dw/paste)
|
||||
do-duplicate #(if main-component-id
|
||||
(st/emit! (dwl/duplicate-component (:component-file (first shapes)) main-component-id))
|
||||
(st/emit! (dw/duplicate-selected false)))
|
||||
|
||||
|
||||
duplicate-title (if main-component-id
|
||||
(tr "workspace.assets.duplicate-main")
|
||||
(tr "workspace.shape.menu.duplicate"))]
|
||||
do-duplicate #(st/emit! (dw/duplicate-selected true))]
|
||||
[:*
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.copy")
|
||||
:shortcut (sc/get-tooltip :copy)
|
||||
|
@ -176,7 +165,7 @@
|
|||
[:& menu-entry {:title (tr "workspace.shape.menu.paste")
|
||||
:shortcut (sc/get-tooltip :paste)
|
||||
:on-click do-paste}]
|
||||
[:& menu-entry {:title duplicate-title
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.duplicate")
|
||||
:shortcut (sc/get-tooltip :duplicate)
|
||||
:on-click do-duplicate}]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue