Merge pull request #4111 from penpot/alotor-bugfix-16

Alotor bugfix 16
This commit is contained in:
Alejandro 2024-02-07 13:14:05 +01:00 committed by GitHub
commit 5b2227cf4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 31 deletions

View file

@ -777,14 +777,19 @@
:add-children :add-children
(let [value (dm/get-prop operation :value) (let [value (dm/get-prop operation :value)
index (dm/get-prop operation :index)] index (dm/get-prop operation :index)
(if (some? index)
(update shape :shapes shape
(fn [shapes] (if (some? index)
(if (vector? shapes) (update shape :shapes
(d/insert-at-index shapes index value) (fn [shapes]
(d/concat-vec shapes value)))) (if (vector? shapes)
(update shape :shapes d/concat-vec value))) (d/insert-at-index shapes index value)
(d/concat-vec shapes value))))
(update shape :shapes d/concat-vec value))]
;; Remove duplication
(update shape :shapes #(into [] (apply d/ordered-set %))))
:remove-children :remove-children
(let [value (dm/get-prop operation :value)] (let [value (dm/get-prop operation :value)]

View file

@ -191,15 +191,15 @@
(mf/use-fn (mf/use-fn
(mf/deps parse-value apply-value update-input on-blur) (mf/deps parse-value apply-value update-input on-blur)
(fn [event] (fn [event]
(let [new-value (or @last-value* default)] (when (mf/ref-val dirty-ref)
(if (or nillable? new-value) (let [new-value (or @last-value* default)]
(apply-value event new-value) (if (or nillable? new-value)
(update-input new-value))) (apply-value event new-value)
(when (fn? on-blur) (update-input new-value)))
(on-blur event)))) (when (fn? on-blur)
(on-blur event)))))
handle-unmount handle-unmount (h/use-ref-callback handle-blur)
(h/use-ref-callback handle-blur)
on-click on-click
(mf/use-fn (mf/use-fn
@ -240,10 +240,7 @@
(when-let [input-node (mf/ref-val ref)] (when-let [input-node (mf/ref-val ref)]
(dom/set-value! input-node (fmt/format-number value)))) (dom/set-value! input-node (fmt/format-number value))))
(mf/with-effect [] (mf/with-effect [handle-unmount] handle-unmount)
(fn []
(when (mf/ref-val dirty-ref)
(handle-unmount))))
(mf/with-layout-effect [] (mf/with-layout-effect []
(let [keys [(events/listen globals/window "pointerdown" on-click) (let [keys [(events/listen globals/window "pointerdown" on-click)

View file

@ -90,7 +90,7 @@
attrs)) attrs))
(defn add-stroke! (defn add-stroke!
[attrs data render-id index] [attrs data render-id index open-path?]
(let [style (:stroke-style data :solid)] (let [style (:stroke-style data :solid)]
(when-not (= style :none) (when-not (= style :none)
(let [width (:stroke-width data 1) (let [width (:stroke-width data 1)
@ -122,16 +122,18 @@
(cond (cond
(and (contains? stroke-caps-line caps-start) (and (contains? stroke-caps-line caps-start)
(= caps-start caps-end) (= caps-start caps-end)
(not= :inner alignment) (or open-path?
(not= :outer alignment) (and (not= :inner alignment)
(not= :outer alignment)))
(not= :dotted style)) (not= :dotted style))
(obj/set! attrs "strokeLinecap" (name caps-start)) (obj/set! attrs "strokeLinecap" (name caps-start))
(= :dotted style) (= :dotted style)
(obj/set! attrs "strokeLinecap" "round")) (obj/set! attrs "strokeLinecap" "round"))
(when (and (not= :inner alignment) (when (or open-path?
(not= :outer alignment)) (and (not= :inner alignment)
(not= :outer alignment)))
;; For other cap types we use markers. ;; For other cap types we use markers.
(when (or (contains? stroke-caps-marker caps-start) (when (or (contains? stroke-caps-marker caps-start)

View file

@ -420,7 +420,7 @@
(mf/html [:> type props]))) (mf/html [:> type props])))
(defn- build-stroke-element (defn- build-stroke-element
[child value position render-id] [child value position render-id open-path?]
(let [props (obj/get child "props") (let [props (obj/get child "props")
type (obj/get child "type") type (obj/get child "type")
@ -428,7 +428,7 @@
(obj/clone) (obj/clone)
(obj/set! "fill" "none") (obj/set! "fill" "none")
(obj/set! "fillOpacity" "none") (obj/set! "fillOpacity" "none")
(attrs/add-stroke! value render-id position)) (attrs/add-stroke! value render-id position open-path?))
style (if (:stroke-image value) style (if (:stroke-image value)
(obj/set! style "stroke" (dm/fmt "url(#stroke-fill-%-%)" render-id position)) (obj/set! style "stroke" (dm/fmt "url(#stroke-fill-%-%)" render-id position))
@ -484,9 +484,10 @@
props (mf/spread-props svg-attrs props (mf/spread-props svg-attrs
{:id stroke-id {:id stroke-id
:className "strokes" :className "strokes"
:style style})] :style style})
open-path? (and ^boolean (cfh/path-shape? shape)
^boolean (gsh/open-path? shape))]
(when-not ^boolean (cfh/frame-shape? shape) (when-not ^boolean (cfh/frame-shape? shape)
(when (and (some? shape-blur) (when (and (some? shape-blur)
(not ^boolean (:hidden shape-blur))) (not ^boolean (:hidden shape-blur)))
@ -503,7 +504,7 @@
:stroke value :stroke value
:index index :index index
:key (dm/str index "-" stroke-id)} :key (dm/str index "-" stroke-id)}
(build-stroke-element child value index render-id)])]))) (build-stroke-element child value index render-id open-path?)])])))
(mf/defc shape-custom-strokes (mf/defc shape-custom-strokes
{::mf/wrap-props false} {::mf/wrap-props false}

View file

@ -112,7 +112,7 @@
(fn [color] (fn [color]
(st/emit! (dch/update-shapes (st/emit! (dch/update-shapes
ids ids
#(assoc-in % [:shadow index :color] color))))) #(assoc-in % [:shadow index :color] (d/without-nils color))))))
detach-color detach-color
(mf/use-fn (mf/use-fn