dsh-selection-annotations 0.0.0-stage → 2.1.1
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 +171 -0
- package/LICENSE +21 -0
- package/README.md +161 -3
- package/README.zh-CN.md +161 -0
- package/client.js +11136 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +7 -0
- package/lib/annotations-db.js +1157 -0
- package/lib/index.js +1304 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +76 -6
- package/scripts/build.mjs +37 -0
- package/scripts/check-build.mjs +10 -0
- package/src/core/annotation-clipboard.js +93 -0
- package/src/core/annotation-utils.js +27 -0
- package/src/core/cards.js +502 -0
- package/src/core/config.js +91 -0
- package/src/core/constants.js +34 -0
- package/src/core/draft-codec.js +77 -0
- package/src/core/draft-store.js +85 -0
- package/src/core/hidden-payload.js +73 -0
- package/src/core/image-codec.js +111 -0
- package/src/core/jump-icon.js +25 -0
- package/src/core/locale.js +59 -0
- package/src/core/log.js +19 -0
- package/src/core/markdown.js +80 -0
- package/src/core/messages.js +311 -0
- package/src/core/note-tone.js +77 -0
- package/src/core/panel-render.js +315 -0
- package/src/core/payload.js +191 -0
- package/src/core/preview-bridge.js +216 -0
- package/src/core/remote-sync.js +206 -0
- package/src/core/scroll-trace.js +177 -0
- package/src/core/sent-store.js +148 -0
- package/src/core/session.js +60 -0
- package/src/core/settings.js +168 -0
- package/src/core/side-tab-state.js +30 -0
- package/src/core/source-capture.js +530 -0
- package/src/core/source-locate.js +220 -0
- package/src/core/source-resolve.js +89 -0
- package/src/core/styles.js +590 -0
- package/src/core/turn-anchor.js +54 -0
- package/src/core/util.js +55 -0
- package/src/core/uuid.js +23 -0
- package/src/core/web-picker.js +426 -0
- package/src/entry.js +22 -0
- package/src/plugin.js +8706 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
export const MESSAGES = {
|
|
2
|
+
zh: {
|
|
3
|
+
annotate: '批注反馈',
|
|
4
|
+
'annotate.adopt': '批注采纳',
|
|
5
|
+
'annotate.reject': '批注否决',
|
|
6
|
+
'annotate.copy': '复制',
|
|
7
|
+
'menu.annotate': '为划选部分批注反馈',
|
|
8
|
+
'menu.adopt': '为划选部分批注采纳',
|
|
9
|
+
'menu.reject': '为划选部分批注否决',
|
|
10
|
+
'menu.copy': '复制',
|
|
11
|
+
'viewer.alt': '批注图片',
|
|
12
|
+
'image.alt': '图片',
|
|
13
|
+
'image.open': '点击查看大图',
|
|
14
|
+
'image.remove': '移除这张图',
|
|
15
|
+
'pop.placeholder': '写点什么(可以留空,只标记原文)',
|
|
16
|
+
'pop.noteLabel': '批注',
|
|
17
|
+
'pop.imagesHint': '可粘贴或拖入图片,随本条批注一起发出',
|
|
18
|
+
'pop.delete': '删除',
|
|
19
|
+
'pop.cancel': '取消',
|
|
20
|
+
'pop.save': '保存',
|
|
21
|
+
'pop.createTitle': '新建批注',
|
|
22
|
+
'pop.editTitle': '修改批注 #{n}',
|
|
23
|
+
'pop.sentTitle': '已发送批注',
|
|
24
|
+
'pop.noNote': '无备注',
|
|
25
|
+
'pop.resize': '调整面板大小',
|
|
26
|
+
'panel.empty': '选中回复、消息或文件预览里的文字,点浮动的「批注反馈」即可。',
|
|
27
|
+
'panel.title': '批注总览',
|
|
28
|
+
'panel.count': '{n} 条',
|
|
29
|
+
'panel.drag': '拖动排序',
|
|
30
|
+
'panel.edit': '编辑',
|
|
31
|
+
'panel.delete': '删除',
|
|
32
|
+
'panel.quote': '引用原文',
|
|
33
|
+
'panel.note': '批注',
|
|
34
|
+
'panel.clear': '清空',
|
|
35
|
+
'panel.copyAll': '拷贝',
|
|
36
|
+
'panel.paste': '粘贴',
|
|
37
|
+
'panel.copy': '拷贝',
|
|
38
|
+
'panel.pasteFailed': '剪贴板里没有可导入的批注数据',
|
|
39
|
+
'panel.pasteDone': '已导入 {n} 条批注',
|
|
40
|
+
'panel.pasteNothing': '没有新的批注可粘贴',
|
|
41
|
+
'panel.copyDone': '已拷贝 {n} 条批注',
|
|
42
|
+
'panel.copyFailed': '拷贝失败:浏览器拒绝了剪贴板写入',
|
|
43
|
+
'panel.webPick': '拾取网页元素',
|
|
44
|
+
'panel.close': '关闭批注总览',
|
|
45
|
+
'panel.collapse': '收起或展开批注总览',
|
|
46
|
+
'webPick.missing': '没有找到内嵌浏览器,请先在侧栏打开网页。',
|
|
47
|
+
'panel.foot': '发送时批注作为独立块随消息提交',
|
|
48
|
+
'panel.sideTab': '在右侧边栏打开批注',
|
|
49
|
+
'panel.sideTabClose': '关闭右侧批注标签页',
|
|
50
|
+
'sideTab.title': '批注总览',
|
|
51
|
+
'sideTab.empty': '还没有批注',
|
|
52
|
+
'panel.refineFailed': '位置精修未生效:{reason}',
|
|
53
|
+
'settings.imagesOpen': '收起图片设置',
|
|
54
|
+
'settings.imagesClosed': '图片设置',
|
|
55
|
+
'settings.imagesOn': '压缩为 JPEG {n}%',
|
|
56
|
+
'settings.imagesOff': '不压缩,原样发送',
|
|
57
|
+
'settings.compress': ' 压缩图片(JPEG)',
|
|
58
|
+
'settings.quality': '质量 ',
|
|
59
|
+
'settings.minSizeBefore': '最短边超过 ',
|
|
60
|
+
'settings.minSizeAfter': ' 像素才压缩',
|
|
61
|
+
'settings.webShot': '网页元素批注自动截图 ',
|
|
62
|
+
'settings.webShotOff': '停用',
|
|
63
|
+
'settings.webShotElement': '仅目标元素本身',
|
|
64
|
+
'settings.webShotPage': '完整页面',
|
|
65
|
+
'settings.instructionOpen': '收起批注指令',
|
|
66
|
+
'settings.instructionClosed': '批注指令',
|
|
67
|
+
'settings.pageTitle': '批注指令',
|
|
68
|
+
'settings.adoptLabel': '「批注采纳」预填文本',
|
|
69
|
+
'settings.adoptHint': '采纳模式下自动写入批注正文的句子;输入前缀会出现补全提示。',
|
|
70
|
+
'settings.rejectLabel': '「批注否决」预填文本',
|
|
71
|
+
'settings.rejectHint': '否决模式下自动写入批注正文的句子,随后打开编辑面板补充理由。',
|
|
72
|
+
'settings.fallbackLabel': '空提示词填充',
|
|
73
|
+
'settings.fallbackHint': '只带批注、正文为空时自动填入;{count} 换成批注条数,{time} 换成发送时间。留空则使用默认文案。',
|
|
74
|
+
'settings.fallbackOpen': '收起空提示词设置',
|
|
75
|
+
'settings.fallbackClosed': '空提示词填充',
|
|
76
|
+
'settings.fallbackOff': '已关闭(正文为空时不填充)',
|
|
77
|
+
'settings.fallbackOn': '已启用',
|
|
78
|
+
'settings.fallbackField': '只带批注时自动填入的正文',
|
|
79
|
+
'settings.default': '默认文案',
|
|
80
|
+
'settings.customized': '已自定义',
|
|
81
|
+
'settings.restore': '恢复默认',
|
|
82
|
+
'settings.instrHint': '删掉「必须调用annotation_replies」那句会让逐条答复失效',
|
|
83
|
+
'settings.pageHint': '这段文字随每条批注一起发给模型。删掉「必须调用 annotation_replies」那句,逐条答复会失效。',
|
|
84
|
+
'settings.section.hint': '只读展示当前生效的设置;修改请到插件详情页的「划选批注」配置区。',
|
|
85
|
+
'settings.section.title': '划选批注',
|
|
86
|
+
'settings.section.imagesTitle': '图片随批注发送',
|
|
87
|
+
'settings.section.imagesHint': '批注里的图片会随这条批注一起发送;这里同时列出自动截图与压缩的当前取值。',
|
|
88
|
+
'settings.section.imagesSent': '随批注发送:是(手动添加或网页元素自动截图的图片都算)。',
|
|
89
|
+
'settings.section.imagesDetail': '网页元素自动截图:{shot};图片压缩:{compression}。',
|
|
90
|
+
'chip.emptyTitle': '还没有批注:选中正文或文件里的文字后点浮动「批注」',
|
|
91
|
+
'chip.title': '查看 / 管理批注',
|
|
92
|
+
'chip.label': '批注',
|
|
93
|
+
'chip.count': '批注 ×{n}',
|
|
94
|
+
'sent.title': '已发送批注 ×{n}',
|
|
95
|
+
'sent.unsynced': '未同步',
|
|
96
|
+
'sent.rewound': '已撤回',
|
|
97
|
+
'gate.failed': '批注没存进库,这条消息没有发出去',
|
|
98
|
+
'sent.reuse': '回放所有批注',
|
|
99
|
+
'sent.replayItem': '回放批注',
|
|
100
|
+
'sent.replayCopied': '因批注已被答复,当前仅将重放数据写入剪贴板,必要时可自主粘贴',
|
|
101
|
+
'reuse.hint': '按原样添加到待发送的批注队列',
|
|
102
|
+
'replies.title': '批注答复 ×{n}',
|
|
103
|
+
'replies.replay': '回放批注',
|
|
104
|
+
'replies.waiting': '批注答复:等待参数',
|
|
105
|
+
'markdown.copy': '复制',
|
|
106
|
+
'markdown.copied': '已复制',
|
|
107
|
+
'markdown.footnotes': '脚注',
|
|
108
|
+
'verdict.accepted': '采纳',
|
|
109
|
+
'verdict.partial': '部分采纳',
|
|
110
|
+
'verdict.rejected': '不采纳',
|
|
111
|
+
'verdict.needs_info': '需要澄清',
|
|
112
|
+
'verdict.unknown': '未判定',
|
|
113
|
+
'verdict.fallback': '答复',
|
|
114
|
+
'summary.accepted': '采纳 {n}',
|
|
115
|
+
'summary.partial': '部分 {n}',
|
|
116
|
+
'summary.rejected': '不采纳 {n}',
|
|
117
|
+
'summary.needsInfo': '需澄清 {n}',
|
|
118
|
+
'label.quote': '引用原文',
|
|
119
|
+
'label.note': '批注',
|
|
120
|
+
'label.answer': '答复',
|
|
121
|
+
'label.reason': '答复理由',
|
|
122
|
+
'label.next': '下一步',
|
|
123
|
+
'jump.label': '查看出处',
|
|
124
|
+
'jump.hint': '跳回这段引用的正文位置',
|
|
125
|
+
'jump.file': '这条出自工作区文件',
|
|
126
|
+
'jump.noAnchor': '这条找不到可定位的正文',
|
|
127
|
+
'jump.noReply': '没有可回访的答复',
|
|
128
|
+
'jump.noCard': '没有可回访的位置',
|
|
129
|
+
'jump.notLoaded': '第 {n} 轮还没加载',
|
|
130
|
+
'reply.index': '批注 {n}',
|
|
131
|
+
'reply.fallbackLabel': '批注 {n} · 答复',
|
|
132
|
+
'next.label': '接下来',
|
|
133
|
+
'next.prefix': '下一步:{text}',
|
|
134
|
+
expand: '点击展开全文',
|
|
135
|
+
'source.unknown': '未知出处',
|
|
136
|
+
'source.user': '用户消息',
|
|
137
|
+
'source.assistant': '助手回复',
|
|
138
|
+
'source.message': '{role}(锚点 {anchor})',
|
|
139
|
+
'source.file': '工作区文件 `{path}`{where}',
|
|
140
|
+
'source.lineRange': ' 第 {a}—{b} 行',
|
|
141
|
+
'source.lineSingle': ' 第 {n} 行',
|
|
142
|
+
'source.pathUnknown': '(未知路径)',
|
|
143
|
+
'source.replyField': '整条答复',
|
|
144
|
+
'source.sentField': '整条批注',
|
|
145
|
+
'source.reply': '逐条答复 · 批注 {index} · {field}(锚点 {anchor}{span})',
|
|
146
|
+
'source.sent': '已发送批注 · 批注 {index} · {field}(锚点 {anchor}{span})',
|
|
147
|
+
'source.web': '网页 `{url}` · 选择器 `{selector}`',
|
|
148
|
+
'source.webShort': '网页 · {url}',
|
|
149
|
+
'source.span': ',字符 {a}–{b}',
|
|
150
|
+
'source.selection': '页面选区',
|
|
151
|
+
'source.fileFallback': '文件',
|
|
152
|
+
'source.replyShort': '批注 {n} 的答复',
|
|
153
|
+
'source.sentShort': '已发送批注 {n}',
|
|
154
|
+
'source.rendered': '(渲染坐标)',
|
|
155
|
+
},
|
|
156
|
+
en: {
|
|
157
|
+
annotate: 'Feedback',
|
|
158
|
+
'annotate.adopt': 'Adopt',
|
|
159
|
+
'annotate.reject': 'Reject',
|
|
160
|
+
'annotate.copy': 'Copy',
|
|
161
|
+
'menu.annotate': 'Feedback on selection',
|
|
162
|
+
'menu.adopt': 'Adopt selection',
|
|
163
|
+
'menu.reject': 'Reject selection',
|
|
164
|
+
'menu.copy': 'Copy',
|
|
165
|
+
'viewer.alt': 'Annotated image',
|
|
166
|
+
'image.alt': 'Image',
|
|
167
|
+
'image.open': 'Click to view full size',
|
|
168
|
+
'image.remove': 'Remove this image',
|
|
169
|
+
'pop.placeholder': 'Add a note (optional — you can just mark the text)',
|
|
170
|
+
'pop.noteLabel': 'Comment',
|
|
171
|
+
'pop.imagesHint': 'Paste or drop images to send with this annotation',
|
|
172
|
+
'pop.delete': 'Delete',
|
|
173
|
+
'pop.cancel': 'Cancel',
|
|
174
|
+
'pop.save': 'Save',
|
|
175
|
+
'pop.createTitle': 'New annotation',
|
|
176
|
+
'pop.editTitle': 'Edit annotation #{n}',
|
|
177
|
+
'pop.sentTitle': 'Sent annotation',
|
|
178
|
+
'pop.noNote': 'No note',
|
|
179
|
+
'pop.resize': 'Resize panel',
|
|
180
|
+
'panel.empty': 'Select text in a reply, message, or file preview, then click the floating “Feedback”.',
|
|
181
|
+
'panel.title': 'Annotations',
|
|
182
|
+
'panel.count': '{n} items',
|
|
183
|
+
'panel.drag': 'Drag to reorder',
|
|
184
|
+
'panel.edit': 'Edit',
|
|
185
|
+
'panel.delete': 'Delete',
|
|
186
|
+
'panel.quote': 'Quoted text',
|
|
187
|
+
'panel.note': 'Note',
|
|
188
|
+
'panel.clear': 'Clear',
|
|
189
|
+
'panel.copyAll': 'Copy',
|
|
190
|
+
'panel.paste': 'Paste',
|
|
191
|
+
'panel.copy': 'Copy',
|
|
192
|
+
'panel.pasteFailed': 'No annotation data in the clipboard',
|
|
193
|
+
'panel.pasteDone': 'Imported {n} annotations',
|
|
194
|
+
'panel.pasteNothing': 'No new annotations to paste',
|
|
195
|
+
'panel.copyDone': 'Copied {n} annotations',
|
|
196
|
+
'panel.copyFailed': 'Copy failed: the browser refused the clipboard write',
|
|
197
|
+
'panel.webPick': 'Pick page element',
|
|
198
|
+
'panel.close': 'Close annotations',
|
|
199
|
+
'panel.collapse': 'Collapse or expand annotations',
|
|
200
|
+
'webPick.missing': 'No embedded browser found. Open a page in the sidebar first.',
|
|
201
|
+
'panel.foot': 'Annotations are sent as a separate block with the message',
|
|
202
|
+
'panel.sideTab': 'Open annotations in the right sidebar',
|
|
203
|
+
'panel.sideTabClose': 'Close the annotations sidebar tab',
|
|
204
|
+
'sideTab.title': 'Annotations', 'sideTab.empty': 'No annotations yet',
|
|
205
|
+
'panel.refineFailed': 'Position refinement failed: {reason}',
|
|
206
|
+
'settings.imagesOpen': 'Hide image settings',
|
|
207
|
+
'settings.imagesClosed': 'Image settings',
|
|
208
|
+
'settings.imagesOn': 'Compress to JPEG {n}%',
|
|
209
|
+
'settings.imagesOff': 'Send originals without compression',
|
|
210
|
+
'settings.compress': ' Compress images (JPEG)',
|
|
211
|
+
'settings.quality': 'Quality ',
|
|
212
|
+
'settings.minSizeBefore': 'Compress only when the shortest side exceeds ',
|
|
213
|
+
'settings.minSizeAfter': ' px',
|
|
214
|
+
'settings.webShot': 'Auto screenshot for web page annotations ',
|
|
215
|
+
'settings.webShotOff': 'Off',
|
|
216
|
+
'settings.webShotElement': 'Target element only',
|
|
217
|
+
'settings.webShotPage': 'Full page',
|
|
218
|
+
'settings.instructionOpen': 'Hide annotation instruction',
|
|
219
|
+
'settings.instructionClosed': 'Annotation instruction',
|
|
220
|
+
'settings.pageTitle': 'Annotation instruction',
|
|
221
|
+
'settings.adoptLabel': 'Prefilled “Adopt” text',
|
|
222
|
+
'settings.adoptHint': 'Written into the note in Adopt mode; typing a prefix shows an inline completion.',
|
|
223
|
+
'settings.rejectLabel': 'Prefilled “Reject” text',
|
|
224
|
+
'settings.rejectHint': 'Written into the note in Reject mode; the editor opens so you can add a reason.',
|
|
225
|
+
'settings.fallbackLabel': 'Empty prompt fallback',
|
|
226
|
+
'settings.fallbackHint': 'Filled into the message body when you send only annotations and the prompt is empty. {count} becomes the annotation count, {time} the send time. Leave it empty to use the default text.',
|
|
227
|
+
'settings.fallbackOpen': 'Hide empty prompt fallback',
|
|
228
|
+
'settings.fallbackClosed': 'Empty prompt fallback',
|
|
229
|
+
'settings.fallbackOff': 'Off (nothing is filled when the prompt is empty)',
|
|
230
|
+
'settings.fallbackOn': 'On',
|
|
231
|
+
'settings.fallbackField': 'Body filled when only annotations are attached',
|
|
232
|
+
'settings.default': 'Default text',
|
|
233
|
+
'settings.customized': 'Customized',
|
|
234
|
+
'settings.restore': 'Restore default',
|
|
235
|
+
'settings.instrHint': 'Removing the sentence that requires annotation_replies disables per-annotation replies',
|
|
236
|
+
'settings.pageHint': 'This text is sent to the model with every annotation. Removing the sentence that requires annotation_replies disables per-annotation replies.',
|
|
237
|
+
'settings.section.hint': 'Read-only view of the settings in effect; edit them in the “Selection annotations” section on the plugin detail page.',
|
|
238
|
+
'settings.section.title': 'Selection annotations',
|
|
239
|
+
'settings.section.imagesTitle': 'Images sent with annotations',
|
|
240
|
+
'settings.section.imagesHint': 'Images attached to an annotation are sent with it; the current auto-screenshot and compression values are listed here.',
|
|
241
|
+
'settings.section.imagesSent': 'Sent with annotations: yes (images you add or that are captured for a web annotation).',
|
|
242
|
+
'settings.section.imagesDetail': 'Auto screenshot for web annotations: {shot}; image compression: {compression}.',
|
|
243
|
+
'chip.emptyTitle': 'No annotations yet: select text in the body or a file, then click the floating “Feedback”',
|
|
244
|
+
'chip.title': 'View / manage annotations',
|
|
245
|
+
'chip.label': 'Annotate',
|
|
246
|
+
'chip.count': 'Annotate ×{n}',
|
|
247
|
+
'sent.title': 'Sent annotations ×{n}',
|
|
248
|
+
'sent.unsynced': 'Not synced',
|
|
249
|
+
'sent.rewound': 'Withdrawn',
|
|
250
|
+
'gate.failed': 'Annotations were not saved, so this message was not sent',
|
|
251
|
+
'sent.reuse': 'Replay all annotations',
|
|
252
|
+
'sent.replayItem': 'Replay annotation',
|
|
253
|
+
'sent.replayCopied': 'This annotation has already been answered, so the replay data was copied to the clipboard only — paste it yourself if needed',
|
|
254
|
+
'reuse.hint': 'Add to the pending annotation queue as-is',
|
|
255
|
+
'replies.title': 'Annotation replies ×{n}',
|
|
256
|
+
'replies.replay': 'Replay annotation',
|
|
257
|
+
'replies.waiting': 'Annotation replies: waiting for arguments',
|
|
258
|
+
'markdown.copy': 'Copy',
|
|
259
|
+
'markdown.copied': 'Copied',
|
|
260
|
+
'markdown.footnotes': 'Footnotes',
|
|
261
|
+
'verdict.accepted': 'Accepted',
|
|
262
|
+
'verdict.partial': 'Partially accepted',
|
|
263
|
+
'verdict.rejected': 'Rejected',
|
|
264
|
+
'verdict.needs_info': 'Needs clarification',
|
|
265
|
+
'verdict.unknown': 'Unrated',
|
|
266
|
+
'verdict.fallback': 'Reply',
|
|
267
|
+
'summary.accepted': 'Accepted {n}',
|
|
268
|
+
'summary.partial': 'Partial {n}',
|
|
269
|
+
'summary.rejected': 'Rejected {n}',
|
|
270
|
+
'summary.needsInfo': 'Needs clarification {n}',
|
|
271
|
+
'label.quote': 'Quoted text',
|
|
272
|
+
'label.note': 'Note',
|
|
273
|
+
'label.answer': 'Reply',
|
|
274
|
+
'label.reason': 'Reason',
|
|
275
|
+
'label.next': 'Next step',
|
|
276
|
+
'jump.label': 'View source',
|
|
277
|
+
'jump.hint': 'Jump back to where this quote came from',
|
|
278
|
+
'jump.file': 'This one comes from a workspace file',
|
|
279
|
+
'jump.noAnchor': 'No locatable text for this one',
|
|
280
|
+
'jump.noReply': 'No reply to return to',
|
|
281
|
+
'jump.noCard': 'No annotation card to return to',
|
|
282
|
+
'jump.notLoaded': 'Turn {n} is not loaded yet',
|
|
283
|
+
'reply.index': 'Annotation {n}',
|
|
284
|
+
'reply.fallbackLabel': 'Annotation {n} · reply',
|
|
285
|
+
'next.label': 'Next',
|
|
286
|
+
'next.prefix': 'Next step: {text}',
|
|
287
|
+
expand: 'Click to expand',
|
|
288
|
+
'source.unknown': 'Unknown source',
|
|
289
|
+
'source.user': 'User message',
|
|
290
|
+
'source.assistant': 'Assistant reply',
|
|
291
|
+
'source.message': '{role} (anchor {anchor})',
|
|
292
|
+
'source.file': 'Workspace file `{path}`{where}',
|
|
293
|
+
'source.lineRange': ' lines {a}–{b}',
|
|
294
|
+
'source.lineSingle': ' line {n}',
|
|
295
|
+
'source.pathUnknown': '(unknown path)',
|
|
296
|
+
'source.replyField': 'Entire reply',
|
|
297
|
+
'source.sentField': 'Entire annotation',
|
|
298
|
+
'source.reply': 'Annotation reply · annotation {index} · {field} (anchor {anchor}{span})',
|
|
299
|
+
'source.sent': 'Sent annotation · annotation {index} · {field} (anchor {anchor}{span})',
|
|
300
|
+
'source.web': 'Web page `{url}` · selector `{selector}`',
|
|
301
|
+
'source.webShort': 'Web · {url}',
|
|
302
|
+
'source.span': ', chars {a}–{b}',
|
|
303
|
+
'source.selection': 'Page selection',
|
|
304
|
+
'source.fileFallback': 'File',
|
|
305
|
+
'source.replyShort': 'Reply to annotation {n}',
|
|
306
|
+
'source.sentShort': 'Sent annotation {n}',
|
|
307
|
+
'source.rendered': ' (rendered position)',
|
|
308
|
+
},
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** 当前语言的语言标签;没有 locale 服务时固定中文。*/
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 批注备注里的「采纳 / 否决」是两个互相独立的判定:一条备注可以同时含两句。
|
|
3
|
+
* 颜色一律由这两个布尔推导,不引入「采纳 / 否决 / 两者」这种三选一状态字段。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** 备注是否含各自的预填关键句。 */
|
|
7
|
+
export function noteFlags(note, adoptText, rejectText) {
|
|
8
|
+
const text = typeof note === 'string' ? note : ''
|
|
9
|
+
return {
|
|
10
|
+
adopt: typeof adoptText === 'string' && adoptText !== '' && text.includes(adoptText),
|
|
11
|
+
reject: typeof rejectText === 'string' && rejectText !== '' && text.includes(rejectText),
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function indexFrom(text, phrase, from) {
|
|
16
|
+
if (typeof phrase !== 'string' || phrase === '') return -1
|
|
17
|
+
return text.indexOf(phrase, from)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 把备注切成「普通文本 / 采纳句 / 否决句」片段,按出现顺序排列。
|
|
22
|
+
* 只给同时命中两句的情况用;单一命中时由容器按整条着色,观感与既有采纳一致。
|
|
23
|
+
*/
|
|
24
|
+
export function noteSegments(note, adoptText, rejectText) {
|
|
25
|
+
const text = typeof note === 'string' ? note : ''
|
|
26
|
+
const segments = []
|
|
27
|
+
let cursor = 0
|
|
28
|
+
while (cursor < text.length) {
|
|
29
|
+
const adoptAt = indexFrom(text, adoptText, cursor)
|
|
30
|
+
const rejectAt = indexFrom(text, rejectText, cursor)
|
|
31
|
+
const at = adoptAt === -1 ? rejectAt : rejectAt === -1 ? adoptAt : Math.min(adoptAt, rejectAt)
|
|
32
|
+
if (at === -1) {
|
|
33
|
+
segments.push({ text: text.slice(cursor), tone: '' })
|
|
34
|
+
break
|
|
35
|
+
}
|
|
36
|
+
const tone = adoptAt !== -1 && at === adoptAt ? 'adopt' : 'reject'
|
|
37
|
+
const phrase = tone === 'adopt' ? adoptText : rejectText
|
|
38
|
+
if (at > cursor) segments.push({ text: text.slice(cursor, at), tone: '' })
|
|
39
|
+
segments.push({ text: phrase, tone })
|
|
40
|
+
cursor = at + phrase.length
|
|
41
|
+
}
|
|
42
|
+
return segments
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 备注的渲染视图:两个布尔 + 逐句片段(只在两者同时命中时给出片段)。 */
|
|
46
|
+
export function noteView(note, adoptText, rejectText) {
|
|
47
|
+
const flags = noteFlags(note, adoptText, rejectText)
|
|
48
|
+
return {
|
|
49
|
+
adopt: flags.adopt,
|
|
50
|
+
reject: flags.reject,
|
|
51
|
+
segments: flags.adopt && flags.reject ? noteSegments(note, adoptText, rejectText) : null,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 把备注写进一个块:两个布尔落到 data 属性,两句同时出现时逐句着色。 */
|
|
56
|
+
export function paintNote(node, text, view) {
|
|
57
|
+
const adopt = view !== null && view !== undefined && view.adopt === true
|
|
58
|
+
const reject = view !== null && view !== undefined && view.reject === true
|
|
59
|
+
node.dataset.adopt = adopt ? '1' : '0'
|
|
60
|
+
node.dataset.reject = reject ? '1' : '0'
|
|
61
|
+
node.textContent = ''
|
|
62
|
+
const segments = view === null || view === undefined ? null : view.segments
|
|
63
|
+
if (!Array.isArray(segments)) {
|
|
64
|
+
node.textContent = text
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
for (const segment of segments) {
|
|
68
|
+
if (segment.tone === '') {
|
|
69
|
+
node.appendChild(document.createTextNode(segment.text))
|
|
70
|
+
continue
|
|
71
|
+
}
|
|
72
|
+
const span = document.createElement('span')
|
|
73
|
+
span.className = segment.tone === 'reject' ? 'sa-note-reject' : 'sa-note-adopt'
|
|
74
|
+
span.textContent = segment.text
|
|
75
|
+
node.appendChild(span)
|
|
76
|
+
}
|
|
77
|
+
}
|