mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 16:21:57 -05:00
Merge remote-tracking branch 'origin/main' into develop
This commit is contained in:
commit
6489ad4114
10 changed files with 123 additions and 104 deletions
|
@ -36,6 +36,7 @@
|
|||
- Fix issue when group creation leaves an empty group [#1724](https://tree.taiga.io/project/penpot/issue/1724)
|
||||
- Fix problem with :multiple for colors and typographies [#1668](https://tree.taiga.io/project/penpot/issue/1668)
|
||||
- Fix problem with locked shapes when change parents [#974](https://github.com/penpot/penpot/issues/974)
|
||||
- Fix problem with new nodes in paths [#978](https://github.com/penpot/penpot/issues/978)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
the nearest integer."
|
||||
[v]
|
||||
#?(:cljs (js/Math.round v)
|
||||
:clj (Math/round v)))
|
||||
:clj (Math/round (float v))))
|
||||
|
||||
(defn ceil
|
||||
"Returns the smallest integer greater than
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
(defmethod process-change :reg-objects
|
||||
[data {:keys [page-id component-id shapes]}]
|
||||
(letfn [(reg-objects [objects]
|
||||
(reduce #(update %1 %2 update-group %1) objects
|
||||
(reduce #(d/update-when %1 %2 update-group %1) objects
|
||||
(sequence (comp
|
||||
(mapcat #(cons % (cph/get-parents % objects)))
|
||||
(map #(get objects %))
|
||||
|
@ -221,28 +221,31 @@
|
|||
;; the new destination target parent id.
|
||||
(if (= prev-parent-id parent-id)
|
||||
objects
|
||||
(loop [sid shape-id
|
||||
pid prev-parent-id
|
||||
objects objects]
|
||||
(let [obj (get objects pid)]
|
||||
(cond-> objects
|
||||
true
|
||||
(update-in [pid :shapes] strip-id sid)
|
||||
(let [sid shape-id
|
||||
pid prev-parent-id
|
||||
obj (get objects pid)
|
||||
component? (and (:shape-ref obj)
|
||||
(= (:type obj) :group)
|
||||
(not ignore-touched))]
|
||||
|
||||
(and (:shape-ref obj)
|
||||
(= (:type obj) :group)
|
||||
(not ignore-touched))
|
||||
(->
|
||||
(update-in [pid :touched]
|
||||
cph/set-touched-group :shapes-group)
|
||||
(d/dissoc-in [pid :remote-synced?]))))))))
|
||||
(-> objects
|
||||
(d/update-in-when [pid :shapes] strip-id sid)
|
||||
|
||||
(cond-> component?
|
||||
(d/update-when
|
||||
pid
|
||||
#(-> %
|
||||
(update :touched cph/set-touched-group :shapes-group)
|
||||
(dissoc :remote-synced?)))))))))
|
||||
|
||||
(update-parent-id [objects id]
|
||||
(assoc-in objects [id :parent-id] parent-id))
|
||||
(-> objects
|
||||
(d/update-when id assoc :parent-id parent-id)))
|
||||
|
||||
;; Updates the frame-id references that might be outdated
|
||||
(assign-frame-id [frame-id objects id]
|
||||
(let [objects (update objects id assoc :frame-id frame-id)
|
||||
(let [objects (-> objects
|
||||
(d/update-when id assoc :frame-id frame-id))
|
||||
obj (get objects id)]
|
||||
(cond-> objects
|
||||
;; If we moving frame, the parent frame is the root
|
||||
|
|
|
@ -181,7 +181,7 @@
|
|||
(defn calculate-invalid-targets
|
||||
[shape-id objects]
|
||||
(let [result #{shape-id}
|
||||
children (get-in objects [shape-id :shape])
|
||||
children (get-in objects [shape-id :shapes])
|
||||
reduce-fn (fn [result child-id]
|
||||
(into result (calculate-invalid-targets child-id objects)))]
|
||||
(reduce reduce-fn result children)))
|
||||
|
|
|
@ -115,7 +115,6 @@
|
|||
[{:keys [redo-changes undo-changes origin save-undo? file-id]
|
||||
:or {save-undo? true}}]
|
||||
|
||||
|
||||
(log/debug :msg "commit-changes"
|
||||
:js/redo-changes redo-changes
|
||||
:js/undo-changes undo-changes)
|
||||
|
|
|
@ -264,13 +264,14 @@
|
|||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected (wsh/lookup-selected state)
|
||||
selected (cp/clean-loops objects selected)]
|
||||
(let [[group rchanges uchanges]
|
||||
(dwlh/generate-add-component selected objects page-id file-id)]
|
||||
(when-not (empty? rchanges)
|
||||
(rx/of (dch/commit-changes {:redo-changes rchanges
|
||||
:undo-changes uchanges
|
||||
:origin it})
|
||||
(dwc/select-shapes (d/ordered-set (:id group))))))))))
|
||||
(when-not (empty? selected)
|
||||
(let [[group rchanges uchanges]
|
||||
(dwlh/generate-add-component selected objects page-id file-id)]
|
||||
(when-not (empty? rchanges)
|
||||
(rx/of (dch/commit-changes {:redo-changes rchanges
|
||||
:undo-changes uchanges
|
||||
:origin it})
|
||||
(dwc/select-shapes (d/ordered-set (:id group)))))))))))
|
||||
|
||||
(defn rename-component
|
||||
"Rename the component with the given id, in the current file library."
|
||||
|
@ -414,22 +415,22 @@
|
|||
(get component :objects)
|
||||
update-new-shape)
|
||||
|
||||
rchanges (map (fn [obj]
|
||||
{:type :add-obj
|
||||
:id (:id obj)
|
||||
:page-id page-id
|
||||
:frame-id (:frame-id obj)
|
||||
:parent-id (:parent-id obj)
|
||||
:ignore-touched true
|
||||
:obj obj})
|
||||
new-shapes)
|
||||
rchanges (mapv (fn [obj]
|
||||
{:type :add-obj
|
||||
:id (:id obj)
|
||||
:page-id page-id
|
||||
:frame-id (:frame-id obj)
|
||||
:parent-id (:parent-id obj)
|
||||
:ignore-touched true
|
||||
:obj obj})
|
||||
new-shapes)
|
||||
|
||||
uchanges (map (fn [obj]
|
||||
{:type :del-obj
|
||||
:id (:id obj)
|
||||
:page-id page-id
|
||||
:ignore-touched true})
|
||||
new-shapes)]
|
||||
uchanges (mapv (fn [obj]
|
||||
{:type :del-obj
|
||||
:id (:id obj)
|
||||
:page-id page-id
|
||||
:ignore-touched true})
|
||||
new-shapes)]
|
||||
|
||||
(rx/of (dch/commit-changes {:redo-changes rchanges
|
||||
:undo-changes uchanges
|
||||
|
@ -448,53 +449,53 @@
|
|||
objects (wsh/lookup-page-objects state page-id)
|
||||
shapes (cp/get-object-with-children id objects)
|
||||
|
||||
rchanges (map (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :component-id
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :component-file
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :component-root?
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :remote-synced?
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :shape-ref
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :touched
|
||||
:val nil}]})
|
||||
shapes)
|
||||
rchanges (mapv (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :component-id
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :component-file
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :component-root?
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :remote-synced?
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :shape-ref
|
||||
:val nil}
|
||||
{:type :set
|
||||
:attr :touched
|
||||
:val nil}]})
|
||||
shapes)
|
||||
|
||||
uchanges (map (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :component-id
|
||||
:val (:component-id obj)}
|
||||
{:type :set
|
||||
:attr :component-file
|
||||
:val (:component-file obj)}
|
||||
{:type :set
|
||||
:attr :component-root?
|
||||
:val (:component-root? obj)}
|
||||
{:type :set
|
||||
:attr :remote-synced?
|
||||
:val (:remote-synced? obj)}
|
||||
{:type :set
|
||||
:attr :shape-ref
|
||||
:val (:shape-ref obj)}
|
||||
{:type :set
|
||||
:attr :touched
|
||||
:val (:touched obj)}]})
|
||||
shapes)]
|
||||
uchanges (mapv (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :component-id
|
||||
:val (:component-id obj)}
|
||||
{:type :set
|
||||
:attr :component-file
|
||||
:val (:component-file obj)}
|
||||
{:type :set
|
||||
:attr :component-root?
|
||||
:val (:component-root? obj)}
|
||||
{:type :set
|
||||
:attr :remote-synced?
|
||||
:val (:remote-synced? obj)}
|
||||
{:type :set
|
||||
:attr :shape-ref
|
||||
:val (:shape-ref obj)}
|
||||
{:type :set
|
||||
:attr :touched
|
||||
:val (:touched obj)}]})
|
||||
shapes)]
|
||||
|
||||
(rx/of (dch/commit-changes {:redo-changes rchanges
|
||||
:undo-changes uchanges
|
||||
|
|
|
@ -282,7 +282,8 @@
|
|||
moving-shapes (->> ids
|
||||
(cp/clean-loops objects)
|
||||
(map #(get objects %))
|
||||
(remove #(= (:frame-id %) frame-id)))
|
||||
(remove #(or (nil? %)
|
||||
(= (:frame-id %) frame-id))))
|
||||
|
||||
rch [{:type :mov-objects
|
||||
:page-id page-id
|
||||
|
|
|
@ -246,12 +246,19 @@
|
|||
:or {font-variant-id "regular"}}]
|
||||
|
||||
(let [{:keys [backend family variants]} (get @fontsdb font-id)]
|
||||
(if (= :google backend)
|
||||
(cond
|
||||
(= :google backend)
|
||||
(-> (generate-gfonts-url
|
||||
{:family family
|
||||
:variants [{:id font-variant-id}]})
|
||||
(http/fetch-text))
|
||||
|
||||
(= :custom backend)
|
||||
(let [variant (d/seek #(= (:id %) font-variant-id) variants)
|
||||
result (generate-custom-font-variant-css family variant)]
|
||||
(p/resolved result))
|
||||
|
||||
:else
|
||||
(let [{:keys [weight style suffix] :as variant}
|
||||
(d/seek #(= (:id %) font-variant-id) variants)
|
||||
font-data {:family family
|
||||
|
|
|
@ -171,7 +171,8 @@
|
|||
(for [{:keys [id] :as project} projects]
|
||||
(let [files (when recent-map
|
||||
(->> (vals recent-map)
|
||||
(filterv #(= id (:project-id %)))))]
|
||||
(filterv #(= id (:project-id %)))
|
||||
(sort-by :modified-at #(compare %2 %1))))]
|
||||
[:& project-item {:project project
|
||||
:files files
|
||||
:first? (= project (first projects))
|
||||
|
|
|
@ -164,11 +164,12 @@
|
|||
[content points]
|
||||
(let [point-set (set points)]
|
||||
|
||||
(loop [segments []
|
||||
prev-point nil
|
||||
(loop [segments []
|
||||
prev-point nil
|
||||
start-point nil
|
||||
cur-cmd (first content)
|
||||
content (rest content)]
|
||||
index 0
|
||||
cur-cmd (first content)
|
||||
content (rest content)]
|
||||
|
||||
(let [;; Close-path makes a segment from the last point to the initial path point
|
||||
cur-point (if (= :close-path (:command cur-cmd))
|
||||
|
@ -191,12 +192,16 @@
|
|||
|
||||
segments (cond-> segments
|
||||
is-segment?
|
||||
(conj [prev-point cur-point cur-cmd]))]
|
||||
(conj {:start prev-point
|
||||
:end cur-point
|
||||
:cmd cur-cmd
|
||||
:index index}))]
|
||||
|
||||
(if (some? cur-cmd)
|
||||
(recur segments
|
||||
cur-point
|
||||
start-point
|
||||
(inc index)
|
||||
(first content)
|
||||
(rest content))
|
||||
|
||||
|
@ -205,12 +210,13 @@
|
|||
(defn split-segments
|
||||
"Given a content creates splits commands between points with new segments"
|
||||
[content points value]
|
||||
|
||||
(let [split-command
|
||||
(fn [[start end cmd]]
|
||||
(fn [{:keys [start end cmd index]}]
|
||||
(case (:command cmd)
|
||||
:line-to [cmd (upg/split-line-to start cmd value)]
|
||||
:curve-to [cmd (upg/split-curve-to start cmd value)]
|
||||
:close-path [cmd [(upc/make-line-to (gpt/line-val start end value)) cmd]]
|
||||
:line-to [index (upg/split-line-to start cmd value)]
|
||||
:curve-to [index (upg/split-curve-to start cmd value)]
|
||||
:close-path [index [(upc/make-line-to (gpt/line-val start end value)) cmd]]
|
||||
nil))
|
||||
|
||||
cmd-changes
|
||||
|
@ -219,12 +225,12 @@
|
|||
(filter (comp not nil?)))))
|
||||
|
||||
process-segments
|
||||
(fn [command]
|
||||
(if (contains? cmd-changes command)
|
||||
(get cmd-changes command)
|
||||
(fn [[index command]]
|
||||
(if (contains? cmd-changes index)
|
||||
(get cmd-changes index)
|
||||
[command]))]
|
||||
|
||||
(into [] (mapcat process-segments) content)))
|
||||
(into [] (mapcat process-segments) (d/enumerate content))))
|
||||
|
||||
(defn remove-nodes
|
||||
"Removes from content the points given. Will try to reconstruct the paths
|
||||
|
|
Loading…
Add table
Reference in a new issue