Skip to content

Commit f2efa61

Browse files
authored
♻️ Improve setInlineStyle (#15193)
1 parent d76c63a commit f2efa61

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

app/src/assets/scss/protyle/_protyle.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
}
106106

107107
svg {
108-
height: 14px;
109108
color: var(--b3-theme-on-surface-light);
109+
height: calc(var(--b3-font-size-editor) * 1.625);
110110
width: 14px;
111111
float: left;
112112
transition: var(--b3-color-transition);

app/src/util/assets.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ export const initAssets = () => {
199199
};
200200

201201
export const setInlineStyle = async (set = true, servePath = "../../../") => {
202-
const height = Math.floor(window.siyuan.config.editor.fontSize * 1.625);
203202
let style;
204203
// Emojis Reset: 字体中包含了 emoji,需重置
205204
// Emojis Additional: 苹果/win11 字体中没有的 emoji
@@ -227,10 +226,9 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {
227226
local("Segoe UI Symbol");
228227
size-adjust: 115%;
229228
}`;
230-
} else {
231-
const isWin11Browser = await isWin11();
232-
if (isWin11Browser) {
233-
style = `@font-face {
229+
} else if (await isWin11()) {
230+
// Win11 Browser
231+
style = `@font-face {
234232
font-family: "Emojis Additional";
235233
src: url(${servePath}appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
236234
unicode-range: U+1fae9, U+1fac6, U+1fabe, U+1fadc, U+e50a, U+1fa89, U+1fadf, U+1f1e6-1f1ff, U+1f3f4, U+e0067, U+e0062,
@@ -251,8 +249,8 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {
251249
local("Segoe UI Symbol");
252250
size-adjust: 85%;
253251
}`;
254-
} else {
255-
style = `@font-face {
252+
} else {
253+
style = `@font-face {
256254
font-family: "Emojis Reset";
257255
src: url(${servePath}appearance/fonts/Noto-COLRv1-2.047/Noto-COLRv1.woff2) format("woff2");
258256
unicode-range: U+1f170-1f171, U+1f17e, U+1f17f, U+1f21a, U+1f22f, U+1f232-1f23a, U+1f250, U+1f251, U+1f32b, U+1f3bc,
@@ -277,11 +275,13 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {
277275
local("EmojiSymbols");
278276
size-adjust: 92%;
279277
}`;
280-
}
281278
}
282-
let rtlCSS = "";
279+
style += `\n:root{ --b3-font-size-editor: ${window.siyuan.config.editor.fontSize}px }
280+
.b3-typography code:not(.hljs), .protyle-wysiwyg span[data-type~=code] { font-variant-ligatures: ${window.siyuan.config.editor.codeLigatures ? "normal" : "none"} }
281+
${window.siyuan.config.editor.justify ? ".protyle-wysiwyg [data-node-id] { text-align: justify }" : ""}`;
283282
if (window.siyuan.config.editor.rtl) {
284-
rtlCSS = `.protyle-title__input,
283+
style += `
284+
.protyle-title__input,
285285
.protyle-wysiwyg .p,
286286
.protyle-wysiwyg .code-block .hljs,
287287
.protyle-wysiwyg .table,
@@ -305,11 +305,6 @@ export const setInlineStyle = async (set = true, servePath = "../../../") => {
305305
margin-left: auto;
306306
}`;
307307
}
308-
style += `\n:root{--b3-font-size-editor:${window.siyuan.config.editor.fontSize}px}
309-
.b3-typography code:not(.hljs), .protyle-wysiwyg span[data-type~=code] { font-variant-ligatures: ${window.siyuan.config.editor.codeLigatures ? "normal" : "none"} }
310-
${rtlCSS}
311-
.protyle-wysiwyg [data-node-id] {${window.siyuan.config.editor.justify ? " text-align: justify;" : ""}}
312-
.protyle-gutters button svg {height:${height}px}`;
313308
if (window.siyuan.config.editor.fontFamily) {
314309
style += `\n.b3-typography:not(.b3-typography--default), .protyle-wysiwyg, .protyle-title {font-family: "Emojis Additional", "Emojis Reset", "${window.siyuan.config.editor.fontFamily}", var(--b3-font-family)}`;
315310
}

0 commit comments

Comments
 (0)