dsh-plugin-zotero 0.5.2 → 0.6.1

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/client/client.js CHANGED
@@ -12,10 +12,13 @@ const WRITE_HEADER = "x-dsh-zotero-write";
12
12
  /** Host 返回的错误,携带 §6 的错误码。 */
13
13
  var ApiFailure = class extends Error {
14
14
  code;
15
- constructor(code, message) {
15
+ /** 有值时表示这个错误可以一键去修(页面上多一个按钮)。 */
16
+ fix;
17
+ constructor(code, message, fix) {
16
18
  super(message);
17
19
  this.name = "ApiFailure";
18
20
  this.code = code;
21
+ this.fix = fix;
19
22
  }
20
23
  };
21
24
  function buildUrl(action, query = {}) {
@@ -32,7 +35,7 @@ function buildUrl(action, query = {}) {
32
35
  async function readEnvelope(res) {
33
36
  const payload = await res.json().catch(() => null);
34
37
  if (payload === null) throw new ApiFailure("internal_error", `Host 返回了非 JSON 响应(HTTP ${res.status})`);
35
- if (!payload.ok) throw new ApiFailure(payload.error.code, payload.error.message);
38
+ if (!payload.ok) throw new ApiFailure(payload.error.code, payload.error.message, payload.error.fix);
36
39
  return payload.data;
37
40
  }
38
41
  async function get(action, query = {}, signal) {
@@ -102,6 +105,15 @@ function fileUrl(key) {
102
105
  return buildUrl("file", { key });
103
106
  }
104
107
  /**
108
+ * 附件可读性探测。
109
+ *
110
+ * 文件流的失败只会给 pdf.js 一个 HTTP 状态码,真正的原因(文件不存在 /
111
+ * 无权限 / 没有本地文件)在这个端点里以 `ApiFailure.message` 给出。
112
+ */
113
+ function fetchAttachmentInfo(key, signal) {
114
+ return get("attachment-info", { key }, signal);
115
+ }
116
+ /**
105
117
  * 网页快照的目录形地址,直接作为 iframe 的 `src`。
106
118
  *
107
119
  * 尾斜杠必须在:浏览器按它解析快照里的相对资源。
@@ -113,6 +125,15 @@ function snapshotUrl(key) {
113
125
  async function openInZotero(input) {
114
126
  await post("open-in-zotero", input);
115
127
  }
128
+ /**
129
+ * 打开「去那儿修」的系统面板。
130
+ *
131
+ * 目前只支持 macOS 的「文件与文件夹」授权:插件读不到 Zotero 附件时,最需要
132
+ * 用户动手的那一步就在那里,让他在系统设置里翻半天不如给个按钮。
133
+ */
134
+ async function openSystemSettings(target) {
135
+ await post("open-settings", { target });
136
+ }
116
137
  /** 写通道当前状态(开关 + 内存里有没有 key)。 */
117
138
  function fetchWriteStatus(signal) {
118
139
  return get("auth-status", {}, signal);
@@ -380,9 +401,14 @@ const dicts = {
380
401
  "detail.info": "文献信息与标注",
381
402
  "outline.title": "目录",
382
403
  "outline.loading": "正在读取目录…",
383
- "outline.empty": "这篇 PDF 没有目录",
404
+ "outline.empty": "这份文档没有目录",
384
405
  "outline.count": "{n} 条",
385
406
  "outline.jump": "跳到第 {page} 页",
407
+ "outline.jumpHeading": "跳到正文对应位置",
408
+ "outline.source.pdf": "PDF 书签 · 按页跳转",
409
+ "outline.source.snapshot": "网页快照标题 · 按标题定位",
410
+ "outline.source.note": "笔记标题 · 按标题定位",
411
+ "outline.source.text": "全文标题 · 按标题定位",
386
412
  "detail.attachmentOpen": "在文档区打开",
387
413
  "detail.annotationLocate": "定位",
388
414
  "detail.attachments": "附件",
@@ -540,6 +566,11 @@ const dicts = {
540
566
  "annotation.type.ink": "手写",
541
567
  "viewer.loading": "正在加载文档…",
542
568
  "viewer.failed": "文档加载失败:{message}",
569
+ "viewer.serverResponse": "Zotero 返回了 {status},但附件本身可以读取,请重试一次。",
570
+ "viewer.attachmentUnavailable": "附件打不开:{message}",
571
+ "viewer.unsupported": "暂不支持预览 {type},可用「在 Zotero 中打开」。",
572
+ "viewer.openPrivacySettings": "打开系统设置",
573
+ "viewer.openSettingsFailed": "打不开系统设置:{message}",
543
574
  "viewer.page": "第 {n} 页",
544
575
  "viewer.pageJump": "跳转到页码(回车确认,Esc 取消)",
545
576
  "viewer.pageTotal": "/ {total}",
@@ -556,7 +587,7 @@ const dicts = {
556
587
  "viewer.snapshotTimeout": "网页快照加载超时,内容可能不完整",
557
588
  "viewer.snapshotRetry": "重新加载",
558
589
  "viewer.snapshotNoHighlight": "这条快照没能加载高亮脚本,标注暂不可见",
559
- "viewer.snapshotStaleBridge": "快照脚本是旧版本:编辑卡片暂时只能居中显示,重启 DSH 后会跟随点击位置",
590
+ "viewer.snapshotStaleBridge": "快照脚本是旧版本:编辑卡片可能居中、网页标题目录可能为空,重启 DSH 后恢复",
560
591
  "viewer.highlightPartial": "有 {n} 条标注未能在网页上定位",
561
592
  "detail.noSnapshot": "这条网页条目没有保存网页快照",
562
593
  "detail.noSnapshotHint": "抓取时勾选「保存网页快照」才能离线还原网页;下面是 Zotero 索引的全文文本",
@@ -704,9 +735,14 @@ const dicts = {
704
735
  "detail.info": "Metadata and annotations",
705
736
  "outline.title": "Contents",
706
737
  "outline.loading": "Reading the outline…",
707
- "outline.empty": "This PDF has no outline",
738
+ "outline.empty": "This document has no outline",
708
739
  "outline.count": "{n} entries",
709
740
  "outline.jump": "Go to page {page}",
741
+ "outline.jumpHeading": "Scroll to this heading",
742
+ "outline.source.pdf": "PDF bookmarks · jump by page",
743
+ "outline.source.snapshot": "Web snapshot headings · jump to the heading",
744
+ "outline.source.note": "Note headings · jump to the heading",
745
+ "outline.source.text": "Full-text headings · jump to the heading",
710
746
  "detail.attachmentOpen": "Open in the document pane",
711
747
  "detail.annotationLocate": "Locate",
712
748
  "detail.attachments": "Attachments",
@@ -864,6 +900,11 @@ const dicts = {
864
900
  "annotation.type.ink": "Ink",
865
901
  "viewer.loading": "Loading document…",
866
902
  "viewer.failed": "Failed to load the document: {message}",
903
+ "viewer.serverResponse": "Zotero returned {status}, but the attachment itself is readable — please retry.",
904
+ "viewer.attachmentUnavailable": "Cannot open the attachment: {message}",
905
+ "viewer.unsupported": "Preview is not supported for {type} — use “Open in Zotero”.",
906
+ "viewer.openPrivacySettings": "Open System Settings",
907
+ "viewer.openSettingsFailed": "Cannot open System Settings: {message}",
867
908
  "viewer.page": "Page {n}",
868
909
  "viewer.pageJump": "Jump to page (Enter to confirm, Esc to cancel)",
869
910
  "viewer.pageTotal": "/ {total}",
@@ -880,7 +921,7 @@ const dicts = {
880
921
  "viewer.snapshotTimeout": "The web snapshot is taking too long; content may be incomplete",
881
922
  "viewer.snapshotRetry": "Reload",
882
923
  "viewer.snapshotNoHighlight": "The highlight script did not load; annotations are hidden",
883
- "viewer.snapshotStaleBridge": "The snapshot bridge is outdated: the edit card is centred for now and will follow the click after you restart DSH",
924
+ "viewer.snapshotStaleBridge": "The snapshot bridge is outdated: the edit card may be centred and the heading outline may be empty. Restart DSH to fix it",
884
925
  "viewer.highlightPartial": "{n} annotation(s) could not be located on the page",
885
926
  "detail.noSnapshot": "No web snapshot was saved for this item",
886
927
  "detail.noSnapshotHint": "Enable “Save web page snapshot” when capturing to render the page offline; showing the indexed full text instead",
@@ -924,6 +965,9 @@ const dicts = {
924
965
  * 主面板 = 目录树 + 标签面板 + 条目列表;条目详情在独立 tab 里,状态不在这里。
925
966
  * 列表与标签请求都用「请求序号 + AbortController」防竞态:快速切分类、连续点标签时
926
967
  * 旧响应不能覆盖新结果。
968
+ *
969
+ * 目录树的「选中 + 展开」另存一份到 localStorage:模块状态只活到页面刷新为止,
970
+ * 存档让刷新页面 / 重开面板后回到上次选中的目录。
927
971
  */
928
972
  /** 搜索防抖时长。 */
929
973
  const SEARCH_DEBOUNCE_MS = 250;
@@ -933,6 +977,15 @@ const ITEMS_PAGE_SIZE = 50;
933
977
  const TOAST_MS = 3e3;
934
978
  /** 列表排序的存储键(localStorage,跨会话与重启都记住)。 */
935
979
  const SORT_KEY = "dsh-plugin-zotero.itemSort";
980
+ /** 目录树状态的存储键:刷新页面 / 重开面板后回到上次选中的目录。 */
981
+ const TREE_STATE_KEY = "dsh-plugin-zotero.treeState";
982
+ /** 合法的虚拟分类范围(存档里的 scope 不在其中就丢弃)。 */
983
+ const KNOWN_SCOPES = [
984
+ "library",
985
+ "publications",
986
+ "unfiled",
987
+ "trash"
988
+ ];
936
989
  /** 文库根节点的 id(只存在于客户端,不对应任何 Zotero 分类)。 */
937
990
  const TREE_ROOT_ID = "__library__";
938
991
  function readSort() {
@@ -943,7 +996,70 @@ function readSort() {
943
996
  return "none";
944
997
  }
945
998
  }
999
+ /** 读目录树存档;缺失、坏 JSON、结构不认识都退回「文库根 + 只展开根」。 */
1000
+ function readTreeState() {
1001
+ const blank = {
1002
+ selected: null,
1003
+ expanded: []
1004
+ };
1005
+ try {
1006
+ const raw = window.localStorage.getItem(TREE_STATE_KEY);
1007
+ if (raw === null) return blank;
1008
+ const parsed = JSON.parse(raw);
1009
+ if (typeof parsed !== "object" || parsed === null) return blank;
1010
+ const record = parsed;
1011
+ const expanded = Array.isArray(record.expanded) ? record.expanded.filter((id) => typeof id === "string") : [];
1012
+ const saved = record.selected;
1013
+ if (saved === null || typeof saved !== "object" || typeof saved.key !== "string" || saved.key === "") return {
1014
+ selected: null,
1015
+ expanded
1016
+ };
1017
+ const scope = KNOWN_SCOPES.find((item) => item === saved.scope);
1018
+ return {
1019
+ selected: {
1020
+ key: saved.key,
1021
+ name: typeof saved.name === "string" ? saved.name : "",
1022
+ ...scope === void 0 ? {} : { scope }
1023
+ },
1024
+ expanded
1025
+ };
1026
+ } catch {
1027
+ return blank;
1028
+ }
1029
+ }
1030
+ /**
1031
+ * 把当前选中与展开写盘。
1032
+ *
1033
+ * 文库根是默认值,不存(存档为空即代表文库根),免得和「没有存档」两种状态打架。
1034
+ */
1035
+ function saveTreeState() {
1036
+ const collection = state.selectedCollection;
1037
+ const saved = {
1038
+ selected: collection === null || collection.key === "__library__" ? null : {
1039
+ key: collection.key,
1040
+ name: collection.name,
1041
+ ...collection.scope === void 0 ? {} : { scope: collection.scope }
1042
+ },
1043
+ expanded: [...state.expanded]
1044
+ };
1045
+ try {
1046
+ window.localStorage.setItem(TREE_STATE_KEY, JSON.stringify(saved));
1047
+ } catch {}
1048
+ }
1049
+ /** 选中分类的祖先 key 链(由内到外);结构异常时中断,避免死循环。 */
1050
+ function ancestorKeys(collections, key) {
1051
+ const byKey = new Map(collections.map((node) => [node.key, node]));
1052
+ const chain = [];
1053
+ let node = byKey.get(key);
1054
+ while (node !== void 0 && node.parentKey !== false) {
1055
+ if (chain.includes(node.parentKey)) break;
1056
+ chain.push(node.parentKey);
1057
+ node = byKey.get(node.parentKey);
1058
+ }
1059
+ return chain;
1060
+ }
946
1061
  function initialState() {
1062
+ const saved = readTreeState();
947
1063
  return {
948
1064
  health: null,
949
1065
  libraryName: "",
@@ -951,9 +1067,14 @@ function initialState() {
951
1067
  treeError: null,
952
1068
  treeLoading: true,
953
1069
  loaded: false,
954
- expanded: /* @__PURE__ */ new Set([TREE_ROOT_ID]),
1070
+ expanded: /* @__PURE__ */ new Set([TREE_ROOT_ID, ...saved.expanded]),
955
1071
  treeQuery: "",
956
- selectedCollection: null,
1072
+ selectedCollection: saved.selected === null ? null : {
1073
+ key: saved.selected.key,
1074
+ name: saved.selected.name,
1075
+ parentKey: false,
1076
+ ...saved.selected.scope === void 0 ? {} : { scope: saved.selected.scope }
1077
+ },
957
1078
  items: [],
958
1079
  itemsTotal: 0,
959
1080
  itemsLoading: false,
@@ -1058,14 +1179,19 @@ function loadTree(force = false) {
1058
1179
  else if (previous.scope !== void 0) selected = previous;
1059
1180
  else selected = tree.collections.find((node) => node.key === previous.key) ?? libraryRoot(tree.libraryName);
1060
1181
  }
1182
+ const expanded = new Set(state.expanded);
1183
+ expanded.add(TREE_ROOT_ID);
1184
+ if (selected.key !== "__library__" && selected.scope === void 0) for (const key of ancestorKeys(tree.collections, selected.key)) expanded.add(key);
1061
1185
  patch$1({
1062
1186
  health: healthData,
1063
1187
  collections: tree.collections,
1064
1188
  libraryName: tree.libraryName,
1065
1189
  treeError: null,
1066
1190
  loaded: true,
1191
+ expanded,
1067
1192
  selectedCollection: selected
1068
1193
  });
1194
+ saveTreeState();
1069
1195
  reloadItems({ reset: true });
1070
1196
  loadTagUsage();
1071
1197
  } catch (error) {
@@ -1084,6 +1210,7 @@ function toggleTreeNode(nodeId) {
1084
1210
  if (expanded.has(nodeId)) expanded.delete(nodeId);
1085
1211
  else expanded.add(nodeId);
1086
1212
  patch$1({ expanded });
1213
+ saveTreeState();
1087
1214
  }
1088
1215
  /**
1089
1216
  * 分类树名称筛选(纯客户端,参照 Zotero 左栏的目录过滤)。
@@ -1112,6 +1239,7 @@ function selectCollection(collection) {
1112
1239
  selectedTags: /* @__PURE__ */ new Set(),
1113
1240
  tagQuery: ""
1114
1241
  });
1242
+ saveTreeState();
1115
1243
  reloadItems({ reset: true });
1116
1244
  loadTagUsage();
1117
1245
  }
@@ -1869,6 +1997,188 @@ function insertChip(sessions, sessionId, reference, span) {
1869
1997
  }) === true;
1870
1998
  }
1871
1999
  //#endregion
2000
+ //#region src/client/styles.ts
2001
+ /** 蓝色高亮色(详情面板的区块标题、当前附件标记等旧调用)。 */
2002
+ const ACCENT = "#508cff";
2003
+ /** Zotero 风格的图标色:固定彩色,不随主题变。 */
2004
+ const TREE_BLUE = "#3b7de0";
2005
+ const TREE_GREEN = "#2f9e63";
2006
+ const TREE_ORANGE = "#e0872f";
2007
+ const TREE_RED = "#dc5a55";
2008
+ /** 标题的蓝→紫点缀。 */
2009
+ const TITLE_BAR_GRADIENT = `linear-gradient(180deg, #4a86e8 0%, #8a63e8 100%)`;
2010
+ /**
2011
+ * 所有按钮的常态配色:浅蓝底 + 蓝色线条轮廓。
2012
+ *
2013
+ * 用内联样式而非 CSS 类覆盖宿主 Button 的默认 background/border(内联优先级
2014
+ * 更高);hover 等伪类交给 {@link THEME_CSS} 的 `.dsh-zp-soft-btn` 规则。
2015
+ * 文字取宿主主题变量,深浅色都可读;主色只体现在底、框、图标上。
2016
+ */
2017
+ const SOFT_BUTTON_STYLE = {
2018
+ color: "var(--dsw-alias-label-primary, CanvasText)",
2019
+ background: "rgba(74,134,232,0.10)",
2020
+ border: "1px solid rgba(74,134,232,0.45)",
2021
+ boxShadow: "0 1px 1px rgba(31,64,128,0.05)",
2022
+ boxSizing: "border-box"
2023
+ };
2024
+ /** 选中 / 激活态:同一套描边,底色与边框加深。 */
2025
+ const SOFT_BUTTON_ACTIVE_STYLE = {
2026
+ ...SOFT_BUTTON_STYLE,
2027
+ background: "rgba(74,134,232,0.24)",
2028
+ border: "1px solid rgba(74,134,232,0.85)"
2029
+ };
2030
+ /** 所有「浅底 + 描边」按钮共用的 class(primary 实心主操作不加)。 */
2031
+ const SOFT_BUTTON_CLASS = "dsh-zp-soft-btn";
2032
+ /** 标题外壳 class;文字色与渐变竖条写在 CSS 里(要做 light/dark 渐进增强)。 */
2033
+ const SECTION_TITLE_CLASS = "dsh-zp-title";
2034
+ /** 按钮 class:选中 / 激活态多挂 `is-active`,hover 时底色加深得更多。 */
2035
+ function softButtonClass(active = false) {
2036
+ return active ? `${SOFT_BUTTON_CLASS} is-active` : SOFT_BUTTON_CLASS;
2037
+ }
2038
+ /**
2039
+ * 标签胶囊的配色,与蓝色系操作按钮分开:
2040
+ * 默认**完全无底色**(只留中性灰细描边),选中照 Zotero 标签选择器用
2041
+ * **深灰底 + 白字**——全站已经够蓝了,标签选中不再掺蓝。
2042
+ * 不复用 `.dsh-zp-soft-btn`,否则它 hover 的 !important 会改掉选中底色。
2043
+ */
2044
+ const TAG_IDLE_STYLE = {
2045
+ color: "var(--dsw-alias-label-primary, CanvasText)",
2046
+ background: "transparent",
2047
+ border: "1px solid rgba(127,127,127,0.34)",
2048
+ boxSizing: "border-box"
2049
+ };
2050
+ /** Zotero 风格的选中标签高亮:深灰 #5a5a5a + 白字。 */
2051
+ const TAG_SELECTED_STYLE = {
2052
+ color: "#ffffff",
2053
+ background: "#5a5a5a",
2054
+ border: "1px solid #4f4f4f",
2055
+ fontWeight: 600,
2056
+ boxSizing: "border-box"
2057
+ };
2058
+ /**
2059
+ * 「全部 / 任一」这类模式开关的选中态:与全站按钮同族(浅蓝底 + 蓝描边),
2060
+ * 只把底色加深一档,不用实心色,也不改文字色。
2061
+ */
2062
+ const MODE_BUTTON_ACTIVE_STYLE = {
2063
+ ...SOFT_BUTTON_ACTIVE_STYLE,
2064
+ background: "rgba(74,134,232,0.32)",
2065
+ border: "1px solid rgba(74,134,232,0.9)"
2066
+ };
2067
+ const TAG_BUTTON_CLASS = "dsh-zp-tag";
2068
+ /** 选中态多挂 `is-selected`,CSS 只负责 hover / active。 */
2069
+ function tagButtonClass(selected = false) {
2070
+ return selected ? `${TAG_BUTTON_CLASS} is-selected` : TAG_BUTTON_CLASS;
2071
+ }
2072
+ /** 全局主题样式:只在入口注入一次,portal / 浮层里的按钮同样生效。 */
2073
+ const THEME_CSS = `
2074
+ .dsh-zp-soft-btn {
2075
+ transition: background-color 120ms ease, border-color 120ms ease;
2076
+ }
2077
+ .dsh-zp-soft-btn:hover:not(:disabled) {
2078
+ background-color: rgba(74, 134, 232, 0.20) !important;
2079
+ border-color: rgba(74, 134, 232, 0.78) !important;
2080
+ }
2081
+ .dsh-zp-soft-btn.is-active:hover:not(:disabled) {
2082
+ background-color: rgba(74, 134, 232, 0.42) !important;
2083
+ }
2084
+ .dsh-zp-soft-btn:active:not(:disabled) {
2085
+ background-color: rgba(74, 134, 232, 0.26) !important;
2086
+ }
2087
+ .dsh-zp-soft-btn.is-active:active:not(:disabled) {
2088
+ background-color: rgba(74, 134, 232, 0.46) !important;
2089
+ }
2090
+ .dsh-zp-soft-btn:disabled {
2091
+ opacity: 0.55 !important;
2092
+ cursor: default;
2093
+ }
2094
+ .dsh-zp-tag {
2095
+ transition: background-color 120ms ease, border-color 120ms ease;
2096
+ }
2097
+ .dsh-zp-tag:hover {
2098
+ background-color: rgba(127, 127, 127, 0.10) !important;
2099
+ border-color: rgba(127, 127, 127, 0.60) !important;
2100
+ }
2101
+ .dsh-zp-tag.is-selected:hover {
2102
+ background-color: #4b4b4b !important;
2103
+ border-color: #404040 !important;
2104
+ }
2105
+ .dsh-zp-tag.is-selected:active {
2106
+ background-color: #404040 !important;
2107
+ }
2108
+ .dsh-zp-title {
2109
+ display: inline-flex;
2110
+ align-items: center;
2111
+ gap: 6px;
2112
+ min-width: 0;
2113
+ /* 无底色、无描边:只靠渐变竖条与文字色点缀,避免标题变成色块。 */
2114
+ padding: 2px 0;
2115
+ font-weight: 700;
2116
+ letter-spacing: 0.1px;
2117
+ /* 老浏览器 / 宿主未声明 color-scheme 时退回主题文字色,仍可读。 */
2118
+ color: var(--dsw-alias-label-primary, CanvasText);
2119
+ color: light-dark(#2456ad, #aacaff);
2120
+ }
2121
+ .dsh-zp-title-bar {
2122
+ flex: 0 0 auto;
2123
+ width: 3px;
2124
+ height: 12px;
2125
+ border-radius: 2px;
2126
+ background-image: ${TITLE_BAR_GRADIENT};
2127
+ }
2128
+ .dsh-zp-title-text {
2129
+ flex: 1 1 auto;
2130
+ min-width: 0;
2131
+ overflow: hidden;
2132
+ text-overflow: ellipsis;
2133
+ white-space: nowrap;
2134
+ }
2135
+ `.trim();
2136
+ const THEME_STYLE_ID = "dsh-plugin-zotero-theme";
2137
+ /** 幂等:插件重载 / 多会话只留一份 <style>。 */
2138
+ function installTheme() {
2139
+ if (typeof document === "undefined" || document.getElementById(THEME_STYLE_ID) !== null) return;
2140
+ const style = document.createElement("style");
2141
+ style.id = THEME_STYLE_ID;
2142
+ style.textContent = THEME_CSS;
2143
+ document.head.appendChild(style);
2144
+ }
2145
+ //#endregion
2146
+ //#region src/client/ui.tsx
2147
+ /** 与宿主 Button 同签名;自动套上浅底描边,保留调用方自己的紧凑尺寸。 */
2148
+ function Button({ className, variant, style, ...rest }) {
2149
+ if (variant === "primary") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2150
+ ...rest,
2151
+ variant: "primary",
2152
+ className,
2153
+ style
2154
+ });
2155
+ const merged = [SOFT_BUTTON_CLASS, className].filter((part) => Boolean(part)).join(" ");
2156
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2157
+ ...rest,
2158
+ variant,
2159
+ className: merged,
2160
+ style: {
2161
+ ...SOFT_BUTTON_STYLE,
2162
+ ...style
2163
+ }
2164
+ });
2165
+ }
2166
+ /** 无底色的分区标题(渐变竖条 + 蓝字);文字过长时省略号截断。 */
2167
+ function SectionTitle({ children, title, style }) {
2168
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2169
+ className: SECTION_TITLE_CLASS,
2170
+ title,
2171
+ style: {
2172
+ fontSize: 13,
2173
+ ...style
2174
+ },
2175
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "dsh-zp-title-bar" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
2176
+ className: "dsh-zp-title-text",
2177
+ children
2178
+ })]
2179
+ });
2180
+ }
2181
+ //#endregion
1872
2182
  //#region src/client/ZoteroCard.tsx
1873
2183
  /**
1874
2184
  * 设置页(浏览器半)。
@@ -2340,7 +2650,7 @@ function ZoteroSettingsSection(props) {
2340
2650
  });
2341
2651
  if (tools.kind === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2342
2652
  style: HINT_STYLE,
2343
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("tools.error"), { message: tools.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2653
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("tools.error"), { message: tools.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2344
2654
  variant: "ghost",
2345
2655
  size: "sm",
2346
2656
  onClick: () => reloadTools(),
@@ -2356,7 +2666,7 @@ function ZoteroSettingsSection(props) {
2356
2666
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("tools.summary"), {
2357
2667
  total: tools.tools.length,
2358
2668
  off: tools.tools.filter((tool) => disabledSet.has(tool.name)).length
2359
- }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2669
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2360
2670
  variant: "ghost",
2361
2671
  size: "sm",
2362
2672
  onClick: () => reloadTools(),
@@ -2415,7 +2725,7 @@ function ZoteroSettingsSection(props) {
2415
2725
  });
2416
2726
  if (write.kind === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2417
2727
  style: HINT_STYLE,
2418
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("write.error"), { message: write.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2728
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("write.error"), { message: write.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2419
2729
  variant: "outline",
2420
2730
  size: "sm",
2421
2731
  onClick: () => reloadWrite(),
@@ -2444,7 +2754,7 @@ function ZoteroSettingsSection(props) {
2444
2754
  }),
2445
2755
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2446
2756
  style: WRITE_ACTIONS_STYLE,
2447
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2757
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2448
2758
  variant: ready ? "outline" : "primary",
2449
2759
  size: "md",
2450
2760
  disabled: blocked,
@@ -2453,7 +2763,7 @@ function ZoteroSettingsSection(props) {
2453
2763
  runAuthorize();
2454
2764
  },
2455
2765
  children: authorizing ? t("write.pending") : ready ? t("write.reauthorize") : t("write.authorize")
2456
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2766
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2457
2767
  variant: "outline",
2458
2768
  size: "md",
2459
2769
  title: t("write.reloadHint"),
@@ -2717,11 +3027,6 @@ const ANNOTATION_COLORS = [
2717
3027
  "#f19837"
2718
3028
  ];
2719
3029
  //#endregion
2720
- //#region src/client/styles.ts
2721
- /** 右栏共用样式。 */
2722
- /** 蓝色高亮色(分区标题、当前附件标记)。 */
2723
- const ACCENT = "#508cff";
2724
- //#endregion
2725
3030
  //#region src/client/AnnotationList.tsx
2726
3031
  /**
2727
3032
  * 条目详情里的标注列表(高亮 / 划线 / 笔记 / 文本 / 截图 / 墨迹)。
@@ -2835,9 +3140,11 @@ function Swatch({ color, type }) {
2835
3140
  function Chip({ active, onClick, children }) {
2836
3141
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2837
3142
  type: "button",
3143
+ className: softButtonClass(active),
2838
3144
  onClick,
2839
3145
  "aria-pressed": active,
2840
3146
  style: {
3147
+ ...active ? SOFT_BUTTON_ACTIVE_STYLE : SOFT_BUTTON_STYLE,
2841
3148
  display: "inline-flex",
2842
3149
  alignItems: "center",
2843
3150
  gap: 4,
@@ -2846,9 +3153,6 @@ function Chip({ active, onClick, children }) {
2846
3153
  fontSize: 11,
2847
3154
  lineHeight: 1.2,
2848
3155
  borderRadius: 10,
2849
- color: "inherit",
2850
- background: active ? "rgba(80,140,255,0.18)" : "transparent",
2851
- border: `1px solid ${active ? "rgba(80,140,255,0.65)" : "rgba(127,127,127,0.3)"}`,
2852
3156
  cursor: "pointer",
2853
3157
  whiteSpace: "nowrap"
2854
3158
  },
@@ -2958,7 +3262,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
2958
3262
  }
2959
3263
  function rowButtons(annotation) {
2960
3264
  if (!canWrite) return null;
2961
- if (!EDITABLE_TYPES.has(annotation.type)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3265
+ if (!EDITABLE_TYPES.has(annotation.type)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2962
3266
  variant: "outline",
2963
3267
  size: "sm",
2964
3268
  disabled: true,
@@ -2967,7 +3271,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
2967
3271
  children: t("annotation.edit")
2968
3272
  });
2969
3273
  const open = editingKey === annotation.key;
2970
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3274
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2971
3275
  variant: "outline",
2972
3276
  size: "sm",
2973
3277
  disabled: busy,
@@ -2975,7 +3279,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
2975
3279
  title: open ? void 0 : t("annotation.editTitle"),
2976
3280
  style: insertButtonStyle$1,
2977
3281
  children: open ? t("annotation.closeEdit") : t("annotation.edit")
2978
- }), armed === annotation.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3282
+ }), armed === annotation.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2979
3283
  variant: "outline",
2980
3284
  size: "sm",
2981
3285
  disabled: busy,
@@ -2983,7 +3287,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
2983
3287
  title: t("annotation.deleteWarn"),
2984
3288
  style: insertButtonStyle$1,
2985
3289
  children: t("annotation.confirmDelete")
2986
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3290
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
2987
3291
  variant: "outline",
2988
3292
  size: "sm",
2989
3293
  disabled: busy,
@@ -3062,7 +3366,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
3062
3366
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3063
3367
  style: editorHintStyle$1,
3064
3368
  children: t("annotation.commentHint")
3065
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3369
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3066
3370
  variant: "outline",
3067
3371
  size: "sm",
3068
3372
  disabled: busy || draft.comment === originalComment,
@@ -3090,7 +3394,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
3090
3394
  style: inputStyle,
3091
3395
  "aria-label": t("annotation.pageLabel")
3092
3396
  }),
3093
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3397
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3094
3398
  variant: "outline",
3095
3399
  size: "sm",
3096
3400
  disabled: busy || !pageChanged,
@@ -3123,7 +3427,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
3123
3427
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3124
3428
  style: editorHintStyle$1,
3125
3429
  children: t("annotation.tagsHint")
3126
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3430
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3127
3431
  variant: "outline",
3128
3432
  size: "sm",
3129
3433
  disabled: busy || draft.tags === originalTags,
@@ -3246,11 +3550,12 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
3246
3550
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
3247
3551
  located && text === "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3248
3552
  type: "button",
3553
+ className: "dsh-zp-soft-btn",
3249
3554
  onClick: () => onLocate(annotation),
3250
3555
  style: locateButtonStyle,
3251
3556
  children: t("detail.annotationLocate")
3252
3557
  }),
3253
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3558
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3254
3559
  variant: "outline",
3255
3560
  size: "sm",
3256
3561
  disabled: !canInsert,
@@ -3306,15 +3611,13 @@ const insertButtonStyle$1 = {
3306
3611
  whiteSpace: "nowrap"
3307
3612
  };
3308
3613
  const locateButtonStyle = {
3614
+ ...SOFT_BUTTON_STYLE,
3309
3615
  flexShrink: 0,
3310
3616
  height: 20,
3311
3617
  padding: "0 6px",
3312
3618
  fontSize: 11,
3313
3619
  lineHeight: 1.2,
3314
3620
  borderRadius: 4,
3315
- border: "1px solid rgba(127,127,127,0.3)",
3316
- background: "transparent",
3317
- color: "inherit",
3318
3621
  cursor: "pointer",
3319
3622
  whiteSpace: "nowrap"
3320
3623
  };
@@ -3639,21 +3942,26 @@ const PATH = {
3639
3942
  };
3640
3943
  /** 已读图标的粉色:不用主题蓝,蓝色容易被读成「未读消息」徽标。 */
3641
3944
  const READ_ICON_COLOR = "#e8798d";
3642
- /** 条目类型图标;未知类型显示文档图标,已读条目整体转粉色。 */
3643
- function ItemTypeIcon({ itemType, read = false }) {
3945
+ /** 未读图标用 Zotero 蓝:列表行里比中性灰更醒目,也与树、按钮同一支蓝。 */
3946
+ const ICON_COLOR = "#4a86e8";
3947
+ /**
3948
+ * 条目类型图标;未知类型显示文档图标,已读条目整体转粉色。
3949
+ * 无底衬,默认 22px(比 Zotero 原生 16px 放大,列表里才看得清)。
3950
+ */
3951
+ function ItemTypeIcon({ itemType, read = false, size = 22 }) {
3644
3952
  const family = FAMILY[itemType] ?? "document";
3645
3953
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
3646
- width: 14,
3647
- height: 14,
3954
+ width: size,
3955
+ height: size,
3648
3956
  viewBox: "0 0 16 16",
3649
3957
  fill: "none",
3650
3958
  stroke: "currentColor",
3651
- strokeWidth: 1.3,
3959
+ strokeWidth: 1.35,
3652
3960
  strokeLinejoin: "round",
3653
3961
  strokeLinecap: "round",
3654
3962
  style: {
3655
- opacity: read ? .9 : .65,
3656
- color: read ? READ_ICON_COLOR : void 0
3963
+ opacity: read ? .95 : .9,
3964
+ color: read ? READ_ICON_COLOR : ICON_COLOR
3657
3965
  },
3658
3966
  "aria-hidden": true,
3659
3967
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: PATH[family] })
@@ -3766,7 +4074,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3766
4074
  function rowButtons(note) {
3767
4075
  if (!canWrite) return null;
3768
4076
  const editingThis = editing?.key === note.key;
3769
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4077
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3770
4078
  variant: "outline",
3771
4079
  size: "sm",
3772
4080
  disabled: busy,
@@ -3774,7 +4082,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3774
4082
  title: note.anchored ? t("note.anchorWarn") : t("note.edit"),
3775
4083
  style: insertButtonStyle,
3776
4084
  children: editingThis ? t("note.cancel") : t("note.edit")
3777
- }), armed === note.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4085
+ }), armed === note.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3778
4086
  variant: "outline",
