🐛 Fix previous styles lost when changing selected text

This commit is contained in:
Aitor Moreno 2026-01-07 12:18:05 +01:00 committed by Alejandro Alonso
parent 51635770ce
commit 2c9159288f
2 changed files with 23 additions and 17 deletions

View File

@ -29,7 +29,7 @@
- Fix missing text color token from selected shapes in selected colors list [Taiga #12956](https://tree.taiga.io/project/penpot/issue/12956) - Fix missing text color token from selected shapes in selected colors list [Taiga #12956](https://tree.taiga.io/project/penpot/issue/12956)
- Fix dropdown option width in Guides columns dropdown [Taiga #12959](https://tree.taiga.io/project/penpot/issue/12959) - Fix dropdown option width in Guides columns dropdown [Taiga #12959](https://tree.taiga.io/project/penpot/issue/12959)
- Fix typos on download modal [Taiga #12865](https://tree.taiga.io/project/penpot/issue/12865) - Fix typos on download modal [Taiga #12865](https://tree.taiga.io/project/penpot/issue/12865)
- Fix problem with text editor maintaining previous styles [Taiga #12835](https://tree.taiga.io/project/penpot/issue/12835)
## 2.12.1 ## 2.12.1

View File

@ -242,7 +242,6 @@ export class SelectionController extends EventTarget {
continue; continue;
} }
let styleValue = element.style.getPropertyValue(styleName); let styleValue = element.style.getPropertyValue(styleName);
if (styleName === "font-family") { if (styleName === "font-family") {
styleValue = sanitizeFontFamily(styleValue); styleValue = sanitizeFontFamily(styleValue);
} }
@ -277,6 +276,12 @@ export class SelectionController extends EventTarget {
this.#applyDefaultStylesToCurrentStyle(); this.#applyDefaultStylesToCurrentStyle();
const root = startNode.parentElement.parentElement.parentElement; const root = startNode.parentElement.parentElement.parentElement;
this.#applyStylesFromElementToCurrentStyle(root); this.#applyStylesFromElementToCurrentStyle(root);
if (startNode === endNode) {
const paragraph = startNode.parentElement.parentElement;
this.#applyStylesFromElementToCurrentStyle(paragraph);
const textSpan = startNode.parentElement;
this.#applyStylesFromElementToCurrentStyle(textSpan);
} else {
// FIXME: I don't like this approximation. Having to iterate nodes twice // FIXME: I don't like this approximation. Having to iterate nodes twice
// is bad for performance. I think we need another way of "computing" // is bad for performance. I think we need another way of "computing"
// the cascade. // the cascade.
@ -294,6 +299,7 @@ export class SelectionController extends EventTarget {
const textSpan = textNode.parentElement; const textSpan = textNode.parentElement;
this.#mergeStylesFromElementToCurrentStyle(textSpan); this.#mergeStylesFromElementToCurrentStyle(textSpan);
} }
}
return this; return this;
} }