dsh-plugin-zotero 0.1.4 → 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.
Files changed (2) hide show
  1. package/client/client.js +100 -52
  2. package/package.json +7 -6
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",
@@ -1500,7 +1508,8 @@ const noteBodyStyle = {
1500
1508
  * 正文区内部再分两块:头部信息(标题 / 元数据 / 摘要,过高时自己滚动)与全文块
1501
1509
  * (撑满剩余高度、自己滚动),所以拖高正文区时全文文本跟着变高。
1502
1510
  *
1503
- * 摘要默认折叠,标题行右侧的箭头按钮展开 / 收起。
1511
+ * 元数据与摘要都默认折叠,各自小标题行右侧的箭头按钮展开 / 收起——右栏空间有限,
1512
+ * 折叠后把高度尽量让给全文正文。
1504
1513
  *
1505
1514
  * 「添加到会话」两处入口:头部按钮(整条目元数据)、全文块里的选区浮出按钮
1506
1515
  * (摘录)。全文块内用鼠标选中文本后浮出小按钮,位置取选区 rect。
@@ -1526,8 +1535,19 @@ const labelStyle = {
1526
1535
  const metaRowStyle = {
1527
1536
  display: "flex",
1528
1537
  gap: 4,
1529
- marginBottom: 4,
1530
- lineHeight: 1.6
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"
1531
1551
  };
1532
1552
  /** 去掉 CSL HTML 标签,只留可见文本(zotero 导出的是便携 HTML)。 */
1533
1553
  function stripTags$1(html) {
@@ -1545,11 +1565,36 @@ function MetaRow({ label, children }) {
1545
1565
  })]
1546
1566
  });
1547
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
+ }
1548
1592
  function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onOpenItem }) {
1549
1593
  const [selection, setSelection] = (0, react.useState)(null);
1550
1594
  const [bodyPercent, setBodyPercent] = (0, react.useState)(readBodyPercent);
1551
1595
  const [splitHover, setSplitHover] = (0, react.useState)(false);
1552
1596
  const [abstractOpen, setAbstractOpen] = (0, react.useState)(false);
1597
+ const [metaOpen, setMetaOpen] = (0, react.useState)(false);
1553
1598
  const boxRef = (0, react.useRef)(null);
1554
1599
  const rootRef = (0, react.useRef)(null);
1555
1600
  const dragRef = (0, react.useRef)(null);
@@ -1604,6 +1649,31 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onOpenItem }) {
1604
1649
  }, attachment.key)) })
1605
1650
  });
1606
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
+ });
1607
1677
  function clampBodyPercent(next) {
1608
1678
  return Math.min(Math.max(next, BODY_PERCENT_MIN), BODY_PERCENT_MAX);
1609
1679
  }
@@ -1680,73 +1750,51 @@ function ItemDetail({ t, detail, onInsertItem, onInsertExcerpt, onOpenItem }) {
1680
1750
  style: {
1681
1751
  display: "flex",
1682
1752
  alignItems: "flex-start",
1683
- gap: 8,
1684
- marginBottom: 10
1753
+ gap: 6,
1754
+ marginBottom: 6
1685
1755
  },
1686
1756
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
1687
1757
  style: {
1688
1758
  flex: 1,
1689
1759
  margin: 0,
1690
- fontSize: 15,
1691
- lineHeight: 1.45
1760
+ fontSize: 13.5,
1761
+ fontWeight: 700,
1762
+ lineHeight: 1.4
1692
1763
  },
1693
1764
  children: detail.title
1694
1765
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
1695
1766
  variant: "outline",
1696
1767
  size: "sm",
1697
1768
  onClick: onInsertItem,
1698
- children: t("action.insertItem")
1769
+ title: t("action.insertItem"),
1770
+ style: insertButtonStyle,
1771
+ children: t("action.insertItemShort")
1699
1772
  })]
1700
1773
  }),
1701
- detail.creators.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
1702
- label: t("detail.creators"),
1703
- children: detail.creators.join("、")
1704
- }),
1705
- detail.year !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
1706
- label: t("detail.year"),
1707
- children: detail.year
1708
- }),
1709
- detail.publicationTitle !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
1710
- label: t("detail.source"),
1711
- children: detail.publicationTitle
1712
- }),
1713
- detail.doi !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
1714
- label: t("detail.doi"),
1715
- children: detail.doi
1716
- }),
1717
- detail.url !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
1718
- label: t("detail.url"),
1719
- children: detail.url
1720
- }),
1721
- detail.tags.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MetaRow, {
1722
- label: t("detail.tags"),
1723
- 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))]
1724
1786
  }),
1725
1787
  detail.abstract !== "" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
1726
1788
  style: {
1727
- marginTop: 12,
1789
+ ...collapsibleStyle,
1728
1790
  paddingBottom: 12
1729
1791
  },
1730
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1731
- style: sectionToggleRowStyle,
1732
- children: [
1733
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
1734
- style: {
1735
- ...sectionTitleStyle,
1736
- margin: 0
1737
- },
1738
- children: t("detail.abstract")
1739
- }),
1740
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
1741
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1742
- type: "button",
1743
- onClick: () => setAbstractOpen((open) => !open),
1744
- "aria-expanded": abstractOpen,
1745
- "aria-label": abstractOpen ? t("detail.abstractCollapse") : t("detail.abstractExpand"),
1746
- style: sectionToggleButtonStyle,
1747
- children: abstractOpen ? "▴" : "▾"
1748
- })
1749
- ]
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")
1750
1798
  }), abstractOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1751
1799
  style: {
1752
1800
  margin: "4px 0 0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-zotero",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
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",
@@ -35,6 +35,12 @@
35
35
  "engines": {
36
36
  "dsh": ">=0.2.1-rc.3 <0.3.0-0"
37
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"
43
+ },
38
44
  "peerDependencies": {
39
45
  "@deepseek-ai/cordis": "^4.0.5",
40
46
  "@deepseek-ai/schemastery": "^3.18.5"
@@ -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
  }