From 8bf8a28439943798c2d6e02c5fb0655420996d18 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 26 Mar 2024 09:41:41 +0100 Subject: [PATCH 1/9] :bug: Fix copy paste images on different environments --- frontend/src/app/main/data/workspace.cljs | 30 ++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index e2bf369b6..d0c6f3a74 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1573,7 +1573,9 @@ (->> (:strokes obj) (keep :stroke-image)) (when (cfh/image-shape? obj) - [(:metadata obj)]))] + [(:metadata obj)]) + (when (:fill-image obj) + [(:fill-image obj)]))] (if (seq imgdata) (->> (rx/from imgdata) @@ -1833,13 +1835,19 @@ (defn paste-shapes [{in-viewport? :in-viewport :as pdata}] (letfn [(translate-media [mdata media-idx attr-path] - (let [id (get-in mdata attr-path) + (let [id (-> (get-in mdata attr-path) + (:id)) mobj (get media-idx id)] (if mobj - (update-in mdata attr-path (fn [value] - (-> value - (assoc :id (:id mobj)) - (assoc :path (:path mobj))))) + (if (empty? attr-path) + (-> mdata + (assoc :id (:id mobj)) + (assoc :path (:path mobj))) + (update-in mdata attr-path (fn [value] + (-> value + (assoc :id (:id mobj)) + (assoc :path (:path mobj)))))) + mdata))) (add-obj? [chg] @@ -1849,15 +1857,15 @@ ;; references to the new uploaded media-objects. (process-rchange [media-idx change] (let [;; Texts can have different fills for pieces of the text - tr-fill-xf (map #(translate-media % media-idx [:fill-image :id])) - tr-stroke-xf (map #(translate-media % media-idx [:stroke-image :id]))] - + tr-fill-xf (map #(translate-media % media-idx [:fill-image])) + tr-stroke-xf (map #(translate-media % media-idx [:stroke-image]))] (if (add-obj? change) (update change :obj (fn [obj] (-> obj (update :fills #(into [] tr-fill-xf %)) (update :strokes #(into [] tr-stroke-xf %)) - (d/update-when :metadata translate-media media-idx [:id]) + (d/update-when :metadata translate-media media-idx []) + (d/update-when :fill-image translate-media media-idx []) (d/update-when :content (fn [content] (txt/xform-nodes tr-fill-xf content))) @@ -1983,7 +1991,7 @@ (let [file-id (:current-file-id state) page (wsh/lookup-page state) - media-idx (->> (:media pdata) + media-idx (->> (:images pdata) (d/index-by :prev-id)) selected (:selected pdata) From 4212b46835c2712252bd8f97303a828b7f288eae Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Tue, 26 Mar 2024 09:04:38 +0100 Subject: [PATCH 2/9] :bug: Add tooltip to select elements by color --- .../app/main/ui/workspace/sidebar/options/rows/color_row.cljs | 1 + frontend/translations/en.po | 4 ++++ frontend/translations/es.po | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs index 31dd285cb..dcbabace6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs @@ -268,6 +268,7 @@ :on-click on-remove} i/remove-icon]) (when select-only [:button {:class (stl/css :select-btn) + :title (tr "settings.select-this-color") :on-click handle-select} i/move])])) diff --git a/frontend/translations/en.po b/frontend/translations/en.po index dd5e69fea..52ee7dd65 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -2527,6 +2527,10 @@ msgstr "Detach" msgid "settings.multiple" msgstr "Mixed" +#: src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +msgid "settings.select-this-color" +msgstr "Select items using this style" + # SECTIONS msgid "shortcut-section.basics" msgstr "Basics" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index 601bd792f..8195efe3b 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -2573,6 +2573,10 @@ msgstr "Desacoplar" msgid "settings.multiple" msgstr "Varios" +#: src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +msgid "settings.select-this-color" +msgstr "Seleccionar elementos que usan este estilo" + # SECTIONS msgid "shortcut-section.basics" msgstr "Básicos" From 6a0768b490c01b21b3f0e6aa62b8c4768975f04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Albeza?= Date: Tue, 26 Mar 2024 14:45:03 +0100 Subject: [PATCH 3/9] :bug: Fix helper to compile polyfills --- frontend/scripts/_helpers.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/scripts/_helpers.js b/frontend/scripts/_helpers.js index b086ce5ec..cb2d36ac9 100644 --- a/frontend/scripts/_helpers.js +++ b/frontend/scripts/_helpers.js @@ -32,7 +32,6 @@ async function findFiles(basePath, predicate, options={}) { predicate = predicate ?? function() { return true; } let files = await fs.readdir(basePath, {recursive: options.recursive ?? false}) - files = files.filter((path) => path.endsWith(".svg")); files = files.map((path) => ph.join(basePath, path)); return files; @@ -54,7 +53,11 @@ export function isSassFile(path) { } export function isSvgFile(path) { - return path.endsWith(".scss"); + return path.endsWith(".svg"); +} + +export function isJsFile(path) { + return path.endsWith(".js"); } export async function compileSass(worker, path, options) { @@ -378,7 +381,7 @@ export async function compilePolyfills() { log.info("init: compile polyfills") - const files = await findFiles("resources/polyfills/"); + const files = await findFiles("resources/polyfills/", isJsFile); let result = []; for (let path of files) { const content = await fs.readFile(path, {encoding:"utf-8"}); From 5315dc18afc0764d59dee70da0450000bd5be32e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 26 Mar 2024 14:42:13 +0100 Subject: [PATCH 4/9] :bug: Fix problems with bool shapes --- common/src/app/common/geom/shapes/path.cljc | 4 +- .../app/main/ui/workspace/shapes/debug.cljs | 93 ++++++++++++++++++- .../ui/workspace/viewport/path_actions.cljs | 2 +- frontend/src/app/util/debug.cljs | 5 +- 4 files changed, 97 insertions(+), 7 deletions(-) diff --git a/common/src/app/common/geom/shapes/path.cljc b/common/src/app/common/geom/shapes/path.cljc index 941b3ffc2..9295c421d 100644 --- a/common/src/app/common/geom/shapes/path.cljc +++ b/common/src/app/common/geom/shapes/path.cljc @@ -845,13 +845,11 @@ (defn close-content [content] (into [] - (comp (filter sp/is-closed?) - (mapcat :data)) + (mapcat :data) (->> content (sp/close-subpaths) (sp/get-subpaths)))) - (defn ray-overlaps? [ray-point {selrect :selrect}] (and (>= (:y ray-point) (:y1 selrect)) diff --git a/frontend/src/app/main/ui/workspace/shapes/debug.cljs b/frontend/src/app/main/ui/workspace/shapes/debug.cljs index e1353644b..8844d18bc 100644 --- a/frontend/src/app/main/ui/workspace/shapes/debug.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/debug.cljs @@ -10,8 +10,12 @@ [app.common.data.macros :as dm] [app.common.files.helpers :as cfh] [app.common.geom.shapes :as gsh] + [app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.text :as gst] [app.common.math :as mth] + [app.common.svg.path.bool :as pb] + [app.common.svg.path.shapes-to-path :as stp] + [app.common.svg.path.subpath :as ups] [app.main.refs :as refs] [app.util.color :as uc] [app.util.debug :as dbg] @@ -87,13 +91,98 @@ :style {:stroke "green" :stroke-width (/ 2 zoom)}}]]))])) +(mf/defc debug-bool-shape + {::mf/wrap-props false} + [{:keys [shape]}] + + (let [objects (mf/deref refs/workspace-page-objects) + zoom (mf/deref refs/selected-zoom) + + radius (/ 3 zoom) + + c1 (-> (get objects (first (:shapes shape))) + (stp/convert-to-path objects)) + c2 (-> (get objects (second (:shapes shape))) + (stp/convert-to-path objects)) + + content-a (:content c1) + content-b (:content c2) + + bool-type (:bool-type shape) + should-reverse? (and (not= :union bool-type) + (= (ups/clockwise? content-b) + (ups/clockwise? content-a))) + + content-a (-> (:content c1) + (pb/close-paths) + (pb/add-previous)) + + content-b (-> (:content c2) + (pb/close-paths) + (cond-> should-reverse? (ups/reverse-content)) + (pb/add-previous)) + + + sr-a (gsp/content->selrect content-a) + sr-b (gsp/content->selrect content-b) + + [content-a-split content-b-split] (pb/content-intersect-split content-a content-b sr-a sr-b) + + ;;content-a-geom (gsp/content->geom-data content-a) + ;;content-b-geom (gsp/content->geom-data content-b) + ;;content-a-split (->> content-a-split #_(filter #(pb/contains-segment? % content-b sr-b content-b-geom))) + ;;content-b-split (->> content-b-split #_(filter #(pb/contains-segment? % content-a sr-a content-a-geom))) + ] + [:* + (for [[i cmd] (d/enumerate content-a-split)] + (let [p1 (:prev cmd) + p2 (gsp/command->point cmd) + + hp (case (:command cmd) + :line-to (-> (gsp/command->line cmd) + (gsp/line-values 0.5)) + + :curve-to (-> (gsp/command->bezier cmd) + (gsp/curve-values 0.5)) + nil)] + [:* + (when p1 + [:circle {:data-i i :key (dm/str "c11-" i) :cx (:x p1) :cy (:y p1) :r radius :fill "red"}]) + [:circle {:data-i i :key (dm/str "c12-" i) :cx (:x p2) :cy (:y p2) :r radius :fill "red"}] + + (when hp + [:circle {:data-i i :key (dm/str "c13-" i) :cx (:x hp) :cy (:y hp) :r radius :fill "orange"}])])) + + (for [[i cmd] (d/enumerate content-b-split)] + (let [p1 (:prev cmd) + p2 (gsp/command->point cmd) + + hp (case (:command cmd) + :line-to (-> (gsp/command->line cmd) + (gsp/line-values 0.5)) + + :curve-to (-> (gsp/command->bezier cmd) + (gsp/curve-values 0.5)) + nil)] + [:* + (when p1 + [:circle {:key (dm/str "c21-" i) :cx (:x p1) :cy (:y p1) :r radius :fill "blue"}]) + [:circle {:key (dm/str "c22-" i) :cx (:x p2) :cy (:y p2) :r radius :fill "blue"}] + + (when hp + [:circle {:data-i i :key (dm/str "c13-" i) :cx (:x hp) :cy (:y hp) :r radius :fill "green"}])]))])) + (mf/defc shape-debug [{:keys [shape]}] [:* (when ^boolean (dbg/enabled? :bounding-boxes) [:& debug-bounding-boxes {:shape shape}]) - (when (and ^boolean (cfh/text-shape? shape) - ^boolean (dbg/enabled? :text-outline) + (when (and ^boolean (dbg/enabled? :bool-shapes) + ^boolean (cfh/bool-shape? shape)) + [:& debug-bool-shape {:shape shape}]) + + (when (and ^boolean (dbg/enabled? :text-outline) + ^boolean (cfh/text-shape? shape) ^boolean (seq (:position-data shape))) [:& debug-text-bounds {:shape shape}])]) diff --git a/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs b/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs index 69597f5a1..0da613105 100644 --- a/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/path_actions.cljs @@ -27,7 +27,7 @@ (i/icon-xref :add (stl/css :add-icon :pathbar-icon))) (def ^:private remove-icon - (i/icon-xref :remove-icon (stl/css :remove-icon :pathbar-icon))) + (i/icon-xref :remove (stl/css :remove :pathbar-icon))) (def ^:private merge-nodes-icon (i/icon-xref :merge-nodes (stl/css :merge-nodes-icon :pathbar-icon))) diff --git a/frontend/src/app/util/debug.cljs b/frontend/src/app/util/debug.cljs index 067ac8a54..094550cef 100644 --- a/frontend/src/app/util/debug.cljs +++ b/frontend/src/app/util/debug.cljs @@ -86,7 +86,10 @@ :shape-panel ;; Show what is touched in copies - :display-touched}) + :display-touched + + ;; Show some visual indicators for bool shape + :bool-shapes}) (defn enable! [option] From 4dac2221e778d5f8e59c0d7849020d71ccbb91b9 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 26 Mar 2024 15:29:12 +0100 Subject: [PATCH 5/9] :bug: Fix problem with proportional scaling --- .../src/app/common/geom/shapes/effects.cljc | 6 ++++ .../src/app/common/geom/shapes/strokes.cljc | 6 ++++ common/src/app/common/types/modifiers.cljc | 36 ++++++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/common/src/app/common/geom/shapes/effects.cljc b/common/src/app/common/geom/shapes/effects.cljc index 912b2de6c..8cac7e25b 100644 --- a/common/src/app/common/geom/shapes/effects.cljc +++ b/common/src/app/common/geom/shapes/effects.cljc @@ -1,3 +1,9 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + (ns app.common.geom.shapes.effects) (defn update-shadow-scale diff --git a/common/src/app/common/geom/shapes/strokes.cljc b/common/src/app/common/geom/shapes/strokes.cljc index 272e5e12b..905aac030 100644 --- a/common/src/app/common/geom/shapes/strokes.cljc +++ b/common/src/app/common/geom/shapes/strokes.cljc @@ -1,3 +1,9 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + (ns app.common.geom.shapes.strokes) (defn update-stroke-width diff --git a/common/src/app/common/types/modifiers.cljc b/common/src/app/common/types/modifiers.cljc index 7967d0379..d0669a024 100644 --- a/common/src/app/common/types/modifiers.cljc +++ b/common/src/app/common/types/modifiers.cljc @@ -737,30 +737,32 @@ (apply-scale-content [shape value] - (cond-> shape - (cfh/text-shape? shape) - (update-text-content scale-text-content value) + ;; Scale can only be positive + (let [value (mth/abs value)] + (cond-> shape + (cfh/text-shape? shape) + (update-text-content scale-text-content value) - :always - (gsc/update-corners-scale value) + :always + (gsc/update-corners-scale value) - (d/not-empty? (:strokes shape)) - (gss/update-strokes-width value) + (d/not-empty? (:strokes shape)) + (gss/update-strokes-width value) - (d/not-empty? (:shadow shape)) - (gse/update-shadows-scale value) + (d/not-empty? (:shadow shape)) + (gse/update-shadows-scale value) - (some? (:blur shape)) - (gse/update-blur-scale value) + (some? (:blur shape)) + (gse/update-blur-scale value) - (ctl/flex-layout? shape) - (ctl/update-flex-scale value) + (ctl/flex-layout? shape) + (ctl/update-flex-scale value) - (ctl/grid-layout? shape) - (ctl/update-grid-scale value) + (ctl/grid-layout? shape) + (ctl/update-grid-scale value) - :always - (ctl/update-flex-child value)))] + :always + (ctl/update-flex-child value))))] (let [remove-children (fn [shapes children-to-remove] From bd88b872c7a47e5e78601befe90da4859bc64563 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 26 Mar 2024 15:34:28 +0100 Subject: [PATCH 6/9] :bug: Fix problem with flip horizontal/vertical --- frontend/src/app/main/data/workspace/transforms.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 80e38ab3e..a69805cdc 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -971,7 +971,7 @@ selrect (gsh/shapes->rect shapes) center (grc/rect->center selrect) modifiers (dwm/create-modif-tree selected (ctm/resize-modifiers (gpt/point -1.0 1.0) center))] - (rx/of (dwm/apply-modifiers {:modifiers modifiers})))))) + (rx/of (dwm/apply-modifiers {:modifiers modifiers :ignore-snap-pixel true})))))) (defn flip-vertical-selected [] (ptk/reify ::flip-vertical-selected @@ -983,4 +983,4 @@ selrect (gsh/shapes->rect shapes) center (grc/rect->center selrect) modifiers (dwm/create-modif-tree selected (ctm/resize-modifiers (gpt/point 1.0 -1.0) center))] - (rx/of (dwm/apply-modifiers {:modifiers modifiers})))))) + (rx/of (dwm/apply-modifiers {:modifiers modifiers :ignore-snap-pixel true})))))) From ef0abc14980a92083748ec7ce1063a9bb0f52f1d Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 26 Mar 2024 17:02:03 +0100 Subject: [PATCH 7/9] :bug: Fix problem with rulers in Firefox --- .../app/main/ui/workspace/viewport/rulers.cljs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/viewport/rulers.cljs b/frontend/src/app/main/ui/workspace/viewport/rulers.cljs index ff9624638..423701445 100644 --- a/frontend/src/app/main/ui/workspace/viewport/rulers.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/rulers.cljs @@ -101,13 +101,13 @@ rulers-size (* rulers-size zoom-inverse)] (if (= axis :x) {:text-x val - :text-y (+ (:y vbox) (- rulers-pos (* 4 zoom-inverse))) + :text-y (+ (:y vbox) rulers-pos (* -1 zoom-inverse)) :line-x1 val :line-y1 (+ (:y vbox) rulers-pos (* 2 zoom-inverse)) :line-x2 val :line-y2 (+ (:y vbox) rulers-pos (* 2 zoom-inverse) rulers-size)} - {:text-x (+ (:x vbox) (- rulers-pos (* 4 zoom-inverse))) + {:text-x (+ (:x vbox) rulers-pos (* -1 zoom-inverse)) :text-y val :line-x1 (+ (:x vbox) rulers-pos (* 2 zoom-inverse)) :line-y1 val @@ -171,7 +171,6 @@ [:text {:x text-x :y text-y :text-anchor "middle" - :dominant-baseline "middle" :transform (when (= axis :y) (str "rotate(-90 " text-x "," text-y ")")) :style {:font-size (* font-size zoom-inverse) :font-family font-family @@ -250,18 +249,16 @@ :fill-opacity selection-area-opacity}}] [:text {:x (- (:x1 selection-rect) (* 4 zoom-inverse)) - :y (+ (:y vbox) (* 10.6 zoom-inverse)) + :y (+ (:y vbox) (* 13.6 zoom-inverse)) :text-anchor "end" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} (fmt/format-number (- (:x1 selection-rect) offset-x))] [:text {:x (+ (:x2 selection-rect) (* 4 zoom-inverse)) - :y (+ (:y vbox) (* 10.6 zoom-inverse)) + :y (+ (:y vbox) (* 13.6 zoom-inverse)) :text-anchor "start" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} @@ -293,18 +290,16 @@ :fill-opacity over-number-opacity}}] [:text {:x (- center-x (/ (:height selection-rect) 2) (* 15 zoom-inverse)) - :y center-y + :y (+ center-y (* 4 zoom-inverse)) :text-anchor "end" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} (fmt/format-number (- (:y2 selection-rect) offset-y))] [:text {:x (+ center-x (/ (:height selection-rect) 2)) - :y center-y + :y (+ center-y (* 4 zoom-inverse)) :text-anchor "start" - :dominant-baseline "middle" :style {:font-size (* font-size zoom-inverse) :font-family font-family :fill selection-area-color}} From 4ef7af104da264956a631d3c825314a114d2fc4c Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 27 Mar 2024 08:41:43 +0100 Subject: [PATCH 8/9] :bug: Fix problem with show guides config --- frontend/src/app/main/ui/workspace/viewport.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 2a808e627..8539def89 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -553,7 +553,7 @@ :offset-y offset-y :show-rulers? show-rulers?}]) - (when show-rulers? + (when (and show-rulers? show-grids?) [:& guides/viewport-guides {:zoom zoom :vbox vbox From 7fa026da1563d8c8e17f9b2ea341e687e859aa82 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 27 Mar 2024 11:08:59 +0100 Subject: [PATCH 9/9] :bug: Fix issue on frontend build script --- frontend/scripts/build | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/scripts/build b/frontend/scripts/build index 4254b5e22..2b462db6a 100755 --- a/frontend/scripts/build +++ b/frontend/scripts/build @@ -20,6 +20,7 @@ rm -rf target/dist; clojure -M:dev:shadow-cljs release main --config-merge "{:release-version \"${CURRENT_HASH}\"}" $EXTRA_PARAMS || exit 1 yarn run compile || exit 1; +mkdir -p target/dist; rsync -avr resources/public/ target/dist/ sed -i -re "s/\%version\%/$CURRENT_VERSION/g" ./target/dist/index.html;