diff --git a/app/appearance/langs/ar_SA.json b/app/appearance/langs/ar_SA.json index 41aa9f00d..e6bc87694 100644 --- a/app/appearance/langs/ar_SA.json +++ b/app/appearance/langs/ar_SA.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "نظام الملفات المحلي", + "relativeFontSize": "نسبة إلى حجم خط المحرر", + "localFileSystem": "نظام الملفات المحلي", "deviceNotSupport": "الجهاز الحالي غير مدعوم", "second": "ثانية", "syncInterval": "الفاصل الزمني للمزامنة", diff --git a/app/appearance/langs/de_DE.json b/app/appearance/langs/de_DE.json index 06ac37618..7a51382ad 100644 --- a/app/appearance/langs/de_DE.json +++ b/app/appearance/langs/de_DE.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "Lokales Dateisystem", + "relativeFontSize": "relativ zur Schriftgröße des Editors", + "localFileSystem": "Lokales Dateisystem", "deviceNotSupport": "Das aktuelle Gerät wird nicht unterstützt", "second": "Sekunde", "syncInterval": "Synchronisierungsintervall", diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index e590fb984..1b6bb1ee8 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "Local file system", + "relativeFontSize": "relative to the editor font size", + "localFileSystem": "Local file system", "deviceNotSupport": "The current device is not supported", "second": "second", "syncInterval": "sync interval", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 9a780e633..c54924536 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "Sistema de archivos local", + "relativeFontSize": "en relación con el tamaño de fuente del editor", + "localFileSystem": "Sistema de archivos local", "deviceNotSupport": "El dispositivo actual no es compatible", "second": "segundo", "syncInterval": "intervalo de sincronización", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index 2b0dfe72e..cf41af87c 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "Système de fichiers local", + "relativeFontSize": "par rapport à la taille de la police de l'éditeur", + "localFileSystem": "Système de fichiers local", "deviceNotSupport": "L'appareil actuel n'est pas pris en charge", "second": "seconde", "syncInterval": "intervalle de synchronisation", diff --git a/app/appearance/langs/he_IL.json b/app/appearance/langs/he_IL.json index 96d1ebd34..e9e26088a 100644 --- a/app/appearance/langs/he_IL.json +++ b/app/appearance/langs/he_IL.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "מערכת קבצים מקומית", + "relativeFontSize": "יחסית לגודל הגופן של העורך", + "localFileSystem": "מערכת קבצים מקומית", "deviceNotSupport": "המכשיר הנוכחי אינו נתמך", "second": "שנייה", "syncInterval": "מרווח סנכרון", diff --git a/app/appearance/langs/it_IT.json b/app/appearance/langs/it_IT.json index c6f74dffa..335e479e6 100644 --- a/app/appearance/langs/it_IT.json +++ b/app/appearance/langs/it_IT.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "File system locale", + "relativeFontSize": "rispetto alla dimensione del carattere dell'editor", + "localFileSystem": "File system locale", "deviceNotSupport": "Il dispositivo corrente non è supportato", "second": "secondo", "syncInterval": "intervallo di sincronizzazione", diff --git a/app/appearance/langs/ja_JP.json b/app/appearance/langs/ja_JP.json index d901f9c05..6ca317880 100644 --- a/app/appearance/langs/ja_JP.json +++ b/app/appearance/langs/ja_JP.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "ローカルファイルシステム", + "relativeFontSize": "エディターのフォントサイズに対して", + "localFileSystem": "ローカルファイルシステム", "deviceNotSupport": "現在のデバイスはサポートされていません", "second": "秒", "syncInterval": "同期間隔", diff --git a/app/appearance/langs/pl_PL.json b/app/appearance/langs/pl_PL.json index 3d562a440..ede2cc960 100644 --- a/app/appearance/langs/pl_PL.json +++ b/app/appearance/langs/pl_PL.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "Lokalny system plików", + "relativeFontSize": "względem rozmiaru czcionki edytora", + "localFileSystem": "Lokalny system plików", "deviceNotSupport": "Bieżące urządzenie nie jest obsługiwane", "second": "sekunda", "syncInterval": "interwał synchronizacji", diff --git a/app/appearance/langs/ru_RU.json b/app/appearance/langs/ru_RU.json index 92e48f232..0442ca3e7 100644 --- a/app/appearance/langs/ru_RU.json +++ b/app/appearance/langs/ru_RU.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "Локальная файловая система", + "relativeFontSize": "относительно размера шрифта редактора", + "localFileSystem": "Локальная файловая система", "deviceNotSupport": "Текущее устройство не поддерживается", "second": "секунда", "syncInterval": "интервал синхронизации", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 6e8b72524..ad985c40f 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "本地檔案系統", + "relativeFontSize": "相對於編輯器字號", + "localFileSystem": "本地檔案系統", "deviceNotSupport": "當前設備不支援", "second": "秒", "syncInterval": "同步間隔", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index bca23a354..06f22ea3a 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1,5 +1,6 @@ { - "localFlieSystem": "本地文件系统", + "relativeFontSize": "相对于编辑器字号", + "localFileSystem": "本地文件系统", "deviceNotSupport": "当前设备不支持", "second": "秒", "syncInterval": "同步间隔", diff --git a/app/src/config/repos.ts b/app/src/config/repos.ts index 9a8dc1176..006ba109a 100644 --- a/app/src/config/repos.ts +++ b/app/src/config/repos.ts @@ -424,7 +424,7 @@ export const repos = { - +
diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts index 3e8060f76..99b520b66 100644 --- a/app/src/protyle/toolbar/Font.ts +++ b/app/src/protyle/toolbar/Font.ts @@ -139,25 +139,23 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[]) => {
-
${window.siyuan.languages.fontSize}
-
-
- -
+ ${window.siyuan.languages.fontSize} + + +
+
+
+
+ +
+
+ +
@@ -188,8 +186,38 @@ export const appearanceMenu = (protyle: IProtyle, nodeElements?: Element[]) => { target = target.parentElement; } }); - element.querySelector("select").addEventListener("change", function (event: Event) { - fontEvent(protyle, nodeElements, "fontSize", (event.target as HTMLSelectElement).value); + const switchElement = element.querySelector(".b3-switch") as HTMLInputElement; + const fontSizePXElement = element.querySelector("#fontSizePX") as HTMLInputElement; + const fontSizeEMElement = element.querySelector("#fontSizeEM") as HTMLInputElement; + switchElement.addEventListener("change", function () { + if (switchElement.checked) { + // px -> em + const em = parseFloat((parseInt(fontSizePXElement.value) / 16).toFixed(2)); + fontSizeEMElement.parentElement.setAttribute("aria-label", (em * 100).toString() + "%"); + fontSizeEMElement.value = em.toString(); + + fontSizePXElement.parentElement.classList.add("fn__none"); + fontSizeEMElement.parentElement.classList.remove("fn__none"); + } else { + const px = Math.round(parseInt(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"); + } + }); + fontSizePXElement.addEventListener("change", function () { + fontEvent(protyle, nodeElements, "fontSize", fontSizePXElement.value + "px"); + }); + fontSizeEMElement.addEventListener("change", function () { + fontEvent(protyle, nodeElements, "fontSize", fontSizeEMElement.value + "em"); + }); + fontSizePXElement.addEventListener("input", function () { + fontSizePXElement.parentElement.setAttribute("aria-label", fontSizePXElement.value + "px"); + }); + fontSizeEMElement.addEventListener("input", function () { + fontSizeEMElement.parentElement.setAttribute("aria-label", (parseFloat(fontSizeEMElement.value) * 100).toFixed(0) + "%") }); return element; };