@klarkxy/dsh-font 0.2.2 → 0.2.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/lib/client.js CHANGED
@@ -16,9 +16,27 @@ const PLUGIN_NAME = "@klarkxy/dsh-font";
16
16
  /** Legacy browser-local font choices, retained as the one-time migration backup.
17
17
  * The active panel reads and writes the host's role-specific preferences. */
18
18
  const STORAGE_KEY = "klarkxy.dsh-font.v1";
19
- /** Root font overrides reach derived Markdown, brand and terminal fonts.
20
- * These are the host variables this feature changes, rather than a private
21
- * palette used to style the plugin's settings page. */
19
+ const FONT_SIZE_SPECS = {
20
+ text: {
21
+ min: 10,
22
+ max: 22,
23
+ default: 14
24
+ },
25
+ code: {
26
+ min: 10,
27
+ max: 16,
28
+ default: 11
29
+ },
30
+ terminal: {
31
+ min: 10,
32
+ max: 20,
33
+ default: 13
34
+ }
35
+ };
36
+ /** Root font variables the legacy local-storage model overrode directly:
37
+ * derived Markdown and brand fonts follow the interface variable. Kept as
38
+ * migration data for the pre-theme-service storage; live writes now go
39
+ * through theme.setFontFamily per role instead. */
22
40
  const UI_FONT_VARIABLE = "--dsw-font-family";
23
41
  /** The host's un-themed interface fallback, referenced when rebuilding the
24
42
  * body's font stack under the conversation scope. */
