mirror of
https://github.com/penpot/penpot.git
synced 2025-06-14 02:11:38 +02:00
🎉 Update font and variant on change (#6220)
This commit is contained in:
parent
2e3ed0c23f
commit
5937ed57ce
1 changed files with 45 additions and 40 deletions
|
@ -9,6 +9,7 @@
|
||||||
[app.common.transit :as t]
|
[app.common.transit :as t]
|
||||||
[app.common.types.shape :as shape]
|
[app.common.types.shape :as shape]
|
||||||
[app.render-wasm.api :as api]
|
[app.render-wasm.api :as api]
|
||||||
|
[beicon.v2.core :as rx]
|
||||||
[clojure.core :as c]
|
[clojure.core :as c]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
|
@ -110,49 +111,53 @@
|
||||||
[self k v]
|
[self k v]
|
||||||
(when ^boolean shape/*wasm-sync*
|
(when ^boolean shape/*wasm-sync*
|
||||||
(api/use-shape (:id self))
|
(api/use-shape (:id self))
|
||||||
(case k
|
(let [pending (case k
|
||||||
:parent-id (api/set-parent-id v)
|
:parent-id (api/set-parent-id v)
|
||||||
:type (api/set-shape-type v)
|
:type (api/set-shape-type v)
|
||||||
:bool-type (api/set-shape-bool-type v)
|
:bool-type (api/set-shape-bool-type v)
|
||||||
:selrect (api/set-shape-selrect v)
|
:selrect (api/set-shape-selrect v)
|
||||||
:show-content (if (= (:type self) :frame)
|
:show-content (if (= (:type self) :frame)
|
||||||
(api/set-shape-clip-content (not v))
|
(api/set-shape-clip-content (not v))
|
||||||
(api/set-shape-clip-content false))
|
(api/set-shape-clip-content false))
|
||||||
:rotation (api/set-shape-rotation v)
|
:rotation (api/set-shape-rotation v)
|
||||||
:transform (api/set-shape-transform v)
|
:transform (api/set-shape-transform v)
|
||||||
:fills (into [] (api/set-shape-fills v))
|
:fills (into [] (api/set-shape-fills v))
|
||||||
:strokes (into [] (api/set-shape-strokes v))
|
:strokes (into [] (api/set-shape-strokes v))
|
||||||
:blend-mode (api/set-shape-blend-mode v)
|
:blend-mode (api/set-shape-blend-mode v)
|
||||||
:opacity (api/set-shape-opacity v)
|
:opacity (api/set-shape-opacity v)
|
||||||
:hidden (api/set-shape-hidden v)
|
:hidden (api/set-shape-hidden v)
|
||||||
:shapes (api/set-shape-children v)
|
:shapes (api/set-shape-children v)
|
||||||
:blur (api/set-shape-blur v)
|
:blur (api/set-shape-blur v)
|
||||||
:shadow (api/set-shape-shadows v)
|
:shadow (api/set-shape-shadows v)
|
||||||
:constraints-h (api/set-constraints-h v)
|
:constraints-h (api/set-constraints-h v)
|
||||||
:constraints-v (api/set-constraints-v v)
|
:constraints-v (api/set-constraints-v v)
|
||||||
|
:svg-attrs (when (= (:type self) :path)
|
||||||
|
(api/set-shape-path-attrs v))
|
||||||
|
:masked-group (when (and (= (:type self) :group) (:masked-group self))
|
||||||
|
(api/set-masked (:masked-group self)))
|
||||||
|
:content (cond
|
||||||
|
(= (:type self) :path)
|
||||||
|
(api/set-shape-path-content v)
|
||||||
|
|
||||||
:svg-attrs (when (= (:type self) :path)
|
(= (:type self) :svg-raw)
|
||||||
(api/set-shape-path-attrs v))
|
(api/set-shape-svg-raw-content (api/get-static-markup self))
|
||||||
:masked-group (when (and (= (:type self) :group) (:masked-group self))
|
|
||||||
(api/set-masked (:masked-group self)))
|
|
||||||
:content (cond
|
|
||||||
(= (:type self) :path)
|
|
||||||
(api/set-shape-path-content v)
|
|
||||||
|
|
||||||
(= (:type self) :svg-raw)
|
(= (:type self) :text)
|
||||||
(api/set-shape-svg-raw-content (api/get-static-markup self))
|
(api/set-shape-text-content v))
|
||||||
|
nil)]
|
||||||
(= (:type self) :text)
|
|
||||||
(into [] (api/set-shape-text-content v)))
|
|
||||||
nil)
|
|
||||||
;; when something synced with wasm
|
|
||||||
;; is modified, we need to request
|
|
||||||
;; a new render.
|
|
||||||
;; TODO: set-wasm-attrs is called twice with every set
|
|
||||||
;; (println "set-wasm-attrs" (:id self) k v)
|
|
||||||
(api/update-shape-tiles)
|
|
||||||
(api/request-render "set-wasm-attrs")))
|
|
||||||
|
|
||||||
|
;; TODO: set-wasm-attrs is called twice with every set
|
||||||
|
(if (and pending (seq pending))
|
||||||
|
(->> (rx/from pending)
|
||||||
|
(rx/mapcat identity)
|
||||||
|
(rx/reduce conj [])
|
||||||
|
(rx/subs! (fn [_]
|
||||||
|
(api/update-shape-tiles)
|
||||||
|
(api/clear-drawing-cache)
|
||||||
|
(api/request-render "set-wasm-attrs-pending"))))
|
||||||
|
(do
|
||||||
|
(api/update-shape-tiles)
|
||||||
|
(api/request-render "set-wasm-attrs"))))))
|
||||||
(defn- impl-assoc
|
(defn- impl-assoc
|
||||||
[self k v]
|
[self k v]
|
||||||
(set-wasm-attrs self k v)
|
(set-wasm-attrs self k v)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue