From 713aba12e2ecd7f34dece034d178ed39338e2d13 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 26 Sep 2023 12:43:13 +0800 Subject: [PATCH] :art: font size --- app/src/assets/scss/component/_chip.scss | 1 - .../assets/scss/component/_typography.scss | 4 ++-- app/src/mobile/util/keyboardToolbar.ts | 18 +++++++++++---- app/src/protyle/render/highlightRender.ts | 2 ++ app/src/protyle/toolbar/Font.ts | 23 +++++++++++++++---- app/src/util/assets.ts | 3 --- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/app/src/assets/scss/component/_chip.scss b/app/src/assets/scss/component/_chip.scss index 5925d251f..94e395f9c 100644 --- a/app/src/assets/scss/component/_chip.scss +++ b/app/src/assets/scss/component/_chip.scss @@ -34,7 +34,6 @@ &--small { padding: 0 8px; font-size: 12px; - line-height: 16px; } &--secondary { diff --git a/app/src/assets/scss/component/_typography.scss b/app/src/assets/scss/component/_typography.scss index 11a3786f5..487783ab5 100644 --- a/app/src/assets/scss/component/_typography.scss +++ b/app/src/assets/scss/component/_typography.scss @@ -297,7 +297,7 @@ .hljs { border-radius: var(--b3-border-radius); - padding: 22px 4px; + padding: 1.6em 4px; font-size: 85%; overflow: auto; font-family: var(--b3-font-family-code); @@ -548,7 +548,7 @@ font-size: 85%; line-height: 1.625; background-color: var(--b3-theme-surface); - padding: 22px 4px; + padding: 1.6em 4px; box-sizing: border-box; border-radius: var(--b3-border-radius) 0 0 var(--b3-border-radius); width: 3.6em; diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts index d4a29684a..43eeaad3b 100644 --- a/app/src/mobile/util/keyboardToolbar.ts +++ b/app/src/mobile/util/keyboardToolbar.ts @@ -49,6 +49,15 @@ export const renderTextMenu = (protyle: IProtyle, toolbarElement: Element) => { `; }); + const nodeElements = getFontNodeElements(protyle); + let disableFont = false; + nodeElements?.find((item: HTMLElement) => { + if (item.classList.contains("list") || item.classList.contains("li")) { + disableFont = true; + return true; + } + }); + let lastColorHTML = ""; const lastFonts = window.siyuan.storage[Constants.LOCAL_FONTSTYLES]; if (lastFonts.length > 0) { @@ -82,9 +91,11 @@ export const renderTextMenu = (protyle: IProtyle, toolbarElement: Element) => { `; break; case "fontSize": - lastColorHTML += ``; + } break; case "style1": lastColorHTML += ` -
${window.siyuan.languages.fontSize}
-
+
${window.siyuan.languages.fontSize}
+
@@ -221,6 +231,9 @@ export const fontEvent = (protyle: IProtyle, nodeElements: Element[], type?: str } else if (type === "fontSize") { e.style.fontSize = color; } + if ((type === "fontSize" || type === "clear") && e.getAttribute("data-type") === "NodeCodeBlock") { + lineNumberRender(e.querySelector(".hljs")); + } }); focusByRange(protyle.toolbar.range); } else { diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts index 75de48aa3..634747519 100644 --- a/app/src/util/assets.ts +++ b/app/src/util/assets.ts @@ -199,7 +199,6 @@ export const addGA = () => { export const setInlineStyle = (set = true) => { const height = Math.floor(window.siyuan.config.editor.fontSize * 1.625); - // .protyle-wysiwyg .hljs.protyle-linenumber 的设置是由于 lineNumberRender 中 clientHeight 总是取的整数 let style = `.b3-typography, .protyle-wysiwyg, .protyle-title {font-size:${window.siyuan.config.editor.fontSize}px !important} .b3-typography code:not(.hljs), .protyle-wysiwyg span[data-type~=code] { font-variant-ligatures: ${window.siyuan.config.editor.codeLigatures ? "normal" : "none"} } .li > .protyle-action {height:${height + 8}px;line-height: ${height + 8}px} @@ -210,8 +209,6 @@ export const setInlineStyle = (set = true) => { .protyle-wysiwyg [data-node-id] [spellcheck] {min-height:${height}px;} .protyle-wysiwyg [data-node-id] {${window.siyuan.config.editor.rtl ? " direction: rtl;" : ""}${window.siyuan.config.editor.justify ? " text-align: justify;" : ""}} .protyle-wysiwyg .li {min-height:${height + 8}px} -.protyle-wysiwyg .hljs.protyle-linenumber {line-height: ${(height * 0.85).toFixed(0)}px} -.protyle-wysiwyg .av__calc {line-height: ${height}px} .protyle-gutters button svg {height:${height}px} .protyle-wysiwyg img.emoji, .b3-typography img.emoji {width:${height - 8}px} .protyle-wysiwyg .h1 img.emoji, .b3-typography h1 img.emoji {width:${Math.floor(window.siyuan.config.editor.fontSize * 1.75 * 1.25)}px}