@@ -32,8 +50,9 @@ function cssVar(name) {
32
50
  /** The host wraps message scroll and composer inside one chat region; it is
33
51
  * the scope for the Obsidian-style third font kind. */
34
52
  const CONVERSATION_FONT_SELECTOR = "[data-conversation-region=\"chat\"]";
35
- /** Browser-local conversation stack: the host persists only its text/code
36
- * roles, so this third kind keeps its own key in the same storage. */
53
+ /** Browser-local conversation stack: the host persists its own three roles
54
+ * (text/code/terminal), while the plugin-owned conversation kind keeps this
55
+ * separate key in the same storage. */
37
56
  const CONVERSATION_STORAGE_KEY = "klarkxy.dsh-font.conversation.v1";
38
57
  function defaultFontSettings() {
39
58
  return {
@@ -762,6 +781,77 @@ ${scope} {
762
781
  `.replace(/^& (\.dsh-ui-[a-z0-9-]+)(?=\s*\{)/gm, (_match, className) => `&${className}, & ${className}`);
763
782
  }
764
783
  //#endregion
784
+ //#region ../dsh-plugin-kit/src/contracts.ts
785
+ /** `@klarkxy/dsh-git-commit` becomes `KlarkxyDshGitCommitModelSettingsChanges`. */
786
+ function modelSettingsChangesIdentity(packageName) {
787
+ const scoped = /^@([^/]+)\/(.+)$/.exec(packageName);
788
+ const parts = (scoped ? `${scoped[1]}/${scoped[2]}` : packageName).split(/[^A-Za-z0-9]+/).filter(Boolean);
789
+ if (!parts.length) throw new Error("Model settings package name has no RPC segment");
790
+ const segment = `${parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}ModelSettingsChanges`;
791
+ if (!/^[A-Z][A-Za-z0-9]*$/.test(segment)) throw new Error(`Model settings sync name is not an RPC segment: ${segment}`);
792
+ return {
793
+ service: segment,
794
+ namespace: segment
795
+ };
796
+ }
797
+ /**
798
+ * Host-owned nav icon seat: a root-scoped list where each entry's `id` must
799
+ * equal the `settings.section` id it decorates. Owner props are
800
+ * `{size, active}`; icons stay `aria-hidden` so the section label remains the
801
+ * accessible name. Contributors into a shared section may register the same
802
+ * icon `id` with different priorities — the ledger keeps every entry while the
803
+ * host renders one icon per section.
804
+ */
805
+ const SETTINGS_SECTION_ICON_SLOT = "settings.section.icon";
806
+ modelSettingsChangesIdentity("@klarkxy/dsh-plugin-kit");
807
+ //#endregion
808
+ //#region ../dsh-plugin-kit/src/client-utils.ts
809
+ /** One `<svg>` with the shared icon chrome; children are plain elements. */
810
+ function lineIcon(children) {
811
+ return function SettingsSectionIcon(props) {
812
+ return (0, react.createElement)("svg", {
813
+ "aria-hidden": "true",
814
+ width: props.size ?? 16,
815
+ height: props.size ?? 16,
816
+ viewBox: "0 0 16 16",
817
+ fill: "none",
818
+ stroke: "currentColor",
819
+ strokeWidth: 1,
820
+ strokeLinecap: "round",
821
+ strokeLinejoin: "round"
822
+ }, ...children.map(([tag, attrs], index) => (0, react.createElement)(tag, {
823
+ key: index,
824
+ ...attrs
825
+ })));
826
+ };
827
+ }
828
+ /** Serif-flavoured letter A for the Font section. */
829
+ const IconFontSettings = lineIcon([
830
+ ["path", { d: "M3.3 12.6 7.9 3.1a.5.5 0 0 1 .9 0l4.6 9.5" }],
831
+ ["path", { d: "M5.2 9.4h6.3" }],
832
+ ["path", { d: "M2.4 12.6h2.4" }],
833
+ ["path", { d: "M11.9 12.6h2.4" }]
834
+ ]);
835
+ /**
836
+ * Contribute the nav icon of a `settings.section` entry. The `settings
837
+ * .section.icon` seat is declared by the host independently of the section
838
+ * list, so the wait runs in parallel: the icon appears as soon as both seats
839
+ * exist and unloading removes it again, restoring the host's default glyph.
840
+ * The `id` must equal the section id; `order`/`priority` mirror `order` so the
841
+ * icon cell sorts like its section and, for shared sections, several
842
+ * contributors can register the same icon id under different priorities
843
+ * without duplicating nav entries.
844
+ */
845
+ function registerSettingsSectionIcon(ctx, sectionId, order, component) {
846
+ const slots = ctx.slots;
847
+ return slots.inject(SETTINGS_SECTION_ICON_SLOT, () => slots.register({
848
+ name: SETTINGS_SECTION_ICON_SLOT,
849
+ id: sectionId,
850
+ order,
851
+ priority: order
852
+ }, component));
853
+ }
854
+ //#endregion
765
855
  //#region src/client.tsx
766
856
  const name = "dsh-font-client";
767
857
  const inject = [
@@ -775,18 +865,27 @@ const COPY = {
775
865
  uiFont: "界面字体",
776
866
  conversationFont: "对话字体",
777
867
  codeFont: "代码字体",
778
- fontSize: "会话字号",
868
+ terminalFont: "终端字体",
869
+ textSize: "字号大小",
870
+ textSizeHelp: "仅影响会话内容的字号",
871
+ codeSize: "代码字号",
872
+ codeSizeHelp: "用于代码块、行内代码与工具输出",
873
+ terminalSize: "终端字号",
874
+ terminalSizeHelp: "用于侧栏终端",
875
+ increaseSize: (label) => `增大${label}`,
876
+ decreaseSize: (label) => `减小${label}`,
877
+ sizeUnit: "px",
779
878
  defaultOption: "默认",
780
879
  followUi: "跟随界面字体",
781
- sameAsUi: "同界面",
782
880
  customOption: "自定义…",
783
881
  customUiPlaceholder: "例如 \"Microsoft YaHei\", sans-serif",
784
882
  customConversationPlaceholder: "例如 \"Source Han Serif SC\", serif",
785
883
  customCodePlaceholder: "例如 \"JetBrains Mono\", monospace",
884
+ customTerminalPlaceholder: "例如 \"Cascadia Mono\", monospace",
786
885
  uiHelp: "作用于整个界面的文字,对话字体跟随它时也包括对话区。自定义时输入完整的 font-family 字体栈,留空恢复默认。",
787
886
  conversationHelp: "作用于对话区的消息和输入框,适合为长文单独选择字体(如衬线体)。仅保存在当前浏览器。",
788
- codeHelp: "作用于代码块与行内代码。终端字体和字号可在「设置 → 通用」中单独调整。",
789
- sizeHelp: "与「设置 → 通用」中的字号同步,范围 10–22。",
887
+ codeHelp: "作用于代码块、行内代码与工具输出。",
888
+ terminalHelp: "作用于侧栏终端,与代码字体独立。",
790
889
  loadFonts: "读取系统字体",
791
890
  reloadFonts: "重新读取系统字体",
792
891
  loadingFonts: "正在读取系统字体…",
@@ -794,27 +893,35 @@ const COPY = {
794
893
  fontsPartial: "列表来自浏览器枚举:仅安装到当前用户的字体可能不在其中,可以直接输入字体名使用。",
795
894
  fontsDenied: "系统字体读取被拒绝或当前环境不支持,仍可手动输入字体名。",
796
895
  systemGroup: "系统字体",
797
- reset: "全部恢复默认",
798
- summary: (ui, conv, code, size) => `界面 ${ui} · 对话 ${conv} · 代码 ${code} · ${size}px`,
799
- defaultName: "默认"
896
+ resetFonts: "恢复默认字体",
897
+ resetSizes: "恢复默认字号"
800
898
  },
801
899
  en: {
802
900
  label: "Font",
803
901
  uiFont: "Interface font",
804
902
  conversationFont: "Conversation font",
805
903
  codeFont: "Code font",
806
- fontSize: "Conversation font size",
904
+ terminalFont: "Terminal font",
905
+ textSize: "Font size",
906
+ textSizeHelp: "Only affects conversation content",
907
+ codeSize: "Code font size",
908
+ codeSizeHelp: "Used for code blocks, inline code, and tool output",
909
+ terminalSize: "Terminal font size",
910
+ terminalSizeHelp: "Used for the sidebar terminal",
911
+ increaseSize: (label) => `Increase ${label.toLowerCase()}`,
912
+ decreaseSize: (label) => `Decrease ${label.toLowerCase()}`,
913
+ sizeUnit: "px",
807
914
  defaultOption: "Default",
808
915
  followUi: "Same as interface font",
809
- sameAsUi: "Same as UI",
810
916
  customOption: "Custom…",
811
917
  customUiPlaceholder: "e.g. \"Microsoft YaHei\", sans-serif",
812
918
  customConversationPlaceholder: "e.g. \"Source Han Serif SC\", serif",
813
919
  customCodePlaceholder: "e.g. \"JetBrains Mono\", monospace",
920
+ customTerminalPlaceholder: "e.g. \"Cascadia Mono\", monospace",
814
921
  uiHelp: "Applies to all interface text, including the conversation while the conversation font follows it. For a custom value enter a full font-family stack; empty restores the default.",
815
922
  conversationHelp: "Applies to messages and the input box in the conversation, e.g. a serif face for long text. Saved in this browser only.",
816
- codeHelp: "Applies to code blocks and inline code. Adjust terminal font and size separately in Settings → General.",
817
- sizeHelp: "Synced with Settings → General; 10–22 px.",
923
+ codeHelp: "Applies to code blocks, inline code, and tool output.",
924
+ terminalHelp: "Applies to the sidebar terminal, independent of the code font.",
818
925
  loadFonts: "Load system fonts",
819
926
  reloadFonts: "Reload system fonts",
820
927
  loadingFonts: "Loading system fonts…",
@@ -822,16 +929,38 @@ const COPY = {
822
929
  fontsPartial: "The list comes from the browser’s enumeration: fonts installed only for the current user may be missing — you can still type the family name directly.",
823
930
  fontsDenied: "Access to system fonts was denied or is unsupported here; you can still type a font name.",
824
931
  systemGroup: "Installed fonts",
825
- reset: "Reset all to defaults",
826
- summary: (ui, conv, code, size) => `${ui} · ${conv} · ${code} · ${size}px`,
827
- defaultName: "Default"
932
+ resetFonts: "Reset fonts",
933
+ resetSizes: "Reset font sizes"
828
934
  }
829
935
  };
830
936
  function fontCopy(locale) {
831
937
  return COPY[locale];
832
938
  }
833
939
  const styles = `${officialUiCss("font-root")}
834
- .font-root .font-custom { margin-top: 8px; }
940
+ .font-root .font-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 16px 0; border-bottom: 0.5px solid var(--dsw-alias-border-l2); }
941
+ .font-root .font-row-text { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-right: 40px; }
942
+ .font-root .font-row-title { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }
943
+ .font-root .font-row-desc { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
944
+ .font-root .font-row-control { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
945
+ .font-root .font-select { flex: 0 1 240px; width: auto; }
946
+ .font-root .font-custom { flex: 1 1 100%; }
947
+ .font-root .font-stepper { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; height: 36px; position: relative; border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-module-platform); }
948
+ .font-root .font-stepper-value { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }
949
+ .font-root .font-stepper-unit { font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-secondary); }
950
+ .font-root .font-stepper-arrows { position: absolute; right: 8px; display: flex; flex-direction: column; gap: 2px; opacity: 0; }
951
+ .font-root .font-stepper:focus-within .font-stepper-arrows { opacity: 1; }
952
+ @media (hover:hover) { .font-root .font-stepper:hover .font-stepper-arrows { opacity: 1; } }
953
+ @media (hover:none) { .font-root .font-stepper-arrows { opacity: 1; } }
954
+ .font-root .font-stepper-arrow { width: 17px; height: 12px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: var(--dsw-radius-sm); background: color-mix(in srgb, var(--dsw-alias-bg-layer-1) 75%, transparent); color: var(--dsw-alias-label-primary); cursor: pointer; }
955
+ @media (hover:hover) { .font-root .font-stepper-arrow:hover:not(:disabled) { background: var(--dsw-alias-bg-layer-1); } }
956
+ .font-root .font-stepper-arrow:disabled { color: var(--dsw-alias-label-caption); cursor: default; }
957
+ /* The last row keeps the hairline off the page's bottom edge, mirroring the
958
+ * host's own last-child rule inside a settings column. */
959
+ .font-root > :last-child, .font-root > :last-child > :last-child { border-bottom: none; }
960
+ @media (max-width: 767px) {
961
+ .font-root .font-row-text { padding-right: 16px; }
962
+ .font-root .font-select { flex: 0 1 auto; width: 240px; max-width: 100%; }
963
+ }
835
964
  `;
836
965
  function readStorage() {
837
966
  try {
@@ -844,13 +973,14 @@ function useLocale(client) {
844
973
  const getSnapshot = () => client.locale.getSnapshot().active.toLowerCase().startsWith("zh") ? "zh" : "en";
845
974
  return (0, react.useSyncExternalStore)((fn) => client.locale.subscribe(fn), getSnapshot, getSnapshot);
846
975
  }
847
- function useFontSize(client) {
848
- return (0, react.useSyncExternalStore)((fn) => client.on("theme/change", () => fn()), () => client.theme.getTheme().fontSizes.text, () => client.theme.getTheme().fontSizes.text);
849
- }
850
976
  function presetMode(value, presets) {
851
977
  return presetFor(value, presets)?.id ?? (value ? "custom" : "");
852
978
  }
979
+ /** One font-family row in the native compact shape: title and description on
980
+ * the left, a preset picker on the trailing edge, the custom stack input
981
+ * wrapping to a full line when the picker is on Custom. */
853
982
  function FontField(props) {
983
+ const labelId = (0, react.useId)();
854
984
  const [draft, setDraft] = (0, react.useState)(void 0);
855
985
  const [customOpen, setCustomOpen] = (0, react.useState)(false);
856
986
  const mode = customOpen ? "custom" : presetMode(props.value, props.presets);
@@ -861,82 +991,149 @@ function FontField(props) {
861
991
  if (!next) setCustomOpen(false);
862
992
  if (next !== props.value) props.onCommit(next);
863
993
  }
864
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
865
- className: "dsh-ui-field",
994
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
995
+ className: "font-row",
866
996
  children: [
867
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
868
- className: "dsh-ui-label",
869
- children: props.label
997
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
998
+ className: "font-row-text",
999
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1000
+ className: "font-row-title",
1001
+ id: labelId,
1002
+ children: props.label
1003
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1004
+ className: "font-row-desc",
1005
+ children: props.help
1006
+ })]
870
1007
  }),
871
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
872
- className: "dsh-ui-select",
873
- value: mode,
874
- onChange: (event) => {
875
- const id = event.target.value;
876
- setDraft(void 0);
877
- if (id === "custom") {
878
- setCustomOpen(true);
879
- return;
880
- }
881
- setCustomOpen(false);
882
- if (id.startsWith("sys:")) {
883
- props.onCommit(fontStackFor(id.slice(4), props.generic));
884
- return;
885
- }
886
- const preset = props.presets.find((item) => item.id === id);
887
- props.onCommit(preset ? preset.value : "");
888
- },
889
- children: [
890
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
891
- value: "",
892
- children: props.defaultLabel
893
- }),
894
- props.presets.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
895
- value: preset.id,
896
- children: preset.label[props.locale]
897
- }, preset.id)),
898
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
899
- value: "custom",
900
- children: props.customLabel
901
- }),
902
- props.systemFonts && props.systemFonts.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("optgroup", {
903
- label: props.systemGroupLabel,
904
- children: props.systemFonts.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
905
- value: `sys:${item.family}`,
906
- children: systemFontLabel(item, props.locale)
907
- }, item.family))
908
- }) : null
909
- ]
1008
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1009
+ className: "font-row-control",
1010
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1011
+ className: "dsh-ui-select font-select",
1012
+ "aria-labelledby": labelId,
1013
+ value: mode,
1014
+ onChange: (event) => {
1015
+ const id = event.target.value;
1016
+ setDraft(void 0);
1017
+ if (id === "custom") {
1018
+ setCustomOpen(true);
1019
+ return;
1020
+ }
1021
+ setCustomOpen(false);
1022
+ if (id.startsWith("sys:")) {
1023
+ props.onCommit(fontStackFor(id.slice(4), props.generic));
1024
+ return;
1025
+ }
1026
+ const preset = props.presets.find((item) => item.id === id);
1027
+ props.onCommit(preset ? preset.value : "");
1028
+ },
1029
+ children: [
1030
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1031
+ value: "",
1032
+ children: props.defaultLabel
1033
+ }),
1034
+ props.presets.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1035
+ value: preset.id,
1036
+ children: preset.label[props.locale]
1037
+ }, preset.id)),
1038
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1039
+ value: "custom",
1040
+ children: props.customLabel
1041
+ }),
1042
+ props.systemFonts && props.systemFonts.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("optgroup", {
1043
+ label: props.systemGroupLabel,
1044
+ children: props.systemFonts.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1045
+ value: `sys:${item.family}`,
1046
+ children: systemFontLabel(item, props.locale)
1047
+ }, item.family))
1048
+ }) : null
1049
+ ]
1050
+ })
910
1051
  }),
911
1052
  mode === "custom" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
912
1053
  className: "font-custom",
913
1054
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
914
1055
  value: draft ?? props.value,
915
1056
  placeholder: props.customPlaceholder,
1057
+ "aria-label": props.label,
916
1058
  onChange: (event) => setDraft(event.target.value),
917
1059
  onBlur: commitDraft,
918
1060
  onKeyDown: (event) => {
919
1061
  if (event.key === "Enter") commitDraft();
920
1062
  }
921
1063
  })
922
- }) : null,
923
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
924
- className: "dsh-ui-help",
925
- children: props.help
926
- })
1064
+ }) : null
927
1065
  ]
928
1066
  });
929
1067
  }
930
- function FontSettingsPanel(props) {
1068
+ /** One font-size row in the native stepper shape: title and description on the
1069
+ * left, a pill holding the centered value with a hover/focus-revealed up/down
1070
+ * arrow column, and the px unit label after it. The displayed value follows
1071
+ * the persisted setting through the theme service, never the click echo, and
1072
+ * the arrows clamp at the role's host bounds instead of asking the service to
1073
+ * reject an out-of-range write. */
1074
+ function FontSizeField(props) {
1075
+ const labelId = (0, react.useId)();
1076
+ const { min, max } = FONT_SIZE_SPECS[props.role];
1077
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1078
+ className: "font-row",
1079
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1080
+ className: "font-row-text",
1081
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1082
+ className: "font-row-title",
1083
+ id: labelId,
1084
+ children: props.label
1085
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1086
+ className: "font-row-desc",
1087
+ children: props.help
1088
+ })]
1089
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1090
+ className: "font-row-control",
1091
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1092
+ className: "font-stepper",
1093
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1094
+ className: "font-stepper-value",
1095
+ "aria-labelledby": labelId,
1096
+ children: props.value
1097
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1098
+ className: "font-stepper-arrows",
1099
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1100
+ type: "button",
1101
+ className: "font-stepper-arrow",
1102
+ "aria-label": props.increaseLabel,
1103
+ disabled: props.value >= max,
1104
+ onClick: () => props.onCommit(props.role, props.value + 1),
1105
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronUpOutlineRegular, { size: 9 })
1106
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1107
+ type: "button",
1108
+ className: "font-stepper-arrow",
1109
+ "aria-label": props.decreaseLabel,
1110
+ disabled: props.value <= min,
1111
+ onClick: () => props.onCommit(props.role, props.value - 1),
1112
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { size: 9 })
1113
+ })]
1114
+ })]
1115
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1116
+ className: "font-stepper-unit",
1117
+ children: props.unit
1118
+ })]
1119
+ })]
1120
+ });
1121
+ }
1122
+ /** The plugin's own settings page (Settings → Font): every font control in one
1123
+ * column — interface family, conversation family + content size, code family +
1124
+ * size, terminal family + size — followed by the shared actions. It writes the
1125
+ * same theme service entries the native General font-size cell uses, so sizes
1126
+ * and families stay in sync with any other writer (keyboard zoom included). */
1127
+ function FontSettingsGroup(props) {
931
1128
  const locale = useLocale(props.client);
932
1129
  const text = COPY[locale];
933
- const families = (0, react.useSyncExternalStore)((fn) => props.client.on("theme/change", () => fn()), () => props.client.theme.getTheme().fontFamilies, () => props.client.theme.getTheme().fontFamilies);
1130
+ const snapshot = (0, react.useSyncExternalStore)((fn) => props.client.on("theme/change", () => fn()), () => props.client.theme.getTheme(), () => props.client.theme.getTheme());
934
1131
  const settings = {
935
- uiFont: families.text,
936
- codeFont: families.code
1132
+ uiFont: snapshot.fontFamilies.text,
1133
+ codeFont: snapshot.fontFamilies.code
937
1134
  };
1135
+ const terminalFont = snapshot.fontFamilies.terminal;
938
1136
  const conversationFont = (0, react.useSyncExternalStore)((fn) => props.conversation.subscribe(fn), () => props.conversation.get(), () => props.conversation.get());
939
- const fontSize = useFontSize(props.client);
940
1137
  const [fontList, setFontList] = (0, react.useState)({
941
1138
  state: "idle",
942
1139
  families: []
@@ -968,22 +1165,27 @@ function FontSettingsPanel(props) {
968
1165
  }));
969
1166
  }
970
1167
  }
971
- function update(patch) {
972
- if (patch.uiFont !== void 0) props.client.theme.setFontFamily("text", normalizeFontFamily(patch.uiFont));
973
- if (patch.codeFont !== void 0) props.client.theme.setFontFamily("code", normalizeFontFamily(patch.codeFont));
1168
+ function updateFamily(role, value) {
1169
+ props.client.theme.setFontFamily(role, normalizeFontFamily(value));
974
1170
  }
975
- const uiName = presetFor(settings.uiFont, UI_FONT_PRESETS)?.label[locale] ?? (settings.uiFont || text.defaultName);
976
- const convName = presetFor(conversationFont, UI_FONT_PRESETS)?.label[locale] ?? (conversationFont || text.sameAsUi);
977
- const codeName = presetFor(settings.codeFont, CODE_FONT_PRESETS)?.label[locale] ?? (settings.codeFont || text.defaultName);
978
- if (props.view === "summary") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
979
- className: "font-root",
980
- "data-testid": "font-summary",
981
- children: text.summary(uiName, convName, codeName, fontSize)
1171
+ function updateSize(role, px) {
1172
+ props.client.theme.setFontSize(role, px);
1173
+ }
1174
+ const sizeField = (role, label, help) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontSizeField, {
1175
+ label,
1176
+ help,
1177
+ role,
1178
+ value: snapshot.fontSizes[role],
1179
+ locale,
1180
+ increaseLabel: text.increaseSize(label),
1181
+ decreaseLabel: text.decreaseSize(label),
1182
+ unit: text.sizeUnit,
1183
+ onCommit: updateSize
982
1184
  });
983
- const sizes = [];
984
- for (let px = 10; px <= 22; px += 1) sizes.push(px);
985
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
986
- className: "font-root dsh-ui-page dsh-ui-form",
1185
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1186
+ className: "font-root",
1187
+ role: "group",
1188
+ "aria-label": text.label,
987
1189
  "data-testid": "font-settings",
988
1190
  children: [
989
1191
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontField, {
@@ -998,7 +1200,7 @@ function FontSettingsPanel(props) {
998
1200
  customLabel: text.customOption,
999
1201
  customPlaceholder: text.customUiPlaceholder,
1000
1202
  systemGroupLabel: text.systemGroup,
1001
- onCommit: (value) => update({ uiFont: value })
1203
+ onCommit: (value) => updateFamily("text", value)
1002
1204
  }),
1003
1205
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontField, {
1004
1206
  label: text.conversationFont,
@@ -1014,6 +1216,7 @@ function FontSettingsPanel(props) {
1014
1216
  systemGroupLabel: text.systemGroup,
1015
1217
  onCommit: (value) => props.conversation.set(value)
1016
1218
  }),
1219
+ sizeField("text", text.textSize, text.textSizeHelp),
1017
1220
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontField, {
1018
1221
  label: text.codeFont,
1019
1222
  help: text.codeHelp,
@@ -1026,74 +1229,81 @@ function FontSettingsPanel(props) {
1026
1229
  customLabel: text.customOption,
1027
1230
  customPlaceholder: text.customCodePlaceholder,
1028
1231
  systemGroupLabel: text.systemGroup,
1029
- onCommit: (value) => update({ codeFont: value })
1232
+ onCommit: (value) => updateFamily("code", value)
1030
1233
  }),
1031
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1032
- className: "dsh-ui-field",
1033
- children: [
1034
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1035
- className: "dsh-ui-label",
1036
- children: text.fontSize
1037
- }),
1038
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
1039
- className: "dsh-ui-select",
1040
- value: fontSize,
1041
- onChange: (event) => {
1042
- const px = Number(event.target.value);
1043
- if (Number.isInteger(px) && px >= 10 && px <= 22 && px !== fontSize) try {
1044
- props.client.theme.setFontSize("text", px);
1045
- } catch {}
1046
- },
1047
- children: sizes.map((px) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("option", {
1048
- value: px,
1049
- children: [px, "px"]
1050
- }, px))
1051
- }),
1052
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1053
- className: "dsh-ui-help",
1054
- children: text.sizeHelp
1055
- })
1056
- ]
1234
+ sizeField("code", text.codeSize, text.codeSizeHelp),
1235
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontField, {
1236
+ label: text.terminalFont,
1237
+ help: text.terminalHelp,
1238
+ value: terminalFont,
1239
+ presets: CODE_FONT_PRESETS,
1240
+ locale,
1241
+ generic: "monospace",
1242
+ systemFonts: fontList.families,
1243
+ defaultLabel: text.defaultOption,
1244
+ customLabel: text.customOption,
1245
+ customPlaceholder: text.customTerminalPlaceholder,
1246
+ systemGroupLabel: text.systemGroup,
1247
+ onCommit: (value) => updateFamily("terminal", value)
1057
1248
  }),
1249
+ sizeField("terminal", text.terminalSize, text.terminalSizeHelp),
1058
1250
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1059
- className: "dsh-ui-form-footer",
1060
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1061
- variant: "outline",
1062
- size: "md",
1063
- disabled: fontList.state === "loading",
1064
- onClick: () => {
1065
- loadSystemFonts();
1066
- },
1067
- children: fontList.state === "loading" ? text.loadingFonts : fontList.state === "ready" ? text.reloadFonts : text.loadFonts
1068
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1069
- variant: "outline",
1070
- size: "md",
1071
- onClick: () => {
1072
- update({
1073
- uiFont: "",
1074
- codeFont: ""
1075
- });
1076
- props.conversation.set("");
1077
- if (fontSize !== 14) props.client.theme.setFontSize("text", 14);
1078
- },
1079
- children: text.reset
1251
+ className: "font-row",
1252
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1253
+ className: "font-row-text",
1254
+ children: [
1255
+ fontList.state === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1256
+ className: "font-row-desc",
1257
+ role: "status",
1258
+ children: text.fontsLoaded(fontList.families.length)
1259
+ }) : null,
1260
+ fontList.state === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1261
+ className: "font-row-desc",
1262
+ role: "status",
1263
+ children: text.fontsPartial
1264
+ }) : null,
1265
+ fontList.state === "denied" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1266
+ className: "font-row-desc",
1267
+ role: "status",
1268
+ children: text.fontsDenied
1269
+ }) : null
1270
+ ]
1271
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1272
+ className: "font-row-control",
1273
+ children: [
1274
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1275
+ variant: "outline",
1276
+ size: "sm",
1277
+ disabled: fontList.state === "loading",
1278
+ onClick: () => {
1279
+ loadSystemFonts();
1280
+ },
1281
+ children: fontList.state === "loading" ? text.loadingFonts : fontList.state === "ready" ? text.reloadFonts : text.loadFonts
1282
+ }),
1283
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1284
+ variant: "outline",
1285
+ size: "sm",
1286
+ onClick: () => {
1287
+ updateFamily("text", "");
1288
+ updateFamily("code", "");
1289
+ updateFamily("terminal", "");
1290
+ props.conversation.set("");
1291
+ },
1292
+ children: text.resetFonts
1293
+ }),
1294
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1295
+ variant: "outline",
1296
+ size: "sm",
1297
+ onClick: () => {
1298
+ updateSize("text", FONT_SIZE_SPECS.text.default);
1299
+ updateSize("code", FONT_SIZE_SPECS.code.default);
1300
+ updateSize("terminal", FONT_SIZE_SPECS.terminal.default);
1301
+ },
1302
+ children: text.resetSizes
1303
+ })
1304
+ ]
1080
1305
  })]
1081
- }),
1082
- fontList.state === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1083
- role: "status",
1084
- className: "dsh-ui-hint",
1085
- children: text.fontsLoaded(fontList.families.length)
1086
- }) : null,
1087
- fontList.state === "ready" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1088
- role: "status",
1089
- className: "dsh-ui-hint",
1090
- children: text.fontsPartial
1091
- }) : null,
1092
- fontList.state === "denied" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1093
- role: "status",
1094
- className: "dsh-ui-hint",
1095
- children: text.fontsDenied
1096
- }) : null
1306
+ })
1097
1307
  ]
1098
1308
  });
1099
1309
  }
@@ -1133,18 +1343,29 @@ function apply(ctx) {
1133
1343
  style.remove();
1134
1344
  };
1135
1345
  }, "font.conversation");
1136
- ctx.effect(() => client.slots.inject("plugins.bundle.config", () => client.slots.register({
1137
- name: "plugins.bundle.config",
1138
- key: PLUGIN_NAME
1139
- }, (slotProps) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontSettingsPanel, {
1140
- client,
1141
- conversation,
1142
- view: slotProps?.view
1143
- }))), "font.settings");
1346
+ ctx.effect(() => client.slots.inject("settings.section", () => [
1347
+ client.slots.register({
1348
+ name: "settings.section",
1349
+ id: "font",
1350
+ order: 5,
1351
+ label: () => client.locale.getSnapshot().active.toLowerCase().startsWith("zh") ? COPY.zh.label : COPY.en.label
1352
+ }, () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontSettingsGroup, {
1353
+ client,
1354
+ conversation
1355
+ })),
1356
+ client.slots.inject("settings.general.item", () => client.slots.register({
1357
+ name: "settings.general.item",
1358
+ id: "font-size",
1359
+ order: 11,
1360
+ priority: -10
1361
+ }, () => null)),
1362
+ registerSettingsSectionIcon(ctx, "font", 5, IconFontSettings)
1363
+ ]), "font.settings");
1144
1364
  }
1145
1365
  //#endregion
1146
1366
  exports.FontField = FontField;
1147
- exports.FontSettingsPanel = FontSettingsPanel;
1367
+ exports.FontSettingsGroup = FontSettingsGroup;
1368
+ exports.FontSizeField = FontSizeField;
1148
1369
  exports.apply = apply;
1149
1370
  exports.fontCopy = fontCopy;
1150
1371
  exports.inject = inject;