From c0c6735e61c034524d5e541adef7bece684e936a Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 4 Mar 2025 23:35:06 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14231 --- app/src/protyle/toolbar/Font.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts index 99b520b66..a8efc3a0d 100644 --- a/app/src/protyle/toolbar/Font.ts +++ b/app/src/protyle/toolbar/Font.ts @@ -96,7 +96,7 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[]) => { lastColorHTML += ""; } let textElement: HTMLElement; - let fontSize = "16px"; + let fontSize = window.siyuan.config.editor.fontSize + "px"; if (nodeElements && nodeElements.length > 0) { textElement = nodeElements[0] as HTMLElement; } else { @@ -106,7 +106,7 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[]) => { } } if (textElement) { - fontSize = textElement.style.fontSize || "16px"; + fontSize = textElement.style.fontSize || window.siyuan.config.editor.fontSize + "px"; } element.innerHTML = `${lastColorHTML}
@@ -143,7 +143,7 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[]) => { ${window.siyuan.languages.fontSize} @@ -198,13 +198,15 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[]) => { fontSizePXElement.parentElement.classList.add("fn__none"); fontSizeEMElement.parentElement.classList.remove("fn__none"); + fontEvent(protyle, nodeElements, "fontSize", fontSizeEMElement.value + "em"); } else { - const px = Math.round(parseInt(fontSizeEMElement.value) * 16); + const px = Math.round(parseFloat(fontSizeEMElement.value) * 16); fontSizePXElement.parentElement.setAttribute("aria-label", px + "px"); fontSizePXElement.value = px.toString(); fontSizePXElement.parentElement.classList.remove("fn__none"); fontSizeEMElement.parentElement.classList.add("fn__none"); + fontEvent(protyle, nodeElements, "fontSize", fontSizePXElement.value + "px"); } }); fontSizePXElement.addEventListener("change", function () {