dsh-enhance 0.3.3 → 0.3.4
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 +3 -3
- package/lib/client.js +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ DeepSeek Harness(DSH)增强插件:Markdown 主题统一、划词批注、
|
|
|
5
5
|
## 功能
|
|
6
6
|
|
|
7
7
|
- **Markdown 主题** — 统一主对话、侧栏对话、文件预览等所有 `MarkdownText` 渲染的排版:标题配色、加粗、行内代码、代码块、表格、引用块。浅色/深色两套配色自动跟随主题。
|
|
8
|
-
- **划词批注** — 选中文字弹出小面板写一句要求(Enter 确认,Esc
|
|
8
|
+
- **划词批注** — 选中文字弹出小面板写一句要求(Enter 确认,Esc 取消;弹窗出现即自动聚焦输入框,光标落在末尾)。面板打开期间 `Cmd/Ctrl+C` 复制的仍是刚选中的段落(在输入框内自己选中文字时,复制的就是输入框里的那段)。确认后汇总为输入框内的 `N annotations` 胶囊:
|
|
9
9
|
- 悬停胶囊展开列表,每行显示要求与引文
|
|
10
10
|
- 悬停行会在正文高亮对应段落,点击行滚动定位到原文
|
|
11
11
|
- 每行右侧可编辑(弹窗)或删除,胶囊右侧一键清空
|
|
@@ -31,9 +31,9 @@ DSH 打开 **Plugins** 页面 → 添加插件 → 输入 `dsh-enhance` → 安
|
|
|
31
31
|
### 方式二:本地 tar 包
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
# 从 Releases 下载 dsh-enhance-0.3.
|
|
34
|
+
# 从 Releases 下载 dsh-enhance-0.3.4.tgz 后
|
|
35
35
|
cd ~/.dsh/profiles/desktop
|
|
36
|
-
npx pnpm@11.28.5 add "file:/绝对路径/dsh-enhance-0.3.
|
|
36
|
+
npx pnpm@11.28.5 add "file:/绝对路径/dsh-enhance-0.3.4.tgz"
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
再编辑 `~/.dsh/profiles/desktop/package.json`,把 `dsh-enhance` 加入 `dsh.profile.bundles`:
|
package/lib/client.js
CHANGED
|
@@ -2675,6 +2675,23 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
2675
2675
|
return collapsed.length > 8e3 ? collapsed.slice(0, MAX_SELECTION_CHARS) : collapsed;
|
|
2676
2676
|
}
|
|
2677
2677
|
/**
|
|
2678
|
+
* Text the copy shortcut should carry while the annotation popover is open.
|
|
2679
|
+
*
|
|
2680
|
+
* Opening the popover focuses the note field, and focusing a field takes the
|
|
2681
|
+
* document selection with it: Cmd+C then copies an empty box instead of the
|
|
2682
|
+
* words the reader just highlighted. So while the field holds no selection of
|
|
2683
|
+
* its own, the copy carries the marked passage; the moment the reader selects
|
|
2684
|
+
* text inside the field, the native copy is the one they asked for.
|
|
2685
|
+
* @param passage - the marked passage, when the popover is showing one.
|
|
2686
|
+
* @param field - the note field, once the popover has rendered it.
|
|
2687
|
+
* @returns text to write to the clipboard, or undefined to leave the copy alone.
|
|
2688
|
+
*/
|
|
2689
|
+
function copyTextFor(passage, field) {
|
|
2690
|
+
if (passage === void 0 || passage.length === 0) return void 0;
|
|
2691
|
+
if (field !== null && field.selectionStart !== field.selectionEnd) return void 0;
|
|
2692
|
+
return passage;
|
|
2693
|
+
}
|
|
2694
|
+
/**
|
|
2678
2695
|
* Place a `width`-wide box below (or above) an anchor rect, clamped into the viewport.
|
|
2679
2696
|
* @param anchor - the selection rectangle.
|
|
2680
2697
|
* @param width - toolbar width in CSS pixels.
|
|
@@ -3257,6 +3274,22 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
3257
3274
|
const onKey = (event) => {
|
|
3258
3275
|
if (event.key === "Escape") dismiss();
|
|
3259
3276
|
};
|
|
3277
|
+
/**
|
|
3278
|
+
* Keep Cmd/Ctrl+C working on the passage the popover just took focus from.
|
|
3279
|
+
*
|
|
3280
|
+
* The popover focuses the note field as it opens, which moves the document
|
|
3281
|
+
* selection into that field — a copy then finds an empty box and the reader
|
|
3282
|
+
* loses the words they highlighted. While the field holds no selection of
|
|
3283
|
+
* its own, the copy is answered with the marked passage instead; a selection
|
|
3284
|
+
* made inside the field still goes through the browser's own copy.
|
|
3285
|
+
*/
|
|
3286
|
+
const onCopy = (event) => {
|
|
3287
|
+
if (event.defaultPrevented) return;
|
|
3288
|
+
const text = copyTextFor(latest.current?.text, input.current);
|
|
3289
|
+
if (text === void 0) return;
|
|
3290
|
+
event.clipboardData?.setData("text/plain", text);
|
|
3291
|
+
event.preventDefault();
|
|
3292
|
+
};
|
|
3260
3293
|
const onScroll = (event) => {
|
|
3261
3294
|
if (isInsidePopover(event.target)) return;
|
|
3262
3295
|
dismiss();
|
|
@@ -3264,12 +3297,14 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
|
|
|
3264
3297
|
for (const name of SETTLE_EVENTS) document.addEventListener(name, settle, true);
|
|
3265
3298
|
document.addEventListener("selectionchange", onChange);
|
|
3266
3299
|
document.addEventListener("keydown", onKey, true);
|
|
3300
|
+
document.addEventListener("copy", onCopy);
|
|
3267
3301
|
window.addEventListener("scroll", onScroll, true);
|
|
3268
3302
|
window.addEventListener("resize", dismiss);
|
|
3269
3303
|
return () => {
|
|
3270
3304
|
for (const name of SETTLE_EVENTS) document.removeEventListener(name, settle, true);
|
|
3271
3305
|
document.removeEventListener("selectionchange", onChange);
|
|
3272
3306
|
document.removeEventListener("keydown", onKey, true);
|
|
3307
|
+
document.removeEventListener("copy", onCopy);
|
|
3273
3308
|
window.removeEventListener("scroll", onScroll, true);
|
|
3274
3309
|
window.removeEventListener("resize", dismiss);
|
|
3275
3310
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-enhance",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "DeepSeek Harness enhancements: Markdown theme for every renderer, select-text annotations with pins, a narrower sidebar, and startup defaults (maximized window, narrowest sidebar, colourful running marker). 中文:DSH 增强插件——Markdown 主题、划词批注、侧栏宽度、启动默认状态。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|