dsh-plugin-zotero 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ curl http://127.0.0.1:23119/api/ # 期望输出:Zotero is running
78
78
  - **右侧栏面板「Zotero 文献库」**:顶部状态栏(Zotero / 模型工具探活)+ 左侧分类树(按需拉取、标题摘要搜索)+ 右侧条目详情或分类概要。
79
79
  - **详情区上下分区**:上方正文区展示标题、元数据、摘要与 PDF 全文;下方用 tab 切换「参考文献 / 笔记 / 标注 / 附件」。两个区域之间的分隔条可拖动,正文占比默认 85% 并按会话记住;没有次级内容的条目正文独占整栏。
80
80
  - **摘要默认折叠**:标题行右侧的箭头按钮展开 / 收起摘要,默认把空间留给正文与全文。
81
- - **笔记可读**:笔记以折叠列表呈现(默认收起,点击标题展开),正文保留 Zotero 的引用块、标注高亮、表格与外链图片;Host 侧已清洗脚本与事件属性,避免注入。「引用」把该条笔记转成纯文本写进会话草稿。
81
+ - **笔记可读**:独立笔记(文库里的全局笔记)打开后正文直接占据上方正文区,跟普通条目一样阅读;条目下的子笔记仍进「笔记」tab,以折叠列表呈现(默认收起,点击标题展开),正文保留 Zotero 的引用块、标注高亮、表格与外链图片。Host 侧已清洗脚本与事件属性,避免注入。「引用」把该条笔记转成纯文本写进会话草稿。
82
82
  - **标注可读**:PDF 上的高亮与划线汇总进「标注」tab(带颜色、页码、原文与评论,可按类型 / 颜色筛选);全文块里原位标出底色与下划线,点列表条目可滚动定位并闪烁,「引用」把该条标注写进会话草稿。
83
83
  - **五种插入方式**:单条目引用、全文划词摘录、单条标注、单条笔记、整目录引用,均只写进会话草稿(不自动发送、不抢焦点),文本携带 `itemKey` / `collectionKey` 供模型接续操作。
84
84
  - **面板严格只读**:不提供任何新建 / 改名 / 删除分类的按钮。
