dsh-plugin-zotero 0.9.0 → 0.9.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.
Files changed (2) hide show
  1. package/client/client.js +49 -6
  2. package/package.json +1 -1
package/client/client.js CHANGED
@@ -2240,6 +2240,15 @@ const KNOWN_SCOPES = [
2240
2240
  ];
2241
2241
  /** 文库根节点的 id(只存在于客户端,不对应任何 Zotero 分类)。 */
2242
2242
  const TREE_ROOT_ID = "__library__";
2243
+ /**
2244
+ * 是否选中「最近阅读」。
2245
+ *
2246
+ * 这份名单来自本插件的阅读记录,Host 端本来就按最后打开时间倒序拼好;
2247
+ * 标题排序对它没有意义,标签面板在这里也搜不到东西,所以两处都要按它关掉。
2248
+ */
2249
+ function isRecentSelection(collection) {
2250
+ return collection !== null && collection.scope === "recent";
2251
+ }
2243
2252
  function readSort() {
2244
2253
  try {
2245
2254
  const value = window.localStorage.getItem(SORT_KEY);
@@ -2583,14 +2592,15 @@ function reloadItems(options) {
2583
2592
  selectedItemKeys: /* @__PURE__ */ new Set()
2584
2593
  });
2585
2594
  patch({ itemsLoading: true });
2586
- const tags = [...state.selectedTags];
2595
+ const recent = isRecentSelection(state.selectedCollection);
2596
+ const tags = recent ? [] : [...state.selectedTags];
2587
2597
  fetchItems({
2588
2598
  ...selectionQuery(),
2589
2599
  q: state.query.trim(),
2590
2600
  tags: tags.length === 0 ? void 0 : tags,
2591
2601
  tagMode: tags.length === 0 ? void 0 : state.tagMode,
2592
- sort: state.sort === "none" ? void 0 : "title",
2593
- direction: state.sort === "none" ? void 0 : state.sort,
2602
+ sort: recent || state.sort === "none" ? void 0 : "title",
2603
+ direction: recent || state.sort === "none" ? void 0 : state.sort,
2594
2604
  limit: ITEMS_PAGE_SIZE,
2595
2605
  offset
2596
2606
  }, controller.signal).then((data) => {
@@ -2623,6 +2633,7 @@ function loadMoreItems() {
2623
2633
  * 状态写进 localStorage:所有会话共用同一块面板,重启后也保持上次的选择。
2624
2634
  */
2625
2635
  function cycleItemSort() {
2636
+ if (isRecentSelection(state.selectedCollection)) return;
2626
2637
  const next = state.sort === "none" ? "asc" : state.sort === "asc" ? "desc" : "none";
2627
2638
  patch({ sort: next });
2628
2639
  try {
@@ -5017,6 +5028,23 @@ const INSIDE_MIN_WIDTH = 160;
5017
5028
  /** 拖宽的硬上限,再宽只是白白盖住正文。 */
5018
5029
  const RESIZE_MAX_WIDTH = 720;
5019
5030
  /**
5031
+ * 面板根节点上的「别拖窗口」声明。
5032
+ *
5033
+ * macOS 宿主的窗口拖拽区是**几何矩形**,不是命中测试:它给整行 chrome 打
5034
+ * `data-window-drag`(对话头部、侧栏顶条、dockkit tabStrip …),浮层只要在几何上
5035
+ * 压住那一行,那段像素就归窗口拖拽 —— 谁画在上层、有没有 pointer capture 都不算数。
5036
+ * 于是把浮层拖到 y≈22(压到对话头部那行)后按住标题栏,动的是整个 DSH 窗口,
5037
+ * 浮层反而拖不动了。
5038
+ *
5039
+ * 宿主留的出口是 `[data-window-drag-exclude]{-webkit-app-region:no-drag}`(base.css),
5040
+ * 且 0.2.2-rc.1 起 `role="dialog"` 之类只在 `data-window-drag` / `-controls` 作用域内
5041
+ * 才自动豁免 no-drag —— 浮层在阅读区里,拿不到那份豁免,必须自己声明。挂了它,
5042
+ * 浮层的整个矩形从拖拽区里被减掉:无论拖到窗口哪儿,按下的都是浮层自己。
5043
+ *
5044
+ * 译文浮层(`viewer/TranslationCard`)压在正文上,会碰到同一行带子,共用这一份。
5045
+ */
5046
+ const WINDOW_DRAG_EXCLUDE = { "data-window-drag-exclude": "" };
5047
+ /**
5020
5048
  * 最近一次「摆到右栏外看得见吗」的结论,只用作下次打开的起点。
5021
5049
  *
5022
5050
  * 早先这里是「一次失败就整个会话锁死在右栏内」:拖动中取样点偶尔被别的元素
@@ -5272,6 +5300,7 @@ function useFloatingBox(options) {
5272
5300
  width: size?.width ?? layout.width,
5273
5301
  ...size === null ? { maxHeight: layout.maxHeight } : { height: size.height }
5274
5302
  },
5303
+ panelProps: WINDOW_DRAG_EXCLUDE,
5275
5304
  moveProps: {
5276
5305
  onPointerDown: (event) => beginDrag("move", event),
5277
5306
  onPointerMove: handleDrag,
@@ -6414,6 +6443,7 @@ function InfoPanel({ t, detail, currentAttachmentKey, open, onToggle, onClose, o
6414
6443
  ref: box.panelRef,
6415
6444
  role: "dialog",
6416
6445
  "aria-label": t("detail.info"),
6446
+ ...box.panelProps,
6417
6447
  style: {
6418
6448
  ...panelStyle$1,
6419
6449
  ...box.style
@@ -6972,6 +7002,7 @@ function OutlinePanel({ t, itemKey, items, sourceLabel, activeIndex, open, onTog
6972
7002
  ref: box.panelRef,
6973
7003
  role: "dialog",
6974
7004
  "aria-label": t("outline.title"),
7005
+ ...box.panelProps,
6975
7006
  style: {
6976
7007
  ...panelStyle,
6977
7008
  ...box.style
@@ -32142,6 +32173,7 @@ function TranslationCard({ t, view, bounds, engine, onEngineChange, onClose, onR
32142
32173
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
32143
32174
  ref: cardRef,
32144
32175
  [MARK]: "",
32176
+ ...WINDOW_DRAG_EXCLUDE,
32145
32177
  style: {
32146
32178
  ...cardStyle,
32147
32179
  width: size.width,
@@ -40290,6 +40322,9 @@ function SearchField({ value, placeholder, clearLabel, onChange }) {
40290
40322
  * 多选,右上角「引用 N」把选中的每条各插一个胶囊。右键单行仍能直接插该条引用。
40291
40323
  * 列表分页(加载更多),筛选后为空与本来为空分开提示。
40292
40324
  *
40325
+ * 标题排序按钮只在真实分类 / 虚拟分类下出现:「最近阅读」恒按最后打开时间倒序,
40326
+ * 那一栏不给排序入口(见 {@link isRecentSelection})。
40327
+ *
40293
40328
  * 行内排版是两行:第一行只放标题,第二行小字灰色放「类型 + 年份 + 作者」,
40294
40329
  * 行与行之间用一条浅色细线分隔。
40295
40330
  */
@@ -40692,6 +40727,8 @@ function ItemList(props) {
40692
40727
  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;
40693
40728
  const name = selectionName(t, libraryName, selectedCollection);
40694
40729
  const isRealCollection = selectedCollection !== null && selectedCollection.key !== "__library__" && selectedCollection.scope === void 0;
40730
+ /** 「最近阅读」恒按最后打开时间倒序:不给标题排序入口,省得点了没反应。 */
40731
+ const recent = isRecentSelection(selectedCollection);
40695
40732
  const tags = [...selectedTags];
40696
40733
  const filtered = tags.length > 0 || query.trim() !== "";
40697
40734
  /** 按列表顺序取选中项,插进草稿的 chip 顺序才与眼前一致。 */
@@ -40737,7 +40774,7 @@ function ItemList(props) {
40737
40774
  onClick: () => onInsertCollection(selectedCollection),
40738
40775
  children: t("action.insertItemShort")
40739
40776
  }) : null,
40740
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
40777
+ !recent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
40741
40778
  variant: "ghost",
40742
40779
  size: "sm",
40743
40780
  title: sortHint(t, sort),
@@ -41220,7 +41257,8 @@ const plainButtonStyle = {
41220
41257
  *
41221
41258
  * 与 Zotero 一致:左侧只有分类与标签,条目一律在右侧列表;列表行单击选中、
41222
41259
  * 双击才在本面板顶层开独立 tab(`onOpenItem`),详情不再占列表位置。
41223
- * 标签面板跟随当前目录:选中目录只列该目录自身的标签,切目录清空已选。
41260
+ * 标签面板跟随当前目录:选中目录只列该目录自身的标签,切目录清空已选;
41261
+ * 「最近阅读」下整块标签面板不渲染(只按最后打开时间列条目,不参与标签筛选)。
41224
41262
  *
41225
41263
  * 两栏之间是可拖动的分隔条(宽度存 localStorage,跨会话/重启都记住)。
41226
41264
  * 数据与选择状态都在 {@link paneStore} 的模块级单例里(跨会话共用同一块面板)。
@@ -41264,6 +41302,11 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
41264
41302
  (0, react.useEffect)(() => {
41265
41303
  loadTree();
41266
41304
  }, []);
41305
+ /**
41306
+ * 「最近阅读」下不渲染标签面板:那份名单只来自本插件的阅读记录,
41307
+ * 标签过滤在里面筛不出东西,留着只会占掉分类树的高度。
41308
+ */
41309
+ const recent = isRecentSelection(selectedCollection);
41267
41310
  const insertion = useInsertion(t, sessions, sessionId, inputActions);
41268
41311
  const [treeWidth, setTreeWidth] = (0, react.useState)(readTreeWidth);
41269
41312
  const [splitHover, setSplitHover] = (0, react.useState)(false);
@@ -41389,7 +41432,7 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
41389
41432
  onInsertCollection: insertion.insertCollection
41390
41433
  })
41391
41434
  }),
41392
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TagPanel, {
41435
+ !recent && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TagPanel, {
41393
41436
  t,
41394
41437
  tags,
41395
41438
  tagsLoading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-zotero",
3
- "version": "0.9.0",
3
+ "version": "0.9.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",