🐛 Fix problems with empty paths and shortcuts

This commit is contained in:
alonso.torres 2021-05-07 13:05:45 +02:00 committed by Andrey Antukh
parent 5e0101e424
commit 3bb3fcfbda
3 changed files with 64 additions and 62 deletions

View file

@ -14,6 +14,7 @@
- Fix problem with `close-path` command [#917](https://github.com/penpot/penpot/issues/917)
- Fix wrong query for obtain the profile default project-id
- Fix problems with empty paths and shortcuts [#923](https://github.com/penpot/penpot/issues/923)
## 1.5.1-alpha

View file

@ -30,14 +30,16 @@
id (st/get-path-id state)
page-id (:current-page-id state)
shape (get-in state (st/get-path state))
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
points (or points selected-points)
new-content (-> (tool-fn (:content shape) points)
points (or points selected-points)]
(when-not (empty? points)
(let [new-content (-> (tool-fn (:content shape) points)
(ups/close-subpaths))
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
(rx/of (dch/commit-changes rch uch {:commit-local? true})
(when (empty? new-content)
dwc/clear-edition-mode)))))))
dwc/clear-edition-mode)))))))))
(defn make-corner
([]

View file

@ -8,14 +8,10 @@
(:require
[app.common.data :as d]
[app.common.geom.point :as gpt]
[app.common.geom.shapes.path :as gshp]
[app.util.svg :as usvg]
[cuerdas.core :as str]
[clojure.set :as set]
[app.common.math :as mth]
[app.util.path.commands :as upc]
[app.util.path.geom :as upg]
))
[clojure.set :as set]))
(defn remove-line-curves
"Remove all curves that have both handlers in the same position that the
@ -235,6 +231,9 @@
to keep everything consistent"
[content points]
(if (empty? points)
content
(let [content (d/with-prev content)]
(loop [result []
@ -298,7 +297,7 @@
(recur result
cur-handler
(first content)
(rest content)))))))
(rest content))))))))
(defn join-nodes
"Creates new segments between points that weren't previously"