3779
4087
  size: "sm",
3780
4088
  disabled: busy,
@@ -3788,7 +4096,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3788
4096
  title: t("note.deleteWarn"),
3789
4097
  style: insertButtonStyle,
3790
4098
  children: t("note.confirmDelete")
3791
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4099
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3792
4100
  variant: "outline",
3793
4101
  size: "sm",
3794
4102
  disabled: busy || editingThis,
@@ -3814,7 +4122,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3814
4122
  "aria-label": t("note.new")
3815
4123
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3816
4124
  style: editorFootStyle,
3817
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4125
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3818
4126
  variant: "outline",
3819
4127
  size: "sm",
3820
4128
  disabled: busy || draft.trim() === "",
@@ -3828,7 +4136,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3828
4136
  });
3829
4137
  },
3830
4138
  children: pending === "create" ? t("note.saving") : t("note.save")
3831
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4139
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3832
4140
  variant: "ghost",
3833
4141
  size: "sm",
3834
4142
  disabled: busy,
@@ -3875,7 +4183,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3875
4183
  })
3876
4184
  ]
3877
4185
  }),
3878
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4186
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3879
4187
  variant: "outline",
3880
4188
  size: "sm",
3881
4189
  onClick: () => onInsert(note),
@@ -3909,7 +4217,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3909
4217
  style: note.anchored ? anchorHintStyle : editorHintStyle,
3910
4218
  children: note.anchored ? t("note.anchorWarn") : t("note.htmlHint")
3911
4219
  }),
3912
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4220
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3913
4221
  variant: "outline",
3914
4222
  size: "sm",
3915
4223
  disabled: busy || editor.html.trim() === "",
@@ -3925,7 +4233,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
3925
4233
  },
3926
4234
  children: pending === "edit" ? t("note.saving") : t("note.save")
3927
4235
  }),
3928
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
4236
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
3929
4237
  variant: "ghost",
3930
4238
  size: "sm",
3931
4239
  disabled: busy,
@@ -4173,6 +4481,7 @@ function InfoPanel({ t, detail, currentAttachmentKey, open, onToggle, onClose, o
4173
4481
  }),
4174
4482
  !selfNote && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4175
4483
  type: "button",
4484
+ className: "dsh-zp-soft-btn",
4176
4485
  onClick: onCite,
4177
4486
  title: t("action.insertItem"),
4178
4487
  style: citeTriggerStyle,
@@ -4382,6 +4691,7 @@ const panelTitleStyle = {
4382
4691
  };
4383
4692
  /** 收在 `i` 右边、跟它同一行:是每次读文献都要点的主操作,不藏进浮层。 */
4384
4693
  const citeTriggerStyle = {
4694
+ ...SOFT_BUTTON_STYLE,
4385
4695
  position: "absolute",
4386
4696
  pointerEvents: "auto",
4387
4697
  top: 4,
@@ -4395,9 +4705,6 @@ const citeTriggerStyle = {
4395
4705
  lineHeight: 1,
4396
4706
  whiteSpace: "nowrap",
4397
4707
  borderRadius: 11,
4398
- border: "1px solid rgba(127,127,127,0.4)",
4399
- background: "Canvas",
4400
- color: "CanvasText",
4401
4708
  cursor: "pointer",
4402
4709
  boxShadow: "0 1px 4px rgba(0,0,0,0.18)",
4403
4710
  zIndex: 21
@@ -4490,20 +4797,21 @@ const attachmentMetaStyle = {
4490
4797
  //#endregion
4491
4798
  //#region src/client/OutlinePanel.tsx
4492
4799
  /**
4493
- * 左上角的目录浮层:PDF 书签按层级列出,点一条跳到对应页。
4800
+ * 左上角的**统一**目录浮层:PDF 书签、网页快照标题、笔记 / 全文标题都在这里。
4494
4801
  *
4495
4802
  * 按钮与「文献信息」并排(目录在左),收起规则和其它浮层共用 {@link useDismiss}:
4496
4803
  * 点浮层外、按 Esc、点进网页快照正文里都会收起。
4497
4804
  *
4498
- * 目录数据由渲染器上报(见 `viewer/types.ts` 的 `onOutlineChange`),这里只负责画;
4499
- * 渲染器不报(纯文本 / 网页快照)时按钮根本不出现,见 `ItemDetail`。
4805
+ * 目录数据一律由渲染器上报(见 `viewer/types.ts` 的 `onOutlineChange`),这里只负责画:
4806
+ * 面板不解释跳转目标,点一条就把 `target` 原样交回 `ItemDetail` 转给渲染器——
4807
+ * 于是 PDF 跳页、HTML 滚到标题可以共用同一份 UI。
4500
4808
  *
4501
4809
  * 点条目跳转后立刻收起:浮层压在文档左侧,留着就把刚跳过去的内容挡了一半。
4502
4810
  */
4503
4811
  /** 缩进宽度;层级再深也不再往外推,免得窄面板里标题全被挤成一点。 */
4504
4812
  const INDENT$1 = 13;
4505
4813
  const MAX_INDENT_DEPTH = 6;
4506
- function OutlinePanel({ t, items, open, onToggle, onClose, onJump }) {
4814
+ function OutlinePanel({ t, items, sourceLabel, open, onToggle, onClose, onJump }) {
4507
4815
  const rootRef = (0, react.useRef)(null);
4508
4816
  /** 悬停行:内联 style 写不了 `:hover`,只能自己记一个下标。 */
4509
4817
  const [hovered, setHovered] = (0, react.useState)(null);
@@ -4534,6 +4842,10 @@ function OutlinePanel({ t, items, open, onToggle, onClose, onJump }) {
4534
4842
  children: tpl(t("outline.count"), { n: items.length })
4535
4843
  })]
4536
4844
  }),
4845
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4846
+ style: sourceStyle,
4847
+ children: sourceLabel
4848
+ }),
4537
4849
  items === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4538
4850
  style: emptyStyle$1,
4539
4851
  children: t("outline.loading")
