@klarkxy/dsh-font 0.2.2 → 0.2.3
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/README.md +9 -10
- package/docs/README.zh-CN.md +9 -10
- package/lib/client.inner.cjs +386 -165
- package/lib/client.inner.cjs.map +1 -1
- package/lib/client.js +386 -165
- package/lib/contracts.d.ts +34 -10
- package/lib/contracts.js +25 -10
- package/lib/contracts.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +4 -4
package/lib/client.inner.cjs
CHANGED
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
30
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
792
|
-
|
|
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
|
-
|
|
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
|
|
811
|
-
|
|
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
|
-
|
|
820
|
-
|
|
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-
|
|
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)("
|
|
859
|
-
className: "
|
|
988
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
989
|
+
className: "font-row",
|
|
860
990
|
children: [
|
|
861
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
862
|
-
className: "
|
|
863
|
-
children:
|
|
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.
|
|
866
|
-
className: "
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
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
|
-
|
|
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
|
|
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:
|
|
930
|
-
codeFont:
|
|
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
|
|
966
|
-
|
|
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
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
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
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
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) =>
|
|
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) =>
|
|
1226
|
+
onCommit: (value) => updateFamily("code", value)
|
|
1024
1227
|
}),
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
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: "
|
|
1054
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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("
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
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.
|
|
1361
|
+
exports.FontSettingsGroup = FontSettingsGroup;
|
|
1362
|
+
exports.FontSizeField = FontSizeField;
|
|
1142
1363
|
exports.apply = apply;
|
|
1143
1364
|
exports.fontCopy = fontCopy;
|
|
1144
1365
|
exports.inject = inject;
|