mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix applyStylesTo entire selection
This commit is contained in:
@@ -339,14 +339,15 @@ export function setStylesFromObject(element, allowedStyles, styleObject) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let styleValue = styleObject[styleName];
|
let styleValue = styleObject[styleName];
|
||||||
|
if (!styleValue)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (styleName === "font-family") {
|
if (styleName === "font-family") {
|
||||||
styleValue = sanitizeFontFamily(styleValue);
|
styleValue = sanitizeFontFamily(styleValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (styleValue) {
|
|
||||||
setStyle(element, styleName, styleValue, styleUnit);
|
setStyle(element, styleName, styleValue, styleUnit);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1974,7 +1974,7 @@ export class SelectionController extends EventTarget {
|
|||||||
// the styles are applied to the current caret
|
// the styles are applied to the current caret
|
||||||
else if (
|
else if (
|
||||||
this.startOffset === this.endOffset &&
|
this.startOffset === this.endOffset &&
|
||||||
this.endOffset === endNode.nodeValue.length
|
this.endOffset === endNode.nodeValue?.length
|
||||||
) {
|
) {
|
||||||
const newTextSpan = createVoidTextSpan(newStyles);
|
const newTextSpan = createVoidTextSpan(newStyles);
|
||||||
this.endTextSpan.after(newTextSpan);
|
this.endTextSpan.after(newTextSpan);
|
||||||
@@ -2026,14 +2026,14 @@ export class SelectionController extends EventTarget {
|
|||||||
(this.#textNodeIterator.currentNode !== startNode &&
|
(this.#textNodeIterator.currentNode !== startNode &&
|
||||||
this.#textNodeIterator.currentNode !== endNode) ||
|
this.#textNodeIterator.currentNode !== endNode) ||
|
||||||
(this.#textNodeIterator.currentNode === endNode &&
|
(this.#textNodeIterator.currentNode === endNode &&
|
||||||
endOffset === endNode.nodeValue.length)
|
endOffset === endNode.nodeValue?.length)
|
||||||
) {
|
) {
|
||||||
setTextSpanStyles(textSpan, newStyles);
|
setTextSpanStyles(textSpan, newStyles);
|
||||||
|
|
||||||
// If we're at end node
|
// If we're at end node
|
||||||
} else if (
|
} else if (
|
||||||
this.#textNodeIterator.currentNode === endNode &&
|
this.#textNodeIterator.currentNode === endNode &&
|
||||||
endOffset < endNode.nodeValue.length &&
|
endOffset < endNode.nodeValue?.length &&
|
||||||
endOffset > 0
|
endOffset > 0
|
||||||
) {
|
) {
|
||||||
const newTextSpan = splitTextSpan(textSpan, endOffset);
|
const newTextSpan = splitTextSpan(textSpan, endOffset);
|
||||||
|
|||||||
Reference in New Issue
Block a user