dsh-plugin-zotero 0.5.1 → 0.5.2
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 +496 -262
- package/lib/host/router.js +5 -0
- package/lib/zotero/client.d.ts +3 -0
- package/lib/zotero/client.js +10 -0
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -338,6 +338,9 @@ const dicts = {
|
|
|
338
338
|
"list.emptyFiltered": "没有符合条件的条目",
|
|
339
339
|
"list.loadFailed": "条目列表加载失败:{message}",
|
|
340
340
|
"list.loadMore": "加载更多",
|
|
341
|
+
"list.sortNone": "按标题排序(当前为 Zotero 原始顺序)",
|
|
342
|
+
"list.sortAsc": "标题正序 A→Z(再点切换为倒序)",
|
|
343
|
+
"list.sortDesc": "标题倒序 Z→A(再点恢复原始顺序)",
|
|
341
344
|
"tags.title": "标签",
|
|
342
345
|
"tags.filterPlaceholder": "筛选标签名称",
|
|
343
346
|
"tags.empty": "这个文库还没有标签",
|
|
@@ -659,6 +662,9 @@ const dicts = {
|
|
|
659
662
|
"list.emptyFiltered": "No items match the filters",
|
|
660
663
|
"list.loadFailed": "Failed to load items: {message}",
|
|
661
664
|
"list.loadMore": "Load more",
|
|
665
|
+
"list.sortNone": "Sort by title (currently Zotero default order)",
|
|
666
|
+
"list.sortAsc": "Title A→Z (click again for Z→A)",
|
|
667
|
+
"list.sortDesc": "Title Z→A (click again for default order)",
|
|
662
668
|
"tags.title": "Tags",
|
|
663
669
|
"tags.filterPlaceholder": "Filter tag names",
|
|
664
670
|
"tags.empty": "This library has no tags yet",
|
|
@@ -925,8 +931,18 @@ const SEARCH_DEBOUNCE_MS = 250;
|
|
|
925
931
|
const ITEMS_PAGE_SIZE = 50;
|
|
926
932
|
/** 提示条停留时长。 */
|
|
927
933
|
const TOAST_MS = 3e3;
|
|
934
|
+
/** 列表排序的存储键(localStorage,跨会话与重启都记住)。 */
|
|
935
|
+
const SORT_KEY = "dsh-plugin-zotero.itemSort";
|
|
928
936
|
/** 文库根节点的 id(只存在于客户端,不对应任何 Zotero 分类)。 */
|
|
929
937
|
const TREE_ROOT_ID = "__library__";
|
|
938
|
+
function readSort() {
|
|
939
|
+
try {
|
|
940
|
+
const value = window.localStorage.getItem(SORT_KEY);
|
|
941
|
+
return value === "asc" || value === "desc" ? value : "none";
|
|
942
|
+
} catch {
|
|
943
|
+
return "none";
|
|
944
|
+
}
|
|
945
|
+
}
|
|
930
946
|
function initialState() {
|
|
931
947
|
return {
|
|
932
948
|
health: null,
|
|
@@ -943,6 +959,7 @@ function initialState() {
|
|
|
943
959
|
itemsLoading: false,
|
|
944
960
|
itemsError: null,
|
|
945
961
|
selectedItemKeys: /* @__PURE__ */ new Set(),
|
|
962
|
+
sort: readSort(),
|
|
946
963
|
tags: null,
|
|
947
964
|
tagsLoading: false,
|
|
948
965
|
tagsError: null,
|
|
@@ -1190,6 +1207,8 @@ function reloadItems(options) {
|
|
|
1190
1207
|
q: state.query.trim(),
|
|
1191
1208
|
tags: tags.length === 0 ? void 0 : tags,
|
|
1192
1209
|
tagMode: tags.length === 0 ? void 0 : state.tagMode,
|
|
1210
|
+
sort: state.sort === "none" ? void 0 : "title",
|
|
1211
|
+
direction: state.sort === "none" ? void 0 : state.sort,
|
|
1193
1212
|
limit: ITEMS_PAGE_SIZE,
|
|
1194
1213
|
offset
|
|
1195
1214
|
}, controller.signal).then((data) => {
|
|
@@ -1216,6 +1235,19 @@ function loadMoreItems() {
|
|
|
1216
1235
|
append: true
|
|
1217
1236
|
});
|
|
1218
1237
|
}
|
|
1238
|
+
/**
|
|
1239
|
+
* 切换标题排序:原始顺序 → 正序 → 倒序 → 原始顺序。
|
|
1240
|
+
*
|
|
1241
|
+
* 状态写进 localStorage:所有会话共用同一块面板,重启后也保持上次的选择。
|
|
1242
|
+
*/
|
|
1243
|
+
function cycleItemSort() {
|
|
1244
|
+
const next = state.sort === "none" ? "asc" : state.sort === "asc" ? "desc" : "none";
|
|
1245
|
+
patch$1({ sort: next });
|
|
1246
|
+
try {
|
|
1247
|
+
window.localStorage.setItem(SORT_KEY, next);
|
|
1248
|
+
} catch {}
|
|
1249
|
+
reloadItems({ reset: true });
|
|
1250
|
+
}
|
|
1219
1251
|
function retryItems() {
|
|
1220
1252
|
reloadItems({ reset: true });
|
|
1221
1253
|
}
|
|
@@ -4030,6 +4062,8 @@ const noticeStyle$2 = {
|
|
|
4030
4062
|
* 左上角的悬浮信息菜单:文献信息 / 摘要 / 标注 / 笔记 / 附件 / 参考文献。
|
|
4031
4063
|
*
|
|
4032
4064
|
* 文档占满整版面,元数据类内容收进这个按钮背后的浮层,每块都可折叠。
|
|
4065
|
+
* 「加入对话」是这一行里的独立按钮(`i` 右侧),不放浮层里:它是每次读文献都要点的
|
|
4066
|
+
* 主操作,藏进菜单等于每次多两次点击。
|
|
4033
4067
|
* 浮层用系统色 `Canvas` / `CanvasText`,盖在白色 PDF 上深浅主题都能读。
|
|
4034
4068
|
* 点浮层外或按 Esc 关闭(统一走 {@link useDismiss},网页快照在 iframe 里的按下也算
|
|
4035
4069
|
* 「外」);点标注定位后也关闭,让文档重新成为焦点。
|
|
@@ -4127,159 +4161,162 @@ function InfoPanel({ t, detail, currentAttachmentKey, open, onToggle, onClose, o
|
|
|
4127
4161
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4128
4162
|
ref: rootRef,
|
|
4129
4163
|
style: rootStyle$6,
|
|
4130
|
-
children: [
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
children:
|
|
4165
|
-
style:
|
|
4166
|
-
children:
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
children:
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
if (!sections.notes) {
|
|
4209
|
-
setInfoSection("notes", true);
|
|
4210
|
-
setComposingNote(true);
|
|
4211
|
-
return;
|
|
4212
|
-
}
|
|
4213
|
-
setComposingNote((previous) => !previous);
|
|
4214
|
-
},
|
|
4215
|
-
title: composingNote ? t("note.cancel") : t("note.new"),
|
|
4216
|
-
"aria-label": t("note.new"),
|
|
4217
|
-
style: blockActionStyle,
|
|
4218
|
-
children: composingNote ? "×" : "+"
|
|
4219
|
-
}) : void 0,
|
|
4220
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NoteList, {
|
|
4221
|
-
t,
|
|
4222
|
-
notes,
|
|
4223
|
-
itemKey: detail.key,
|
|
4224
|
-
canWrite: detail.writeEnabled,
|
|
4225
|
-
selfNote,
|
|
4226
|
-
composing: composingNote,
|
|
4227
|
-
onComposingChange: setComposingNote,
|
|
4228
|
-
onInsert: onInsertNote,
|
|
4229
|
-
onChanged
|
|
4230
|
-
})
|
|
4231
|
-
}),
|
|
4232
|
-
detail.attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4233
|
-
label: t("detail.attachments"),
|
|
4234
|
-
hint: String(detail.attachments.length),
|
|
4235
|
-
open: sections.attachments,
|
|
4236
|
-
onToggle: () => toggle("attachments"),
|
|
4237
|
-
children: detail.attachments.map((attachment) => {
|
|
4238
|
-
const current = attachment.key === currentAttachmentKey;
|
|
4239
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4164
|
+
children: [
|
|
4165
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4166
|
+
type: "button",
|
|
4167
|
+
onClick: onToggle,
|
|
4168
|
+
"aria-expanded": open,
|
|
4169
|
+
"aria-label": t("detail.info"),
|
|
4170
|
+
title: t("detail.info"),
|
|
4171
|
+
style: triggerStyle$1,
|
|
4172
|
+
children: "i"
|
|
4173
|
+
}),
|
|
4174
|
+
!selfNote && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4175
|
+
type: "button",
|
|
4176
|
+
onClick: onCite,
|
|
4177
|
+
title: t("action.insertItem"),
|
|
4178
|
+
style: citeTriggerStyle,
|
|
4179
|
+
children: t("action.insertItemShort")
|
|
4180
|
+
}),
|
|
4181
|
+
open && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4182
|
+
role: "dialog",
|
|
4183
|
+
"aria-label": t("detail.info"),
|
|
4184
|
+
style: panelStyle$1,
|
|
4185
|
+
children: [
|
|
4186
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4187
|
+
style: panelHeaderStyle$1,
|
|
4188
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4189
|
+
style: panelTitleStyle,
|
|
4190
|
+
title: detail.title,
|
|
4191
|
+
children: detail.title
|
|
4192
|
+
})
|
|
4193
|
+
}),
|
|
4194
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4195
|
+
label: t("detail.metadata"),
|
|
4196
|
+
open: sections.metadata,
|
|
4197
|
+
onToggle: () => toggle("metadata"),
|
|
4198
|
+
children: metaRows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4199
|
+
style: metaRowStyle,
|
|
4200
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4201
|
+
style: metaLabelStyle,
|
|
4202
|
+
children: row.label
|
|
4203
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4204
|
+
style: { wordBreak: "break-word" },
|
|
4205
|
+
children: row.value
|
|
4206
|
+
})]
|
|
4207
|
+
}, row.label))
|
|
4208
|
+
}),
|
|
4209
|
+
detail.abstract !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4210
|
+
label: t("detail.abstract"),
|
|
4211
|
+
open: sections.abstract,
|
|
4212
|
+
onToggle: () => toggle("abstract"),
|
|
4213
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4214
|
+
style: paragraphStyle,
|
|
4215
|
+
children: detail.abstract
|
|
4216
|
+
})
|
|
4217
|
+
}),
|
|
4218
|
+
detail.annotations.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4219
|
+
label: t("detail.annotations"),
|
|
4220
|
+
hint: String(detail.annotations.length),
|
|
4221
|
+
open: sections.annotations,
|
|
4222
|
+
onToggle: () => toggle("annotations"),
|
|
4223
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotationList, {
|
|
4224
|
+
t,
|
|
4225
|
+
annotations: detail.annotations,
|
|
4226
|
+
hasFulltext: detail.fulltext !== null,
|
|
4227
|
+
truncated: detail.fulltext?.truncated === true,
|
|
4228
|
+
filter: annotationFilter,
|
|
4229
|
+
canWrite: detail.writeEnabled,
|
|
4230
|
+
onFilterChange: onAnnotationFilterChange,
|
|
4231
|
+
onLocate: onLocateAnnotation,
|
|
4232
|
+
onInsert: onInsertAnnotation,
|
|
4233
|
+
onChanged
|
|
4234
|
+
})
|
|
4235
|
+
}),
|
|
4236
|
+
(notes.length > 0 || detail.writeEnabled && !selfNote) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4237
|
+
label: t("detail.notes"),
|
|
4238
|
+
hint: String(notes.length),
|
|
4239
|
+
open: sections.notes,
|
|
4240
|
+
onToggle: () => toggle("notes"),
|
|
4241
|
+
action: detail.writeEnabled && !selfNote ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4240
4242
|
type: "button",
|
|
4241
|
-
onClick: () =>
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4243
|
+
onClick: () => {
|
|
4244
|
+
if (!sections.notes) {
|
|
4245
|
+
setInfoSection("notes", true);
|
|
4246
|
+
setComposingNote(true);
|
|
4247
|
+
return;
|
|
4248
|
+
}
|
|
4249
|
+
setComposingNote((previous) => !previous);
|
|
4245
4250
|
},
|
|
4246
|
-
title: t("
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4251
|
+
title: composingNote ? t("note.cancel") : t("note.new"),
|
|
4252
|
+
"aria-label": t("note.new"),
|
|
4253
|
+
style: blockActionStyle,
|
|
4254
|
+
children: composingNote ? "×" : "+"
|
|
4255
|
+
}) : void 0,
|
|
4256
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NoteList, {
|
|
4257
|
+
t,
|
|
4258
|
+
notes,
|
|
4259
|
+
itemKey: detail.key,
|
|
4260
|
+
canWrite: detail.writeEnabled,
|
|
4261
|
+
selfNote,
|
|
4262
|
+
composing: composingNote,
|
|
4263
|
+
onComposingChange: setComposingNote,
|
|
4264
|
+
onInsert: onInsertNote,
|
|
4265
|
+
onChanged
|
|
4266
|
+
})
|
|
4267
|
+
}),
|
|
4268
|
+
detail.attachments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4269
|
+
label: t("detail.attachments"),
|
|
4270
|
+
hint: String(detail.attachments.length),
|
|
4271
|
+
open: sections.attachments,
|
|
4272
|
+
onToggle: () => toggle("attachments"),
|
|
4273
|
+
children: detail.attachments.map((attachment) => {
|
|
4274
|
+
const current = attachment.key === currentAttachmentKey;
|
|
4275
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4276
|
+
type: "button",
|
|
4277
|
+
onClick: () => onSelectAttachment(attachment.key),
|
|
4278
|
+
style: {
|
|
4279
|
+
...attachmentRowStyle,
|
|
4280
|
+
opacity: current ? 1 : .8
|
|
4281
|
+
},
|
|
4282
|
+
title: t("detail.attachmentOpen"),
|
|
4283
|
+
children: [
|
|
4284
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4285
|
+
style: {
|
|
4286
|
+
width: 12,
|
|
4287
|
+
flexShrink: 0,
|
|
4288
|
+
color: "#508cff"
|
|
4289
|
+
},
|
|
4290
|
+
children: current ? "●" : ""
|
|
4291
|
+
}),
|
|
4292
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4293
|
+
style: {
|
|
4294
|
+
flex: 1,
|
|
4295
|
+
textAlign: "left",
|
|
4296
|
+
wordBreak: "break-word"
|
|
4297
|
+
},
|
|
4298
|
+
children: attachment.filename || attachment.title
|
|
4299
|
+
}),
|
|
4300
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4301
|
+
style: attachmentMetaStyle,
|
|
4302
|
+
children: [attachment.contentType, attachment.size > 0 ? ` · ${Math.round(attachment.size / 1024)} KB` : ""]
|
|
4303
|
+
})
|
|
4304
|
+
]
|
|
4305
|
+
}, attachment.key);
|
|
4306
|
+
})
|
|
4307
|
+
}),
|
|
4308
|
+
detail.bib !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Block, {
|
|
4309
|
+
label: t("detail.bibTitle"),
|
|
4310
|
+
open: sections.bib,
|
|
4311
|
+
onToggle: () => toggle("bib"),
|
|
4312
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4313
|
+
style: paragraphStyle,
|
|
4314
|
+
children: stripTags(detail.bib)
|
|
4315
|
+
})
|
|
4279
4316
|
})
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4317
|
+
]
|
|
4318
|
+
})
|
|
4319
|
+
]
|
|
4283
4320
|
});
|
|
4284
4321
|
}
|
|
4285
4322
|
const rootStyle$6 = {
|
|
@@ -4288,7 +4325,7 @@ const rootStyle$6 = {
|
|
|
4288
4325
|
zIndex: 20,
|
|
4289
4326
|
pointerEvents: "none"
|
|
4290
4327
|
};
|
|
4291
|
-
/**
|
|
4328
|
+
/** 这一行按钮从左往右:目录(8)、文献信息(34)、加入对话(60),每个 22 高、间隔 4。 */
|
|
4292
4329
|
const triggerStyle$1 = {
|
|
4293
4330
|
position: "absolute",
|
|
4294
4331
|
pointerEvents: "auto",
|
|
@@ -4343,13 +4380,27 @@ const panelTitleStyle = {
|
|
|
4343
4380
|
lineHeight: 1.45,
|
|
4344
4381
|
wordBreak: "break-word"
|
|
4345
4382
|
};
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4383
|
+
/** 收在 `i` 右边、跟它同一行:是每次读文献都要点的主操作,不藏进浮层。 */
|
|
4384
|
+
const citeTriggerStyle = {
|
|
4385
|
+
position: "absolute",
|
|
4386
|
+
pointerEvents: "auto",
|
|
4387
|
+
top: 4,
|
|
4388
|
+
left: 60,
|
|
4389
|
+
display: "inline-flex",
|
|
4390
|
+
alignItems: "center",
|
|
4391
|
+
height: 22,
|
|
4392
|
+
padding: "0 9px",
|
|
4393
|
+
fontSize: 11.5,
|
|
4394
|
+
fontWeight: 500,
|
|
4395
|
+
lineHeight: 1,
|
|
4396
|
+
whiteSpace: "nowrap",
|
|
4397
|
+
borderRadius: 11,
|
|
4398
|
+
border: "1px solid rgba(127,127,127,0.4)",
|
|
4399
|
+
background: "Canvas",
|
|
4400
|
+
color: "CanvasText",
|
|
4401
|
+
cursor: "pointer",
|
|
4402
|
+
boxShadow: "0 1px 4px rgba(0,0,0,0.18)",
|
|
4403
|
+
zIndex: 21
|
|
4353
4404
|
};
|
|
4354
4405
|
const blockStyle = {
|
|
4355
4406
|
borderBottom: "1px solid rgba(127,127,127,0.18)",
|
|
@@ -28138,7 +28189,7 @@ function AnnotationCard({ t, annotation, style, cardRef, canEdit, onClose, onIns
|
|
|
28138
28189
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
28139
28190
|
type: "button",
|
|
28140
28191
|
onClick: onClose,
|
|
28141
|
-
style: iconButtonStyle,
|
|
28192
|
+
style: iconButtonStyle$1,
|
|
28142
28193
|
"aria-label": t("viewer.close"),
|
|
28143
28194
|
children: "×"
|
|
28144
28195
|
})
|
|
@@ -28331,7 +28382,7 @@ const swatchStyle$1 = {
|
|
|
28331
28382
|
border: "none",
|
|
28332
28383
|
cursor: "pointer"
|
|
28333
28384
|
};
|
|
28334
|
-
const iconButtonStyle = {
|
|
28385
|
+
const iconButtonStyle$1 = {
|
|
28335
28386
|
width: 20,
|
|
28336
28387
|
height: 20,
|
|
28337
28388
|
padding: 0,
|
|
@@ -31143,18 +31194,63 @@ function PageField({ current, total, onJump, t }) {
|
|
|
31143
31194
|
})]
|
|
31144
31195
|
});
|
|
31145
31196
|
}
|
|
31197
|
+
/**
|
|
31198
|
+
* 放大镜图标:镜筒里一根横线是缩小,再加一根竖线是放大,把手朝右下。
|
|
31199
|
+
*
|
|
31200
|
+
* 纯 `currentColor` 描边,深浅主题都跟着文字走。
|
|
31201
|
+
*/
|
|
31202
|
+
function ZoomIcon({ kind }) {
|
|
31203
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
31204
|
+
width: "15",
|
|
31205
|
+
height: "15",
|
|
31206
|
+
viewBox: "0 0 16 16",
|
|
31207
|
+
"aria-hidden": "true",
|
|
31208
|
+
focusable: "false",
|
|
31209
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", {
|
|
31210
|
+
fill: "none",
|
|
31211
|
+
stroke: "currentColor",
|
|
31212
|
+
strokeWidth: "1.35",
|
|
31213
|
+
strokeLinecap: "round",
|
|
31214
|
+
children: [
|
|
31215
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
31216
|
+
cx: "6.8",
|
|
31217
|
+
cy: "6.8",
|
|
31218
|
+
r: "4.4"
|
|
31219
|
+
}),
|
|
31220
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
31221
|
+
x1: "10.15",
|
|
31222
|
+
y1: "10.15",
|
|
31223
|
+
x2: "13.6",
|
|
31224
|
+
y2: "13.6"
|
|
31225
|
+
}),
|
|
31226
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
31227
|
+
x1: "4.8",
|
|
31228
|
+
y1: "6.8",
|
|
31229
|
+
x2: "8.8",
|
|
31230
|
+
y2: "6.8"
|
|
31231
|
+
}),
|
|
31232
|
+
kind === "in" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
|
|
31233
|
+
x1: "6.8",
|
|
31234
|
+
y1: "4.8",
|
|
31235
|
+
x2: "6.8",
|
|
31236
|
+
y2: "8.8"
|
|
31237
|
+
})
|
|
31238
|
+
]
|
|
31239
|
+
})
|
|
31240
|
+
});
|
|
31241
|
+
}
|
|
31146
31242
|
function DocumentView({ t, detail, source, annotations, viewerRef, onReady, onInsertExcerpt, onInsertAnnotation, onOpenInZotero, onChanged, onOutlineChange }) {
|
|
31147
31243
|
const renderer = pickRenderer(source, detail);
|
|
31148
31244
|
const Renderer = renderer.Component;
|
|
31149
|
-
const [zoom, setZoom] = (0, react.useState)({
|
|
31150
|
-
percent: 100,
|
|
31151
|
-
fitWidth: true
|
|
31152
|
-
});
|
|
31153
31245
|
const [page, setPage] = (0, react.useState)({
|
|
31154
31246
|
current: 1,
|
|
31155
31247
|
total: 0
|
|
31156
31248
|
});
|
|
31157
|
-
|
|
31249
|
+
/**
|
|
31250
|
+
* 缩放比例不再显示,但这个回调渲染器还得有(`RendererProps` 必填)。
|
|
31251
|
+
* 留着空实现而不是改接口:唯一用处是给工具条写字,删掉它要动三个渲染器。
|
|
31252
|
+
*/
|
|
31253
|
+
const handleZoomChange = (0, react.useCallback)(() => {}, []);
|
|
31158
31254
|
const handlePageChange = (0, react.useCallback)((current, total) => {
|
|
31159
31255
|
setPage({
|
|
31160
31256
|
current,
|
|
@@ -31182,43 +31278,34 @@ function DocumentView({ t, detail, source, annotations, viewerRef, onReady, onIn
|
|
|
31182
31278
|
onJump: (target) => viewerRef.current?.goToPage(target),
|
|
31183
31279
|
t
|
|
31184
31280
|
}),
|
|
31185
|
-
renderer.capabilities.zoom && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
31186
|
-
|
|
31281
|
+
renderer.capabilities.zoom && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
31282
|
+
style: barDividerStyle,
|
|
31283
|
+
"aria-hidden": "true"
|
|
31284
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
31285
|
+
style: zoomGroupStyle,
|
|
31286
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
31187
31287
|
type: "button",
|
|
31188
31288
|
onClick: () => viewerRef.current?.zoomOut(),
|
|
31189
|
-
style:
|
|
31289
|
+
style: iconButtonStyle,
|
|
31190
31290
|
"aria-label": t("viewer.zoomOut"),
|
|
31191
31291
|
title: t("viewer.zoomOut"),
|
|
31192
|
-
children: "
|
|
31193
|
-
}),
|
|
31194
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
31195
|
-
style: zoomStyle,
|
|
31196
|
-
children: [zoom.percent, "%"]
|
|
31197
|
-
}),
|
|
31198
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
31292
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomIcon, { kind: "out" })
|
|
31293
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
31199
31294
|
type: "button",
|
|
31200
31295
|
onClick: () => viewerRef.current?.zoomIn(),
|
|
31201
|
-
style:
|
|
31296
|
+
style: iconButtonStyle,
|
|
31202
31297
|
"aria-label": t("viewer.zoomIn"),
|
|
31203
31298
|
title: t("viewer.zoomIn"),
|
|
31204
|
-
children: "
|
|
31205
|
-
})
|
|
31206
|
-
|
|
31207
|
-
type: "button",
|
|
31208
|
-
onClick: () => viewerRef.current?.fitToWidth(),
|
|
31209
|
-
style: {
|
|
31210
|
-
...toolButtonStyle,
|
|
31211
|
-
opacity: zoom.fitWidth ? 1 : .6
|
|
31212
|
-
},
|
|
31213
|
-
"aria-label": t("viewer.fitWidth"),
|
|
31214
|
-
title: t("viewer.fitWidth"),
|
|
31215
|
-
children: "⤢"
|
|
31216
|
-
})
|
|
31217
|
-
] }),
|
|
31299
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ZoomIcon, { kind: "in" })
|
|
31300
|
+
})]
|
|
31301
|
+
})] }),
|
|
31218
31302
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
31219
31303
|
type: "button",
|
|
31220
31304
|
onClick: () => onOpenInZotero(page.current),
|
|
31221
|
-
style:
|
|
31305
|
+
style: {
|
|
31306
|
+
...toolButtonStyle,
|
|
31307
|
+
marginLeft: GROUP_GAP
|
|
31308
|
+
},
|
|
31222
31309
|
title: t("viewer.openInZotero"),
|
|
31223
31310
|
children: t("viewer.openInZoteroShort")
|
|
31224
31311
|
})
|
|
@@ -31247,14 +31334,19 @@ function DocumentView({ t, detail, source, annotations, viewerRef, onReady, onIn
|
|
|
31247
31334
|
})]
|
|
31248
31335
|
});
|
|
31249
31336
|
}
|
|
31250
|
-
/**
|
|
31337
|
+
/**
|
|
31338
|
+
* 左侧留出三个悬浮按钮(目录 / 文献信息 / 加入对话)的位置,标题居中显示在剩下这段里。
|
|
31339
|
+
*
|
|
31340
|
+
* 悬浮按钮是绝对定位、盖在工具条上的(见 `OutlinePanel` / `InfoPanel`:8 + 22 + 4 一格,
|
|
31341
|
+
* 第三格「加入对话」到 124 为止),所以这里的 `paddingLeft` 必须一起改,否则标题从按钮底下钻出来。
|
|
31342
|
+
*/
|
|
31251
31343
|
const barStyle = {
|
|
31252
31344
|
display: "flex",
|
|
31253
31345
|
alignItems: "center",
|
|
31254
31346
|
gap: 4,
|
|
31255
31347
|
flexShrink: 0,
|
|
31256
31348
|
height: 30,
|
|
31257
|
-
padding: "0 8px 0
|
|
31349
|
+
padding: "0 8px 0 132px",
|
|
31258
31350
|
borderBottom: "1px solid rgba(127,127,127,0.2)",
|
|
31259
31351
|
background: "transparent"
|
|
31260
31352
|
};
|
|
@@ -31264,9 +31356,16 @@ const titleStyle$1 = {
|
|
|
31264
31356
|
overflow: "hidden",
|
|
31265
31357
|
textOverflow: "ellipsis",
|
|
31266
31358
|
whiteSpace: "nowrap",
|
|
31359
|
+
textAlign: "center",
|
|
31267
31360
|
fontSize: 11,
|
|
31268
31361
|
opacity: .62
|
|
31269
31362
|
};
|
|
31363
|
+
/**
|
|
31364
|
+
* 工具条里相邻两组控件之间的额外间距(页码 ↔ 缩放 ↔ Zotero)。
|
|
31365
|
+
*
|
|
31366
|
+
* 组内只隔 4(工具条的 `gap`),组间靠这个拉开,否则 `1 / 3` 和两个放大镜会连成一片。
|
|
31367
|
+
*/
|
|
31368
|
+
const GROUP_GAP = 10;
|
|
31270
31369
|
const pageStyle = {
|
|
31271
31370
|
flexShrink: 0,
|
|
31272
31371
|
display: "inline-flex",
|
|
@@ -31289,13 +31388,36 @@ const pageInputStyle = {
|
|
|
31289
31388
|
color: "inherit",
|
|
31290
31389
|
outline: "none"
|
|
31291
31390
|
};
|
|
31292
|
-
|
|
31391
|
+
/** 页码区与缩放区之间的竖线:比纯靠留白更能看出是两组。 */
|
|
31392
|
+
const barDividerStyle = {
|
|
31293
31393
|
flexShrink: 0,
|
|
31294
|
-
|
|
31295
|
-
|
|
31296
|
-
|
|
31297
|
-
|
|
31298
|
-
|
|
31394
|
+
width: 1,
|
|
31395
|
+
height: 14,
|
|
31396
|
+
margin: "0 3px 0 8px",
|
|
31397
|
+
background: "rgba(127,127,127,0.28)"
|
|
31398
|
+
};
|
|
31399
|
+
/** 缩放组(两个放大镜):不再显示百分比,纯图标。 */
|
|
31400
|
+
const zoomGroupStyle = {
|
|
31401
|
+
flexShrink: 0,
|
|
31402
|
+
display: "inline-flex",
|
|
31403
|
+
alignItems: "center",
|
|
31404
|
+
gap: 2
|
|
31405
|
+
};
|
|
31406
|
+
/** 无边框图标按钮:放大镜本身当按钮,不再套一层方框。 */
|
|
31407
|
+
const iconButtonStyle = {
|
|
31408
|
+
flexShrink: 0,
|
|
31409
|
+
display: "inline-flex",
|
|
31410
|
+
alignItems: "center",
|
|
31411
|
+
justifyContent: "center",
|
|
31412
|
+
width: 22,
|
|
31413
|
+
height: 22,
|
|
31414
|
+
padding: 0,
|
|
31415
|
+
borderRadius: 4,
|
|
31416
|
+
border: "none",
|
|
31417
|
+
background: "transparent",
|
|
31418
|
+
color: "inherit",
|
|
31419
|
+
opacity: .75,
|
|
31420
|
+
cursor: "pointer"
|
|
31299
31421
|
};
|
|
31300
31422
|
const toolButtonStyle = {
|
|
31301
31423
|
flexShrink: 0,
|
|
@@ -32264,7 +32386,9 @@ function SearchField({ value, placeholder, clearLabel, onChange }) {
|
|
|
32264
32386
|
* 头部含范围名、条数与搜索框;条目行单击选中、双击才开独立 tab,ctrl / cmd 点选
|
|
32265
32387
|
* 多选,右上角「引用 N」把选中的每条各插一个胶囊。右键单行仍能直接插该条引用。
|
|
32266
32388
|
* 列表分页(加载更多),筛选后为空与本来为空分开提示。
|
|
32267
|
-
*
|
|
32389
|
+
*
|
|
32390
|
+
* 行内排版是两行:第一行只放标题,第二行小字灰色放「类型 + 年份 + 作者」,
|
|
32391
|
+
* 行与行之间用一条浅色细线分隔。
|
|
32268
32392
|
*/
|
|
32269
32393
|
function selectionName(t, libraryName, collection) {
|
|
32270
32394
|
if (collection === null || collection.key === "__library__") return libraryName === "" ? t("tab.title") : libraryName;
|
|
@@ -32289,34 +32413,72 @@ const titleRowStyle = {
|
|
|
32289
32413
|
gap: 8,
|
|
32290
32414
|
minWidth: 0
|
|
32291
32415
|
};
|
|
32416
|
+
/** 行 hover 只染未选中行:选中态用内联背景,优先级更高,不需要额外规则。 */
|
|
32417
|
+
const ITEM_CSS = ".dsh-zotero-item-row:hover{background:rgba(127,127,127,0.08)}";
|
|
32418
|
+
/** 行外壳:只负责那条浅色分隔线,通栏铺满。
|
|
32419
|
+
*
|
|
32420
|
+
* 用 flex 是为了「撑满」:Menu 的 anchor 外面会包一层按内容收窄的元素,
|
|
32421
|
+
* 做成 flex 容器后那层被拉伸到整行宽,里面的标题才有确定的宽度可截断。
|
|
32422
|
+
*/
|
|
32423
|
+
const itemShellStyle = {
|
|
32424
|
+
display: "flex",
|
|
32425
|
+
borderBottom: "1px solid rgba(127,127,127,0.14)"
|
|
32426
|
+
};
|
|
32292
32427
|
const itemRowStyle = {
|
|
32293
32428
|
display: "flex",
|
|
32294
|
-
|
|
32295
|
-
|
|
32296
|
-
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
borderRadius:
|
|
32429
|
+
alignItems: "flex-start",
|
|
32430
|
+
gap: 7,
|
|
32431
|
+
width: "100%",
|
|
32432
|
+
boxSizing: "border-box",
|
|
32433
|
+
padding: "7px 8px",
|
|
32434
|
+
borderRadius: 6,
|
|
32300
32435
|
cursor: "pointer"
|
|
32301
32436
|
};
|
|
32437
|
+
/** 标题独占第一行,可截断。 */
|
|
32302
32438
|
const itemTitleStyle = {
|
|
32303
|
-
|
|
32439
|
+
display: "block",
|
|
32304
32440
|
minWidth: 0,
|
|
32305
32441
|
overflow: "hidden",
|
|
32306
32442
|
textOverflow: "ellipsis",
|
|
32307
|
-
whiteSpace: "nowrap"
|
|
32443
|
+
whiteSpace: "nowrap",
|
|
32444
|
+
fontSize: 13,
|
|
32445
|
+
lineHeight: 1.45
|
|
32308
32446
|
};
|
|
32447
|
+
/** 第二行:类型 + 年份 + 作者,小字灰。 */
|
|
32309
32448
|
const itemMetaStyle = {
|
|
32310
|
-
|
|
32449
|
+
display: "flex",
|
|
32450
|
+
alignItems: "baseline",
|
|
32451
|
+
gap: 6,
|
|
32452
|
+
minWidth: 0,
|
|
32453
|
+
marginTop: 1,
|
|
32454
|
+
fontSize: 11,
|
|
32455
|
+
lineHeight: 1.4,
|
|
32456
|
+
opacity: .5
|
|
32457
|
+
};
|
|
32458
|
+
/** 类型与年份比作者再淡一点:作者是主要识别信息。 */
|
|
32459
|
+
const itemMetaTypeStyle = {
|
|
32460
|
+
flex: "0 0 auto",
|
|
32461
|
+
opacity: .85
|
|
32462
|
+
};
|
|
32463
|
+
const itemMetaYearStyle = {
|
|
32311
32464
|
flex: "0 0 auto",
|
|
32312
|
-
|
|
32313
|
-
|
|
32314
|
-
|
|
32465
|
+
opacity: .85
|
|
32466
|
+
};
|
|
32467
|
+
const itemMetaTextStyle = {
|
|
32468
|
+
flex: "1 1 auto",
|
|
32469
|
+
minWidth: 0,
|
|
32470
|
+
overflow: "hidden",
|
|
32471
|
+
textOverflow: "ellipsis",
|
|
32472
|
+
whiteSpace: "nowrap"
|
|
32473
|
+
};
|
|
32474
|
+
const itemBodyStyle = {
|
|
32475
|
+
flex: 1,
|
|
32476
|
+
minWidth: 0
|
|
32315
32477
|
};
|
|
32316
32478
|
const itemIconStyle = {
|
|
32317
32479
|
display: "flex",
|
|
32318
|
-
|
|
32319
|
-
|
|
32480
|
+
flexShrink: 0,
|
|
32481
|
+
marginTop: 3
|
|
32320
32482
|
};
|
|
32321
32483
|
/** 头部引用按钮的紧凑尺寸。 */
|
|
32322
32484
|
const citeButtonStyle = {
|
|
@@ -32326,6 +32488,47 @@ const citeButtonStyle = {
|
|
|
32326
32488
|
fontSize: 11,
|
|
32327
32489
|
lineHeight: 1.2
|
|
32328
32490
|
};
|
|
32491
|
+
/** 排序图标按钮:与引用按钮同高,只放图标。 */
|
|
32492
|
+
const sortButtonStyle = {
|
|
32493
|
+
flexShrink: 0,
|
|
32494
|
+
height: 20,
|
|
32495
|
+
padding: "0 4px",
|
|
32496
|
+
lineHeight: 1
|
|
32497
|
+
};
|
|
32498
|
+
/** 排序生效时的图标颜色(与列表选中态同一支蓝)。 */
|
|
32499
|
+
const SORT_ACTIVE_COLOR = "#508cff";
|
|
32500
|
+
/**
|
|
32501
|
+
* 排序图标:三条长短不一的横线 + 右侧方向箭头。
|
|
32502
|
+
*
|
|
32503
|
+
* 未排序时箭头两头都画(提示「可点」)且整体偏淡;正序朝上、倒序朝下并染色。
|
|
32504
|
+
*/
|
|
32505
|
+
function SortIcon({ sort }) {
|
|
32506
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
32507
|
+
width: 14,
|
|
32508
|
+
height: 14,
|
|
32509
|
+
viewBox: "0 0 16 16",
|
|
32510
|
+
fill: "none",
|
|
32511
|
+
stroke: "currentColor",
|
|
32512
|
+
strokeWidth: 1.3,
|
|
32513
|
+
strokeLinecap: "round",
|
|
32514
|
+
strokeLinejoin: "round",
|
|
32515
|
+
"aria-hidden": true,
|
|
32516
|
+
focusable: "false",
|
|
32517
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
32518
|
+
d: "M2.4 3.6h7.2M2.4 8h4.8M2.4 12.4h2.8",
|
|
32519
|
+
opacity: sort !== "none" ? 1 : .75
|
|
32520
|
+
}), sort === "none" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
32521
|
+
d: "M13 4.2v7.6M13 4.2l-1.5 1.7M13 4.2l1.5 1.7M13 11.8l-1.5-1.7M13 11.8l1.5-1.7",
|
|
32522
|
+
opacity: .5
|
|
32523
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: sort === "asc" ? "M13 12.2V4M13 4l-1.7 1.9M13 4l1.7 1.9" : "M13 3.8V12M13 12l-1.7-1.9M13 12l1.7-1.9" })]
|
|
32524
|
+
});
|
|
32525
|
+
}
|
|
32526
|
+
/** 排序按钮的提示文案随状态变,点了知道下一步会变成什么。 */
|
|
32527
|
+
function sortHint(t, sort) {
|
|
32528
|
+
if (sort === "asc") return t("list.sortAsc");
|
|
32529
|
+
if (sort === "desc") return t("list.sortDesc");
|
|
32530
|
+
return t("list.sortNone");
|
|
32531
|
+
}
|
|
32329
32532
|
/** 筛选摘要里的小胶囊。 */
|
|
32330
32533
|
const chipStyle = {
|
|
32331
32534
|
display: "inline-flex",
|
|
@@ -32351,57 +32554,73 @@ const chipRemoveStyle = {
|
|
|
32351
32554
|
function ItemRow({ t, item, selected, onSelect, onOpen, onInsert }) {
|
|
32352
32555
|
const [menuOpen, setMenuOpen] = (0, react.useState)(false);
|
|
32353
32556
|
const read = isRead(item);
|
|
32354
|
-
const
|
|
32355
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
32356
|
-
|
|
32357
|
-
|
|
32358
|
-
|
|
32359
|
-
setMenuOpen(false)
|
|
32360
|
-
|
|
32361
|
-
|
|
32362
|
-
|
|
32363
|
-
portal: true,
|
|
32364
|
-
items: [{
|
|
32365
|
-
id: "insert-item",
|
|
32366
|
-
label: t("action.insertItem")
|
|
32367
|
-
}],
|
|
32368
|
-
anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32369
|
-
title: itemTooltip(t, item),
|
|
32370
|
-
onClick: (event) => onSelect(item.key, event.ctrlKey || event.metaKey),
|
|
32371
|
-
onDoubleClick: () => onOpen(item.key, item.title),
|
|
32372
|
-
onContextMenu: (event) => {
|
|
32373
|
-
event.preventDefault();
|
|
32374
|
-
setMenuOpen(true);
|
|
32375
|
-
},
|
|
32376
|
-
style: {
|
|
32377
|
-
...itemRowStyle,
|
|
32378
|
-
background: selected ? "rgba(80,140,255,0.18)" : "transparent"
|
|
32557
|
+
const typeLabel = itemTypeLabel(t, item.itemType);
|
|
32558
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
32559
|
+
style: itemShellStyle,
|
|
32560
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
32561
|
+
open: menuOpen,
|
|
32562
|
+
onClose: () => setMenuOpen(false),
|
|
32563
|
+
onSelect: (id) => {
|
|
32564
|
+
setMenuOpen(false);
|
|
32565
|
+
if (id === "insert-item") onInsert(item);
|
|
32379
32566
|
},
|
|
32380
|
-
|
|
32381
|
-
|
|
32567
|
+
align: "end",
|
|
32568
|
+
portal: true,
|
|
32569
|
+
items: [{
|
|
32570
|
+
id: "insert-item",
|
|
32571
|
+
label: t("action.insertItem")
|
|
32572
|
+
}],
|
|
32573
|
+
anchor: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32574
|
+
className: "dsh-zotero-item-row",
|
|
32575
|
+
title: itemTooltip(t, item),
|
|
32576
|
+
onClick: (event) => onSelect(item.key, event.ctrlKey || event.metaKey),
|
|
32577
|
+
onDoubleClick: () => onOpen(item.key, item.title),
|
|
32578
|
+
onContextMenu: (event) => {
|
|
32579
|
+
event.preventDefault();
|
|
32580
|
+
setMenuOpen(true);
|
|
32581
|
+
},
|
|
32582
|
+
style: selected ? {
|
|
32583
|
+
...itemRowStyle,
|
|
32584
|
+
background: "rgba(80,140,255,0.16)"
|
|
32585
|
+
} : itemRowStyle,
|
|
32586
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32382
32587
|
style: itemIconStyle,
|
|
32383
32588
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ItemTypeIcon, {
|
|
32384
32589
|
itemType: item.itemType,
|
|
32385
32590
|
read
|
|
32386
32591
|
})
|
|
32387
|
-
}),
|
|
32388
|
-
|
|
32389
|
-
|
|
32390
|
-
|
|
32391
|
-
|
|
32392
|
-
|
|
32393
|
-
|
|
32394
|
-
|
|
32395
|
-
|
|
32396
|
-
|
|
32397
|
-
|
|
32398
|
-
|
|
32399
|
-
|
|
32592
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32593
|
+
style: itemBodyStyle,
|
|
32594
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32595
|
+
style: {
|
|
32596
|
+
...itemTitleStyle,
|
|
32597
|
+
...readTitleStyle(read)
|
|
32598
|
+
},
|
|
32599
|
+
children: item.title
|
|
32600
|
+
}), (typeLabel !== "" || item.year !== "" || item.creators !== "") && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32601
|
+
style: itemMetaStyle,
|
|
32602
|
+
children: [
|
|
32603
|
+
typeLabel !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32604
|
+
style: itemMetaTypeStyle,
|
|
32605
|
+
children: typeLabel
|
|
32606
|
+
}),
|
|
32607
|
+
item.year !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32608
|
+
style: itemMetaYearStyle,
|
|
32609
|
+
children: item.year
|
|
32610
|
+
}),
|
|
32611
|
+
item.creators !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32612
|
+
style: itemMetaTextStyle,
|
|
32613
|
+
children: item.creators
|
|
32614
|
+
})
|
|
32615
|
+
]
|
|
32616
|
+
})]
|
|
32617
|
+
})]
|
|
32618
|
+
})
|
|
32400
32619
|
})
|
|
32401
32620
|
});
|
|
32402
32621
|
}
|
|
32403
32622
|
function ItemList(props) {
|
|
32404
|
-
const { t, libraryName, selectedCollection, query, items, itemsTotal, itemsLoading, itemsError, selectedTags, tagMode, selectedItemKeys, onSearch, onRemoveTag, onRetry, onLoadMore, onOpenItem, onSelectItem, onClearSelection, onInsertItem, onInsertItems, onInsertCollection } = props;
|
|
32623
|
+
const { t, libraryName, selectedCollection, query, items, itemsTotal, itemsLoading, itemsError, selectedTags, tagMode, sort, selectedItemKeys, onSearch, onRemoveTag, onRetry, onLoadMore, onCycleSort, onOpenItem, onSelectItem, onClearSelection, onInsertItem, onInsertItems, onInsertCollection } = props;
|
|
32405
32624
|
const name = selectionName(t, libraryName, selectedCollection);
|
|
32406
32625
|
const isRealCollection = selectedCollection !== null && selectedCollection.key !== "__library__" && selectedCollection.scope === void 0;
|
|
32407
32626
|
const tags = [...selectedTags];
|
|
@@ -32453,7 +32672,19 @@ function ItemList(props) {
|
|
|
32453
32672
|
style: citeButtonStyle,
|
|
32454
32673
|
onClick: () => onInsertCollection(selectedCollection),
|
|
32455
32674
|
children: t("action.insertItemShort")
|
|
32456
|
-
}) : null
|
|
32675
|
+
}) : null,
|
|
32676
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
32677
|
+
variant: "ghost",
|
|
32678
|
+
size: "sm",
|
|
32679
|
+
title: sortHint(t, sort),
|
|
32680
|
+
"aria-label": sortHint(t, sort),
|
|
32681
|
+
style: sort === "none" ? sortButtonStyle : {
|
|
32682
|
+
...sortButtonStyle,
|
|
32683
|
+
color: SORT_ACTIVE_COLOR
|
|
32684
|
+
},
|
|
32685
|
+
onClick: onCycleSort,
|
|
32686
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SortIcon, { sort })
|
|
32687
|
+
})
|
|
32457
32688
|
]
|
|
32458
32689
|
}),
|
|
32459
32690
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchField, {
|
|
@@ -32494,17 +32725,18 @@ function ItemList(props) {
|
|
|
32494
32725
|
})]
|
|
32495
32726
|
})
|
|
32496
32727
|
]
|
|
32497
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.
|
|
32728
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32498
32729
|
onClick: (event) => {
|
|
32499
32730
|
if (event.target === event.currentTarget) onClearSelection();
|
|
32500
32731
|
},
|
|
32501
32732
|
style: {
|
|
32502
32733
|
flex: 1,
|
|
32503
32734
|
minHeight: 0,
|
|
32504
|
-
|
|
32505
|
-
|
|
32735
|
+
overflowX: "hidden",
|
|
32736
|
+
overflowY: "auto",
|
|
32737
|
+
padding: "2px 6px 8px"
|
|
32506
32738
|
},
|
|
32507
|
-
children: itemsError !== null && items.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32739
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: ITEM_CSS }), itemsError !== null && items.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32508
32740
|
style: {
|
|
32509
32741
|
padding: "12px 8px",
|
|
32510
32742
|
fontSize: 12.5,
|
|
@@ -32541,7 +32773,7 @@ function ItemList(props) {
|
|
|
32541
32773
|
onClick: onLoadMore,
|
|
32542
32774
|
children: t("list.loadMore")
|
|
32543
32775
|
})
|
|
32544
|
-
})] })
|
|
32776
|
+
})] })]
|
|
32545
32777
|
})]
|
|
32546
32778
|
});
|
|
32547
32779
|
}
|
|
@@ -32941,7 +33173,7 @@ function StatusDot({ ok, label }) {
|
|
|
32941
33173
|
});
|
|
32942
33174
|
}
|
|
32943
33175
|
function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
|
|
32944
|
-
const { health, libraryName, collections, treeError, treeLoading, selectedCollection, query, items, itemsTotal, itemsLoading, itemsError, tags, tagsLoading, tagsError, treeQuery, tagQuery, selectedTags, tagMode, tagUsage, tagUsageLoading, selectedItemKeys } = usePaneState();
|
|
33176
|
+
const { health, libraryName, collections, treeError, treeLoading, selectedCollection, query, items, itemsTotal, itemsLoading, itemsError, tags, tagsLoading, tagsError, treeQuery, tagQuery, selectedTags, tagMode, tagUsage, tagUsageLoading, sort, selectedItemKeys } = usePaneState();
|
|
32945
33177
|
(0, react.useEffect)(() => {
|
|
32946
33178
|
loadTree();
|
|
32947
33179
|
}, []);
|
|
@@ -33136,11 +33368,13 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
|
|
|
33136
33368
|
itemsError,
|
|
33137
33369
|
selectedTags,
|
|
33138
33370
|
tagMode,
|
|
33371
|
+
sort,
|
|
33139
33372
|
selectedItemKeys,
|
|
33140
33373
|
onSearch: setQuery,
|
|
33141
33374
|
onRemoveTag: toggleTag,
|
|
33142
33375
|
onRetry: retryItems,
|
|
33143
33376
|
onLoadMore: loadMoreItems,
|
|
33377
|
+
onCycleSort: cycleItemSort,
|
|
33144
33378
|
onOpenItem,
|
|
33145
33379
|
onSelectItem: selectItem,
|
|
33146
33380
|
onClearSelection: clearItemSelection,
|
package/lib/host/router.js
CHANGED
|
@@ -173,6 +173,9 @@ async function handleItems(res, params) {
|
|
|
173
173
|
const q = params.get('q') ?? undefined;
|
|
174
174
|
const tags = params.getAll('tag').map((tag) => tag.trim()).filter((tag) => tag !== '');
|
|
175
175
|
const tagMode = params.get('tagMode') === 'any' ? 'any' : 'all';
|
|
176
|
+
// 排序:只认按标题,方向缺省正序;不认识的取值一律退回原始顺序。
|
|
177
|
+
const sortDirection = params.get('direction') === 'desc' ? 'desc' : 'asc';
|
|
178
|
+
const sort = params.get('sort') === 'title' ? 'title' : undefined;
|
|
176
179
|
const limit = clampLimit(params.get('limit'));
|
|
177
180
|
const offset = parseOffset(params.get('offset'));
|
|
178
181
|
const result = await zotero.listItems({
|
|
@@ -181,6 +184,8 @@ async function handleItems(res, params) {
|
|
|
181
184
|
q,
|
|
182
185
|
tags,
|
|
183
186
|
tagMode,
|
|
187
|
+
sort,
|
|
188
|
+
direction: sort === undefined ? undefined : sortDirection,
|
|
184
189
|
limit,
|
|
185
190
|
offset,
|
|
186
191
|
});
|
package/lib/zotero/client.d.ts
CHANGED
|
@@ -188,6 +188,9 @@ export interface ListItemsOptions {
|
|
|
188
188
|
/** 标签过滤:AND(默认)逐个 `tag=`,OR 合并成 `tag=A || B`。 */
|
|
189
189
|
tags?: readonly string[];
|
|
190
190
|
tagMode?: 'all' | 'any';
|
|
191
|
+
/** 排序字段;缺省用 Zotero 的原始顺序。 */
|
|
192
|
+
sort?: 'title';
|
|
193
|
+
direction?: 'asc' | 'desc';
|
|
191
194
|
limit: number;
|
|
192
195
|
offset: number;
|
|
193
196
|
}
|
package/lib/zotero/client.js
CHANGED
|
@@ -611,6 +611,13 @@ function appendItemFilters(params, options) {
|
|
|
611
611
|
params.append('tag', tag);
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
+
/** 把排序写进查询参数(本地 API 支持 `sort=title` + `direction=asc|desc`)。 */
|
|
615
|
+
function appendItemSort(params, options) {
|
|
616
|
+
if (options.sort === undefined)
|
|
617
|
+
return;
|
|
618
|
+
params.set('sort', options.sort);
|
|
619
|
+
params.set('direction', options.direction === 'desc' ? 'desc' : 'asc');
|
|
620
|
+
}
|
|
614
621
|
/** 范围内的顶层条目端点基址(条目列表与标签用量共用同一套范围规则)。 */
|
|
615
622
|
function itemListBase(options) {
|
|
616
623
|
return options.scope === 'publications'
|
|
@@ -628,6 +635,7 @@ function itemListQuery(options) {
|
|
|
628
635
|
start: String(options.offset),
|
|
629
636
|
});
|
|
630
637
|
appendItemFilters(params, options);
|
|
638
|
+
appendItemSort(params, options);
|
|
631
639
|
return { base: itemListBase(options), params };
|
|
632
640
|
}
|
|
633
641
|
/**
|
|
@@ -639,6 +647,8 @@ async function listUnfiled(options) {
|
|
|
639
647
|
for (let start = 0; start < UNFILED_SCAN_MAX; start += PAGE_SIZE) {
|
|
640
648
|
const params = new URLSearchParams({ limit: String(PAGE_SIZE), start: String(start) });
|
|
641
649
|
appendItemFilters(params, options);
|
|
650
|
+
// 排序也交给服务端:筛完再排会与分页对不上(扫描顺序决定筛后结果顺序)。
|
|
651
|
+
appendItemSort(params, options);
|
|
642
652
|
const { body } = await requestJson(`${libraryBase()}/items/top?${params.toString()}`);
|
|
643
653
|
if (!Array.isArray(body) || body.length === 0)
|
|
644
654
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-zotero",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Map your Zotero library into DSH: let AI operate Zotero for you and help you read papers. Browse collections and tags in the sidebar, read PDFs with highlights in place, and cite excerpts, annotations, notes or whole items into the chat. The model works from the source text for reviews, comparisons and data extraction, and can also search and organize the library, import papers and attach translations back to items; first use needs the Zotero MCP plugin and the local API enabled.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|