@@ -4545,16 +4857,15 @@ function OutlinePanel({ t, items, open, onToggle, onClose, onJump }) {
4545
4857
  items !== null && items.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4546
4858
  style: listStyle,
4547
4859
  children: items.map((item, index) => {
4548
- const target = item.page;
4860
+ const target = item.target;
4861
+ const hint = target === null ? item.title : `${item.title}\n${target.kind === "page" ? tpl(t("outline.jump"), { page: target.page }) : t("outline.jumpHeading")}`;
4549
4862
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4550
4863
  type: "button",
4551
4864
  disabled: target === null,
4552
- onClick: () => {
4553
- if (target !== null) onJump(target);
4554
- },
4865
+ onClick: () => onJump(item),
4555
4866
  onMouseEnter: () => setHovered(index),
4556
4867
  onMouseLeave: () => setHovered((current) => current === index ? null : current),
4557
- title: target === null ? item.title : `${item.title}\n${tpl(t("outline.jump"), { page: target })}`,
4868
+ title: hint,
4558
4869
  style: {
4559
4870
  ...rowStyle$2,
4560
4871
  paddingLeft: 6 + Math.min(item.depth, MAX_INDENT_DEPTH) * INDENT$1,
@@ -4660,6 +4971,13 @@ const countStyle$1 = {
4660
4971
  fontWeight: 400,
4661
4972
  opacity: .65
4662
4973
  };
4974
+ /** 来源说明:三种文档解析出来的目录长得不一样,给用户一句口径。 */
4975
+ const sourceStyle = {
4976
+ flexShrink: 0,
4977
+ padding: "0 4px 6px",
4978
+ fontSize: 11,
4979
+ opacity: .58
4980
+ };
4663
4981
  const listStyle = {
4664
4982
  flex: 1,
4665
4983
  minHeight: 0,
@@ -28421,14 +28739,12 @@ const footStyle = {
28421
28739
  marginTop: 8
28422
28740
  };
28423
28741
  const smallButtonStyle$1 = {
28742
+ ...SOFT_BUTTON_STYLE,
28424
28743
  height: 22,
28425
28744
  padding: "0 8px",
28426
28745
  fontSize: 11.5,
28427
28746
  lineHeight: 1.2,
28428
28747
  borderRadius: 5,
28429
- border: "1px solid rgba(127,127,127,0.35)",
28430
- background: "transparent",
28431
- color: "inherit",
28432
28748
  cursor: "pointer",
28433
28749
  whiteSpace: "nowrap"
28434
28750
  };
@@ -28757,6 +29073,138 @@ function AnnotationOverlay({ annotations, viewport, flashKey }) {
28757
29073
  })
28758
29074
  });
28759
29075
  }
29076
+ /**
29077
+ * 加到标题元素上的临时锚点属性。
29078
+ *
29079
+ * 只出现在插件自己生成的 HTML 里(笔记正文经 {@link parseHtmlHeadings} 加工),
29080
+ * 不会写回 Zotero;不用原生 `id`,免得撞上笔记里本来就有的锚点。
29081
+ */
29082
+ const OUTLINE_ANCHOR_ATTR = "data-dsh-zp-outline";
29083
+ function pageTarget(page) {
29084
+ return {
29085
+ kind: "page",
29086
+ page
29087
+ };
29088
+ }
29089
+ function anchorTarget(id) {
29090
+ return {
29091
+ kind: "anchor",
29092
+ id: String(id)
29093
+ };
29094
+ }
29095
+ /**
29096
+ * 标题级别 → 缩进层级。
29097
+ *
29098
+ * 以整篇文档里**最小的标题级别**为 0:通篇只有 h3 的页面不该整体缩进两格,
29099
+ * 网页快照尤其常见(正文从 h2 起)。PDF 书签不用这个,它自带树形层级。
29100
+ */
29101
+ function headingDepths(levels) {
29102
+ if (levels.length === 0) return [];
29103
+ const base = Math.min(...levels);
29104
+ return levels.map((level) => Math.max(0, Math.min(7, level - base)));
29105
+ }
29106
+ const HTML_HEADING_TAGS = {
29107
+ H1: 1,
29108
+ H2: 2,
29109
+ H3: 3,
29110
+ H4: 4,
29111
+ H5: 5,
29112
+ H6: 6
29113
+ };
29114
+ /** 元素纯文本或纯文本行里的 Markdown 标题(`# 标题`)。 */
29115
+ const MARKDOWN_HEADING = /^(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/u;
29116
+ const MARKDOWN_LINE = /^[ \t]{0,3}(#{1,6})[ \t]+(.+?)[ \t]*#*[ \t]*$/u;
29117
+ function tidy(value) {
29118
+ return value.replace(/\s+/gu, " ").trim();
29119
+ }
29120
+ /**
29121
+ * 从 HTML 片段里提标题,并给每个标题打上锚点。
29122
+ *
29123
+ * 笔记是 Zotero 存的 HTML:标题通常是 `<h1>`–`<h6>`,但 Markdown 源码被原样贴进
29124
+ * 笔记时会变成 `<p># 标题</p>`,所以两种都认。解析用 `DOMParser` 的 inert 文档,
29125
+ * 只取节点与文本、不执行任何脚本;正文里危险的标签 Host 侧已经剥过。
29126
+ *
29127
+ * 返回加工后的 HTML 而不是只返回条目:标题节点要带锚点,跳转才有落点。
29128
+ */
29129
+ function parseHtmlHeadings(html) {
29130
+ const doc = new DOMParser().parseFromString(`<body>${html}</body>`, "text/html");
29131
+ const candidates = Array.from(doc.body.querySelectorAll("h1,h2,h3,h4,h5,h6,p,li,blockquote"));
29132
+ const picked = [];
29133
+ const pickedElements = /* @__PURE__ */ new Set();
29134
+ for (const element of candidates) {
29135
+ if (picked.length >= 800) break;
29136
+ let parent = element.parentElement;
29137
+ let nested = false;
29138
+ while (parent !== null && parent !== doc.body) {
29139
+ if (pickedElements.has(parent)) {
29140
+ nested = true;
29141
+ break;
29142
+ }
29143
+ parent = parent.parentElement;
29144
+ }
29145
+ if (nested) continue;
29146
+ const raw = tidy(element.textContent ?? "");
29147
+ const tagLevel = HTML_HEADING_TAGS[element.tagName] ?? 0;
29148
+ const markdown = tagLevel === 0 ? MARKDOWN_HEADING.exec(raw) : null;
29149
+ const level = tagLevel > 0 ? tagLevel : markdown === null ? 0 : markdown[1].length;
29150
+ const title = tagLevel > 0 ? raw : tidy(markdown?.[2] ?? "");
29151
+ if (level === 0 || title === "") continue;
29152
+ picked.push({
29153
+ element,
29154
+ level,
29155
+ title
29156
+ });
29157
+ pickedElements.add(element);
29158
+ }
29159
+ const depths = headingDepths(picked.map((entry) => entry.level));
29160
+ const items = picked.map((entry, index) => {
29161
+ entry.element.setAttribute(OUTLINE_ANCHOR_ATTR, String(index));
29162
+ return {
29163
+ title: entry.title,
29164
+ depth: depths[index],
29165
+ target: anchorTarget(index)
29166
+ };
29167
+ });
29168
+ return {
29169
+ html: doc.body.innerHTML,
29170
+ items
29171
+ };
29172
+ }
29173
+ /**
29174
+ * 从纯文本里提 Markdown 标题。
29175
+ *
29176
+ * 用于 PDF 全文索引、`.md` 附件的全文文本这类「只有字符串」的兜底视图。跳转目标
29177
+ * 记的是**标题行在全文里的字符偏移**,渲染时不改正文 DOM(标注高亮按同样的偏移
29178
+ * 切分,插锚点会打乱它),跳的时候再按偏移找回文字节点。
29179
+ */
29180
+ function parseMarkdownHeadings(text) {
29181
+ const levels = [];
29182
+ const titles = [];
29183
+ const offsets = [];
29184
+ let offset = 0;
29185
+ let fenced = false;
29186
+ for (const line of text.split("\n")) {
29187
+ if (/^\s*(?:```|~~~)/u.test(line)) fenced = !fenced;
29188
+ else if (!fenced && levels.length < 800) {
29189
+ const match = MARKDOWN_LINE.exec(line);
29190
+ if (match !== null) {
29191
+ const title = tidy(match[2]);
29192
+ if (title !== "") {
29193
+ levels.push(match[1].length);
29194
+ titles.push(title);
29195
+ offsets.push(offset);
29196
+ }
29197
+ }
29198
+ }
29199
+ offset += line.length + 1;
29200
+ }
29201
+ const depths = headingDepths(levels);
29202
+ return titles.map((title, index) => ({
29203
+ title,
29204
+ depth: depths[index],
29205
+ target: anchorTarget(offsets[index])
29206
+ }));
29207
+ }
28760
29208
  //#endregion
28761
29209
  //#region src/client/viewer/pdfjs.ts
28762
29210
  /**
@@ -28788,10 +29236,14 @@ const PDF_CSS = `
28788
29236
  .dsh-zotero-pdf-pages {
28789
29237
  display: flex;
28790
29238
  flex-direction: column;
28791
- align-items: center;
29239
+ align-items: flex-start;
28792
29240
  gap: 12px;
28793
29241
  padding: 12px;
28794
- min-width: min-content;
29242
+ /* 宽度固定为可视区:横向页只向右溢出形成滚动条,不能让它把窄页一起推到
29243
+ 容器中间(混排文档里会出现一侧几百像素的灰边)。每页靠 JS 算的
29244
+ margin-left 在自己的可视区里居中,宽页则贴着左内边距。 */
29245
+ box-sizing: border-box;
29246
+ width: 100%;
28795
29247
  }
28796
29248
  .dsh-zotero-pdf-page {
28797
29249
  position: relative;
@@ -29019,6 +29471,7 @@ function SelectionBar({ t, text, x, y, onInsert, onDismiss, annotate }) {
29019
29471
  const active = type === value;
29020
29472
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
29021
29473
  type: "button",
29474
+ className: softButtonClass(active),
29022
29475
  onMouseDown: (event) => event.preventDefault(),
29023
29476
  onClick: () => setType(value),
29024
29477
  disabled: annotate?.busy === true,
@@ -29055,6 +29508,7 @@ function SelectionBar({ t, text, x, y, onInsert, onDismiss, annotate }) {
29055
29508
  }, color)),
29056
29509
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
29057
29510
  type: "button",
29511
+ className: softButtonClass(commentOpen),
29058
29512
  onMouseDown: (event) => event.preventDefault(),
29059
29513
  onClick: () => setCommentOpen((open) => !open),
29060
29514
  style: {
@@ -29086,20 +29540,19 @@ function SelectionBar({ t, text, x, y, onInsert, onDismiss, annotate }) {
29086
29540
  style: groupStyle,
29087
29541
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
29088
29542
  type: "button",
29543
+ className: SOFT_BUTTON_CLASS,
29089
29544
  onClick: copy,
29090
29545
  style: buttonStyle,
29091
29546
  children: t("action.copy")
29092
29547
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
29093
29548
  type: "button",
29549
+ className: SOFT_BUTTON_CLASS,
29094
29550
  onMouseDown: (event) => event.preventDefault(),
29095
29551
  onClick: () => {
29096
29552
  onInsert(text);
29097
29553
  finish();
29098
29554
  },
29099
- style: {
29100
- ...buttonStyle,
29101
- borderLeft: "1px solid rgba(127,127,127,0.25)"
29102
- },
29555
+ style: buttonStyle,
29103
29556
  children: t("action.insertItemShort")
29104
29557
  })]
29105
29558
  })
@@ -29133,28 +29586,22 @@ const groupStyle = {
29133
29586
  whiteSpace: "nowrap"
29134
29587
  };
29135
29588
  const buttonStyle = {
29589
+ ...SOFT_BUTTON_STYLE,
29136
29590
  padding: "3px 8px",
29137
- border: "none",
29138
- background: "transparent",
29139
- color: "inherit",
29591
+ borderRadius: 5,
29140
29592
  font: "inherit",
29141
29593
  cursor: "pointer",
29142
29594
  whiteSpace: "nowrap"
29143
29595
  };
29144
29596
  const chipStyle$1 = {
29597
+ ...SOFT_BUTTON_STYLE,
29145
29598
  padding: "2px 6px",
29146
- border: "1px solid rgba(127,127,127,0.25)",
29147
29599
  borderRadius: 5,
29148
- background: "transparent",
29149
- color: "inherit",
29150
29600
  font: "inherit",
29151
29601
  cursor: "pointer",
29152
29602
  whiteSpace: "nowrap"
29153
29603
  };
29154
- const chipActiveStyle = {
29155
- borderColor: "rgba(80, 140, 255, 0.6)",
29156
- background: "rgba(80, 140, 255, 0.14)"
29157
- };
29604
+ const chipActiveStyle = SOFT_BUTTON_ACTIVE_STYLE;
29158
29605
  const swatchStyle = {
29159
29606
  width: 15,
29160
29607
  height: 15,
@@ -29302,6 +29749,10 @@ function useReadPosition(attachmentKey) {
29302
29749
  * 分片节奏由 `renderQueue.paceChunk` 接管(滚动中远处的页等停手、近处的页隔帧),
29303
29750
  * 文本层与选区框校正等停稳后才做,滚动期间文本层直接不上屏(字是透明的,撤掉
29304
29751
  * 不影响画面);页码定位读缓存的页面 top 数组,不在滚动帧里读 `offsetTop`。
29752
+ *
29753
+ * 缩放按「页号 + 页内相对坐标」锚定视口中心那个文档点,倍率改完再把它放回中心,
29754
+ * 横竖两轴都不跳;之所以不用 scrollHeight 的比例,是因为同一份 PDF 里可能混着
29755
+ * 竖排和横排页,总高并不随倍率等比例变化。
29305
29756
  */
29306
29757
  const MIN_SCALE = .5;
29307
29758
  const MAX_SCALE = 3;
@@ -29315,6 +29766,8 @@ const ZOOM_STEPS = [
29315
29766
  2,
29316
29767
  3
29317
29768
  ];
29769
+ /** 页面容器左右内边距(与 PDF_CSS 的 padding 一致),适应宽度和水平居中都按它算。 */
29770
+ const GUTTER = 12;
29318
29771
  const FLASH_MS$1 = 1600;
29319
29772
  /** 停手这么久就把文本层放回屏幕(比绘制让路的判定短:字要尽早能选)。 */
29320
29773
  const SCROLLING_FLAG_MS = 140;
@@ -29326,13 +29779,51 @@ const RETAIN_MARGIN = "300% 0px";
29326
29779
  const MAX_CANVAS_PIXELS = 5242880;
29327
29780
  const EMPTY_PAGES = /* @__PURE__ */ new Set();
29328
29781
  const EMPTY_ANNOTATIONS = [];
29329
- /** 目录条目数与层级的硬上限:个别 PDF 的书签能上千条,面板画不完也没人看得完。 */
29330
- const OUTLINE_MAX_ITEMS = 800;
29331
- const OUTLINE_MAX_DEPTH = 8;
29332
29782
  function errorText$1(error) {
29333
29783
  return error instanceof Error ? error.message : String(error);
29334
29784
  }
29335
29785
  /**
29786
+ * pdf.js 的「服务器返回 N」:形如
29787
+ * `Unexpected server response (404) while retrieving PDF "dsh-app://app/…".`
29788
+ */
29789
+ const SERVER_RESPONSE = /Unexpected server response \((\d{3})\)/u;
29790
+ /**
29791
+ * 去掉 pdf.js 文案里的 URL。
29792
+ *
29793
+ * 那串 `dsh-app://app/dsh-zotero/api/file?key=…` 对用户没有任何用处,只会让
29794
+ * 提示看起来像内部报错;状态码留着,真正的原因由 {@link explainLoadFailure} 补。
29795
+ */
29796
+ function tidyLoadError(message) {
29797
+ return message.replace(/\s*while retrieving PDF\s*"[^"]*"\.?/u, "").trim();
29798
+ }
29799
+ /**
29800
+ * 把「服务器返回 404」翻译成人话。
29801
+ *
29802
+ * `/api/file` 成功时发的是二进制流,失败时 pdf.js 只拿得到状态码,于是界面上
29803
+ * 只剩一句看不懂的 404。这里补一次 `/api/attachment-info` 探测:
29804
+ * - 探测失败 → 那条错误消息就是真相(「附件文件不存在:/path」「没有权限读取」),
29805
+ * 能一键修的错误还会带上 `fix`;
29806
+ * - 探测成功 → 文件本身读得到,这次 404 是瞬时的(Zotero 重启、正在重建索引),
29807
+ * 提示重试比解释原因有用。
29808
+ *
29809
+ * 非 HTTP 类失败(加密、损坏、内存不足)一律返回 `null`,让原文案照原样显示。
29810
+ */
29811
+ async function explainLoadFailure(error, key, t, signal) {
29812
+ const status = SERVER_RESPONSE.exec(errorText$1(error))?.[1];
29813
+ if (status === void 0 || key === "") return null;
29814
+ try {
29815
+ const info = await fetchAttachmentInfo(key, signal);
29816
+ if (!info.servable) return { text: tpl(t("viewer.unsupported"), { type: info.contentType || info.filename }) };
29817
+ return { text: tpl(t("viewer.serverResponse"), { status }) };
29818
+ } catch (probeError) {
29819
+ const fix = probeError instanceof ApiFailure ? probeError.fix : void 0;
29820
+ return {
29821
+ text: tpl(t("viewer.attachmentUnavailable"), { message: tidyLoadError(errorText$1(probeError)) }),
29822
+ ...fix === void 0 ? {} : { fix }
29823
+ };
29824
+ }
29825
+ }
29826
+ /**
29336
29827
  * 一条书签的 `dest` → 1 基页码。
29337
29828
  *
29338
29829
  * `dest` 有两种形态:命名目标(字符串,要去 catalog 里查)或显式数组
@@ -29373,14 +29864,15 @@ async function readOutline(pdf) {
29373
29864
  const out = [];
29374
29865
  const walk = async (nodes, depth) => {
29375
29866
  for (const node of nodes) {
29376
- if (out.length >= OUTLINE_MAX_ITEMS) return;
29867
+ if (out.length >= 800) return;
29868
+ const page = await outlinePageOf(pdf, node.dest);
29377
29869
  out.push({
29378
29870
  title: (node.title ?? "").trim() || "(无标题)",
29379
- page: await outlinePageOf(pdf, node.dest),
29871
+ target: page === null ? null : pageTarget(page),
29380
29872
  depth
29381
29873
  });
29382
29874
  const children = node.items;
29383
- if (depth + 1 < OUTLINE_MAX_DEPTH && Array.isArray(children) && children.length > 0) await walk(children, depth + 1);
29875
+ if (depth + 1 < 8 && Array.isArray(children) && children.length > 0) await walk(children, depth + 1);
29384
29876
  }
29385
29877
  };
29386
29878
  await walk(tree, 0);
@@ -29500,7 +29992,7 @@ function moveLineBreaksOffscreen(container) {
29500
29992
  br.replaceWith(holder);
29501
29993
  }
29502
29994
  }
29503
- const PdfPage = (0, react.memo)(function PdfPage({ label, pdf, pageNumber, scale, active, retained, estimateWidth, estimateHeight, annotations, flashKey, onAnnotationClick, priorityOf }) {
29995
+ const PdfPage = (0, react.memo)(function PdfPage({ label, pdf, pageNumber, scale, active, retained, estimateWidth, estimateHeight, containerWidth, annotations, flashKey, onAnnotationClick, priorityOf }) {
29504
29996
  const wrapRef = (0, react.useRef)(null);
29505
29997
  const hostRef = (0, react.useRef)(null);
29506
29998
  const textRef = (0, react.useRef)(null);
@@ -29656,9 +30148,12 @@ const PdfPage = (0, react.memo)(function PdfPage({ label, pdf, pageNumber, scale
29656
30148
  const annotation = hitTest(event.clientX, event.clientY);
29657
30149
  if (annotation !== null) onAnnotationClick(annotation, event.clientX, event.clientY);
29658
30150
  }
30151
+ const pageWidth = viewport?.width ?? estimateWidth;
30152
+ const leftInset = Math.max(0, (containerWidth - pageWidth) / 2 - GUTTER);
29659
30153
  const pageStyle = {
29660
- width: viewport?.width ?? estimateWidth,
30154
+ width: pageWidth,
29661
30155
  height: viewport?.height ?? estimateHeight,
30156
+ marginLeft: leftInset,
29662
30157
  "--total-scale-factor": scale,
29663
30158
  "--scale-round-x": "1px",
29664
30159
  "--scale-round-y": "1px"
@@ -29715,7 +30210,10 @@ function PdfViewer(props) {
29715
30210
  const rootRef = (0, react.useRef)(null);
29716
30211
  const scrollRef = (0, react.useRef)(null);
29717
30212
  const cardRef = (0, react.useRef)(null);
29718
- const anchorRef = (0, react.useRef)(null);
30213
+ /** 每次缩放前记下的锚点,由 useLayoutEffect 在新布局里消费一次。 */
30214
+ const zoomAnchorRef = (0, react.useRef)(null);
30215
+ /** 即使倍率没变(已到上限、适应宽度时本来就相等)也要消费掉锚点,所以用计数强制跑一次。 */
30216
+ const [zoomTick, setZoomTick] = (0, react.useState)(0);
29719
30217
  const rafRef = (0, react.useRef)(null);
29720
30218
  const flashTimerRef = (0, react.useRef)(null);
29721
30219
  /** 「正在滚动」标记的定时器:停手一会儿后把文本层放回屏幕上。 */
@@ -29779,6 +30277,9 @@ function PdfViewer(props) {
29779
30277
  return;
29780
30278
  }
29781
30279
  let disposed = false;
30280
+ const key = source?.attachmentKey ?? "";
30281
+ /** 换文档/卸载时把探测请求一起取消,别让它在后台白跑。 */
30282
+ const probe = new AbortController();
29782
30283
  setLoading(true);
29783
30284
  setError(null);
29784
30285
  setPdf(null);
@@ -29818,12 +30319,16 @@ function PdfViewer(props) {
29818
30319
  });
29819
30320
  }).catch((loadError) => {
29820
30321
  if (disposed) return;
29821
- setError(errorText$1(loadError));
30322
+ setError({ text: tpl(t("viewer.failed"), { message: tidyLoadError(errorText$1(loadError)) }) });
29822
30323
  setLoading(false);
29823
30324
  outlineRef.current?.([]);
30325
+ explainLoadFailure(loadError, key, t, probe.signal).then((reason) => {
30326
+ if (!disposed && reason !== null) setError(reason);
30327
+ });
29824
30328
  });
29825
30329
  return () => {
29826
30330
  disposed = true;
30331
+ probe.abort();
29827
30332
  task.destroy();
29828
30333
  };
29829
30334
  }, [
@@ -29936,10 +30441,51 @@ function PdfViewer(props) {
29936
30441
  pageCount,
29937
30442
  notePage
29938
30443
  ]);
29939
- const applyZoom = (next) => {
30444
+ /**
30445
+ * 改倍率前先固定屏幕上 (x, y) 这一点的文档位置。
30446
+ *
30447
+ * 只记「第几页 + 页内相对坐标」:混排 PDF 里各页高宽不同,按 scrollHeight
30448
+ * 比例还原会偏;按页记则不管页怎么变,同一个字仍落在同一个屏幕位置。
30449
+ * 点落在页间空隙或灰边上时就归到最近的一页,比例允许超出 0..1。
30450
+ */
30451
+ const captureZoomAnchor = (0, react.useCallback)((x, y) => {
30452
+ const element = scrollRef.current;
30453
+ const pages = element?.firstElementChild;
30454
+ if (element === null || element === void 0 || pages === null || pages === void 0) return;
30455
+ const count = pages.children.length;
30456
+ if (count === 0) return;
30457
+ const docX = element.scrollLeft + x;
30458
+ const docY = element.scrollTop + y;
30459
+ let index = 0;
30460
+ for (let i = 0; i < count; i += 1) {
30461
+ const child = pages.children[i];
30462
+ if (docY <= child.offsetTop + child.offsetHeight) {
30463
+ index = i;
30464
+ break;
30465
+ }
30466
+ index = i;
30467
+ }
30468
+ const page = pages.children[index];
30469
+ const top = page.offsetTop;
30470
+ const width = page.offsetWidth;
30471
+ const height = page.offsetHeight;
30472
+ if (width <= 0 || height <= 0) return;
30473
+ zoomAnchorRef.current = {
30474
+ page: index + 1,
30475
+ fx: (docX - page.offsetLeft) / width,
30476
+ fy: (docY - top) / height,
30477
+ x,
30478
+ y
30479
+ };
30480
+ setZoomTick((value) => value + 1);
30481
+ }, []);
30482
+ /** 按钮 / 命令行缩放按视口中心锚定;Ctrl+滚轮按鼠标位置锚定。 */
30483
+ const applyZoom = (0, react.useCallback)((next, at) => {
30484
+ const element = scrollRef.current;
30485
+ if (element !== null) captureZoomAnchor(at?.x ?? element.clientWidth / 2, at?.y ?? element.clientHeight / 2);
29940
30486
  setFitWidth(false);
29941
30487
  setManualScale(clampScale(next));
29942
- };
30488
+ }, [captureZoomAnchor]);
29943
30489
  const scaleRef = (0, react.useRef)(scale);
29944
30490
  scaleRef.current = scale;
29945
30491
  (0, react.useEffect)(() => {
@@ -29949,25 +30495,31 @@ function PdfViewer(props) {
29949
30495
  if (!(event.ctrlKey || event.metaKey)) return;
29950
30496
  event.preventDefault();
29951
30497
  const rect = element.getBoundingClientRect();
29952
- const y = event.clientY - rect.top;
29953
- anchorRef.current = {
29954
- ratio: element.scrollHeight > 0 ? (element.scrollTop + y) / element.scrollHeight : 0,
29955
- y
29956
- };
29957
30498
  const factor = event.deltaY < 0 ? 1.1 : 1 / 1.1;
29958
- setFitWidth(false);
29959
- setManualScale(clampScale(scaleRef.current * factor));
30499
+ applyZoom(scaleRef.current * factor, {
30500
+ x: Math.min(Math.max(event.clientX - rect.left, 0), element.clientWidth),
30501
+ y: Math.min(Math.max(event.clientY - rect.top, 0), element.clientHeight)
30502
+ });
29960
30503
  };
29961
30504
  element.addEventListener("wheel", onWheel, { passive: false });
29962
30505
  return () => element.removeEventListener("wheel", onWheel);
29963
- }, []);
30506
+ }, [applyZoom]);
30507
+ /** 布局已按新倍率提交:把锚点那个文档点放回原来的屏幕位置,横竖两轴一起调。 */
29964
30508
  (0, react.useLayoutEffect)(() => {
29965
- const anchor = anchorRef.current;
30509
+ const anchor = zoomAnchorRef.current;
29966
30510
  const element = scrollRef.current;
29967
30511
  if (anchor === null || element === null) return;
29968
- anchorRef.current = null;
29969
- element.scrollTop = Math.max(0, anchor.ratio * element.scrollHeight - anchor.y);
29970
- }, [scale]);
30512
+ zoomAnchorRef.current = null;
30513
+ topsRef.current = null;
30514
+ const target = element.querySelector(`[data-zp-page="${anchor.page}"]`);
30515
+ if (target === null) return;
30516
+ element.scrollLeft = Math.max(0, target.offsetLeft + anchor.fx * target.offsetWidth - anchor.x);
30517
+ element.scrollTop = Math.max(0, target.offsetTop + anchor.fy * target.offsetHeight - anchor.y);
30518
+ }, [
30519
+ zoomTick,
30520
+ scale,
30521
+ fitWidth
30522
+ ]);
29971
30523
  const annotationsByPage = (0, react.useMemo)(() => {
29972
30524
  const map = /* @__PURE__ */ new Map();
29973
30525
  for (const annotation of annotations) {
@@ -30206,10 +30758,17 @@ function PdfViewer(props) {
30206
30758
  locate,
30207
30759
  currentPage: () => currentPageRef.current,
30208
30760
  goToPage,
30761
+ goToOutline: (target) => {
30762
+ if (target?.kind === "page") goToPage(target.page);
30763
+ },
30209
30764
  zoomIn,
30210
30765
  zoomOut,
30211
30766
  setZoom: (percent) => applyZoom(percent / 100),
30212
- fitToWidth: () => setFitWidth(true)
30767
+ fitToWidth: () => {
30768
+ const element = scrollRef.current;
30769
+ if (element !== null) captureZoomAnchor(element.clientWidth / 2, element.clientHeight / 2);
30770
+ setFitWidth(true);
30771
+ }
30213
30772
  }));
30214
30773
  (0, react.useEffect)(() => () => {
30215
30774
  if (rafRef.current !== null) window.cancelAnimationFrame(rafRef.current);
@@ -30268,6 +30827,7 @@ function PdfViewer(props) {
30268
30827
  retained: retainedPages.has(index + 1),
30269
30828
  estimateWidth,
30270
30829
  estimateHeight,
30830
+ containerWidth,
30271
30831
  annotations: annotationsByPage.get(index) ?? EMPTY_ANNOTATIONS,
30272
30832
  flashKey: index === flashPage ? flashKey : null,
30273
30833
  onAnnotationClick,
@@ -30283,29 +30843,46 @@ function PdfViewer(props) {
30283
30843
  style: hintOverlayStyle,
30284
30844
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
30285
30845
  style: {
30286
- maxWidth: 260,
30846
+ maxWidth: 300,
30287
30847
  textAlign: "center"
30288
30848
  },
30289
30849
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
30290
- style: { margin: "0 0 8px" },
30291
- children: tpl(t("viewer.failed"), { message: error })
30850
+ style: {
30851
+ margin: "0 0 8px",
30852
+ lineHeight: 1.5
30853
+ },
30854
+ children: error.text
30292
30855
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
30293
30856
  style: {
30294
30857
  display: "flex",
30295
30858
  gap: 6,
30296
- justifyContent: "center"
30859
+ justifyContent: "center",
30860
+ flexWrap: "wrap"
30297
30861
  },
30298
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30299
- type: "button",
30300
- onClick: () => setRetry((value) => value + 1),
30301
- style: smallButtonStyle,
30302
- children: t("action.retry")
30303
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30304
- type: "button",
30305
- onClick: () => onOpenInZotero(1),
30306
- style: smallButtonStyle,
30307
- children: t("viewer.openInZotero")
30308
- })]
30862
+ children: [
30863
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30864
+ type: "button",
30865
+ onClick: () => setRetry((value) => value + 1),
30866
+ style: smallButtonStyle,
30867
+ children: t("action.retry")
30868
+ }),
30869
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30870
+ type: "button",
30871
+ onClick: () => onOpenInZotero(1),
30872
+ style: smallButtonStyle,
30873
+ children: t("viewer.openInZotero")
30874
+ }),
30875
+ error.fix !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
30876
+ type: "button",
30877
+ onClick: () => {
30878
+ openSystemSettings(error.fix).catch((reason) => {
30879
+ showToast(tpl(t("viewer.openSettingsFailed"), { message: errorText$1(reason) }));
30880
+ });
30881
+ },
30882
+ style: smallButtonStyle,
30883
+ children: t("viewer.openPrivacySettings")
30884
+ })
30885
+ ]
30309
30886
  })]
30310
30887
  })
30311
30888
  }),
@@ -30347,14 +30924,12 @@ const hintOverlayStyle = {
30347
30924
  pointerEvents: "none"
30348
30925
  };
30349
30926
  const smallButtonStyle = {
30927
+ ...SOFT_BUTTON_STYLE,
30350
30928
  height: 22,
30351
30929
  padding: "0 8px",
30352
30930
  fontSize: 11.5,
30353
30931
  lineHeight: 1.2,
30354
30932
  borderRadius: 5,
30355
- border: "1px solid rgba(127,127,127,0.35)",
30356
- background: "transparent",
30357
- color: "inherit",
30358
30933
  cursor: "pointer",
30359
30934
  whiteSpace: "nowrap"
30360
30935
  };
@@ -30374,6 +30949,7 @@ const smallButtonStyle = {
30374
30949
  const SNAPSHOT_CHANNEL = "dsh-zotero/snapshot";
30375
30950
  const EVENT_TYPES = /* @__PURE__ */ new Set([
30376
30951
  "ready",
30952
+ "outline",
30377
30953
  "applied",
30378
30954
  "selection",
30379
30955
  "locate-result",
@@ -30411,6 +30987,9 @@ function commandEnvelope(command) {
30411
30987
  *
30412
30988
  * `annotations` 用一份轻量签名做依赖:`onChanged()` 之后详情会整份重取,
30413
30989
  * 数组引用每次都变;按签名判断可以避免无关重渲染也往 iframe 里推一遍。
30990
+ *
30991
+ * 网页标题目录也走这座桥:iframe 里扫 h1–h6 打锚点后上报 `outline`,本组件转成
30992
+ * 统一目录项交给左上角浮层;点目录项发 `scroll-to-outline` 让 iframe 自己滚。
30414
30993
  */
30415
30994
  /** 桥接脚本一般几百毫秒就绪;超过这个时间就认定它没跑起来。 */
30416
30995
  const BRIDGE_TIMEOUT_MS = 8e3;
@@ -30431,6 +31010,28 @@ function itemsOf(annotations) {
30431
31010
  }
30432
31011
  return items;
30433
31012
  }
31013
+ /**
31014
+ * iframe 报上来的标题目录 → 统一目录项。
31015
+ *
31016
+ * 消息来自沙箱里的页面脚本,虽然只能伪造文字也不能写库,还是逐字段收窄一遍:
31017
+ * 标题与锚点必须是字符串、层级夹到面板画得出来的范围、条数封顶。
31018
+ */
31019
+ function outlineOf(raw) {
31020
+ const items = [];
31021
+ for (const entry of raw) {
31022
+ if (items.length >= 800) break;
31023
+ if (typeof entry?.title !== "string" || typeof entry?.id !== "string") continue;
31024
+ const title = entry.title.trim();
31025
+ if (title === "") continue;
31026
+ const depth = typeof entry.depth === "number" && Number.isFinite(entry.depth) ? Math.max(0, Math.min(7, Math.trunc(entry.depth))) : 0;
31027
+ items.push({
31028
+ title,
31029
+ depth,
31030
+ target: anchorTarget(entry.id)
31031
+ });
31032
+ }
31033
+ return items;
31034
+ }
30434
31035
  /** 只把 http(s) 交给系统:快照里的 `javascript:` / `file:` 一律丢弃。 */
30435
31036
  function openExternal(href) {
30436
31037
  let url;
@@ -30442,7 +31043,7 @@ function openExternal(href) {
30442
31043
  if (url.protocol !== "http:" && url.protocol !== "https:") return;
30443
31044
  window.open(url.href, "_blank", "noopener,noreferrer");
30444
31045
  }
30445
- function SnapshotViewer({ t, detail, source, annotations, viewerRef, onReady, onInsertExcerpt, onInsertAnnotation, onOpenInZotero, onChanged }) {
31046
+ function SnapshotViewer({ t, detail, source, annotations, viewerRef, onReady, onInsertExcerpt, onInsertAnnotation, onOpenInZotero, onChanged, onOutlineChange }) {
30446
31047
  const rootRef = (0, react.useRef)(null);
30447
31048
  const frameRef = (0, react.useRef)(null);
30448
31049
  const cardRef = (0, react.useRef)(null);
@@ -30451,6 +31052,9 @@ function SnapshotViewer({ t, detail, source, annotations, viewerRef, onReady, on
30451
31052
  const selectionRef = (0, react.useRef)(null);
30452
31053
  const annotationsRef = (0, react.useRef)(annotations);
30453
31054
  annotationsRef.current = annotations;
31055
+ /** 目录回调走 ref:message 监听只该挂一次,不该因父级重渲染换了回调身份就重挂。 */
31056
+ const outlineRef = (0, react.useRef)(onOutlineChange);
31057
+ outlineRef.current = onOutlineChange;
30454
31058
  const [reloadKey, setReloadKey] = (0, react.useState)(0);
30455
31059
  const [bridgeReady, setBridgeReady] = (0, react.useState)(false);
30456
31060
  const [bridgeMissing, setBridgeMissing] = (0, react.useState)(false);
@@ -30534,13 +31138,19 @@ function SnapshotViewer({ t, detail, source, annotations, viewerRef, onReady, on
30534
31138
  if (data.type === "ready") {
30535
31139
  readyRef.current = true;
30536
31140
  setBridgeReady(true);
30537
- setStaleBridge((data.bridge ?? 1) < 2);
31141
+ const bridge = data.bridge ?? 1;
31142
+ setStaleBridge(bridge < 3);
30538
31143
  setBridgeMissing(false);
31144
+ if (bridge < 3) outlineRef.current?.([]);
30539
31145
  pushAnnotations();
30540
31146
  flushLocate();
30541
31147
  onReady();
30542
31148
  return;
30543
31149
  }
31150
+ if (data.type === "outline") {
31151
+ outlineRef.current?.(outlineOf(Array.isArray(data.items) ? data.items : []));
31152
+ return;
31153
+ }
30544
31154
  if (data.type === "applied") {
30545
31155
  setMissed(typeof data.error === "string" ? data.total : Math.max(0, data.total - data.resolved));
30546
31156
  flushLocate();
@@ -30573,6 +31183,7 @@ function SnapshotViewer({ t, detail, source, annotations, viewerRef, onReady, on
30573
31183
  const timer = window.setTimeout(() => {
30574
31184
  if (readyRef.current) return;
30575
31185
  setBridgeMissing(true);
31186
+ outlineRef.current?.([]);
30576
31187
  }, BRIDGE_TIMEOUT_MS);
30577
31188
  return () => window.clearTimeout(timer);
30578
31189
  }, [reloadKey]);
@@ -30593,6 +31204,12 @@ function SnapshotViewer({ t, detail, source, annotations, viewerRef, onReady, on
30593
31204
  locate,
30594
31205
  currentPage: () => 1,
30595
31206
  goToPage: () => void 0,
31207
+ goToOutline: (target) => {
31208
+ if (target?.kind === "anchor") post({
31209
+ type: "scroll-to-outline",
31210
+ id: target.id
31211
+ });
31212
+ },
30596
31213
  zoomIn: () => void 0,
30597
31214
  zoomOut: () => void 0,
30598
31215
  setZoom: () => void 0,
@@ -30776,28 +31393,61 @@ const noticeStyle = {
30776
31393
  zIndex: 9
30777
31394
  };
30778
31395
  const retryStyle = {
31396
+ ...SOFT_BUTTON_STYLE,
30779
31397
  marginLeft: "auto",
30780
31398
  padding: "2px 8px",
30781
31399
  fontSize: 11.5,
30782
31400
  borderRadius: 5,
30783
- border: "1px solid rgba(127,127,127,0.35)",
30784
- background: "transparent",
30785
- color: "inherit",
30786
31401
  cursor: "pointer",
30787
31402
  whiteSpace: "nowrap"
30788
31403
  };
30789
31404
  //#endregion
30790
31405
  //#region src/client/viewer/TextViewer.tsx
30791
31406
  /**
30792
- * 文本渲染器:PDF 全文或独立笔记的纯文本兜底视图。
31407
+ * 文本渲染器:独立笔记 / Markdown 页面、PDF 全文或其它附件的纯文本兜底视图。
30793
31408
  *
30794
31409
  * PDF.js 不可用(非 PDF 附件、浏览器拒绝渲染、文件缺失)时由注册表回退到这里。
30795
31410
  * 标注只有 `range`(全文区间)能落到文字上;点标注列表仍会滚动定位并闪烁。
30796
31411
  * 该渲染器没有分页与缩放,工具条据 `capabilities` 自动隐藏对应控件。
31412
+ *
31413
+ * 目录:笔记按 HTML 标题(`<h1>`–`<h6>`,或写成 Markdown 的 `<p># 标题</p>`)解析,
31414
+ * 纯文本按 `#` 标题行解析,都上报给左上角那一份统一目录浮层。笔记用元素锚点定位,
31415
+ * 纯文本用字符偏移定位——后者不能往正文里插锚点,否则按同样偏移切分的标注会错位。
30797
31416
  */
30798
31417
  const FLASH_CLASS = "dsh-zotero-ann-flash";
30799
31418
  const FLASH_MS = 1200;
31419
+ const OUTLINE_FLASH_CLASS = "dsh-zp-outline-flash";
30800
31420
  const TEXT_TYPES = /* @__PURE__ */ new Set(["highlight", "underline"]);
31421
+ /** 把视口里的某个 y 坐标滚到滚动容器顶部偏下一点的位置。 */
31422
+ function scrollBoxTo(box, viewportTop) {
31423
+ const boxTop = box.getBoundingClientRect().top;
31424
+ box.scrollTo({
31425
+ top: Math.max(0, box.scrollTop + viewportTop - boxTop - 8),
31426
+ behavior: "smooth"
31427
+ });
31428
+ }
31429
+ /**
31430
+ * 全文字符偏移 → 文字节点内偏移。
31431
+ *
31432
+ * 正文被标注切片包成 `<mark>` / `<span>`,但 `textContent` 与 `fulltext.content`
31433
+ * 完全一致,所以按文档顺序累加文字节点长度就能换回去。只遍历 `contentRef` 这一层,
31434
+ * 不含「全文索引兜底」等提示文字。
31435
+ */
31436
+ function textNodeAtOffset(root, offset) {
31437
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
31438
+ let consumed = 0;
31439
+ let current = walker.nextNode();
31440
+ while (current !== null) {
31441
+ const length = current.nodeValue?.length ?? 0;
31442
+ if (offset <= consumed + length) return {
31443
+ node: current,
31444
+ local: offset - consumed
31445
+ };
31446
+ consumed += length;
31447
+ current = walker.nextNode();
31448
+ }
31449
+ return null;
31450
+ }
30801
31451
  const AnnotatedText = (0, react.memo)(function AnnotatedText({ segments }) {
30802
31452
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: segments.map((segment, index) => {
30803
31453
  if (segment.kind === "text") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: segment.text }, index);
@@ -30823,14 +31473,26 @@ const AnnotatedText = (0, react.memo)(function AnnotatedText({ segments }) {
30823
31473
  }, index);
30824
31474
  }) });
30825
31475
  });
30826
- function TextViewer({ t, detail, annotations, viewerRef, onReady, onInsertExcerpt }) {
31476
+ function TextViewer({ t, detail, annotations, viewerRef, onReady, onInsertExcerpt, onOutlineChange }) {
30827
31477
  const boxRef = (0, react.useRef)(null);
31478
+ /** 纯文本正文的内层:字符偏移只在这层里数,排除上下两条提示文字。 */
31479
+ const contentRef = (0, react.useRef)(null);
30828
31480
  const flashTimer = (0, react.useRef)(null);
31481
+ const outlineTimer = (0, react.useRef)(null);
30829
31482
  const [selection, setSelection] = (0, react.useState)(null);
30830
31483
  const selfNote = detail.itemType === "note" ? detail.notes.find((note) => note.key === detail.key) ?? null : null;
30831
31484
  const fulltext = detail.fulltext;
30832
31485
  const marked = (0, react.useMemo)(() => selfNote === null ? annotations.filter((annotation) => TEXT_TYPES.has(annotation.type)) : [], [annotations, selfNote]);
30833
31486
  const segments = (0, react.useMemo)(() => buildSegments(fulltext?.content ?? "", marked), [fulltext, marked]);
31487
+ /** 笔记 HTML 加好标题锚点后再交给 `dangerouslySetInnerHTML`。 */
31488
+ const noteParsed = (0, react.useMemo)(() => selfNote === null ? null : parseHtmlHeadings(selfNote.html), [selfNote]);
31489
+ const textOutline = (0, react.useMemo)(() => fulltext === null ? [] : parseMarkdownHeadings(fulltext.content), [fulltext]);
31490
+ /** 目录回调走 ref:上报 effect 不该因父级重渲染换了回调身份就重跑。 */
31491
+ const outlineRef = (0, react.useRef)(onOutlineChange);
31492
+ outlineRef.current = onOutlineChange;
31493
+ (0, react.useEffect)(() => {
31494
+ outlineRef.current?.(noteParsed?.items ?? textOutline);
31495
+ }, [noteParsed, textOutline]);
30834
31496
  (0, react.useEffect)(() => {
30835
31497
  const timer = window.setTimeout(onReady, 0);
30836
31498
  return () => window.clearTimeout(timer);
@@ -30841,6 +31503,7 @@ function TextViewer({ t, detail, annotations, viewerRef, onReady, onInsertExcerp
30841
31503
  ]);
30842
31504
  (0, react.useEffect)(() => () => {
30843
31505
  if (flashTimer.current !== null) window.clearTimeout(flashTimer.current);
31506
+ if (outlineTimer.current !== null) window.clearTimeout(outlineTimer.current);
30844
31507
  }, []);
30845
31508
  function locate(annotationKey) {
30846
31509
  const box = boxRef.current;
@@ -30863,10 +31526,41 @@ function TextViewer({ t, detail, annotations, viewerRef, onReady, onInsertExcerp
30863
31526
  }, FLASH_MS);
30864
31527
  return true;
30865
31528
  }
31529
+ function flashHeading(element) {
31530
+ if (outlineTimer.current !== null) window.clearTimeout(outlineTimer.current);
31531
+ element.classList.remove(OUTLINE_FLASH_CLASS);
31532
+ element.offsetWidth;
31533
+ element.classList.add(OUTLINE_FLASH_CLASS);
31534
+ outlineTimer.current = window.setTimeout(() => {
31535
+ element.classList.remove(OUTLINE_FLASH_CLASS);
31536
+ outlineTimer.current = null;
31537
+ }, FLASH_MS);
31538
+ }
31539
+ function goToOutline(target) {
31540
+ const box = boxRef.current;
31541
+ if (target === null || target.kind !== "anchor" || box === null) return;
31542
+ if (noteParsed !== null) {
31543
+ if (!/^\d+$/u.test(target.id)) return;
31544
+ const element = box.querySelector(`[${OUTLINE_ANCHOR_ATTR}="${target.id}"]`);
31545
+ if (element === null) return;
31546
+ scrollBoxTo(box, element.getBoundingClientRect().top);
31547
+ flashHeading(element);
31548
+ return;
31549
+ }
31550
+ const offset = Number.parseInt(target.id, 10);
31551
+ if (!Number.isFinite(offset) || contentRef.current === null) return;
31552
+ const hit = textNodeAtOffset(contentRef.current, offset);
31553
+ if (hit === null) return;
31554
+ const range = document.createRange();
31555
+ range.setStart(hit.node, Math.min(Math.max(hit.local, 0), hit.node.nodeValue?.length ?? 0));
31556
+ range.collapse(true);
31557
+ scrollBoxTo(box, range.getBoundingClientRect().top);
31558
+ }
30866
31559
  (0, react.useImperativeHandle)(viewerRef, () => ({
30867
31560
  locate,
30868
31561
  currentPage: () => 1,
30869
31562
  goToPage: () => void 0,
31563
+ goToOutline,
30870
31564
  zoomIn: () => void 0,
30871
31565
  zoomOut: () => void 0,
30872
31566
  setZoom: () => void 0,
@@ -30907,7 +31601,7 @@ function TextViewer({ t, detail, annotations, viewerRef, onReady, onInsertExcerp
30907
31601
  style: noteStyle,
30908
31602
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
30909
31603
  className: "dsh-zotero-note",
30910
- dangerouslySetInnerHTML: { __html: selfNote.html }
31604
+ dangerouslySetInnerHTML: { __html: noteParsed?.html ?? selfNote.html }
30911
31605
  }), selfNote.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
30912
31606
  style: truncatedStyle,
30913
31607
  children: t("detail.noteTruncated")
@@ -30919,7 +31613,10 @@ function TextViewer({ t, detail, annotations, viewerRef, onReady, onInsertExcerp
30919
31613
  style: fallbackStyle,
30920
31614
  children: t("detail.fulltextFallback")
30921
31615
  }),
30922
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotatedText, { segments }),
31616
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
31617
+ ref: contentRef,
31618
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotatedText, { segments })
31619
+ }),
30923
31620
  fulltext?.truncated === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
30924
31621
  style: truncatedStyle,
30925
31622
  children: t("detail.fulltextTruncated")
@@ -30985,6 +31682,16 @@ const TEXT_CSS = `
30985
31682
  0%, 100% { outline-color: transparent; }
30986
31683
  20%, 80% { outline-color: rgba(80,140,255,0.95); }
30987
31684
  }
31685
+ .dsh-zp-outline-flash {
31686
+ border-radius: 3px;
31687
+ outline: 2px solid transparent;
31688
+ outline-offset: 2px;
31689
+ animation: dsh-zp-outline-flash 1.1s ease-in-out 1;
31690
+ }
31691
+ @keyframes dsh-zp-outline-flash {
31692
+ 0%, 100% { outline-color: transparent; }
31693
+ 20%, 80% { outline-color: rgba(80,140,255,0.95); }
31694
+ }
30988
31695
  `;
30989
31696
  //#endregion
30990
31697
  //#region src/client/viewer/WebpageViewer.tsx
@@ -31089,7 +31796,8 @@ const RENDERERS = [
31089
31796
  id: "snapshot",
31090
31797
  capabilities: {
31091
31798
  zoom: false,
31092
- pageNavigation: false
31799
+ pageNavigation: false,
31800
+ outline: true
31093
31801
  },
31094
31802
  match: (source) => source !== null && isHtml(source),
31095
31803
  Component: SnapshotViewer
@@ -31098,7 +31806,8 @@ const RENDERERS = [
31098
31806
  id: "pdf",
31099
31807
  capabilities: {
31100
31808
  zoom: true,
31101
- pageNavigation: true
31809
+ pageNavigation: true,
31810
+ outline: true
31102
31811
  },
31103
31812
  match: (source) => source !== null && isPdf(source),
31104
31813
  Component: PdfViewer
@@ -31111,7 +31820,8 @@ const RENDERERS = [
31111
31820
  id: "webpage",
31112
31821
  capabilities: {
31113
31822
  zoom: false,
31114
- pageNavigation: false
31823
+ pageNavigation: false,
31824
+ outline: true
31115
31825
  },
31116
31826
  match: (source, detail) => detail.itemType === "webpage" && (source === null || !isPdf(source) && !isHtml(source)),
31117
31827
  Component: WebpageViewer
@@ -31120,7 +31830,8 @@ const RENDERERS = [
31120
31830
  id: "text",
31121
31831
  capabilities: {
31122
31832
  zoom: false,
31123
- pageNavigation: false
31833
+ pageNavigation: false,
31834
+ outline: true
31124
31835
  },
31125
31836
  match: () => true,
31126
31837
  Component: TextViewer
@@ -31420,6 +32131,7 @@ const iconButtonStyle = {
31420
32131
  cursor: "pointer"
31421
32132
  };
31422
32133
  const toolButtonStyle = {
32134
+ ...SOFT_BUTTON_STYLE,
31423
32135
  flexShrink: 0,
31424
32136
  display: "inline-flex",
31425
32137
  alignItems: "center",
@@ -31430,9 +32142,6 @@ const toolButtonStyle = {
31430
32142
  fontSize: 11.5,
31431
32143
  lineHeight: 1,
31432
32144
  borderRadius: 5,
31433
- border: "1px solid rgba(127,127,127,0.3)",
31434
- background: "transparent",
31435
- color: "inherit",
31436
32145
  cursor: "pointer",
31437
32146
  whiteSpace: "nowrap"
31438
32147
  };
@@ -31451,6 +32160,14 @@ const toolButtonStyle = {
31451
32160
  /** 定位重试:渲染器刚就绪时页面占位可能还没提交,最多试几次。 */
31452
32161
  const LOCATE_RETRIES = 6;
31453
32162
  const LOCATE_RETRY_MS = 60;
32163
+ /** 目录来源说明:同一份浮层服务三类文档,给用户一句口径。 */
32164
+ const OUTLINE_SOURCE_LABEL = {
32165
+ pdf: "outline.source.pdf",
32166
+ snapshot: "outline.source.snapshot",
32167
+ note: "outline.source.note",
32168
+ text: "outline.source.text",
32169
+ webpage: "outline.source.text"
32170
+ };
31454
32171
  function errorMessage$1(error) {
31455
32172
  return error instanceof Error ? error.message : String(error);
31456
32173
  }
@@ -31470,7 +32187,7 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
31470
32187
  const [infoOpen, setInfoOpen] = (0, react.useState)(false);
31471
32188
  const [outlineOpen, setOutlineOpen] = (0, react.useState)(false);
31472
32189
  const [outline, setOutline] = (0, react.useState)({
31473
- attachmentKey: "",
32190
+ documentKey: "",
31474
32191
  items: null
31475
32192
  });
31476
32193
  const [selectedKey, setSelectedKey] = (0, react.useState)(null);
@@ -31511,17 +32228,19 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
31511
32228
  } : null;
31512
32229
  /** 收起信息浮层;`InfoPanel` 内部再用 `useDismiss` 接管「点浮层外 / Esc」。 */
31513
32230
  const closeInfo = (0, react.useCallback)(() => setInfoOpen(false), []);
31514
- const sourceKey = source?.attachmentKey ?? "";
32231
+ const documentKey = `${detail.key}:${source?.attachmentKey ?? "self"}`;
31515
32232
  /** 归属对不上的目录一律当「还没读到」,绝不用上一条文献的书签跳页。 */
31516
- const outlineItems = outline.attachmentKey === sourceKey ? outline.items : null;
32233
+ const outlineItems = outline.documentKey === documentKey ? outline.items : null;
31517
32234
  const handleOutlineChange = (0, react.useCallback)((items) => {
31518
32235
  setOutline({
31519
- attachmentKey: sourceKey,
32236
+ documentKey,
31520
32237
  items
31521
32238
  });
31522
- }, [sourceKey]);
31523
- /** 目录按钮只在有分页的文档上出现:跳页是这个浮层唯一的用处。 */
31524
- const outlineAvailable = pickRenderer(source, detail).capabilities.pageNavigation;
32239
+ }, [documentKey]);
32240
+ const renderer = pickRenderer(source, detail);
32241
+ /** 目录按钮按渲染器能力出现:PDF / 快照 / 笔记 / 全文共用左上角那一个浮层。 */
32242
+ const outlineAvailable = renderer.capabilities.outline;
32243
+ const outlineSourceLabel = t(OUTLINE_SOURCE_LABEL[detail.itemType === "note" ? "note" : renderer.id] ?? "outline.source.text");
31525
32244
  const flushPendingLocate = (0, react.useCallback)((key, attempt) => {
31526
32245
  if (locateTimer.current !== null) {
31527
32246
  window.clearTimeout(locateTimer.current);
@@ -31571,13 +32290,14 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
31571
32290
  });
31572
32291
  }
31573
32292
  /**
31574
- * 跳页。
32293
+ * 跳到一条目录项。
31575
32294
  *
31576
- * 跳完就收起目录:浮层压在文档左边,留着会把刚跳过去的那一页挡掉一半。
32295
+ * 目标原样交给渲染器:PDF 按页、网页快照 / 笔记按标题锚点,面板不解释。
32296
+ * 跳完就收起目录:浮层压在文档左边,留着会把刚跳过去的内容挡掉一半。
31577
32297
  */
31578
- function jumpToPage(page) {
32298
+ function jumpToOutline(item) {
31579
32299
  setOutlineOpen(false);
31580
- viewerRef.current?.goToPage(page);
32300
+ if (item.target !== null) viewerRef.current?.goToOutline(item.target);
31581
32301
  }
31582
32302
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
31583
32303
  style: rootStyle,
@@ -31598,13 +32318,14 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
31598
32318
  outlineAvailable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OutlinePanel, {
31599
32319
  t,
31600
32320
  items: outlineItems,
32321
+ sourceLabel: outlineSourceLabel,
31601
32322
  open: outlineOpen,
31602
32323
  onToggle: () => {
31603
32324
  if (!outlineOpen) setInfoOpen(false);
31604
32325
  setOutlineOpen(!outlineOpen);
31605
32326
  },
31606
32327
  onClose: () => setOutlineOpen(false),
31607
- onJump: jumpToPage
32328
+ onJump: jumpToOutline
31608
32329
  }),
31609
32330
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InfoPanel, {
31610
32331
  t,
@@ -31900,7 +32621,7 @@ function ZoteroItemPane(props) {
31900
32621
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
31901
32622
  style: { margin: "0 0 8px" },
31902
32623
  children: tpl(t("detail.loadFailed"), { message: error ?? "" })
31903
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
32624
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
31904
32625
  variant: "outline",
31905
32626
  size: "sm",
31906
32627
  onClick: () => setRetry((n) => n + 1),
@@ -31930,7 +32651,8 @@ function ZoteroItemPane(props) {
31930
32651
  * - 顶部筛选框只筛目录名(同 Zotero 左栏):命中分类保留、非命中的祖先作为
31931
32652
  * 上下文行保留、未命中的子分类隐藏;筛选期间自动展开命中路径。
31932
32653
  * - 展开状态放在 {@link paneStore}:右侧栏切 tab 时正文会被卸载重挂,
31933
- * 只有模块级 store 能让树保持原样。
32654
+ * 只有模块级 store 能让树保持原样;store 再把「选中 + 展开」写进 localStorage,
32655
+ * 页面刷新后也能回到上次的位置。
31934
32656
  */
31935
32657
  /** 每层缩进量(px)。 */
31936
32658
  const INDENT = 14;
@@ -31958,26 +32680,44 @@ const VIRTUAL_NODES = [
31958
32680
  icon: "TRASH"
31959
32681
  }
31960
32682
  ];
31961
- function glyph(path) {
32683
+ function glyph(icon, size = 15) {
31962
32684
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
31963
- width: 14,
31964
- height: 14,
32685
+ width: size,
32686
+ height: size,
31965
32687
  viewBox: "0 0 16 16",
31966
32688
  fill: "none",
31967
- stroke: "currentColor",
31968
- strokeWidth: 1.3,
32689
+ stroke: icon.color,
32690
+ strokeWidth: 1.4,
31969
32691
  strokeLinejoin: "round",
31970
- style: { opacity: .65 },
31971
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: path })
32692
+ strokeLinecap: "round",
32693
+ "aria-hidden": true,
32694
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: icon.path })
31972
32695
  });
31973
32696
  }
31974
- const FOLDER_ICON = "M2.5 12.5V4.5a1 1 0 0 1 1-1h3L8 5h4.5a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1z";
31975
- const LIBRARY_ICON = "M2.5 3.5h5v9h-5zM8.5 3.5h5v9h-5z";
31976
- /** 虚拟分类的图标 path(键与 {@link VIRTUAL_NODES.icon} 对应)。 */
32697
+ /** 蓝色古典柱廊:对应 Zotero 的「我的文库」。 */
32698
+ const LIBRARY_ICON = {
32699
+ path: "M1.7 5.9 8 2.5l6.3 3.4zM2.7 6.5h10.6M3.7 7.1v4.7M6.5 7.1v4.7M9.5 7.1v4.7M12.3 7.1v4.7M2.2 12.1h11.6M2.7 12.1v1.4h10.6v-1.4",
32700
+ color: TREE_BLUE
32701
+ };
32702
+ /** 蓝色文件夹:左上带 tab、中间一道盖线,Zotero 分类图标的轮廓。 */
32703
+ const FOLDER_ICON = {
32704
+ path: "M2.3 5.1V4.4a.8.8 0 0 1 .8-.8h3.4L7.9 5.3h5.8a.8.8 0 0 1 .8.8v6.6a.8.8 0 0 1-.8.8H3.1a.8.8 0 0 1-.8-.8zM2.3 6.7h12.2",
32705
+ color: TREE_BLUE
32706
+ };
32707
+ /** 虚拟分类的图标(键与 {@link VIRTUAL_NODES.icon} 对应)。 */
31977
32708
  const VIRTUAL_ICON = {
31978
- BOOK: "M3 2.8 8 2l5 0.8v10.4L8 14l-5-0.8zM8 2v12",
31979
- UNFILED: FOLDER_ICON,
31980
- TRASH: "M3.2 4.5h9.6M6.3 4.5V3h3.4v1.5M4.6 4.5l0.6 9.2h5.6l0.6-9.2M6.8 7v4.4M9.2 7v4.4"
32709
+ BOOK: {
32710
+ path: "M4 2.4h5.4L12 5v8.6H4zM9.4 2.4V5H12M6.2 8h4M6.2 10.4h4",
32711
+ color: TREE_GREEN
32712
+ },
32713
+ UNFILED: {
32714
+ path: "M4.2 2.5h5.2L12 5v8.5H4.2zM9.4 2.5V5H12M6.3 8.1h4M6.3 10.4h2.7",
32715
+ color: TREE_ORANGE
32716
+ },
32717
+ TRASH: {
32718
+ path: "M3.2 4.5h9.6M6.3 4.5V3h3.4v1.5M4.6 4.5l0.6 9.2h5.6l0.6-9.2M6.8 7v4.4M9.2 7v4.4",
32719
+ color: TREE_RED
32720
+ }
31981
32721
  };
31982
32722
  function buildForest(collections) {
31983
32723
  const nodes = /* @__PURE__ */ new Map();
@@ -32032,8 +32772,13 @@ const rowStyle = {
32032
32772
  function rowIndent(depth) {
32033
32773
  return { paddingLeft: BASE_INDENT + depth * INDENT };
32034
32774
  }
32775
+ /** 选中行:浅蓝底 + 蓝色文字,与 Zotero 的灰底相比更贴合整套配色。 */
32035
32776
  function rowBackground(selected) {
32036
- return { background: selected ? "rgba(127,127,127,0.16)" : "transparent" };
32777
+ return selected ? {
32778
+ background: "rgba(74,134,232,0.15)",
32779
+ color: TREE_BLUE,
32780
+ fontWeight: 600
32781
+ } : { background: "transparent" };
32037
32782
  }
32038
32783
  const iconBox = {
32039
32784
  width: 16,
@@ -32292,7 +33037,8 @@ function Magnifier() {
32292
33037
  strokeLinecap: "round",
32293
33038
  style: {
32294
33039
  flexShrink: 0,
32295
- opacity: .55
33040
+ color: "#4a86e8",
33041
+ opacity: .85
32296
33042
  },
32297
33043
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
32298
33044
  cx: "7",
@@ -32345,8 +33091,8 @@ function SearchField({ value, placeholder, clearLabel, onChange }) {
32345
33091
  boxSizing: "border-box",
32346
33092
  padding: "0 7px",
32347
33093
  borderRadius: 6,
32348
- border: `1px solid ${focused ? "rgba(80,140,255,0.7)" : "rgba(127,127,127,0.28)"}`,
32349
- background: "rgba(127,127,127,0.06)",
33094
+ border: `1px solid ${focused ? "rgba(74,134,232,0.75)" : "rgba(74,134,232,0.32)"}`,
33095
+ background: "rgba(74,134,232,0.05)",
32350
33096
  cursor: "text",
32351
33097
  color: "inherit"
32352
33098
  },
@@ -32409,7 +33155,7 @@ const headerStyle = {
32409
33155
  };
32410
33156
  const titleRowStyle = {
32411
33157
  display: "flex",
32412
- alignItems: "baseline",
33158
+ alignItems: "center",
32413
33159
  gap: 8,
32414
33160
  minWidth: 0
32415
33161
  };
@@ -32475,10 +33221,15 @@ const itemBodyStyle = {
32475
33221
  flex: 1,
32476
33222
  minWidth: 0
32477
33223
  };
33224
+ /** 图标固定占位 24px,只居中图标本身,不铺底色。 */
32478
33225
  const itemIconStyle = {
32479
33226
  display: "flex",
33227
+ alignItems: "center",
33228
+ justifyContent: "center",
32480
33229
  flexShrink: 0,
32481
- marginTop: 3
33230
+ width: 24,
33231
+ height: 24,
33232
+ marginTop: 1
32482
33233
  };
32483
33234
  /** 头部引用按钮的紧凑尺寸。 */
32484
33235
  const citeButtonStyle = {
@@ -32640,13 +33391,8 @@ function ItemList(props) {
32640
33391
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
32641
33392
  style: titleRowStyle,
32642
33393
  children: [
32643
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
32644
- style: {
32645
- fontSize: 13,
32646
- overflow: "hidden",
32647
- textOverflow: "ellipsis",
32648
- whiteSpace: "nowrap"
32649
- },
33394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTitle, {
33395
+ title: name,
32650
33396
  children: name
32651
33397
  }),
32652
33398
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -32658,14 +33404,14 @@ function ItemList(props) {
32658
33404
  children: tpl(t("list.count"), { n: itemsTotal })
32659
33405
  }),
32660
33406
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
32661
- chosen.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33407
+ chosen.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
32662
33408
  variant: "outline",
32663
33409
  size: "sm",
32664
33410
  title: t("action.insertSelected"),
32665
33411
  style: citeButtonStyle,
32666
33412
  onClick: () => onInsertItems(chosen),
32667
33413
  children: tpl(t("action.citeCount"), { n: chosen.length })
32668
- }) : isRealCollection && selectedCollection !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33414
+ }) : isRealCollection && selectedCollection !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
32669
33415
  variant: "outline",
32670
33416
  size: "sm",
32671
33417
  title: t("action.insertCollection"),
@@ -32673,7 +33419,7 @@ function ItemList(props) {
32673
33419
  onClick: () => onInsertCollection(selectedCollection),
32674
33420
  children: t("action.insertItemShort")
32675
33421
  }) : null,
32676
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33422
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
32677
33423
  variant: "ghost",
32678
33424
  size: "sm",
32679
33425
  title: sortHint(t, sort),
@@ -32745,7 +33491,7 @@ function ItemList(props) {
32745
33491
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
32746
33492
  style: { margin: "0 0 8px" },
32747
33493
  children: tpl(t("list.loadFailed"), { message: itemsError })
32748
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33494
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
32749
33495
  variant: "outline",
32750
33496
  size: "sm",
32751
33497
  onClick: onRetry,
@@ -32766,7 +33512,7 @@ function ItemList(props) {
32766
33512
  onInsert: onInsertItem
32767
33513
  }, item.key)), items.length < itemsTotal && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
32768
33514
  style: { padding: "6px 4px" },
32769
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33515
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
32770
33516
  variant: "ghost",
32771
33517
  size: "sm",
32772
33518
  disabled: itemsLoading,
@@ -32830,8 +33576,13 @@ const tagFlowStyle = {
32830
33576
  };
32831
33577
  /** 自动标签的淡化程度(Zotero 用斜体区分,这里斜体 + 略淡)。 */
32832
33578
  const AUTOMATIC_OPACITY = .72;
33579
+ /**
33580
+ * 标签胶囊:未选中透明无底色(中性灰细描边),选中 Zotero 深灰底白字。
33581
+ * 自动标签的斜体 + 淡化保留,但选中态不被淡化盖过识别度。
33582
+ */
32833
33583
  function pillStyle(selected, automatic) {
32834
33584
  return {
33585
+ ...selected ? TAG_SELECTED_STYLE : TAG_IDLE_STYLE,
32835
33586
  padding: "1px 7px",
32836
33587
  fontSize: 11.5,
32837
33588
  lineHeight: "17px",
@@ -32839,12 +33590,9 @@ function pillStyle(selected, automatic) {
32839
33590
  overflow: "hidden",
32840
33591
  textOverflow: "ellipsis",
32841
33592
  whiteSpace: "nowrap",
32842
- color: "inherit",
32843
- background: selected ? "rgba(80,140,255,0.18)" : "transparent",
32844
- border: `1px solid ${selected ? "rgba(80,140,255,0.55)" : "rgba(127,127,127,0.32)"}`,
32845
33593
  borderRadius: 9,
32846
33594
  cursor: "pointer",
32847
- opacity: automatic ? AUTOMATIC_OPACITY : 1,
33595
+ opacity: automatic && !selected ? AUTOMATIC_OPACITY : 1,
32848
33596
  fontStyle: automatic ? "italic" : "normal"
32849
33597
  };
32850
33598
  }
@@ -32855,12 +33603,32 @@ function TagPill({ t, tag, selected, scopeCount, scoped, onToggle }) {
32855
33603
  hints.push(tpl(scoped ? t("tags.scopeCount") : t("tags.libraryCount"), { n: scoped ? scopeCount : tag.count }));
32856
33604
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
32857
33605
  type: "button",
33606
+ className: tagButtonClass(selected),
32858
33607
  onClick: onToggle,
32859
33608
  title: hints.join("\n"),
32860
33609
  style: pillStyle(selected, automatic),
32861
33610
  children: tag.name
32862
33611
  });
32863
33612
  }
33613
+ /**
33614
+ * 折叠按钮里的实心三角:画布 10px = 20px 外框的 50%,路径再几乎撑满画布,
33615
+ * 比原来的字符 `▴/▾`(11px 字号下字形只有几像素)醒目得多。
33616
+ * 两个方向用完全镜像的 path,不用 CSS rotate(SVG 的 transform-origin 易出偏差)。
33617
+ */
33618
+ function CollapseArrow({ collapsed }) {
33619
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
33620
+ width: 10,
33621
+ height: 10,
33622
+ viewBox: "0 0 16 16",
33623
+ fill: "currentColor",
33624
+ stroke: "currentColor",
33625
+ strokeWidth: 1.1,
33626
+ strokeLinejoin: "round",
33627
+ style: { flexShrink: 0 },
33628
+ "aria-hidden": true,
33629
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: collapsed ? "M8 13.6 L1 2.4 H15 Z" : "M8 2.4 L1 13.6 H15 Z" })
33630
+ });
33631
+ }
32864
33632
  function TagPanel(props) {
32865
33633
  const { t, tags, tagsLoading, tagsError, tagQuery, selectedTags, tagMode, scoped, tagUsage, tagUsageLoading, onTagQuery, onToggleTag, onClearTags, onSetTagMode, onRetry, onInsertTag, onInsertTagSet } = props;
32866
33634
  const [height, setHeight] = (0, react.useState)(readHeight);
@@ -32946,7 +33714,7 @@ function TagPanel(props) {
32946
33714
  flexShrink: 0
32947
33715
  },
32948
33716
  children: [
32949
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
33717
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTitle, {
32950
33718
  style: { fontSize: 12 },
32951
33719
  children: t("tags.title")
32952
33720
  }),
@@ -32960,23 +33728,23 @@ function TagPanel(props) {
32960
33728
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
32961
33729
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
32962
33730
  type: "button",
33731
+ className: SOFT_BUTTON_CLASS,
32963
33732
  onClick: toggleCollapsed,
32964
33733
  "aria-expanded": !collapsed,
32965
33734
  "aria-label": t(collapsed ? "tags.expand" : "tags.collapse"),
32966
33735
  title: t(collapsed ? "tags.expand" : "tags.collapse"),
32967
33736
  style: {
33737
+ ...SOFT_BUTTON_STYLE,
33738
+ display: "inline-flex",
33739
+ alignItems: "center",
33740
+ justifyContent: "center",
32968
33741
  width: 20,
32969
33742
  height: 20,
32970
33743
  padding: 0,
32971
- fontSize: 11,
32972
- lineHeight: 1,
32973
- color: "#508cff",
32974
- background: "transparent",
32975
- border: "1px solid rgba(80,140,255,0.4)",
32976
33744
  borderRadius: 5,
32977
33745
  cursor: "pointer"
32978
33746
  },
32979
- children: collapsed ? "▾" : "▴"
33747
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapseArrow, { collapsed })
32980
33748
  })
32981
33749
  ]
32982
33750
  }),
@@ -33011,6 +33779,7 @@ function TagPanel(props) {
33011
33779
  }),
33012
33780
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
33013
33781
  type: "button",
33782
+ className: softButtonClass(tagMode === "all"),
33014
33783
  onClick: () => onSetTagMode("all"),
33015
33784
  title: t("tags.matchAllHint"),
33016
33785
  "aria-pressed": tagMode === "all",
@@ -33019,6 +33788,7 @@ function TagPanel(props) {
33019
33788
  }),
