mirror of
https://github.com/penpot/penpot.git
synced 2026-05-30 04:08:08 +00:00
Merge pull request #9814 from penpot/hiru-fix-detach-token-typ
🐛 Fix changed font size when editing a text with no changes
This commit is contained in:
commit
eb095169b8
@ -8,6 +8,7 @@
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.types.text :as txt]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.text.content.styles :as styles]))
|
||||
|
||||
(defn is-text-node
|
||||
@ -60,7 +61,15 @@
|
||||
|
||||
(defn get-paragraph-styles
|
||||
[element]
|
||||
(get-attrs-from-styles element (d/concat-set txt/paragraph-attrs txt/text-node-attrs) (d/merge txt/default-paragraph-attrs txt/default-text-attrs)))
|
||||
(let [styles (get-attrs-from-styles element
|
||||
(d/concat-set txt/paragraph-attrs txt/text-node-attrs)
|
||||
(d/merge txt/default-paragraph-attrs txt/default-text-attrs))
|
||||
;; Recover real font-size from data attribute, which to_dom/get-paragraph-styles may have
|
||||
;; changed to "0" ("0" trick to avoid it interfering with height calculation in the browser).
|
||||
saved-font-size (dom/get-data element "saved-font-size")]
|
||||
(cond-> styles
|
||||
(some? saved-font-size)
|
||||
(assoc :font-size saved-font-size))))
|
||||
|
||||
(defn get-root-styles
|
||||
[element]
|
||||
|
||||
@ -133,7 +133,11 @@
|
||||
(create-element
|
||||
"div"
|
||||
{:id (or (:key paragraph) (create-random-key))
|
||||
:data {:itype "paragraph"}
|
||||
:data {:itype "paragraph"
|
||||
;; Save the real font size to be restored later in from-dom/get-paragraph-styles,
|
||||
;; because the function get-paragraph-styles here sets it to "0" in the css properties,
|
||||
;; to avoid the browser affecting the height calculation.
|
||||
:saved-font-size (:font-size paragraph)}
|
||||
:style (get-paragraph-styles paragraph)}
|
||||
(mapv #(create-text-span % paragraph) (:children paragraph))))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user