0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-13 07:21:40 -05:00

Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Alejandro Alonso 2023-07-14 15:27:38 +02:00
commit e9914d5265
14 changed files with 79 additions and 33 deletions

View file

@ -94,6 +94,10 @@
- Fix exports menu on viewer mode [Taiga #5568](https://tree.taiga.io/project/penpot/issue/5568)
- Fix create empty comments [Taiga #5536](https://tree.taiga.io/project/penpot/issue/5536)
- Fix text changes not propagated to copy [Taiga #5364](https://tree.taiga.io/project/penpot/issue/5364)
- Fix position of text cursor is a bit too high in Invitations section [Taiga #5511](https://tree.taiga.io/project/penpot/issue/5511)
- Fix undo when updating several texts [Taiga #5197](https://tree.taiga.io/project/penpot/issue/5197)
- Fix assets right click button for multiple selection [Taiga #5545](https://tree.taiga.io/project/penpot/issue/5545)
- Fix problem with precision in resizes [Taiga #5623](https://tree.taiga.io/project/penpot/issue/5623)
### :arrow_up: Deps updates

View file

@ -155,6 +155,7 @@
(dm/export gco/shapes->rect)
(dm/export gco/points->center)
(dm/export gco/transform-points)
(dm/export gco/shape->points)
(dm/export gtr/move)
(dm/export gtr/absolute-move)

View file

@ -87,3 +87,15 @@
(or ^boolean (mth/nan? (:x p))
^boolean (mth/nan? (:y p))))
points)))
(defn shape->points
[{:keys [transform points]}]
(if (gmt/unit? transform)
;; Fix problem with precision could skew the shape
;; when there are no transforms the points are the selrect shape
(let [p0 (nth points 0) ;; left top
p2 (nth points 2) ;; right bottom
p1 (gpt/point (:x p2) (:y p0))
p3 (gpt/point (:x p0) (:y p2))]
[p0 p1 p2 p3])
points))

View file

@ -473,7 +473,7 @@
(cond-> modif-tree
snap-pixel? (gpp/adjust-pixel-precision objects snap-precision snap-ignore-axis))
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))
bounds (d/lazy-map (keys objects) #(gco/shape->points (get objects %)))
bounds (cond-> bounds
(some? old-modif-tree)
(transform-bounds objects old-modif-tree))

View file

@ -63,7 +63,7 @@
(defn set-pixel-precision
"Adjust modifiers so they adjust to the pixel grid"
[modifiers shape precision ignore-axis]
(let [points (-> shape :points (gco/transform-points (ctm/modifiers->transform modifiers)))
(let [points (-> shape gco/shape->points (gco/transform-points (ctm/modifiers->transform modifiers)))
has-resize? (not (ctm/only-move? modifiers))
[modifiers points]

View file

@ -337,13 +337,11 @@
;; NOTE: ensure we have a fresh shallow copy of shape
shape (cr/clone shape)
shape (adjust-shape-flips! shape points)
center (gco/points->center points)
selrect (calculate-selrect points center)
transform (calculate-transform points center selrect)
inverse (when (some? transform) (gmt/inverse transform))
]
inverse (when (some? transform) (gmt/inverse transform))]
(if-not (and (some? inverse) (some? transform))
shape

View file

@ -35,6 +35,7 @@
input {
&.no-padding {
padding-top: 12px;
height: 50px;
}
min-height: 40px;
}

View file

@ -85,6 +85,15 @@
}
}
span.library-title {
color: $color-gray-10;
font-size: $fs14;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tool-window-bar-icon {
height: 21px;
display: flex;

View file

@ -407,9 +407,9 @@
(defn- prepare-duplicate-shape-change
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id]
(prepare-duplicate-shape-change changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id (:frame-id obj) (:parent-id obj)))
(prepare-duplicate-shape-change changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id (:frame-id obj) (:parent-id obj) false))
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id]
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id duplicating-component?]
(cond
(nil? obj)
changes
@ -423,8 +423,9 @@
parent-id (or parent-id frame-id)
name (:name obj)
is-component-root? (:saved-component-root obj)
is-component-main? (:main-instance obj)
is-component-root? (or (:saved-component-root? obj) (ctk/instance-root? obj))
duplicating-component? (or duplicating-component? is-component-root?)
is-component-main? (ctk/main-instance? obj)
regenerate-component
(fn [changes shape]
(let [components-v2 (dm/get-in library-data [:options :components-v2])
@ -437,20 +438,20 @@
:parent-id parent-id
:frame-id frame-id)
(dissoc :shapes
:main-instance
:shape-ref
:use-for-thumbnail)
:main-instance?
:use-for-thumbnail?)
(gsh/move delta)
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects))
(cond-> (ctl/grid-layout? obj)
(remap-grid-cells ids-map)))
changes (-> (pcb/add-object changes new-obj)
(pcb/amend-last-change #(assoc % :old-id (:id obj)))
(cond-> (ctl/grid-layout? objects (:parent-id obj))
(-> (pcb/update-shapes [(:parent-id obj)] ctl/assign-cells)
(pcb/reorder-grid-children [(:parent-id obj)]))))
new-obj (cond-> new-obj
(not duplicating-component?)
(dissoc :shape-ref))
changes (-> (pcb/add-object changes new-obj {:ignore-touched duplicating-component?})
(pcb/amend-last-change #(assoc % :old-id (:id obj))))
changes (cond-> changes
(and is-component-root? is-component-main?)
@ -470,7 +471,8 @@
it
file-id
(if frame? new-id frame-id)
new-id))
new-id
duplicating-component?))
changes
(map (d/getf objects) (:shapes obj)))))))

