mirror of
https://github.com/penpot/penpot.git
synced 2025-07-26 03:57:24 +02:00
🐛 Fix allow modify component copy structure under some circumstances
This commit is contained in:
parent
8363b86cfa
commit
38b72abf32
2 changed files with 66 additions and 56 deletions
|
@ -355,8 +355,9 @@
|
|||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected (wsh/lookup-selected state)
|
||||
selected (cfh/clean-loops objects selected)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(cfh/clean-loops objects)
|
||||
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects))
|
||||
|
|
|
@ -230,7 +230,9 @@
|
|||
|
||||
(let [multiple? (> (count shapes) 1)
|
||||
single? (= (count shapes) 1)
|
||||
do-create-artboard-from-selection #(st/emit! (dwsh/create-artboard-from-selection))
|
||||
|
||||
objects (deref refs/workspace-page-objects)
|
||||
any-in-copy? (some true? (map #(ctn/has-any-copy-parent? objects %) shapes))
|
||||
|
||||
;; components can't be ungrouped
|
||||
has-frame? (->> shapes (d/seek #(and (cfh/frame-shape? %) (not (ctk/instance-head? %)))))
|
||||
|
@ -244,8 +246,12 @@
|
|||
do-create-group #(st/emit! dw/group-selected)
|
||||
do-mask-group #(st/emit! dw/mask-group)
|
||||
do-remove-group #(st/emit! dw/ungroup-selected)
|
||||
do-unmask-group #(st/emit! dw/unmask-group)]
|
||||
do-unmask-group #(st/emit! dw/unmask-group)
|
||||
do-create-artboard-from-selection
|
||||
#(st/emit! (dwsh/create-artboard-from-selection))]
|
||||
|
||||
[:*
|
||||
(when (not any-in-copy?)
|
||||
[:*
|
||||
(when (or has-bool? has-group? has-mask? has-frame?)
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.ungroup")
|
||||
|
@ -269,7 +275,7 @@
|
|||
[:& menu-entry {:title (tr "workspace.shape.menu.create-artboard-from-selection")
|
||||
:shortcut (sc/get-tooltip :artboard-selection)
|
||||
:on-click do-create-artboard-from-selection}]
|
||||
[:& menu-separator]]))
|
||||
[:& menu-separator]])]))
|
||||
|
||||
(mf/defc context-focus-mode-menu
|
||||
[{:keys []}]
|
||||
|
@ -392,6 +398,8 @@
|
|||
{::mf/props :obj}
|
||||
[{:keys [shapes]}]
|
||||
(let [single? (= (count shapes) 1)
|
||||
objects (deref refs/workspace-page-objects)
|
||||
any-in-copy? (some true? (map #(ctn/has-any-copy-parent? objects %) shapes))
|
||||
|
||||
has-flex?
|
||||
(and single? (every? ctl/flex-layout? shapes))
|
||||
|
@ -414,7 +422,8 @@
|
|||
(fn [_event]
|
||||
(let [ids (map :id shapes)]
|
||||
(st/emit! (dwsl/remove-layout ids)))))]
|
||||
|
||||
[:*
|
||||
(when (not any-in-copy?)
|
||||
(if (or ^boolean has-flex?
|
||||
^boolean has-grid?)
|
||||
[:div
|
||||
|
@ -436,7 +445,7 @@
|
|||
[:& menu-entry {:title (tr "workspace.shape.menu.add-grid")
|
||||
:shortcut (sc/get-tooltip :toggle-layout-grid)
|
||||
:value "grid"
|
||||
:on-click on-add-layout}]])))
|
||||
:on-click on-add-layout}]]))]))
|
||||
|
||||
(mf/defc context-menu-component
|
||||
[{:keys [shapes]}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue