mirror of
https://github.com/penpot/penpot.git
synced 2025-06-15 02:41:39 +02:00
🐛 Fixes after review
This commit is contained in:
parent
dfc9d0709d
commit
a82bcd0ab2
9 changed files with 30 additions and 32 deletions
|
@ -512,10 +512,11 @@
|
|||
|
||||
id-duplicated (first new-selected)]
|
||||
|
||||
;; Warning: This order is important for the focus mode.
|
||||
(rx/merge
|
||||
(rx/concat
|
||||
(->> (rx/from dup-frames)
|
||||
(rx/map (fn [[old-id new-id]] (dwt/duplicate-thumbnail old-id new-id))))
|
||||
|
||||
;; Warning: This order is important for the focus mode.
|
||||
(rx/of (dch/commit-changes changes)
|
||||
(select-shapes new-selected)
|
||||
(memorize-duplicated id-original id-duplicated))))))))))
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.data.workspace.thumbnails
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -49,17 +50,15 @@
|
|||
;; the 2 second debounce is finished
|
||||
(rx/merge
|
||||
(->> stream
|
||||
(rx/take-until stopper)
|
||||
(rx/filter (ptk/type? ::update-thumbnail))
|
||||
(rx/filter #(= id (:id (deref %))))
|
||||
(rx/map deref)
|
||||
(rx/filter #(= id (:id %)))
|
||||
(rx/debounce 2000)
|
||||
(rx/first)
|
||||
(rx/flat-map
|
||||
(fn [event]
|
||||
(let [data (:data @event)]
|
||||
(rp/mutation! :upsert-file-object-thumbnail (assoc params :data data)))))
|
||||
|
||||
(rx/map #(fn [state] (d/dissoc-in state [::update-thumbnail-lock id]))))
|
||||
(rx/take 1)
|
||||
(rx/map :data)
|
||||
(rx/flat-map #(rp/mutation! :upsert-file-object-thumbnail (assoc params :data %)))
|
||||
(rx/map #(fn [state] (d/dissoc-in state [::update-thumbnail-lock id])))
|
||||
(rx/take-until stopper))
|
||||
|
||||
(->> (rx/of (update-thumbnail id data))
|
||||
(rx/observe-on :async)))))))))
|
||||
|
@ -98,9 +97,7 @@
|
|||
(fn [id]
|
||||
(let [shape (or (get new-objects id)
|
||||
(get old-objects id))]
|
||||
|
||||
(or (and (= :frame (:type shape)) id)
|
||||
(:frame-id shape))))
|
||||
(or (and (cph/frame-shape? shape) id) (:frame-id shape))))
|
||||
|
||||
;; Extracts the frames and then removes nils and the root frame
|
||||
xform (comp (mapcat extract-ids)
|
||||
|
@ -151,17 +148,17 @@
|
|||
|
||||
;; Async so we wait for additional side-effects of commit-changes
|
||||
(rx/observe-on :async)
|
||||
(rx/filter (comp not thumbnail-change?))
|
||||
(rx/filter (complement thumbnail-change?))
|
||||
(rx/with-latest-from objects-stream)
|
||||
(rx/map extract-frame-changes)
|
||||
(rx/share))]
|
||||
|
||||
(->> frame-changes
|
||||
(rx/take-until stopper)
|
||||
(rx/flat-map
|
||||
(fn [ids]
|
||||
(->> (rx/from ids)
|
||||
(rx/map #(ptk/data-event ::force-render %))))))))))
|
||||
(rx/map #(ptk/data-event ::force-render %)))))
|
||||
(rx/take-until stopper))))))
|
||||
|
||||
(defn duplicate-thumbnail
|
||||
[old-id new-id]
|
||||
|
|
|
@ -396,7 +396,7 @@
|
|||
st/state))
|
||||
|
||||
(def thumbnail-data
|
||||
(l/derived #(get-in % [:workspace-file :thumbnails] {}) st/state))
|
||||
(l/derived #(dm/get-in % [:workspace-file :thumbnails] {}) st/state))
|
||||
|
||||
(defn thumbnail-frame-data
|
||||
[frame-id]
|
||||
|
|
|
@ -402,7 +402,7 @@
|
|||
:style {:-webkit-print-color-adjust :exact}
|
||||
:fill "none"}
|
||||
|
||||
(let [fonts (ff/frame->fonts obj-id objects)]
|
||||
(let [fonts (ff/frame->fonts object-id objects)]
|
||||
[:& ff/fontfaces-style {:fonts fonts}])
|
||||
|
||||
(case (:type object)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.geom.shapes.text :as gst]
|
||||
[app.main.ui.context :as muc]
|
||||
[cuerdas.core :as str]
|
||||
[rumext.alpha :as mf]))
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
(obj/set! "style" style))))
|
||||
|
||||
(defn translate-shape [attrs shape]
|
||||
(let [transform (str (usvg/svg-transform-matrix shape)
|
||||
(let [transform (dm/str (usvg/svg-transform-matrix shape)
|
||||
" "
|
||||
(:transform attrs ""))]
|
||||
(cond-> attrs
|
||||
|
@ -60,7 +60,7 @@
|
|||
(obj/set! "preserveAspectRatio" "none"))]
|
||||
|
||||
[:& (mf/provider svg-ids-ctx) {:value ids-mapping}
|
||||
[:g.svg-raw {:transform (str (gsh/transform-matrix shape))}
|
||||
[:g.svg-raw {:transform (dm/str (gsh/transform-matrix shape))}
|
||||
[:> "svg" attrs children]]]))
|
||||
|
||||
(mf/defc svg-element
|
||||
|
|
|
@ -76,15 +76,15 @@
|
|||
(defn frame->fonts
|
||||
[frame objects]
|
||||
(->> (cph/get-children objects (:id frame))
|
||||
(filterv cph/text-shape?)
|
||||
(mapv (comp fonts/get-content-fonts :content))
|
||||
(filter cph/text-shape?)
|
||||
(map (comp fonts/get-content-fonts :content))
|
||||
(reduce set/union #{})))
|
||||
|
||||
(defn shapes->fonts
|
||||
[shapes]
|
||||
(->> shapes
|
||||
(filterv cph/text-shape?)
|
||||
(mapv (comp fonts/get-content-fonts :content))
|
||||
(filter cph/text-shape?)
|
||||
(map (comp fonts/get-content-fonts :content))
|
||||
(reduce set/union #{})))
|
||||
|
||||
(mf/defc fontfaces-style
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.workspace.shapes.frame
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.main.data.workspace.thumbnails :as dwt]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
|
@ -35,9 +36,9 @@
|
|||
childs (mf/deref childs-ref)]
|
||||
|
||||
[:& (mf/provider embed/context) {:value true}
|
||||
[:> shape-container #js {:shape shape :ref ref}
|
||||
[:& shape-container {:shape shape :ref ref}
|
||||
[:& ff/fontfaces-style {:fonts fonts}]
|
||||
[:> frame-shape {:shape shape :childs childs} ]]]))))
|
||||
[:& frame-shape {:shape shape :childs childs} ]]]))))
|
||||
|
||||
(defn check-props
|
||||
[new-props old-props]
|
||||
|
@ -80,7 +81,7 @@
|
|||
modifiers-ref (mf/use-memo (mf/deps frame-id) #(refs/workspace-modifiers-by-frame-id frame-id))
|
||||
modifiers (mf/deref modifiers-ref)
|
||||
|
||||
disable-thumbnail? (d/not-empty? (get-in modifiers [(:id shape) :modifiers]))
|
||||
disable-thumbnail? (d/not-empty? (dm/get-in modifiers [(:id shape) :modifiers]))
|
||||
|
||||
[on-load-frame-dom thumb-renderer]
|
||||
(ftr/use-render-thumbnail shape node-ref rendered? thumbnail? disable-thumbnail?)
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
#{:app.main.data.workspace.notifications/handle-pointer-update
|
||||
:app.main.data.workspace.selection/change-hover-state})
|
||||
|
||||
(defonce ^:dynamic *debug* (atom #{#_:events :thumbnails}))
|
||||
(defonce ^:dynamic *debug* (atom #{#_:events}))
|
||||
|
||||
(defn debug-all! [] (reset! *debug* debug-options))
|
||||
(defn debug-none! [] (reset! *debug* #{}))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue