Skip to content

Commit

Permalink
style: 改进字号 CSS 和列表项的伪元素布局 (#13959)
Browse files Browse the repository at this point in the history
* style: 添加 --b3-font-size-editor 变量

* style: 添加 --b3-font-size-editor 变量
  • Loading branch information
TCOTC authored Jan 30, 2025
1 parent beb6b80 commit 698698e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/assets/scss/component/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
font-variant-ligatures: no-common-ligatures;
display: flex;
flex-direction: column;
font-size: var(--b3-font-size-editor);
font-family: var(--b3-font-family-protyle);

img {
Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/scss/protyle/_protyle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
.protyle-title {
margin: 34px 16px 0 24px;
position: relative;
font-size: 16px;
font-size: var(--b3-font-size-editor);
font-family: var(--b3-font-family-protyle);
padding-left: 2px;
border-radius: var(--b3-border-radius);
Expand Down
8 changes: 6 additions & 2 deletions app/src/assets/scss/protyle/_wysiwyg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,18 @@
&::after {
content: "";
position: absolute;
border-radius: 50%;
top: 50%;
transition: var(--b3-transition);
left: 50%;
height: max(14px, 1em);
width: max(14px, 1em);
margin: min(-7px, -.5em) 0 0 min(-7px, -.5em);
border-radius: 50%;
transition: var(--b3-transition);
}

svg {
width: 34px;
height: max(14px, 1em - 8px);
display: block;
z-index: 1;
position: relative;
Expand Down
6 changes: 2 additions & 4 deletions app/src/util/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const loadAssets = (data: Config.IAppearance) => {
/// #if BROWSER
if (!window.webkit?.messageHandlers && !window.JSAndroid && !window.JSHarmony &&
("serviceWorker" in window.navigator) && ("caches" in window) && ("fetch" in window) && navigator.serviceWorker) {
document.head.insertAdjacentHTML("afterbegin", `<meta name="theme-color" content="${getComputedStyle(document.body).getPropertyValue("--b3-toolbar-background").trim()}">`)
document.head.insertAdjacentHTML("afterbegin", `<meta name="theme-color" content="${getComputedStyle(document.body).getPropertyValue("--b3-toolbar-background").trim()}">`);
}
/// #endif
setCodeTheme();
Expand Down Expand Up @@ -288,13 +288,11 @@ export const setInlineStyle = async (set = true) => {
}`;
}
}
style += `.b3-typography, .protyle-wysiwyg, .protyle-title {font-size:${window.siyuan.config.editor.fontSize}px !important}
style += `\n:root{--b3-font-size-editor:${window.siyuan.config.editor.fontSize}px}
.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}
.protyle-wysiwyg [data-node-id].li > .protyle-action ~ [data-type="NodeHeading"] {line-height:${height + 8}px}
.protyle-wysiwyg [data-node-id].li > .protyle-action ~ [data-type="NodeHeading"] > [spellcheck] {min-height:${height + 8}px}
.protyle-wysiwyg [data-node-id].li > .protyle-action::after {height: ${window.siyuan.config.editor.fontSize}px;width: ${window.siyuan.config.editor.fontSize}px;margin:-${window.siyuan.config.editor.fontSize / 2}px 0 0 -${window.siyuan.config.editor.fontSize / 2}px}
.protyle-wysiwyg [data-node-id].li > .protyle-action svg {height: ${Math.max(14, window.siyuan.config.editor.fontSize - 8)}px}
.protyle-wysiwyg [data-node-id].li::before {height: calc(100% - ${height + 12}px);top:${(height + 12)}px}
.protyle-wysiwyg [data-node-id]:not([data-type="NodeHeading"]) > [spellcheck] {min-height:${height}px;}
.protyle-wysiwyg .p,
Expand Down

0 comments on commit 698698e

Please sign in to comment.