mirror of
https://github.com/penpot/penpot.git
synced 2025-06-08 23:41:38 +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 _]
|
(watch [it state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
selected (wsh/lookup-selected state)
|
selected (->> (wsh/lookup-selected state)
|
||||||
selected (cfh/clean-loops objects selected)
|
(cfh/clean-loops objects)
|
||||||
|
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
|
||||||
|
|
||||||
changes (-> (pcb/empty-changes it page-id)
|
changes (-> (pcb/empty-changes it page-id)
|
||||||
(pcb/with-objects objects))
|
(pcb/with-objects objects))
|
||||||
|
|
|
@ -230,7 +230,9 @@
|
||||||
|
|
||||||
(let [multiple? (> (count shapes) 1)
|
(let [multiple? (> (count shapes) 1)
|
||||||
single? (= (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
|
;; components can't be ungrouped
|
||||||
has-frame? (->> shapes (d/seek #(and (cfh/frame-shape? %) (not (ctk/instance-head? %)))))
|
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-create-group #(st/emit! dw/group-selected)
|
||||||
do-mask-group #(st/emit! dw/mask-group)
|
do-mask-group #(st/emit! dw/mask-group)
|
||||||
do-remove-group #(st/emit! dw/ungroup-selected)
|
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?)
|
(when (or has-bool? has-group? has-mask? has-frame?)
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.ungroup")
|
[:& menu-entry {:title (tr "workspace.shape.menu.ungroup")
|
||||||
|
@ -269,7 +275,7 @@
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.create-artboard-from-selection")
|
[:& menu-entry {:title (tr "workspace.shape.menu.create-artboard-from-selection")
|
||||||
:shortcut (sc/get-tooltip :artboard-selection)
|
:shortcut (sc/get-tooltip :artboard-selection)
|
||||||
:on-click do-create-artboard-from-selection}]
|
:on-click do-create-artboard-from-selection}]
|
||||||
[:& menu-separator]]))
|
[:& menu-separator]])]))
|
||||||
|
|
||||||
(mf/defc context-focus-mode-menu
|
(mf/defc context-focus-mode-menu
|
||||||
[{:keys []}]
|
[{:keys []}]
|
||||||
|
@ -392,6 +398,8 @@
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
[{:keys [shapes]}]
|
[{:keys [shapes]}]
|
||||||
(let [single? (= (count shapes) 1)
|
(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?
|
has-flex?
|
||||||
(and single? (every? ctl/flex-layout? shapes))
|
(and single? (every? ctl/flex-layout? shapes))
|
||||||
|
@ -414,7 +422,8 @@
|
||||||
(fn [_event]
|
(fn [_event]
|
||||||
(let [ids (map :id shapes)]
|
(let [ids (map :id shapes)]
|
||||||
(st/emit! (dwsl/remove-layout ids)))))]
|
(st/emit! (dwsl/remove-layout ids)))))]
|
||||||
|
[:*
|
||||||
|
(when (not any-in-copy?)
|
||||||
(if (or ^boolean has-flex?
|
(if (or ^boolean has-flex?
|
||||||
^boolean has-grid?)
|
^boolean has-grid?)
|
||||||
[:div
|
[:div
|
||||||
|
@ -436,7 +445,7 @@
|
||||||
[:& menu-entry {:title (tr "workspace.shape.menu.add-grid")
|
[:& menu-entry {:title (tr "workspace.shape.menu.add-grid")
|
||||||
:shortcut (sc/get-tooltip :toggle-layout-grid)
|
:shortcut (sc/get-tooltip :toggle-layout-grid)
|
||||||
:value "grid"
|
:value "grid"
|
||||||
:on-click on-add-layout}]])))
|
:on-click on-add-layout}]]))]))
|
||||||
|
|
||||||
(mf/defc context-menu-component
|
(mf/defc context-menu-component
|
||||||
[{:keys [shapes]}]
|
[{:keys [shapes]}]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue