mirror of
https://github.com/penpot/penpot.git
synced 2026-09-10 14:09:17 +00:00
🐛 Fix problem with caret color value (#9717)
This commit is contained in:
parent
8dd4b486e7
commit
a9d0feb8fd
@ -147,7 +147,13 @@
|
|||||||
|
|
||||||
on-style-change
|
on-style-change
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(let [styles (styles/get-styles-from-event event)]
|
(let [styles (styles/get-styles-from-event event)
|
||||||
|
fills (:fills styles)
|
||||||
|
fill-color (when (sequential? fills) (some :fill-color fills))]
|
||||||
|
;; Dynamically update the caret color as the cursor moves between spans
|
||||||
|
(when-let [container-node (mf/ref-val container-ref)]
|
||||||
|
(dom/set-style! container-node "--text-editor-caret-color"
|
||||||
|
(or fill-color text-color)))
|
||||||
(st/emit! (dwt/v2-update-text-editor-styles shape-id styles))))
|
(st/emit! (dwt/v2-update-text-editor-styles shape-id styles))))
|
||||||
|
|
||||||
on-needs-layout
|
on-needs-layout
|
||||||
@ -219,10 +225,18 @@
|
|||||||
(= (:vertical-align content) "bottom")]))
|
(= (:vertical-align content) "bottom")]))
|
||||||
|
|
||||||
(defn get-color-from-content [content]
|
(defn get-color-from-content [content]
|
||||||
(let [fills (->> (tree-seq map? :children content)
|
(let [nodes (tree-seq map? :children content)
|
||||||
(mapcat :fills)
|
get-color (fn [node]
|
||||||
(filter :fill-color))]
|
;; Handle both new format (:fills vector) and old/deprecated format
|
||||||
(some :fill-color fills)))
|
;; (direct :fill-color on the content node — pre-fills-refactor files)
|
||||||
|
(or (some :fill-color (:fills node))
|
||||||
|
(:fill-color node)))]
|
||||||
|
;; Prefer inline (leaf) text nodes over paragraph nodes. The paragraph's :fills
|
||||||
|
;; tracks the last-typed color, so using it directly would make the caret take
|
||||||
|
;; the last span's color rather than the first visible span's color.
|
||||||
|
;; Inline nodes have no :type; they are identified by the presence of :text.
|
||||||
|
(or (->> nodes (filter #(contains? % :text)) (some get-color))
|
||||||
|
(->> nodes (some get-color)))))
|
||||||
|
|
||||||
(defn get-default-text-color
|
(defn get-default-text-color
|
||||||
"Returns the appropriate text color based on fill, frame, and background."
|
"Returns the appropriate text color based on fill, frame, and background."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user