dsh-think-translate 1.0.4 → 1.0.5

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.
Files changed (2) hide show
  1. package/lib/client.js +26 -2
  2. package/package.json +4 -1
package/lib/client.js CHANGED
@@ -6,6 +6,14 @@ window.__ModuleLoader__.load({
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
7
  var react = require("react");
8
8
  var React = react.default !== undefined ? react.default : react;
9
+ // Official Markdown renderer (loaded via the client module graph, declared
10
+ // in dsh.client.external). Using it keeps official formatting — code-block
11
+ // copy, syntax highlighting, tables, footnotes, file mentions — while this
12
+ // plugin only supplies translated text. Falls back to the local Markdownish
13
+ // if the dependency is unavailable.
14
+ var primitives = null;
15
+ try { primitives = require("@deepseek-ai/dsh-client-ui-primitives"); } catch (e) { primitives = null; }
16
+ var MarkdownText = primitives && primitives.MarkdownText ? primitives.MarkdownText : null;
9
17
  var createElement = function (type, props) {
10
18
  var children = [];
11
19
  for (var i = 2; i < arguments.length; i++) children.push(arguments[i]);
@@ -135,6 +143,7 @@ window.__ModuleLoader__.load({
135
143
  providerUnavailable: "翻译服务未加载:插件的 host 半边未生效(常见于刚改过配置或更新后)。请重启 Web 再试——重启后翻译与设置将恢复正常。",
136
144
  providerDesc: "Google / Bing / 本地模型(自动选择)",
137
145
  labels: { google: "google gtx(免费)", bing: "bing(免费)", openai: "本地部署模型(Ollama)" },
146
+ copy: "复制", copied: "已复制",
138
147
  note: "界面翻译:思考链、任务卡片、回答正文会显示为你选的语言,原文保留在会话记录中可随时对照。优先使用本地模型,其次 Google/Bing;文件路径、代码等自动跳过。",
139
148
  },
140
149
  "en": {
@@ -149,6 +158,7 @@ window.__ModuleLoader__.load({
149
158
  providerUnavailable: "Translation service not loaded: the plugin host half is inactive (common after config changes or updates). Restart the web app to restore translation and settings.",
150
159
  providerDesc: "Google / Bing / local model (auto)",
151
160
  labels: { google: "google gtx (free)", bing: "bing (free)", openai: "Local model (Ollama)" },
161
+ copy: "Copy", copied: "Copied",
152
162
  note: "UI translation: the thinking chain, task cards and answer text display in your chosen language; originals stay in the transcript for comparison. Local model first, then Google/Bing; file paths and code are skipped.",
153
163
  },
154
164
  "ja": {
@@ -720,11 +730,25 @@ window.__ModuleLoader__.load({
720
730
  }
721
731
  function TextBlock(props) {
722
732
  var s = useStore();
733
+ var tt = UI_TEXT[s.lang] || UI_TEXT.en;
723
734
  var tr = useXlate(props.text, s.ans && !props.streaming);
724
735
  var hasTr = !!(tr && tr.ok && !tr.skipped && tr.text !== props.text);
736
+ // Official MarkdownText when available: keeps the full official
737
+ // formatting (code copy, highlighting, tables...). Translated text
738
+ // replaces the body when answer translation is on; original stays in
739
+ // a collapsible details block.
740
+ var codeLabels = MarkdownText ? { copyLabel: tt.copy, copiedLabel: tt.copied } : undefined;
741
+ var MDT = MarkdownText || Markdownish;
742
+ var body = hasTr ? tr.text : props.text;
725
743
  return createElement("div", null,
726
- createElement(Markdownish, { text: props.text, streaming: props.streaming }),
727
- hasTr ? createElement("div", { className: "xl-trans-after" }, tr.text) : null);
744
+ createElement(MDT, MarkdownText
745
+ ? { text: body, streaming: props.streaming, codeLabels: codeLabels }
746
+ : { text: body, streaming: props.streaming }),
747
+ hasTr ? createElement("details", { className: "xl-orig" },
748
+ createElement("summary", null, tt.original),
749
+ createElement("div", null, createElement(MDT, MarkdownText
750
+ ? { text: props.text, codeLabels: codeLabels }
751
+ : { text: props.text }))) : null);
728
752
  }
729
753
 
730
754
  function AssistantView(props) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-think-translate",
3
3
  "description": "Display-layer translation for the DSH web app: thinking chain, task cards, and optional answer text, in 8 target languages (local Ollama / Google / Bing, fail-open)",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -27,6 +27,9 @@
27
27
  "immediately": true,
28
28
  "inject": [
29
29
  "@deepseek-ai/dsh-client-runtime"
30
+ ],
31
+ "external": [
32
+ "@deepseek-ai/dsh-client-ui-primitives"
30
33
  ]
31
34
  },
32
35
  "bundle": {