33020
33789
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
33021
33790
  type: "button",
33791
+ className: softButtonClass(tagMode === "any"),
33022
33792
  onClick: () => onSetTagMode("any"),
33023
33793
  title: t("tags.matchAnyHint"),
33024
33794
  "aria-pressed": tagMode === "any",
@@ -33027,12 +33797,13 @@ function TagPanel(props) {
33027
33797
  }),
33028
33798
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
33029
33799
  type: "button",
33800
+ className: "dsh-zp-soft-btn",
33030
33801
  onClick: onClearTags,
33031
33802
  style: plainButtonStyle,
33032
33803
  children: t("tags.clear")
33033
33804
  }),
33034
33805
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
33035
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33806
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
33036
33807
  variant: "outline",
33037
33808
  size: "sm",
33038
33809
  disabled: tooMany,
@@ -33064,7 +33835,7 @@ function TagPanel(props) {
33064
33835
  color: "#d29922"
33065
33836
  },
33066
33837
  children: tpl(t("tags.loadFailed"), { message: tagsError })
33067
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
33838
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
33068
33839
  variant: "outline",
33069
33840
  size: "sm",
33070
33841
  onClick: onRetry,
@@ -33103,25 +33874,23 @@ function TagPanel(props) {
33103
33874
  ]
33104
33875
  });
