diff --git a/CHANGES.md b/CHANGES.md index 9bc1c955d..1da4bf6ae 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,6 +41,12 @@ - Fix path stroke is not working properly with high thickness [Taiga #2154](https://tree.taiga.io/project/penpot/issue/2154). - Fix bug with transformation operations [Taiga #2155](https://tree.taiga.io/project/penpot/issue/2155). - Fix bug in firefox when a text box is inside a mask [Taiga #2152](https://tree.taiga.io/project/penpot/issue/2152). +- Fix problem with stroke inside/outside [Taiga #2186](https://tree.taiga.io/project/penpot/issue/2186) +- Fix masks export area [Taiga #2189](https://tree.taiga.io/project/penpot/issue/2189) +- Fix paste in place in arboards [Taiga #2188](https://tree.taiga.io/project/penpot/issue/2188) +- Fix font size input stuck on selection change [Taiga #2184](https://tree.taiga.io/project/penpot/issue/2184) +- Fix stroke cut on shapes export [Taiga #2171](https://tree.taiga.io/project/penpot/issue/2171) +- Fix no color when boolean with an SVG [Taiga #2193](https://tree.taiga.io/project/penpot/issue/2193) ### :arrow_up: Deps updates diff --git a/common/src/app/common/geom/shapes.cljc b/common/src/app/common/geom/shapes.cljc index 86cd32d81..91a7043ba 100644 --- a/common/src/app/common/geom/shapes.cljc +++ b/common/src/app/common/geom/shapes.cljc @@ -13,7 +13,8 @@ [app.common.geom.shapes.intersect :as gin] [app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.rect :as gpr] - [app.common.geom.shapes.transforms :as gtr])) + [app.common.geom.shapes.transforms :as gtr] + [app.common.math :as mth])) ;; --- Setup (Initialize) ;; FIXME: Is this the correct place for these functions? @@ -127,6 +128,13 @@ (assoc :selrect selrect :points points)))) +(defn shape-stroke-margin + [shape stroke-width] + (if (= (:type shape) :path) + ;; TODO: Calculate with the stroke offset (not implemented yet + (mth/sqrt (* 2 stroke-width stroke-width)) + (- (mth/sqrt (* 2 stroke-width stroke-width)) stroke-width))) + ;; EXPORTS (d/export gco/center-shape) diff --git a/common/src/app/common/path/shapes_to_path.cljc b/common/src/app/common/path/shapes_to_path.cljc index 7a41c60e7..d2f905914 100644 --- a/common/src/app/common/path/shapes_to_path.cljc +++ b/common/src/app/common/path/shapes_to_path.cljc @@ -176,7 +176,12 @@ (let [children (->> (:shapes shape) (map #(get objects %)) (map #(convert-to-path % objects))) - head (first children) + bool-type (:bool-type shape) + head (if (= bool-type :difference) (first children) (last children)) + head (cond-> head + (and (contains? head :svg-attrs) (nil? (:fill-color head))) + (assoc :fill-color "#000000")) + head-data (select-keys head style-properties) content (pb/content-bool (:bool-type shape) (mapv :content children))] diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 9219ab1f9..e5e36f6ab 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1648,7 +1648,6 @@ ;; Procceed with the standard shape paste procediment. (do-paste [it state mouse-pos media] (let [page-objects (wsh/lookup-page-objects state) - all-objects (merge page-objects paste-objects) media-idx (d/index-by :prev-id media) ;; Calculate position for the pasted elements @@ -1670,6 +1669,8 @@ :shape-ref :touched)))))) + all-objects (merge page-objects paste-objects) + page-id (:current-page-id state) unames (-> (wsh/lookup-page-objects state page-id) (dwc/retrieve-used-names)) ;; TODO: move this calculation inside prepare-duplcate-changes? diff --git a/frontend/src/app/main/data/workspace/booleans.cljs b/frontend/src/app/main/data/workspace/booleans.cljs index 25a03e57e..5c3c1af7b 100644 --- a/frontend/src/app/main/data/workspace/booleans.cljs +++ b/frontend/src/app/main/data/workspace/booleans.cljs @@ -33,6 +33,10 @@ [bool-type name shapes objects] (let [shapes (mapv #(stp/convert-to-path % objects) shapes) head (if (= bool-type :difference) (first shapes) (last shapes)) + head (cond-> head + (and (contains? head :svg-attrs) (nil? (:fill-color head))) + (assoc :fill-color "#000000")) + head-data (select-keys head stp/style-properties)] [(-> {:id (uuid/next) :type :bool @@ -51,7 +55,10 @@ (let [shapes (->> (:shapes group) (map #(get objects %)) (mapv #(stp/convert-to-path % objects))) - head (first shapes) + head (if (= bool-type :difference) (first shapes) (last shapes)) + head (cond-> head + (and (contains? head :svg-attrs) (nil? (:fill-color head))) + (assoc :fill-color "#000000")) head-data (select-keys head stp/style-properties)] (-> group diff --git a/frontend/src/app/main/ui/components/editable_select.cljs b/frontend/src/app/main/ui/components/editable_select.cljs index d1a2e666f..49cea928f 100644 --- a/frontend/src/app/main/ui/components/editable_select.cljs +++ b/frontend/src/app/main/ui/components/editable_select.cljs @@ -76,6 +76,7 @@ handle-key-down (mf/use-callback + (mf/deps set-value) (fn [event] (when (= type "number") (let [up? (kbd/up-arrow? event) diff --git a/frontend/src/app/main/ui/render.cljs b/frontend/src/app/main/ui/render.cljs index a0a3b81dc..0263a4826 100644 --- a/frontend/src/app/main/ui/render.cljs +++ b/frontend/src/app/main/ui/render.cljs @@ -37,11 +37,17 @@ (update :width + (* 2 padding)) (update :height + (* 2 padding)))] - (if (= :group (:type object)) + (cond + (and (= :group (:type object)) + (:masked-group? object)) + (calc-bounds (get objects (first (:shapes object))) objects) + + (= :group (:type object)) (->> (:shapes object) (into [obj-bounds] xf-get-bounds) (gsh/join-rects)) + :else obj-bounds))) (mf/defc object-svg diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 619e9954e..35d7691de 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -35,8 +35,22 @@ [{:keys [shape render-id]}] (let [stroke-mask-id (str "outer-stroke-" render-id) shape-id (str "stroke-shape-" render-id) - stroke-width (:stroke-width shape 0)] - [:mask {:id stroke-mask-id} + stroke-width (case (:stroke-alignment shape :center) + :center (/ (:stroke-width shape 0) 2) + :outer (:stroke-width shape 0) + 0) + margin (gsh/shape-stroke-margin shape stroke-width) + bounding-box (-> (gsh/points->selrect (:points shape)) + (update :x - (+ stroke-width margin)) + (update :y - (+ stroke-width margin)) + (update :width + (* 2 (+ stroke-width margin))) + (update :height + (* 2 (+ stroke-width margin))))] + [:mask {:id stroke-mask-id + :x (:x bounding-box) + :y (:y bounding-box) + :width (:width bounding-box) + :height (:height bounding-box) + :maskUnits "userSpaceOnUse"} [:use {:xlinkHref (str "#" shape-id) :style #js {:fill "none" :stroke "white" :strokeWidth (* stroke-width 2)}}] @@ -146,8 +160,8 @@ (mf/defc stroke-defs [{:keys [shape render-id]}] - (when (and (= (:type shape) :path) - (gsh/open-path? shape)) + (when (or (not= (:type shape) :path) + (not (gsh/open-path? shape))) (cond (and (= :inner (:stroke-alignment shape :center)) (> (:stroke-width shape 0) 0)) diff --git a/frontend/src/app/main/ui/shapes/filters.cljs b/frontend/src/app/main/ui/shapes/filters.cljs index 25af34796..60ba3fee6 100644 --- a/frontend/src/app/main/ui/shapes/filters.cljs +++ b/frontend/src/app/main/ui/shapes/filters.cljs @@ -202,17 +202,12 @@ :height (- y2 y1)}))))) (defn calculate-padding [shape] - (let [{:keys [stroke-style stroke-alignment stroke-width]} shape] - (cond - (and (not= stroke-style :none) - (= stroke-alignment :outer)) - stroke-width - - (and (not= stroke-style :none) - (= stroke-alignment :center)) - (mth/ceil (/ stroke-width 2)) - - :else 0))) + (let [stroke-width (case (:stroke-alignment shape :center) + :center (/ (:stroke-width shape 0) 2) + :outer (:stroke-width shape 0) + 0) + margin (gsh/shape-stroke-margin shape stroke-width)] + (+ stroke-width margin))) (mf/defc filters [{:keys [filter-id shape]}] @@ -221,9 +216,7 @@ ;; Adds the previous filter as `filter-in` parameter filters (map #(assoc %1 :filter-in %2) filters (cons nil (map :id filters))) - bounds (get-filters-bounds shape filters (or (-> shape :blur :value) 0)) - padding (calculate-padding shape)] [:*