dsh-fonttune 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.en.md +10 -0
- package/CHANGELOG.md +10 -0
- package/README.en.md +5 -4
- package/README.md +5 -4
- package/lib/client.js +287 -73
- package/lib/index.js +13 -4
- package/lib/shared.cjs +209 -33
- package/package.json +2 -2
package/CHANGELOG.en.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to **dsh-fonttune** are documented here. Chinese version: [CHANGELOG.md](CHANGELOG.md).
|
|
4
4
|
|
|
5
|
+
## [0.1.4] - 2026-09-15
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Code font-size offset**: the size control is split into **two independent axes** — "Body font size offset" for text and interface sizes, and "Code font size offset" for code blocks and inline code only. The single slider used to scale both chains, so moving the body always dragged code along with it; now each moves on its own. The field is `sizeOffsetCode` (-3 ~ +6 px, 0 = leave alone), sitting next to the existing `sizeOffset`, whose meaning narrows to "body and interface text". After upgrading, an existing configuration leaves code at DSH's own sizes while body behaviour is unchanged.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Card layout**: each size slider now sits under the font it resizes — body font → body size offset → code font → code size offset → weight. The two sliders are labelled separately ("Body font size offset" / "Code font size offset"), and the card description reads "Body and code fonts, a size offset for each, weight, and a West/CJK split".
|
|
12
|
+
- **How the code chain is consumed**: DSH's markdown code tokens are `font` shorthands (`--dsw-font-markdown-code` / `-code-block` / `-code-block-small`, valued like `11px/19px <family>`), and the shorthands — not their `-font-size` parts — are what the shipped stylesheets actually read, so the code axis rewrites those too (size and line height scaled, family list kept verbatim) alongside the split parts. The embedded fallback map is corrected to rc.2's real values (it claimed 13px/20px) and gains the three shorthand names.
|
|
13
|
+
- **Compatibility table** now lists 0.1.4 as the latest version.
|
|
14
|
+
|
|
5
15
|
## [0.1.3] - 2026-09-14
|
|
6
16
|
|
|
7
17
|
### Changed
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
**dsh-fonttune** 的重要变更都记录在这里。英文版见 [CHANGELOG.en.md](CHANGELOG.en.md)。
|
|
4
4
|
|
|
5
|
+
## [0.1.4] - 2026-09-15
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
- **代码字号偏移**:字号从「一个全局偏移」拆成**两个互不影响的轴**——「正文字号偏移」作用于正文与界面文字,「代码字号偏移」只作用于代码块与行内代码。原来那一个滑块同时缩放两条链路,调正文必然带动代码;现在各调各的。字段为 `sizeOffsetCode`(-3 ~ +6 px,0 = 不动),与既有的 `sizeOffset` 并列;`sizeOffset` 语义收敛为「正文与界面文字」,旧配置升级后代码字号回到 DSH 原值、正文行为不变。
|
|
9
|
+
|
|
10
|
+
### 变更
|
|
11
|
+
- **卡片布局**:字号滑块移到对应字体下面——正文字体 → 正文字号偏移 → 代码字体 → 代码字号偏移 → 字重;两处滑块文案分开(「正文字号偏移」/「代码字号偏移」),卡片描述改为「正文与代码字体、各自的字号偏移、字重、中西文分栏」。
|
|
12
|
+
- **代码链路的消费点**:DSH 的 markdown 代码 token 都是 `font` 简写(`--dsw-font-markdown-code` / `-code-block` / `-code-block-small`,值是 `11px/19px <family>` 这种形式),真正被样式表消费的是简写而不是 `-font-size` 分件,所以代码轴连同简写一起重写(尺寸与行高按比例乘、字体族原样保留),分件也一并覆盖;内置兜底表按 rc.2 的真实取值修正(此前记的 13px/20px 与主题不符),并补上三个简写名。
|
|
13
|
+
- **兼容表**改列 0.1.4 为最新版本。
|
|
14
|
+
|
|
5
15
|
## [0.1.3] - 2026-09-14
|
|
6
16
|
|
|
7
17
|
### 变更
|
package/README.en.md
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> [中文](README.md) | **English**
|
|
4
4
|
|
|
5
|
-
**Font plugin for DeepSeek Harness (DSH)**: set the body and code font families, a
|
|
5
|
+
**Font plugin for DeepSeek Harness (DSH)**: set the body and code font families, a font-size offset for each, and a global font weight, and pick fonts per **Western / CJK** slot. Everything lives in the native card under **Settings → Plugins → Plugin configuration** and applies immediately.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Body / code fonts** — two independent fallback lists, Latin families first and CJK after; leaving one empty keeps DSH's own stack untouched
|
|
10
|
-
- **
|
|
10
|
+
- **Body font-size offset** — -3 ~ +6 px for text and interface sizes, stacked on top of DSH's own font-size setting rather than replacing it; every size step scales together with its line height
|
|
11
|
+
- **Code font-size offset** — -3 ~ +6 px for code blocks and inline code, **independent** of the body offset: moving one never moves the other
|
|
11
12
|
- **Global font weight** — any integer from 300 to 600; unset or 400 both mean "keep DSH's own weight"
|
|
12
13
|
- **West / CJK split (simple mode)** — a switch at the top of the card: simple mode gives just a Western and a CJK single-pick slot (one pair for body, one for code), advanced mode is the full stack editor; both views share one stack, so toggling never changes the order you set up
|
|
13
14
|
- **Font picker panel** — four preset groups (monospace / CJK / Latin / generic), plus an "installed on this machine" group on Chromium; a name that is not in the list can be created with "use xxx"
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
|
|
19
20
|
| Plugin version | Supported DSH versions |
|
|
20
21
|
| --- | --- |
|
|
21
|
-
| **0.1.
|
|
22
|
+
| **0.1.4** (latest) | 0.1.5-rc.2 |
|
|
22
23
|
|
|
23
24
|
`engines.dsh` requires **0.1.5-rc.2** or newer, and the compatibility declaration lists only the **latest release of the 0.1.5 line**: it carries every fix in that line, which makes it the most stable build of the major version, while older builds of the same major version stay compatible per semantic versioning. Earlier or newer DSH versions are untested and not declared. On install or update, the DSH market runs a host-compatibility preflight against `engines.dsh`, `dsh.compatibility.dshReleases` and `peerDependencies` in `package.json`.
|
|
24
25
|
|
|
@@ -48,7 +49,7 @@ Restart DSH once afterwards and open the Web UI; changing settings needs no rest
|
|
|
48
49
|
|
|
49
50
|
- **Open the settings** — Settings → Plugins → Plugin configuration → expand the "Font tune" card
|
|
50
51
|
- **Pick fonts** — in simple mode click the four slots (Body · Western, Body · CJK, Code · Western, Code · CJK); in advanced mode use "Add font" and the chip editor to maintain the full fallback list
|
|
51
|
-
- **Tune
|
|
52
|
+
- **Tune sizes** — each size slider sits directly under the font it resizes: "Body font size offset" under the body font, "Code font size offset" under the code font, with the weight slider below. Drag and release to apply. Changed fields are marked and can be reset individually, with "Reset all" at the bottom of the card
|
|
52
53
|
- **Preview** — the mixed-script and code preview at the bottom of the card renders with the current configuration
|
|
53
54
|
- Settings are stored in DSH's settings document (`settings.yaml`), so they travel with your configuration
|
|
54
55
|
|
package/README.md
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> [English](README.en.md) | **中文**
|
|
4
4
|
|
|
5
|
-
**DeepSeek Harness(DSH
|
|
5
|
+
**DeepSeek Harness(DSH)字体插件**:设置正文与代码的字体族、各自独立的字号偏移与字重,并按「西文 / 中文」分栏挑字体;配置入口是 **设置 → 插件 → 插件配置** 里的原生卡片,改完即时生效。
|
|
6
6
|
|
|
7
7
|
## 功能
|
|
8
8
|
|
|
9
9
|
- **正文 / 代码字体** —— 两套独立的字体回退列表,拉丁字体在前、中文字体在后;留空表示完全沿用 DSH 的字体栈
|
|
10
|
-
-
|
|
10
|
+
- **正文字号偏移** —— -3 ~ +6 px,作用于正文与界面文字;与 DSH 自己的「字号大小」叠加而不是覆盖,每一档字号连同它的行高一起等比缩放
|
|
11
|
+
- **代码字号偏移** —— -3 ~ +6 px,**独立**作用于代码块与行内代码:调正文不会带动代码,调代码也不会带动正文
|
|
11
12
|
- **全局字重** —— 300 ~ 600 任意整数;未设置或 400 都表示沿用 DSH 原本的字重
|
|
12
13
|
- **西文 / 中文分栏(简单模式)** —— 卡片顶部一个开关:简单模式只给「西文」「中文」两个单选格(正文/代码各一对),高级模式是完整的字体栈编辑器;两种模式共用同一条栈,来回切换不会改动已排好的顺序
|
|
13
14
|
- **选字体面板** —— 内置 等宽 / 中文(CJK)/ 拉丁 / 通用 四组预设,Chromium 下再补上「本机已安装」分组;搜索不到的名字可以直接「使用 xxx」新建
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
|
|
19
20
|
| 插件版本 | 支持的 DSH 版本 |
|
|
20
21
|
| --- | --- |
|
|
21
|
-
| **0.1.
|
|
22
|
+
| **0.1.4**(最新) | 0.1.5-rc.2 |
|
|
22
23
|
|
|
23
24
|
`engines.dsh` 下限为 **0.1.5-rc.2**,兼容声明只列 **0.1.5 线的最新版本**:它包含这条线的全部修复,是同一大版本里最稳的一版,而同一大版本内的旧版本按语义化版本约定向上兼容。更早或更新的 DSH 未经验证,不作声明。安装或更新时,DSH 市场会依据 `package.json` 里的 `engines.dsh`、`dsh.compatibility.dshReleases` 与 `peerDependencies` 做宿主兼容预检。
|
|
24
25
|
|
|
@@ -48,7 +49,7 @@ dsh plugin --profile web add <插件目录路径>
|
|
|
48
49
|
|
|
49
50
|
- **打开设置** —— 设置 → 插件 → 插件配置 → 展开「字体增强」卡片
|
|
50
51
|
- **换字体** —— 简单模式下点「正文 · 西文字体」「正文 · 中文字体」「代码 · 西文字体」「代码 · 中文字体」四个格子选字体;高级模式下用「添加字体」与 chips 编辑器维护完整回退列表
|
|
51
|
-
-
|
|
52
|
+
- **调整字号** —— 字号滑块就在对应的字体下面:「正文字号偏移」跟着正文字体、「代码字号偏移」跟着代码字体;再往下是「字重」。拖动松手即生效;改过的字段标「已修改」并可单独重置,卡片底部有「全部重置」
|
|
52
53
|
- **预览** —— 卡片底部的中英混排与代码预览用当前配置渲染
|
|
53
54
|
- 设置保存在 DSH 的设置文档里(`settings.yaml`),跟随配置走
|
|
54
55
|
|
package/lib/client.js
CHANGED
|
@@ -32,9 +32,12 @@ var SANS_FIELD = "sans";
|
|
|
32
32
|
/** Field carrying the code CSS font-family stack (empty = leave DSH alone). */
|
|
33
33
|
var MONO_FIELD = "mono";
|
|
34
34
|
|
|
35
|
-
/** Field carrying the
|
|
35
|
+
/** Field carrying the body/UI font-size offset in px (0 = leave DSH alone). */
|
|
36
36
|
var SIZE_FIELD = "sizeOffset";
|
|
37
37
|
|
|
38
|
+
/** Field carrying the code font-size offset in px (0 = leave DSH alone). */
|
|
39
|
+
var CODE_SIZE_FIELD = "sizeOffsetCode";
|
|
40
|
+
|
|
38
41
|
/** Field carrying the global font weight (0 = leave DSH alone). */
|
|
39
42
|
var WEIGHT_FIELD = "weight";
|
|
40
43
|
|
|
@@ -61,6 +64,7 @@ var DEFAULTS = {
|
|
|
61
64
|
sans: "",
|
|
62
65
|
mono: "",
|
|
63
66
|
sizeOffset: 0,
|
|
67
|
+
sizeOffsetCode: 0,
|
|
64
68
|
weight: WEIGHT_UNSET,
|
|
65
69
|
};
|
|
66
70
|
|
|
@@ -146,13 +150,12 @@ var GENERIC_FAMILIES = [
|
|
|
146
150
|
* Normalize a configuration-shaped object coming from the settings document,
|
|
147
151
|
* a config layer, or a test fixture.
|
|
148
152
|
* @param {unknown} value - candidate configuration.
|
|
149
|
-
* @returns {{sans: string, mono: string, sizeOffset: number, weight: number}} the normalized config.
|
|
153
|
+
* @returns {{sans: string, mono: string, sizeOffset: number, sizeOffsetCode: number, weight: number}} the normalized config.
|
|
150
154
|
*/
|
|
151
155
|
function normalizeConfig(value) {
|
|
152
156
|
var source = value !== null && typeof value === "object" ? value : {};
|
|
153
|
-
var size =
|
|
154
|
-
|
|
155
|
-
size = Math.round(Math.min(SIZE_MAX, Math.max(SIZE_MIN, size)));
|
|
157
|
+
var size = clampOffset(source[SIZE_FIELD]);
|
|
158
|
+
var codeSize = clampOffset(source[CODE_SIZE_FIELD]);
|
|
156
159
|
var weight = Number(source[WEIGHT_FIELD]);
|
|
157
160
|
if (!isFinite(weight)) weight = WEIGHT_UNSET;
|
|
158
161
|
weight = Math.round(weight);
|
|
@@ -163,10 +166,22 @@ function normalizeConfig(value) {
|
|
|
163
166
|
config[SANS_FIELD] = sanitize(source[SANS_FIELD]).slice(0, MAX_STACK_LENGTH);
|
|
164
167
|
config[MONO_FIELD] = sanitize(source[MONO_FIELD]).slice(0, MAX_STACK_LENGTH);
|
|
165
168
|
config[SIZE_FIELD] = size;
|
|
169
|
+
config[CODE_SIZE_FIELD] = codeSize;
|
|
166
170
|
config[WEIGHT_FIELD] = weight;
|
|
167
171
|
return config;
|
|
168
172
|
}
|
|
169
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Clamp one size offset to the allowed range, with 0 for anything unusable.
|
|
176
|
+
* @param {unknown} value - candidate offset in px.
|
|
177
|
+
* @returns {number} the offset the stylesheet may use.
|
|
178
|
+
*/
|
|
179
|
+
function clampOffset(value) {
|
|
180
|
+
var size = Number(value);
|
|
181
|
+
if (!isFinite(size)) return 0;
|
|
182
|
+
return Math.round(Math.min(SIZE_MAX, Math.max(SIZE_MIN, size)));
|
|
183
|
+
}
|
|
184
|
+
|
|
170
185
|
/**
|
|
171
186
|
* Format a family list as a CSS font-family value.
|
|
172
187
|
* @param {readonly string[]} families - family names in precedence order.
|
|
@@ -361,7 +376,7 @@ function scaleFor(sizeOffset, base) {
|
|
|
361
376
|
|
|
362
377
|
/**
|
|
363
378
|
* Whether a configuration asks for any change at all.
|
|
364
|
-
* @param {{sans: string, mono: string, sizeOffset: number, weight: number}} config - normalized config.
|
|
379
|
+
* @param {{sans: string, mono: string, sizeOffset: number, sizeOffsetCode: number, weight: number}} config - normalized config.
|
|
365
380
|
* @returns {boolean} true when nothing should be injected.
|
|
366
381
|
*/
|
|
367
382
|
function isDormant(config) {
|
|
@@ -369,6 +384,7 @@ function isDormant(config) {
|
|
|
369
384
|
config[SANS_FIELD] === "" &&
|
|
370
385
|
config[MONO_FIELD] === "" &&
|
|
371
386
|
config[SIZE_FIELD] === 0 &&
|
|
387
|
+
config[CODE_SIZE_FIELD] === 0 &&
|
|
372
388
|
config[WEIGHT_FIELD] === WEIGHT_UNSET
|
|
373
389
|
);
|
|
374
390
|
}
|
|
@@ -384,13 +400,22 @@ function isDormant(config) {
|
|
|
384
400
|
* would never inherit a plain `body` rule. The explicit `body` / `pre,code`
|
|
385
401
|
* rules stay as a second path for elements that hardcode a family.
|
|
386
402
|
*
|
|
387
|
-
* The size
|
|
403
|
+
* The size offsets rewrite DSH's own design tokens rather than every element:
|
|
388
404
|
* a token whose name ends in `-font-size` or `-line-height` is re-declared as
|
|
389
405
|
* itself multiplied by one scale factor. `baseTokens` supplies the untouched
|
|
390
406
|
* values (read from the live document, falling back to the embedded map), so
|
|
391
407
|
* the ratio composes with DSH's own font-size slider instead of replacing it.
|
|
392
408
|
*
|
|
393
|
-
*
|
|
409
|
+
* Body and code are two independent axes. Body sizes hang off the content-size
|
|
410
|
+
* chain (`--dsh-content-font-size` and the `--dsw-font-*` steps), while every
|
|
411
|
+
* markdown code token is a bare literal (`--dsw-font-markdown-code-block:
|
|
412
|
+
* 11px/19px …`) that the content chain never touches — so the code axis is the
|
|
413
|
+
* only thing that moves it, and the body axis deliberately leaves those tokens
|
|
414
|
+
* alone. Code sizing is consumed through the `font` SHORTHAND tokens (that is
|
|
415
|
+
* what the shipped stylesheets use), which is why those are re-declared too,
|
|
416
|
+
* not just their `-font-size` / `-line-height` parts.
|
|
417
|
+
*
|
|
418
|
+
* @param {{sans: string, mono: string, sizeOffset: number, sizeOffsetCode: number, weight: number}} config - normalized config.
|
|
394
419
|
* @param {Record<string, string>} [baseTokens] - token name to untouched value.
|
|
395
420
|
* @returns {string} declarations for one `<style>` element ("" when dormant).
|
|
396
421
|
*/
|
|
@@ -399,6 +424,7 @@ function buildFontCss(config, baseTokens) {
|
|
|
399
424
|
var sans = formatStack(parseStack(normalized[SANS_FIELD]));
|
|
400
425
|
var mono = formatStack(parseStack(normalized[MONO_FIELD]));
|
|
401
426
|
var offset = normalized[SIZE_FIELD];
|
|
427
|
+
var codeOffset = normalized[CODE_SIZE_FIELD];
|
|
402
428
|
var weight = normalized[WEIGHT_FIELD];
|
|
403
429
|
if (isDormant(normalized)) return "";
|
|
404
430
|
var declarations = [];
|
|
@@ -422,28 +448,17 @@ function buildFontCss(config, baseTokens) {
|
|
|
422
448
|
);
|
|
423
449
|
}
|
|
424
450
|
if (offset !== 0) {
|
|
425
|
-
var
|
|
426
|
-
var names = tokenNames(baseTokens);
|
|
427
|
-
var scaled = [];
|
|
428
|
-
for (var index = 0; index < names.length; index += 1) {
|
|
429
|
-
var name = names[index];
|
|
430
|
-
var base = baseTokens[name];
|
|
431
|
-
if (typeof base !== "string" || base === "") continue;
|
|
432
|
-
// A base that itself references another token via var() derives from it:
|
|
433
|
-
// scaling the var target already scales this one, so re-scaling here
|
|
434
|
-
// would compound (markdown-base = var(--dsh-content-font-size) would
|
|
435
|
-
// take the ratio twice). DSH's chain does the work instead.
|
|
436
|
-
if (base.indexOf("var(") !== -1) continue;
|
|
437
|
-
// !important: the theme writes `--dsh-content-font-size` INLINE on body,
|
|
438
|
-
// and an inline declaration outranks a plain stylesheet one — without
|
|
439
|
-
// the flag body itself would keep DSH's own size while every descendant
|
|
440
|
-
// scales, splitting the page in two.
|
|
441
|
-
scaled.push(name + ":calc((" + base + ") * " + scale + ") !important");
|
|
442
|
-
}
|
|
451
|
+
var scaled = scaleTokens(bodyTokenNames(baseTokens), baseTokens, round(scaleFor(offset), 6));
|
|
443
452
|
if (scaled.length > 0) {
|
|
444
453
|
declarations.push(bodyAndDescendants(scaled.join(";")));
|
|
445
454
|
}
|
|
446
455
|
}
|
|
456
|
+
if (codeOffset !== 0) {
|
|
457
|
+
var scaledCode = scaleCodeTokens(baseTokens, round(scaleFor(codeOffset), 6));
|
|
458
|
+
if (scaledCode.length > 0) {
|
|
459
|
+
declarations.push(bodyAndDescendants(scaledCode.join(";")));
|
|
460
|
+
}
|
|
461
|
+
}
|
|
447
462
|
if (weight !== WEIGHT_UNSET) {
|
|
448
463
|
// Written as the user chose it: a variable font honors every integer, and
|
|
449
464
|
// a static one rounds to its own nearest step by itself.
|
|
@@ -452,6 +467,109 @@ function buildFontCss(config, baseTokens) {
|
|
|
452
467
|
return declarations.join("\n");
|
|
453
468
|
}
|
|
454
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Values a ratio may multiply: a number with a unit, a bare number, or an
|
|
472
|
+
* expression. A keyword (`unset`, `inherit`) or an unrecognized shape is left
|
|
473
|
+
* alone instead of being wrapped into an invalid `calc()`.
|
|
474
|
+
*/
|
|
475
|
+
var SCALABLE_VALUE = /^(?:[+-]?(?:\d|\.\d)|calc\(|var\(|min\(|max\(|clamp\()/;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Whether one token value can be multiplied by a scale factor.
|
|
479
|
+
* @param {string} value - the token's untouched value.
|
|
480
|
+
* @returns {boolean} true when `calc((value) * scale)` is meaningful.
|
|
481
|
+
*/
|
|
482
|
+
function isScalableValue(value) {
|
|
483
|
+
return typeof value === "string" && SCALABLE_VALUE.test(value.trim());
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Scale one set of tokens by one ratio.
|
|
488
|
+
*
|
|
489
|
+
* A base that itself references another token via var() derives from it:
|
|
490
|
+
* scaling the var target already scales this one, so re-scaling here would
|
|
491
|
+
* compound (markdown-base = var(--dsh-content-font-size) would take the ratio
|
|
492
|
+
* twice). DSH's chain does the work instead.
|
|
493
|
+
*
|
|
494
|
+
* `!important` is required: the theme writes `--dsh-content-font-size` INLINE on
|
|
495
|
+
* body, and an inline declaration outranks a plain stylesheet one — without the
|
|
496
|
+
* flag body itself would keep DSH's own size while every descendant scales,
|
|
497
|
+
* splitting the page in two.
|
|
498
|
+
*
|
|
499
|
+
* @param {string[]} names - token names to re-declare.
|
|
500
|
+
* @param {Record<string, string>} baseTokens - token name to untouched value.
|
|
501
|
+
* @param {number} scale - the ratio to apply.
|
|
502
|
+
* @returns {string[]} declarations.
|
|
503
|
+
*/
|
|
504
|
+
function scaleTokens(names, baseTokens, scale) {
|
|
505
|
+
var out = [];
|
|
506
|
+
for (var index = 0; index < names.length; index += 1) {
|
|
507
|
+
var name = names[index];
|
|
508
|
+
var base = baseTokens[name];
|
|
509
|
+
if (typeof base !== "string" || base === "") continue;
|
|
510
|
+
if (base.indexOf("var(") !== -1) continue;
|
|
511
|
+
if (!isScalableValue(base)) continue;
|
|
512
|
+
out.push(name + ":calc((" + base + ") * " + scale + ") !important");
|
|
513
|
+
}
|
|
514
|
+
return out;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Re-declare the markdown code tokens at their own ratio.
|
|
519
|
+
*
|
|
520
|
+
* Two shapes exist and both must be covered, because the shipped stylesheets
|
|
521
|
+
* consume the shorthand (`font: var(--dsw-font-markdown-code-block-small)`)
|
|
522
|
+
* while the split tokens exist for anything that asks for a single part:
|
|
523
|
+
* `11px/19px <family>` and a bare `11px`.
|
|
524
|
+
*
|
|
525
|
+
* @param {Record<string, string>} baseTokens - token name to untouched value.
|
|
526
|
+
* @param {number} scale - the ratio to apply.
|
|
527
|
+
* @returns {string[]} declarations.
|
|
528
|
+
*/
|
|
529
|
+
function scaleCodeTokens(baseTokens, scale) {
|
|
530
|
+
var names = codeTokenNames(baseTokens);
|
|
531
|
+
var out = [];
|
|
532
|
+
for (var index = 0; index < names.length; index += 1) {
|
|
533
|
+
var name = names[index];
|
|
534
|
+
var base = baseTokens[name];
|
|
535
|
+
if (typeof base !== "string" || base === "") continue;
|
|
536
|
+
var shorthand = scaleFontShorthand(base, scale);
|
|
537
|
+
if (shorthand !== null) {
|
|
538
|
+
out.push(name + ":" + shorthand + " !important");
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
// A part token that derives from another token follows that token's own
|
|
542
|
+
// scaling; re-declaring it here would compound the ratio.
|
|
543
|
+
if (base.indexOf("var(") !== -1) continue;
|
|
544
|
+
if (!isScalableValue(base)) continue;
|
|
545
|
+
out.push(name + ":calc((" + base + ") * " + scale + ") !important");
|
|
546
|
+
}
|
|
547
|
+
return out;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Multiply the size and the line height inside one `font` shorthand value,
|
|
552
|
+
* leaving the family list (and anything else after it) untouched.
|
|
553
|
+
* @param {string} value - a value shaped like `11px/19px var(--ds-font-family-code)`.
|
|
554
|
+
* @param {number} scale - the ratio to apply.
|
|
555
|
+
* @returns {string|null} the scaled shorthand, or null when the shape differs.
|
|
556
|
+
*/
|
|
557
|
+
function scaleFontShorthand(value, scale) {
|
|
558
|
+
var slash = value.indexOf("/");
|
|
559
|
+
if (slash <= 0) return null;
|
|
560
|
+
var size = value.slice(0, slash).trim();
|
|
561
|
+
var rest = value.slice(slash + 1).trim();
|
|
562
|
+
var gap = rest.search(/\s/);
|
|
563
|
+
if (gap <= 0) return null;
|
|
564
|
+
var height = rest.slice(0, gap).trim();
|
|
565
|
+
var family = rest.slice(gap + 1).trim();
|
|
566
|
+
if (size === "" || height === "" || family === "") return null;
|
|
567
|
+
if (!isScalableValue(size) || !isScalableValue(height)) return null;
|
|
568
|
+
return (
|
|
569
|
+
"calc((" + size + ") * " + scale + ")/calc((" + height + ") * " + scale + ") " + family
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
455
573
|
/**
|
|
456
574
|
* Match DSH's typography tokens: the design system's sizes plus the content
|
|
457
575
|
* size the theme plugin writes on `body` (whose secondary variant carries a
|
|
@@ -483,6 +601,30 @@ function isFontToken(name) {
|
|
|
483
601
|
return typeof name === "string" && TOKEN_PATTERN.test(name);
|
|
484
602
|
}
|
|
485
603
|
|
|
604
|
+
/**
|
|
605
|
+
* Match DSH's markdown code tokens, which are their own sizing axis.
|
|
606
|
+
*
|
|
607
|
+
* The theme declares these as literals the content-size chain never reaches
|
|
608
|
+
* (`--dsw-font-markdown-code:12px/19px …`, `-code-block:11px/19px …`,
|
|
609
|
+
* `-code-block-small:11px/16px …`), and the shipped stylesheets consume them
|
|
610
|
+
* through the `font` shorthand. Everything with this prefix therefore belongs
|
|
611
|
+
* to the code offset and to nothing else.
|
|
612
|
+
* @param {string} name - custom property name including the leading dashes.
|
|
613
|
+
* @returns {boolean} true when the token sizes code.
|
|
614
|
+
*/
|
|
615
|
+
function isCodeToken(name) {
|
|
616
|
+
return typeof name === "string" && name.indexOf("--dsw-font-markdown-code") === 0;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Whether a token is one this plugin re-declares at all.
|
|
621
|
+
* @param {string} name - custom property name including the leading dashes.
|
|
622
|
+
* @returns {boolean} true for body sizes, body line heights and code tokens.
|
|
623
|
+
*/
|
|
624
|
+
function isScaledToken(name) {
|
|
625
|
+
return isFontToken(name) || isCodeToken(name);
|
|
626
|
+
}
|
|
627
|
+
|
|
486
628
|
/**
|
|
487
629
|
* Ordered token names present in a base map, sizes before line heights so a
|
|
488
630
|
* reader of the stylesheet sees each size next to its height.
|
|
@@ -491,7 +633,7 @@ function isFontToken(name) {
|
|
|
491
633
|
*/
|
|
492
634
|
function tokenNames(baseTokens) {
|
|
493
635
|
if (baseTokens === null || typeof baseTokens !== "object") return [];
|
|
494
|
-
var names = Object.keys(baseTokens).filter(
|
|
636
|
+
var names = Object.keys(baseTokens).filter(isScaledToken);
|
|
495
637
|
names.sort(function (left, right) {
|
|
496
638
|
if (left.length !== right.length) return left.length - right.length;
|
|
497
639
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
@@ -499,6 +641,28 @@ function tokenNames(baseTokens) {
|
|
|
499
641
|
return names;
|
|
500
642
|
}
|
|
501
643
|
|
|
644
|
+
/**
|
|
645
|
+
* The body/UI tokens: everything this plugin scales except the code family,
|
|
646
|
+
* which answers to its own offset.
|
|
647
|
+
* @param {Record<string, string>} [baseTokens] - token name to value.
|
|
648
|
+
* @returns {string[]} the names the body offset re-declares.
|
|
649
|
+
*/
|
|
650
|
+
function bodyTokenNames(baseTokens) {
|
|
651
|
+
return tokenNames(baseTokens).filter(function (name) {
|
|
652
|
+
return !isCodeToken(name);
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* The code tokens: the `font` shorthands plus their `-font-size` /
|
|
658
|
+
* `-line-height` parts, when the live stylesheets declare them.
|
|
659
|
+
* @param {Record<string, string>} [baseTokens] - token name to value.
|
|
660
|
+
* @returns {string[]} the names the code offset re-declares.
|
|
661
|
+
*/
|
|
662
|
+
function codeTokenNames(baseTokens) {
|
|
663
|
+
return tokenNames(baseTokens).filter(isCodeToken);
|
|
664
|
+
}
|
|
665
|
+
|
|
502
666
|
/**
|
|
503
667
|
* Embedded fallback for the tokens the theme plugin defines at runtime.
|
|
504
668
|
*
|
|
@@ -546,12 +710,18 @@ var FALLBACK_TOKENS = {
|
|
|
546
710
|
"--dsw-font-markdown-h3-line-height": "26px",
|
|
547
711
|
"--dsw-font-markdown-h4-font-size": "15px",
|
|
548
712
|
"--dsw-font-markdown-h4-line-height": "24px",
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
"--dsw-font-markdown-code
|
|
552
|
-
"--dsw-font-markdown-code-
|
|
553
|
-
"--dsw-font-markdown-code-
|
|
554
|
-
"--dsw-font-markdown-code-block
|
|
713
|
+
// The code family is consumed through the `font` shorthand, so the shorthand
|
|
714
|
+
// names matter more than their parts — both are listed, at rc.2's values.
|
|
715
|
+
"--dsw-font-markdown-code": "12px/19px var(--ds-font-family-code)",
|
|
716
|
+
"--dsw-font-markdown-code-font-size": "12px",
|
|
717
|
+
"--dsw-font-markdown-code-line-height": "19px",
|
|
718
|
+
"--dsw-font-markdown-code-block": "11px/19px var(--ds-font-family-code)",
|
|
719
|
+
"--dsw-font-markdown-code-block": "11px/19px var(--ds-font-family-code)",
|
|
720
|
+
"--dsw-font-markdown-code-block-font-size": "11px",
|
|
721
|
+
"--dsw-font-markdown-code-block-line-height": "19px",
|
|
722
|
+
"--dsw-font-markdown-code-block-small": "11px/16px var(--ds-font-family-code)",
|
|
723
|
+
"--dsw-font-markdown-code-block-small-font-size": "11px",
|
|
724
|
+
"--dsw-font-markdown-code-block-small-line-height": "16px",
|
|
555
725
|
"--dsw-font-markdown-table-font-size": "13px",
|
|
556
726
|
"--dsw-font-markdown-table-line-height": "22px",
|
|
557
727
|
"--dsh-content-font-size": "14px",
|
|
@@ -638,6 +808,7 @@ var shared = {
|
|
|
638
808
|
SANS_FIELD: SANS_FIELD,
|
|
639
809
|
MONO_FIELD: MONO_FIELD,
|
|
640
810
|
SIZE_FIELD: SIZE_FIELD,
|
|
811
|
+
CODE_SIZE_FIELD: CODE_SIZE_FIELD,
|
|
641
812
|
WEIGHT_FIELD: WEIGHT_FIELD,
|
|
642
813
|
SIZE_MIN: SIZE_MIN,
|
|
643
814
|
SIZE_MAX: SIZE_MAX,
|
|
@@ -662,6 +833,11 @@ var shared = {
|
|
|
662
833
|
isDormant: isDormant,
|
|
663
834
|
buildFontCss: buildFontCss,
|
|
664
835
|
isFontToken: isFontToken,
|
|
836
|
+
isCodeToken: isCodeToken,
|
|
837
|
+
isScaledToken: isScaledToken,
|
|
838
|
+
codeTokenNames: codeTokenNames,
|
|
839
|
+
bodyTokenNames: bodyTokenNames,
|
|
840
|
+
scaleFontShorthand: scaleFontShorthand,
|
|
665
841
|
isGenericFamilyName: isGenericFamilyName,
|
|
666
842
|
isCJKFamilyName: isCJKFamilyName,
|
|
667
843
|
setWestEntry: setWestEntry,
|
|
@@ -713,6 +889,7 @@ var NAMESPACE = shared.NAMESPACE;
|
|
|
713
889
|
var SANS_FIELD = shared.SANS_FIELD;
|
|
714
890
|
var MONO_FIELD = shared.MONO_FIELD;
|
|
715
891
|
var SIZE_FIELD = shared.SIZE_FIELD;
|
|
892
|
+
var CODE_SIZE_FIELD = shared.CODE_SIZE_FIELD;
|
|
716
893
|
var WEIGHT_FIELD = shared.WEIGHT_FIELD;
|
|
717
894
|
var SIZE_MIN = shared.SIZE_MIN;
|
|
718
895
|
var SIZE_MAX = shared.SIZE_MAX;
|
|
@@ -726,6 +903,7 @@ var PRESETS = shared.PRESETS;
|
|
|
726
903
|
var buildFontCss = shared.buildFontCss;
|
|
727
904
|
var formatStack = shared.formatStack;
|
|
728
905
|
var isFontToken = shared.isFontToken;
|
|
906
|
+
var isScaledToken = shared.isScaledToken;
|
|
729
907
|
var normalizeConfig = shared.normalizeConfig;
|
|
730
908
|
var parseStack = shared.parseStack;
|
|
731
909
|
var quoteFamily = shared.quoteFamily;
|
|
@@ -762,7 +940,7 @@ var DICTS = {
|
|
|
762
940
|
en: {
|
|
763
941
|
"card.title": "Font tune",
|
|
764
942
|
"card.description":
|
|
765
|
-
"Body and code fonts, a size offset, weight, and a West/CJK split",
|
|
943
|
+
"Body and code fonts, a size offset for each, weight, and a West/CJK split",
|
|
766
944
|
"card.expand": "Expand",
|
|
767
945
|
"card.collapse": "Collapse",
|
|
768
946
|
"card.resetAll": "Reset all",
|
|
@@ -814,9 +992,12 @@ var DICTS = {
|
|
|
814
992
|
"split.remove": "Remove {name}",
|
|
815
993
|
"split.rest": "Other fallbacks (reorder them in Advanced): {names}",
|
|
816
994
|
|
|
817
|
-
"size.
|
|
818
|
-
"size.
|
|
819
|
-
"Adds {offset} to
|
|
995
|
+
"size.bodyLabel": "Body font size offset",
|
|
996
|
+
"size.bodyHint":
|
|
997
|
+
"Adds {offset} to text and interface sizes, on top of DSH's own font-size setting. 0 keeps DSH's sizes.",
|
|
998
|
+
"size.codeLabel": "Code font size offset",
|
|
999
|
+
"size.codeHint":
|
|
1000
|
+
"Adds {offset} to code blocks and inline code only; the body offset does not reach them. 0 keeps DSH's sizes.",
|
|
820
1001
|
"size.unit": "px",
|
|
821
1002
|
|
|
822
1003
|
"weight.label": "Font weight",
|
|
@@ -835,7 +1016,7 @@ var DICTS = {
|
|
|
835
1016
|
},
|
|
836
1017
|
zh: {
|
|
837
1018
|
"card.title": "字体增强",
|
|
838
|
-
"card.description": "
|
|
1019
|
+
"card.description": "正文与代码字体、各自的字号偏移、字重、中西文分栏",
|
|
839
1020
|
"card.expand": "展开",
|
|
840
1021
|
"card.collapse": "收起",
|
|
841
1022
|
"card.resetAll": "全部重置",
|
|
@@ -885,9 +1066,12 @@ var DICTS = {
|
|
|
885
1066
|
"split.remove": "移除 {name}",
|
|
886
1067
|
"split.rest": "其余回退项(在高级模式中排序):{names}",
|
|
887
1068
|
|
|
888
|
-
"size.
|
|
889
|
-
"size.
|
|
890
|
-
"
|
|
1069
|
+
"size.bodyLabel": "正文字号偏移",
|
|
1070
|
+
"size.bodyHint":
|
|
1071
|
+
"给正文与界面文字统一加 {offset},与设置里的「字号大小」叠加;0 表示保持原样。",
|
|
1072
|
+
"size.codeLabel": "代码字号偏移",
|
|
1073
|
+
"size.codeHint":
|
|
1074
|
+
"只作用于代码块与行内代码,与正文字号互不影响;0 表示保持原样。",
|
|
891
1075
|
"size.unit": "px",
|
|
892
1076
|
|
|
893
1077
|
"weight.label": "字重",
|
|
@@ -1063,7 +1247,7 @@ function isOwnSheet(sheet) {
|
|
|
1063
1247
|
}
|
|
1064
1248
|
|
|
1065
1249
|
/**
|
|
1066
|
-
* Snapshot the typography tokens the size
|
|
1250
|
+
* Snapshot the typography tokens the size offsets scale.
|
|
1067
1251
|
*
|
|
1068
1252
|
* Three sources, in rising authority: the embedded fallback map (covers the
|
|
1069
1253
|
* frame before DSH's runtime tokens exist), declarations read from the
|
|
@@ -1073,6 +1257,10 @@ function isOwnSheet(sheet) {
|
|
|
1073
1257
|
* rule applies it reports the SCALED values, and feeding those back as bases
|
|
1074
1258
|
* compounds the offset on every refresh.
|
|
1075
1259
|
*
|
|
1260
|
+
* Code shorthands (`--dsw-font-markdown-code-block` and friends) are collected
|
|
1261
|
+
* too: they are `font` values rather than `-font-size` tokens, and they are
|
|
1262
|
+
* what the shipped stylesheets actually consume.
|
|
1263
|
+
*
|
|
1076
1264
|
* @returns {Record<string, string>} token name to its untouched value.
|
|
1077
1265
|
*/
|
|
1078
1266
|
function readBaseTokens() {
|
|
@@ -1101,7 +1289,7 @@ function readBaseTokens() {
|
|
|
1101
1289
|
if (!style) continue;
|
|
1102
1290
|
for (var propertyIndex = 0; propertyIndex < style.length; propertyIndex += 1) {
|
|
1103
1291
|
var property = style[propertyIndex];
|
|
1104
|
-
if (property.slice(0, 2) !== "--" || !
|
|
1292
|
+
if (property.slice(0, 2) !== "--" || !isScaledToken(property)) continue;
|
|
1105
1293
|
var declared = style.getPropertyValue(property).trim();
|
|
1106
1294
|
if (declared !== "") out[property] = declared;
|
|
1107
1295
|
}
|
|
@@ -1122,7 +1310,7 @@ function readBaseTokens() {
|
|
|
1122
1310
|
}
|
|
1123
1311
|
for (var inlineIndex = 0; inlineIndex < inline.length; inlineIndex += 1) {
|
|
1124
1312
|
var inlineName = inline[inlineIndex];
|
|
1125
|
-
if (inlineName.slice(0, 2) !== "--" || !
|
|
1313
|
+
if (inlineName.slice(0, 2) !== "--" || !isScaledToken(inlineName)) continue;
|
|
1126
1314
|
var inlineValue = inline.getPropertyValue(inlineName).trim();
|
|
1127
1315
|
if (inlineValue !== "") out[inlineName] = inlineValue;
|
|
1128
1316
|
}
|
|
@@ -2082,8 +2270,47 @@ function FontCard(props) {
|
|
|
2082
2270
|
};
|
|
2083
2271
|
|
|
2084
2272
|
var offset = config[SIZE_FIELD];
|
|
2273
|
+
var codeOffset = config[CODE_SIZE_FIELD];
|
|
2085
2274
|
var weight = config[WEIGHT_FIELD];
|
|
2086
2275
|
var offsetText = offset > 0 ? "+" + offset : String(offset);
|
|
2276
|
+
var codeOffsetText = codeOffset > 0 ? "+" + codeOffset : String(codeOffset);
|
|
2277
|
+
|
|
2278
|
+
/**
|
|
2279
|
+
* One size slider, rendered directly under the family it resizes.
|
|
2280
|
+
* @param {object} props - field, label keys, current value and text.
|
|
2281
|
+
* @returns {object} the field shell wrapping the slider.
|
|
2282
|
+
*/
|
|
2283
|
+
var sizeField = function (props) {
|
|
2284
|
+
return h(
|
|
2285
|
+
FieldShell,
|
|
2286
|
+
{
|
|
2287
|
+
t: t,
|
|
2288
|
+
label: t(props.labelKey),
|
|
2289
|
+
hint: t(props.hintKey, { offset: props.text }),
|
|
2290
|
+
overridden: overridden(props.field) && props.value !== 0,
|
|
2291
|
+
disabled: !writable,
|
|
2292
|
+
onReset: function () {
|
|
2293
|
+
resetField(props.field);
|
|
2294
|
+
},
|
|
2295
|
+
},
|
|
2296
|
+
h(NumberSlider, {
|
|
2297
|
+
min: SIZE_MIN,
|
|
2298
|
+
max: SIZE_MAX,
|
|
2299
|
+
value: props.value,
|
|
2300
|
+
disabled: !writable,
|
|
2301
|
+
label: t(props.labelKey),
|
|
2302
|
+
readout: props.text + " " + t("size.unit"),
|
|
2303
|
+
minLabel: SIZE_MIN + " " + t("size.unit"),
|
|
2304
|
+
maxLabel: "+" + SIZE_MAX + " " + t("size.unit"),
|
|
2305
|
+
pendingText: function (value) {
|
|
2306
|
+
return (value > 0 ? "+" + value : String(value)) + " " + t("size.unit");
|
|
2307
|
+
},
|
|
2308
|
+
onChange: function (value) {
|
|
2309
|
+
setField(props.field, value);
|
|
2310
|
+
},
|
|
2311
|
+
})
|
|
2312
|
+
);
|
|
2313
|
+
};
|
|
2087
2314
|
|
|
2088
2315
|
return h(
|
|
2089
2316
|
"li",
|
|
@@ -2192,6 +2419,14 @@ function FontCard(props) {
|
|
|
2192
2419
|
})
|
|
2193
2420
|
),
|
|
2194
2421
|
|
|
2422
|
+
sizeField({
|
|
2423
|
+
field: SIZE_FIELD,
|
|
2424
|
+
labelKey: "size.bodyLabel",
|
|
2425
|
+
hintKey: "size.bodyHint",
|
|
2426
|
+
value: offset,
|
|
2427
|
+
text: offsetText,
|
|
2428
|
+
}),
|
|
2429
|
+
|
|
2195
2430
|
view === "simple"
|
|
2196
2431
|
? h(SimpleFamilyField, {
|
|
2197
2432
|
t: t,
|
|
@@ -2233,35 +2468,13 @@ function FontCard(props) {
|
|
|
2233
2468
|
})
|
|
2234
2469
|
),
|
|
2235
2470
|
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
disabled: !writable,
|
|
2244
|
-
onReset: function () {
|
|
2245
|
-
resetField(SIZE_FIELD);
|
|
2246
|
-
},
|
|
2247
|
-
},
|
|
2248
|
-
h(NumberSlider, {
|
|
2249
|
-
min: SIZE_MIN,
|
|
2250
|
-
max: SIZE_MAX,
|
|
2251
|
-
value: offset,
|
|
2252
|
-
disabled: !writable,
|
|
2253
|
-
label: t("size.label"),
|
|
2254
|
-
readout: offsetText + " " + t("size.unit"),
|
|
2255
|
-
minLabel: SIZE_MIN + " " + t("size.unit"),
|
|
2256
|
-
maxLabel: "+" + SIZE_MAX + " " + t("size.unit"),
|
|
2257
|
-
pendingText: function (value) {
|
|
2258
|
-
return (value > 0 ? "+" + value : String(value)) + " " + t("size.unit");
|
|
2259
|
-
},
|
|
2260
|
-
onChange: function (value) {
|
|
2261
|
-
setField(SIZE_FIELD, value);
|
|
2262
|
-
},
|
|
2263
|
-
})
|
|
2264
|
-
),
|
|
2471
|
+
sizeField({
|
|
2472
|
+
field: CODE_SIZE_FIELD,
|
|
2473
|
+
labelKey: "size.codeLabel",
|
|
2474
|
+
hintKey: "size.codeHint",
|
|
2475
|
+
value: codeOffset,
|
|
2476
|
+
text: codeOffsetText,
|
|
2477
|
+
}),
|
|
2265
2478
|
|
|
2266
2479
|
h(
|
|
2267
2480
|
FieldShell,
|
|
@@ -2348,6 +2561,7 @@ function FontCard(props) {
|
|
|
2348
2561
|
resetField(SANS_FIELD);
|
|
2349
2562
|
resetField(MONO_FIELD);
|
|
2350
2563
|
resetField(SIZE_FIELD);
|
|
2564
|
+
resetField(CODE_SIZE_FIELD);
|
|
2351
2565
|
resetField(WEIGHT_FIELD);
|
|
2352
2566
|
},
|
|
2353
2567
|
},
|
package/lib/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import shared from "./shared.cjs";
|
|
|
22
22
|
|
|
23
23
|
const {
|
|
24
24
|
buildFontCss,
|
|
25
|
+
CODE_SIZE_FIELD,
|
|
25
26
|
FALLBACK_TOKENS,
|
|
26
27
|
MONO_FIELD,
|
|
27
28
|
NAMESPACE,
|
|
@@ -51,9 +52,9 @@ const MAX_STACK = 200;
|
|
|
51
52
|
* The durable settings section.
|
|
52
53
|
*
|
|
53
54
|
* Every field defaults to "leave DSH alone": an empty stack injects no family
|
|
54
|
-
* rule, a zero offset injects no size rule, and a zero weight
|
|
55
|
-
* weight rule. Installing the plugin therefore changes nothing until
|
|
56
|
-
* asks for something.
|
|
55
|
+
* rule, a zero offset injects no size rule on either axis, and a zero weight
|
|
56
|
+
* injects no weight rule. Installing the plugin therefore changes nothing until
|
|
57
|
+
* the user asks for something.
|
|
57
58
|
*/
|
|
58
59
|
export const Config = z.object({
|
|
59
60
|
[SANS_FIELD]: z
|
|
@@ -74,7 +75,15 @@ export const Config = z.object({
|
|
|
74
75
|
.max(SIZE_MAX)
|
|
75
76
|
.default(0)
|
|
76
77
|
.description(
|
|
77
|
-
`
|
|
78
|
+
`Body/UI font-size offset in px (${SIZE_MIN}..${SIZE_MAX}, 0 keeps DSH's own sizes)`
|
|
79
|
+
),
|
|
80
|
+
[CODE_SIZE_FIELD]: z
|
|
81
|
+
.number()
|
|
82
|
+
.min(SIZE_MIN)
|
|
83
|
+
.max(SIZE_MAX)
|
|
84
|
+
.default(0)
|
|
85
|
+
.description(
|
|
86
|
+
`Code font-size offset in px (${SIZE_MIN}..${SIZE_MAX}, 0 keeps DSH's own sizes; independent of the body offset)`
|
|
78
87
|
),
|
|
79
88
|
[WEIGHT_FIELD]: z
|
|
80
89
|
.number()
|
package/lib/shared.cjs
CHANGED
|
@@ -23,9 +23,12 @@ var SANS_FIELD = "sans";
|
|
|
23
23
|
/** Field carrying the code CSS font-family stack (empty = leave DSH alone). */
|
|
24
24
|
var MONO_FIELD = "mono";
|
|
25
25
|
|
|
26
|
-
/** Field carrying the
|
|
26
|
+
/** Field carrying the body/UI font-size offset in px (0 = leave DSH alone). */
|
|
27
27
|
var SIZE_FIELD = "sizeOffset";
|
|
28
28
|
|
|
29
|
+
/** Field carrying the code font-size offset in px (0 = leave DSH alone). */
|
|
30
|
+
var CODE_SIZE_FIELD = "sizeOffsetCode";
|
|
31
|
+
|
|
29
32
|
/** Field carrying the global font weight (0 = leave DSH alone). */
|
|
30
33
|
var WEIGHT_FIELD = "weight";
|
|
31
34
|
|
|
@@ -52,6 +55,7 @@ var DEFAULTS = {
|
|
|
52
55
|
sans: "",
|
|
53
56
|
mono: "",
|
|
54
57
|
sizeOffset: 0,
|
|
58
|
+
sizeOffsetCode: 0,
|
|
55
59
|
weight: WEIGHT_UNSET,
|
|
56
60
|
};
|
|
57
61
|
|
|
@@ -137,13 +141,12 @@ var GENERIC_FAMILIES = [
|
|
|
137
141
|
* Normalize a configuration-shaped object coming from the settings document,
|
|
138
142
|
* a config layer, or a test fixture.
|
|
139
143
|
* @param {unknown} value - candidate configuration.
|
|
140
|
-
* @returns {{sans: string, mono: string, sizeOffset: number, weight: number}} the normalized config.
|
|
144
|
+
* @returns {{sans: string, mono: string, sizeOffset: number, sizeOffsetCode: number, weight: number}} the normalized config.
|
|
141
145
|
*/
|
|
142
146
|
function normalizeConfig(value) {
|
|
143
147
|
var source = value !== null && typeof value === "object" ? value : {};
|
|
144
|
-
var size =
|
|
145
|
-
|
|
146
|
-
size = Math.round(Math.min(SIZE_MAX, Math.max(SIZE_MIN, size)));
|
|
148
|
+
var size = clampOffset(source[SIZE_FIELD]);
|
|
149
|
+
var codeSize = clampOffset(source[CODE_SIZE_FIELD]);
|
|
147
150
|
var weight = Number(source[WEIGHT_FIELD]);
|
|
148
151
|
if (!isFinite(weight)) weight = WEIGHT_UNSET;
|
|
149
152
|
weight = Math.round(weight);
|
|
@@ -154,10 +157,22 @@ function normalizeConfig(value) {
|
|
|
154
157
|
config[SANS_FIELD] = sanitize(source[SANS_FIELD]).slice(0, MAX_STACK_LENGTH);
|
|
155
158
|
config[MONO_FIELD] = sanitize(source[MONO_FIELD]).slice(0, MAX_STACK_LENGTH);
|
|
156
159
|
config[SIZE_FIELD] = size;
|
|
160
|
+
config[CODE_SIZE_FIELD] = codeSize;
|
|
157
161
|
config[WEIGHT_FIELD] = weight;
|
|
158
162
|
return config;
|
|
159
163
|
}
|
|
160
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Clamp one size offset to the allowed range, with 0 for anything unusable.
|
|
167
|
+
* @param {unknown} value - candidate offset in px.
|
|
168
|
+
* @returns {number} the offset the stylesheet may use.
|
|
169
|
+
*/
|
|
170
|
+
function clampOffset(value) {
|
|
171
|
+
var size = Number(value);
|
|
172
|
+
if (!isFinite(size)) return 0;
|
|
173
|
+
return Math.round(Math.min(SIZE_MAX, Math.max(SIZE_MIN, size)));
|
|
174
|
+
}
|
|
175
|
+
|
|
161
176
|
/**
|
|
162
177
|
* Format a family list as a CSS font-family value.
|
|
163
178
|
* @param {readonly string[]} families - family names in precedence order.
|
|
@@ -352,7 +367,7 @@ function scaleFor(sizeOffset, base) {
|
|
|
352
367
|
|
|
353
368
|
/**
|
|
354
369
|
* Whether a configuration asks for any change at all.
|
|
355
|
-
* @param {{sans: string, mono: string, sizeOffset: number, weight: number}} config - normalized config.
|
|
370
|
+
* @param {{sans: string, mono: string, sizeOffset: number, sizeOffsetCode: number, weight: number}} config - normalized config.
|
|
356
371
|
* @returns {boolean} true when nothing should be injected.
|
|
357
372
|
*/
|
|
358
373
|
function isDormant(config) {
|
|
@@ -360,6 +375,7 @@ function isDormant(config) {
|
|
|
360
375
|
config[SANS_FIELD] === "" &&
|
|
361
376
|
config[MONO_FIELD] === "" &&
|
|
362
377
|
config[SIZE_FIELD] === 0 &&
|
|
378
|
+
config[CODE_SIZE_FIELD] === 0 &&
|
|
363
379
|
config[WEIGHT_FIELD] === WEIGHT_UNSET
|
|
364
380
|
);
|
|
365
381
|
}
|
|
@@ -375,13 +391,22 @@ function isDormant(config) {
|
|
|
375
391
|
* would never inherit a plain `body` rule. The explicit `body` / `pre,code`
|
|
376
392
|
* rules stay as a second path for elements that hardcode a family.
|
|
377
393
|
*
|
|
378
|
-
* The size
|
|
394
|
+
* The size offsets rewrite DSH's own design tokens rather than every element:
|
|
379
395
|
* a token whose name ends in `-font-size` or `-line-height` is re-declared as
|
|
380
396
|
* itself multiplied by one scale factor. `baseTokens` supplies the untouched
|
|
381
397
|
* values (read from the live document, falling back to the embedded map), so
|
|
382
398
|
* the ratio composes with DSH's own font-size slider instead of replacing it.
|
|
383
399
|
*
|
|
384
|
-
*
|
|
400
|
+
* Body and code are two independent axes. Body sizes hang off the content-size
|
|
401
|
+
* chain (`--dsh-content-font-size` and the `--dsw-font-*` steps), while every
|
|
402
|
+
* markdown code token is a bare literal (`--dsw-font-markdown-code-block:
|
|
403
|
+
* 11px/19px …`) that the content chain never touches — so the code axis is the
|
|
404
|
+
* only thing that moves it, and the body axis deliberately leaves those tokens
|
|
405
|
+
* alone. Code sizing is consumed through the `font` SHORTHAND tokens (that is
|
|
406
|
+
* what the shipped stylesheets use), which is why those are re-declared too,
|
|
407
|
+
* not just their `-font-size` / `-line-height` parts.
|
|
408
|
+
*
|
|
409
|
+
* @param {{sans: string, mono: string, sizeOffset: number, sizeOffsetCode: number, weight: number}} config - normalized config.
|
|
385
410
|
* @param {Record<string, string>} [baseTokens] - token name to untouched value.
|
|
386
411
|
* @returns {string} declarations for one `<style>` element ("" when dormant).
|
|
387
412
|
*/
|
|
@@ -390,6 +415,7 @@ function buildFontCss(config, baseTokens) {
|
|
|
390
415
|
var sans = formatStack(parseStack(normalized[SANS_FIELD]));
|
|
391
416
|
var mono = formatStack(parseStack(normalized[MONO_FIELD]));
|
|
392
417
|
var offset = normalized[SIZE_FIELD];
|
|
418
|
+
var codeOffset = normalized[CODE_SIZE_FIELD];
|
|
393
419
|
var weight = normalized[WEIGHT_FIELD];
|
|
394
420
|
if (isDormant(normalized)) return "";
|
|
395
421
|
var declarations = [];
|
|
@@ -413,28 +439,17 @@ function buildFontCss(config, baseTokens) {
|
|
|
413
439
|
);
|
|
414
440
|
}
|
|
415
441
|
if (offset !== 0) {
|
|
416
|
-
var
|
|
417
|
-
var names = tokenNames(baseTokens);
|
|
418
|
-
var scaled = [];
|
|
419
|
-
for (var index = 0; index < names.length; index += 1) {
|
|
420
|
-
var name = names[index];
|
|
421
|
-
var base = baseTokens[name];
|
|
422
|
-
if (typeof base !== "string" || base === "") continue;
|
|
423
|
-
// A base that itself references another token via var() derives from it:
|
|
424
|
-
// scaling the var target already scales this one, so re-scaling here
|
|
425
|
-
// would compound (markdown-base = var(--dsh-content-font-size) would
|
|
426
|
-
// take the ratio twice). DSH's chain does the work instead.
|
|
427
|
-
if (base.indexOf("var(") !== -1) continue;
|
|
428
|
-
// !important: the theme writes `--dsh-content-font-size` INLINE on body,
|
|
429
|
-
// and an inline declaration outranks a plain stylesheet one — without
|
|
430
|
-
// the flag body itself would keep DSH's own size while every descendant
|
|
431
|
-
// scales, splitting the page in two.
|
|
432
|
-
scaled.push(name + ":calc((" + base + ") * " + scale + ") !important");
|
|
433
|
-
}
|
|
442
|
+
var scaled = scaleTokens(bodyTokenNames(baseTokens), baseTokens, round(scaleFor(offset), 6));
|
|
434
443
|
if (scaled.length > 0) {
|
|
435
444
|
declarations.push(bodyAndDescendants(scaled.join(";")));
|
|
436
445
|
}
|
|
437
446
|
}
|
|
447
|
+
if (codeOffset !== 0) {
|
|
448
|
+
var scaledCode = scaleCodeTokens(baseTokens, round(scaleFor(codeOffset), 6));
|
|
449
|
+
if (scaledCode.length > 0) {
|
|
450
|
+
declarations.push(bodyAndDescendants(scaledCode.join(";")));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
438
453
|
if (weight !== WEIGHT_UNSET) {
|
|
439
454
|
// Written as the user chose it: a variable font honors every integer, and
|
|
440
455
|
// a static one rounds to its own nearest step by itself.
|
|
@@ -443,6 +458,109 @@ function buildFontCss(config, baseTokens) {
|
|
|
443
458
|
return declarations.join("\n");
|
|
444
459
|
}
|
|
445
460
|
|
|
461
|
+
/**
|
|
462
|
+
* Values a ratio may multiply: a number with a unit, a bare number, or an
|
|
463
|
+
* expression. A keyword (`unset`, `inherit`) or an unrecognized shape is left
|
|
464
|
+
* alone instead of being wrapped into an invalid `calc()`.
|
|
465
|
+
*/
|
|
466
|
+
var SCALABLE_VALUE = /^(?:[+-]?(?:\d|\.\d)|calc\(|var\(|min\(|max\(|clamp\()/;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Whether one token value can be multiplied by a scale factor.
|
|
470
|
+
* @param {string} value - the token's untouched value.
|
|
471
|
+
* @returns {boolean} true when `calc((value) * scale)` is meaningful.
|
|
472
|
+
*/
|
|
473
|
+
function isScalableValue(value) {
|
|
474
|
+
return typeof value === "string" && SCALABLE_VALUE.test(value.trim());
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Scale one set of tokens by one ratio.
|
|
479
|
+
*
|
|
480
|
+
* A base that itself references another token via var() derives from it:
|
|
481
|
+
* scaling the var target already scales this one, so re-scaling here would
|
|
482
|
+
* compound (markdown-base = var(--dsh-content-font-size) would take the ratio
|
|
483
|
+
* twice). DSH's chain does the work instead.
|
|
484
|
+
*
|
|
485
|
+
* `!important` is required: the theme writes `--dsh-content-font-size` INLINE on
|
|
486
|
+
* body, and an inline declaration outranks a plain stylesheet one — without the
|
|
487
|
+
* flag body itself would keep DSH's own size while every descendant scales,
|
|
488
|
+
* splitting the page in two.
|
|
489
|
+
*
|
|
490
|
+
* @param {string[]} names - token names to re-declare.
|
|
491
|
+
* @param {Record<string, string>} baseTokens - token name to untouched value.
|
|
492
|
+
* @param {number} scale - the ratio to apply.
|
|
493
|
+
* @returns {string[]} declarations.
|
|
494
|
+
*/
|
|
495
|
+
function scaleTokens(names, baseTokens, scale) {
|
|
496
|
+
var out = [];
|
|
497
|
+
for (var index = 0; index < names.length; index += 1) {
|
|
498
|
+
var name = names[index];
|
|
499
|
+
var base = baseTokens[name];
|
|
500
|
+
if (typeof base !== "string" || base === "") continue;
|
|
501
|
+
if (base.indexOf("var(") !== -1) continue;
|
|
502
|
+
if (!isScalableValue(base)) continue;
|
|
503
|
+
out.push(name + ":calc((" + base + ") * " + scale + ") !important");
|
|
504
|
+
}
|
|
505
|
+
return out;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Re-declare the markdown code tokens at their own ratio.
|
|
510
|
+
*
|
|
511
|
+
* Two shapes exist and both must be covered, because the shipped stylesheets
|
|
512
|
+
* consume the shorthand (`font: var(--dsw-font-markdown-code-block-small)`)
|
|
513
|
+
* while the split tokens exist for anything that asks for a single part:
|
|
514
|
+
* `11px/19px <family>` and a bare `11px`.
|
|
515
|
+
*
|
|
516
|
+
* @param {Record<string, string>} baseTokens - token name to untouched value.
|
|
517
|
+
* @param {number} scale - the ratio to apply.
|
|
518
|
+
* @returns {string[]} declarations.
|
|
519
|
+
*/
|
|
520
|
+
function scaleCodeTokens(baseTokens, scale) {
|
|
521
|
+
var names = codeTokenNames(baseTokens);
|
|
522
|
+
var out = [];
|
|
523
|
+
for (var index = 0; index < names.length; index += 1) {
|
|
524
|
+
var name = names[index];
|
|
525
|
+
var base = baseTokens[name];
|
|
526
|
+
if (typeof base !== "string" || base === "") continue;
|
|
527
|
+
var shorthand = scaleFontShorthand(base, scale);
|
|
528
|
+
if (shorthand !== null) {
|
|
529
|
+
out.push(name + ":" + shorthand + " !important");
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
532
|
+
// A part token that derives from another token follows that token's own
|
|
533
|
+
// scaling; re-declaring it here would compound the ratio.
|
|
534
|
+
if (base.indexOf("var(") !== -1) continue;
|
|
535
|
+
if (!isScalableValue(base)) continue;
|
|
536
|
+
out.push(name + ":calc((" + base + ") * " + scale + ") !important");
|
|
537
|
+
}
|
|
538
|
+
return out;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Multiply the size and the line height inside one `font` shorthand value,
|
|
543
|
+
* leaving the family list (and anything else after it) untouched.
|
|
544
|
+
* @param {string} value - a value shaped like `11px/19px var(--ds-font-family-code)`.
|
|
545
|
+
* @param {number} scale - the ratio to apply.
|
|
546
|
+
* @returns {string|null} the scaled shorthand, or null when the shape differs.
|
|
547
|
+
*/
|
|
548
|
+
function scaleFontShorthand(value, scale) {
|
|
549
|
+
var slash = value.indexOf("/");
|
|
550
|
+
if (slash <= 0) return null;
|
|
551
|
+
var size = value.slice(0, slash).trim();
|
|
552
|
+
var rest = value.slice(slash + 1).trim();
|
|
553
|
+
var gap = rest.search(/\s/);
|
|
554
|
+
if (gap <= 0) return null;
|
|
555
|
+
var height = rest.slice(0, gap).trim();
|
|
556
|
+
var family = rest.slice(gap + 1).trim();
|
|
557
|
+
if (size === "" || height === "" || family === "") return null;
|
|
558
|
+
if (!isScalableValue(size) || !isScalableValue(height)) return null;
|
|
559
|
+
return (
|
|
560
|
+
"calc((" + size + ") * " + scale + ")/calc((" + height + ") * " + scale + ") " + family
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
|
|
446
564
|
/**
|
|
447
565
|
* Match DSH's typography tokens: the design system's sizes plus the content
|
|
448
566
|
* size the theme plugin writes on `body` (whose secondary variant carries a
|
|
@@ -474,6 +592,30 @@ function isFontToken(name) {
|
|
|
474
592
|
return typeof name === "string" && TOKEN_PATTERN.test(name);
|
|
475
593
|
}
|
|
476
594
|
|
|
595
|
+
/**
|
|
596
|
+
* Match DSH's markdown code tokens, which are their own sizing axis.
|
|
597
|
+
*
|
|
598
|
+
* The theme declares these as literals the content-size chain never reaches
|
|
599
|
+
* (`--dsw-font-markdown-code:12px/19px …`, `-code-block:11px/19px …`,
|
|
600
|
+
* `-code-block-small:11px/16px …`), and the shipped stylesheets consume them
|
|
601
|
+
* through the `font` shorthand. Everything with this prefix therefore belongs
|
|
602
|
+
* to the code offset and to nothing else.
|
|
603
|
+
* @param {string} name - custom property name including the leading dashes.
|
|
604
|
+
* @returns {boolean} true when the token sizes code.
|
|
605
|
+
*/
|
|
606
|
+
function isCodeToken(name) {
|
|
607
|
+
return typeof name === "string" && name.indexOf("--dsw-font-markdown-code") === 0;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Whether a token is one this plugin re-declares at all.
|
|
612
|
+
* @param {string} name - custom property name including the leading dashes.
|
|
613
|
+
* @returns {boolean} true for body sizes, body line heights and code tokens.
|
|
614
|
+
*/
|
|
615
|
+
function isScaledToken(name) {
|
|
616
|
+
return isFontToken(name) || isCodeToken(name);
|
|
617
|
+
}
|
|
618
|
+
|
|
477
619
|
/**
|
|
478
620
|
* Ordered token names present in a base map, sizes before line heights so a
|
|
479
621
|
* reader of the stylesheet sees each size next to its height.
|
|
@@ -482,7 +624,7 @@ function isFontToken(name) {
|
|
|
482
624
|
*/
|
|
483
625
|
function tokenNames(baseTokens) {
|
|
484
626
|
if (baseTokens === null || typeof baseTokens !== "object") return [];
|
|
485
|
-
var names = Object.keys(baseTokens).filter(
|
|
627
|
+
var names = Object.keys(baseTokens).filter(isScaledToken);
|
|
486
628
|
names.sort(function (left, right) {
|
|
487
629
|
if (left.length !== right.length) return left.length - right.length;
|
|
488
630
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
@@ -490,6 +632,28 @@ function tokenNames(baseTokens) {
|
|
|
490
632
|
return names;
|
|
491
633
|
}
|
|
492
634
|
|
|
635
|
+
/**
|
|
636
|
+
* The body/UI tokens: everything this plugin scales except the code family,
|
|
637
|
+
* which answers to its own offset.
|
|
638
|
+
* @param {Record<string, string>} [baseTokens] - token name to value.
|
|
639
|
+
* @returns {string[]} the names the body offset re-declares.
|
|
640
|
+
*/
|
|
641
|
+
function bodyTokenNames(baseTokens) {
|
|
642
|
+
return tokenNames(baseTokens).filter(function (name) {
|
|
643
|
+
return !isCodeToken(name);
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* The code tokens: the `font` shorthands plus their `-font-size` /
|
|
649
|
+
* `-line-height` parts, when the live stylesheets declare them.
|
|
650
|
+
* @param {Record<string, string>} [baseTokens] - token name to value.
|
|
651
|
+
* @returns {string[]} the names the code offset re-declares.
|
|
652
|
+
*/
|
|
653
|
+
function codeTokenNames(baseTokens) {
|
|
654
|
+
return tokenNames(baseTokens).filter(isCodeToken);
|
|
655
|
+
}
|
|
656
|
+
|
|
493
657
|
/**
|
|
494
658
|
* Embedded fallback for the tokens the theme plugin defines at runtime.
|
|
495
659
|
*
|
|
@@ -537,12 +701,18 @@ var FALLBACK_TOKENS = {
|
|
|
537
701
|
"--dsw-font-markdown-h3-line-height": "26px",
|
|
538
702
|
"--dsw-font-markdown-h4-font-size": "15px",
|
|
539
703
|
"--dsw-font-markdown-h4-line-height": "24px",
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
"--dsw-font-markdown-code
|
|
543
|
-
"--dsw-font-markdown-code-
|
|
544
|
-
"--dsw-font-markdown-code-
|
|
545
|
-
"--dsw-font-markdown-code-block
|
|
704
|
+
// The code family is consumed through the `font` shorthand, so the shorthand
|
|
705
|
+
// names matter more than their parts — both are listed, at rc.2's values.
|
|
706
|
+
"--dsw-font-markdown-code": "12px/19px var(--ds-font-family-code)",
|
|
707
|
+
"--dsw-font-markdown-code-font-size": "12px",
|
|
708
|
+
"--dsw-font-markdown-code-line-height": "19px",
|
|
709
|
+
"--dsw-font-markdown-code-block": "11px/19px var(--ds-font-family-code)",
|
|
710
|
+
"--dsw-font-markdown-code-block": "11px/19px var(--ds-font-family-code)",
|
|
711
|
+
"--dsw-font-markdown-code-block-font-size": "11px",
|
|
712
|
+
"--dsw-font-markdown-code-block-line-height": "19px",
|
|
713
|
+
"--dsw-font-markdown-code-block-small": "11px/16px var(--ds-font-family-code)",
|
|
714
|
+
"--dsw-font-markdown-code-block-small-font-size": "11px",
|
|
715
|
+
"--dsw-font-markdown-code-block-small-line-height": "16px",
|
|
546
716
|
"--dsw-font-markdown-table-font-size": "13px",
|
|
547
717
|
"--dsw-font-markdown-table-line-height": "22px",
|
|
548
718
|
"--dsh-content-font-size": "14px",
|
|
@@ -629,6 +799,7 @@ var shared = {
|
|
|
629
799
|
SANS_FIELD: SANS_FIELD,
|
|
630
800
|
MONO_FIELD: MONO_FIELD,
|
|
631
801
|
SIZE_FIELD: SIZE_FIELD,
|
|
802
|
+
CODE_SIZE_FIELD: CODE_SIZE_FIELD,
|
|
632
803
|
WEIGHT_FIELD: WEIGHT_FIELD,
|
|
633
804
|
SIZE_MIN: SIZE_MIN,
|
|
634
805
|
SIZE_MAX: SIZE_MAX,
|
|
@@ -653,6 +824,11 @@ var shared = {
|
|
|
653
824
|
isDormant: isDormant,
|
|
654
825
|
buildFontCss: buildFontCss,
|
|
655
826
|
isFontToken: isFontToken,
|
|
827
|
+
isCodeToken: isCodeToken,
|
|
828
|
+
isScaledToken: isScaledToken,
|
|
829
|
+
codeTokenNames: codeTokenNames,
|
|
830
|
+
bodyTokenNames: bodyTokenNames,
|
|
831
|
+
scaleFontShorthand: scaleFontShorthand,
|
|
656
832
|
isGenericFamilyName: isGenericFamilyName,
|
|
657
833
|
isCJKFamilyName: isCJKFamilyName,
|
|
658
834
|
setWestEntry: setWestEntry,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-fonttune",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Font plugin for the DeepSeek Harness Web GUI: body and code font families, a
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Font plugin for the DeepSeek Harness Web GUI: body and code font families, a separate font-size offset for each, a global font weight, and a West/CJK split picker.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|