dsh-copy-document-preview
界面增强 活跃维护

dsh-copy-document-preview

shellpower96/dsh-copy-document-preview

在侧边栏文档预览上加一枚一键复制按钮,点击即把当前预览文件的文本内容写入剪贴板;遇到二进制文件则自动复制其完整路径,无需手动选中或另存。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
JavaScript
主要语言
MIT
开源协议
16 KB
仓库大小
1 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:shellpower96/dsh-copy-document-preview
git clone https://github.com/shellpower96/dsh-copy-document-preview.git
git clone git@github.com:shellpower96/dsh-copy-document-preview.git
README.md main

dsh-copy-document-preview

One-click copy button for the DeepSeek Harness sidebar document preview.

The official preview header shows the path, the renderer picker, the wrap toggle
and Reload — but nothing that gets the document out of the pane. This plugin adds
one button there: click it and the previewed file's text is on your clipboard.

English | 中文

What it does

  • A copy button in the document preview header, rendered after the preview's own
    controls and after Open in app.
  • Copies the whole file, not just the part the preview has loaded: the plugin reads
    the file through the harness's own paged file Remote (remote.workspaceFiles.read),
    the same reader the preview itself uses, and never bypasses the Session that owns
    the file.
  • Binary files copy their path instead. For a PDF, image or Office document the
    Host reports workspace-file/not-text; the button then copies the file's absolute
    path and says so, rather than failing silently.
  • Clear feedback. A check mark for two seconds after a successful copy, a warning
    mark and a reason on failure, both announced to assistive technology.
  • Text files copy their text. Markdown, plain text and code files are copied as
    their source text; the copy does not include the preview's line numbers.
Preview What lands on the clipboard
Plain text, Markdown, code, logs The file's full text
CSV / TSV / JSON / YAML The file's full text
PDF, image, Office (.docx, .xlsx, .pptx), zip, binary The file's absolute path

Install

From the npm registry:

dsh plugin --profile web add dsh-copy-document-preview

Straight from GitHub:

dsh plugin --profile web add github:shellpower96/dsh-copy-document-preview

If your machine has no GitHub SSH key, use the HTTPS form of the same repository:

dsh plugin --profile web add https://github.com/shellpower96/dsh-copy-document-preview.git#main

Then restart dsh web. Alternatively install it from the Plugin Market or the
Plugin Manager, which also enables the bundle for you.

Remove it with:

dsh plugin --profile web remove dsh-copy-document-preview

How it works

The plugin has no build step and no runtime dependencies. Its browser half registers
one entry in the document toolbar's additive list slot
(sidebar.right.tab.document.actions), a slot that only appends, so no existing
control is replaced.

  • The slot hands the entry the file's absolutePath; the Session id, the locale
    function and the standard hooks come from the slot runtime.
  • Reading uses remote.workspaceFiles.read(sessionId, path, { offset }, signal), the
    same Remote the preview uses, so the file is read with the previewing Session's own
    authority and the host's byte and line limits still apply.
  • The browser half never imports a Harness Client package, styles itself with the
    host's --dsw-alias-* theme tokens (so it follows light and dark mode), and routes
    every visible string through the client locale service (English and Simplified
    Chinese).
  • Nothing is written outside the plugin's own component, and the button is the only
    DOM it owns.

Limitations

  • The clipboard write uses navigator.clipboard, so the page must be a secure
    context (https:// or http://127.0.0.1) and focused. There is no
    execCommand('copy') fallback.
  • A file larger than the host's per-page limits (maxLines, maxBytes) fails with
    the host's own too-large error, and so does a file with more than 200 pages.
  • Binary files copy their path; the plugin cannot extract text from them.

License

MIT