package/client/client.js CHANGED
@@ -31,6 +31,7 @@ const dicts = {
31
31
  "action.insertExcerpt": "添加摘录",
32
32
  "action.insertToChat": "引用到会话",
33
33
  "action.insertCollection": "添加整目录引用",
34
+ "action.retry": "重试",
34
35
  "status.zoteroOn": "Zotero 已连接",
35
36
  "status.zoteroOff": "Zotero 未连接",
36
37
  "status.mcpOn": "模型工具可用",
@@ -43,7 +44,9 @@ const dicts = {
43
44
  "tree.searchPlaceholder": "搜索标题 / 摘要",
44
45
  "tree.count": "{n} 条",
45
46
  "tree.empty": "这个分类下没有条目",
47
+ "tree.loadFailed": "条目加载失败",
46
48
  "detail.empty": "从左侧选择分类或条目",
49
+ "detail.loadFailed": "条目加载失败:{message}",
47
50
  "detail.metadata": "文献信息",
48
51
  "detail.metadataExpand": "展开文献信息",
49
52
  "detail.metadataCollapse": "收起文献信息",
@@ -71,12 +74,14 @@ const dicts = {
71
74
  "detail.annotationNotAnchoredTruncated": "全文超出索引上限,这段原文可能在未返回的部分",
72
75
  "detail.annotationNotAnchoredNoFulltext": "该附件没有全文索引,无法定位",
73
76
  "detail.fulltext": "全文",
77
+ "detail.noteBody": "笔记正文",
74
78
  "detail.noFulltext": "该附件没有可用的全文索引",
75
79
  "detail.fulltextTruncated": "(已按长度截断)",
76
80
  "detail.collectionSummary": "分类:{name}",
77
81
  "detail.collectionCount": "共 {n} 条条目",
78
82
  "detail.bibTitle": "参考文献(APA)",
79
- "detail.noBib": "该分类没有可导出的引用条目(裸 PDF 附件不产生引用)",
83
+ "detail.noBib": "该分类没有可导出的引用条目(笔记与裸 PDF 附件不产生引用)",
84
+ "detail.items": "条目",
80
85
  "error.noEditor": "当前面板不在会话上下文中,无法插入到输入框",
81
86
  "error.draftChanged": "输入框草稿已变化,未插入;请避免在插入期间编辑草稿",
82
87
  "error.empty": "没有可插入的内容",
@@ -149,6 +154,7 @@ const dicts = {
149
154
  "action.insertExcerpt": "Add excerpt",
150
155
  "action.insertToChat": "Add to chat",
151
156
  "action.insertCollection": "Add collection citations",
157
+ "action.retry": "Retry",
152
158
  "status.zoteroOn": "Zotero connected",
153
159
  "status.zoteroOff": "Zotero not connected",
154
160
  "status.mcpOn": "Model tools available",
@@ -161,7 +167,9 @@ const dicts = {
161
167
  "tree.searchPlaceholder": "Search title / abstract",
162
168
  "tree.count": "{n} items",
163
169
  "tree.empty": "No items in this collection",
170
+ "tree.loadFailed": "Failed to load items",
164
171
  "detail.empty": "Select a collection or item on the left",
172
+ "detail.loadFailed": "Failed to load the item: {message}",
165
173
  "detail.metadata": "Metadata",
166
174
  "detail.metadataExpand": "Expand metadata",
167
175
  "detail.metadataCollapse": "Collapse metadata",
@@ -189,12 +197,14 @@ const dicts = {
189
197
  "detail.annotationNotAnchoredTruncated": "The full text was truncated; this passage may be in the omitted part",
190
198
  "detail.annotationNotAnchoredNoFulltext": "No full-text index for this attachment, so it cannot be located",
191
199
  "detail.fulltext": "Full text",
200
+ "detail.noteBody": "Note",
192
201
  "detail.noFulltext": "No full-text index available for this attachment",
193
202
  "detail.fulltextTruncated": "(truncated by length)",
194
203
  "detail.collectionSummary": "Collection: {name}",
195
204
  "detail.collectionCount": "{n} items",
196
205
  "detail.bibTitle": "Bibliography (APA)",
197
- "detail.noBib": "Nothing citable here (bare PDF attachments produce no citation)",
206
+ "detail.noBib": "Nothing citable here (notes and bare PDF attachments produce no citation)",
207
+ "detail.items": "Items",
198
208
  "error.noEditor": "This panel is not in a conversation context; cannot insert into the composer",
199
209
  "error.draftChanged": "The draft changed; nothing was inserted. Avoid editing while inserting.",
200
210
  "error.empty": "Nothing to insert",
@@ -342,12 +352,14 @@ function initialState() {
342
352
  expanded: /* @__PURE__ */ new Set([TREE_ROOT_ID]),
343
353
  nodeItems: {},
344
354
  nodeTotals: {},
355
+ nodeErrors: {},
345
356
  query: "",
346
357
  results: null,
347
358
  selectedItemKey: null,
348
359
  selectedCollection: null,
349
360
  detail: null,
350
361
  detailLoading: false,
362
+ detailError: null,
351
363
  collectionBib: null,
352
364
  toast: null
353
365
  };
@@ -359,6 +371,8 @@ let state = initialState();
359
371
  const listeners = /* @__PURE__ */ new Set();
360
372
  let treeInflight = null;
361
373
  const nodeInflight = /* @__PURE__ */ new Set();
374
+ /** 各节点最近一次加载用的定位信息;刷新时用来重拉已展开的分支。 */
375
+ const nodeTargets = /* @__PURE__ */ new Map();
362
376
  let searchTimer = null;
363
377
  let toastTimer = null;
364
378
  function patch(next) {
@@ -368,6 +382,12 @@ function patch(next) {
368
382
  };
369
383
  for (const listener of listeners) listener();
370
384
  }
385
+ /** 返回去掉某个 key 的记录;没有该 key 时原样返回,避免无意义的新对象。 */
386
+ function withoutKey(record, key) {
387
+ if (!(key in record)) return record;
388
+ const { [key]: _removed, ...rest } = record;
389
+ return rest;
390
+ }
371
391
  /** 订阅整份面板状态(任一字段变化都会触发重渲染)。 */
372
392
  function usePaneState() {
373
393
  const [snapshot, setSnapshot] = (0, react.useState)(getPaneState);
@@ -397,6 +417,21 @@ function loadTree(force = false) {
397
417
  if (treeInflight !== null) return treeInflight;
398
418
  if (!force && state.loaded) return Promise.resolve();
399
419
  patch({ treeLoading: true });
420
+ if (force) {
421
+ const expanded = [...state.expanded];
422
+ patch({
423
+ nodeItems: {},
424
+ nodeTotals: {},
425
+ nodeErrors: {},
426
+ collectionBib: null
427
+ });
428
+ for (const nodeId of expanded) {
429
+ const target = nodeTargets.get(nodeId);
430
+ if (target !== void 0) loadNodeItems(nodeId, target, true);
431
+ }
432
+ if (state.selectedItemKey !== null) openItem(state.selectedItemKey);
433
+ else if (state.selectedCollection !== null) selectCollection(state.selectedCollection);
434
+ }
400
435
  const run = (async () => {
401
436
  try {
402
437
  const [healthData, tree] = await Promise.all([fetchHealth(), fetchTree()]);
@@ -417,10 +452,17 @@ function loadTree(force = false) {
417
452
  treeInflight = run;
418
453
  return run;
419
454
  }
420
- /** 按需拉取某节点的条目;已拉取或正在拉取时直接返回。 */
421
- function loadNodeItems(nodeId, target) {
422
- if (state.nodeItems[nodeId] !== void 0 || nodeInflight.has(nodeId)) return;
455
+ /** 按需拉取某节点的条目;已拉取或正在拉取时直接返回(force 时清缓存重拉)。 */
456
+ function loadNodeItems(nodeId, target, force = false) {
457
+ nodeTargets.set(nodeId, target);
458
+ if (nodeInflight.has(nodeId)) return;
459
+ if (!force && state.nodeItems[nodeId] !== void 0) return;
423
460
  nodeInflight.add(nodeId);
461
+ if (force) patch({
462
+ nodeItems: withoutKey(state.nodeItems, nodeId),
463
+ nodeTotals: withoutKey(state.nodeTotals, nodeId)
464
+ });
465
+ patch({ nodeErrors: withoutKey(state.nodeErrors, nodeId) });
424
466
  fetchItems({
425
467
  ...target,
426
468
  limit: NODE_LIMIT
@@ -435,21 +477,24 @@ function loadNodeItems(nodeId, target) {
435
477
  [nodeId]: data.total
436
478
  }
437
479
  });
438
- }).catch(() => {
480
+ }).catch((error) => {
439
481
  patch({
440
- nodeItems: {
441
- ...state.nodeItems,
442
- [nodeId]: []
443
- },
444
- nodeTotals: {
445
- ...state.nodeTotals,
446
- [nodeId]: 0
482
+ nodeItems: withoutKey(state.nodeItems, nodeId),
483
+ nodeTotals: withoutKey(state.nodeTotals, nodeId),
484
+ nodeErrors: {
485
+ ...state.nodeErrors,
486
+ [nodeId]: errorMessage(error)
447
487
  }
448
488
  });
449
489
  }).finally(() => {
450
490
  nodeInflight.delete(nodeId);
451
491
  });
452
492
  }
493
+ /** 重试某个加载失败的节点(树行内「重试」)。 */
494
+ function retryNode(nodeId) {
495
+ const target = nodeTargets.get(nodeId);
496
+ if (target !== void 0) loadNodeItems(nodeId, target, true);
497
+ }
453
498
  /** 三角箭头:只开合节点,展开时按需拉取条目(根节点没有条目,不传 target)。 */
454
499
  function toggleTreeNode(nodeId, target) {
455
500
  const willOpen = !state.expanded.has(nodeId);
@@ -482,14 +527,15 @@ function setQuery(next) {
482
527
  }).then((data) => patch({ results: data.items })).catch(() => patch({ results: [] }));
483
528
  }, SEARCH_DEBOUNCE_MS);
484
529
  }
485
- /** 打开条目详情。 */
530
+ /** 打开条目详情。失败时记录原因,由详情区就地显示「重试」。 */
486
531
  function openItem(key) {
487
532
  patch({
488
533
  selectedItemKey: key,
489
534
  detail: null,
490
- detailLoading: true
535
+ detailLoading: true,
536
+ detailError: null
491
537
  });
492
- fetchItem(key).then((data) => patch({ detail: data })).catch((error) => showToast(errorMessage(error))).finally(() => patch({ detailLoading: false }));
538
+ fetchItem(key).then((data) => patch({ detail: data })).catch((error) => patch({ detailError: errorMessage(error) })).finally(() => patch({ detailLoading: false }));
493
539
  }
494
540
  /** 选中分类并拉取该目录的引用(APA);虚拟分类(出版物/未分类/回收站)不导出引用。 */
495
541
  function selectCollection(collection) {
@@ -518,6 +564,7 @@ function resetPaneStore() {
518
564
  toastTimer = null;
519
565
  treeInflight = null;
520
566
  nodeInflight.clear();
567
+ nodeTargets.clear();
521
568
  state = initialState();
522
569
  for (const listener of listeners) listener();
523
570
  }
@@ -975,6 +1022,17 @@ function hintStyle$1(depth) {
975
1022
  paddingLeft: BASE_INDENT + depth * INDENT + 22
976
1023
  };
977
1024
  }
1025
+ /** 行内「重试」按钮:失败提示旁的小按钮。 */
1026
+ const retryButtonStyle = {
1027
+ padding: "0 6px",
1028
+ fontSize: 11.5,
1029
+ lineHeight: "18px",
1030
+ color: "inherit",
1031
+ background: "transparent",
1032
+ border: "1px solid rgba(127,127,127,0.35)",
1033
+ borderRadius: 5,
1034
+ cursor: "pointer"
1035
+ };
978
1036
  function Chevron({ open, onToggle }) {
979
1037
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
980
1038
  onClick: (event) => {
@@ -1046,15 +1104,29 @@ function ItemRow({ ctx, item, depth }) {
1046
1104
  });
1047
1105
  }
1048
1106
  function renderItems(ctx, nodeId, depth) {
1107
+ if (ctx.nodeErrors[nodeId] !== void 0) return [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1108
+ style: {
1109
+ ...hintStyle$1(depth),
1110
+ display: "flex",
1111
+ alignItems: "center",
1112
+ gap: 8
1113
+ },
1114
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1115
+ style: { color: "#d29922" },
1116
+ children: ctx.t("tree.loadFailed")
1117
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1118
+ type: "button",
1119
+ onClick: () => ctx.retry(nodeId),
1120
+ style: retryButtonStyle,
1121
+ children: ctx.t("action.retry")
1122
+ })]
1123
+ }, "error")];
1049
1124
  const items = ctx.itemsByNode[nodeId];
1050
1125
  if (items === void 0) return [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1051
1126
  style: hintStyle$1(depth),
1052
1127
  children: ctx.t("status.loading")
1053
1128
  }, "loading")];
1054
- if (items.length === 0) return [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1055
- style: hintStyle$1(depth),
1056
- children: ctx.t("tree.empty")
1057
- }, "empty")];
1129
+ if (items.length === 0) return [];
1058
1130
  return items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ItemRow, {
1059
1131
  ctx,
1060
1132
  item,
@@ -1183,7 +1255,7 @@ function VirtualRows({ ctx, node, depth }) {
1183
1255
  function CollectionTree(props) {
1184
1256
  const { t, collections, selectedItemKey, selectedCollectionKey, onSelectItem, onSelectCollection, onInsertItem, onInsertCollection } = props;
1185
1257
  /** 展开集合与各节点条目都在 store 里(默认展开根节点),重挂面板后原样恢复。 */
1186
- const { expanded, nodeItems, nodeTotals } = usePaneState();
1258
+ const { expanded, nodeItems, nodeTotals, nodeErrors } = usePaneState();
1187
1259
  /** 按需拉取:条目一律由 toggle / select 触发,根节点不再预取全库条目。 */
1188
1260
  function open(nodeId, collection) {
1189
1261
  expandTreeNode(nodeId, loadOpts(collection));
@@ -1200,10 +1272,12 @@ function CollectionTree(props) {
1200
1272
  expanded,
1201
1273
  itemsByNode: nodeItems,
1202
1274
  totalsByNode: nodeTotals,
1275
+ nodeErrors,
1203
1276
  selectedItemKey,
1204
1277
  selectedCollectionKey,
1205
1278
  toggle,
1206
1279
  select,
1280
+ retry: retryNode,
1207
1281
  onSelectItem,
1208
1282
  onInsertItem,
1209
1283
  onInsertCollection
@@ -2028,7 +2102,7 @@ function NoteList({ t, notes, onInsert }) {
2028
2102
  }), open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2029
2103
  className: "dsh-zotero-note",
2030
2104
  dangerouslySetInnerHTML: { __html: note.html },
2031
- style: noteBodyStyle
2105
+ style: noteBodyStyle$1
2032
2106
  })]
2033
2107
  }, note.key);
2034
2108
  })] });
@@ -2038,6 +2112,9 @@ function NoteList({ t, notes, onInsert }) {
2038
2112
  *
2039
2113
  * 笔记 HTML 由 Zotero 生成,段落/引用/高亮标记都是默认样式,这里补一套
2040
2114
  * 贴合右栏密度的排版(引用块、标注高亮、图片、表格)。
2115
+ *
2116
+ * 独立笔记(条目本身就是 note)在详情「全文」位置渲染,那里也引这份样式,
2117
+ * 因此导出。
2041
2118
  */
2042
2119
  const NOTE_CSS = `
2043
2120
  .dsh-zotero-note p { margin: 0 0 6px; }
@@ -2087,7 +2164,7 @@ const insertButtonStyle$1 = {
2087
2164
  lineHeight: 1.2,
2088
2165
  whiteSpace: "nowrap"
2089
2166
  };
2090
- const noteBodyStyle = {
2167
+ const noteBodyStyle$1 = {
2091
2168
  marginTop: 6,
2092
2169
  padding: "6px 8px",
2093
2170
  border: "1px solid rgba(127,127,127,0.25)",
@@ -2114,6 +2191,9 @@ const noteBodyStyle = {
2114
2191
  *
2115
2192
  * 「添加到会话」两处入口:头部按钮(整条目元数据)、全文块里的选区浮出按钮
2116
2193
  * (摘录)。全文块内用鼠标选中文本后浮出小按钮,位置取选区 rect。
2194
+ *
2195
+ * 独立笔记(条目自身 `itemType: "note"`)的正文直接作为全文块内容渲染,
2196
+ * 与打开普通条目一样占据正文区,不再只能去底部「笔记」tab 里翻。
2117
2197
  */
2118
2198
  /** 正文区占比的存储键与取值范围(%)。 */
2119
2199
  const BODY_PERCENT_KEY = "dsh-plugin-zotero.detailBodyPercent";
@@ -2150,6 +2230,34 @@ const insertButtonStyle = {
2150
2230
  lineHeight: 1.2,
2151
2231
  whiteSpace: "nowrap"
2152
2232
  };
2233
+ /** 正文块外框:PDF 全文与独立笔记共用,仅排版细节不同。 */
2234
+ const bodyBoxStyle = {
2235
+ position: "relative",
2236
+ flex: 1,
2237
+ minHeight: 60,
2238
+ overflow: "auto",
2239
+ padding: "8px 10px",
2240
+ border: "1px solid rgba(127,127,127,0.25)",
2241
+ borderRadius: 6,
2242
+ fontSize: 12.5,
2243
+ opacity: .9
2244
+ };
2245
+ /** PDF 全文:纯文本,保留换行。 */
2246
+ const textBodyStyle = {
2247
+ ...bodyBoxStyle,
2248
+ whiteSpace: "pre-wrap",
2249
+ lineHeight: 1.7
2250
+ };
2251
+ /** 独立笔记:HTML 自带块级换行,不能再叠 pre-wrap,否则标签间空白会被放大。 */
2252
+ const noteBodyStyle = {
2253
+ ...bodyBoxStyle,
2254
+ lineHeight: 1.75,
2255
+ overflowWrap: "break-word"
2256
+ };
2257
+ const truncatedHintStyle = {
2258
+ marginTop: 6,
2259
+ opacity: .6
2260
+ };
2153
2261
  /** 去掉 CSL HTML 标签,只留可见文本(zotero 导出的是便携 HTML)。 */
2154
2262
  function stripTags$1(html) {
2155
2263
  return html.replace(/<[^>]*>/gu, "").replace(/\s+/gu, " ").trim();
@@ -2260,6 +2368,11 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2260
2368
  }
2261
2369
  const bib = detail.bib;
2262
2370
  const fulltext = detail.fulltext;
2371
+ /** 条目本身就是独立笔记时,正文即自身,直接放到全文位置展示。 */
2372
+ const selfNote = detail.itemType === "note" ? detail.notes.find((note) => note.key === detail.key) ?? null : null;
2373
+ /** 正文区是否有可展示的内容(PDF 全文或独立笔记正文)。 */
2374
+ const hasBody = fulltext !== null || selfNote !== null;
2375
+ const bodyKey = selfNote !== null ? selfNote.key : fulltext?.attachmentKey ?? "";
2263
2376
  const visibleAnnotations = (0, react.useMemo)(() => filterAnnotations(detail.annotations, annotationFilter), [detail.annotations, annotationFilter]);
2264
2377
  const segments = (0, react.useMemo)(() => buildSegments(fulltext?.content ?? "", visibleAnnotations), [fulltext, visibleAnnotations]);
2265
2378
  (0, react.useEffect)(() => () => {
@@ -2280,7 +2393,7 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2280
2393
  children: stripTags$1(bib)
2281
2394
  })
2282
2395
  });
2283
- if (detail.notes.length > 0) tabs.push({
2396
+ if (detail.notes.length > 0 && selfNote === null) tabs.push({
2284
2397
  id: "notes",
2285
2398
  label: t("detail.notes"),
2286
2399
  hint: String(detail.notes.length),
@@ -2436,7 +2549,7 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2436
2549
  minHeight: 0
2437
2550
  },
2438
2551
  children: [
2439
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: ANNOTATION_CSS }),
2552
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: ANNOTATION_CSS + NOTE_CSS }),
2440
2553
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2441
2554
  style: {
2442
2555
  flex: hasBottom ? `0 0 ${bodyPercent}%` : "1 1 auto",
@@ -2447,7 +2560,7 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2447
2560
  },
2448
2561
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2449
2562
  style: {
2450
- flex: fulltext !== null ? "0 1 auto" : "1 1 auto",
2563
+ flex: hasBody ? "0 1 auto" : "1 1 auto",
2451
2564
  minHeight: 44,
2452
2565
  overflow: "auto",
2453
2566
  padding: "12px 14px 0",
@@ -2470,7 +2583,7 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2470
2583
  lineHeight: 1.4
2471
2584
  },
2472
2585
  children: detail.title
2473
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2586
+ }), selfNote === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2474
2587
  variant: "outline",
2475
2588
  size: "sm",
2476
2589
  onClick: onInsertItem,
@@ -2514,78 +2627,87 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onInsertAnnotati
2514
2627
  ]
2515
2628
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2516
2629
  style: {
2517
- flex: fulltext !== null ? "1 1 0" : "0 0 auto",
2630
+ flex: hasBody ? "1 1 0" : "0 0 auto",
2518
2631
  minHeight: 0,
2519
2632
  display: "flex",
2520
2633
  flexDirection: "column",
2521
2634
  padding: "2px 14px 14px"
2522
2635
  },
2523
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2524
- style: sectionTitleStyle,
2525
- children: [t("detail.fulltext"), fulltext !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2526
- style: {
2527
- opacity: .55,
2528
- fontWeight: 400,
2529
- marginLeft: 8
2530
- },
2531
- children: fulltext.attachmentKey
2532
- })]
2533
- }), fulltext === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2534
- style: {
2535
- margin: 0,
2536
- opacity: .6
2537
- },
2538
- children: t("detail.noFulltext")
2539
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2540
- ref: boxRef,
2541
- onMouseUp: handleMouseUp,
2636
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2542
2637
  style: {
2543
- position: "relative",
2544
- flex: 1,
2545
- minHeight: 60,
2546
- overflow: "auto",
2547
- padding: "8px 10px",
2548
- border: "1px solid rgba(127,127,127,0.25)",
2549
- borderRadius: 6,
2550
- whiteSpace: "pre-wrap",
2551
- fontSize: 12.5,
2552
- lineHeight: 1.7,
2553
- opacity: .9
2638
+ display: "flex",
2639
+ alignItems: "center",
2640
+ gap: 6,
2641
+ marginBottom: 6
2554
2642
  },
2555
2643
  children: [
2556
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotatedText, { segments }),
2557
- fulltext.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2644
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
2558
2645
  style: {
2559
- marginTop: 6,
2560
- opacity: .6
2646
+ ...sectionTitleStyle,
2647
+ margin: 0
2561
2648
  },
2562
- children: t("detail.fulltextTruncated")
2649
+ children: [t(selfNote !== null ? "detail.noteBody" : "detail.fulltext"), bodyKey !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2650
+ style: {
2651
+ opacity: .55,
2652
+ fontWeight: 400,
2653
+ marginLeft: 8
2654
+ },
2655
+ children: bodyKey
2656
+ })]
2563
2657
  }),
2564
- selection !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2565
- type: "button",
2566
- onMouseDown: (event) => event.preventDefault(),
2567
- onClick: () => {
2568
- onInsertExcerpt(selection.text);
2569
- window.getSelection()?.removeAllRanges();
2570
- setSelection(null);
2571
- },
2572
- style: {
2573
- position: "absolute",
2574
- left: selection.x,
2575
- top: selection.y,
2576
- transform: "translate(-50%, -130%)",
2577
- padding: "3px 8px",
2578
- fontSize: 12,
2579
- borderRadius: 6,
2580
- border: "1px solid rgba(127,127,127,0.35)",
2581
- background: "rgba(40,40,40,0.92)",
2582
- color: "#fff",
2583
- cursor: "pointer",
2584
- zIndex: 5
2585
- },
2586
- children: t("action.insertExcerpt")
2658
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
2659
+ selfNote !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2660
+ variant: "outline",
2661
+ size: "sm",
2662
+ onClick: () => onInsertNote(selfNote),
2663
+ title: t("action.insertToChat"),
2664
+ style: insertButtonStyle,
2665
+ children: t("action.insertItemShort")
2587
2666
  })
2588
2667
  ]
2668
+ }), !hasBody ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2669
+ style: {
2670
+ margin: 0,
2671
+ opacity: .6
2672
+ },
2673
+ children: t("detail.noFulltext")
2674
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2675
+ ref: boxRef,
2676
+ onMouseUp: handleMouseUp,
2677
+ style: selfNote === null ? textBodyStyle : noteBodyStyle,
2678
+ children: [selfNote !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2679
+ className: "dsh-zotero-note",
2680
+ dangerouslySetInnerHTML: { __html: selfNote.html }
2681
+ }), selfNote.truncated && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2682
+ style: truncatedHintStyle,
2683
+ children: t("detail.noteTruncated")
2684
+ })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotatedText, { segments }), fulltext?.truncated === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2685
+ style: truncatedHintStyle,
2686
+ children: t("detail.fulltextTruncated")
2687
+ })] }), selection !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2688
+ type: "button",
2689
+ onMouseDown: (event) => event.preventDefault(),
2690
+ onClick: () => {
2691
+ onInsertExcerpt(selection.text);
2692
+ window.getSelection()?.removeAllRanges();
2693
+ setSelection(null);
2694
+ },
2695
+ style: {
2696
+ position: "absolute",
2697
+ left: selection.x,
2698
+ top: selection.y,
2699
+ transform: "translate(-50%, -130%)",
2700
+ padding: "3px 8px",
2701
+ fontSize: 12,
2702
+ borderRadius: 6,
2703
+ border: "1px solid rgba(127,127,127,0.35)",
2704
+ background: "rgba(40,40,40,0.92)",
2705
+ color: "#fff",
2706
+ cursor: "pointer",
2707
+ zIndex: 5
2708
+ },
2709
+ children: t("action.insertExcerpt")
2710
+ })]
2589
2711
  })]
2590
2712
  })]
2591
2713
  }),
@@ -2685,7 +2807,7 @@ function StatusDot({ ok, label }) {
2685
2807
  });
2686
2808
  }
2687
2809
  function ZoteroPane({ t, inputActions }) {
2688
- const { health, libraryName, collections, treeError, treeLoading, query, results, selectedItemKey, selectedCollection, detail, detailLoading, collectionBib, toast } = usePaneState();
2810
+ const { health, libraryName, collections, treeError, treeLoading, query, results, selectedItemKey, selectedCollection, detail, detailLoading, detailError, collectionBib, nodeItems, nodeErrors, toast } = usePaneState();
2689
2811
  (0, react.useEffect)(() => {
2690
2812
  loadTree();
2691
2813
  }, []);
@@ -2770,6 +2892,8 @@ function ZoteroPane({ t, inputActions }) {
2770
2892
  report,
2771
2893
  t
2772
2894
  ]);
2895
+ /** 分类详情里的条目列表:与左侧树共用同一份缓存(选中分类时树已按需拉取)。 */
2896
+ const collectionItems = selectedCollection === null ? void 0 : nodeItems[selectedCollection.key];
2773
2897
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2774
2898
  style: {
2775
2899
  position: "relative",
@@ -2915,9 +3039,24 @@ function ZoteroPane({ t, inputActions }) {
2915
3039
  overflow: "auto",
2916
3040
  minHeight: 0
2917
3041
  },
2918
- children: selectedItemKey !== null ? detailLoading || detail === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3042
+ children: selectedItemKey !== null ? detailLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2919
3043
  style: hintStyle,
2920
3044
  children: t("status.loading")
3045
+ }) : detail === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3046
+ style: {
3047
+ padding: "12px 14px",
3048
+ fontSize: 12.5,
3049
+ color: "#d29922"
3050
+ },
3051
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
3052
+ style: { margin: "0 0 8px" },
3053
+ children: tpl(t("detail.loadFailed"), { message: detailError ?? "" })
3054
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3055
+ variant: "outline",
3056
+ size: "sm",
3057
+ onClick: () => openItem(selectedItemKey),
3058
+ children: t("action.retry")
3059
+ })]
2921
3060
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ItemDetail, {
2922
3061
  t,
2923
3062
  detail,
@@ -2975,7 +3114,25 @@ function ZoteroPane({ t, inputActions }) {
2975
3114
  opacity: .85
2976
3115
  },
2977
3116
  children: stripTags(collectionBib)
2978
- })] })
3117
+ })] }),
3118
+ collectionItems !== void 0 && collectionItems.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
3119
+ style: {
3120
+ ...sectionTitleStyle,
3121
+ margin: "16px 0 6px"
3122
+ },
3123
+ children: t("detail.items")
3124
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: collectionItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3125
+ onClick: () => openItem(item.key),
3126
+ style: resultRowStyle,
3127
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3128
+ style: resultTitleStyle,
3129
+ title: item.title,
3130
+ children: item.title
3131
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3132
+ style: resultMetaStyle,
3133
+ children: [item.creators, item.year].filter((part) => part !== "").join(" · ")
3134
+ })]
3135
+ }, item.key)) })] })
2979
3136
  ]
2980
3137
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2981
3138
  style: hintStyle,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-zotero",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Install this plugin and DSH can operate your Zotero for you: search the library, read PDF full text, summarize highlights and notes, organize collections by topic, import your downloaded papers, and attach a translated version back to an item. The right sidebar also gains a Zotero library panel that brings an item, an excerpt or a whole collection into the conversation with one click.",
5
5
  "keywords": [
6
6
  "dsh",