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

This commit is contained in:
Andrey Antukh 2022-09-20 08:48:55 +02:00
commit 32b8c17dad
15 changed files with 66 additions and 35 deletions

View file

@ -47,6 +47,9 @@
- Fix toggle overlay position [Taiga #4091](https://tree.taiga.io/project/penpot/issue/4091) - Fix toggle overlay position [Taiga #4091](https://tree.taiga.io/project/penpot/issue/4091)
- Fix overlay closed on clicked outside [Taiga #4027](https://tree.taiga.io/project/penpot/issue/4027) - Fix overlay closed on clicked outside [Taiga #4027](https://tree.taiga.io/project/penpot/issue/4027)
- Fix animate multiple overlays [Taiga #3993](https://tree.taiga.io/project/penpot/issue/3993) - Fix animate multiple overlays [Taiga #3993](https://tree.taiga.io/project/penpot/issue/3993)
- Fix problem with snap to grids [#2221](https://github.com/penpot/penpot/issues/2221)
- Fix issue when scaling to value 0 [#2252](https://github.com/penpot/penpot/issues/2252)
- Fix problem when moving shapes inside nested frames [Taiga #4113](https://tree.taiga.io/project/penpot/issue/4113)
## 1.15.3-beta ## 1.15.3-beta
@ -60,6 +63,8 @@
- Fix undo after moving layers will wrongly order the layers [Taiga #3344](https://tree.taiga.io/project/penpot/issue/3344) - Fix undo after moving layers will wrongly order the layers [Taiga #3344](https://tree.taiga.io/project/penpot/issue/3344)
- Fix grouping typographies by drag & drop does not work (again) [#2203](https://github.com/penpot/penpot/issues/2203) - Fix grouping typographies by drag & drop does not work (again) [#2203](https://github.com/penpot/penpot/issues/2203)
- Fix when ungrouping, the items previously grouped should ALWAYS remain selected [Taiga #4064](https://tree.taiga.io/project/penpot/issue/4064) - Fix when ungrouping, the items previously grouped should ALWAYS remain selected [Taiga #4064](https://tree.taiga.io/project/penpot/issue/4064)
- Change shortcut for "Clear undo" [#2219](https://github.com/penpot/penpot/issues/2219)
## 1.15.2-beta ## 1.15.2-beta

View file

@ -317,9 +317,14 @@
(unit) (unit)
(scale value)))) (scale value))))
(defn no-zeros
"Remove zero values from either coordinate"
[point]
(-> point
(update :x #(if (mth/almost-zero? %) 0.001 %))
(update :y #(if (mth/almost-zero? %) 0.001 %))))
;; --- Debug ;; --- Debug
(defmethod pp/simple-dispatch Point [obj] (pr obj)) (defmethod pp/simple-dispatch Point [obj] (pr obj))

View file

@ -96,8 +96,8 @@
(defn get-root-frames-ids (defn get-root-frames-ids
"Retrieves all frame objects as vector. It is not implemented in "Retrieves all frame objects as vector. It is not implemented in
function of `get-immediate-children` for performance reasons. This function of `cph/get-immediate-children` for performance
function is executed in the render hot path." reasons. This function is executed in the render hot path."
[objects] [objects]
(let [add-frame (let [add-frame
(fn [result shape] (fn [result shape]
@ -213,6 +213,28 @@
(let [frame-id (frame-id-by-position objects position)] (let [frame-id (frame-id-by-position objects position)]
(get objects frame-id))) (get objects frame-id)))
(defn all-frames-by-position
[objects position]
(->> (get-frames-ids objects)
(sort-z-index objects)
(filterv #(and position (gsh/has-point? (get objects %) position)))))
(defn top-nested-frame
"Search for the top nested frame for positioning shapes when moving or creating.
Looks for all the frames in a position and then goes in depth between the top-most and its
children to find the target."
[objects position]
(let [frame-ids (all-frames-by-position objects position)
frame-set (set frame-ids)]
(loop [current-id (first frame-ids)]
(let [current-shape (get objects current-id)
child-frame-id (d/seek #(contains? frame-set %)
(-> (:shapes current-shape) reverse))]
(if (nil? child-frame-id)
(or current-id uuid/zero)
(recur child-frame-id))))))
(defn get-viewer-frames (defn get-viewer-frames
([objects] ([objects]
(get-viewer-frames objects nil)) (get-viewer-frames objects nil))

View file

@ -16,7 +16,7 @@
.text-editor { .text-editor {
.DraftEditor-root { .DraftEditor-root {
height: auto; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }

View file

@ -1374,7 +1374,7 @@
[frame-id frame-id delta]) [frame-id frame-id delta])
(empty? page-selected) (empty? page-selected)
(let [frame-id (ctst/frame-id-by-position page-objects mouse-pos) (let [frame-id (ctst/top-nested-frame page-objects mouse-pos)
delta (gpt/subtract mouse-pos orig-pos)] delta (gpt/subtract mouse-pos orig-pos)]
[frame-id frame-id delta]) [frame-id frame-id delta])
@ -1486,8 +1486,8 @@
height 16 height 16
page-id (:current-page-id state) page-id (:current-page-id state)
frame-id (-> (wsh/lookup-page-objects state page-id) frame-id (-> (wsh/lookup-page-objects state page-id)
(ctst/frame-id-by-position @ms/mouse-position)) (ctst/top-nested-frame @ms/mouse-position))
shape (cts/setup-rect-selrect shape (cp/setup-rect-selrect
{:id id {:id id
:type :text :type :text
:name "Text" :name "Text"

View file

@ -11,7 +11,7 @@
[app.common.math :as mth] [app.common.math :as mth]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.types.shape :as cts] [app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctt] [app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace.drawing.common :as common] [app.main.data.workspace.drawing.common :as common]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
@ -65,8 +65,7 @@
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
focus (:workspace-focus-selected state) focus (:workspace-focus-selected state)
zoom (get-in state [:workspace-local :zoom] 1) zoom (get-in state [:workspace-local :zoom] 1)
fid (ctst/top-nested-frame objects initial)
fid (ctt/frame-id-by-position objects initial)
shape (get-in state [:workspace-drawing :object]) shape (get-in state [:workspace-drawing :object])
shape (-> shape shape (-> shape

View file

@ -8,7 +8,7 @@
(:require (:require
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.path :as gsp]
[app.common.types.shape-tree :as ctt] [app.common.types.shape-tree :as ctst]
[app.main.data.workspace.drawing.common :as common] [app.main.data.workspace.drawing.common :as common]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[app.main.streams :as ms] [app.main.streams :as ms]
@ -47,7 +47,7 @@
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
content (get-in state [:workspace-drawing :object :content] []) content (get-in state [:workspace-drawing :object :content] [])
position (get-in content [0 :params] nil) position (get-in content [0 :params] nil)
frame-id (ctt/frame-id-by-position objects position)] frame-id (ctst/top-nested-frame objects position)]
(-> state (-> state
(assoc-in [:workspace-drawing :object :frame-id] frame-id)))))) (assoc-in [:workspace-drawing :object :frame-id] frame-id))))))

View file

@ -103,6 +103,7 @@
(gpt/point (+ (:width main-instance-shape) 50) 0)) (gpt/point (+ (:width main-instance-shape) 50) 0))
component-root (ctk/get-component-root component) component-root (ctk/get-component-root component)
frame-id (ctst/top-nested-frame objects (gpt/add orig-pos delta))
[new-component-shape new-component-shapes _] [new-component-shape new-component-shapes _]
(ctst/clone-object component-root (ctst/clone-object component-root

View file

@ -11,7 +11,7 @@
[app.common.path.commands :as upc] [app.common.path.commands :as upc]
[app.common.path.shapes-to-path :as upsp] [app.common.path.shapes-to-path :as upsp]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.shape-tree :as ctt] [app.common.types.shape-tree :as ctst]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.drawing.common :as dwdc] [app.main.data.workspace.drawing.common :as dwdc]
[app.main.data.workspace.edition :as dwe] [app.main.data.workspace.edition :as dwe]
@ -258,7 +258,7 @@
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
content (get-in state [:workspace-drawing :object :content] []) content (get-in state [:workspace-drawing :object :content] [])
position (get-in content [0 :params] nil) position (get-in content [0 :params] nil)
frame-id (ctt/frame-id-by-position objects position)] frame-id (ctst/top-nested-frame objects position)]
(-> state (-> state
(assoc-in [:workspace-drawing :object :frame-id] frame-id)))))) (assoc-in [:workspace-drawing :object :frame-id] frame-id))))))

View file

@ -36,7 +36,7 @@
;; Calculate the frame over which we're drawing ;; Calculate the frame over which we're drawing
(let [position @ms/mouse-position (let [position @ms/mouse-position
frame-id (:frame-id attrs (ctst/frame-id-by-position objects position)) frame-id (:frame-id attrs (ctst/top-nested-frame objects position))
shape (when-not (empty? selected) shape (when-not (empty? selected)
(cph/get-base-shape objects selected))] (cph/get-base-shape objects selected))]
@ -277,7 +277,6 @@
(ptk/reify ::create-and-add-shape (ptk/reify ::create-and-add-shape
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(prn ">>>create-")
(let [{:keys [width height]} data (let [{:keys [width height]} data
[vbc-x vbc-y] (viewport-center state) [vbc-x vbc-y] (viewport-center state)
@ -285,8 +284,8 @@
y (:y data (- vbc-y (/ height 2))) y (:y data (- vbc-y (/ height 2)))
page-id (:current-page-id state) page-id (:current-page-id state)
frame-id (-> (wsh/lookup-page-objects state page-id) frame-id (-> (wsh/lookup-page-objects state page-id)
(ctst/frame-id-by-position {:x frame-x :y frame-y})) (ctst/top-nested-frame {:x frame-x :y frame-y}))
shape (-> (cts/make-minimal-shape type) shape (-> (cp/make-minimal-shape type)
(merge data) (merge data)
(merge {:x x :y y}) (merge {:x x :y y})
(assoc :frame-id frame-id) (assoc :frame-id frame-id)

View file

@ -45,8 +45,8 @@
:subsections [:edit] :subsections [:edit]
:fn #(st/emit! dwc/redo)} :fn #(st/emit! dwc/redo)}
:clear-undo {:tooltip (ds/meta "Q") :clear-undo {:tooltip (ds/alt "Z")
:command (ds/c-mod "q") :command "alt+z"
:subsections [:edit] :subsections [:edit]
:fn #(st/emit! dwu/reinitialize-undo)} :fn #(st/emit! dwu/reinitialize-undo)}

View file

@ -14,7 +14,7 @@
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.spec :refer [max-safe-int min-safe-int]] [app.common.spec :refer [max-safe-int min-safe-int]]
[app.common.types.shape :as cts] [app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctt] [app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.selection :as dws] [app.main.data.workspace.selection :as dws]
@ -359,7 +359,7 @@
(let [{:keys [tag attrs hidden]} element-data (let [{:keys [tag attrs hidden]} element-data
attrs (usvg/format-styles attrs) attrs (usvg/format-styles attrs)
element-data (cond-> element-data (map? element-data) (assoc :attrs attrs)) element-data (cond-> element-data (map? element-data) (assoc :attrs attrs))
name (ctt/generate-unique-name unames (or (:id attrs) (tag->name tag))) name (ctst/generate-unique-name unames (or (:id attrs) (tag->name tag)))
att-refs (usvg/find-attr-references attrs) att-refs (usvg/find-attr-references attrs)
references (usvg/find-def-references (:defs svg-data) att-refs) references (usvg/find-def-references (:defs svg-data) att-refs)
@ -436,17 +436,17 @@
(try (try
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
frame-id (ctt/frame-id-by-position objects position) frame-id (ctst/top-nested-frame objects position)
selected (wsh/lookup-selected state) selected (wsh/lookup-selected state)
[vb-x vb-y vb-width vb-height] (svg-dimensions svg-data) [vb-x vb-y vb-width vb-height] (svg-dimensions svg-data)
x (- x vb-x (/ vb-width 2)) x (- x vb-x (/ vb-width 2))
y (- y vb-y (/ vb-height 2)) y (- y vb-y (/ vb-height 2))
unames (ctt/retrieve-used-names objects) unames (ctst/retrieve-used-names objects)
svg-name (->> (str/replace (:name svg-data) ".svg" "") svg-name (->> (str/replace (:name svg-data) ".svg" "")
(ctt/generate-unique-name unames)) (ctst/generate-unique-name unames))
svg-data (-> svg-data svg-data (-> svg-data
(assoc :x x (assoc :x x

View file

@ -16,7 +16,7 @@
[app.common.pages.common :as cpc] [app.common.pages.common :as cpc]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.shape-tree :as ctt] [app.common.types.shape-tree :as ctst]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.collapse :as dwc] [app.main.data.workspace.collapse :as dwc]
@ -352,7 +352,8 @@
(gpt/multiply handler-mult)) (gpt/multiply handler-mult))
;; Resize vector ;; Resize vector
scalev (gpt/divide (gpt/add shapev deltav) shapev) scalev (-> (gpt/divide (gpt/add shapev deltav) shapev)
(gpt/no-zeros))
scalev (if lock? scalev (if lock?
(let [v (cond (let [v (cond
@ -748,13 +749,13 @@
(let [position @ms/mouse-position (let [position @ms/mouse-position
page-id (:current-page-id state) page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
frame-id (ctt/frame-id-by-position objects position) frame-id (ctst/top-nested-frame objects position)
lookup (d/getf objects) lookup (d/getf objects)
moving-shapes moving-shapes
(->> ids (->> ids
(cph/clean-loops objects) (cph/clean-loops objects)
(keep (d/getf objects)) (keep lookup)
(remove #(= (:frame-id %) frame-id))) (remove #(= (:frame-id %) frame-id)))
moving-frames moving-frames
@ -767,7 +768,7 @@
(fn [shape] (fn [shape]
;; Hide in viwer must be enabled just when a board is moved ;; Hide in viwer must be enabled just when a board is moved
;; inside another artboard an nested to it, we have to avoid ;; inside another artboard an nested to it, we have to avoid
;; situations like: - Moving inside the same frame - Moving ;; situations like: 1. Moving inside the same frame; 2. Moving
;; outside the frame ;; outside the frame
(cond-> shape (cond-> shape
(and (not= frame-id (:id shape)) (and (not= frame-id (:id shape))

View file

@ -21,8 +21,7 @@
:width width :width width
:fontFamily "sourcesanspro" :fontFamily "sourcesanspro"
:display "flex" :display "flex"
:whiteSpace "break-spaces" :whiteSpace "break-spaces"}]
:flex-wrap "wrap"}]
(cond-> base (cond-> base
(= valign "top") (obj/set! "alignItems" "flex-start") (= valign "top") (obj/set! "alignItems" "flex-start")
(= valign "center") (obj/set! "alignItems" "center") (= valign "center") (obj/set! "alignItems" "center")

View file

@ -56,7 +56,7 @@
(defn get-grids-snap-points (defn get-grids-snap-points
[frame coord] [frame coord]
(if (not (ctst/rotated-frame? frame)) (if (ctst/rotated-frame? frame)
[] []
(let [grid->snap (fn [[grid-type position]] (let [grid->snap (fn [[grid-type position]]
{:type :layout {:type :layout