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