mirror of
https://github.com/penpot/penpot.git
synced 2025-04-11 06:21:30 -05:00
✨ Do not allow the creation of groups, masks nor boolean in copies
This commit is contained in:
parent
b4d78d2fd7
commit
51fe27369b
7 changed files with 37 additions and 21 deletions
|
@ -109,7 +109,8 @@
|
|||
[:parent-id ::sm/uuid]
|
||||
[:shapes :any]
|
||||
[:index {:optional true} [:maybe :int]]
|
||||
[:after-shape {:optional true} :any]]]
|
||||
[:after-shape {:optional true} :any]
|
||||
[:component-swap {:optional true} :boolean]]]
|
||||
|
||||
[:reorder-children
|
||||
[:map {:title "ReorderChildrenChange"}
|
||||
|
|
|
@ -531,7 +531,7 @@
|
|||
(merge-path other-path item))))
|
||||
[other-path last-item false]))))
|
||||
|
||||
(defn prev-path
|
||||
(defn butlast-path
|
||||
"Remove the last item of the path."
|
||||
[path]
|
||||
(let [split (split-path path)]
|
||||
|
|
|
@ -2668,8 +2668,10 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
svg, img {
|
||||
svg,
|
||||
img {
|
||||
background-color: $color-canvas;
|
||||
border-radius: $br4;
|
||||
border: 2px solid transparent;
|
||||
|
@ -2697,6 +2699,7 @@
|
|||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
justify-content: space-between;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
height: 24px;
|
||||
svg {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.path.shapes-to-path :as stp]
|
||||
[app.common.types.container :as ctn]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.uuid :as uuid]
|
||||
|
@ -92,7 +93,8 @@
|
|||
ordered-indexes (cph/order-by-indexed-shapes objects ids)
|
||||
shapes (->> ordered-indexes
|
||||
(map (d/getf objects))
|
||||
(remove cph/frame-shape?))]
|
||||
(remove cph/frame-shape?)
|
||||
(remove #(ctn/has-any-copy-parent? objects %)))]
|
||||
|
||||
(when-not (empty? shapes)
|
||||
(let [[boolean-data index] (create-bool-data bool-type name (reverse shapes) objects)
|
||||
|
@ -114,7 +116,8 @@
|
|||
(let [objects (wsh/lookup-page-objects state)
|
||||
change-to-bool
|
||||
(fn [shape] (group->bool shape bool-type objects))]
|
||||
(rx/of (dch/update-shapes [shape-id] change-to-bool {:reg-objects? true}))))))
|
||||
(when-not (ctn/has-any-copy-parent? objects (get objects shape-id))
|
||||
(rx/of (dch/update-shapes [shape-id] change-to-bool {:reg-objects? true})))))))
|
||||
|
||||
(defn bool-to-group
|
||||
[shape-id]
|
||||
|
@ -124,14 +127,17 @@
|
|||
(let [objects (wsh/lookup-page-objects state)
|
||||
change-to-group
|
||||
(fn [shape] (bool->group shape objects))]
|
||||
(rx/of (dch/update-shapes [shape-id] change-to-group {:reg-objects? true}))))))
|
||||
(when-not (ctn/has-any-copy-parent? objects (get objects shape-id))
|
||||
(rx/of (dch/update-shapes [shape-id] change-to-group {:reg-objects? true})))))))
|
||||
|
||||
|
||||
(defn change-bool-type
|
||||
[shape-id bool-type]
|
||||
(ptk/reify ::change-bool-type
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(let [change-type
|
||||
(watch [_ state _]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
change-type
|
||||
(fn [shape] (assoc shape :bool-type bool-type))]
|
||||
(rx/of (dch/update-shapes [shape-id] change-type {:reg-objects? true}))))))
|
||||
(when-not (ctn/has-any-copy-parent? objects (get objects shape-id))
|
||||
(rx/of (dch/update-shapes [shape-id] change-type {:reg-objects? true})))))))
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.types.component :as ctk]
|
||||
[app.common.types.container :as ctn]
|
||||
[app.common.types.pages-list :as ctpl]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
|
@ -226,8 +227,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 (cph/clean-loops objects selected)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(cph/clean-loops objects)
|
||||
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
|
||||
shapes (shapes-for-grouping objects selected)
|
||||
parents (into #{} (map :parent-id) shapes)]
|
||||
(when-not (empty? shapes)
|
||||
|
@ -264,7 +266,8 @@
|
|||
(ctl/grid-layout? objects (:parent-id shape))
|
||||
(pcb/update-shapes [(:parent-id shape)] ctl/assign-cells))))
|
||||
|
||||
selected (wsh/lookup-selected state)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
|
||||
changes-list (sequence
|
||||
(keep prepare)
|
||||
selected)
|
||||
|
@ -284,11 +287,12 @@
|
|||
:origin it}
|
||||
undo-id (js/Symbol)]
|
||||
|
||||
(rx/of (dwu/start-undo-transaction undo-id)
|
||||
(when-not (empty? selected)
|
||||
(rx/of (dwu/start-undo-transaction undo-id)
|
||||
(dch/commit-changes changes)
|
||||
(ptk/data-event :layout/update parents)
|
||||
(dwu/commit-undo-transaction undo-id)
|
||||
(dws/select-shapes child-ids))))))
|
||||
(dws/select-shapes child-ids)))))))
|
||||
|
||||
(def mask-group
|
||||
(ptk/reify ::mask-group
|
||||
|
@ -296,8 +300,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 (cph/clean-loops objects selected)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(cph/clean-loops objects)
|
||||
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
|
||||
shapes (shapes-for-grouping objects selected)
|
||||
first-shape (first shapes)]
|
||||
(when-not (empty? shapes)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.path.shapes-to-path :as upsp]
|
||||
[app.common.types.container :as ctn]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[beicon.core :as rx]
|
||||
|
@ -20,7 +21,8 @@
|
|||
(watch [it state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state)
|
||||
selected (wsh/lookup-selected state)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(remove #(ctn/has-any-copy-parent? objects (get objects %))))
|
||||
|
||||
children-ids
|
||||
(into #{}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.data.workspace.specialized-panel :as dwsp]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.render :refer [component-svg]]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.context-menu :refer [context-menu]]
|
||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||
|
@ -162,7 +161,7 @@
|
|||
filters* (mf/use-state
|
||||
{:term ""
|
||||
:file-id (:component-file shape)
|
||||
:path (cph/prev-path (:name shape))})
|
||||
:path (cph/butlast-path (:name shape))})
|
||||
filters (deref filters*)
|
||||
|
||||
components (-> (get-in libraries [(:file-id filters) :data :components])
|
||||
|
@ -173,7 +172,7 @@
|
|||
(filter #(str/includes? (str/lower (:name %)) (str/lower (:term filters))) components))
|
||||
|
||||
groups (->> (map :path components)
|
||||
(filter #(= (cph/prev-path (:path %)) (:path filters)))
|
||||
(filter #(= (cph/butlast-path (:path %)) (:path filters)))
|
||||
(remove str/empty?)
|
||||
distinct
|
||||
(map #(hash-map :name %)))
|
||||
|
@ -222,7 +221,7 @@
|
|||
on-go-back
|
||||
(mf/use-fn
|
||||
(mf/deps (:path filters))
|
||||
#(swap! filters* assoc :path (cph/prev-path (:path filters))))
|
||||
#(swap! filters* assoc :path (cph/butlast-path (:path filters))))
|
||||
|
||||
on-enter-group
|
||||
(mf/use-fn #(swap! filters* assoc :path %))
|
||||
|
|
Loading…
Add table
Reference in a new issue