mirror of
https://github.com/penpot/penpot.git
synced 2025-07-21 00:27:13 +02:00
🐛 Fixed issues when asigning a color to a part of the text
This commit is contained in:
parent
6f56a19390
commit
e01e689f69
7 changed files with 45 additions and 24 deletions
|
@ -120,19 +120,19 @@
|
|||
is-text? #(= :text (:type (get objects %)))
|
||||
text-ids (filter is-text? ids)
|
||||
shape-ids (filter (comp not is-text?) ids)
|
||||
update-fn (fn [shape] (assoc shape
|
||||
:fill-color color
|
||||
:fill-opacity opacity
|
||||
:fill-color-ref-id id
|
||||
:fill-color-ref-file file-id))
|
||||
editor (get-in state [:workspace-local :editor])
|
||||
converted-attrs {:fill color}
|
||||
|
||||
attrs (cond-> {:fill-color color
|
||||
:fill-color-ref-id id
|
||||
:fill-color-ref-file file-id}
|
||||
(and opacity (not= opacity :multiple)) (assoc :fill-opacity opacity))
|
||||
|
||||
update-fn (fn [shape] (merge shape attrs))
|
||||
editors (get-in state [:workspace-local :editors])
|
||||
reduce-fn (fn [state id]
|
||||
(update-in state [:workspace-data :pages-index pid :objects id] update-fn))]
|
||||
|
||||
(rx/from (conj
|
||||
(map #(dwt/update-text-attrs {:id % :editor editor :attrs converted-attrs}) text-ids)
|
||||
(map #(dwt/update-text-attrs {:id % :editor (get editors %) :attrs attrs}) text-ids)
|
||||
(dwc/update-shapes shape-ids update-fn))))))))
|
||||
|
||||
(defn change-stroke [ids color id file-id]
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
[app.common.geom.shapes :as geom]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.util.object :as obj]
|
||||
[app.util.color :as uc]
|
||||
[app.util.text :as ut]))
|
||||
|
||||
;; --- Text Editor Rendering
|
||||
|
@ -60,13 +61,22 @@
|
|||
|
||||
font-family (obj/get data "font-family")
|
||||
font-size (obj/get data "font-size")
|
||||
|
||||
;; Old properties for backwards compatibility
|
||||
fill (obj/get data "fill")
|
||||
opacity (obj/get data "opacity")
|
||||
opacity (obj/get data "opacity" 1)
|
||||
|
||||
fill-color (obj/get data "fill-color" fill)
|
||||
fill-opacity (obj/get data "fill-opacity" opacity)
|
||||
fill-color-ref-id (obj/get data "fill-color-ref-id")
|
||||
fill-color-ref-file (obj/get data "fill-color-ref-file")
|
||||
|
||||
[r g b a] (uc/hex->rgba fill-color fill-opacity)
|
||||
|
||||
fontsdb (deref fonts/fontsdb)
|
||||
|
||||
base #js {:textDecoration text-decoration
|
||||
:color fill
|
||||
:opacity opacity
|
||||
:color (str/format "rgba(%s, %s, %s, %s)" r g b a)
|
||||
:textTransform text-transform
|
||||
:lineHeight (or line-height "inherit")}]
|
||||
|
||||
|
|
|
@ -318,7 +318,9 @@
|
|||
:min 0
|
||||
:step 0.1
|
||||
:max 1
|
||||
:value (math/precision (:alpha @current-color) 2)
|
||||
:value (if (= (:alpha @current-color) :multiple)
|
||||
""
|
||||
(math/precision (:alpha @current-color) 2))
|
||||
:on-change (fn [e]
|
||||
(let [val (-> e dom/get-target dom/get-value (math/clamp 0 1))]
|
||||
(swap! current-color assoc :alpha val)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
[app.util.text :as ut]
|
||||
[app.common.geom.shapes :as geom]
|
||||
[app.util.object :as obj]
|
||||
[app.util.color :as uc]
|
||||
[app.util.timers :as timers]
|
||||
["slate" :as slate]
|
||||
["slate-react" :as rslate])
|
||||
|
@ -141,13 +142,22 @@
|
|||
|
||||
font-family (obj/get data "font-family")
|
||||
font-size (obj/get data "font-size")
|
||||
|
||||
;; Old properties for backwards compatibility
|
||||
fill (obj/get data "fill")
|
||||
opacity (obj/get data "opacity")
|
||||
opacity (obj/get data "opacity" 1)
|
||||
|
||||
fill-color (obj/get data "fill-color" fill)
|
||||
fill-opacity (obj/get data "fill-opacity" opacity)
|
||||
fill-color-ref-id (obj/get data "fill-color-ref-id")
|
||||
fill-color-ref-file (obj/get data "fill-color-ref-file")
|
||||
|
||||
[r g b a] (uc/hex->rgba fill-color fill-opacity)
|
||||
|
||||
fontsdb (deref fonts/fontsdb)
|
||||
|
||||
base #js {:textDecoration text-decoration
|
||||
:color fill
|
||||
:opacity opacity
|
||||
:color (str/format "rgba(%s, %s, %s, %s)" r g b a)
|
||||
:textTransform text-transform
|
||||
:lineHeight (or line-height "inherit")}]
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@
|
|||
extract-fn))]
|
||||
(geom/get-attrs-multi (map mapfn shapes) (or attrs text-attrs))))
|
||||
|
||||
measure-values
|
||||
(geom/get-attrs-multi shapes measure-attrs)
|
||||
measure-values (geom/get-attrs-multi shapes measure-attrs)
|
||||
|
||||
fill-values (extract {:attrs fill-attrs
|
||||
:text-attrs ot/text-fill-attrs
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
get-color-name (fn [{:keys [id file-id]}]
|
||||
(let [src-colors (if file-id (get-in shared-libs [file-id :data :colors]) file-colors)]
|
||||
(get-in src-colors [id :name])))
|
||||
;;
|
||||
|
||||
default-color {:value "#000000" :opacity 1}
|
||||
|
||||
|
@ -120,11 +119,10 @@
|
|||
(mf/use-effect
|
||||
(mf/deps color)
|
||||
#(reset! state (parse-color color)))
|
||||
;; is this necessary?
|
||||
|
||||
[:div.row-flex.color-data
|
||||
[:span.color-th
|
||||
{:class (when (:id color) "color-name")
|
||||
{:class (when (and (:id color) (not= (:id color) :multiple)) "color-name")
|
||||
:style {:background-color (-> value value-to-background)}
|
||||
:on-click (color-picker-callback @state handle-pick-color handle-open handle-close disable-opacity)}
|
||||
(when (= value :multiple) "?")]
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
["slate" :refer [Transforms]]))
|
||||
|
||||
(def text-typography-attrs [:typography-ref-id :typography-ref-file])
|
||||
(def text-fill-attrs [:fill :opacity])
|
||||
(def text-fill-attrs [:fill-color :fill-opacity :fill-color-ref-id :fill-color-ref-file :fill :opacity ])
|
||||
(def text-font-attrs [:font-id :font-family :font-variant-id :font-size :font-weight :font-style])
|
||||
(def text-align-attrs [:text-align])
|
||||
(def text-spacing-attrs [:line-height :letter-spacing])
|
||||
|
@ -290,8 +290,10 @@
|
|||
:shape shape
|
||||
:attrs text-fill-attrs})
|
||||
|
||||
converted-fill-values {:fill-color (:fill fill-values)
|
||||
:fill-opacity (:opacity fill-values)}
|
||||
fill-values (cond-> fill-values
|
||||
;; Keep for backwards compatibility
|
||||
(:fill fill-values) (assoc :fill-color (:fill fill-values))
|
||||
(:opacity fill-values) (assoc :fill-opacity (:fill fill-values)))
|
||||
|
||||
text-values (merge
|
||||
(dwt/current-root-values
|
||||
|
@ -310,7 +312,7 @@
|
|||
:values measure-values}]
|
||||
[:& fill-menu {:ids ids
|
||||
:type type
|
||||
:values converted-fill-values
|
||||
:values fill-values
|
||||
:editor editor}]
|
||||
[:& shadow-menu {:ids ids
|
||||
:type type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue