diff --git a/frontend/text-editor/src/editor/content/dom/Content.js b/frontend/text-editor/src/editor/content/dom/Content.js index 1b2ca84edd..9f3ed49ffc 100644 --- a/frontend/text-editor/src/editor/content/dom/Content.js +++ b/frontend/text-editor/src/editor/content/dom/Content.js @@ -73,10 +73,11 @@ export function mapContentFragmentFromDocument(document, root, styleDefaults) { currentParagraph = createParagraph(undefined, currentStyle); } } - const inline = createInline(new Text(currentNode.nodeValue), currentStyle); const fontSize = inline.style.getPropertyValue("font-size"); if (!fontSize) console.warn("font-size", fontSize); + const fontFamily = inline.style.getPropertyValue("font-family"); + if (!fontFamily) console.warn("font-family", fontFamily); currentParagraph.appendChild(inline); currentNode = nodeIterator.nextNode(); diff --git a/frontend/text-editor/src/editor/content/dom/Style.js b/frontend/text-editor/src/editor/content/dom/Style.js index b7abe2f8b2..d194a13363 100644 --- a/frontend/text-editor/src/editor/content/dom/Style.js +++ b/frontend/text-editor/src/editor/content/dom/Style.js @@ -23,7 +23,8 @@ export function mergeStyleDeclarations(target, source) { // for (const styleName of source) { for (let index = 0; index < source.length; index++) { const styleName = source.item(index); - target.setProperty(styleName, source.getPropertyValue(styleName)); + const styleValue = source.getPropertyValue(styleName); + target.setProperty(styleName, styleValue); } return target } @@ -108,9 +109,10 @@ export function getComputedStyle(element) { inertElement.style.setProperty(styleName, newValue); } } else { + const newValue = currentElement.style.getPropertyValue(styleName); inertElement.style.setProperty( styleName, - currentElement.style.getPropertyValue(styleName) + newValue ); } } @@ -130,9 +132,10 @@ export function getComputedStyle(element) { * @returns {CSSStyleDeclaration} */ export function normalizeStyles(node, styleDefaults = getStyleDefaultsDeclaration()) { + const computedStyle = getComputedStyle(node.parentElement); const styleDeclaration = mergeStyleDeclarations( styleDefaults, - getComputedStyle(node.parentElement) + computedStyle ); // If there's a color property, we should convert it to @@ -149,7 +152,7 @@ export function normalizeStyles(node, styleDefaults = getStyleDefaultsDeclaratio // If there's a font-family property and not a --font-id, then // we remove the font-family because it will not work. const fontFamily = styleDeclaration.getPropertyValue("font-family"); - const fontId = styleDeclaration.getPropertyPriority("--font-id"); + const fontId = styleDeclaration.getPropertyValue("--font-id"); if (fontFamily && !fontId) { styleDeclaration.removeProperty("font-family"); }