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