mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix paste RTF crashes text editor (#7196)
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
- Fix consistency issues on how font variants are visualized [Taiga #11499](https://tree.taiga.io/project/penpot/us/11499)
|
- Fix consistency issues on how font variants are visualized [Taiga #11499](https://tree.taiga.io/project/penpot/us/11499)
|
||||||
- Fix parsing rx and ry SVG values for rect radius [Taiga #11861](https://tree.taiga.io/project/penpot/issue/11861)
|
- Fix parsing rx and ry SVG values for rect radius [Taiga #11861](https://tree.taiga.io/project/penpot/issue/11861)
|
||||||
- Misleading affordance in saved versions [Taiga #11887](https://tree.taiga.io/project/penpot/issue/11887)
|
- Misleading affordance in saved versions [Taiga #11887](https://tree.taiga.io/project/penpot/issue/11887)
|
||||||
|
- Fix pasting RTF text crashes penpot [Taiga #11717](https://tree.taiga.io/project/penpot/issue/11717)
|
||||||
|
|
||||||
## 2.9.0
|
## 2.9.0
|
||||||
|
|
||||||
|
|||||||
@@ -517,8 +517,8 @@ export class TextEditor extends EventTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createRootFromHTML(html, style) {
|
export function createRootFromHTML(html, style = undefined) {
|
||||||
const fragment = mapContentFragmentFromHTML(html, style);
|
const fragment = mapContentFragmentFromHTML(html, style || undefined);
|
||||||
const root = createRoot([], style);
|
const root = createRoot([], style);
|
||||||
root.replaceChildren(fragment);
|
root.replaceChildren(fragment);
|
||||||
resetInertElement();
|
resetInertElement();
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
import { getFills } from "./Color.js";
|
import { getFills } from "./Color.js";
|
||||||
|
|
||||||
const DEFAULT_FONT_SIZE = "16px";
|
const DEFAULT_FONT_SIZE = "16px";
|
||||||
|
const DEFAULT_FONT_SIZE_VALUE = parseFloat(DEFAULT_FONT_SIZE);
|
||||||
const DEFAULT_LINE_HEIGHT = "1.2";
|
const DEFAULT_LINE_HEIGHT = "1.2";
|
||||||
const DEFAULT_FONT_WEIGHT = "400";
|
const DEFAULT_FONT_WEIGHT = "400";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merges two style declarations. `source` -> `target`.
|
* Merges two style declarations. `source` -> `target`.
|
||||||
*
|
*
|
||||||
@@ -220,10 +222,13 @@ export function setStyle(element, styleName, styleValue, styleUnit) {
|
|||||||
*/
|
*/
|
||||||
function getStyleFontSize(styleValueAsNumber, styleValue) {
|
function getStyleFontSize(styleValueAsNumber, styleValue) {
|
||||||
if (styleValue.endsWith("pt")) {
|
if (styleValue.endsWith("pt")) {
|
||||||
return (styleValueAsNumber * 1.3333).toFixed();
|
const baseSize = 1.3333;
|
||||||
|
return (styleValueAsNumber * baseSize).toFixed();
|
||||||
} else if (styleValue.endsWith("em")) {
|
} else if (styleValue.endsWith("em")) {
|
||||||
|
const baseSize = DEFAULT_FONT_SIZE_VALUE;
|
||||||
return (styleValueAsNumber * baseSize).toFixed();
|
return (styleValueAsNumber * baseSize).toFixed();
|
||||||
} else if (styleValue.endsWith("%")) {
|
} else if (styleValue.endsWith("%")) {
|
||||||
|
const baseSize = DEFAULT_FONT_SIZE_VALUE;
|
||||||
return ((styleValueAsNumber / 100) * baseSize).toFixed();
|
return ((styleValueAsNumber / 100) * baseSize).toFixed();
|
||||||
}
|
}
|
||||||
return styleValueAsNumber.toFixed();
|
return styleValueAsNumber.toFixed();
|
||||||
|
|||||||
Reference in New Issue
Block a user