mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 08:51:41 +02:00
✨ Improved text selection
This commit is contained in:
parent
618d22d214
commit
bbf91a8957
6 changed files with 82 additions and 27 deletions
|
@ -82,7 +82,7 @@
|
|||
|
||||
(defn add-fill
|
||||
([attrs shape render-id]
|
||||
(add-fill attrs shape render-id 0))
|
||||
(add-fill attrs shape render-id nil))
|
||||
|
||||
([attrs shape render-id index]
|
||||
(let [fill-attrs
|
||||
|
@ -92,7 +92,7 @@
|
|||
{:fill (str/format "url(#%s)" fill-image-id)})
|
||||
|
||||
(contains? shape :fill-color-gradient)
|
||||
(let [fill-color-gradient-id (str "fill-color-gradient_" render-id "_" index)]
|
||||
(let [fill-color-gradient-id (str "fill-color-gradient_" render-id (if index (str "_" index) ""))]
|
||||
{:fill (str/format "url(#%s)" fill-color-gradient-id)})
|
||||
|
||||
(contains? shape :fill-color)
|
||||
|
|
|
@ -98,16 +98,6 @@
|
|||
(some #(cph/is-parent? objects % group-id))
|
||||
(not))))
|
||||
|
||||
(defn check-text-collision?
|
||||
"Checks if he current position `pos` overlaps any of the text-nodes for the given `text-id`"
|
||||
[objects pos text-id]
|
||||
(and (= :text (get-in objects [text-id :type]))
|
||||
(let [collisions
|
||||
(->> (dom/query-all (str "#shape-" text-id " .text-node"))
|
||||
(map dom/get-bounding-rect)
|
||||
(map dom/bounding-rect->rect))]
|
||||
(not (some #(gshr/contains-point? % pos) collisions)))))
|
||||
|
||||
(defn setup-hover-shapes [page-id move-stream raw-position-ref objects transform selected ctrl? hover hover-ids hover-disabled? zoom]
|
||||
(let [;; We use ref so we don't recreate the stream on a change
|
||||
zoom-ref (mf/use-ref zoom)
|
||||
|
@ -180,9 +170,6 @@
|
|||
|
||||
remove-xfm (mapcat #(cph/get-parent-ids objects %))
|
||||
remove-id? (cond-> (into #{} remove-xfm selected)
|
||||
:always
|
||||
(into (filter #(check-text-collision? objects (mf/ref-val raw-position-ref) %)) ids)
|
||||
|
||||
(not @ctrl?)
|
||||
(into (filter #(group-empty-space? % objects ids)) ids)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue