dsh-cite 0.7.7 → 0.7.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.7.8 (2026-10-30)
4
+
5
+ - 引文工作台:「引文与下载」页新增导出前检查(可切换全部 / 仅所选范围,显示范围条数、引文格式、缺标题 / 作者 / 年份条目数与完整备份范围),下载按钮改为工作台按钮并在空库时给出说明;冲突提示改用工作台状态组件并只保留一条恢复路径,冲突期间「保存所选」禁用并说明原因;补全进度条补上标签和除零保护,键盘聚焦轮廓改用主题强调色。
6
+ - Pre-export checks with explicit scope, conflict recovery that cannot resubmit a stale revision, labelled progress and theme-based focus rings in the reference workbench.
7
+
8
+ - 同步共享 workbench-ui v1.1:Page 外的 Empty / Dialog / Status 自带样式与 `.dshw` 主题作用域,Status 新增 warn 色调。
9
+ - Sync workbench-ui v1.1: Empty / Dialog / Status now carry their own styles and `.dshw` theme scope outside Page, and Status gains a warn tone.
10
+
3
11
  ## 0.7.7 (2026-10-30)
4
12
 
5
13
  - 重整中英文首页:用途、三步流程图、安装入口与操作示例;详细配置与边界集中到完整说明。
package/docs/USAGE.md CHANGED
@@ -16,7 +16,9 @@ BibTeX 导入、导出保留 URL 与 DOI;数学比较符不作为任意 HTML
16
16
  2. 点击「本地预览」,核对缺失字段与重复提示,选择要保存的条目。精确 DOI 重复不能再次导入;无 DOI 的可能重复项默认不选,可人工确认后选择。
17
17
  3. 点击「保存所选」。输入在关闭设置后仍保留;刷新整个浏览器前应保存。上传不会改写原文件。
18
18
  4. 需要元数据时,选择库中条目,点击「从 Crossref 在线补全所选项」。只补空字段;已有内容不覆盖,差异显示在「元数据与来源」中。失败项可重新选择后重试,取消本次任务不会写入该任务的补全结果。
19
- 5. 切换基本引文格式,或在条目详情中预览单条引文。BibTeX / 参考文献文本下载范围为所选项,未选择时下载全库;完整备份始终包括全库及原始来源。
19
+ 5. 切换基本引文格式,或在条目详情中预览单条引文。「引文与下载」页先给出导出前检查:可切换「全部文献」或「仅所选」范围,并列出范围条数、引文格式、缺标题 / 作者 / 年份的条目数,以及「完整备份始终包含全库与原始输入」。确认无误后再下载 BibTeX、参考文献文本或完整备份。
20
+
21
+ 多窗口冲突不会被静默覆盖:提示会说明库已在别处更新、当前输入仍然保留,并提供「重新预览当前输入」这一条恢复路径;冲突期间「保存所选」保持禁用并给出原因。导出前检查里的范围、条数与缺失字段来自当前本地数据,切换范围会立即重新计算。
20
22
 
21
23
  界面跟随 DSH 的中文 / English 设置,不翻译或复制文献数据。导出沿用四种基本格式;不同文献类型、学校或期刊的细节要求需另行核对。
22
24
 
package/docs/WORKBENCH.md CHANGED
@@ -14,6 +14,16 @@ Update the plugin, restart DSH and open its native sidebar panel (or More if it
14
14
 
15
15
  The UI follows host language and theme without translating user content. Narrow master/detail views have a Back action; editors adapt their columns to available space. Destructive actions require confirmation and edits are protected.
16
16
 
17
+ ## 导出前检查与冲突 / Export checks and conflicts
18
+
19
+ 「引文与下载」页先显示导出前检查,再给下载链接:可切换「全部文献 / 仅所选」,列出当前范围的条数、引文格式、缺标题 / 作者 / 年份的条目数,并说明完整备份始终包含全库与原始输入。条数与缺失字段来自本地文献库,切换范围立即重算;空库时下载位置给出说明而不是无效按钮。
20
+
21
+ The downloads tab shows a pre-export check before the links: switch between the entire library and the current selection, read the entry count, citation style, counts of entries missing title/authors/year, and the note that full backup always covers the whole library with original sources. Counts come from the local library and recompute when the scope changes; an empty library explains itself instead of showing inert buttons.
22
+
23
+ 并发保存冲突以错误状态呈现,说明库已在别处更新、当前输入仍保留,并只提供「重新预览当前输入」一条恢复路径;冲突期间「保存所选」禁用并说明原因,不会重复提交同一个过期修订。
24
+
25
+ A concurrent-save conflict is shown as an error status that names what happened, keeps the input, and offers one recovery path (preview the current input again). Saving stays disabled with a stated reason, so the same stale revision cannot be resubmitted.
26
+
17
27
  ## 源码 / Source
18
28
 
19
29
  编辑 templates/client.js、templates/panels/*.js 与 templates/workbench-ui.js,运行 pnpm run build。lib/client.js 是确定性产物,请随源码提交。公共组件的规范源位于 dsh-suite/ui/workbench-ui.js,Suite 的同步脚本显式分发副本;单个仓库可独立构建和安装。
package/lib/client.js CHANGED
@@ -494,7 +494,7 @@ function createWorkbenchUI(React) {
494
494
  }
495
495
  function Page({ title, subtitle, actions, children, workbench = false, className, rootRef, ...props }) {
496
496
  return h('section', { ...props, ref: rootRef, className: cx('dshw', 'w-page', className), 'data-main': workbench ? 'true' : 'false' },
497
- h('style', null, styles),
497
+ h(Styles, { key: 'styles' }),
498
498
  h('header', { className: 'w-page-header' }, h('div', { className: 'w-heading' }, h('h1', null, title), subtitle ? h('p', { className: 'w-subtitle' }, subtitle) : null), actions ? h('div', { className: 'w-header-actions' }, actions) : null),
499
499
  h('div', { className: 'w-body' }, children));
500
500
  }
@@ -517,10 +517,10 @@ function createWorkbenchUI(React) {
517
517
  }
518
518
  function Status({ children, tone = 'info', className }) {
519
519
  if (!children) return null;
520
- return h('div', { className: cx('w-status', 'w-status-' + tone, className), role: tone === 'error' ? 'alert' : 'status', 'aria-live': tone === 'error' ? 'assertive' : 'polite' }, h(Icon, { name: tone === 'success' ? 'check' : 'info', size: 18 }), h('div', null, children));
520
+ return h('div', { className: cx('dshw', 'w-status', 'w-status-' + tone, className), role: tone === 'error' ? 'alert' : 'status', 'aria-live': tone === 'error' ? 'assertive' : 'polite' }, h(Icon, { name: tone === 'success' ? 'check' : 'info', size: 18 }), h('div', null, children));
521
521
  }
522
522
  function Empty({ title, children, action, icon = 'file' }) {
523
- return h('div', { className: 'w-empty' }, h(Icon, { name: icon, size: 32 }), h('h2', null, title), children ? h('div', { className: 'w-muted' }, children) : null, action ? h('div', { className: 'w-toolbar' }, action) : null);
523
+ return h('div', { className: 'dshw w-empty' }, h(Styles, { key: 'styles' }), h(Icon, { name: icon, size: 32 }), h('h2', null, title), children ? h('div', { className: 'w-muted' }, children) : null, action ? h('div', { className: 'w-toolbar' }, action) : null);
524
524
  }
525
525
  function Split({ list, detail, selected, onBack, backLabel, className, listWidth = 360 }) {
526
526
  const ref = useRef(null);
@@ -564,7 +564,8 @@ function createWorkbenchUI(React) {
564
564
  else if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
565
565
  else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
566
566
  }
567
- return h('div', { className: 'w-overlay', onClick: event => { if (!busy && event.target === event.currentTarget) onClose(); } },
567
+ return h('div', { className: 'dshw w-overlay', onClick: event => { if (!busy && event.target === event.currentTarget) onClose(); } },
568
+ h(Styles, { key: 'styles' }),
568
569
  h('section', { ref: panel, className: cx('w-dialog', className), role: 'dialog', 'aria-modal': true, 'aria-labelledby': id, tabIndex: -1, onKeyDown: keydown },
569
570
  h('header', { className: 'w-dialog-header' }, h('h2', { id }, title), h(IconButton, { icon: 'close', label: closeLabel, disabled: busy, onClick: onClose })), h('div', { className: 'w-dialog-body' }, children)));
570
571
  }
@@ -578,7 +579,7 @@ function createWorkbenchUI(React) {
578
579
  .dshw{--w-bg:var(--dsw-alias-bg-layer-1,#fff);--w-soft:var(--dsw-alias-bg-layer-2,#f7f8fa);--w-text:var(--dsw-alias-label-primary,#18202c);--w-muted:var(--dsw-alias-label-secondary,#667085);--w-border:var(--dsw-alias-border-l3,#e7e9ef);--w-accent:var(--dsh-plugin-workbench-accent,#4f6bdb);--w-selected:color-mix(in srgb,var(--w-accent) 10%,var(--w-bg));--w-primary:var(--w-text);--w-on-primary:var(--w-bg);container-type:inline-size;container-name:dsh-workbench;color:var(--w-text);background:var(--w-bg);font:14px/1.65 var(--dsh-font-family-content,system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif);min-width:0;max-width:100%;box-sizing:border-box;text-align:start;color-scheme:inherit}
579
580
  .dshw *,.dshw *:before,.dshw *:after{box-sizing:border-box}.dshw h1,.dshw h2,.dshw h3,.dshw h4,.dshw p{margin:0}.dshw h1{font-size:30px;line-height:1.25;letter-spacing:-.025em;font-weight:650}.dshw h2{font-size:24px;line-height:1.35;font-weight:650;letter-spacing:-.015em;overflow-wrap:anywhere}.dshw h3,.dshw h4{font-size:16px;line-height:1.4;font-weight:600}.dshw a{color:var(--w-accent);text-underline-offset:3px;overflow-wrap:anywhere}.dshw button,.dshw input,.dshw select,.dshw textarea{font:inherit;color:inherit;max-width:100%}.dshw input:not([type=checkbox]):not([type=radio]):not([type=file]),.dshw select,.dshw textarea{background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 11px;min-width:0;line-height:1.5}.dshw input:not([type=checkbox]):not([type=radio]):not([type=file]),.dshw select{min-height:38px}.dshw textarea{resize:vertical}.dshw input[type=checkbox],.dshw input[type=radio]{width:16px;height:16px;flex-shrink:0;accent-color:var(--w-accent)}.dshw :focus-visible{outline:2px solid var(--w-accent);outline-offset:3px}.dshw button:disabled,.dshw input:disabled,.dshw select:disabled,.dshw textarea:disabled{opacity:.5;cursor:not-allowed}.dshw label{font-size:13px}.dshw fieldset{min-width:0;border:1px solid var(--w-border);border-radius:8px}.dshw summary{cursor:pointer;font-weight:550;list-style:none;display:flex;align-items:center;gap:8px}.dshw summary::-webkit-details-marker{display:none}.dshw summary:after{content:'';display:block;margin-inline-start:auto;width:7px;height:7px;border-inline-end:1.75px solid currentColor;border-bottom:1.75px solid currentColor;transform:rotate(45deg);flex-shrink:0}.dshw details[open]>summary:after{transform:rotate(225deg)}.dshw details>summary+*{margin-top:12px}.dshw pre{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.7 ui-monospace,SFMono-Regular,Consolas,monospace;max-width:100%;background:var(--w-soft);border-radius:6px;padding:14px}.dshw img,.dshw video,.dshw iframe{max-width:100%}
580
581
  .w-page{display:flex;flex-direction:column;position:relative;padding:0;min-height:540px;gap:0}.w-page[data-main=true]{height:100%;min-height:0;padding:calc(24px + var(--dsh-frame-top-clearance,0px)) 28px 0 max(28px,var(--dsh-frame-leading-clearance,0px));overflow:auto}.w-page-header{display:flex;justify-content:space-between;gap:24px;align-items:flex-start;padding-bottom:22px;flex-shrink:0}.w-heading{min-width:0}.w-subtitle{margin-top:8px!important;font-size:14px;color:var(--w-muted);line-height:1.6}.w-header-actions,.w-toolbar,.w-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0}.w-header-actions{justify-content:flex-end}.w-body,.w-tabs-layout{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}.w-body{overflow:auto}.w-tab-panel{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:auto}.w-tabs{display:flex;align-items:stretch;gap:20px;border-bottom:1px solid var(--w-border);flex-shrink:0;overflow-x:auto;scrollbar-width:thin}.dshw .w-tabs>button{border:0;border-bottom:2px solid transparent;background:transparent;padding:11px 8px 13px;white-space:nowrap;font-size:14px;font-weight:550;cursor:pointer;color:var(--w-muted);display:flex;align-items:center;gap:7px}.dshw .w-tabs>button[aria-selected=true]{border-bottom-color:var(--w-accent);color:var(--w-accent)}.w-count,.w-tag{font-size:12px;line-height:1.5;display:inline-flex;align-items:center;flex-shrink:0;background:var(--w-soft);border-radius:5px;padding:1px 6px;color:var(--w-muted)}.w-tabs [aria-selected=true] .w-count,.w-selected .w-tag{color:var(--w-accent);background:var(--w-selected)}
581
- .dshw .w-button{display:inline-flex;justify-content:center;align-items:center;gap:7px;background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 12px;min-height:36px;line-height:1.4;font-size:14px;font-weight:500;cursor:pointer;text-decoration:none;white-space:normal}.dshw .w-button:not(:disabled):hover{background:var(--w-soft)}.dshw .w-primary{background:var(--w-primary);border-color:var(--w-primary);color:var(--w-on-primary)}.dshw .w-primary:not(:disabled):hover{background:var(--w-primary);opacity:.9}.dshw .w-ghost{background:transparent;border-color:transparent}.dshw .w-danger{color:var(--dsw-alias-state-error-primary,#b43c3c)}.dshw .w-icon-button{width:36px;min-width:36px;padding:8px}.dshw .w-button svg{flex-shrink:0}.w-muted{color:var(--w-muted);font-size:12px;line-height:1.6}.w-section{padding:24px 0;border-bottom:1px solid var(--w-border);min-width:0}.w-section>h3{margin-bottom:12px}.w-section>p+p{margin-top:8px}.w-fields{display:grid;gap:16px;min-width:0}.w-field{display:grid;gap:6px;min-width:0}.w-field>input,.w-field>select,.w-field>textarea{width:100%}.w-status{display:flex;align-items:flex-start;gap:8px;padding:11px 13px;margin:12px 0;border:1px solid var(--w-border);border-radius:8px;background:var(--w-soft);font-size:13px;overflow-wrap:anywhere;flex-shrink:0}.w-status>svg{flex-shrink:0;margin-top:2px}.w-status-error{color:var(--dsw-alias-state-error-primary,#ad3636)}.w-status-success{color:var(--dsw-alias-state-success-primary,#24794a)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px;max-width:580px;padding:48px 24px;margin:auto;min-height:280px;overflow-wrap:anywhere}.w-empty>svg{color:var(--w-muted)}.w-empty h2{font-size:20px}.w-empty .w-muted{font-size:14px}.w-empty .w-toolbar{justify-content:center}
582
+ .dshw .w-button{display:inline-flex;justify-content:center;align-items:center;gap:7px;background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 12px;min-height:36px;line-height:1.4;font-size:14px;font-weight:500;cursor:pointer;text-decoration:none;white-space:normal}.dshw .w-button:not(:disabled):hover{background:var(--w-soft)}.dshw .w-primary{background:var(--w-primary);border-color:var(--w-primary);color:var(--w-on-primary)}.dshw .w-primary:not(:disabled):hover{background:var(--w-primary);opacity:.9}.dshw .w-ghost{background:transparent;border-color:transparent}.dshw .w-danger{color:var(--dsw-alias-state-error-primary,#b43c3c)}.dshw .w-icon-button{width:36px;min-width:36px;padding:8px}.dshw .w-button svg{flex-shrink:0}.w-muted{color:var(--w-muted);font-size:12px;line-height:1.6}.w-section{padding:24px 0;border-bottom:1px solid var(--w-border);min-width:0}.w-section>h3{margin-bottom:12px}.w-section>p+p{margin-top:8px}.w-fields{display:grid;gap:16px;min-width:0}.w-field{display:grid;gap:6px;min-width:0}.w-field>input,.w-field>select,.w-field>textarea{width:100%}.w-status{display:flex;align-items:flex-start;gap:8px;padding:11px 13px;margin:12px 0;border:1px solid var(--w-border);border-radius:8px;background:var(--w-soft);font-size:13px;overflow-wrap:anywhere;flex-shrink:0}.w-status>svg{flex-shrink:0;margin-top:2px}.w-status-error{color:var(--dsw-alias-state-error-primary,#ad3636)}.w-status-success{color:var(--dsw-alias-state-success-primary,#24794a)}.w-status-warn{color:var(--dsw-alias-state-warning-primary,#8a5a00)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px;max-width:580px;padding:48px 24px;margin:auto;min-height:280px;overflow-wrap:anywhere}.w-empty>svg{color:var(--w-muted)}.w-empty h2{font-size:20px}.w-empty .w-muted{font-size:14px}.w-empty .w-toolbar{justify-content:center}
582
583
  .w-split{display:grid;grid-template-columns:minmax(240px,var(--w-list-width)) minmax(0,1fr);min-height:460px;flex:1;min-width:0}.w-master{min-width:0;border-inline-end:1px solid var(--w-border);overflow:auto;padding-bottom:24px}.w-detail{min-width:0;padding:26px 28px;overflow:auto;overflow-wrap:anywhere;display:flex;flex-direction:column}.w-master-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:20px 16px}.w-search{display:flex;align-items:center;gap:8px;border:1px solid var(--w-border);border-radius:8px;padding:0 10px;min-width:0;flex:1;background:var(--w-bg)}.w-search>svg{color:var(--w-muted);flex-shrink:0}.dshw .w-search>input{border:0!important;background:transparent!important;padding:8px 0!important;width:100%;outline-offset:0}.w-row{display:flex;gap:0;min-width:0;position:relative;border-bottom:1px solid var(--w-border);border-inline-start:3px solid transparent}.w-row-select{display:flex;align-items:flex-start;padding:21px 0 0 14px}.dshw .w-row-button{display:flex;flex-direction:column;align-items:stretch;gap:7px;text-align:start;width:100%;padding:18px 18px 18px 16px;border:0;background:transparent;color:inherit;min-width:0;cursor:pointer;line-height:1.5}.dshw .w-row-button:hover{background:var(--w-soft)}.w-row-head{display:flex;align-items:flex-start;gap:10px;justify-content:space-between;min-width:0}.w-row-head>strong{font-size:14px;line-height:1.5;font-weight:600;overflow-wrap:anywhere}.w-row-meta,.w-row-description{color:var(--w-muted);font-size:12px;line-height:1.6;overflow-wrap:anywhere}.w-row-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.w-selected{background:var(--w-selected);border-inline-start-color:var(--w-accent)}.w-back{display:none!important}.w-detail-title{margin-bottom:12px!important}.w-detail-meta{color:var(--w-muted);font-size:13px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.w-detail-footer{padding:24px 0;display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:auto;border-top:1px solid var(--w-border)}.w-detail-footer .w-muted{flex:1;min-width:160px}.w-definition{display:grid;grid-template-columns:minmax(80px,120px) minmax(0,1fr);gap:8px 16px;font-size:14px;margin:20px 0}.w-definition dt{color:var(--w-muted)}.w-definition dd{margin:0;min-width:0;overflow-wrap:anywhere}
583
584
  .w-switch-label{display:inline-flex;align-items:center;gap:8px;font-size:13px;position:relative;cursor:pointer}.w-switch-label>input{position:absolute;opacity:0;inset-inline-end:0;width:36px!important;height:22px!important;margin:0;cursor:pointer}.w-switch-track{width:36px;height:22px;border-radius:12px;display:block;background:var(--w-border);border:1px solid var(--w-border);pointer-events:none;padding:2px;transition:background .15s}.w-switch-track:before{content:'';display:block;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #0002;transition:transform .15s}.w-switch-label>input:checked+.w-switch-track{background:var(--w-accent);border-color:var(--w-accent)}.w-switch-label>input:checked+.w-switch-track:before{transform:translateX(14px)}.w-switch-label>input:focus-visible+.w-switch-track{outline:2px solid var(--w-accent);outline-offset:3px}.w-switch-label:has(>input:disabled){opacity:.5;cursor:not-allowed}
584
585
  .w-overlay{position:fixed;inset:0;background:#0005;display:flex;justify-content:flex-end;z-index:1000;padding:12px;overflow:auto}.w-dialog{width:min(620px,100%);max-height:100%;display:flex;flex-direction:column;min-height:0;background:var(--w-bg);color:var(--w-text);border:1px solid var(--w-border);border-radius:12px;box-shadow:0 18px 70px #0003}.w-dialog-header{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:20px 24px;border-bottom:1px solid var(--w-border);flex-shrink:0}.w-dialog-header>h2{font-size:20px}.w-dialog-body{overflow:auto;padding:20px 24px;min-height:0}.w-editor-grid{display:grid;grid-template-columns:210px minmax(0,1fr) 300px;min-height:500px;flex:1}.w-editor-list{padding:20px 12px;border-inline-end:1px solid var(--w-border);min-width:0}.w-editor-canvas{background:var(--w-soft);padding:20px;min-width:0;display:flex;flex-direction:column;gap:14px}.w-editor-inspector{padding:24px;border-inline-start:1px solid var(--w-border);min-width:0;overflow:auto}.w-editor-inspector h3{margin-bottom:18px}.w-preview-empty{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:12px;aspect-ratio:16/9;min-height:180px;background:var(--w-soft);border:1px solid var(--w-border);border-radius:8px;padding:24px;color:var(--w-muted)}.w-content-pad{padding:24px 0}.w-stack{display:flex;flex-direction:column;gap:16px;min-width:0}.w-scroll-x{overflow:auto;max-width:100%}
@@ -587,7 +588,8 @@ function createWorkbenchUI(React) {
587
588
  @media(max-width:700px){.w-page[data-main=true]{padding:calc(16px + var(--dsh-frame-top-clearance,0px)) 16px 0 max(16px,var(--dsh-frame-leading-clearance,0px))}.w-overlay{padding:8px}.w-dialog{width:100%}}
588
589
  @media(prefers-reduced-motion:reduce){.dshw *,.dshw *:before{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
589
590
  `;
590
- return { Icon, Button, IconButton, Page, Tabs, Status, Empty, Split, Row, Search, Switch, Dialog, register, styles };
591
+ function Styles() { return h('style', null, styles); }
592
+ return { Icon, Button, IconButton, Page, Tabs, Status, Empty, Split, Row, Search, Switch, Dialog, Styles, register, styles };
591
593
  }
592
594
 
593
595
  // Editable browser entry. Build with node scripts/build-client.mjs.
@@ -631,12 +633,13 @@ function CiteLibrary({ library, filtered, visible, selected, setSelected, search
631
633
 
632
634
  const CITE_WORKBENCH_CSS = `
633
635
  .cite-workbench.dcw{--fg:var(--w-text);--fg-muted:var(--w-muted);--border:var(--w-border);--bg:var(--w-bg);--bg-surface:var(--w-bg);--bg-muted:var(--w-soft);padding:0}.cite-workbench.dcw[data-main=true]{padding:calc(24px + var(--dsh-frame-top-clearance,0px)) 28px 0 max(28px,var(--dsh-frame-leading-clearance,0px))}.cite-workbench .cite-selection{padding:0 16px 16px}.cite-workbench .cite-selection .w-button{font-size:12px;min-height:30px;padding:5px 6px}.cite-workbench .cite-selected-actions{padding:18px 16px;border-top:1px solid var(--w-border)}.cite-workbench .cite-selected-actions p{margin-top:10px}.cite-workbench .cite-detail h2{font-size:24px;line-height:1.35}.cite-workbench .cite-detail .w-definition{grid-template-columns:100px minmax(0,1fr);margin:24px 0}.cite-workbench .cite-detail dt{color:var(--w-muted);font-weight:400}.cite-workbench .cite-detail .w-section h3{margin-bottom:14px}.cite-workbench .cite-style{display:flex;align-items:center;gap:14px;margin:14px 0;flex-wrap:wrap}.cite-workbench .cite-style select{width:auto;min-width:180px}.cite-workbench .cite-detail pre{background:var(--w-soft);font:13px/1.7 ui-monospace,Consolas,monospace;border-radius:8px;padding:16px;max-height:none}.cite-workbench .cite-detail .w-section>.w-muted{margin-top:12px}.cite-workbench .cite-warnings{font-size:12px;color:var(--dsw-alias-state-warn-primary,#946400)}.cite-workbench .cite-footer-note{margin:24px 0}.cite-workbench .cite-form-view{max-width:800px;width:100%;padding:24px 0}.cite-workbench .card{border:0;border-bottom:1px solid var(--w-border);border-radius:0;padding:20px 0;margin:0;background:transparent}.cite-workbench.dcw button.primary{background:var(--w-primary);color:var(--w-on-primary);border-color:var(--w-primary)}.cite-workbench .notice{background:var(--w-soft);color:var(--w-text);border:1px solid var(--w-border)}.cite-workbench .notice.error{color:var(--dsw-alias-state-error-primary,#ad3636)}.cite-workbench input[type=checkbox]{accent-color:var(--w-accent);width:16px;height:16px}.cite-workbench :focus-visible{outline:2px solid var(--w-accent);outline-offset:3px}.cite-workbench .cite-more{margin:16px}.cite-workbench .cite-form-view .bar button,.cite-workbench .cite-form-view .button{font-size:14px;min-height:36px}.cite-workbench .cite-form-view h3{font-size:18px}.cite-workbench .cite-detail .bar{gap:8px}.cite-workbench.dcw .w-row-button{border:0;border-radius:0;padding:18px 16px;background:transparent}.cite-workbench .cite-detail .w-status{display:block}
636
+ .cite-workbench .cite-scope{border:0;padding:0;margin:18px 0;display:grid;gap:8px}.cite-workbench .cite-scope legend{font-weight:600;padding:0;margin-bottom:6px}.cite-workbench .cite-scope label{display:flex;align-items:center;gap:8px;margin:0}.cite-workbench .cite-checks{list-style:none;padding:0;margin:12px 0;display:grid;gap:6px;font-size:13px;overflow-wrap:anywhere}.cite-workbench progress{accent-color:var(--w-accent)}
634
637
  @container dsh-workbench (max-width:760px){.cite-workbench .cite-selection{padding-inline:0}.cite-workbench .cite-selected-actions{padding-inline:0}.cite-workbench .cite-detail .w-definition{grid-template-columns:80px minmax(0,1fr)}}
635
638
  @media(max-width:700px){.cite-workbench.dcw[data-main=true]{padding:calc(16px + var(--dsh-frame-top-clearance,0px)) 16px 0 max(16px,var(--dsh-frame-leading-clearance,0px))}}
636
639
  `;
637
640
 
638
641
  let activeLang = 'zh', cache = { kind: 'doi', text: '', label: '', preview: null, chosen: [], selected: [], style: 'gb-t-7714', dirty: false, job: null };
639
- const css = `.dcw{font:14px/1.65 system-ui,sans-serif;color:var(--fg,#203b42);min-width:0;padding:8px}.dcw *{box-sizing:border-box}.dcw h2{font-size:23px;margin:0}.dcw h3{font-size:17px;margin:0 0 10px}.dcw p{margin:8px 0}.dcw .muted{color:var(--fg-muted,#677881);font-size:13px}.dcw .bar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:12px 0}.dcw button,.dcw .button{font:inherit;color:inherit;border:1px solid var(--border,#c5d5d4);border-radius:8px;padding:8px 12px;background:var(--bg-surface,#fff);text-decoration:none;cursor:pointer;white-space:normal}.dcw button.primary{background:#27695b;border-color:#27695b;color:white}.dcw button:disabled{opacity:.45;cursor:default}.dcw label{display:block;margin:10px 0 4px}.dcw input:not([type=checkbox]),.dcw textarea,.dcw select{font:inherit;color:inherit;width:100%;border:1px solid var(--border,#bfd1d0);border-radius:8px;background:var(--bg,#fff);padding:9px}.dcw input[type=checkbox]{accent-color:#27695b;width:18px;height:18px;flex-shrink:0}.dcw textarea{resize:vertical;min-height:140px}.dcw .grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.dcw .card{border:1px solid var(--border,#c5d5d4);border-radius:12px;padding:14px;margin:12px 0;min-width:0;background:var(--bg-surface,#fff)}.dcw .notice{border-radius:8px;padding:10px;background:#eef5ed;color:#2a604a;overflow-wrap:anywhere}.dcw .error{background:#fff0ea;color:#943b27}.dcw .entry{padding:12px 0;border-top:1px solid var(--border,#d3dedd);overflow-wrap:anywhere}.dcw .entry:first-child{border-top:0}.dcw .choose{display:flex;align-items:flex-start;gap:10px;margin:0;cursor:pointer}.dcw .choose input{margin-top:4px}.dcw .choose>span{min-width:0}.dcw .tag{display:inline-block;margin:4px 5px 0 0;padding:2px 6px;border-radius:5px;font-size:12px;background:var(--bg-muted,#edf2f1)}.dcw .warn{color:#a65318}.dcw pre{font:13px/1.6 system-ui,sans-serif;white-space:pre-wrap;overflow-wrap:anywhere;max-height:220px;overflow:auto;margin:8px 0}.dcw details{margin-top:10px}.dcw summary{cursor:pointer}.dcw dl{display:grid;grid-template-columns:auto 1fr;gap:5px 14px}.dcw dt{font-weight:600}.dcw dd{margin:0;overflow-wrap:anywhere}.dcw progress{width:100%;height:12px}.dcw :focus-visible{outline:3px solid #79cdb4;outline-offset:2px}[role=dialog]:has(.dcw){width:min(1200px,calc(100vw - 40px))!important;max-width:1200px!important}@media(max-width:800px){.dcw{padding:3px}.dcw .grid{grid-template-columns:1fr}[role=dialog]:has(.dcw){width:100%!important;max-width:100%!important;flex-direction:column!important}[role=dialog]:has(.dcw)>nav+div{min-width:0;width:100%}[role=dialog]:has(.dcw)>nav+div>div:has(.dcw){padding:12px!important;min-width:0}[role=dialog]:has(.dcw) nav{width:100%!important;flex-basis:auto!important;border-right:0;max-height:170px;overflow:auto}[role=dialog]:has(.dcw) nav>div:has(>button){display:flex;flex-direction:row!important;flex-wrap:wrap;gap:4px}}`;
642
+ const css = `.dcw{font:14px/1.65 system-ui,sans-serif;color:var(--fg,#203b42);min-width:0;padding:8px}.dcw *{box-sizing:border-box}.dcw h2{font-size:23px;margin:0}.dcw h3{font-size:17px;margin:0 0 10px}.dcw p{margin:8px 0}.dcw .muted{color:var(--fg-muted,#677881);font-size:13px}.dcw .bar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:12px 0}.dcw button,.dcw .button{font:inherit;color:inherit;border:1px solid var(--border,#c5d5d4);border-radius:8px;padding:8px 12px;background:var(--bg-surface,#fff);text-decoration:none;cursor:pointer;white-space:normal}.dcw button.primary{background:#27695b;border-color:#27695b;color:white}.dcw button:disabled{opacity:.45;cursor:default}.dcw label{display:block;margin:10px 0 4px}.dcw input:not([type=checkbox]),.dcw textarea,.dcw select{font:inherit;color:inherit;width:100%;border:1px solid var(--border,#bfd1d0);border-radius:8px;background:var(--bg,#fff);padding:9px}.dcw input[type=checkbox]{accent-color:#27695b;width:18px;height:18px;flex-shrink:0}.dcw textarea{resize:vertical;min-height:140px}.dcw .grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.dcw .card{border:1px solid var(--border,#c5d5d4);border-radius:12px;padding:14px;margin:12px 0;min-width:0;background:var(--bg-surface,#fff)}.dcw .notice{border-radius:8px;padding:10px;background:#eef5ed;color:#2a604a;overflow-wrap:anywhere}.dcw .error{background:#fff0ea;color:#943b27}.dcw .entry{padding:12px 0;border-top:1px solid var(--border,#d3dedd);overflow-wrap:anywhere}.dcw .entry:first-child{border-top:0}.dcw .choose{display:flex;align-items:flex-start;gap:10px;margin:0;cursor:pointer}.dcw .choose input{margin-top:4px}.dcw .choose>span{min-width:0}.dcw .tag{display:inline-block;margin:4px 5px 0 0;padding:2px 6px;border-radius:5px;font-size:12px;background:var(--bg-muted,#edf2f1)}.dcw .warn{color:#a65318}.dcw pre{font:13px/1.6 system-ui,sans-serif;white-space:pre-wrap;overflow-wrap:anywhere;max-height:220px;overflow:auto;margin:8px 0}.dcw details{margin-top:10px}.dcw summary{cursor:pointer}.dcw dl{display:grid;grid-template-columns:auto 1fr;gap:5px 14px}.dcw dt{font-weight:600}.dcw dd{margin:0;overflow-wrap:anywhere}.dcw progress{width:100%;height:12px}[role=dialog]:has(.dcw){width:min(1200px,calc(100vw - 40px))!important;max-width:1200px!important}@media(max-width:800px){.dcw{padding:3px}.dcw .grid{grid-template-columns:1fr}[role=dialog]:has(.dcw){width:100%!important;max-width:100%!important;flex-direction:column!important}[role=dialog]:has(.dcw)>nav+div{min-width:0;width:100%}[role=dialog]:has(.dcw)>nav+div>div:has(.dcw){padding:12px!important;min-width:0}[role=dialog]:has(.dcw) nav{width:100%!important;flex-basis:auto!important;border-right:0;max-height:170px;overflow:auto}[role=dialog]:has(.dcw) nav>div:has(>button){display:flex;flex-direction:row!important;flex-wrap:wrap;gap:4px}}`;
640
643
  async function api(body) {
641
644
  const r = await fetch(new URL(route, document.baseURI), { method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json', 'x-dsh-cite': '1' }, body: JSON.stringify(body) });
642
645
  let data;
@@ -663,7 +666,7 @@ const CITE_WORKBENCH_CSS = `
663
666
  const [activeTab,setActiveTab]=useState('library'),[citationError,setCitationError]=useState(''); const controlId=React.useId();
664
667
  const [lang, setLang] = useState('zh'), [kind, setKind] = useState(cache.kind), [text, setText] = useState(cache.text), [label, setLabel] = useState(cache.label);
665
668
  const [preview, setPreview] = useState(cache.preview), [chosen, setChosen] = useState(cache.chosen), [selected, setSelected] = useState(cache.selected), [style, setStyle] = useState(cache.style), [dirty, setDirty] = useState(cache.dirty);
666
- const [library, setLibrary] = useState({ revision: 0, entries: [], sources: [] }), [job, setJob] = useState(cache.job), [busy, setBusy] = useState(false), [error, setError] = useState(''), [notice, setNotice] = useState(''), [conflict, setConflict] = useState(false), [search, setSearch] = useState(''), [limit, setLimit] = useState(50), [activeId, setActiveId] = useState(''), [citation, setCitation] = useState('');
669
+ const [library, setLibrary] = useState({ revision: 0, entries: [], sources: [] }), [job, setJob] = useState(cache.job), [busy, setBusy] = useState(false), [error, setError] = useState(''), [notice, setNotice] = useState(''), [conflict, setConflict] = useState(false), [search, setSearch] = useState(''), [limit, setLimit] = useState(50), [activeId, setActiveId] = useState(''), [citation, setCitation] = useState(''), [exportScope, setExportScope] = useState(selected.length ? 'selected' : 'all');
667
670
  const busyRef = useRef(false), fileRef = useRef(null), dirtyRef = useRef(dirty);
668
671
  dirtyRef.current = dirty;
669
672
  const t = (zh, en) => lang === 'en' ? en : zh, running = job?.state === 'running', locked = busy || running;
@@ -735,14 +738,33 @@ const referenceId=activeId && referenceEntries.some(entry=>entry.id===activeId)?
735
738
  throw new Error(t('请选择 .bib 文件。', 'Choose a .bib file.')); if (file.size > 256 * 1024)
736
739
  throw new Error(t('文件超过 256 KiB,请拆分导入。', 'File exceeds 256 KiB. Split it before importing.')); const content = await file.text(); setKind('bibtex'); setText(content); setLabel(file.name); setPreview(null); setChosen([]); setDirty(true); setConflict(false); setNotice(t('文件已读取,点击“本地预览”检查后再保存。', 'File loaded. Choose Local preview before saving.')); }); fileRef.current.value = ''; }
737
740
  function toggle(values, value, set) { set(values.includes(value) ? values.filter(v => v !== value) : [...values, value]); }
738
- const filtered = library.entries.filter(e => [e.work.title, authors(e.work), e.work.doi, e.work.year].join(' ').toLowerCase().includes(search.toLowerCase())), visible = filtered.slice(0, limit), selectedIds = selected.length ? selected : undefined;
739
- const downloadLink = (format, zh, en) => library.entries.length ? h('a', { className: 'button', href: download(format, style, lang, format === 'backup' ? undefined : selectedIds), download: '' }, t(zh, en)) : h('button', { disabled: true }, t(zh, en));
741
+ const filtered = library.entries.filter(e => [e.work.title, authors(e.work), e.work.doi, e.work.year].join(' ').toLowerCase().includes(search.toLowerCase())), visible = filtered.slice(0, limit);
742
+ // Export scope is explicit: the checks below describe exactly what the download links will contain.
743
+ const scopeEntries = exportScope === 'selected' ? library.entries.filter(entry => selected.includes(entry.id)) : library.entries;
744
+ const scopeMissing = { title: scopeEntries.filter(entry => !entry.work.title).length, authors: scopeEntries.filter(entry => !authors(entry.work)).length, year: scopeEntries.filter(entry => !entry.work.year).length };
745
+ const downloadLink = (format, zh, en) => scopeEntries.length ? h('a', { className: 'w-button', href: download(format, style, lang, format === 'backup' || exportScope === 'all' ? undefined : selected), download: '' }, t(zh, en)) : h('span', { className: 'w-muted' }, t('当前范围没有可下载的文献。', 'Nothing to download in this scope.'));
740
746
  return __stardustUpdatesInlinePage(React,h(W.Page,{workbench,title:t('引文库','Reference library'),subtitle:t('整理文献、核对来源并导出引文。','Organize references, inspect sources and export citations.'),className:'dcw cite-workbench',actions:h(React.Fragment,null,
741
747
  h(W.Button,{variant:'primary',icon:'plus',onClick:()=>setActiveTab('import')},t('导入文献','Import references')),h(W.Button,{icon:'download',onClick:()=>setActiveTab('export')},t('下载与备份','Downloads and backup')))},
742
- h('style',null,css),h('style',null,CITE_WORKBENCH_CSS),h(W.Status,{tone:'error'},error),h(W.Status,{tone:'error'},citationError),h(W.Status,{tone:'success'},notice),conflict && h('div', { className: 'notice error' }, h('p', null, t('库已在别处更新。当前输入仍保留,请重新预览再保存。', 'The library changed elsewhere. Your input is retained; preview again before saving.')), h('button', { disabled: locked || !text.trim(), onClick: () => perform(async () => { await refresh(); await parse(); }) }, t('重新预览当前输入', 'Preview current input again'))),
748
+ h('style',null,css),h('style',null,CITE_WORKBENCH_CSS),h(W.Status,{tone:'error'},conflict ? null : error),h(W.Status,{tone:'error'},citationError),h(W.Status,{tone:'success'},notice),conflict ? h(W.Status, { tone: 'error' }, h('div', null, h('p', null, t('库已在别处更新。当前输入仍保留,请重新预览当前输入再保存。', 'The library changed elsewhere. Your input is retained; preview the current input again before saving.')), h('div', { className: 'w-toolbar' }, h(W.Button, { icon: 'refresh', disabled: locked || !text.trim(), title: text.trim() ? undefined : t('先粘贴 DOI 或 BibTeX 输入。', 'Paste DOI or BibTeX input first.'), onClick: () => perform(async () => { await refresh(); await parse(); }) }, t('重新预览当前输入', 'Preview current input again'))))) : null,
743
749
  h(W.Tabs,{label:t('引文工作台视图','Reference workbench views'),value:activeTab,onChange:setActiveTab,items:[{id:'library',label:t('文献库','Library')},{id:'import',label:t('导入与预览','Import and preview')},{id:'export',label:t('引文与下载','Citations and downloads')}]},
744
- activeTab === 'import' ? h('div',{className:'cite-form-view'},h('div', null, h('div', { className: 'card' }, h('h3', null, t('导入与本地预览', 'Import and local preview')), h('label', { htmlFor: controlId+'-kind' }, t('输入类型', 'Input type')), h('select', { id: controlId+'-kind', value: kind, disabled: locked, onChange: e => changeInput(setKind, e.target.value) }, h('option', { value: 'doi' }, t('DOI 列表(每行一条)', 'DOI list (one per line)')), h('option', { value: 'bibtex' }, 'BibTeX / BibLaTeX')), h('label', { htmlFor: controlId+'-input' }, t('DOI / BibTeX 输入', 'DOI / BibTeX input')), h('textarea', { id: controlId+'-input', rows: 8, value: text, disabled: locked, spellCheck: false, onChange: e => changeInput(setText, e.target.value), placeholder: kind === 'doi' ? '10.1038/nature12345\nhttps://doi.org/10.1145/3368089.3409749' : '@article{key,\n title={Your title},\n author={Family, Given},\n year={2026}\n}' }), h('label', { htmlFor: controlId+'-source' }, t('来源名称(可选)', 'Source name (optional)')), h('input', { id: controlId+'-source', value: label, maxLength: 160, disabled: locked, onChange: e => changeInput(setLabel, e.target.value) }), h('input', { ref: fileRef, type: 'file', accept: '.bib', style: { display: 'none' }, onChange: upload }), h('div', { className: 'bar' }, h('button', { disabled: locked, onClick: () => fileRef.current.click() }, t('上传 .bib', 'Upload .bib')), h('button', { className: 'primary', disabled: locked || !text.trim(), onClick: () => perform(parse) }, t('本地预览', 'Local preview'))), h('p', { className: 'muted' }, t('最多 256 KiB / 100 条;库最多 500 条。预览、去重和格式切换都不联网。上传仅读取文件,不改写原文件。', 'Up to 256 KiB / 100 entries per import; 500 in the library. Preview, deduplication and formatting are offline. Upload reads your file without changing it.')), dirty && h('p', { className: 'muted' }, t('当前输入尚未保存到文献库。关闭设置后输入仍保留。', 'Current input has not been saved. It is retained when you close settings.'))), preview && h('div', { className: 'card' }, h('h3', null, t('预览:选择要保存的文献', 'Preview: choose entries to save')), h('p', { className: 'muted' }, preview.label + ' · ' + t('已选 ', 'Selected ') + chosen.length + '/' + preview.rows.length), preview.rows.map(r => h('div', { className: 'entry', key: r.index }, h('label', { className: 'choose' }, h('input', { type: 'checkbox', checked: chosen.includes(r.index), disabled: locked || !!r.error || !!r.duplicate, 'aria-label': t('保存预览条目 ', 'Save preview entry ') + (r.index + 1), onChange: () => toggle(chosen, r.index, setChosen) }), h('span', null, h('strong', null, (r.index + 1) + '. ' + (r.work?.title || r.work?.doi || r.key)), r.work && h('div', { className: 'muted' }, [authors(r.work), r.work.year || '', r.work.doi].filter(Boolean).join(' · ')), r.duplicate && h('span', { className: 'tag warn' }, r.duplicate === 'library' ? t('DOI 已在库中,跳过', 'DOI already saved; skipped') : t('同批 DOI 重复,跳过', 'Repeated DOI in this batch; skipped')), r.candidate && h('span', { className: 'tag warn' }, t('可能重复,请核对后决定', 'Possible duplicate; review before selecting')), r.warnings.map(w => h('span', { key: w, className: 'tag warn' }, warning(w))), r.error && h('p', { className: 'notice error' }, t(r.error, r.errorEn || 'Invalid reference. Check the original input.')))))), h('div', { className: 'bar' }, h('button', { className: 'primary', disabled: locked || conflict || !chosen.length, onClick: () => perform(save) }, t('保存所选 ', 'Save selected ') + chosen.length), h('button', { disabled: locked, onClick: () => { setPreview(null); setChosen([]); } }, t('返回输入', 'Back to input')))))) : activeTab === 'export' ? h('div',{className:'cite-form-view'},h('div', { className: 'card' }, h('h3', null, t('引文与下载', 'References and downloads')), h('label', { htmlFor: controlId+'-style' }, t('引文格式(基本格式)', 'Citation style (basic)')), h('select', { id: controlId+'-style', value: style, onChange: e => setStyle(e.target.value) }, ['gb-t-7714', 'apa', 'mla', 'chicago'].map((value, i) => h('option', { value, key: value }, ['GB/T 7714', 'APA', 'MLA', 'Chicago'][i]))), citation && h('pre', { 'aria-label': t('引文预览', 'Reference preview') }, citation), h('p', { className: 'muted' }, t('沿用原插件的四种基本格式;提交论文前请核对学校或期刊要求。上方可预览单条引文。', 'Uses the existing four basic styles. Check your institution or journal requirements before submission. Use an entry above to preview its reference.')), h('p', null, selected.length ? t('下载范围:所选 ', 'Download scope: selected ') + selected.length : t('下载范围:全部文献', 'Download scope: entire library')), h('div', { className: 'bar' }, downloadLink('bibtex', '下载 BibTeX', 'Download BibTeX'), downloadLink('references', '下载参考文献文本', 'Download reference text'), downloadLink('backup', '完整备份(含原始来源)', 'Full backup (with original sources)')), h('p', { className: 'muted' }, t('完整备份始终包含全库及原始输入,不受选择范围影响。导出 BibTeX 使用互不重复的引用键;保留的原始来源用于核对未映射字段。', 'Full backup always includes the entire library and original input. BibTeX exports use unique citation keys. Original sources preserve fields that are not mapped into this workbench.'))),job && h('div', { className: job.state === 'failed' ? 'card notice error' : 'card', role: job.state === 'failed' ? 'alert' : 'status' }, h('h3', null, t('补全进度', 'Enrichment progress')), h('progress', { max: job.total, value: job.completed }), h('p', null, ({ running: t('查询中', 'Looking up'), done: t('已完成', 'Completed'), failed: t('未保存本次补全', 'Enrichment was not saved'), cancelled: t('已取消,原文献保留', 'Cancelled; saved entries preserved') }[job.state]) + ' · ' + job.completed + '/' + job.total), job.state === 'done' && h('p', null, t('已检查并保存 ', 'Entries checked and saved: ') + job.saved + t(' 条;失败 ', '; failed: ') + job.results.filter(r => !r.ok).length), job.message && h('p', { className: 'notice error' }, t(job.message, job.messageEn || 'The job could not be completed; saved entries are preserved.')), running && h('button', { disabled: busy, onClick: () => perform(async () => { await api({ action: 'cancel', job: job.id }); }) }, t('取消本次补全', 'Cancel enrichment')), h('details', null, h('summary', null, t('查看每条结果', 'Show individual results')), job.results.map(r => h('div', { className: 'entry', key: r.id }, h('strong', null, r.doi || t('没有 DOI', 'No DOI')), h('p', null, r.ok ? t('补全字段:', 'Fields filled: ') + (r.filled.length ? r.filled.map(fieldName).join(', ') : t('无需补全', 'none needed')) : t(r.error, r.errorEn || 'Lookup failed. Check the DOI or retry.')), r.conflicts?.length > 0 && h('p', { className: 'warn' }, t('有 ', 'Differences: ') + r.conflicts.length + t(' 项差异;请查看文献详情。', '; see entry details.'))))))) :
745
- h(CiteLibrary,{library,filtered,visible,selected,setSelected,search,setSearch,limit,setLimit,activeId,setActiveId,citation,style,setStyle,t,fieldName,warning,locked,refresh,perform,enrich:ids=>perform(async()=>setJob(await api({action:'enrich',ids,revision:library.revision}))),jobProgress:job && h('div', { className: job.state === 'failed' ? 'card notice error' : 'card', role: job.state === 'failed' ? 'alert' : 'status' }, h('h3', null, t('补全进度', 'Enrichment progress')), h('progress', { max: job.total, value: job.completed }), h('p', null, ({ running: t('查询中', 'Looking up'), done: t('已完成', 'Completed'), failed: t('未保存本次补全', 'Enrichment was not saved'), cancelled: t('已取消,原文献保留', 'Cancelled; saved entries preserved') }[job.state]) + ' · ' + job.completed + '/' + job.total), job.state === 'done' && h('p', null, t('已检查并保存 ', 'Entries checked and saved: ') + job.saved + t(' 条;失败 ', '; failed: ') + job.results.filter(r => !r.ok).length), job.message && h('p', { className: 'notice error' }, t(job.message, job.messageEn || 'The job could not be completed; saved entries are preserved.')), running && h('button', { disabled: busy, onClick: () => perform(async () => { await api({ action: 'cancel', job: job.id }); }) }, t('取消本次补全', 'Cancel enrichment')), h('details', null, h('summary', null, t('查看每条结果', 'Show individual results')), job.results.map(r => h('div', { className: 'entry', key: r.id }, h('strong', null, r.doi || t('没有 DOI', 'No DOI')), h('p', null, r.ok ? t('补全字段:', 'Fields filled: ') + (r.filled.length ? r.filled.map(fieldName).join(', ') : t('无需补全', 'none needed')) : t(r.error, r.errorEn || 'Lookup failed. Check the DOI or retry.')), r.conflicts?.length > 0 && h('p', { className: 'warn' }, t('有 ', 'Differences: ') + r.conflicts.length + t(' 项差异;请查看文献详情。', '; see entry details.')))))),onImport:()=>setActiveTab('import')}))),"dsh-cite");
750
+ activeTab === 'import' ? h('div',{className:'cite-form-view'},h('div', null, h('div', { className: 'card' }, h('h3', null, t('导入与本地预览', 'Import and local preview')), h('label', { htmlFor: controlId+'-kind' }, t('输入类型', 'Input type')), h('select', { id: controlId+'-kind', value: kind, disabled: locked, onChange: e => changeInput(setKind, e.target.value) }, h('option', { value: 'doi' }, t('DOI 列表(每行一条)', 'DOI list (one per line)')), h('option', { value: 'bibtex' }, 'BibTeX / BibLaTeX')), h('label', { htmlFor: controlId+'-input' }, t('DOI / BibTeX 输入', 'DOI / BibTeX input')), h('textarea', { id: controlId+'-input', rows: 8, value: text, disabled: locked, spellCheck: false, onChange: e => changeInput(setText, e.target.value), placeholder: kind === 'doi' ? '10.1038/nature12345\nhttps://doi.org/10.1145/3368089.3409749' : '@article{key,\n title={Your title},\n author={Family, Given},\n year={2026}\n}' }), h('label', { htmlFor: controlId+'-source' }, t('来源名称(可选)', 'Source name (optional)')), h('input', { id: controlId+'-source', value: label, maxLength: 160, disabled: locked, onChange: e => changeInput(setLabel, e.target.value) }), h('input', { ref: fileRef, type: 'file', accept: '.bib', style: { display: 'none' }, onChange: upload }), h('div', { className: 'w-toolbar' }, h(W.Button, { icon: 'upload', disabled: locked, onClick: () => fileRef.current.click() }, t('上传 .bib', 'Upload .bib')), h(W.Button, { variant: 'primary', icon: 'search', disabled: locked || !text.trim(), title: text.trim() ? undefined : t('先粘贴 DOI 或 BibTeX 输入。', 'Paste DOI or BibTeX input first.'), onClick: () => perform(parse) }, t('本地预览', 'Local preview'))), h('p', { className: 'muted' }, t('最多 256 KiB / 100 条;库最多 500 条。预览、去重和格式切换都不联网。上传仅读取文件,不改写原文件。', 'Up to 256 KiB / 100 entries per import; 500 in the library. Preview, deduplication and formatting are offline. Upload reads your file without changing it.')), dirty && h('p', { className: 'muted' }, t('当前输入尚未保存到文献库。关闭设置后输入仍保留。', 'Current input has not been saved. It is retained when you close settings.'))), preview && h('div', { className: 'card' }, h('h3', null, t('预览:选择要保存的文献', 'Preview: choose entries to save')), h('p', { className: 'muted' }, preview.label + ' · ' + t('已选 ', 'Selected ') + chosen.length + '/' + preview.rows.length), preview.rows.map(r => h('div', { className: 'entry', key: r.index }, h('label', { className: 'choose' }, h('input', { type: 'checkbox', checked: chosen.includes(r.index), disabled: locked || !!r.error || !!r.duplicate, 'aria-label': t('保存预览条目 ', 'Save preview entry ') + (r.index + 1), onChange: () => toggle(chosen, r.index, setChosen) }), h('span', null, h('strong', null, (r.index + 1) + '. ' + (r.work?.title || r.work?.doi || r.key)), r.work && h('div', { className: 'muted' }, [authors(r.work), r.work.year || '', r.work.doi].filter(Boolean).join(' · ')), r.duplicate && h('span', { className: 'tag warn' }, r.duplicate === 'library' ? t('DOI 已在库中,跳过', 'DOI already saved; skipped') : t('同批 DOI 重复,跳过', 'Repeated DOI in this batch; skipped')), r.candidate && h('span', { className: 'tag warn' }, t('可能重复,请核对后决定', 'Possible duplicate; review before selecting')), r.warnings.map(w => h('span', { key: w, className: 'tag warn' }, warning(w))), r.error && h('p', { className: 'notice error' }, t(r.error, r.errorEn || 'Invalid reference. Check the original input.')))))), h('div', { className: 'w-toolbar' }, h(W.Button, { variant: 'primary', icon: 'check', disabled: locked || conflict || !chosen.length, title: conflict ? t('库已更新,请重新预览后再保存。', 'The library changed; preview again before saving.') : !chosen.length ? t('先勾选要保存的条目。', 'Select entries to save first.') : undefined, onClick: () => perform(save) }, t('保存所选 ', 'Save selected ') + chosen.length), h(W.Button, { disabled: locked, onClick: () => { setPreview(null); setChosen([]); } }, t('返回输入', 'Back to input')))))) : activeTab === 'export' ? h('div',{className:'cite-form-view'},h('div', { className: 'card' },
751
+ h('h3', null, t('导出前检查', 'Before you export')),
752
+ h('fieldset', { className: 'cite-scope' }, h('legend', null, t('导出范围', 'Export scope')),
753
+ h('label', null, h('input', { type: 'radio', name: controlId + '-scope', checked: exportScope === 'all', disabled: locked, onChange: () => setExportScope('all') }), h('span', null, t('全部文献', 'Entire library') + ' · ' + library.entries.length + t(' 条', ' references'))),
754
+ h('label', null, h('input', { type: 'radio', name: controlId + '-scope', checked: exportScope === 'selected', disabled: locked || !selected.length, onChange: () => setExportScope('selected') }), h('span', null, t('仅所选', 'Selected only') + ' · ' + selected.length + t(' 条', ' references'))),
755
+ !selected.length ? h('p', { className: 'muted' }, t('在“文献库”里勾选条目后,可以选择只导出所选。', 'Select entries in Library to export a subset.')) : null),
756
+ h('label', { htmlFor: controlId + '-style' }, t('引文格式(基本格式)', 'Citation style (basic)')),
757
+ h('select', { id: controlId + '-style', value: style, onChange: e => setStyle(e.target.value) }, ['gb-t-7714', 'apa', 'mla', 'chicago'].map((value, i) => h('option', { value, key: value }, ['GB/T 7714', 'APA', 'MLA', 'Chicago'][i]))),
758
+ h('ul', { className: 'cite-checks' },
759
+ h('li', null, t('范围:', 'Scope: ') + (exportScope === 'selected' ? t('所选 ', 'selected ') : t('全库 ', 'entire library ')) + scopeEntries.length + t(' 条文献', ' references')),
760
+ h('li', null, t('引文格式:', 'Citation style: ') + ({ 'gb-t-7714': 'GB/T 7714', apa: 'APA', mla: 'MLA', chicago: 'Chicago' }[style] || style)),
761
+ h('li', null, t('完整备份:始终包含全库与原始输入,不受范围影响。', 'Full backup: always the entire library with original sources, regardless of scope.'))),
762
+ (scopeMissing.title || scopeMissing.authors || scopeMissing.year) ? h(W.Status, null, t('当前范围内有 ', 'In this scope: ') + scopeMissing.title + t(' 条缺标题、', ' without a title, ') + scopeMissing.authors + t(' 条缺作者、', ' without authors, ') + scopeMissing.year + t(' 条缺年份;导出仍会生成,提交前建议在文献库补全或从 Crossref 在线补全。', ' without a year. The export still works; fill the gaps in Library, optionally with Crossref enrichment, before submitting.')) : null,
763
+ citation && h('pre', { 'aria-label': t('引文预览', 'Reference preview') }, citation),
764
+ h('p', { className: 'muted' }, t('沿用原插件的四种基本格式;提交论文前请核对学校或期刊要求。上方可预览单条引文。', 'Uses the existing four basic styles. Check your institution or journal requirements before submission. Use an entry above to preview its reference.')),
765
+ h('div', { className: 'w-toolbar' }, downloadLink('bibtex', '下载 BibTeX', 'Download BibTeX'), downloadLink('references', '下载参考文献文本', 'Download reference text'), downloadLink('backup', '完整备份(含原始来源)', 'Full backup (with original sources)')),
766
+ h('p', { className: 'muted' }, t('完整备份始终包含全库及原始输入,不受选择范围影响。导出 BibTeX 使用互不重复的引用键;保留的原始来源用于核对未映射字段。', 'Full backup always includes the entire library and original input. BibTeX exports use unique citation keys. Original sources preserve fields that are not mapped into this workbench.'))),job && h('div', { className: job.state === 'failed' ? 'card notice error' : 'card', role: job.state === 'failed' ? 'alert' : 'status' }, h('h3', null, t('补全进度', 'Enrichment progress')), h('progress', { max: job.total || 1, value: job.completed, 'aria-label': t('补全进度', 'Enrichment progress') }), h('p', null, ({ running: t('查询中', 'Looking up'), done: t('已完成', 'Completed'), failed: t('未保存本次补全', 'Enrichment was not saved'), cancelled: t('已取消,原文献保留', 'Cancelled; saved entries preserved') }[job.state]) + ' · ' + job.completed + '/' + job.total), job.state === 'done' && h('p', null, t('已检查并保存 ', 'Entries checked and saved: ') + job.saved + t(' 条;失败 ', '; failed: ') + job.results.filter(r => !r.ok).length), job.message && h('p', { className: 'notice error' }, t(job.message, job.messageEn || 'The job could not be completed; saved entries are preserved.')), running && h(W.Button, { variant: 'ghost', disabled: busy, onClick: () => perform(async () => { await api({ action: 'cancel', job: job.id }); }) }, t('取消本次补全', 'Cancel enrichment')), h('details', null, h('summary', null, t('查看每条结果', 'Show individual results')), job.results.map(r => h('div', { className: 'entry', key: r.id }, h('strong', null, r.doi || t('没有 DOI', 'No DOI')), h('p', null, r.ok ? t('补全字段:', 'Fields filled: ') + (r.filled.length ? r.filled.map(fieldName).join(', ') : t('无需补全', 'none needed')) : t(r.error, r.errorEn || 'Lookup failed. Check the DOI or retry.')), r.conflicts?.length > 0 && h('p', { className: 'warn' }, t('有 ', 'Differences: ') + r.conflicts.length + t(' 项差异;请查看文献详情。', '; see entry details.'))))))) :
767
+ h(CiteLibrary,{library,filtered,visible,selected,setSelected,search,setSearch,limit,setLimit,activeId,setActiveId,citation,style,setStyle,t,fieldName,warning,locked,refresh,perform,enrich:ids=>perform(async()=>setJob(await api({action:'enrich',ids,revision:library.revision}))),jobProgress:job && h('div', { className: job.state === 'failed' ? 'card notice error' : 'card', role: job.state === 'failed' ? 'alert' : 'status' }, h('h3', null, t('补全进度', 'Enrichment progress')), h('progress', { max: job.total || 1, value: job.completed, 'aria-label': t('补全进度', 'Enrichment progress') }), h('p', null, ({ running: t('查询中', 'Looking up'), done: t('已完成', 'Completed'), failed: t('未保存本次补全', 'Enrichment was not saved'), cancelled: t('已取消,原文献保留', 'Cancelled; saved entries preserved') }[job.state]) + ' · ' + job.completed + '/' + job.total), job.state === 'done' && h('p', null, t('已检查并保存 ', 'Entries checked and saved: ') + job.saved + t(' 条;失败 ', '; failed: ') + job.results.filter(r => !r.ok).length), job.message && h('p', { className: 'notice error' }, t(job.message, job.messageEn || 'The job could not be completed; saved entries are preserved.')), running && h(W.Button, { variant: 'ghost', disabled: busy, onClick: () => perform(async () => { await api({ action: 'cancel', job: job.id }); }) }, t('取消本次补全', 'Cancel enrichment')), h('details', null, h('summary', null, t('查看每条结果', 'Show individual results')), job.results.map(r => h('div', { className: 'entry', key: r.id }, h('strong', null, r.doi || t('没有 DOI', 'No DOI')), h('p', null, r.ok ? t('补全字段:', 'Fields filled: ') + (r.filled.length ? r.filled.map(fieldName).join(', ') : t('无需补全', 'none needed')) : t(r.error, r.errorEn || 'Lookup failed. Check the DOI or retry.')), r.conflicts?.length > 0 && h('p', { className: 'warn' }, t('有 ', 'Differences: ') + r.conflicts.length + t(' 项差异;请查看文献详情。', '; see entry details.')))))),onImport:()=>setActiveTab('import')}))),"dsh-cite");
746
768
  }
747
769
  function apply(ctx) { let locale; try {
748
770
  locale = ctx.get?.('locale') || ctx.locale;
@@ -751,7 +773,7 @@ const referenceId=activeId && referenceEntries.some(entry=>entry.id===activeId)?
751
773
  W.register(ctx,{id:'dsh-cite.workbench',label,icon:'book',component:Workbench,inject:()=>({locale}),order:64});
752
774
  ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'dsh-cite', order: 64, label, inject: () => ({ locale }) }, Workbench)); }
753
775
  return { inject: ['slots', 'locale'], apply };
754
- } },{"name":"dsh-cite","version":"0.1.0","hasWorkbench":true,"packageVersion":"0.7.7","label":"引文库","labelEn":"Citations","suiteComponent":true}));
776
+ } },{"name":"dsh-cite","version":"0.1.0","hasWorkbench":true,"packageVersion":"0.7.8","label":"引文库","labelEn":"Citations","suiteComponent":true}));
755
777
 
756
778
  })();
757
779
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cite",
3
- "version": "0.7.7",
4
- "description": "把零散 DOI 和 BibTeX 整理成可用的文献库。 联网补全需要访问 Crossref 欢迎提交 issues 和 PR。",
3
+ "version": "0.7.8",
4
+ "description": "DSH 文献工作台:DOI / BibTeX 导入预览、去重、Crossref 补全、引文导出与来源备份。欢迎提交 issues 和 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "scripts": {
27
27
  "build": "tsc -p tsconfig.json && node scripts/build-client.mjs && node scripts/build-updates.mjs",
28
28
  "typecheck": "tsc -p tsconfig.json --noEmit",
29
- "test": "pnpm run build && node --test \"test/*.test.mjs\"",
30
- "prepublishOnly": "pnpm run build"
29
+ "test": "npm run build && node --test \"test/*.test.mjs\"",
30
+ "prepublishOnly": "npm run build"
31
31
  },
32
32
  "dsh": {
33
33
  "client": {