mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 15:15:16 +02:00
Merge pull request #6714 from penpot/niwinz-staging-fix-path-edition
🐛 Fix unexpected exception on selectiong node on non path shape
This commit is contained in:
commit
2a5b087aa4
2 changed files with 20 additions and 17 deletions
|
@ -470,6 +470,8 @@
|
|||
"Given a content and a set of points return all the segments in the path
|
||||
that uses the points"
|
||||
[content points]
|
||||
(assert (impl/path-data? content) "expected path data instance")
|
||||
|
||||
(let [point-set (set points)]
|
||||
(loop [result (transient [])
|
||||
prev-point nil
|
||||
|
|
|
@ -46,24 +46,25 @@
|
|||
(i/icon-xref :snap-nodes (stl/css :snap-nodes-icon :pathbar-icon)))
|
||||
|
||||
(defn check-enabled [content selected-points]
|
||||
(let [segments (path.segm/get-segments-with-points content selected-points)
|
||||
num-segments (count segments)
|
||||
num-points (count selected-points)
|
||||
points-selected? (seq selected-points)
|
||||
segments-selected? (seq segments)
|
||||
;; max segments for n points is (n × (n -1)) / 2
|
||||
max-segments (-> num-points
|
||||
(* (- num-points 1))
|
||||
(/ 2))
|
||||
is-curve? (some #(path.segm/is-curve? content %) selected-points)]
|
||||
(when content
|
||||
(let [segments (path.segm/get-segments-with-points content selected-points)
|
||||
num-segments (count segments)
|
||||
num-points (count selected-points)
|
||||
points-selected? (seq selected-points)
|
||||
segments-selected? (seq segments)
|
||||
;; max segments for n points is (n × (n -1)) / 2
|
||||
max-segments (-> num-points
|
||||
(* (- num-points 1))
|
||||
(/ 2))
|
||||
is-curve? (some #(path.segm/is-curve? content %) selected-points)]
|
||||
|
||||
{:make-corner (and points-selected? is-curve?)
|
||||
:make-curve (and points-selected? (not is-curve?))
|
||||
:add-node segments-selected?
|
||||
:remove-node points-selected?
|
||||
:merge-nodes segments-selected?
|
||||
:join-nodes (and points-selected? (>= num-points 2) (< num-segments max-segments))
|
||||
:separate-nodes segments-selected?}))
|
||||
{:make-corner (and points-selected? is-curve?)
|
||||
:make-curve (and points-selected? (not is-curve?))
|
||||
:add-node segments-selected?
|
||||
:remove-node points-selected?
|
||||
:merge-nodes segments-selected?
|
||||
:join-nodes (and points-selected? (>= num-points 2) (< num-segments max-segments))
|
||||
:separate-nodes segments-selected?})))
|
||||
|
||||
(mf/defc path-actions*
|
||||
[{:keys [shape edit-path]}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue