Skip to content

Commit d4134d0

Browse files
committed
fix: 修复设置代码块字体无效的问题
1 parent a5f93cf commit d4134d0

5 files changed

Lines changed: 339 additions & 200 deletions

File tree

lang/index.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,5 +3678,61 @@
36783678
"ru": "",
36793679
"en": "",
36803680
"fr": ""
3681+
},
3682+
"iz5k2g5": {
3683+
"zh-cn": "搜索...",
3684+
"ja": "",
3685+
"ko": "",
3686+
"ru": "",
3687+
"en": "",
3688+
"fr": ""
3689+
},
3690+
"1li91h6": {
3691+
"zh-cn": " 无匹配项 ",
3692+
"ja": "",
3693+
"ko": "",
3694+
"ru": "",
3695+
"en": "",
3696+
"fr": ""
3697+
},
3698+
"d5bwf64": {
3699+
"zh-cn": "搜索字体",
3700+
"ja": "",
3701+
"ko": "",
3702+
"ru": "",
3703+
"en": "",
3704+
"fr": ""
3705+
},
3706+
"d7h3ol4": {
3707+
"zh-cn": "无匹配项",
3708+
"ja": "",
3709+
"ko": "",
3710+
"ru": "",
3711+
"en": "",
3712+
"fr": ""
3713+
},
3714+
"xixe9md": {
3715+
"zh-cn": "配置编辑器和代码的字体样式",
3716+
"ja": "",
3717+
"ko": "",
3718+
"ru": "",
3719+
"en": "",
3720+
"fr": ""
3721+
},
3722+
"jzo94qd": {
3723+
"zh-cn": "配置不同文本元素的字体大小",
3724+
"ja": "",
3725+
"ko": "",
3726+
"ru": "",
3727+
"en": "",
3728+
"fr": ""
3729+
},
3730+
"dyvec84": {
3731+
"zh-cn": "正文内容",
3732+
"ja": "",
3733+
"ko": "",
3734+
"ru": "",
3735+
"en": "",
3736+
"fr": ""
36813737
}
36823738
}

src/core/styles/milkup.css

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
/* 编辑器容器 */
66
.milkup-editor {
7-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
7+
font-family:
8+
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
89
font-size: 16px;
910
line-height: 1.6;
1011
color: var(--text-color, #333);
@@ -39,14 +40,14 @@
3940
.milkup-syntax-visible,
4041
.milkup-syntax {
4142
color: var(--text-color-3, #999);
42-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
43+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
4344
font-size: 0.9em;
4445
}
4546

4647
/* 语法标记 - 默认样式 */
4748
.milkup-syntax-marker {
4849
color: var(--text-color-3, #999);
49-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
50+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
5051
font-size: 0.9em;
5152
}
5253

@@ -71,8 +72,8 @@
7172
var(--hover-background-color, rgba(94, 129, 172, 0.1)) 100%
7273
);
7374
color: var(--text-color-1, #333);
74-
font-family: var(--milkup-font-code), 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo,
75-
monospace;
75+
font-family:
76+
var(--milkup-font-code), "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
7677
font-size: calc(var(--milkup-font-size-code, 16px) * 0.875);
7778
font-weight: 600;
7879
line-height: 1.2;
@@ -163,12 +164,25 @@
163164
line-height: 1.25;
164165
}
165166

166-
.milkup-editor h1 { font-size: 2em; }
167-
.milkup-editor h2 { font-size: 1.5em; }
168-
.milkup-editor h3 { font-size: 1.25em; }
169-
.milkup-editor h4 { font-size: 1em; }
170-
.milkup-editor h5 { font-size: 0.875em; }
171-
.milkup-editor h6 { font-size: 0.85em; color: var(--text-color-2, #6a737d); }
167+
.milkup-editor h1 {
168+
font-size: 2em;
169+
}
170+
.milkup-editor h2 {
171+
font-size: 1.5em;
172+
}
173+
.milkup-editor h3 {
174+
font-size: 1.25em;
175+
}
176+
.milkup-editor h4 {
177+
font-size: 1em;
178+
}
179+
.milkup-editor h5 {
180+
font-size: 0.875em;
181+
}
182+
.milkup-editor h6 {
183+
font-size: 0.85em;
184+
color: var(--text-color-2, #6a737d);
185+
}
172186

173187
/* 段落 */
174188
.milkup-editor p {
@@ -224,7 +238,10 @@
224238
color: var(--text-color-3, #999);
225239
cursor: pointer;
226240
opacity: 0;
227-
transition: opacity 0.2s, background 0.2s, color 0.2s;
241+
transition:
242+
opacity 0.2s,
243+
background 0.2s,
244+
color 0.2s;
228245
}
229246

230247
.milkup-code-block:hover .milkup-code-block-copy-btn {
@@ -263,7 +280,7 @@
263280
}
264281

265282
.milkup-custom-select-button::after {
266-
content: '';
283+
content: "";
267284
width: 0;
268285
height: 0;
269286
border-left: 4px solid transparent;
@@ -364,8 +381,15 @@
364381
}
365382

366383
.milkup-code-block-editor .cm-content {
367-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
368-
font-size: 14px;
384+
font-family: var(
385+
--milkup-font-code,
386+
"SFMono-Regular",
387+
Consolas,
388+
"Liberation Mono",
389+
Menlo,
390+
monospace
391+
) !important;
392+
font-size: var(--milkup-font-size-code, 14px) !important;
369393
color: var(--text-color, #333);
370394
}
371395

@@ -435,7 +459,7 @@
435459
}
436460

437461
.milkup-context-menu-item.has-submenu::after {
438-
content: '';
462+
content: "";
439463
width: 0;
440464
height: 0;
441465
border-top: 4px solid transparent;
@@ -490,7 +514,9 @@
490514
border-radius: 2px;
491515
background: var(--background-color-1, #fff);
492516
cursor: pointer;
493-
transition: background 0.05s ease, border-color 0.05s ease;
517+
transition:
518+
background 0.05s ease,
519+
border-color 0.05s ease;
494520
}
495521

496522
.milkup-table-grid-picker .grid-cell.active {
@@ -724,7 +750,7 @@
724750

725751
.milkup-editor .milkup-image-placeholder-src {
726752
font-size: 0.8em;
727-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
753+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
728754
word-break: break-all;
729755
max-width: 100%;
730756
opacity: 0.7;
@@ -754,7 +780,6 @@
754780
color: inherit;
755781
}
756782

757-
758783
/* 数学块预览区域 */
759784
.milkup-editor .math-block .math-preview {
760785
padding: 0.5em 0;
@@ -794,7 +819,7 @@
794819
display: inline-block;
795820
min-width: 1ch;
796821
min-height: 1.2em;
797-
font-family: KaTeX_Main, 'Times New Roman', serif;
822+
font-family: KaTeX_Main, "Times New Roman", serif;
798823
font-size: 1.21em;
799824
white-space: pre-wrap;
800825
text-align: center;
@@ -1001,7 +1026,7 @@
10011026
display: inline;
10021027
user-select: auto;
10031028
color: var(--text-color-3, #999);
1004-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
1029+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
10051030
}
10061031

10071032
/* 源码模式下隐藏数学公式渲染 widget */
@@ -1049,7 +1074,7 @@
10491074
padding-right: 8px;
10501075
text-align: right;
10511076
color: var(--text-color-3, #999) !important;
1052-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
1077+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace !important;
10531078
font-size: 14px !important;
10541079
font-weight: normal !important;
10551080
font-style: normal !important;
@@ -1061,8 +1086,14 @@
10611086
}
10621087

10631088
/* 列表项内段落的行号 - 补偿列表标记宽度 */
1064-
.milkup-editor.source-view .milkup-list-item.source-view .milkup-list-item-content > .milkup-list-line-number::before,
1065-
.milkup-editor.source-view .milkup-task-item.source-view .milkup-list-item-content > .milkup-list-line-number::before {
1089+
.milkup-editor.source-view
1090+
.milkup-list-item.source-view
1091+
.milkup-list-item-content
1092+
> .milkup-list-line-number::before,
1093+
.milkup-editor.source-view
1094+
.milkup-task-item.source-view
1095+
.milkup-list-item-content
1096+
> .milkup-list-line-number::before {
10661097
left: calc(-60px - var(--marker-width, 20px));
10671098
}
10681099

@@ -1071,7 +1102,7 @@
10711102
margin: 0;
10721103
padding: 0;
10731104
line-height: 1.6;
1074-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
1105+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
10751106
font-size: 14px;
10761107
color: var(--secondary-color, #6a9955);
10771108
white-space: pre-wrap;
@@ -1092,7 +1123,7 @@
10921123

10931124
.milkup-editor.source-view .milkup-code-block-lines::before {
10941125
counter-increment: line-number attr(data-line-count number, 1);
1095-
content: '';
1126+
content: "";
10961127
display: none;
10971128
}
10981129

@@ -1122,7 +1153,9 @@
11221153
/* 源码模式下的占位符需要向右偏移以避开行号 */
11231154
.milkup-editor.milkup-empty.source-view::before {
11241155
padding-top: 56px;
1125-
padding-left: calc(var(--milkup-editor-padding, 20px) + 20px + 48px); /* 左右边距 + 上下边距 + 行号区域 */
1156+
padding-left: calc(
1157+
var(--milkup-editor-padding, 20px) + 20px + 48px
1158+
); /* 左右边距 + 上下边距 + 行号区域 */
11261159
}
11271160

11281161
/* ============ 源码模式样式 ============ */
@@ -1157,7 +1190,7 @@
11571190

11581191
/* 代码块源码内容 */
11591192
.milkup-code-block-source {
1160-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
1193+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
11611194
font-size: 14px;
11621195
line-height: 1.6;
11631196
color: inherit;
@@ -1173,15 +1206,15 @@
11731206
}
11741207

11751208
.milkup-code-block-source:empty::before {
1176-
content: '```\n\n```';
1209+
content: "```\n\n```";
11771210
color: var(--text-color-3, #999);
11781211
pointer-events: none;
11791212
}
11801213

11811214
/* 代码块源码模式:使用 data-line-count 属性递增行号计数器 */
11821215
.milkup-editor.source-view .milkup-code-block-source::before {
11831216
counter-increment: line-number attr(data-line-count number, 1);
1184-
content: '';
1217+
content: "";
11851218
display: none;
11861219
}
11871220

@@ -1251,7 +1284,7 @@
12511284
/* 列表标记 */
12521285
.milkup-list-marker {
12531286
display: none;
1254-
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
1287+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
12551288
color: var(--text-color-3, #999);
12561289
}
12571290

@@ -1298,7 +1331,9 @@
12981331
border-radius: 3px;
12991332
background: var(--background-color, #fff);
13001333
cursor: pointer;
1301-
transition: background-color 0.15s ease, border-color 0.15s ease;
1334+
transition:
1335+
background-color 0.15s ease,
1336+
border-color 0.15s ease;
13021337
box-sizing: border-box;
13031338
}
13041339

@@ -1378,7 +1413,7 @@
13781413
padding: 6px 8px;
13791414
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
13801415
font-size: 13px;
1381-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1416+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
13821417
}
13831418

13841419
.milkup-search-row,
@@ -1500,5 +1535,5 @@
15001535
white-space: nowrap;
15011536
overflow: hidden;
15021537
text-overflow: ellipsis;
1503-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1538+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
15041539
}

0 commit comments

Comments
 (0)