transproof-dsh-plugin 0.1.2 → 0.1.3
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/app/index.html +4 -0
- package/app/js/01-core.js +1 -1
- package/app/js/08-render-audit.js +4 -1
- package/app/js/17-cite-header.js +151 -0
- package/package.json +1 -1
package/app/index.html
CHANGED
|
@@ -1654,6 +1654,7 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1654
1654
|
<tr><td><b>📋 交付质检报告(v4.40 新)</b></td><td>校对结果按钮行新增「📋 交付报告」:把错误分类、已修进度、质量评分(本地算分;跑过 AI 质量预估也带上)、检查覆盖汇总成一张可复制 Markdown 报告,页脚带 TransProof 名片——交稿时一句话说清「查了什么、还剩什么风险」(纯本地、不花 token)</td></tr>
|
|
1655
1655
|
<tr><td><b>🔎 专名百科自动查证(v4.41 新)</b></td><td>专有译词库「专名核验」卡片每行新增「🔎 查维基」:按外文名查中英维基百科,带回通行译名 + 简介 + 真 URL,人工确认后入词库;已批准专名的背景简介会自动带进翻译/校对提示词。查不到或被拦时给友好提示(开代理 / 换渠道)</td></tr>
|
|
1656
1656
|
<tr><td><b>🌱 一边译一边填术语表(v4.42 新)</b></td><td>翻译页再勾「翻译时收集新词到译词库」,译完自动把新术语、专业词、反复出现的关键词连同建议译名收进译词库(默认待审核,与「抽专名」互不干扰、自动去重)——术语库不用手敲,越翻越全</td></tr>
|
|
1657
|
+
<tr><td><b>📎 导出引用头(v4.43 新)</b></td><td>复制结果弹窗顶部新增「📎 引用头」:可选粘贴 ①中译标题 ②作者(中译名)+ 研究机构 ③APA 格式出处 ④版权声明(CC BY-NC-SA 4.0,仅供个人学习),四样都可勾选;元数据点「🤖 自动提取」从原文抽、查不到的手填,勾选后拼在译文最前面一起复制</td></tr>
|
|
1657
1658
|
</tbody>
|
|
1658
1659
|
</table>
|
|
1659
1660
|
<div class="alert i" style="margin-top:12px">
|
|
@@ -1794,6 +1795,8 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1794
1795
|
<tr><td><b>近期</b></td><td><b>左下角版本显示</b>:页面最底端左下角常驻显示当前版本号,网页端 / 插件端同款</td><td>✅ 已上线(v4.39.1)</td></tr>
|
|
1795
1796
|
<tr><td><b>近期</b></td><td><b>交付质检报告</b>:一键汇总错误分类 / 已修进度 / 质量评分 / 检查覆盖成可复制报告,页脚带 TransProof 名片</td><td>✅ 已上线(v4.40.0,结果区「📋 交付报告」)</td></tr>
|
|
1796
1797
|
<tr><td><b>近期</b></td><td><b>专名百科自动查证</b>:专名核验点「🔎 查维基」直连中英维基百科,带回译名 + 简介 + 真 URL,批准后背景简介进提示词</td><td>✅ 已上线(v4.41.0,专名核验卡片「🔎 查维基」)</td></tr>
|
|
1798
|
+
<tr><td><b>近期</b></td><td><b>一边译一边填术语表</b>:翻译页勾「收集新词到译词库」,译完自动把新术语+建议译名收进词库(默认待审、自动去重)</td><td>✅ 已上线(v4.42.0,翻译页「翻译时收集新词到译词库」)</td></tr>
|
|
1799
|
+
<tr><td><b>近期</b></td><td><b>导出引用头</b>:复制结果时最前面可选加「中译标题 / 作者+机构 / APA 出处 / 版权声明」四样,元数据 AI 抽 + 手填</td><td>✅ 已上线(v4.43.0,复制结果弹窗「📎 引用头」)</td></tr>
|
|
1797
1800
|
<tr><td><b>云端版</b></td><td><b>改动留痕、可回溯</b>:每次重要校对留下不可篡改的备份点,谁改了什么、当时发生了什么都能查,不再靠猜</td><td>规划中</td></tr>
|
|
1798
1801
|
</tbody>
|
|
1799
1802
|
</table>
|
|
@@ -1840,5 +1843,6 @@ Entfremdung | 异化 | 马克思;与 Verfremdung「间离」区分"></textarea
|
|
|
1840
1843
|
<script src="js/14-noun-verify.js"></script>
|
|
1841
1844
|
<script src="js/15-delivery-report.js"></script>
|
|
1842
1845
|
<script src="js/16-wiki-verify.js"></script>
|
|
1846
|
+
<script src="js/17-cite-header.js"></script>
|
|
1843
1847
|
</body>
|
|
1844
1848
|
</html>
|
package/app/js/01-core.js
CHANGED
|
@@ -397,6 +397,7 @@ function showCopyOptions(md){
|
|
|
397
397
|
'</label>'
|
|
398
398
|
).join('');
|
|
399
399
|
modal('复制结果(勾选要复制的段落)', [
|
|
400
|
+
(typeof citeBlockForDialog === 'function' ? citeBlockForDialog() : ''),
|
|
400
401
|
'<div style="font-size:13px;color:var(--tx2);margin-bottom:10px">默认全选。取消勾选不需要的段落(如逐条批注、注释建议)即可只复制你想要的部分。</div>',
|
|
401
402
|
'<div style="display:flex;gap:8px;margin-bottom:10px;flex-wrap:wrap"><button class="btn sm gray" id="copy-all">全选</button><button class="btn sm gray" id="copy-none">全不选</button><button class="btn sm gray" id="copy-core">仅修订后译文</button></div>',
|
|
402
403
|
'<div style="max-height:46vh;overflow:auto;border:1px solid var(--bd);border-radius:8px">' + checks + '</div>',
|
|
@@ -407,10 +408,12 @@ function showCopyOptions(md){
|
|
|
407
408
|
$('#copy-all').onclick = () => sections.forEach((s, i) => { box(i).checked = true; });
|
|
408
409
|
$('#copy-none').onclick = () => sections.forEach((s, i) => { box(i).checked = false; });
|
|
409
410
|
$('#copy-core').onclick = () => sections.forEach((s, i) => { box(i).checked = /修订后译文|终稿|定稿/.test(s.title); });
|
|
411
|
+
if(typeof citeBindDialog === 'function'){ citeBindDialog(); }
|
|
410
412
|
$('#copy-do').onclick = async () => {
|
|
411
413
|
const picked = sections.filter((s, i) => box(i).checked);
|
|
412
414
|
if(!picked.length){ toast('请至少勾选一段', 'w'); return; }
|
|
413
|
-
|
|
415
|
+
let text = picked.map(s => s.content).join('\n\n');
|
|
416
|
+
if(typeof citeBuildFromDialog === 'function'){ const h = citeBuildFromDialog(); if(h){ text = h + '\n\n' + text; } }
|
|
414
417
|
try{ await navigator.clipboard.writeText(text); closeModal(); toast('已复制 ' + picked.length + ' 段(' + text.length + ' 字)'); }
|
|
415
418
|
catch(e){ toast('复制失败,请手动选中文本', 'e'); }
|
|
416
419
|
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* ═══════════ T-033 导出引用头(APA 署名 + 版权声明)· v4.43.0 ═══════════
|
|
2
|
+
校对完成 → 点「复制结果」时,在最前面可选地加四样:
|
|
3
|
+
①中译标题 ②作者(中译名)+ 研究机构 ③APA 格式出处 ④版权声明(CC BY-NC-SA 4.0,仅供个人学习)。
|
|
4
|
+
元数据由 AI 从原文自动抽取,查不到的字段留给翻译者手填。 */
|
|
5
|
+
const CITE_LS = 'tp.citemeta';
|
|
6
|
+
const CITE_SYS = '你是学术文献元数据抽取助手。输入是论文/文章的开头或全文。从中提取引用所需信息,输出 JSON 对象(不要代码围栏、不要解释):{"title_zh":"文章中文标题(原文是中文则原样,否则给出译名)","author_zh":"第一作者中译名(姓在前,如 麦考利)","institution":"第一作者研究机构中文名","author_en":"APA 格式作者列表(保留原文字符串,如 McCauley, S. M., & Christiansen, M. H.)","year":"出版年份","article_title":"文章原文标题","journal":"期刊名","volume":"卷","issue":"期","pages":"页码","doi":"DOI 纯数字串(不带 https://doi.org/ 前缀)"}。查不到的字段填空字符串。只输出 JSON 对象本身。';
|
|
7
|
+
|
|
8
|
+
function citeMetaDefaults(){
|
|
9
|
+
return { title_zh:'', author_zh:'', institution:'', author_en:'', year:'', article_title:'', journal:'', volume:'', issue:'', pages:'', doi:'' };
|
|
10
|
+
}
|
|
11
|
+
function citeLoadMeta(){
|
|
12
|
+
try{
|
|
13
|
+
const o = JSON.parse(localStorage.getItem(CITE_LS) || 'null');
|
|
14
|
+
if(o && typeof o === 'object') return Object.assign(citeMetaDefaults(), o);
|
|
15
|
+
}catch(e){}
|
|
16
|
+
return citeMetaDefaults();
|
|
17
|
+
}
|
|
18
|
+
function citeSaveMeta(m){
|
|
19
|
+
try{ localStorage.setItem(CITE_LS, JSON.stringify(m || citeMetaDefaults())); }catch(e){}
|
|
20
|
+
}
|
|
21
|
+
function citeSourceText(){
|
|
22
|
+
const cands = [];
|
|
23
|
+
const src = $('#src'), tss = $('#ts-src');
|
|
24
|
+
if(src && src.value) cands.push(src.value);
|
|
25
|
+
if(tss && tss.value) cands.push(tss.value);
|
|
26
|
+
if(window.__TP_FILES && __TP_FILES.src && __TP_FILES.src.text) cands.push(__TP_FILES.src.text);
|
|
27
|
+
for(const c of cands){ if(c && c.trim().length > 40) return c; }
|
|
28
|
+
return (cands.find(c => c && c.trim()) || '');
|
|
29
|
+
}
|
|
30
|
+
function citeDoiUrl(d){
|
|
31
|
+
d = (d || '').trim();
|
|
32
|
+
if(!d) return '';
|
|
33
|
+
if(d.indexOf('http://') === 0 || d.indexOf('https://') === 0) return d;
|
|
34
|
+
return 'https://doi.org/' + d;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function citeBuildApa(m){
|
|
38
|
+
m = m || {};
|
|
39
|
+
const a=(m.author_en||'').trim(), y=(m.year||'').trim(), t=(m.article_title||'').trim(),
|
|
40
|
+
j=(m.journal||'').trim(), v=(m.volume||'').trim(), i=(m.issue||'').trim(),
|
|
41
|
+
p=(m.pages||'').trim(), d=citeDoiUrl(m.doi);
|
|
42
|
+
let out = '';
|
|
43
|
+
if(a) out += a;
|
|
44
|
+
if(y) out += (out ? ' (' : '(') + y + ')';
|
|
45
|
+
if(t) out += (out ? '. ' : '') + t + '.';
|
|
46
|
+
if(j) out += (out ? ' ' : '') + j;
|
|
47
|
+
if(v) out += ', ' + v;
|
|
48
|
+
if(i) out += '(' + i + ')';
|
|
49
|
+
if(p) out += ', ' + p + '.';
|
|
50
|
+
else if(j || v || i) out += '.';
|
|
51
|
+
if(d) out += ' ' + d;
|
|
52
|
+
return out.trim() ? out : '';
|
|
53
|
+
}
|
|
54
|
+
function citeBuildHeader(m, opts){
|
|
55
|
+
m = m || {};
|
|
56
|
+
opts = opts || { title:true, author:true, apa:true, license:true };
|
|
57
|
+
const parts = [];
|
|
58
|
+
if(opts.title && (m.title_zh||'').trim()) parts.push('【标题】' + m.title_zh.trim());
|
|
59
|
+
if(opts.author){
|
|
60
|
+
const a=(m.author_zh||'').trim(), ins=(m.institution||'').trim();
|
|
61
|
+
if(a || ins) parts.push('【作者】' + (a ? a + (ins ? ',' + ins : '') : ins));
|
|
62
|
+
}
|
|
63
|
+
if(opts.apa){ const apa = citeBuildApa(m); if(apa) parts.push('【APA 出处】\n' + apa); }
|
|
64
|
+
if(opts.license) parts.push('【版权声明】\n本文遵循 CC BY-NC-SA 4.0 协议发布,仅供个人学习使用。');
|
|
65
|
+
return parts.join('\n\n');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let CITE_CUR = null;
|
|
69
|
+
function citeBlockForDialog(){
|
|
70
|
+
CITE_CUR = citeLoadMeta();
|
|
71
|
+
return citeHeaderBlockHtml(CITE_CUR);
|
|
72
|
+
}
|
|
73
|
+
function citeHeaderBlockHtml(meta){
|
|
74
|
+
meta = meta || citeMetaDefaults();
|
|
75
|
+
const f = (k, label, ph) =>
|
|
76
|
+
'<div style="display:flex;gap:6px;align-items:center">' +
|
|
77
|
+
'<label style="width:76px;flex-shrink:0;font-size:12px;color:var(--tx2)">' + label + '</label>' +
|
|
78
|
+
'<input id="cite-' + k + '" value="' + esc(meta[k] || '') + '" placeholder="' + (ph||'') + '" style="flex:1;font-size:13px;padding:4px 6px">' +
|
|
79
|
+
'</div>';
|
|
80
|
+
return '<div style="border:1px solid var(--bd);border-radius:8px;padding:10px;margin-bottom:10px">' +
|
|
81
|
+
'<div style="font-size:13px;font-weight:600;margin-bottom:8px">📎 引用头(勾选后置于译文最前面,查不到的手填)</div>' +
|
|
82
|
+
'<div style="display:flex;flex-wrap:wrap;gap:12px;margin-bottom:8px;font-size:13px">' +
|
|
83
|
+
'<label><input type="checkbox" id="cite-op-title" checked style="width:auto"> ① 中译标题</label>' +
|
|
84
|
+
'<label><input type="checkbox" id="cite-op-author" checked style="width:auto"> ② 作者+机构</label>' +
|
|
85
|
+
'<label><input type="checkbox" id="cite-op-apa" checked style="width:auto"> ③ APA 出处</label>' +
|
|
86
|
+
'<label><input type="checkbox" id="cite-op-license" checked style="width:auto"> ④ 版权声明</label>' +
|
|
87
|
+
'<button class="btn sm gray" id="cite-extract" type="button">🤖 自动提取</button>' +
|
|
88
|
+
'</div>' +
|
|
89
|
+
'<details><summary style="font-size:12px;color:var(--ac);cursor:pointer">✏️ 编辑引用信息</summary>' +
|
|
90
|
+
'<div style="margin-top:8px;display:grid;gap:4px">' +
|
|
91
|
+
f('title_zh','中译标题','文章中文标题') +
|
|
92
|
+
f('author_zh','作者中译名','如:麦考利') +
|
|
93
|
+
f('institution','研究机构','如:康奈尔大学') +
|
|
94
|
+
f('author_en','APA 作者','McCauley, S. M., & Christiansen, M. H.') +
|
|
95
|
+
f('year','年份','2019') +
|
|
96
|
+
f('article_title','文章标题','原文标题') +
|
|
97
|
+
f('journal','期刊','Psychological Review') +
|
|
98
|
+
f('volume','卷','126') + f('issue','期','1') + f('pages','页码','1–51') +
|
|
99
|
+
f('doi','DOI','10.1037/rev0000126') +
|
|
100
|
+
'</div></details></div>';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function citeCollectMetaFromForm(){
|
|
104
|
+
const m = citeMetaDefaults();
|
|
105
|
+
const keys = ['title_zh','author_zh','institution','author_en','year','article_title','journal','volume','issue','pages','doi'];
|
|
106
|
+
for(const k of keys){ const el = $('#cite-' + k); if(el) m[k] = el.value.trim(); }
|
|
107
|
+
return m;
|
|
108
|
+
}
|
|
109
|
+
function citeBuildFromDialog(){
|
|
110
|
+
const m = citeCollectMetaFromForm();
|
|
111
|
+
citeSaveMeta(m);
|
|
112
|
+
const opts = {
|
|
113
|
+
title: $('#cite-op-title') ? $('#cite-op-title').checked : true,
|
|
114
|
+
author: $('#cite-op-author') ? $('#cite-op-author').checked : true,
|
|
115
|
+
apa: $('#cite-op-apa') ? $('#cite-op-apa').checked : true,
|
|
116
|
+
license: $('#cite-op-license') ? $('#cite-op-license').checked : true
|
|
117
|
+
};
|
|
118
|
+
return citeBuildHeader(m, opts);
|
|
119
|
+
}
|
|
120
|
+
async function citeExtract(){
|
|
121
|
+
const src = citeSourceText();
|
|
122
|
+
if(!src){ toast('没找到原文,无法自动提取', 'w'); return; }
|
|
123
|
+
const btn = $('#cite-extract');
|
|
124
|
+
if(btn){ btn.disabled = true; btn.textContent = '提取中…'; }
|
|
125
|
+
try{
|
|
126
|
+
const user = '原文(前 6000 字):\n' + src.slice(0, 6000);
|
|
127
|
+
const raw = await callModelSimple(CITE_SYS, user, 1000);
|
|
128
|
+
const obj = extractJsonObject(raw);
|
|
129
|
+
if(obj && typeof obj === 'object'){
|
|
130
|
+
const m = citeCollectMetaFromForm();
|
|
131
|
+
const keys = ['title_zh','author_zh','institution','author_en','year','article_title','journal','volume','issue','pages','doi'];
|
|
132
|
+
for(const k of keys){ if(obj[k] != null && String(obj[k]).trim()) m[k] = String(obj[k]).trim(); }
|
|
133
|
+
citeSaveMeta(m);
|
|
134
|
+
for(const k of keys){ const el = $('#cite-' + k); if(el) el.value = m[k] || ''; }
|
|
135
|
+
toast('已自动提取,请核对(查不到的空着即可)');
|
|
136
|
+
} else {
|
|
137
|
+
toast('提取失败,请手动填写', 'w');
|
|
138
|
+
}
|
|
139
|
+
}catch(e){ toast('提取失败:' + (e && e.message ? e.message : '网络或模型错误'), 'e'); }
|
|
140
|
+
finally{ if(btn){ btn.disabled = false; btn.textContent = '🤖 自动提取'; } }
|
|
141
|
+
}
|
|
142
|
+
function citeBindDialog(){
|
|
143
|
+
const b = $('#cite-extract');
|
|
144
|
+
if(b) b.onclick = citeExtract;
|
|
145
|
+
}
|
|
146
|
+
window.citeBuildHeader = citeBuildHeader;
|
|
147
|
+
window.citeBuildApa = citeBuildApa;
|
|
148
|
+
window.citeBuildFromDialog = citeBuildFromDialog;
|
|
149
|
+
window.citeHeaderBlockHtml = citeHeaderBlockHtml;
|
|
150
|
+
window.citeBindDialog = citeBindDialog;
|
|
151
|
+
window.citeBlockForDialog = citeBlockForDialog;
|
package/package.json
CHANGED