From 68eadcb24fca1abe4dbbe5893452926c7daf2017 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 26 Mar 2021 10:37:19 +0100 Subject: [PATCH 1/4] :bug: Fix text selection in comments --- CHANGES.md | 1 + frontend/resources/styles/main/partials/comments.scss | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 20f76d437..c44241f99 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -53,6 +53,7 @@ - Updates worksans font [#744](https://github.com/penpot/penpot/issues/744) - Fix problem with team management in dashboard [Taiga #1475](https://tree.taiga.io/project/penpot/issue/1475) - Fix problem with blending modes in masks [Taiga #1476](https://tree.taiga.io/project/penpot/issue/1476) +- Fix text selection in comments [#745](https://github.com/penpot/penpot/issues/745) ### :arrow_up: Deps updates diff --git a/frontend/resources/styles/main/partials/comments.scss b/frontend/resources/styles/main/partials/comments.scss index 216de4c2a..cc6248efa 100644 --- a/frontend/resources/styles/main/partials/comments.scss +++ b/frontend/resources/styles/main/partials/comments.scss @@ -42,6 +42,7 @@ border-radius: 2px; min-width: 280px; max-width: 280px; + user-select: text; .comments { max-height: 420px; From 20e4562c0905f7e94e3de6059a0320d5fd1f3ba2 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 26 Mar 2021 10:41:27 +0100 Subject: [PATCH 2/4] :bug: Fixed some issues when shift-selecting on sidebars --- common/app/common/pages/helpers.cljc | 22 ++++++++++--------- frontend/src/app/main/data/workspace.cljs | 3 ++- .../app/main/ui/workspace/shapes/outline.cljs | 4 ++-- .../src/app/main/ui/workspace/viewport.cljs | 3 ++- .../main/ui/workspace/viewport/selection.cljs | 8 ++++++- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/common/app/common/pages/helpers.cljc b/common/app/common/pages/helpers.cljc index d47a38383..2a5ba99aa 100644 --- a/common/app/common/pages/helpers.cljc +++ b/common/app/common/pages/helpers.cljc @@ -187,16 +187,18 @@ (defn clean-loops "Clean a list of ids from circular references." [objects ids] - (loop [ids ids - id (first ids) - others (rest ids)] - (if-not id - ids - (recur (cond-> ids - (some #(contains? ids %) (get-parents id objects)) - (disj id)) - (first others) - (rest others))))) + (let [parent-selected? + (fn [id] + (let [parents (get-parents id objects)] + (some ids parents))) + + add-element + (fn [result id] + (cond-> result + (not (parent-selected? id)) + (conj id)))] + + (reduce add-element (d/ordered-set) ids))) (defn calculate-invalid-targets [shape-id objects] diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 61b51eebb..b29c43bd0 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1352,7 +1352,8 @@ ptk/WatchEvent (watch [_ state stream] (let [objects (dwc/lookup-page-objects state) - selected (get-in state [:workspace-local :selected]) + selected (->> (get-in state [:workspace-local :selected]) + (cp/clean-loops objects)) pdata (reduce (partial collect-object-ids objects) {} selected) initial {:type :copied-shapes :file-id (:current-file-id state) diff --git a/frontend/src/app/main/ui/workspace/shapes/outline.cljs b/frontend/src/app/main/ui/workspace/shapes/outline.cljs index 13ad2d5a6..58b8b7d56 100644 --- a/frontend/src/app/main/ui/workspace/shapes/outline.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/outline.cljs @@ -20,8 +20,8 @@ (mf/defc outline {::mf/wrap-props false} [props] - (let [zoom (mf/deref refs/selected-zoom) - shape (unchecked-get props "shape") + (let [shape (unchecked-get props "shape") + zoom (unchecked-get props "zoom") color (unchecked-get props "color") transform (gsh/transform-matrix shape) path? (= :path (:type shape)) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 04849970d..3962ae83a 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -202,7 +202,8 @@ :selected selected :hover (when (not= :frame (:type @hover)) #{(or @frame-hover (:id @hover))}) - :edition edition}]) + :edition edition + :zoom zoom}]) (when show-selection-handlers? [:& selection/selection-handlers diff --git a/frontend/src/app/main/ui/workspace/viewport/selection.cljs b/frontend/src/app/main/ui/workspace/viewport/selection.cljs index 16b5edfbb..d9a5a2522 100644 --- a/frontend/src/app/main/ui/workspace/viewport/selection.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/selection.cljs @@ -296,7 +296,13 @@ (mf/defc multiple-selection-handlers [{:keys [shapes selected zoom color show-distances disable-handlers on-move-selected] :as props}] - (let [shape (geom/setup {:type :rect} (geom/selection-rect (->> shapes (map geom/transform-shape)))) + (let [shape (mf/use-memo + (mf/deps shapes) + #(->> shapes + (map geom/transform-shape) + (geom/selection-rect) + (geom/setup {:type :rect}))) + shape-center (geom/center-shape shape) hover-id (-> (mf/deref refs/current-hover) first) From a2d8518724f41d014ae03d8c05c5dea72b2e7827 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 26 Mar 2021 10:50:52 +0100 Subject: [PATCH 3/4] :recycle: Moved outlines to viewport namespace --- .../src/app/main/ui/workspace/viewport.cljs | 3 +- .../ui/workspace/viewport/interactions.cljs | 5 +- .../{shapes => viewport}/outline.cljs | 53 ++++++++++++++++--- .../main/ui/workspace/viewport/selection.cljs | 2 +- .../main/ui/workspace/viewport/widgets.cljs | 30 +---------- 5 files changed, 54 insertions(+), 39 deletions(-) rename frontend/src/app/main/ui/workspace/{shapes => viewport}/outline.cljs (51%) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 3962ae83a..7e7ac7332 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -22,6 +22,7 @@ [app.main.ui.workspace.viewport.gradients :as gradients] [app.main.ui.workspace.viewport.hooks :as hooks] [app.main.ui.workspace.viewport.interactions :as interactions] + [app.main.ui.workspace.viewport.outline :as outline] [app.main.ui.workspace.viewport.pixel-overlay :as pixel-overlay] [app.main.ui.workspace.viewport.presence :as presence] [app.main.ui.workspace.viewport.selection :as selection] @@ -197,7 +198,7 @@ [:g {:style {:pointer-events (if disable-events? "none" "auto")}} (when show-outlines? - [:& widgets/shape-outlines + [:& outline/shape-outlines {:objects objects :selected selected :hover (when (not= :frame (:type @hover)) diff --git a/frontend/src/app/main/ui/workspace/viewport/interactions.cljs b/frontend/src/app/main/ui/workspace/viewport/interactions.cljs index 50df4ea07..c77f315da 100644 --- a/frontend/src/app/main/ui/workspace/viewport/interactions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/interactions.cljs @@ -15,12 +15,13 @@ [app.main.data.workspace :as dw] [app.main.refs :as refs] [app.main.store :as st] - [app.main.ui.workspace.shapes.outline :refer [outline]] + [app.main.ui.workspace.viewport.outline :refer [outline]] [app.util.data :as dt] [app.util.dom :as dom] [app.util.keyboard :as kbd] [cuerdas.core :as str] - [rumext.alpha :as mf])) + [rumext.alpha :as mf] + )) (defn- get-click-interaction [shape] diff --git a/frontend/src/app/main/ui/workspace/shapes/outline.cljs b/frontend/src/app/main/ui/workspace/viewport/outline.cljs similarity index 51% rename from frontend/src/app/main/ui/workspace/shapes/outline.cljs rename to frontend/src/app/main/ui/workspace/viewport/outline.cljs index 58b8b7d56..dcffdc669 100644 --- a/frontend/src/app/main/ui/workspace/shapes/outline.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/outline.cljs @@ -7,15 +7,16 @@ ;; ;; Copyright (c) 2020 UXBOX Labs SL -(ns app.main.ui.workspace.shapes.outline +(ns app.main.ui.workspace.viewport.outline (:require - [rumext.alpha :as mf] [app.common.geom.shapes :as gsh] - [app.util.object :as obj] - [rumext.util :refer [map->obj]] + [app.common.pages :as cp] [app.main.refs :as refs] - [app.util.geom.path :as ugp])) - + [app.util.geom.path :as ugp] + [app.util.object :as obj] + [clojure.set :as set] + [rumext.alpha :as mf] + [rumext.util :refer [map->obj]])) (mf/defc outline {::mf/wrap-props false} @@ -60,3 +61,43 @@ :height height})] [:> outline-type (map->obj (merge common props))])) + +(mf/defc shape-outlines-render + {::mf/wrap-props false + ::mf/wrap [#(mf/memo' % (mf/check-props ["shapes" "zoom"]))]} + [props] + (let [shapes (obj/get props "shapes") + zoom (obj/get props "zoom") + color (if (or (> (count shapes) 1) (nil? (:shape-ref (first shapes)))) + "#31EFB8" "#00E0FF")] + (for [shape shapes] + [:& outline {:key (str "outline-" (:id shape)) + :shape (gsh/transform-shape shape) + :zoom zoom + :color color}]))) + +(mf/defc shape-outlines + {::mf/wrap-props false} + [props] + (let [selected (or (obj/get props "selected") #{}) + hover (or (obj/get props "hover") #{}) + objects (obj/get props "objects") + edition (obj/get props "edition") + zoom (obj/get props "zoom") + + transform (mf/deref refs/current-transform) + + outlines-ids (->> (set/union selected hover) + (cp/clean-loops objects)) + + show-outline? (fn [shape] (and (not (:hidden shape)) + (not (:blocked shape)))) + + shapes (->> outlines-ids + (filter #(not= edition %)) + (map #(get objects %)) + (filterv show-outline?))] + + [:g.outlines {:display (when (some? transform) "none")} + [:& shape-outlines-render {:shapes shapes + :zoom zoom}]])) diff --git a/frontend/src/app/main/ui/workspace/viewport/selection.cljs b/frontend/src/app/main/ui/workspace/viewport/selection.cljs index d9a5a2522..0e2fb2033 100644 --- a/frontend/src/app/main/ui/workspace/viewport/selection.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/selection.cljs @@ -23,7 +23,7 @@ [app.main.ui.cursors :as cur] [app.main.ui.hooks :as hooks] [app.main.ui.measurements :as msr] - [app.main.ui.workspace.shapes.outline :refer [outline]] + [app.main.ui.workspace.viewport.outline :refer [outline]] [app.main.ui.workspace.shapes.path.editor :refer [path-editor]] [app.util.data :as d] [app.util.debug :refer [debug?]] diff --git a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs index 679c824f8..c60d02293 100644 --- a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs @@ -17,39 +17,11 @@ [app.main.store :as st] [app.main.streams :as ms] [app.main.ui.hooks :as hooks] - [app.main.ui.workspace.shapes.outline :refer [outline]] [app.main.ui.workspace.shapes.path.actions :refer [path-actions]] [app.util.dom :as dom] - [clojure.set :as set] + [app.util.object :as obj] [rumext.alpha :as mf])) -(mf/defc shape-outlines - {::mf/wrap-props false} - [props] - (let [objects (unchecked-get props "objects") - selected (or (unchecked-get props "selected") #{}) - hover (or (unchecked-get props "hover") #{}) - edition (unchecked-get props "edition") - outline? (set/union selected hover) - show-outline? (fn [shape] (and (not (:hidden shape)) - (not (:blocked shape)) - (not= edition (:id shape)) - (outline? (:id shape)))) - - shapes (cond->> (vals objects) - show-outline? (filter show-outline?)) - - transform (mf/deref refs/current-transform) - color (if (or (> (count shapes) 1) (nil? (:shape-ref (first shapes)))) - "#31EFB8" "#00E0FF")] - (when (nil? transform) - [:g.outlines - (for [shape shapes] - [:& outline {:key (str "outline-" (:id shape)) - :shape (gsh/transform-shape shape) - :color color}])]))) - - (mf/defc pixel-grid [{:keys [vbox zoom]}] [:g.pixel-grid From 3c2ae03ceaf08bc86871a9c856be9e51abda7b13 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 26 Mar 2021 10:52:29 +0100 Subject: [PATCH 4/4] :bug: Fix problem with blocked shapes --- CHANGES.md | 1 + frontend/src/app/worker/selection.cljs | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c44241f99..c5b86f334 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -54,6 +54,7 @@ - Fix problem with team management in dashboard [Taiga #1475](https://tree.taiga.io/project/penpot/issue/1475) - Fix problem with blending modes in masks [Taiga #1476](https://tree.taiga.io/project/penpot/issue/1476) - Fix text selection in comments [#745](https://github.com/penpot/penpot/issues/745) +- Fix problem with blocked shapes [Taiga #1480](https://tree.taiga.io/project/penpot/issue/1480) ### :arrow_up: Deps updates diff --git a/frontend/src/app/worker/selection.cljs b/frontend/src/app/worker/selection.cljs index 425ae2bd0..cba546625 100644 --- a/frontend/src/app/worker/selection.cljs +++ b/frontend/src/app/worker/selection.cljs @@ -54,6 +54,7 @@ match-criteria? (fn [shape] (and (not (:hidden shape)) + (not (:blocked shape)) (or (not frame-id) (= frame-id (:frame-id shape))) (case (:type shape) :frame include-frames?