dsh-plugin-zotero 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -12
- package/client/client.js +167 -100
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# dsh-plugin-zotero
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**把 Zotero 和 DSH 连起来。**
|
|
4
|
+
|
|
5
|
+
装好这个插件,大模型就能直接查看、检索和读取你 Zotero 里的文献、笔记和 PDF 全文;你也可以在 DSH 右侧栏浏览自己的文库,把条目、摘录或整个目录一键带进对话。
|
|
6
|
+
|
|
7
|
+
不用写代码,也不用记命令。第一次使用前,只需在 Zotero 里完成两项一次性设置(装一个桥接小插件、打开通信开关),步骤见[使用前提](#使用前提)。
|
|
4
8
|
|
|
5
9
|
## 截图
|
|
6
10
|
|
|
@@ -8,24 +12,20 @@
|
|
|
8
12
|
|
|
9
13
|
<sub>上图为 DSH 会话与右侧「Zotero 文献库」面板:上方正文区展示元数据与全文,下方分区 tab 展示参考文献、笔记与附件,点击图片可查看原图。</sub>
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
一句话概括它能做什么:
|
|
12
16
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
17
|
+
- **浏览与检索**:按 Zotero 分类逐级浏览文库,按标题 / 摘要搜索,查看条目的元数据、摘要、参考文献、笔记、附件与 PDF 全文。
|
|
18
|
+
- **带进对话**:单条目引用、全文划词摘录或整目录引用,一键写进当前会话草稿(不自动发送),模型可以接着基于它工作。
|
|
19
|
+
- **交给模型**:让大模型帮你找文献、读全文、整理笔记,必要时按你的要求调整分类;不想让模型改文库,可以逐个关掉写操作。
|
|
20
|
+
- **安全可控**:浏览面板严格只读;模型能做什么可以逐项开关。
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|---|---|---|
|
|
19
|
-
| **人侧面板** | 在 DSH 右侧栏只读浏览 Zotero 文库(分类树 / 搜索 / 条目详情 / 笔记 / PDF 全文),把条目、摘录或整目录引用写进会话草稿 | 插件在宿主 web server 自注册的 `/dsh-zotero/api/*` 路由 |
|
|
20
|
-
| **模型侧** | 检索、精读、按需操作文库 | 插件**自持**连接本机 Zotero 集成 MCP,工具以 `mcp__zotero__*` 注册给模型 |
|
|
21
|
-
|
|
22
|
-
MCP 没起,面板照常可用;Zotero 没开,模型工具自然也不可用。
|
|
22
|
+
面板分三块:顶部状态栏显示连接状态并提供刷新;左侧分类树按分类浏览与搜索;右侧详情区展示正文与「参考文献 / 笔记 / 附件」标签页。
|
|
23
23
|
|
|
24
24
|
> 面向使用者的完整说明(入口、交互、toast 与错误对照表)见 [插件使用说明](docs/插件使用说明/dsh-plugin-zotero使用说明.zh.md)。
|
|
25
25
|
|
|
26
26
|
## 安装
|
|
27
27
|
|
|
28
|
-
要求 dsh ≥ 0.2.
|
|
28
|
+
要求 dsh ≥ 0.2.1-rc.3(`package.json` 的 `engines.dsh` 为 `>=0.2.1-rc.3 <0.3.0-0`)。
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
# 从 npm(推荐)
|
|
@@ -113,6 +113,17 @@ MCP 组下方是 **「MCP 工具」** 区:现场列出集成 MCP 的全部工
|
|
|
113
113
|
|
|
114
114
|
## 架构
|
|
115
115
|
|
|
116
|
+
从使用者视角看,插件分两半,职责不重叠、互不依赖:
|
|
117
|
+
|
|
118
|
+
| 半边 | 能力 | 通道 |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| **人侧面板** | 在 DSH 右侧栏只读浏览 Zotero 文库(分类树 / 搜索 / 条目详情 / 笔记 / PDF 全文),把条目、摘录或整目录引用写进会话草稿 | 插件在宿主 web server 自注册的 `/dsh-zotero/api/*` 路由 |
|
|
121
|
+
| **模型侧** | 检索、精读、按需操作文库 | 插件**自持**连接本机 Zotero 集成 MCP,工具以 `mcp__zotero__*` 注册给模型 |
|
|
122
|
+
|
|
123
|
+
MCP 没起,面板照常可用;Zotero 没开,模型工具自然也不可用。
|
|
124
|
+
|
|
125
|
+
代码分布:
|
|
126
|
+
|
|
116
127
|
| 半边 | 代码位置 | 通道 |
|
|
117
128
|
|---|---|---|
|
|
118
129
|
| Host | `src/index.ts`、`src/host/`、`src/zotero/` | 把 Zotero 本地 API 包装成只读 HTTP 端点,挂在 DSH 宿主 web server 上 |
|
package/client/client.js
CHANGED
|
@@ -27,6 +27,7 @@ const dicts = {
|
|
|
27
27
|
"guide.desc": "浏览本地 Zotero 文库,把条目、摘录或整个目录加入当前会话",
|
|
28
28
|
"action.refresh": "刷新",
|
|
29
29
|
"action.insertItem": "添加条目引用",
|
|
30
|
+
"action.insertItemShort": "引用",
|
|
30
31
|
"action.insertExcerpt": "添加摘录",
|
|
31
32
|
"action.insertCollection": "添加整目录引用",
|
|
32
33
|
"status.zoteroOn": "Zotero 已连接",
|
|
@@ -42,6 +43,9 @@ const dicts = {
|
|
|
42
43
|
"tree.count": "{n} 条",
|
|
43
44
|
"tree.empty": "这个分类下没有条目",
|
|
44
45
|
"detail.empty": "从左侧选择分类或条目",
|
|
46
|
+
"detail.metadata": "文献信息",
|
|
47
|
+
"detail.metadataExpand": "展开文献信息",
|
|
48
|
+
"detail.metadataCollapse": "收起文献信息",
|
|
45
49
|
"detail.creators": "作者",
|
|
46
50
|
"detail.year": "年份",
|
|
47
51
|
"detail.source": "出处",
|
|
@@ -119,6 +123,7 @@ const dicts = {
|
|
|
119
123
|
"guide.desc": "Browse the local Zotero library and add items, excerpts or whole collections to this conversation",
|
|
120
124
|
"action.refresh": "Refresh",
|
|
121
125
|
"action.insertItem": "Add item citation",
|
|
126
|
+
"action.insertItemShort": "Cite",
|
|
122
127
|
"action.insertExcerpt": "Add excerpt",
|
|
123
128
|
"action.insertCollection": "Add collection citations",
|
|
124
129
|
"status.zoteroOn": "Zotero connected",
|
|
@@ -134,6 +139,9 @@ const dicts = {
|
|
|
134
139
|
"tree.count": "{n} items",
|
|
135
140
|
"tree.empty": "No items in this collection",
|
|
136
141
|
"detail.empty": "Select a collection or item on the left",
|
|
142
|
+
"detail.metadata": "Metadata",
|
|
143
|
+
"detail.metadataExpand": "Expand metadata",
|
|
144
|
+
"detail.metadataCollapse": "Collapse metadata",
|
|
137
145
|
"detail.creators": "Creators",
|
|
138
146
|
"detail.year": "Year",
|
|
139
147
|
"detail.source": "Source",
|
|
@@ -273,8 +281,12 @@ function fetchCollectionBib(key, style = "apa") {
|
|
|
273
281
|
const SEARCH_DEBOUNCE_MS = 250;
|
|
274
282
|
/** 搜索结果条数上限。 */
|
|
275
283
|
const SEARCH_LIMIT = 100;
|
|
284
|
+
/** 分类树每个节点一次最多拉取的条目数。 */
|
|
285
|
+
const NODE_LIMIT = 200;
|
|
276
286
|
/** 提示条停留时长。 */
|
|
277
287
|
const TOAST_MS = 3e3;
|
|
288
|
+
/** 文库根节点的 id(只存在于客户端,不对应任何 Zotero 分类)。 */
|
|
289
|
+
const TREE_ROOT_ID = "__library__";
|
|
278
290
|
function initialState() {
|
|
279
291
|
return {
|
|
280
292
|
health: null,
|
|
@@ -283,6 +295,9 @@ function initialState() {
|
|
|
283
295
|
treeError: null,
|
|
284
296
|
treeLoading: true,
|
|
285
297
|
loaded: false,
|
|
298
|
+
expanded: /* @__PURE__ */ new Set([TREE_ROOT_ID]),
|
|
299
|
+
nodeItems: {},
|
|
300
|
+
nodeTotals: {},
|
|
286
301
|
query: "",
|
|
287
302
|
results: null,
|
|
288
303
|
selectedItemKey: null,
|
|
@@ -299,6 +314,7 @@ function errorMessage(error) {
|
|
|
299
314
|
let state = initialState();
|
|
300
315
|
const listeners = /* @__PURE__ */ new Set();
|
|
301
316
|
let treeInflight = null;
|
|
317
|
+
const nodeInflight = /* @__PURE__ */ new Set();
|
|
302
318
|
let searchTimer = null;
|
|
303
319
|
let toastTimer = null;
|
|
304
320
|
function patch(next) {
|
|
@@ -357,6 +373,53 @@ function loadTree(force = false) {
|
|
|
357
373
|
treeInflight = run;
|
|
358
374
|
return run;
|
|
359
375
|
}
|
|
376
|
+
/** 按需拉取某节点的条目;已拉取或正在拉取时直接返回。 */
|
|
377
|
+
function loadNodeItems(nodeId, target) {
|
|
378
|
+
if (state.nodeItems[nodeId] !== void 0 || nodeInflight.has(nodeId)) return;
|
|
379
|
+
nodeInflight.add(nodeId);
|
|
380
|
+
fetchItems({
|
|
381
|
+
...target,
|
|
382
|
+
limit: NODE_LIMIT
|
|
383
|
+
}).then((data) => {
|
|
384
|
+
patch({
|
|
385
|
+
nodeItems: {
|
|
386
|
+
...state.nodeItems,
|
|
387
|
+
[nodeId]: data.items
|
|
388
|
+
},
|
|
389
|
+
nodeTotals: {
|
|
390
|
+
...state.nodeTotals,
|
|
391
|
+
[nodeId]: data.total
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}).catch(() => {
|
|
395
|
+
patch({
|
|
396
|
+
nodeItems: {
|
|
397
|
+
...state.nodeItems,
|
|
398
|
+
[nodeId]: []
|
|
399
|
+
},
|
|
400
|
+
nodeTotals: {
|
|
401
|
+
...state.nodeTotals,
|
|
402
|
+
[nodeId]: 0
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}).finally(() => {
|
|
406
|
+
nodeInflight.delete(nodeId);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
/** 三角箭头:只开合节点,展开时按需拉取条目(根节点没有条目,不传 target)。 */
|
|
410
|
+
function toggleTreeNode(nodeId, target) {
|
|
411
|
+
const willOpen = !state.expanded.has(nodeId);
|
|
412
|
+
const expanded = new Set(state.expanded);
|
|
413
|
+
if (willOpen) expanded.add(nodeId);
|
|
414
|
+
else expanded.delete(nodeId);
|
|
415
|
+
patch({ expanded });
|
|
416
|
+
if (willOpen && target !== void 0) loadNodeItems(nodeId, target);
|
|
417
|
+
}
|
|
418
|
+
/** 选中分类时调用:确保节点展开且条目已拉取。 */
|
|
419
|
+
function expandTreeNode(nodeId, target) {
|
|
420
|
+
if (!state.expanded.has(nodeId)) patch({ expanded: new Set(state.expanded).add(nodeId) });
|
|
421
|
+
loadNodeItems(nodeId, target);
|
|
422
|
+
}
|
|
360
423
|
/** 更新搜索词并按防抖取数;清空时回到分类树。 */
|
|
361
424
|
function setQuery(next) {
|
|
362
425
|
patch({ query: next });
|
|
@@ -410,6 +473,7 @@ function resetPaneStore() {
|
|
|
410
473
|
searchTimer = null;
|
|
411
474
|
toastTimer = null;
|
|
412
475
|
treeInflight = null;
|
|
476
|
+
nodeInflight.clear();
|
|
413
477
|
state = initialState();
|
|
414
478
|
for (const listener of listeners) listener();
|
|
415
479
|
}
|
|
@@ -738,10 +802,9 @@ function ZoteroCard(props) {
|
|
|
738
802
|
* - 「我的文库」根节点**不再平铺全库条目**(这些条目本就挂在各分类下,平铺会造成重复);
|
|
739
803
|
* 其下额外挂三个虚拟分类:我的出版物 / 未分类条目 / 回收站,与 Zotero 左侧栏一致。
|
|
740
804
|
* - 分类 / 条目右键 → 「添加到会话」。
|
|
805
|
+
* - 展开集合与各节点条目都放在 {@link paneStore}:右侧栏切 tab 时面板正文会被卸载
|
|
806
|
+
* 重挂,局部 state 会丢,只有模块级 store 能让树保持原样。
|
|
741
807
|
*/
|
|
742
|
-
/** 每个节点一次最多拉取的条目数。 */
|
|
743
|
-
const NODE_LIMIT = 200;
|
|
744
|
-
const ROOT_NODE = "__library__";
|
|
745
808
|
/** 每层缩进量(px)。 */
|
|
746
809
|
const INDENT = 14;
|
|
747
810
|
/** 树左起始留白(px)。 */
|
|
@@ -1075,50 +1138,14 @@ function VirtualRows({ ctx, node, depth }) {
|
|
|
1075
1138
|
}
|
|
1076
1139
|
function CollectionTree(props) {
|
|
1077
1140
|
const { t, collections, selectedItemKey, selectedCollectionKey, onSelectItem, onSelectCollection, onInsertItem, onInsertCollection } = props;
|
|
1078
|
-
/**
|
|
1079
|
-
const
|
|
1080
|
-
const [itemsByNode, setItemsByNode] = (0, react.useState)({});
|
|
1081
|
-
const [totalsByNode, setTotalsByNode] = (0, react.useState)({});
|
|
1082
|
-
async function load(nodeId, opts = {}) {
|
|
1083
|
-
if (itemsByNode[nodeId] !== void 0) return;
|
|
1084
|
-
try {
|
|
1085
|
-
const data = await fetchItems({
|
|
1086
|
-
...opts,
|
|
1087
|
-
limit: NODE_LIMIT
|
|
1088
|
-
});
|
|
1089
|
-
setItemsByNode((prev) => ({
|
|
1090
|
-
...prev,
|
|
1091
|
-
[nodeId]: data.items
|
|
1092
|
-
}));
|
|
1093
|
-
setTotalsByNode((prev) => ({
|
|
1094
|
-
...prev,
|
|
1095
|
-
[nodeId]: data.total
|
|
1096
|
-
}));
|
|
1097
|
-
} catch {
|
|
1098
|
-
setItemsByNode((prev) => ({
|
|
1099
|
-
...prev,
|
|
1100
|
-
[nodeId]: []
|
|
1101
|
-
}));
|
|
1102
|
-
setTotalsByNode((prev) => ({
|
|
1103
|
-
...prev,
|
|
1104
|
-
[nodeId]: 0
|
|
1105
|
-
}));
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1141
|
+
/** 展开集合与各节点条目都在 store 里(默认展开根节点),重挂面板后原样恢复。 */
|
|
1142
|
+
const { expanded, nodeItems, nodeTotals } = usePaneState();
|
|
1108
1143
|
/** 按需拉取:条目一律由 toggle / select 触发,根节点不再预取全库条目。 */
|
|
1109
1144
|
function open(nodeId, collection) {
|
|
1110
|
-
|
|
1111
|
-
load(nodeId, loadOpts(collection));
|
|
1145
|
+
expandTreeNode(nodeId, loadOpts(collection));
|
|
1112
1146
|
}
|
|
1113
1147
|
function toggle(nodeId, collection) {
|
|
1114
|
-
|
|
1115
|
-
setExpanded((prev) => {
|
|
1116
|
-
const next = new Set(prev);
|
|
1117
|
-
if (willOpen) next.add(nodeId);
|
|
1118
|
-
else next.delete(nodeId);
|
|
1119
|
-
return next;
|
|
1120
|
-
});
|
|
1121
|
-
if (willOpen && collection !== void 0) load(nodeId, loadOpts(collection));
|
|
1148
|
+
toggleTreeNode(nodeId, collection === void 0 ? void 0 : loadOpts(collection));
|
|
1122
1149
|
}
|
|
1123
1150
|
function select(collection) {
|
|
1124
1151
|
onSelectCollection(collection);
|
|
@@ -1127,8 +1154,8 @@ function CollectionTree(props) {
|
|
|
1127
1154
|
const ctx = {
|
|
1128
1155
|
t,
|
|
1129
1156
|
expanded,
|
|
1130
|
-
itemsByNode,
|
|
1131
|
-
totalsByNode,
|
|
1157
|
+
itemsByNode: nodeItems,
|
|
1158
|
+
totalsByNode: nodeTotals,
|
|
1132
1159
|
selectedItemKey,
|
|
1133
1160
|
selectedCollectionKey,
|
|
1134
1161
|
toggle,
|
|
@@ -1137,7 +1164,7 @@ function CollectionTree(props) {
|
|
|
1137
1164
|
onInsertItem,
|
|
1138
1165
|
onInsertCollection
|
|
1139
1166
|
};
|
|
1140
|
-
const rootOpen = expanded.has(
|
|
1167
|
+
const rootOpen = expanded.has(TREE_ROOT_ID);
|
|
1141
1168
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1142
1169
|
style: {
|
|
1143
1170
|
padding: "8px 6px",
|
|
@@ -1145,7 +1172,7 @@ function CollectionTree(props) {
|
|
|
1145
1172
|
flexDirection: "column"
|
|
1146
1173
|
},
|
|
1147
1174
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1148
|
-
onClick: () => toggle(
|
|
1175
|
+
onClick: () => toggle(TREE_ROOT_ID),
|
|
1149
1176
|
style: {
|
|
1150
1177
|
...rowStyle,
|
|
1151
1178
|
...rowIndent(0)
|
|
@@ -1153,7 +1180,7 @@ function CollectionTree(props) {
|
|
|
1153
1180
|
children: [
|
|
1154
1181
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chevron, {
|
|
1155
1182
|
open: rootOpen,
|
|
1156
|
-
onToggle: () => toggle(
|
|
1183
|
+
onToggle: () => toggle(TREE_ROOT_ID)
|
|
1157
1184
|
}),
|
|
1158
1185
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1159
1186
|
style: iconBox,
|
|
@@ -1481,7 +1508,8 @@ const noteBodyStyle = {
|
|
|
1481
1508
|
* 正文区内部再分两块:头部信息(标题 / 元数据 / 摘要,过高时自己滚动)与全文块
|
|
1482
1509
|
* (撑满剩余高度、自己滚动),所以拖高正文区时全文文本跟着变高。
|
|
1483
1510
|
*
|
|
1484
|
-
*
|
|
1511
|
+
* 元数据与摘要都默认折叠,各自小标题行右侧的箭头按钮展开 / 收起——右栏空间有限,
|
|
1512
|
+
* 折叠后把高度尽量让给全文正文。
|
|
1485
1513
|
*
|
|
1486
1514
|
* 「添加到会话」两处入口:头部按钮(整条目元数据)、全文块里的选区浮出按钮
|
|
1487
1515
|
* (摘录)。全文块内用鼠标选中文本后浮出小按钮,位置取选区 rect。
|
|
@@ -1507,8 +1535,19 @@ const labelStyle = {
|
|
|
1507
1535
|
const metaRowStyle = {
|
|
1508
1536
|
display: "flex",
|
|
1509
1537
|
gap: 4,
|
|
1510
|
-
marginBottom:
|
|
1511
|
-
lineHeight: 1.
|
|
1538
|
+
marginBottom: 2,
|
|
1539
|
+
lineHeight: 1.5
|
|
1540
|
+
};
|
|
1541
|
+
/** 折叠区块(元数据 / 摘要)的外框:紧凑的上间距,展开内容再留 4px。 */
|
|
1542
|
+
const collapsibleStyle = { marginTop: 8 };
|
|
1543
|
+
/** 头部「添加条目引用」:压到最小号,把宽度尽量让给标题。 */
|
|
1544
|
+
const insertButtonStyle = {
|
|
1545
|
+
flexShrink: 0,
|
|
1546
|
+
height: 20,
|
|
1547
|
+
padding: "0 6px",
|
|
1548
|
+
fontSize: 11,
|
|
1549
|
+
lineHeight: 1.2,
|
|
1550
|
+
whiteSpace: "nowrap"
|
|
1512
1551
|
};
|
|
1513
1552
|
/** 去掉 CSL HTML 标签,只留可见文本(zotero 导出的是便携 HTML)。 */
|
|
1514
1553
|
function stripTags$1(html) {
|
|
@@ -1526,11 +1565,36 @@ function MetaRow({ label, children }) {
|
|
|
1526
1565
|
})]
|
|
1527
1566
|
});
|
|
1528
1567
|
}
|
|
1568
|
+
/** 小标题 + 右侧展开/收起箭头。 */
|
|
1569
|
+
function SectionToggle({ label, open, onToggle, expandLabel, collapseLabel }) {
|
|
1570
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1571
|
+
style: sectionToggleRowStyle,
|
|
1572
|
+
children: [
|
|
1573
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
1574
|
+
style: {
|
|
1575
|
+
...sectionTitleStyle,
|
|
1576
|
+
margin: 0
|
|
1577
|
+
},
|
|
1578
|
+
children: label
|
|
1579
|
+
}),
|
|
1580
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
1581
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1582
|
+
type: "button",
|
|
1583
|
+
onClick: onToggle,
|
|
1584
|
+
"aria-expanded": open,
|
|
1585
|
+
"aria-label": open ? collapseLabel : expandLabel,
|
|
1586
|
+
style: sectionToggleButtonStyle,
|
|
1587
|
+
children: open ? "▴" : "▾"
|
|
1588
|
+
})
|
|
1589
|
+
]
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1529
1592
|
function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onOpenItem }) {
|
|
1530
1593
|
const [selection, setSelection] = (0, react.useState)(null);
|
|
1531
1594
|
const [bodyPercent, setBodyPercent] = (0, react.useState)(readBodyPercent);
|
|
1532
1595
|
const [splitHover, setSplitHover] = (0, react.useState)(false);
|
|
1533
1596
|
const [abstractOpen, setAbstractOpen] = (0, react.useState)(false);
|
|
1597
|
+
const [metaOpen, setMetaOpen] = (0, react.useState)(false);
|
|
1534
1598
|
const boxRef = (0, react.useRef)(null);
|
|
1535
1599
|
const rootRef = (0, react.useRef)(null);
|
|
1536
1600
|
const dragRef = (0, react.useRef)(null);
|
|
@@ -1585,6 +1649,31 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onOpenItem }) {
|
|
|
1585
1649
|
}, attachment.key)) })
|
|
1586
1650
|
});
|
|
1587
1651
|
const hasBottom = tabs.length > 0;
|
|
1652
|
+
const metaRows = [];
|
|
1653
|
+
if (detail.creators.length > 0) metaRows.push({
|
|
1654
|
+
label: t("detail.creators"),
|
|
1655
|
+
value: detail.creators.join("、")
|
|
1656
|
+
});
|
|
1657
|
+
if (detail.year !== "") metaRows.push({
|
|
1658
|
+
label: t("detail.year"),
|
|
1659
|
+
value: detail.year
|
|
1660
|
+
});
|
|
1661
|
+
if (detail.publicationTitle !== "") metaRows.push({
|
|
1662
|
+
label: t("detail.source"),
|
|
1663
|
+
value: detail.publicationTitle
|
|
1664
|
+
});
|
|
1665
|
+
if (detail.doi !== "") metaRows.push({
|
|
1666
|
+
label: t("detail.doi"),
|
|
1667
|
+
value: detail.doi
|
|
1668
|
+
});
|
|
1669
|
+
if (detail.url !== "") metaRows.push({
|
|
1670
|
+
label: t("detail.url"),
|
|
1671
|
+
value: detail.url
|
|
1672
|
+
});
|
|
1673
|
+
if (detail.tags.length > 0) metaRows.push({
|
|
1674
|
+
label: t("detail.tags"),
|
|
1675
|
+
value: detail.tags.join("、")
|
|
1676
|
+
});
|
|
1588
1677
|
function clampBodyPercent(next) {
|
|
1589
1678
|
return Math.min(Math.max(next, BODY_PERCENT_MIN), BODY_PERCENT_MAX);
|
|
1590
1679
|
}
|
|
@@ -1661,73 +1750,51 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onOpenItem }) {
|
|
|
1661
1750
|
style: {
|
|
1662
1751
|
display: "flex",
|
|
1663
1752
|
alignItems: "flex-start",
|
|
1664
|
-
gap:
|
|
1665
|
-
marginBottom:
|
|
1753
|
+
gap: 6,
|
|
1754
|
+
marginBottom: 6
|
|
1666
1755
|
},
|
|
1667
1756
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
1668
1757
|
style: {
|
|
1669
1758
|
flex: 1,
|
|
1670
1759
|
margin: 0,
|
|
1671
|
-
fontSize:
|
|
1672
|
-
|
|
1760
|
+
fontSize: 13.5,
|
|
1761
|
+
fontWeight: 700,
|
|
1762
|
+
lineHeight: 1.4
|
|
1673
1763
|
},
|
|
1674
1764
|
children: detail.title
|
|
1675
1765
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1676
1766
|
variant: "outline",
|
|
1677
1767
|
size: "sm",
|
|
1678
1768
|
onClick: onInsertItem,
|
|
1679
|
-
|
|
1769
|
+
title: t("action.insertItem"),
|
|
1770
|
+
style: insertButtonStyle,
|
|
1771
|
+
children: t("action.insertItemShort")
|
|
1680
1772
|
})]
|
|
1681
1773
|
}),
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
children:
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
detail.doi !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
|
|
1695
|
-
label: t("detail.doi"),
|
|
1696
|
-
children: detail.doi
|
|
1697
|
-
}),
|
|
1698
|
-
detail.url !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
|
|
1699
|
-
label: t("detail.url"),
|
|
1700
|
-
children: detail.url
|
|
1701
|
-
}),
|
|
1702
|
-
detail.tags.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
|
|
1703
|
-
label: t("detail.tags"),
|
|
1704
|
-
children: detail.tags.join("、")
|
|
1774
|
+
metaRows.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1775
|
+
style: collapsibleStyle,
|
|
1776
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionToggle, {
|
|
1777
|
+
label: t("detail.metadata"),
|
|
1778
|
+
open: metaOpen,
|
|
1779
|
+
onToggle: () => setMetaOpen((open) => !open),
|
|
1780
|
+
expandLabel: t("detail.metadataExpand"),
|
|
1781
|
+
collapseLabel: t("detail.metadataCollapse")
|
|
1782
|
+
}), metaOpen && metaRows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
|
|
1783
|
+
label: row.label,
|
|
1784
|
+
children: row.value
|
|
1785
|
+
}, row.label))]
|
|
1705
1786
|
}),
|
|
1706
1787
|
detail.abstract !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1707
1788
|
style: {
|
|
1708
|
-
|
|
1789
|
+
...collapsibleStyle,
|
|
1709
1790
|
paddingBottom: 12
|
|
1710
1791
|
},
|
|
1711
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
margin: 0
|
|
1718
|
-
},
|
|
1719
|
-
children: t("detail.abstract")
|
|
1720
|
-
}),
|
|
1721
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
1722
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1723
|
-
type: "button",
|
|
1724
|
-
onClick: () => setAbstractOpen((open) => !open),
|
|
1725
|
-
"aria-expanded": abstractOpen,
|
|
1726
|
-
"aria-label": abstractOpen ? t("detail.abstractCollapse") : t("detail.abstractExpand"),
|
|
1727
|
-
style: sectionToggleButtonStyle,
|
|
1728
|
-
children: abstractOpen ? "▴" : "▾"
|
|
1729
|
-
})
|
|
1730
|
-
]
|
|
1792
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionToggle, {
|
|
1793
|
+
label: t("detail.abstract"),
|
|
1794
|
+
open: abstractOpen,
|
|
1795
|
+
onToggle: () => setAbstractOpen((open) => !open),
|
|
1796
|
+
expandLabel: t("detail.abstractExpand"),
|
|
1797
|
+
collapseLabel: t("detail.abstractCollapse")
|
|
1731
1798
|
}), abstractOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1732
1799
|
style: {
|
|
1733
1800
|
margin: "4px 0 0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-zotero",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "Connect the Zotero library on your computer to DSH: browse and search your own papers in the right sidebar, read metadata, notes and PDF full text, and bring a citation, an excerpt or a whole collection into the conversation with one click, so the model can answer from your own literature.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
7
7
|
"deepseek",
|
|
@@ -33,17 +33,23 @@
|
|
|
33
33
|
"cordis.patch.yml"
|
|
34
34
|
],
|
|
35
35
|
"engines": {
|
|
36
|
-
"dsh": ">=0.2.
|
|
36
|
+
"dsh": ">=0.2.1-rc.3 <0.3.0-0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.json",
|
|
40
|
+
"build:client": "tsdown",
|
|
41
|
+
"typecheck:client": "tsc -p tsconfig.client.json --noEmit",
|
|
42
|
+
"prepack": "pnpm build && pnpm build:client"
|
|
37
43
|
},
|
|
38
44
|
"peerDependencies": {
|
|
39
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
40
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
45
|
+
"@deepseek-ai/cordis": "^4.0.5",
|
|
46
|
+
"@deepseek-ai/schemastery": "^3.18.5"
|
|
41
47
|
},
|
|
42
48
|
"devDependencies": {
|
|
43
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
44
|
-
"@deepseek-ai/dsh": "0.2.
|
|
45
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
46
|
-
"@deepseek-ai/schemastery": "3.18.
|
|
49
|
+
"@deepseek-ai/cordis": "^4.0.5",
|
|
50
|
+
"@deepseek-ai/dsh": "0.2.1-rc.3",
|
|
51
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.3",
|
|
52
|
+
"@deepseek-ai/schemastery": "3.18.5",
|
|
47
53
|
"@types/node": "^24.19.2",
|
|
48
54
|
"@types/react": "~18.3.1",
|
|
49
55
|
"react": "^18.3.1",
|
|
@@ -64,10 +70,5 @@
|
|
|
64
70
|
],
|
|
65
71
|
"platform": "web"
|
|
66
72
|
}
|
|
67
|
-
},
|
|
68
|
-
"scripts": {
|
|
69
|
-
"build": "tsc -p tsconfig.json",
|
|
70
|
-
"build:client": "tsdown",
|
|
71
|
-
"typecheck:client": "tsc -p tsconfig.client.json --noEmit"
|
|
72
73
|
}
|
|
73
74
|
}
|