View file

@ -627,6 +627,18 @@
(rx/of (update-text-attrs {:id id :attrs attrs}))
(rx/empty)))))))
(defn update-all-attrs
[ids attrs]
(ptk/reify ::update-all-attrs
ptk/WatchEvent
(watch [_ _ _]
(let [undo-id (js/Symbol)]
(rx/concat
(rx/of (dwu/start-undo-transaction undo-id))
(->> (rx/from ids)
(rx/map #(update-attrs % attrs)))
(rx/of (dwu/commit-undo-transaction undo-id)))))))
(defn apply-typography
"A higher level event that has the resposability of to apply the

View file

@ -130,11 +130,13 @@
(mf/use-callback
(mf/deps shape state)
(fn [event]
(dom/stop-propagation event)
(dom/prevent-default event)
(st/emit! ::dwt/finalize-editor-state)
(st/emit! (dwt/initialize-editor-state shape default-decorator))
(reset! blurred true)))
(let [is-empty? (ted/is-current-empty state)]
(dom/stop-propagation event)
(dom/prevent-default event)
(when (not is-empty?)
(st/emit! ::dwt/finalize-editor-state)
(st/emit! (dwt/initialize-editor-state shape default-decorator)))
(reset! blurred true))))
on-focus
(mf/use-callback

View file

@ -78,11 +78,11 @@
(if local?
[:*
[:span file-name " (" (tr "workspace.assets.local-library") ")"]
[:span.library-title file-name " (" (tr "workspace.assets.local-library") ")"]
(when shared?
[:span.tool-badge (tr "workspace.assets.shared")])]
[:*
[:span file-name]
[:span.library-title file-name]
[:span.tool-link.tooltip.tooltip-left {:alt "Open library file"}
[:a {:href (str "#" url)
:target "_blank"

View file

@ -172,16 +172,16 @@
emit-update!
(mf/use-callback
(mf/deps values)
(fn [id attrs]
(st/emit! (dwt/save-font (-> (merge txt/default-text-attrs values attrs)
(select-keys dwt/text-attrs)))
(dwt/update-attrs id attrs))))
(fn [ids attrs]
(st/emit! (dwt/save-font (-> (merge txt/default-text-attrs values attrs)
(select-keys dwt/text-attrs)))
(dwt/update-all-attrs ids attrs))))
on-change
(mf/use-callback
(mf/deps ids emit-update!)
(fn [attrs]
(run! #(emit-update! % attrs) ids)))
(emit-update! ids attrs)))
typography
(mf/use-memo
@ -211,8 +211,9 @@
typography (dwt/generate-typography-name typography)
id (uuid/next)]
(st/emit! (dwl/add-typography (assoc typography :id id) false))
(run! #(emit-update! % {:typography-ref-id id
:typography-ref-file file-id}) ids)))
(emit-update! ids
{:typography-ref-id id
:typography-ref-file file-id})))
handle-detach-typography
(mf/use-callback

View file

@ -73,6 +73,10 @@
(let [block (impl/getCurrentBlock state)]
(get-editor-block-data block)))
(defn is-current-empty
[state]
(impl/isCurrentEmpty state))
(defn get-editor-current-inline-styles
[state]
(if (impl/isCurrentEmpty state)