mirror of
https://github.com/penpot/penpot.git
synced 2025-06-05 14:21:40 +02:00
♻️ Components refactor: remove it usage on libraries_helpers
This commit is contained in:
parent
05f4459fb7
commit
37e68249aa
7 changed files with 45 additions and 39 deletions
|
@ -68,7 +68,7 @@
|
|||
result)))))))
|
||||
|
||||
(defn prepare-create-group
|
||||
[it objects page-id shapes base-name keep-name?]
|
||||
[changes objects page-id shapes base-name keep-name?]
|
||||
(let [frame-id (:frame-id (first shapes))
|
||||
parent-id (:parent-id (first shapes))
|
||||
gname (if (and keep-name?
|
||||
|
@ -114,7 +114,8 @@
|
|||
(filter (partial ctl/grid-layout? objects)))
|
||||
shapes)
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
changes (-> changes
|
||||
(pcb/with-page-id page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/add-object group {:index group-idx})
|
||||
(pcb/update-shapes (map :id shapes) ctl/remove-layout-item-data)
|
||||
|
@ -191,7 +192,7 @@
|
|||
parents (into #{} (map :parent-id) shapes)]
|
||||
(when-not (empty? shapes)
|
||||
(let [[group changes]
|
||||
(prepare-create-group it objects page-id shapes "Group" false)]
|
||||
(prepare-create-group (pcb/empty-changes it) objects page-id shapes "Group" false)]
|
||||
(rx/of (dch/commit-changes changes)
|
||||
(dws/select-shapes (d/ordered-set (:id group)))
|
||||
(ptk/data-event :layout/update {:ids parents}))))))))
|
||||
|
@ -267,7 +268,7 @@
|
|||
(= (:type (first shapes)) :group))
|
||||
[first-shape (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects))]
|
||||
(prepare-create-group it objects page-id shapes "Mask" true))
|
||||
(prepare-create-group (pcb/empty-changes it) objects page-id shapes "Mask" true))
|
||||
|
||||
changes (-> changes
|
||||
(pcb/update-shapes (:shapes group)
|
||||
|
|
|
@ -351,7 +351,7 @@
|
|||
parents (into #{} (map :parent-id) shapes)]
|
||||
(when-not (empty? shapes)
|
||||
(let [[root _ changes]
|
||||
(cflh/generate-add-component it shapes objects page-id file-id components-v2
|
||||
(cflh/generate-add-component (pcb/empty-changes it) shapes objects page-id file-id components-v2
|
||||
dwg/prepare-create-group
|
||||
cfsh/prepare-create-artboard-from-selection)]
|
||||
(when-not (empty? (:redo-changes changes))
|
||||
|
@ -1024,22 +1024,22 @@
|
|||
(-> (pcb/empty-changes it)
|
||||
(pcb/set-undo-group undo-group))
|
||||
[(when sync-components?
|
||||
(cflh/generate-sync-library it file-id :components asset-id library-id libraries current-file-id))
|
||||
(cflh/generate-sync-library (pcb/empty-changes it) file-id :components asset-id library-id libraries current-file-id))
|
||||
(when sync-colors?
|
||||
(cflh/generate-sync-library it file-id :colors asset-id library-id libraries current-file-id))
|
||||
(cflh/generate-sync-library (pcb/empty-changes it) file-id :colors asset-id library-id libraries current-file-id))
|
||||
(when sync-typographies?
|
||||
(cflh/generate-sync-library it file-id :typographies asset-id library-id libraries current-file-id))])
|
||||
(cflh/generate-sync-library (pcb/empty-changes it) file-id :typographies asset-id library-id libraries current-file-id))])
|
||||
|
||||
file-changes (reduce
|
||||
pcb/concat-changes
|
||||
(-> (pcb/empty-changes it)
|
||||
(pcb/set-undo-group undo-group))
|
||||
[(when sync-components?
|
||||
(cflh/generate-sync-file it file-id :components asset-id library-id libraries current-file-id))
|
||||
(cflh/generate-sync-file (pcb/empty-changes it) file-id :components asset-id library-id libraries current-file-id))
|
||||
(when sync-colors?
|
||||
(cflh/generate-sync-file it file-id :colors asset-id library-id libraries current-file-id))
|
||||
(cflh/generate-sync-file (pcb/empty-changes it) file-id :colors asset-id library-id libraries current-file-id))
|
||||
(when sync-typographies?
|
||||
(cflh/generate-sync-file it file-id :typographies asset-id library-id libraries current-file-id))])
|
||||
(cflh/generate-sync-file (pcb/empty-changes it) file-id :typographies asset-id library-id libraries current-file-id))])
|
||||
|
||||
changes (pcb/concat-changes library-changes file-changes)
|
||||
|
||||
|
|
|
@ -422,7 +422,7 @@
|
|||
(prepare-duplicate-guides shapes page ids-map delta)))))
|
||||
|
||||
(defn- prepare-duplicate-component-change
|
||||
[changes objects page component-root parent-id frame-id delta libraries library-data it]
|
||||
[changes objects page component-root parent-id frame-id delta libraries library-data]
|
||||
(let [component-id (:component-id component-root)
|
||||
file-id (:component-file component-root)
|
||||
main-component (ctf/get-component libraries file-id component-id)
|
||||
|
@ -467,7 +467,7 @@
|
|||
changes
|
||||
|
||||
(ctf/is-main-of-known-component? obj libraries)
|
||||
(prepare-duplicate-component-change changes objects page obj parent-id frame-id delta libraries library-data it)
|
||||
(prepare-duplicate-component-change changes objects page obj parent-id frame-id delta libraries library-data)
|
||||
|
||||
:else
|
||||
(let [frame? (cfh/frame-shape? obj)
|
||||
|
|
|
@ -132,7 +132,7 @@
|
|||
shapes (dwg/shapes-for-grouping objects shape-ids)
|
||||
|
||||
[group component-id changes]
|
||||
(cflh/generate-add-component nil
|
||||
(cflh/generate-add-component (pcb/empty-changes nil)
|
||||
shapes
|
||||
(:objects page)
|
||||
(:id page)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue