dsh-plugin-zotero 0.5.2 → 0.6.0
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 +158 -70
- package/client/client.js +486 -129
- package/lib/host/router.js +34 -1
- package/lib/zotero/client.d.ts +9 -1
- package/lib/zotero/client.js +53 -10
- package/lib/zotero/types.d.ts +16 -0
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -102,6 +102,15 @@ function fileUrl(key) {
|
|
|
102
102
|
return buildUrl("file", { key });
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
+
* 附件可读性探测。
|
|
106
|
+
*
|
|
107
|
+
* 文件流的失败只会给 pdf.js 一个 HTTP 状态码,真正的原因(文件不存在 /
|
|
108
|
+
* 无权限 / 没有本地文件)在这个端点里以 `ApiFailure.message` 给出。
|
|
109
|
+
*/
|
|
110
|
+
function fetchAttachmentInfo(key, signal) {
|
|
111
|
+
return get("attachment-info", { key }, signal);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
105
114
|
* 网页快照的目录形地址,直接作为 iframe 的 `src`。
|
|
106
115
|
*
|
|
107
116
|
* 尾斜杠必须在:浏览器按它解析快照里的相对资源。
|
|
@@ -540,6 +549,9 @@ const dicts = {
|
|
|
540
549
|
"annotation.type.ink": "手写",
|
|
541
550
|
"viewer.loading": "正在加载文档…",
|
|
542
551
|
"viewer.failed": "文档加载失败:{message}",
|
|
552
|
+
"viewer.serverResponse": "Zotero 返回了 {status},但附件本身可以读取,请重试一次。",
|
|
553
|
+
"viewer.attachmentUnavailable": "附件打不开:{message}",
|
|
554
|
+
"viewer.unsupported": "暂不支持预览 {type},可用「在 Zotero 中打开」。",
|
|
543
555
|
"viewer.page": "第 {n} 页",
|
|
544
556
|
"viewer.pageJump": "跳转到页码(回车确认,Esc 取消)",
|
|
545
557
|
"viewer.pageTotal": "/ {total}",
|
|
@@ -864,6 +876,9 @@ const dicts = {
|
|
|
864
876
|
"annotation.type.ink": "Ink",
|
|
865
877
|
"viewer.loading": "Loading document…",
|
|
866
878
|
"viewer.failed": "Failed to load the document: {message}",
|
|
879
|
+
"viewer.serverResponse": "Zotero returned {status}, but the attachment itself is readable — please retry.",
|
|
880
|
+
"viewer.attachmentUnavailable": "Cannot open the attachment: {message}",
|
|
881
|
+
"viewer.unsupported": "Preview is not supported for {type} — use “Open in Zotero”.",
|
|
867
882
|
"viewer.page": "Page {n}",
|
|
868
883
|
"viewer.pageJump": "Jump to page (Enter to confirm, Esc to cancel)",
|
|
869
884
|
"viewer.pageTotal": "/ {total}",
|
|
@@ -924,6 +939,9 @@ const dicts = {
|
|
|
924
939
|
* 主面板 = 目录树 + 标签面板 + 条目列表;条目详情在独立 tab 里,状态不在这里。
|
|
925
940
|
* 列表与标签请求都用「请求序号 + AbortController」防竞态:快速切分类、连续点标签时
|
|
926
941
|
* 旧响应不能覆盖新结果。
|
|
942
|
+
*
|
|
943
|
+
* 目录树的「选中 + 展开」另存一份到 localStorage:模块状态只活到页面刷新为止,
|
|
944
|
+
* 存档让刷新页面 / 重开面板后回到上次选中的目录。
|
|
927
945
|
*/
|
|
928
946
|
/** 搜索防抖时长。 */
|
|
929
947
|
const SEARCH_DEBOUNCE_MS = 250;
|
|
@@ -933,6 +951,15 @@ const ITEMS_PAGE_SIZE = 50;
|
|
|
933
951
|
const TOAST_MS = 3e3;
|
|
934
952
|
/** 列表排序的存储键(localStorage,跨会话与重启都记住)。 */
|
|
935
953
|
const SORT_KEY = "dsh-plugin-zotero.itemSort";
|
|
954
|
+
/** 目录树状态的存储键:刷新页面 / 重开面板后回到上次选中的目录。 */
|
|
955
|
+
const TREE_STATE_KEY = "dsh-plugin-zotero.treeState";
|
|
956
|
+
/** 合法的虚拟分类范围(存档里的 scope 不在其中就丢弃)。 */
|
|
957
|
+
const KNOWN_SCOPES = [
|
|
958
|
+
"library",
|
|
959
|
+
"publications",
|
|
960
|
+
"unfiled",
|
|
961
|
+
"trash"
|
|
962
|
+
];
|
|
936
963
|
/** 文库根节点的 id(只存在于客户端,不对应任何 Zotero 分类)。 */
|
|
937
964
|
const TREE_ROOT_ID = "__library__";
|
|
938
965
|
function readSort() {
|
|
@@ -943,7 +970,70 @@ function readSort() {
|
|
|
943
970
|
return "none";
|
|
944
971
|
}
|
|
945
972
|
}
|
|
973
|
+
/** 读目录树存档;缺失、坏 JSON、结构不认识都退回「文库根 + 只展开根」。 */
|
|
974
|
+
function readTreeState() {
|
|
975
|
+
const blank = {
|
|
976
|
+
selected: null,
|
|
977
|
+
expanded: []
|
|
978
|
+
};
|
|
979
|
+
try {
|
|
980
|
+
const raw = window.localStorage.getItem(TREE_STATE_KEY);
|
|
981
|
+
if (raw === null) return blank;
|
|
982
|
+
const parsed = JSON.parse(raw);
|
|
983
|
+
if (typeof parsed !== "object" || parsed === null) return blank;
|
|
984
|
+
const record = parsed;
|
|
985
|
+
const expanded = Array.isArray(record.expanded) ? record.expanded.filter((id) => typeof id === "string") : [];
|
|
986
|
+
const saved = record.selected;
|
|
987
|
+
if (saved === null || typeof saved !== "object" || typeof saved.key !== "string" || saved.key === "") return {
|
|
988
|
+
selected: null,
|
|
989
|
+
expanded
|
|
990
|
+
};
|
|
991
|
+
const scope = KNOWN_SCOPES.find((item) => item === saved.scope);
|
|
992
|
+
return {
|
|
993
|
+
selected: {
|
|
994
|
+
key: saved.key,
|
|
995
|
+
name: typeof saved.name === "string" ? saved.name : "",
|
|
996
|
+
...scope === void 0 ? {} : { scope }
|
|
997
|
+
},
|
|
998
|
+
expanded
|
|
999
|
+
};
|
|
1000
|
+
} catch {
|
|
1001
|
+
return blank;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* 把当前选中与展开写盘。
|
|
1006
|
+
*
|
|
1007
|
+
* 文库根是默认值,不存(存档为空即代表文库根),免得和「没有存档」两种状态打架。
|
|
1008
|
+
*/
|
|
1009
|
+
function saveTreeState() {
|
|
1010
|
+
const collection = state.selectedCollection;
|
|
1011
|
+
const saved = {
|
|
1012
|
+
selected: collection === null || collection.key === "__library__" ? null : {
|
|
1013
|
+
key: collection.key,
|
|
1014
|
+
name: collection.name,
|
|
1015
|
+
...collection.scope === void 0 ? {} : { scope: collection.scope }
|
|
1016
|
+
},
|
|
1017
|
+
expanded: [...state.expanded]
|
|
1018
|
+
};
|
|
1019
|
+
try {
|
|
1020
|
+
window.localStorage.setItem(TREE_STATE_KEY, JSON.stringify(saved));
|
|
1021
|
+
} catch {}
|
|
1022
|
+
}
|
|
1023
|
+
/** 选中分类的祖先 key 链(由内到外);结构异常时中断,避免死循环。 */
|
|
1024
|
+
function ancestorKeys(collections, key) {
|
|
1025
|
+
const byKey = new Map(collections.map((node) => [node.key, node]));
|
|
1026
|
+
const chain = [];
|
|
1027
|
+
let node = byKey.get(key);
|
|
1028
|
+
while (node !== void 0 && node.parentKey !== false) {
|
|
1029
|
+
if (chain.includes(node.parentKey)) break;
|
|
1030
|
+
chain.push(node.parentKey);
|
|
1031
|
+
node = byKey.get(node.parentKey);
|
|
1032
|
+
}
|
|
1033
|
+
return chain;
|
|
1034
|
+
}
|
|
946
1035
|
function initialState() {
|
|
1036
|
+
const saved = readTreeState();
|
|
947
1037
|
return {
|
|
948
1038
|
health: null,
|
|
949
1039
|
libraryName: "",
|
|
@@ -951,9 +1041,14 @@ function initialState() {
|
|
|
951
1041
|
treeError: null,
|
|
952
1042
|
treeLoading: true,
|
|
953
1043
|
loaded: false,
|
|
954
|
-
expanded: /* @__PURE__ */ new Set([TREE_ROOT_ID]),
|
|
1044
|
+
expanded: /* @__PURE__ */ new Set([TREE_ROOT_ID, ...saved.expanded]),
|
|
955
1045
|
treeQuery: "",
|
|
956
|
-
selectedCollection: null
|
|
1046
|
+
selectedCollection: saved.selected === null ? null : {
|
|
1047
|
+
key: saved.selected.key,
|
|
1048
|
+
name: saved.selected.name,
|
|
1049
|
+
parentKey: false,
|
|
1050
|
+
...saved.selected.scope === void 0 ? {} : { scope: saved.selected.scope }
|
|
1051
|
+
},
|
|
957
1052
|
items: [],
|
|
958
1053
|
itemsTotal: 0,
|
|
959
1054
|
itemsLoading: false,
|
|
@@ -1058,14 +1153,19 @@ function loadTree(force = false) {
|
|
|
1058
1153
|
else if (previous.scope !== void 0) selected = previous;
|
|
1059
1154
|
else selected = tree.collections.find((node) => node.key === previous.key) ?? libraryRoot(tree.libraryName);
|
|
1060
1155
|
}
|
|
1156
|
+
const expanded = new Set(state.expanded);
|
|
1157
|
+
expanded.add(TREE_ROOT_ID);
|
|
1158
|
+
if (selected.key !== "__library__" && selected.scope === void 0) for (const key of ancestorKeys(tree.collections, selected.key)) expanded.add(key);
|
|
1061
1159
|
patch$1({
|
|
1062
1160
|
health: healthData,
|
|
1063
1161
|
collections: tree.collections,
|
|
1064
1162
|
libraryName: tree.libraryName,
|
|
1065
1163
|
treeError: null,
|
|
1066
1164
|
loaded: true,
|
|
1165
|
+
expanded,
|
|
1067
1166
|
selectedCollection: selected
|
|
1068
1167
|
});
|
|
1168
|
+
saveTreeState();
|
|
1069
1169
|
reloadItems({ reset: true });
|
|
1070
1170
|
loadTagUsage();
|
|
1071
1171
|
} catch (error) {
|
|
@@ -1084,6 +1184,7 @@ function toggleTreeNode(nodeId) {
|
|
|
1084
1184
|
if (expanded.has(nodeId)) expanded.delete(nodeId);
|
|
1085
1185
|
else expanded.add(nodeId);
|
|
1086
1186
|
patch$1({ expanded });
|
|
1187
|
+
saveTreeState();
|
|
1087
1188
|
}
|
|
1088
1189
|
/**
|
|
1089
1190
|
* 分类树名称筛选(纯客户端,参照 Zotero 左栏的目录过滤)。
|
|
@@ -1112,6 +1213,7 @@ function selectCollection(collection) {
|
|
|
1112
1213
|
selectedTags: /* @__PURE__ */ new Set(),
|
|
1113
1214
|
tagQuery: ""
|
|
1114
1215
|
});
|
|
1216
|
+
saveTreeState();
|
|
1115
1217
|
reloadItems({ reset: true });
|
|
1116
1218
|
loadTagUsage();
|
|
1117
1219
|
}
|
|
@@ -1869,6 +1971,188 @@ function insertChip(sessions, sessionId, reference, span) {
|
|
|
1869
1971
|
}) === true;
|
|
1870
1972
|
}
|
|
1871
1973
|
//#endregion
|
|
1974
|
+
//#region src/client/styles.ts
|
|
1975
|
+
/** 蓝色高亮色(详情面板的区块标题、当前附件标记等旧调用)。 */
|
|
1976
|
+
const ACCENT = "#508cff";
|
|
1977
|
+
/** Zotero 风格的图标色:固定彩色,不随主题变。 */
|
|
1978
|
+
const TREE_BLUE = "#3b7de0";
|
|
1979
|
+
const TREE_GREEN = "#2f9e63";
|
|
1980
|
+
const TREE_ORANGE = "#e0872f";
|
|
1981
|
+
const TREE_RED = "#dc5a55";
|
|
1982
|
+
/** 标题的蓝→紫点缀。 */
|
|
1983
|
+
const TITLE_BAR_GRADIENT = `linear-gradient(180deg, #4a86e8 0%, #8a63e8 100%)`;
|
|
1984
|
+
/**
|
|
1985
|
+
* 所有按钮的常态配色:浅蓝底 + 蓝色线条轮廓。
|
|
1986
|
+
*
|
|
1987
|
+
* 用内联样式而非 CSS 类覆盖宿主 Button 的默认 background/border(内联优先级
|
|
1988
|
+
* 更高);hover 等伪类交给 {@link THEME_CSS} 的 `.dsh-zp-soft-btn` 规则。
|
|
1989
|
+
* 文字取宿主主题变量,深浅色都可读;主色只体现在底、框、图标上。
|
|
1990
|
+
*/
|
|
1991
|
+
const SOFT_BUTTON_STYLE = {
|
|
1992
|
+
color: "var(--dsw-alias-label-primary, CanvasText)",
|
|
1993
|
+
background: "rgba(74,134,232,0.10)",
|
|
1994
|
+
border: "1px solid rgba(74,134,232,0.45)",
|
|
1995
|
+
boxShadow: "0 1px 1px rgba(31,64,128,0.05)",
|
|
1996
|
+
boxSizing: "border-box"
|
|
1997
|
+
};
|
|
1998
|
+
/** 选中 / 激活态:同一套描边,底色与边框加深。 */
|
|
1999
|
+
const SOFT_BUTTON_ACTIVE_STYLE = {
|
|
2000
|
+
...SOFT_BUTTON_STYLE,
|
|
2001
|
+
background: "rgba(74,134,232,0.24)",
|
|
2002
|
+
border: "1px solid rgba(74,134,232,0.85)"
|
|
2003
|
+
};
|
|
2004
|
+
/** 所有「浅底 + 描边」按钮共用的 class(primary 实心主操作不加)。 */
|
|
2005
|
+
const SOFT_BUTTON_CLASS = "dsh-zp-soft-btn";
|
|
2006
|
+
/** 标题外壳 class;文字色与渐变竖条写在 CSS 里(要做 light/dark 渐进增强)。 */
|
|
2007
|
+
const SECTION_TITLE_CLASS = "dsh-zp-title";
|
|
2008
|
+
/** 按钮 class:选中 / 激活态多挂 `is-active`,hover 时底色加深得更多。 */
|
|
2009
|
+
function softButtonClass(active = false) {
|
|
2010
|
+
return active ? `${SOFT_BUTTON_CLASS} is-active` : SOFT_BUTTON_CLASS;
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* 标签胶囊的配色,与蓝色系操作按钮分开:
|
|
2014
|
+
* 默认**完全无底色**(只留中性灰细描边),选中照 Zotero 标签选择器用
|
|
2015
|
+
* **深灰底 + 白字**——全站已经够蓝了,标签选中不再掺蓝。
|
|
2016
|
+
* 不复用 `.dsh-zp-soft-btn`,否则它 hover 的 !important 会改掉选中底色。
|
|
2017
|
+
*/
|
|
2018
|
+
const TAG_IDLE_STYLE = {
|
|
2019
|
+
color: "var(--dsw-alias-label-primary, CanvasText)",
|
|
2020
|
+
background: "transparent",
|
|
2021
|
+
border: "1px solid rgba(127,127,127,0.34)",
|
|
2022
|
+
boxSizing: "border-box"
|
|
2023
|
+
};
|
|
2024
|
+
/** Zotero 风格的选中标签高亮:深灰 #5a5a5a + 白字。 */
|
|
2025
|
+
const TAG_SELECTED_STYLE = {
|
|
2026
|
+
color: "#ffffff",
|
|
2027
|
+
background: "#5a5a5a",
|
|
2028
|
+
border: "1px solid #4f4f4f",
|
|
2029
|
+
fontWeight: 600,
|
|
2030
|
+
boxSizing: "border-box"
|
|
2031
|
+
};
|
|
2032
|
+
/**
|
|
2033
|
+
* 「全部 / 任一」这类模式开关的选中态:与全站按钮同族(浅蓝底 + 蓝描边),
|
|
2034
|
+
* 只把底色加深一档,不用实心色,也不改文字色。
|
|
2035
|
+
*/
|
|
2036
|
+
const MODE_BUTTON_ACTIVE_STYLE = {
|
|
2037
|
+
...SOFT_BUTTON_ACTIVE_STYLE,
|
|
2038
|
+
background: "rgba(74,134,232,0.32)",
|
|
2039
|
+
border: "1px solid rgba(74,134,232,0.9)"
|
|
2040
|
+
};
|
|
2041
|
+
const TAG_BUTTON_CLASS = "dsh-zp-tag";
|
|
2042
|
+
/** 选中态多挂 `is-selected`,CSS 只负责 hover / active。 */
|
|
2043
|
+
function tagButtonClass(selected = false) {
|
|
2044
|
+
return selected ? `${TAG_BUTTON_CLASS} is-selected` : TAG_BUTTON_CLASS;
|
|
2045
|
+
}
|
|
2046
|
+
/** 全局主题样式:只在入口注入一次,portal / 浮层里的按钮同样生效。 */
|
|
2047
|
+
const THEME_CSS = `
|
|
2048
|
+
.dsh-zp-soft-btn {
|
|
2049
|
+
transition: background-color 120ms ease, border-color 120ms ease;
|
|
2050
|
+
}
|
|
2051
|
+
.dsh-zp-soft-btn:hover:not(:disabled) {
|
|
2052
|
+
background-color: rgba(74, 134, 232, 0.20) !important;
|
|
2053
|
+
border-color: rgba(74, 134, 232, 0.78) !important;
|
|
2054
|
+
}
|
|
2055
|
+
.dsh-zp-soft-btn.is-active:hover:not(:disabled) {
|
|
2056
|
+
background-color: rgba(74, 134, 232, 0.42) !important;
|
|
2057
|
+
}
|
|
2058
|
+
.dsh-zp-soft-btn:active:not(:disabled) {
|
|
2059
|
+
background-color: rgba(74, 134, 232, 0.26) !important;
|
|
2060
|
+
}
|
|
2061
|
+
.dsh-zp-soft-btn.is-active:active:not(:disabled) {
|
|
2062
|
+
background-color: rgba(74, 134, 232, 0.46) !important;
|
|
2063
|
+
}
|
|
2064
|
+
.dsh-zp-soft-btn:disabled {
|
|
2065
|
+
opacity: 0.55 !important;
|
|
2066
|
+
cursor: default;
|
|
2067
|
+
}
|
|
2068
|
+
.dsh-zp-tag {
|
|
2069
|
+
transition: background-color 120ms ease, border-color 120ms ease;
|
|
2070
|
+
}
|
|
2071
|
+
.dsh-zp-tag:hover {
|
|
2072
|
+
background-color: rgba(127, 127, 127, 0.10) !important;
|
|
2073
|
+
border-color: rgba(127, 127, 127, 0.60) !important;
|
|
2074
|
+
}
|
|
2075
|
+
.dsh-zp-tag.is-selected:hover {
|
|
2076
|
+
background-color: #4b4b4b !important;
|
|
2077
|
+
border-color: #404040 !important;
|
|
2078
|
+
}
|
|
2079
|
+
.dsh-zp-tag.is-selected:active {
|
|
2080
|
+
background-color: #404040 !important;
|
|
2081
|
+
}
|
|
2082
|
+
.dsh-zp-title {
|
|
2083
|
+
display: inline-flex;
|
|
2084
|
+
align-items: center;
|
|
2085
|
+
gap: 6px;
|
|
2086
|
+
min-width: 0;
|
|
2087
|
+
/* 无底色、无描边:只靠渐变竖条与文字色点缀,避免标题变成色块。 */
|
|
2088
|
+
padding: 2px 0;
|
|
2089
|
+
font-weight: 700;
|
|
2090
|
+
letter-spacing: 0.1px;
|
|
2091
|
+
/* 老浏览器 / 宿主未声明 color-scheme 时退回主题文字色,仍可读。 */
|
|
2092
|
+
color: var(--dsw-alias-label-primary, CanvasText);
|
|
2093
|
+
color: light-dark(#2456ad, #aacaff);
|
|
2094
|
+
}
|
|
2095
|
+
.dsh-zp-title-bar {
|
|
2096
|
+
flex: 0 0 auto;
|
|
2097
|
+
width: 3px;
|
|
2098
|
+
height: 12px;
|
|
2099
|
+
border-radius: 2px;
|
|
2100
|
+
background-image: ${TITLE_BAR_GRADIENT};
|
|
2101
|
+
}
|
|
2102
|
+
.dsh-zp-title-text {
|
|
2103
|
+
flex: 1 1 auto;
|
|
2104
|
+
min-width: 0;
|
|
2105
|
+
overflow: hidden;
|
|
2106
|
+
text-overflow: ellipsis;
|
|
2107
|
+
white-space: nowrap;
|
|
2108
|
+
}
|
|
2109
|
+
`.trim();
|
|
2110
|
+
const THEME_STYLE_ID = "dsh-plugin-zotero-theme";
|
|
2111
|
+
/** 幂等:插件重载 / 多会话只留一份 <style>。 */
|
|
2112
|
+
function installTheme() {
|
|
2113
|
+
if (typeof document === "undefined" || document.getElementById(THEME_STYLE_ID) !== null) return;
|
|
2114
|
+
const style = document.createElement("style");
|
|
2115
|
+
style.id = THEME_STYLE_ID;
|
|
2116
|
+
style.textContent = THEME_CSS;
|
|
2117
|
+
document.head.appendChild(style);
|
|
2118
|
+
}
|
|
2119
|
+
//#endregion
|
|
2120
|
+
//#region src/client/ui.tsx
|
|
2121
|
+
/** 与宿主 Button 同签名;自动套上浅底描边,保留调用方自己的紧凑尺寸。 */
|
|
2122
|
+
function Button({ className, variant, style, ...rest }) {
|
|
2123
|
+
if (variant === "primary") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2124
|
+
...rest,
|
|
2125
|
+
variant: "primary",
|
|
2126
|
+
className,
|
|
2127
|
+
style
|
|
2128
|
+
});
|
|
2129
|
+
const merged = [SOFT_BUTTON_CLASS, className].filter((part) => Boolean(part)).join(" ");
|
|
2130
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
2131
|
+
...rest,
|
|
2132
|
+
variant,
|
|
2133
|
+
className: merged,
|
|
2134
|
+
style: {
|
|
2135
|
+
...SOFT_BUTTON_STYLE,
|
|
2136
|
+
...style
|
|
2137
|
+
}
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
/** 无底色的分区标题(渐变竖条 + 蓝字);文字过长时省略号截断。 */
|
|
2141
|
+
function SectionTitle({ children, title, style }) {
|
|
2142
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
2143
|
+
className: SECTION_TITLE_CLASS,
|
|
2144
|
+
title,
|
|
2145
|
+
style: {
|
|
2146
|
+
fontSize: 13,
|
|
2147
|
+
...style
|
|
2148
|
+
},
|
|
2149
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "dsh-zp-title-bar" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", {
|
|
2150
|
+
className: "dsh-zp-title-text",
|
|
2151
|
+
children
|
|
2152
|
+
})]
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
//#endregion
|
|
1872
2156
|
//#region src/client/ZoteroCard.tsx
|
|
1873
2157
|
/**
|
|
1874
2158
|
* 设置页(浏览器半)。
|
|
@@ -2340,7 +2624,7 @@ function ZoteroSettingsSection(props) {
|
|
|
2340
2624
|
});
|
|
2341
2625
|
if (tools.kind === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2342
2626
|
style: HINT_STYLE,
|
|
2343
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("tools.error"), { message: tools.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2627
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("tools.error"), { message: tools.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2344
2628
|
variant: "ghost",
|
|
2345
2629
|
size: "sm",
|
|
2346
2630
|
onClick: () => reloadTools(),
|
|
@@ -2356,7 +2640,7 @@ function ZoteroSettingsSection(props) {
|
|
|
2356
2640
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("tools.summary"), {
|
|
2357
2641
|
total: tools.tools.length,
|
|
2358
2642
|
off: tools.tools.filter((tool) => disabledSet.has(tool.name)).length
|
|
2359
|
-
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2643
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2360
2644
|
variant: "ghost",
|
|
2361
2645
|
size: "sm",
|
|
2362
2646
|
onClick: () => reloadTools(),
|
|
@@ -2415,7 +2699,7 @@ function ZoteroSettingsSection(props) {
|
|
|
2415
2699
|
});
|
|
2416
2700
|
if (write.kind === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2417
2701
|
style: HINT_STYLE,
|
|
2418
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("write.error"), { message: write.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2702
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: tpl(t("write.error"), { message: write.message }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2419
2703
|
variant: "outline",
|
|
2420
2704
|
size: "sm",
|
|
2421
2705
|
onClick: () => reloadWrite(),
|
|
@@ -2444,7 +2728,7 @@ function ZoteroSettingsSection(props) {
|
|
|
2444
2728
|
}),
|
|
2445
2729
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2446
2730
|
style: WRITE_ACTIONS_STYLE,
|
|
2447
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2731
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2448
2732
|
variant: ready ? "outline" : "primary",
|
|
2449
2733
|
size: "md",
|
|
2450
2734
|
disabled: blocked,
|
|
@@ -2453,7 +2737,7 @@ function ZoteroSettingsSection(props) {
|
|
|
2453
2737
|
runAuthorize();
|
|
2454
2738
|
},
|
|
2455
2739
|
children: authorizing ? t("write.pending") : ready ? t("write.reauthorize") : t("write.authorize")
|
|
2456
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
2740
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2457
2741
|
variant: "outline",
|
|
2458
2742
|
size: "md",
|
|
2459
2743
|
title: t("write.reloadHint"),
|
|
@@ -2717,11 +3001,6 @@ const ANNOTATION_COLORS = [
|
|
|
2717
3001
|
"#f19837"
|
|
2718
3002
|
];
|
|
2719
3003
|
//#endregion
|
|
2720
|
-
//#region src/client/styles.ts
|
|
2721
|
-
/** 右栏共用样式。 */
|
|
2722
|
-
/** 蓝色高亮色(分区标题、当前附件标记)。 */
|
|
2723
|
-
const ACCENT = "#508cff";
|
|
2724
|
-
//#endregion
|
|
2725
3004
|
//#region src/client/AnnotationList.tsx
|
|
2726
3005
|
/**
|
|
2727
3006
|
* 条目详情里的标注列表(高亮 / 划线 / 笔记 / 文本 / 截图 / 墨迹)。
|
|
@@ -2835,9 +3114,11 @@ function Swatch({ color, type }) {
|
|
|
2835
3114
|
function Chip({ active, onClick, children }) {
|
|
2836
3115
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2837
3116
|
type: "button",
|
|
3117
|
+
className: softButtonClass(active),
|
|
2838
3118
|
onClick,
|
|
2839
3119
|
"aria-pressed": active,
|
|
2840
3120
|
style: {
|
|
3121
|
+
...active ? SOFT_BUTTON_ACTIVE_STYLE : SOFT_BUTTON_STYLE,
|
|
2841
3122
|
display: "inline-flex",
|
|
2842
3123
|
alignItems: "center",
|
|
2843
3124
|
gap: 4,
|
|
@@ -2846,9 +3127,6 @@ function Chip({ active, onClick, children }) {
|
|
|
2846
3127
|
fontSize: 11,
|
|
2847
3128
|
lineHeight: 1.2,
|
|
2848
3129
|
borderRadius: 10,
|
|
2849
|
-
color: "inherit",
|
|
2850
|
-
background: active ? "rgba(80,140,255,0.18)" : "transparent",
|
|
2851
|
-
border: `1px solid ${active ? "rgba(80,140,255,0.65)" : "rgba(127,127,127,0.3)"}`,
|
|
2852
3130
|
cursor: "pointer",
|
|
2853
3131
|
whiteSpace: "nowrap"
|
|
2854
3132
|
},
|
|
@@ -2958,7 +3236,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
2958
3236
|
}
|
|
2959
3237
|
function rowButtons(annotation) {
|
|
2960
3238
|
if (!canWrite) return null;
|
|
2961
|
-
if (!EDITABLE_TYPES.has(annotation.type)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3239
|
+
if (!EDITABLE_TYPES.has(annotation.type)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2962
3240
|
variant: "outline",
|
|
2963
3241
|
size: "sm",
|
|
2964
3242
|
disabled: true,
|
|
@@ -2967,7 +3245,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
2967
3245
|
children: t("annotation.edit")
|
|
2968
3246
|
});
|
|
2969
3247
|
const open = editingKey === annotation.key;
|
|
2970
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3248
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2971
3249
|
variant: "outline",
|
|
2972
3250
|
size: "sm",
|
|
2973
3251
|
disabled: busy,
|
|
@@ -2975,7 +3253,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
2975
3253
|
title: open ? void 0 : t("annotation.editTitle"),
|
|
2976
3254
|
style: insertButtonStyle$1,
|
|
2977
3255
|
children: open ? t("annotation.closeEdit") : t("annotation.edit")
|
|
2978
|
-
}), armed === annotation.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3256
|
+
}), armed === annotation.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2979
3257
|
variant: "outline",
|
|
2980
3258
|
size: "sm",
|
|
2981
3259
|
disabled: busy,
|
|
@@ -2983,7 +3261,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
2983
3261
|
title: t("annotation.deleteWarn"),
|
|
2984
3262
|
style: insertButtonStyle$1,
|
|
2985
3263
|
children: t("annotation.confirmDelete")
|
|
2986
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3264
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
2987
3265
|
variant: "outline",
|
|
2988
3266
|
size: "sm",
|
|
2989
3267
|
disabled: busy,
|
|
@@ -3062,7 +3340,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
3062
3340
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3063
3341
|
style: editorHintStyle$1,
|
|
3064
3342
|
children: t("annotation.commentHint")
|
|
3065
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3343
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3066
3344
|
variant: "outline",
|
|
3067
3345
|
size: "sm",
|
|
3068
3346
|
disabled: busy || draft.comment === originalComment,
|
|
@@ -3090,7 +3368,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
3090
3368
|
style: inputStyle,
|
|
3091
3369
|
"aria-label": t("annotation.pageLabel")
|
|
3092
3370
|
}),
|
|
3093
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3371
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3094
3372
|
variant: "outline",
|
|
3095
3373
|
size: "sm",
|
|
3096
3374
|
disabled: busy || !pageChanged,
|
|
@@ -3123,7 +3401,7 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
3123
3401
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3124
3402
|
style: editorHintStyle$1,
|
|
3125
3403
|
children: t("annotation.tagsHint")
|
|
3126
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3404
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3127
3405
|
variant: "outline",
|
|
3128
3406
|
size: "sm",
|
|
3129
3407
|
disabled: busy || draft.tags === originalTags,
|
|
@@ -3246,11 +3524,12 @@ function AnnotationList({ t, annotations, hasFulltext, truncated, filter, canWri
|
|
|
3246
3524
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
3247
3525
|
located && text === "" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3248
3526
|
type: "button",
|
|
3527
|
+
className: "dsh-zp-soft-btn",
|
|
3249
3528
|
onClick: () => onLocate(annotation),
|
|
3250
3529
|
style: locateButtonStyle,
|
|
3251
3530
|
children: t("detail.annotationLocate")
|
|
3252
3531
|
}),
|
|
3253
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
3532
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3254
3533
|
variant: "outline",
|
|
3255
3534
|
size: "sm",
|
|
3256
3535
|
disabled: !canInsert,
|
|
@@ -3306,15 +3585,13 @@ const insertButtonStyle$1 = {
|
|
|
3306
3585
|
whiteSpace: "nowrap"
|
|
3307
3586
|
};
|
|
3308
3587
|
const locateButtonStyle = {
|
|
3588
|
+
...SOFT_BUTTON_STYLE,
|
|
3309
3589
|
flexShrink: 0,
|
|
3310
3590
|
height: 20,
|
|
3311
3591
|
padding: "0 6px",
|
|
3312
3592
|
fontSize: 11,
|
|
3313
3593
|
lineHeight: 1.2,
|
|
3314
3594
|
borderRadius: 4,
|
|
3315
|
-
border: "1px solid rgba(127,127,127,0.3)",
|
|
3316
|
-
background: "transparent",
|
|
3317
|
-
color: "inherit",
|
|
3318
3595
|
cursor: "pointer",
|
|
3319
3596
|
whiteSpace: "nowrap"
|
|
3320
3597
|
};
|
|
@@ -3639,21 +3916,26 @@ const PATH = {
|
|
|
3639
3916
|
};
|
|
3640
3917
|
/** 已读图标的粉色:不用主题蓝,蓝色容易被读成「未读消息」徽标。 */
|
|
3641
3918
|
const READ_ICON_COLOR = "#e8798d";
|
|
3642
|
-
/**
|
|
3643
|
-
|
|
3919
|
+
/** 未读图标用 Zotero 蓝:列表行里比中性灰更醒目,也与树、按钮同一支蓝。 */
|
|
3920
|
+
const ICON_COLOR = "#4a86e8";
|
|
3921
|
+
/**
|
|
3922
|
+
* 条目类型图标;未知类型显示文档图标,已读条目整体转粉色。
|
|
3923
|
+
* 无底衬,默认 22px(比 Zotero 原生 16px 放大,列表里才看得清)。
|
|
3924
|
+
*/
|
|
3925
|
+
function ItemTypeIcon({ itemType, read = false, size = 22 }) {
|
|
3644
3926
|
const family = FAMILY[itemType] ?? "document";
|
|
3645
3927
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
3646
|
-
width:
|
|
3647
|
-
height:
|
|
3928
|
+
width: size,
|
|
3929
|
+
height: size,
|
|
3648
3930
|
viewBox: "0 0 16 16",
|
|
3649
3931
|
fill: "none",
|
|
3650
3932
|
stroke: "currentColor",
|
|
3651
|
-
strokeWidth: 1.
|
|
3933
|
+
strokeWidth: 1.35,
|
|
3652
3934
|
strokeLinejoin: "round",
|
|
3653
3935
|
strokeLinecap: "round",
|
|
3654
3936
|
style: {
|
|
3655
|
-
opacity: read ? .
|
|
3656
|
-
color: read ? READ_ICON_COLOR :
|
|
3937
|
+
opacity: read ? .95 : .9,
|
|
3938
|
+
color: read ? READ_ICON_COLOR : ICON_COLOR
|
|
3657
3939
|
},
|
|
3658
3940
|
"aria-hidden": true,
|
|
3659
3941
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: PATH[family] })
|
|
@@ -3766,7 +4048,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3766
4048
|
function rowButtons(note) {
|
|
3767
4049
|
if (!canWrite) return null;
|
|
3768
4050
|
const editingThis = editing?.key === note.key;
|
|
3769
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4051
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3770
4052
|
variant: "outline",
|
|
3771
4053
|
size: "sm",
|
|
3772
4054
|
disabled: busy,
|
|
@@ -3774,7 +4056,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3774
4056
|
title: note.anchored ? t("note.anchorWarn") : t("note.edit"),
|
|
3775
4057
|
style: insertButtonStyle,
|
|
3776
4058
|
children: editingThis ? t("note.cancel") : t("note.edit")
|
|
3777
|
-
}), armed === note.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4059
|
+
}), armed === note.key ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3778
4060
|
variant: "outline",
|
|
3779
4061
|
size: "sm",
|
|
3780
4062
|
disabled: busy,
|
|
@@ -3788,7 +4070,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3788
4070
|
title: t("note.deleteWarn"),
|
|
3789
4071
|
style: insertButtonStyle,
|
|
3790
4072
|
children: t("note.confirmDelete")
|
|
3791
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4073
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3792
4074
|
variant: "outline",
|
|
3793
4075
|
size: "sm",
|
|
3794
4076
|
disabled: busy || editingThis,
|
|
@@ -3814,7 +4096,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3814
4096
|
"aria-label": t("note.new")
|
|
3815
4097
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3816
4098
|
style: editorFootStyle,
|
|
3817
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4099
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3818
4100
|
variant: "outline",
|
|
3819
4101
|
size: "sm",
|
|
3820
4102
|
disabled: busy || draft.trim() === "",
|
|
@@ -3828,7 +4110,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3828
4110
|
});
|
|
3829
4111
|
},
|
|
3830
4112
|
children: pending === "create" ? t("note.saving") : t("note.save")
|
|
3831
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4113
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3832
4114
|
variant: "ghost",
|
|
3833
4115
|
size: "sm",
|
|
3834
4116
|
disabled: busy,
|
|
@@ -3875,7 +4157,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3875
4157
|
})
|
|
3876
4158
|
]
|
|
3877
4159
|
}),
|
|
3878
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4160
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3879
4161
|
variant: "outline",
|
|
3880
4162
|
size: "sm",
|
|
3881
4163
|
onClick: () => onInsert(note),
|
|
@@ -3909,7 +4191,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3909
4191
|
style: note.anchored ? anchorHintStyle : editorHintStyle,
|
|
3910
4192
|
children: note.anchored ? t("note.anchorWarn") : t("note.htmlHint")
|
|
3911
4193
|
}),
|
|
3912
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4194
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3913
4195
|
variant: "outline",
|
|
3914
4196
|
size: "sm",
|
|
3915
4197
|
disabled: busy || editor.html.trim() === "",
|
|
@@ -3925,7 +4207,7 @@ function NoteList({ t, notes, itemKey, canWrite, selfNote, composing, onComposin
|
|
|
3925
4207
|
},
|
|
3926
4208
|
children: pending === "edit" ? t("note.saving") : t("note.save")
|
|
3927
4209
|
}),
|
|
3928
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4210
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3929
4211
|
variant: "ghost",
|
|
3930
4212
|
size: "sm",
|
|
3931
4213
|
disabled: busy,
|
|
@@ -4173,6 +4455,7 @@ function InfoPanel({ t, detail, currentAttachmentKey, open, onToggle, onClose, o
|
|
|
4173
4455
|
}),
|
|
4174
4456
|
!selfNote && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4175
4457
|
type: "button",
|
|
4458
|
+
className: "dsh-zp-soft-btn",
|
|
4176
4459
|
onClick: onCite,
|
|
4177
4460
|
title: t("action.insertItem"),
|
|
4178
4461
|
style: citeTriggerStyle,
|
|
@@ -4382,6 +4665,7 @@ const panelTitleStyle = {
|
|
|
4382
4665
|
};
|
|
4383
4666
|
/** 收在 `i` 右边、跟它同一行:是每次读文献都要点的主操作,不藏进浮层。 */
|
|
4384
4667
|
const citeTriggerStyle = {
|
|
4668
|
+
...SOFT_BUTTON_STYLE,
|
|
4385
4669
|
position: "absolute",
|
|
4386
4670
|
pointerEvents: "auto",
|
|
4387
4671
|
top: 4,
|
|
@@ -4395,9 +4679,6 @@ const citeTriggerStyle = {
|
|
|
4395
4679
|
lineHeight: 1,
|
|
4396
4680
|
whiteSpace: "nowrap",
|
|
4397
4681
|
borderRadius: 11,
|
|
4398
|
-
border: "1px solid rgba(127,127,127,0.4)",
|
|
4399
|
-
background: "Canvas",
|
|
4400
|
-
color: "CanvasText",
|
|
4401
4682
|
cursor: "pointer",
|
|
4402
4683
|
boxShadow: "0 1px 4px rgba(0,0,0,0.18)",
|
|
4403
4684
|
zIndex: 21
|
|
@@ -28421,14 +28702,12 @@ const footStyle = {
|
|
|
28421
28702
|
marginTop: 8
|
|
28422
28703
|
};
|
|
28423
28704
|
const smallButtonStyle$1 = {
|
|
28705
|
+
...SOFT_BUTTON_STYLE,
|
|
28424
28706
|
height: 22,
|
|
28425
28707
|
padding: "0 8px",
|
|
28426
28708
|
fontSize: 11.5,
|
|
28427
28709
|
lineHeight: 1.2,
|
|
28428
28710
|
borderRadius: 5,
|
|
28429
|
-
border: "1px solid rgba(127,127,127,0.35)",
|
|
28430
|
-
background: "transparent",
|
|
28431
|
-
color: "inherit",
|
|
28432
28711
|
cursor: "pointer",
|
|
28433
28712
|
whiteSpace: "nowrap"
|
|
28434
28713
|
};
|
|
@@ -29019,6 +29298,7 @@ function SelectionBar({ t, text, x, y, onInsert, onDismiss, annotate }) {
|
|
|
29019
29298
|
const active = type === value;
|
|
29020
29299
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
29021
29300
|
type: "button",
|
|
29301
|
+
className: softButtonClass(active),
|
|
29022
29302
|
onMouseDown: (event) => event.preventDefault(),
|
|
29023
29303
|
onClick: () => setType(value),
|
|
29024
29304
|
disabled: annotate?.busy === true,
|
|
@@ -29055,6 +29335,7 @@ function SelectionBar({ t, text, x, y, onInsert, onDismiss, annotate }) {
|
|
|
29055
29335
|
}, color)),
|
|
29056
29336
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
29057
29337
|
type: "button",
|
|
29338
|
+
className: softButtonClass(commentOpen),
|
|
29058
29339
|
onMouseDown: (event) => event.preventDefault(),
|
|
29059
29340
|
onClick: () => setCommentOpen((open) => !open),
|
|
29060
29341
|
style: {
|
|
@@ -29086,20 +29367,19 @@ function SelectionBar({ t, text, x, y, onInsert, onDismiss, annotate }) {
|
|
|
29086
29367
|
style: groupStyle,
|
|
29087
29368
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
29088
29369
|
type: "button",
|
|
29370
|
+
className: SOFT_BUTTON_CLASS,
|
|
29089
29371
|
onClick: copy,
|
|
29090
29372
|
style: buttonStyle,
|
|
29091
29373
|
children: t("action.copy")
|
|
29092
29374
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
29093
29375
|
type: "button",
|
|
29376
|
+
className: SOFT_BUTTON_CLASS,
|
|
29094
29377
|
onMouseDown: (event) => event.preventDefault(),
|
|
29095
29378
|
onClick: () => {
|
|
29096
29379
|
onInsert(text);
|
|
29097
29380
|
finish();
|
|
29098
29381
|
},
|
|
29099
|
-
style:
|
|
29100
|
-
...buttonStyle,
|
|
29101
|
-
borderLeft: "1px solid rgba(127,127,127,0.25)"
|
|
29102
|
-
},
|
|
29382
|
+
style: buttonStyle,
|
|
29103
29383
|
children: t("action.insertItemShort")
|
|
29104
29384
|
})]
|
|
29105
29385
|
})
|
|
@@ -29133,28 +29413,22 @@ const groupStyle = {
|
|
|
29133
29413
|
whiteSpace: "nowrap"
|
|
29134
29414
|
};
|
|
29135
29415
|
const buttonStyle = {
|
|
29416
|
+
...SOFT_BUTTON_STYLE,
|
|
29136
29417
|
padding: "3px 8px",
|
|
29137
|
-
|
|
29138
|
-
background: "transparent",
|
|
29139
|
-
color: "inherit",
|
|
29418
|
+
borderRadius: 5,
|
|
29140
29419
|
font: "inherit",
|
|
29141
29420
|
cursor: "pointer",
|
|
29142
29421
|
whiteSpace: "nowrap"
|
|
29143
29422
|
};
|
|
29144
29423
|
const chipStyle$1 = {
|
|
29424
|
+
...SOFT_BUTTON_STYLE,
|
|
29145
29425
|
padding: "2px 6px",
|
|
29146
|
-
border: "1px solid rgba(127,127,127,0.25)",
|
|
29147
29426
|
borderRadius: 5,
|
|
29148
|
-
background: "transparent",
|
|
29149
|
-
color: "inherit",
|
|
29150
29427
|
font: "inherit",
|
|
29151
29428
|
cursor: "pointer",
|
|
29152
29429
|
whiteSpace: "nowrap"
|
|
29153
29430
|
};
|
|
29154
|
-
const chipActiveStyle =
|
|
29155
|
-
borderColor: "rgba(80, 140, 255, 0.6)",
|
|
29156
|
-
background: "rgba(80, 140, 255, 0.14)"
|
|
29157
|
-
};
|
|
29431
|
+
const chipActiveStyle = SOFT_BUTTON_ACTIVE_STYLE;
|
|
29158
29432
|
const swatchStyle = {
|
|
29159
29433
|
width: 15,
|
|
29160
29434
|
height: 15,
|
|
@@ -29333,6 +29607,42 @@ function errorText$1(error) {
|
|
|
29333
29607
|
return error instanceof Error ? error.message : String(error);
|
|
29334
29608
|
}
|
|
29335
29609
|
/**
|
|
29610
|
+
* pdf.js 的「服务器返回 N」:形如
|
|
29611
|
+
* `Unexpected server response (404) while retrieving PDF "dsh-app://app/…".`
|
|
29612
|
+
*/
|
|
29613
|
+
const SERVER_RESPONSE = /Unexpected server response \((\d{3})\)/u;
|
|
29614
|
+
/**
|
|
29615
|
+
* 去掉 pdf.js 文案里的 URL。
|
|
29616
|
+
*
|
|
29617
|
+
* 那串 `dsh-app://app/dsh-zotero/api/file?key=…` 对用户没有任何用处,只会让
|
|
29618
|
+
* 提示看起来像内部报错;状态码留着,真正的原因由 {@link explainLoadFailure} 补。
|
|
29619
|
+
*/
|
|
29620
|
+
function tidyLoadError(message) {
|
|
29621
|
+
return message.replace(/\s*while retrieving PDF\s*"[^"]*"\.?/u, "").trim();
|
|
29622
|
+
}
|
|
29623
|
+
/**
|
|
29624
|
+
* 把「服务器返回 404」翻译成人话。
|
|
29625
|
+
*
|
|
29626
|
+
* `/api/file` 成功时发的是二进制流,失败时 pdf.js 只拿得到状态码,于是界面上
|
|
29627
|
+
* 只剩一句看不懂的 404。这里补一次 `/api/attachment-info` 探测:
|
|
29628
|
+
* - 探测失败 → 那条错误消息就是真相(「附件文件不存在:/path」「没有权限读取」);
|
|
29629
|
+
* - 探测成功 → 文件本身读得到,这次 404 是瞬时的(Zotero 重启、正在重建索引),
|
|
29630
|
+
* 提示重试比解释原因有用。
|
|
29631
|
+
*
|
|
29632
|
+
* 非 HTTP 类失败(加密、损坏、内存不足)一律返回 `null`,让原文案照原样显示。
|
|
29633
|
+
*/
|
|
29634
|
+
async function explainLoadFailure(error, key, t, signal) {
|
|
29635
|
+
const status = SERVER_RESPONSE.exec(errorText$1(error))?.[1];
|
|
29636
|
+
if (status === void 0 || key === "") return null;
|
|
29637
|
+
try {
|
|
29638
|
+
const info = await fetchAttachmentInfo(key, signal);
|
|
29639
|
+
if (!info.servable) return tpl(t("viewer.unsupported"), { type: info.contentType || info.filename });
|
|
29640
|
+
return tpl(t("viewer.serverResponse"), { status });
|
|
29641
|
+
} catch (probeError) {
|
|
29642
|
+
return tpl(t("viewer.attachmentUnavailable"), { message: tidyLoadError(errorText$1(probeError)) });
|
|
29643
|
+
}
|
|
29644
|
+
}
|
|
29645
|
+
/**
|
|
29336
29646
|
* 一条书签的 `dest` → 1 基页码。
|
|
29337
29647
|
*
|
|
29338
29648
|
* `dest` 有两种形态:命名目标(字符串,要去 catalog 里查)或显式数组
|
|
@@ -29779,6 +30089,9 @@ function PdfViewer(props) {
|
|
|
29779
30089
|
return;
|
|
29780
30090
|
}
|
|
29781
30091
|
let disposed = false;
|
|
30092
|
+
const key = source?.attachmentKey ?? "";
|
|
30093
|
+
/** 换文档/卸载时把探测请求一起取消,别让它在后台白跑。 */
|
|
30094
|
+
const probe = new AbortController();
|
|
29782
30095
|
setLoading(true);
|
|
29783
30096
|
setError(null);
|
|
29784
30097
|
setPdf(null);
|
|
@@ -29818,12 +30131,16 @@ function PdfViewer(props) {
|
|
|
29818
30131
|
});
|
|
29819
30132
|
}).catch((loadError) => {
|
|
29820
30133
|
if (disposed) return;
|
|
29821
|
-
setError(errorText$1(loadError));
|
|
30134
|
+
setError(tpl(t("viewer.failed"), { message: tidyLoadError(errorText$1(loadError)) }));
|
|
29822
30135
|
setLoading(false);
|
|
29823
30136
|
outlineRef.current?.([]);
|
|
30137
|
+
explainLoadFailure(loadError, key, t, probe.signal).then((reason) => {
|
|
30138
|
+
if (!disposed && reason !== null) setError(reason);
|
|
30139
|
+
});
|
|
29824
30140
|
});
|
|
29825
30141
|
return () => {
|
|
29826
30142
|
disposed = true;
|
|
30143
|
+
probe.abort();
|
|
29827
30144
|
task.destroy();
|
|
29828
30145
|
};
|
|
29829
30146
|
}, [
|
|
@@ -30288,7 +30605,7 @@ function PdfViewer(props) {
|
|
|
30288
30605
|
},
|
|
30289
30606
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
30290
30607
|
style: { margin: "0 0 8px" },
|
|
30291
|
-
children:
|
|
30608
|
+
children: error
|
|
30292
30609
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
30293
30610
|
style: {
|
|
30294
30611
|
display: "flex",
|
|
@@ -30347,14 +30664,12 @@ const hintOverlayStyle = {
|
|
|
30347
30664
|
pointerEvents: "none"
|
|
30348
30665
|
};
|
|
30349
30666
|
const smallButtonStyle = {
|
|
30667
|
+
...SOFT_BUTTON_STYLE,
|
|
30350
30668
|
height: 22,
|
|
30351
30669
|
padding: "0 8px",
|
|
30352
30670
|
fontSize: 11.5,
|
|
30353
30671
|
lineHeight: 1.2,
|
|
30354
30672
|
borderRadius: 5,
|
|
30355
|
-
border: "1px solid rgba(127,127,127,0.35)",
|
|
30356
|
-
background: "transparent",
|
|
30357
|
-
color: "inherit",
|
|
30358
30673
|
cursor: "pointer",
|
|
30359
30674
|
whiteSpace: "nowrap"
|
|
30360
30675
|
};
|
|
@@ -30776,13 +31091,11 @@ const noticeStyle = {
|
|
|
30776
31091
|
zIndex: 9
|
|
30777
31092
|
};
|
|
30778
31093
|
const retryStyle = {
|
|
31094
|
+
...SOFT_BUTTON_STYLE,
|
|
30779
31095
|
marginLeft: "auto",
|
|
30780
31096
|
padding: "2px 8px",
|
|
30781
31097
|
fontSize: 11.5,
|
|
30782
31098
|
borderRadius: 5,
|
|
30783
|
-
border: "1px solid rgba(127,127,127,0.35)",
|
|
30784
|
-
background: "transparent",
|
|
30785
|
-
color: "inherit",
|
|
30786
31099
|
cursor: "pointer",
|
|
30787
31100
|
whiteSpace: "nowrap"
|
|
30788
31101
|
};
|
|
@@ -31420,6 +31733,7 @@ const iconButtonStyle = {
|
|
|
31420
31733
|
cursor: "pointer"
|
|
31421
31734
|
};
|
|
31422
31735
|
const toolButtonStyle = {
|
|
31736
|
+
...SOFT_BUTTON_STYLE,
|
|
31423
31737
|
flexShrink: 0,
|
|
31424
31738
|
display: "inline-flex",
|
|
31425
31739
|
alignItems: "center",
|
|
@@ -31430,9 +31744,6 @@ const toolButtonStyle = {
|
|
|
31430
31744
|
fontSize: 11.5,
|
|
31431
31745
|
lineHeight: 1,
|
|
31432
31746
|
borderRadius: 5,
|
|
31433
|
-
border: "1px solid rgba(127,127,127,0.3)",
|
|
31434
|
-
background: "transparent",
|
|
31435
|
-
color: "inherit",
|
|
31436
31747
|
cursor: "pointer",
|
|
31437
31748
|
whiteSpace: "nowrap"
|
|
31438
31749
|
};
|
|
@@ -31900,7 +32211,7 @@ function ZoteroItemPane(props) {
|
|
|
31900
32211
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
31901
32212
|
style: { margin: "0 0 8px" },
|
|
31902
32213
|
children: tpl(t("detail.loadFailed"), { message: error ?? "" })
|
|
31903
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
32214
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
31904
32215
|
variant: "outline",
|
|
31905
32216
|
size: "sm",
|
|
31906
32217
|
onClick: () => setRetry((n) => n + 1),
|
|
@@ -31930,7 +32241,8 @@ function ZoteroItemPane(props) {
|
|
|
31930
32241
|
* - 顶部筛选框只筛目录名(同 Zotero 左栏):命中分类保留、非命中的祖先作为
|
|
31931
32242
|
* 上下文行保留、未命中的子分类隐藏;筛选期间自动展开命中路径。
|
|
31932
32243
|
* - 展开状态放在 {@link paneStore}:右侧栏切 tab 时正文会被卸载重挂,
|
|
31933
|
-
* 只有模块级 store
|
|
32244
|
+
* 只有模块级 store 能让树保持原样;store 再把「选中 + 展开」写进 localStorage,
|
|
32245
|
+
* 页面刷新后也能回到上次的位置。
|
|
31934
32246
|
*/
|
|
31935
32247
|
/** 每层缩进量(px)。 */
|
|
31936
32248
|
const INDENT = 14;
|
|
@@ -31958,26 +32270,44 @@ const VIRTUAL_NODES = [
|
|
|
31958
32270
|
icon: "TRASH"
|
|
31959
32271
|
}
|
|
31960
32272
|
];
|
|
31961
|
-
function glyph(
|
|
32273
|
+
function glyph(icon, size = 15) {
|
|
31962
32274
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
31963
|
-
width:
|
|
31964
|
-
height:
|
|
32275
|
+
width: size,
|
|
32276
|
+
height: size,
|
|
31965
32277
|
viewBox: "0 0 16 16",
|
|
31966
32278
|
fill: "none",
|
|
31967
|
-
stroke:
|
|
31968
|
-
strokeWidth: 1.
|
|
32279
|
+
stroke: icon.color,
|
|
32280
|
+
strokeWidth: 1.4,
|
|
31969
32281
|
strokeLinejoin: "round",
|
|
31970
|
-
|
|
31971
|
-
|
|
32282
|
+
strokeLinecap: "round",
|
|
32283
|
+
"aria-hidden": true,
|
|
32284
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: icon.path })
|
|
31972
32285
|
});
|
|
31973
32286
|
}
|
|
31974
|
-
|
|
31975
|
-
const LIBRARY_ICON =
|
|
31976
|
-
|
|
32287
|
+
/** 蓝色古典柱廊:对应 Zotero 的「我的文库」。 */
|
|
32288
|
+
const LIBRARY_ICON = {
|
|
32289
|
+
path: "M1.7 5.9 8 2.5l6.3 3.4zM2.7 6.5h10.6M3.7 7.1v4.7M6.5 7.1v4.7M9.5 7.1v4.7M12.3 7.1v4.7M2.2 12.1h11.6M2.7 12.1v1.4h10.6v-1.4",
|
|
32290
|
+
color: TREE_BLUE
|
|
32291
|
+
};
|
|
32292
|
+
/** 蓝色文件夹:左上带 tab、中间一道盖线,Zotero 分类图标的轮廓。 */
|
|
32293
|
+
const FOLDER_ICON = {
|
|
32294
|
+
path: "M2.3 5.1V4.4a.8.8 0 0 1 .8-.8h3.4L7.9 5.3h5.8a.8.8 0 0 1 .8.8v6.6a.8.8 0 0 1-.8.8H3.1a.8.8 0 0 1-.8-.8zM2.3 6.7h12.2",
|
|
32295
|
+
color: TREE_BLUE
|
|
32296
|
+
};
|
|
32297
|
+
/** 虚拟分类的图标(键与 {@link VIRTUAL_NODES.icon} 对应)。 */
|
|
31977
32298
|
const VIRTUAL_ICON = {
|
|
31978
|
-
BOOK:
|
|
31979
|
-
|
|
31980
|
-
|
|
32299
|
+
BOOK: {
|
|
32300
|
+
path: "M4 2.4h5.4L12 5v8.6H4zM9.4 2.4V5H12M6.2 8h4M6.2 10.4h4",
|
|
32301
|
+
color: TREE_GREEN
|
|
32302
|
+
},
|
|
32303
|
+
UNFILED: {
|
|
32304
|
+
path: "M4.2 2.5h5.2L12 5v8.5H4.2zM9.4 2.5V5H12M6.3 8.1h4M6.3 10.4h2.7",
|
|
32305
|
+
color: TREE_ORANGE
|
|
32306
|
+
},
|
|
32307
|
+
TRASH: {
|
|
32308
|
+
path: "M3.2 4.5h9.6M6.3 4.5V3h3.4v1.5M4.6 4.5l0.6 9.2h5.6l0.6-9.2M6.8 7v4.4M9.2 7v4.4",
|
|
32309
|
+
color: TREE_RED
|
|
32310
|
+
}
|
|
31981
32311
|
};
|
|
31982
32312
|
function buildForest(collections) {
|
|
31983
32313
|
const nodes = /* @__PURE__ */ new Map();
|
|
@@ -32032,8 +32362,13 @@ const rowStyle = {
|
|
|
32032
32362
|
function rowIndent(depth) {
|
|
32033
32363
|
return { paddingLeft: BASE_INDENT + depth * INDENT };
|
|
32034
32364
|
}
|
|
32365
|
+
/** 选中行:浅蓝底 + 蓝色文字,与 Zotero 的灰底相比更贴合整套配色。 */
|
|
32035
32366
|
function rowBackground(selected) {
|
|
32036
|
-
return
|
|
32367
|
+
return selected ? {
|
|
32368
|
+
background: "rgba(74,134,232,0.15)",
|
|
32369
|
+
color: TREE_BLUE,
|
|
32370
|
+
fontWeight: 600
|
|
32371
|
+
} : { background: "transparent" };
|
|
32037
32372
|
}
|
|
32038
32373
|
const iconBox = {
|
|
32039
32374
|
width: 16,
|
|
@@ -32292,7 +32627,8 @@ function Magnifier() {
|
|
|
32292
32627
|
strokeLinecap: "round",
|
|
32293
32628
|
style: {
|
|
32294
32629
|
flexShrink: 0,
|
|
32295
|
-
|
|
32630
|
+
color: "#4a86e8",
|
|
32631
|
+
opacity: .85
|
|
32296
32632
|
},
|
|
32297
32633
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
|
|
32298
32634
|
cx: "7",
|
|
@@ -32345,8 +32681,8 @@ function SearchField({ value, placeholder, clearLabel, onChange }) {
|
|
|
32345
32681
|
boxSizing: "border-box",
|
|
32346
32682
|
padding: "0 7px",
|
|
32347
32683
|
borderRadius: 6,
|
|
32348
|
-
border: `1px solid ${focused ? "rgba(
|
|
32349
|
-
background: "rgba(
|
|
32684
|
+
border: `1px solid ${focused ? "rgba(74,134,232,0.75)" : "rgba(74,134,232,0.32)"}`,
|
|
32685
|
+
background: "rgba(74,134,232,0.05)",
|
|
32350
32686
|
cursor: "text",
|
|
32351
32687
|
color: "inherit"
|
|
32352
32688
|
},
|
|
@@ -32409,7 +32745,7 @@ const headerStyle = {
|
|
|
32409
32745
|
};
|
|
32410
32746
|
const titleRowStyle = {
|
|
32411
32747
|
display: "flex",
|
|
32412
|
-
alignItems: "
|
|
32748
|
+
alignItems: "center",
|
|
32413
32749
|
gap: 8,
|
|
32414
32750
|
minWidth: 0
|
|
32415
32751
|
};
|
|
@@ -32475,10 +32811,15 @@ const itemBodyStyle = {
|
|
|
32475
32811
|
flex: 1,
|
|
32476
32812
|
minWidth: 0
|
|
32477
32813
|
};
|
|
32814
|
+
/** 图标固定占位 24px,只居中图标本身,不铺底色。 */
|
|
32478
32815
|
const itemIconStyle = {
|
|
32479
32816
|
display: "flex",
|
|
32817
|
+
alignItems: "center",
|
|
32818
|
+
justifyContent: "center",
|
|
32480
32819
|
flexShrink: 0,
|
|
32481
|
-
|
|
32820
|
+
width: 24,
|
|
32821
|
+
height: 24,
|
|
32822
|
+
marginTop: 1
|
|
32482
32823
|
};
|
|
32483
32824
|
/** 头部引用按钮的紧凑尺寸。 */
|
|
32484
32825
|
const citeButtonStyle = {
|
|
@@ -32640,13 +32981,8 @@ function ItemList(props) {
|
|
|
32640
32981
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
32641
32982
|
style: titleRowStyle,
|
|
32642
32983
|
children: [
|
|
32643
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
32644
|
-
|
|
32645
|
-
fontSize: 13,
|
|
32646
|
-
overflow: "hidden",
|
|
32647
|
-
textOverflow: "ellipsis",
|
|
32648
|
-
whiteSpace: "nowrap"
|
|
32649
|
-
},
|
|
32984
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTitle, {
|
|
32985
|
+
title: name,
|
|
32650
32986
|
children: name
|
|
32651
32987
|
}),
|
|
32652
32988
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -32658,14 +32994,14 @@ function ItemList(props) {
|
|
|
32658
32994
|
children: tpl(t("list.count"), { n: itemsTotal })
|
|
32659
32995
|
}),
|
|
32660
32996
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
32661
|
-
chosen.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
32997
|
+
chosen.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
32662
32998
|
variant: "outline",
|
|
32663
32999
|
size: "sm",
|
|
32664
33000
|
title: t("action.insertSelected"),
|
|
32665
33001
|
style: citeButtonStyle,
|
|
32666
33002
|
onClick: () => onInsertItems(chosen),
|
|
32667
33003
|
children: tpl(t("action.citeCount"), { n: chosen.length })
|
|
32668
|
-
}) : isRealCollection && selectedCollection !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33004
|
+
}) : isRealCollection && selectedCollection !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
32669
33005
|
variant: "outline",
|
|
32670
33006
|
size: "sm",
|
|
32671
33007
|
title: t("action.insertCollection"),
|
|
@@ -32673,7 +33009,7 @@ function ItemList(props) {
|
|
|
32673
33009
|
onClick: () => onInsertCollection(selectedCollection),
|
|
32674
33010
|
children: t("action.insertItemShort")
|
|
32675
33011
|
}) : null,
|
|
32676
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33012
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
32677
33013
|
variant: "ghost",
|
|
32678
33014
|
size: "sm",
|
|
32679
33015
|
title: sortHint(t, sort),
|
|
@@ -32745,7 +33081,7 @@ function ItemList(props) {
|
|
|
32745
33081
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
32746
33082
|
style: { margin: "0 0 8px" },
|
|
32747
33083
|
children: tpl(t("list.loadFailed"), { message: itemsError })
|
|
32748
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33084
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
32749
33085
|
variant: "outline",
|
|
32750
33086
|
size: "sm",
|
|
32751
33087
|
onClick: onRetry,
|
|
@@ -32766,7 +33102,7 @@ function ItemList(props) {
|
|
|
32766
33102
|
onInsert: onInsertItem
|
|
32767
33103
|
}, item.key)), items.length < itemsTotal && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
32768
33104
|
style: { padding: "6px 4px" },
|
|
32769
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33105
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
32770
33106
|
variant: "ghost",
|
|
32771
33107
|
size: "sm",
|
|
32772
33108
|
disabled: itemsLoading,
|
|
@@ -32830,8 +33166,13 @@ const tagFlowStyle = {
|
|
|
32830
33166
|
};
|
|
32831
33167
|
/** 自动标签的淡化程度(Zotero 用斜体区分,这里斜体 + 略淡)。 */
|
|
32832
33168
|
const AUTOMATIC_OPACITY = .72;
|
|
33169
|
+
/**
|
|
33170
|
+
* 标签胶囊:未选中透明无底色(中性灰细描边),选中 Zotero 深灰底白字。
|
|
33171
|
+
* 自动标签的斜体 + 淡化保留,但选中态不被淡化盖过识别度。
|
|
33172
|
+
*/
|
|
32833
33173
|
function pillStyle(selected, automatic) {
|
|
32834
33174
|
return {
|
|
33175
|
+
...selected ? TAG_SELECTED_STYLE : TAG_IDLE_STYLE,
|
|
32835
33176
|
padding: "1px 7px",
|
|
32836
33177
|
fontSize: 11.5,
|
|
32837
33178
|
lineHeight: "17px",
|
|
@@ -32839,12 +33180,9 @@ function pillStyle(selected, automatic) {
|
|
|
32839
33180
|
overflow: "hidden",
|
|
32840
33181
|
textOverflow: "ellipsis",
|
|
32841
33182
|
whiteSpace: "nowrap",
|
|
32842
|
-
color: "inherit",
|
|
32843
|
-
background: selected ? "rgba(80,140,255,0.18)" : "transparent",
|
|
32844
|
-
border: `1px solid ${selected ? "rgba(80,140,255,0.55)" : "rgba(127,127,127,0.32)"}`,
|
|
32845
33183
|
borderRadius: 9,
|
|
32846
33184
|
cursor: "pointer",
|
|
32847
|
-
opacity: automatic ? AUTOMATIC_OPACITY : 1,
|
|
33185
|
+
opacity: automatic && !selected ? AUTOMATIC_OPACITY : 1,
|
|
32848
33186
|
fontStyle: automatic ? "italic" : "normal"
|
|
32849
33187
|
};
|
|
32850
33188
|
}
|
|
@@ -32855,12 +33193,32 @@ function TagPill({ t, tag, selected, scopeCount, scoped, onToggle }) {
|
|
|
32855
33193
|
hints.push(tpl(scoped ? t("tags.scopeCount") : t("tags.libraryCount"), { n: scoped ? scopeCount : tag.count }));
|
|
32856
33194
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
32857
33195
|
type: "button",
|
|
33196
|
+
className: tagButtonClass(selected),
|
|
32858
33197
|
onClick: onToggle,
|
|
32859
33198
|
title: hints.join("\n"),
|
|
32860
33199
|
style: pillStyle(selected, automatic),
|
|
32861
33200
|
children: tag.name
|
|
32862
33201
|
});
|
|
32863
33202
|
}
|
|
33203
|
+
/**
|
|
33204
|
+
* 折叠按钮里的实心三角:画布 10px = 20px 外框的 50%,路径再几乎撑满画布,
|
|
33205
|
+
* 比原来的字符 `▴/▾`(11px 字号下字形只有几像素)醒目得多。
|
|
33206
|
+
* 两个方向用完全镜像的 path,不用 CSS rotate(SVG 的 transform-origin 易出偏差)。
|
|
33207
|
+
*/
|
|
33208
|
+
function CollapseArrow({ collapsed }) {
|
|
33209
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
33210
|
+
width: 10,
|
|
33211
|
+
height: 10,
|
|
33212
|
+
viewBox: "0 0 16 16",
|
|
33213
|
+
fill: "currentColor",
|
|
33214
|
+
stroke: "currentColor",
|
|
33215
|
+
strokeWidth: 1.1,
|
|
33216
|
+
strokeLinejoin: "round",
|
|
33217
|
+
style: { flexShrink: 0 },
|
|
33218
|
+
"aria-hidden": true,
|
|
33219
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: collapsed ? "M8 13.6 L1 2.4 H15 Z" : "M8 2.4 L1 13.6 H15 Z" })
|
|
33220
|
+
});
|
|
33221
|
+
}
|
|
32864
33222
|
function TagPanel(props) {
|
|
32865
33223
|
const { t, tags, tagsLoading, tagsError, tagQuery, selectedTags, tagMode, scoped, tagUsage, tagUsageLoading, onTagQuery, onToggleTag, onClearTags, onSetTagMode, onRetry, onInsertTag, onInsertTagSet } = props;
|
|
32866
33224
|
const [height, setHeight] = (0, react.useState)(readHeight);
|
|
@@ -32946,7 +33304,7 @@ function TagPanel(props) {
|
|
|
32946
33304
|
flexShrink: 0
|
|
32947
33305
|
},
|
|
32948
33306
|
children: [
|
|
32949
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33307
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTitle, {
|
|
32950
33308
|
style: { fontSize: 12 },
|
|
32951
33309
|
children: t("tags.title")
|
|
32952
33310
|
}),
|
|
@@ -32960,23 +33318,23 @@ function TagPanel(props) {
|
|
|
32960
33318
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
32961
33319
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
32962
33320
|
type: "button",
|
|
33321
|
+
className: SOFT_BUTTON_CLASS,
|
|
32963
33322
|
onClick: toggleCollapsed,
|
|
32964
33323
|
"aria-expanded": !collapsed,
|
|
32965
33324
|
"aria-label": t(collapsed ? "tags.expand" : "tags.collapse"),
|
|
32966
33325
|
title: t(collapsed ? "tags.expand" : "tags.collapse"),
|
|
32967
33326
|
style: {
|
|
33327
|
+
...SOFT_BUTTON_STYLE,
|
|
33328
|
+
display: "inline-flex",
|
|
33329
|
+
alignItems: "center",
|
|
33330
|
+
justifyContent: "center",
|
|
32968
33331
|
width: 20,
|
|
32969
33332
|
height: 20,
|
|
32970
33333
|
padding: 0,
|
|
32971
|
-
fontSize: 11,
|
|
32972
|
-
lineHeight: 1,
|
|
32973
|
-
color: "#508cff",
|
|
32974
|
-
background: "transparent",
|
|
32975
|
-
border: "1px solid rgba(80,140,255,0.4)",
|
|
32976
33334
|
borderRadius: 5,
|
|
32977
33335
|
cursor: "pointer"
|
|
32978
33336
|
},
|
|
32979
|
-
children:
|
|
33337
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapseArrow, { collapsed })
|
|
32980
33338
|
})
|
|
32981
33339
|
]
|
|
32982
33340
|
}),
|
|
@@ -33011,6 +33369,7 @@ function TagPanel(props) {
|
|
|
33011
33369
|
}),
|
|
33012
33370
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
33013
33371
|
type: "button",
|
|
33372
|
+
className: softButtonClass(tagMode === "all"),
|
|
33014
33373
|
onClick: () => onSetTagMode("all"),
|
|
33015
33374
|
title: t("tags.matchAllHint"),
|
|
33016
33375
|
"aria-pressed": tagMode === "all",
|
|
@@ -33019,6 +33378,7 @@ function TagPanel(props) {
|
|
|
33019
33378
|
}),
|
|
33020
33379
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
33021
33380
|
type: "button",
|
|
33381
|
+
className: softButtonClass(tagMode === "any"),
|
|
33022
33382
|
onClick: () => onSetTagMode("any"),
|
|
33023
33383
|
title: t("tags.matchAnyHint"),
|
|
33024
33384
|
"aria-pressed": tagMode === "any",
|
|
@@ -33027,12 +33387,13 @@ function TagPanel(props) {
|
|
|
33027
33387
|
}),
|
|
33028
33388
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
33029
33389
|
type: "button",
|
|
33390
|
+
className: "dsh-zp-soft-btn",
|
|
33030
33391
|
onClick: onClearTags,
|
|
33031
33392
|
style: plainButtonStyle,
|
|
33032
33393
|
children: t("tags.clear")
|
|
33033
33394
|
}),
|
|
33034
33395
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
33035
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33396
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
33036
33397
|
variant: "outline",
|
|
33037
33398
|
size: "sm",
|
|
33038
33399
|
disabled: tooMany,
|
|
@@ -33064,7 +33425,7 @@ function TagPanel(props) {
|
|
|
33064
33425
|
color: "#d29922"
|
|
33065
33426
|
},
|
|
33066
33427
|
children: tpl(t("tags.loadFailed"), { message: tagsError })
|
|
33067
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33428
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
33068
33429
|
variant: "outline",
|
|
33069
33430
|
size: "sm",
|
|
33070
33431
|
onClick: onRetry,
|
|
@@ -33103,25 +33464,23 @@ function TagPanel(props) {
|
|
|
33103
33464
|
]
|
|
33104
33465
|
});
|
|
33105
33466
|
}
|
|
33467
|
+
/** 「全部 / 任一」互斥开关:与全站按钮同色,只把选中底色加深。 */
|
|
33106
33468
|
function modeButtonStyle(active) {
|
|
33107
33469
|
return {
|
|
33470
|
+
...active ? MODE_BUTTON_ACTIVE_STYLE : SOFT_BUTTON_STYLE,
|
|
33108
33471
|
padding: "0 5px",
|
|
33109
33472
|
fontSize: 11,
|
|
33110
33473
|
lineHeight: "16px",
|
|
33111
|
-
color: "inherit",
|
|
33112
|
-
background: active ? "rgba(80,140,255,0.18)" : "transparent",
|
|
33113
|
-
border: active ? "1px solid rgba(80,140,255,0.5)" : "1px solid rgba(127,127,127,0.3)",
|
|
33114
33474
|
borderRadius: 5,
|
|
33115
33475
|
cursor: "pointer"
|
|
33116
33476
|
};
|
|
33117
33477
|
}
|
|
33478
|
+
/** 「清除」是普通动作,没有选中态:与全站按钮同色。 */
|
|
33118
33479
|
const plainButtonStyle = {
|
|
33480
|
+
...SOFT_BUTTON_STYLE,
|
|
33119
33481
|
padding: "0 5px",
|
|
33120
33482
|
fontSize: 11,
|
|
33121
33483
|
lineHeight: "16px",
|
|
33122
|
-
color: "inherit",
|
|
33123
|
-
background: "transparent",
|
|
33124
|
-
border: "1px solid rgba(127,127,127,0.3)",
|
|
33125
33484
|
borderRadius: 5,
|
|
33126
33485
|
cursor: "pointer",
|
|
33127
33486
|
opacity: .8
|
|
@@ -33229,10 +33588,7 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
|
|
|
33229
33588
|
flexShrink: 0
|
|
33230
33589
|
},
|
|
33231
33590
|
children: [
|
|
33232
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
33233
|
-
style: { fontSize: 13 },
|
|
33234
|
-
children: libraryName === "" ? t("tab.title") : libraryName
|
|
33235
|
-
}),
|
|
33591
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SectionTitle, { children: libraryName === "" ? t("tab.title") : libraryName }),
|
|
33236
33592
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, {
|
|
33237
33593
|
ok: health?.zotero.running === true,
|
|
33238
33594
|
label: t(health?.zotero.running === true ? "status.zoteroOn" : "status.zoteroOff")
|
|
@@ -33242,7 +33598,7 @@ function ZoteroPane({ t, inputActions, sessions, sessionId, onOpenItem }) {
|
|
|
33242
33598
|
label: t(health?.mcp.running === true ? "status.mcpOn" : "status.mcpOff")
|
|
33243
33599
|
}),
|
|
33244
33600
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
33245
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
33601
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
33246
33602
|
variant: "ghost",
|
|
33247
33603
|
size: "sm",
|
|
33248
33604
|
onClick: () => void loadTree(true),
|
|
@@ -33427,6 +33783,7 @@ const inject = [
|
|
|
33427
33783
|
"sessions"
|
|
33428
33784
|
];
|
|
33429
33785
|
function apply(ctx) {
|
|
33786
|
+
installTheme();
|
|
33430
33787
|
ctx.effect(() => ctx.locale.register(NS, dicts), "dsh-plugin-zotero: dictionaries");
|
|
33431
33788
|
const t = ctx.locale.bind(NS);
|
|
33432
33789
|
ctx.effect(() => ctx.sidebarRightTabs.register({
|