33105
33876
  }
33877
+ /** 「全部 / 任一」互斥开关:与全站按钮同色,只把选中底色加深。 */
33106
33878
  function modeButtonStyle(active) {
33107
33879
  return {
33880
+ ...active ? MODE_BUTTON_ACTIVE_STYLE : SOFT_BUTTON_STYLE,
33108
33881
  padding: "0 5px",
33109
33882
  fontSize: 11,
33110
33883
  lineHeight: "16px",
33111
- color: "inherit",
33112
- background: active ? "rgba(80,140,255,0.18)" : "transparent",
33113
- border: active ? "1px solid rgba(80,140,255,0.5)" : "1px solid rgba(127,127,127,0.3)",
33114
33884
  borderRadius: 5,
33115
33885
  cursor: "pointer"
33116
33886
  };
33117
33887
  }
33888
+ /** 「清除」是普通动作,没有选中态:与全站按钮同色。 */
33118
33889
  const plainButtonStyle = {
33890
+ ...SOFT_BUTTON_STYLE,
33119
33891
  padding: "0 5px",
33120
33892
  fontSize: 11,
33121
33893
  lineHeight: "16px",
33122
- color: "inherit",
33123
- background: "transparent",
33124
- border: "1px solid rgba(127,127,127,0.3)",
33125
33894
  borderRadius: 5,
33126
33895
  cursor: "pointer",
33127
33896
  opacity: .8
@@ -33229,10 +33998,7 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
33229
33998
  flexShrink: 0
33230
33999
  },
33231
34000
  children: [
33232
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
33233
- style: { fontSize: 13 },
33234
- children: libraryName === "" ? t("tab.title") : libraryName
33235
- }),
34001
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTitle, { children: libraryName === "" ? t("tab.title") : libraryName }),
33236
34002
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
33237
34003
  ok: health?.zotero.running === true,
33238
34004
  label: t(health?.zotero.running === true ? "status.zoteroOn" : "status.zoteroOff")
@@ -33242,7 +34008,7 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
33242
34008
  label: t(health?.mcp.running === true ? "status.mcpOn" : "status.mcpOff")
33243
34009
  }),
33244
34010
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
33245
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
34011
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
33246
34012
  variant: "ghost",
33247
34013
  size: "sm",
33248
34014
  onClick: () => void loadTree(true),
@@ -33427,6 +34193,7 @@ const inject = [
33427
34193
  "sessions"
33428
34194
  ];
33429
34195
  function apply(ctx) {
34196
+ installTheme();
33430
34197
  ctx.effect(() => ctx.locale.register(NS, dicts), "dsh-plugin-zotero: dictionaries");
33431
34198
  const t = ctx.locale.bind(NS);
33432
34199
  ctx.effect(() => ctx.sidebarRightTabs.register({