mirror of https://github.com/penpot/penpot.git
🐛 Fix previous styles lost when changing selected text
This commit is contained in:
parent
919f78daeb
commit
7819e6c440
|
|
@ -23,7 +23,7 @@
|
||||||
- Fix wrong board size presets in Android [Taiga #12339](https://tree.taiga.io/project/penpot/issue/12339)
|
- Fix wrong board size presets in Android [Taiga #12339](https://tree.taiga.io/project/penpot/issue/12339)
|
||||||
- Fix problem with grid layout components and auto sizing [Github #7797](https://github.com/penpot/penpot/issues/7797)
|
- Fix problem with grid layout components and auto sizing [Github #7797](https://github.com/penpot/penpot/issues/7797)
|
||||||
- Fix some alignments on inspect tab [Taiga #12915](https://tree.taiga.io/project/penpot/issue/12915)
|
- Fix some alignments on inspect tab [Taiga #12915](https://tree.taiga.io/project/penpot/issue/12915)
|
||||||
|
- Fix problem with text editor maintaining previous styles [Taiga #12835](https://tree.taiga.io/project/penpot/issue/12835)
|
||||||
|
|
||||||
## 2.12.1
|
## 2.12.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,22 +276,29 @@ 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);
|
||||||
// FIXME: I don't like this approximation. Having to iterate nodes twice
|
if (startNode === endNode) {
|
||||||
// is bad for performance. I think we need another way of "computing"
|
const paragraph = startNode.parentElement.parentElement;
|
||||||
// the cascade.
|
|
||||||
for (const textNode of this.#textNodeIterator.iterateFrom(
|
|
||||||
startNode,
|
|
||||||
endNode,
|
|
||||||
)) {
|
|
||||||
const paragraph = textNode.parentElement.parentElement;
|
|
||||||
this.#applyStylesFromElementToCurrentStyle(paragraph);
|
this.#applyStylesFromElementToCurrentStyle(paragraph);
|
||||||
}
|
const textSpan = startNode.parentElement;
|
||||||
for (const textNode of this.#textNodeIterator.iterateFrom(
|
this.#applyStylesFromElementToCurrentStyle(textSpan);
|
||||||
startNode,
|
} else {
|
||||||
endNode,
|
// FIXME: I don't like this approximation. Having to iterate nodes twice
|
||||||
)) {
|
// is bad for performance. I think we need another way of "computing"
|
||||||
const textSpan = textNode.parentElement;
|
// the cascade.
|
||||||
this.#mergeStylesFromElementToCurrentStyle(textSpan);
|
for (const textNode of this.#textNodeIterator.iterateFrom(
|
||||||
|
startNode,
|
||||||
|
endNode,
|
||||||
|
)) {
|
||||||
|
const paragraph = textNode.parentElement.parentElement;
|
||||||
|
this.#applyStylesFromElementToCurrentStyle(paragraph);
|
||||||
|
}
|
||||||
|
for (const textNode of this.#textNodeIterator.iterateFrom(
|
||||||
|
startNode,
|
||||||
|
endNode,
|
||||||
|
)) {
|
||||||
|
const textSpan = textNode.parentElement;
|
||||||
|
this.#mergeStylesFromElementToCurrentStyle(textSpan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue