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 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 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 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 ### :arrow_up: Deps updates

View file

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

View file

@ -87,3 +87,15 @@
(or ^boolean (mth/nan? (:x p)) (or ^boolean (mth/nan? (:x p))
^boolean (mth/nan? (:y p)))) ^boolean (mth/nan? (:y p))))
points))) 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 (cond-> modif-tree
snap-pixel? (gpp/adjust-pixel-precision objects snap-precision snap-ignore-axis)) 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 bounds (cond-> bounds
(some? old-modif-tree) (some? old-modif-tree)
(transform-bounds objects old-modif-tree)) (transform-bounds objects old-modif-tree))

View file

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

View file

@ -341,9 +341,7 @@
center (gco/points->center points) center (gco/points->center points)
selrect (calculate-selrect points center) selrect (calculate-selrect points center)
transform (calculate-transform points center selrect) 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)) (if-not (and (some? inverse) (some? transform))
shape shape

View file

@ -35,6 +35,7 @@
input { input {
&.no-padding { &.no-padding {
padding-top: 12px; padding-top: 12px;
height: 50px;
} }
min-height: 40px; 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 { .tool-window-bar-icon {
height: 21px; height: 21px;
display: flex; display: flex;

View file

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

View file

@ -627,6 +627,18 @@
(rx/of (update-text-attrs {:id id :attrs attrs})) (rx/of (update-text-attrs {:id id :attrs attrs}))
(rx/empty))))))) (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 (defn apply-typography
"A higher level event that has the resposability of to apply the "A higher level event that has the resposability of to apply the

View file

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

View file

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

View file

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

View file

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