diff --git a/CHANGES.md b/CHANGES.md index 62020d9d8b..60e02f8a95 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,11 +11,12 @@ ### :bug: Bugs fixed -- Fix problem with exporting before the document is saved [Taiga #2189](https://tree.taiga.io/project/penpot/issue/2189) -- Fix undo stacking when changing color from color-picker [Taiga #2191](https://tree.taiga.io/project/penpot/issue/2191) -- Fix pages dropdown in viewer [Taiga #2087](https://tree.taiga.io/project/penpot/issue/2087) -- Fix problem when exporting texts with gradients or opacity [Taiga #2200](https://tree.taiga.io/project/penpot/issue/2200) -- Fix problem with view mode comments [Taiga #](https://tree.taiga.io/project/penpot/issue/2226) +- Fix problem with exporting before the document is saved [Taiga #2189](https://tree.taiga.io/project/penpot/issue/2189). +- Fix undo stacking when changing color from color-picker [Taiga #2191](https://tree.taiga.io/project/penpot/issue/2191). +- Fix pages dropdown in viewer [Taiga #2087](https://tree.taiga.io/project/penpot/issue/2087). +- Fix problem when exporting texts with gradients or opacity [Taiga #2200](https://tree.taiga.io/project/penpot/issue/2200). +- Fix problem with view mode comments [Taiga #226](https://tree.taiga.io/project/penpot/issue/2226). +- Disallow to create a component when already has one [Taiga #2237](https://tree.taiga.io/project/penpot/issue/2237). ### :arrow_up: Deps updates ### :heart: Community contributions by (Thank you!) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 0f6a4a2e83..53d8cf9a26 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -125,70 +125,73 @@ create a group that contains all ids. Then, make a component with it, and link all shapes to their corresponding one in the component." [shapes objects page-id file-id] - (let [[group rchanges uchanges] - (if (and (= (count shapes) 1) - (= (:type (first shapes)) :group)) - [(first shapes) [] []] - (dwg/prepare-create-group objects page-id shapes "Component-1" true)) + (if (and (= (count shapes) 1) + (:component-id (first shapes))) + empty-changes + (let [[group rchanges uchanges] + (if (and (= (count shapes) 1) + (= (:type (first shapes)) :group)) + [(first shapes) [] []] + (dwg/prepare-create-group objects page-id shapes "Component-1" true)) - [new-shape new-shapes updated-shapes] - (make-component-shape group objects file-id) + [new-shape new-shapes updated-shapes] + (make-component-shape group objects file-id) - rchanges (conj rchanges - {:type :add-component - :id (:id new-shape) - :name (:name new-shape) - :shapes new-shapes}) + rchanges (conj rchanges + {:type :add-component + :id (:id new-shape) + :name (:name new-shape) + :shapes new-shapes}) - rchanges (into rchanges - (map (fn [updated-shape] - {:type :mod-obj - :page-id page-id - :id (:id updated-shape) - :operations [{:type :set - :attr :component-id - :val (:component-id updated-shape)} - {:type :set - :attr :component-file - :val (:component-file updated-shape)} - {:type :set - :attr :component-root? - :val (:component-root? updated-shape)} - {:type :set - :attr :shape-ref - :val (:shape-ref updated-shape)} - {:type :set - :attr :touched - :val (:touched updated-shape)}]}) - updated-shapes)) - - uchanges (conj uchanges - {:type :del-component - :id (:id new-shape)}) - - uchanges (into uchanges - (map (fn [updated-shape] - (let [original-shape (get objects (:id updated-shape))] + rchanges (into rchanges + (map (fn [updated-shape] {:type :mod-obj :page-id page-id :id (:id updated-shape) :operations [{:type :set :attr :component-id - :val (:component-id original-shape)} + :val (:component-id updated-shape)} {:type :set :attr :component-file - :val (:component-file original-shape)} + :val (:component-file updated-shape)} {:type :set :attr :component-root? - :val (:component-root? original-shape)} + :val (:component-root? updated-shape)} {:type :set :attr :shape-ref - :val (:shape-ref original-shape)} + :val (:shape-ref updated-shape)} {:type :set :attr :touched - :val (:touched original-shape)}]})) - updated-shapes))] - [group rchanges uchanges])) + :val (:touched updated-shape)}]}) + updated-shapes)) + + uchanges (conj uchanges + {:type :del-component + :id (:id new-shape)}) + + uchanges (into uchanges + (map (fn [updated-shape] + (let [original-shape (get objects (:id updated-shape))] + {:type :mod-obj + :page-id page-id + :id (:id updated-shape) + :operations [{:type :set + :attr :component-id + :val (:component-id original-shape)} + {:type :set + :attr :component-file + :val (:component-file original-shape)} + {:type :set + :attr :component-root? + :val (:component-root? original-shape)} + {:type :set + :attr :shape-ref + :val (:shape-ref original-shape)} + {:type :set + :attr :touched + :val (:touched original-shape)}]})) + updated-shapes))] + [group rchanges uchanges]))) (defn duplicate-component "Clone the root shape of the component and all children. Generate new diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index 9cdae04669..abe4ed6062 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -281,7 +281,8 @@ [:& menu-entry {:title (tr "workspace.shape.menu.delete-flow-start") :on-click (do-remove-flow flow)}]))) - (when (not= (:type shape) :frame) + (when (and (not= (:type shape) :frame) + (or multiple? (nil? (:component-id shape)))) [:* [:& menu-separator] [:& menu-entry {:title (tr "workspace.shape.menu.create-component")