From 619b557c80e90109cec4ddbd11f85a01c95490c5 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 15 Feb 2024 16:39:09 +0100 Subject: [PATCH 1/4] :bug: Fix anonymous access to shared prototypes --- backend/src/app/rpc/commands/files.clj | 1 + frontend/src/app/main/data/viewer.cljs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 3f7313291..38aba8f30 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -351,6 +351,7 @@ (sv/defmethod ::get-file-fragment "Retrieve a file fragment by its ID. Only authenticated users." {::doc/added "1.17" + ::rpc/auth false ::sm/params schema:get-file-fragment ::sm/result schema:file-fragment} [{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id file-id fragment-id share-id]}] diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index af8401d8a..a698e567c 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -74,9 +74,11 @@ (assoc-in [:viewer-local :interactions-show?] interactions-show?))) ptk/WatchEvent - (watch [_ _ _] + (watch [_ state _] (rx/of (fetch-bundle (d/without-nils params)) - (fetch-comment-threads params))) + ;; Only fetch threads for logged-in users + (when (some? (:profile state)) + (fetch-comment-threads params)))) ptk/EffectEvent (effect [_ _ _] From 74e57c00af0d3481ee070e1bdf3f7903725ce142 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 15 Feb 2024 17:16:59 +0100 Subject: [PATCH 2/4] :bug: Fix create interactions with nested frames --- frontend/src/app/main/data/workspace/interactions.cljs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/workspace/interactions.cljs b/frontend/src/app/main/data/workspace/interactions.cljs index a8e2fe284..2bdc9f2e1 100644 --- a/frontend/src/app/main/data/workspace/interactions.cljs +++ b/frontend/src/app/main/data/workspace/interactions.cljs @@ -208,7 +208,10 @@ from-frame-id (if (cfh/frame-shape? from-shape) from-id (:frame-id from-shape)) - target-frame (ctst/get-frame-by-position objects position)] + target-frame + (->> (ctst/get-frames-by-position objects position) + (remove :hide-in-viewer) + (last))] (when (and (not= (:id target-frame) uuid/zero) (not= (:id target-frame) from-frame-id)) From 4c81ac43862c34431df336039e4c08ea81a81d9c Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 16 Feb 2024 09:43:38 +0100 Subject: [PATCH 3/4] :bug: Fix problem with strokes exporting images --- common/src/app/common/geom/shapes/bounds.cljc | 81 ++++++++++--------- frontend/src/app/main/render.cljs | 2 +- .../src/app/main/ui/shapes/custom_stroke.cljs | 5 +- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/common/src/app/common/geom/shapes/bounds.cljc b/common/src/app/common/geom/shapes/bounds.cljc index c60840d7a..854d24440 100644 --- a/common/src/app/common/geom/shapes/bounds.cljc +++ b/common/src/app/common/geom/shapes/bounds.cljc @@ -15,8 +15,8 @@ (defn shape-stroke-margin [shape stroke-width] (if (cfh/path-shape? shape) - ;; TODO: Calculate with the stroke offset (not implemented yet - (mth/sqrt (* 2 stroke-width stroke-width)) + ;; TODO: Calculate with the stroke offset (not implemented yet) + (+ stroke-width (mth/sqrt (* 2 stroke-width stroke-width))) (- (mth/sqrt (* 2 stroke-width stroke-width)) stroke-width))) (defn- apply-filters @@ -104,7 +104,7 @@ 0)) (reduce d/max 0)) - margin + stroke-margin (if ignore-margin? 0 (shape-stroke-margin shape stroke-width)) @@ -124,9 +124,8 @@ :drop-shadow (+ (mth/abs (:offset-y %)) (* (:spread %) 2) (* (:blur %) 2) 10) 0)) (reduce d/max 0))] - - {:horizontal (mth/ceil (+ stroke-width margin shadow-width)) - :vertical (mth/ceil (+ stroke-width margin shadow-height))}))) + {:horizontal (mth/ceil (+ stroke-margin shadow-width)) + :vertical (mth/ceil (+ stroke-margin shadow-height))}))) (defn- add-padding [bounds padding] @@ -143,47 +142,51 @@ (update :height + (* 2 v-padding))))) (defn calculate-base-bounds - [shape] - (-> (get-shape-filter-bounds shape) - (add-padding (calculate-padding shape true)))) + ([shape] + (calculate-base-bounds shape true)) + ([shape ignore-margin?] + (-> (get-shape-filter-bounds shape) + (add-padding (calculate-padding shape ignore-margin?))))) (defn get-object-bounds - [objects shape] - (let [base-bounds (calculate-base-bounds shape) - bounds - (cond - (or (empty? (:shapes shape)) - (or (:masked-group shape) (= :bool (:type shape))) - (and (cfh/frame-shape? shape) (not (:show-content shape)))) - [base-bounds] + ([objects shape] + (get-object-bounds objects shape nil)) + ([objects shape {:keys [ignore-margin?] :or {ignore-margin? true}}] + (let [base-bounds (calculate-base-bounds shape ignore-margin?) + bounds + (cond + (or (empty? (:shapes shape)) + (or (:masked-group shape) (= :bool (:type shape))) + (and (cfh/frame-shape? shape) (not (:show-content shape)))) + [base-bounds] - :else - (cfh/reduce-objects - objects + :else + (cfh/reduce-objects + objects - (fn [shape] - (and (not (:hidden shape)) - (d/not-empty? (:shapes shape)) - (or (not (cfh/frame-shape? shape)) - (:show-content shape)) + (fn [shape] + (and (not (:hidden shape)) + (d/not-empty? (:shapes shape)) + (or (not (cfh/frame-shape? shape)) + (:show-content shape)) - (or (not (cfh/group-shape? shape)) - (not (:masked-group shape))))) - (:id shape) + (or (not (cfh/group-shape? shape)) + (not (:masked-group shape))))) + (:id shape) - (fn [result child] - (cond-> result - (not (:hidden child)) - (conj (calculate-base-bounds child)))) + (fn [result child] + (cond-> result + (not (:hidden child)) + (conj (calculate-base-bounds child)))) - [base-bounds])) + [base-bounds])) - children-bounds - (cond->> (grc/join-rects bounds) - (not (cfh/frame-shape? shape)) (or (:children-bounds shape))) + children-bounds + (cond->> (grc/join-rects bounds) + (not (cfh/frame-shape? shape)) (or (:children-bounds shape))) - filters (shape->filters shape) - blur-value (or (-> shape :blur :value) 0)] + filters (shape->filters shape) + blur-value (or (-> shape :blur :value) 0)] - (get-rect-filter-bounds children-bounds filters blur-value))) + (get-rect-filter-bounds children-bounds filters blur-value)))) diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 0a19c8a84..be312cae2 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -449,7 +449,7 @@ (assoc :fills [])) - {:keys [width height] :as bounds} (gsb/get-object-bounds objects object) + {:keys [width height] :as bounds} (gsb/get-object-bounds objects object {:ignore-margin? false}) vbox (format-viewbox bounds) fonts (ff/shape->fonts object objects) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 6366c42e0..fa27d4e52 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -13,6 +13,7 @@ [app.common.geom.shapes :as gsh] [app.common.geom.shapes.bounds :as gsb] [app.common.geom.shapes.text :as gst] + [app.common.math :as mth] [app.config :as cf] [app.main.ui.context :as muc] [app.main.ui.shapes.attrs :as attrs] @@ -47,7 +48,7 @@ :center (/ (:stroke-width stroke 0) 2) :outer (:stroke-width stroke 0) 0) - margin (gsb/shape-stroke-margin stroke stroke-width) + stroke-margin (gsb/shape-stroke-margin shape stroke-width) ;; NOTE: for performance reasons we may can delimit a bit the ;; dependencies to really useful shape attrs instead of using @@ -57,8 +58,6 @@ (gst/shape->rect shape) (grc/points->rect (:points shape)))) - stroke-margin (+ stroke-width margin) - x (- (dm/get-prop selrect :x) stroke-margin) y (- (dm/get-prop selrect :y) stroke-margin) w (+ (dm/get-prop selrect :width) (* 2 stroke-margin)) From 330c0ac9f900b6513d0eeac00833d3d8582a7e9e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 16 Feb 2024 13:32:32 +0100 Subject: [PATCH 4/4] :bug: Fix problem with text proportion lock --- common/src/app/common/geom/proportions.cljc | 2 +- frontend/src/app/main/ui/shapes/custom_stroke.cljs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/app/common/geom/proportions.cljc b/common/src/app/common/geom/proportions.cljc index d6f37c216..7afaeef4d 100644 --- a/common/src/app/common/geom/proportions.cljc +++ b/common/src/app/common/geom/proportions.cljc @@ -40,6 +40,6 @@ (cond (= type :svg-raw) (setup-proportions-size shape) (= type :image) (setup-proportions-image shape) - image-fill? (setup-proportions-size shape) (= type :text) shape + image-fill? (setup-proportions-size shape) :else (setup-proportions-const shape)))) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index fa27d4e52..e855405a1 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -13,7 +13,6 @@ [app.common.geom.shapes :as gsh] [app.common.geom.shapes.bounds :as gsb] [app.common.geom.shapes.text :as gst] - [app.common.math :as mth] [app.config :as cf] [app.main.ui.context :as muc] [app.main.ui.shapes.attrs :as attrs]