From 745cf1c79d4f343d27854c0e336d83f871df4e38 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 31 Mar 2023 12:05:59 +0200 Subject: [PATCH 1/4] :bug: Fix problem with invalid geometry --- common/src/app/common/geom/point.cljc | 6 ++++-- common/src/app/common/geom/shapes/common.cljc | 15 ++++++++++++++- common/src/app/common/geom/shapes/modifiers.cljc | 5 ++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/geom/point.cljc b/common/src/app/common/geom/point.cljc index d83a46c991..5517bc5a24 100644 --- a/common/src/app/common/geom/point.cljc +++ b/common/src/app/common/geom/point.cljc @@ -318,8 +318,10 @@ (defn unit [p1] (let [p-length (length p1)] - (Point. (/ (dm/get-prop p1 :x) p-length) - (/ (dm/get-prop p1 :y) p-length)))) + (if (mth/almost-zero? p-length) + (Point. 0 0) + (Point. (/ (dm/get-prop p1 :x) p-length) + (/ (dm/get-prop p1 :y) p-length))))) (defn perpendicular [pt] diff --git a/common/src/app/common/geom/shapes/common.cljc b/common/src/app/common/geom/shapes/common.cljc index 710c15e782..a0fcdb4b5d 100644 --- a/common/src/app/common/geom/shapes/common.cljc +++ b/common/src/app/common/geom/shapes/common.cljc @@ -9,7 +9,8 @@ [app.common.data :as d] [app.common.geom.matrix :as gmt] [app.common.geom.point :as gpt] - [app.common.geom.shapes.rect :as gpr])) + [app.common.geom.shapes.rect :as gpr] + [app.common.math :as mth])) (defn center-rect [{:keys [x y width height]}] @@ -71,3 +72,15 @@ [{:keys [x1 y1 x2 y2] :as sr} matrix] (let [[c1 c2] (transform-points [(gpt/point x1 y1) (gpt/point x2 y2)] matrix)] (gpr/corners->selrect c1 c2))) + +(defn invalid-geometry? + [{:keys [points selrect]}] + + (or (mth/nan? (:x selrect)) + (mth/nan? (:y selrect)) + (mth/nan? (:width selrect)) + (mth/nan? (:height selrect)) + (some (fn [p] + (or (mth/nan? (:x p)) + (mth/nan? (:y p)))) + points))) diff --git a/common/src/app/common/geom/shapes/modifiers.cljc b/common/src/app/common/geom/shapes/modifiers.cljc index d14f5aaa3e..cd94fb11a0 100644 --- a/common/src/app/common/geom/shapes/modifiers.cljc +++ b/common/src/app/common/geom/shapes/modifiers.cljc @@ -9,6 +9,7 @@ [app.common.data :as d] [app.common.data.macros :as dm] [app.common.geom.point :as gpt] + [app.common.geom.shapes.common :as gco] [app.common.geom.shapes.constraints :as gct] [app.common.geom.shapes.flex-layout :as gcl] [app.common.geom.shapes.pixel-precision :as gpp] @@ -175,6 +176,7 @@ (let [children (->> (cph/get-immediate-children objects (:id parent)) (remove :hidden) + (remove gco/invalid-geometry?) (map apply-modifiers)) layout-data (gcl/calc-layout-data parent children @transformed-parent-bounds) children (into [] (cond-> children (not (:reverse? layout-data)) reverse)) @@ -215,7 +217,8 @@ (ctm/resize-parent (gpt/point 1 scale-height) origin (:transform parent) (:transform-inverse parent))))) children (->> (cph/get-immediate-children objects parent-id) - (remove :hidden)) + (remove :hidden) + (remove gco/invalid-geometry?)) content-bounds (when (and (d/not-empty? children) (or (ctl/auto-height? parent) (ctl/auto-width? parent))) From 6abca96da1311a47d1b312840e59d8c738e7953b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 7 Apr 2023 08:55:53 +0200 Subject: [PATCH 2/4] :paperclip: Add improved docstring for penpot_secret_key --- docker/images/docker-compose.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/images/docker-compose.yaml b/docker/images/docker-compose.yaml index 8b0f671c95..7e85d178c0 100644 --- a/docker/images/docker-compose.yaml +++ b/docker/images/docker-compose.yaml @@ -140,10 +140,10 @@ services: - PENPOT_FLAGS=enable-registration enable-login-with-password disable-email-verification enable-smtp enable-prepl-server ## Penpot SECRET KEY. It serves as a master key from which other keys for subsystems - ## (eg http sessions) are derived. + ## (eg http sessions, or invitations) are derived. ## - ## Leave it comment if it is ok for you to have to login again after each backend - ## restart. + ## If you leve it commented, all created sessions and invitations will + ## become invalid on container restart. ## ## If you going to uncomment this, we recommend use here a trully randomly generated ## 512 bits base64 encoded string. You can generate one with: From ae3de34033972288101c8160ef145cdd50cfd1b0 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 13 Apr 2023 14:15:49 +0200 Subject: [PATCH 3/4] :bug: Fix problem with rulers not placing correctly --- CHANGES.md | 6 ++++++ frontend/src/app/main/ui/workspace/viewport/hooks.cljs | 5 ++--- version.txt | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 47c8c35a9f..b5a5182530 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 1.18.3 + +### :bug: Bugs fixed + +- Fix problem with rulers not placing correctly [Taiga #5093](https://tree.taiga.io/project/penpot/issue/5093) + ## 1.18.2 ### :bug: Bugs fixed diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index 84bd54855a..240bfbee55 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -59,10 +59,9 @@ (fn [] (when-not vport (let [node (mf/ref-val viewport-ref) - prnt (dom/get-parent node) - size (dom/get-client-size prnt)] + prnt (dom/get-parent node)] ;; We schedule the event so it fires after `initialize-page` event - (timers/schedule #(st/emit! (dw/initialize-viewport size)))))))) + (timers/schedule #(st/emit! (dw/initialize-viewport (dom/get-client-size prnt))))))))) (defn setup-cursor [cursor alt? mod? space? panning drawing-tool drawing-path? path-editing? z? workspace-read-only?] (mf/use-effect diff --git a/version.txt b/version.txt index b57fc7228b..b9fb27ab4f 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.18.2 +1.18.3 From 452dcb5eecb4841a742ede0e1d957f88eb9c1ba2 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 13 Apr 2023 14:16:03 +0200 Subject: [PATCH 4/4] :bug: Fix problem when "show in view mode" flag --- frontend/src/app/main/data/workspace/shapes.cljs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index f0cb2757bc..17fd1bed8d 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -129,6 +129,9 @@ objects (wsh/lookup-page-objects state page-id) ordered-indexes (cph/order-by-indexed-shapes objects shapes) + parent-id (get-in objects [frame-id :parent-id]) + + ordered-indexes (->> ordered-indexes (remove #(= % parent-id))) to-move-shapes (map (d/getf objects) ordered-indexes) changes @@ -137,9 +140,7 @@ (pcb/with-objects objects) (cond-> (not (ctl/any-layout? objects frame-id)) (pcb/update-shapes ordered-indexes ctl/remove-layout-item-data)) - (pcb/update-shapes ordered-indexes #(cond-> % - (and (cph/frame-shape? %) (not= (:parent-id %) uuid/zero)) - (assoc :hide-in-viewer true))) + (pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true))) (pcb/change-parent frame-id to-move-shapes 0) (cond-> (ctl/grid-layout? objects frame-id) (pcb/update-shapes [frame-id] ctl/assign-cells))))]