返回目录
模型与 MCP 插件

dsh-md-editor

Yzz25/dsh-md-editor

Edit workspace Markdown files directly in the DeepSeek Harness right Sidebar.

Stars
0
Forks
0
Issues
0
更新
7 天前

PROJECT TOPICS

项目标签

INSTALL REFERENCE

安装参考

未验证
dsh plugin --profile web add github:Yzz25/dsh-md-editor

该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。

PROJECT README

README

dsh-md-editor

Edit workspace Markdown files in the DeepSeek Harness right Sidebar.

A .md or .markdown file opened from the file tree lands in a CodeMirror 6 editor with syntax highlighting, line numbers, undo/redo, find, Tab indentation, and list continuation on Enter. Text is selected and copied with the browser's own selection, so drag-select, double-click, Ctrl+A, and Ctrl+C behave like any other page. Saving is automatic (800 ms after the last keystroke, on blur, and when the tab goes away); Ctrl+S always saves now.

  • Where it runs — as one implementation of the built-in document preview (documentPreviews, extensions: ['md', 'markdown'], loading: 'renderer'), so the shipped tab, path header, reload button, wrap toggle, and viewer menu stay in place. Pick the shipped Markdown viewer in the toolbar's viewer menu to read the rendered document again. The body reads the file itself and keeps rendering while the shell reloads content, so a save never rebuilds the editor — scroll offset, caret, focus, and an in-progress input-method composition all survive.
  • The write channel — the Sidebar's file Remote is read-only, so the Host half adds POST /md-editor: re-authorized on every request (ctx.connection.requestRejection), fenced to the Session's workspace (ctx.fs.contains), and written with ctx.fs.writeText under a replaceIfVersion guard plus the Session's sandbox policy.
  • Fidelity — the byte-order mark, the line-ending style, and the trailing newline are restored on write, so an edit is a one-line diff.
  • Input methods — an unfinished composition is never written or replaced: the save and any external re-read wait for compositionend, so composed characters cannot be lost.
  • Limits — workspace files only, at most 2 MiB and 5000 lines, uniform LF/CRLF only, and no writes without permission. Everything else stays visible but read-only with the reason in a banner. A file that changed on disk while edits were pending is never overwritten silently: the conflict banner offers Keep mine or Use disk.
  • No extra network access, no model requests. The plugin registers no tool, prompt section, or session event; it never persists document content outside the file itself.
  • Text size — the status bar's A- / A+ control resizes the editor text between 11 and 24 px. The choice is remembered for the profile's browser and applies to every open editor at once.

Build

The browser half is a generated bundle:

pnpm install --node-linker=hoisted
node build.mjs

client.js is the build output — a window.__ModuleLoader__.load({ id, factory }) call whose factory returns the plugin exports, with React (and only React) kept external for the page's module table.

Install

Install the directory as a local bundle and enable Markdown 编辑器 / Markdown editor in Plugins. The Host half adds the /md-editor route; the browser half activates once the document preview is loaded.

Usage (中文说明)

The complete Chinese guide — interface, shortcuts, autosave versus manual save, text size, conflict handling, read-only cases, fidelity rules, and uninstalling — lives in docs/USAGE.zh.md.

License

MIT — see LICENSE.

When the body does re-mount

A save no longer rebuilds the editor: renderer-mode bodies survive the shell's content reloads. The body still unmounts when the tab itself goes away (another tab selected, pane closed), so it remembers per resource address the caret, the scroll offset, the focus, and whether the text was unsaved:

  • same text as before: the caret, scroll, focus, and save status come back;
  • unsaved edits and a different disk text: the edits come back with the conflict banner already open, so neither side is lost silently.

Two details make that scroll restoration honest. The offset is recorded by a scroll listener rather than read when the component is disposed, because a passive cleanup runs after React detached the DOM, where scrollTop reads 0. The restore itself runs after the shell claimed the scrollport — the shell applies its own remembered offset there, measured against whatever renderer held the tab before — and the surface is then held at that offset for about a second: CodeMirror measures line heights asynchronously and re-scrolls from those measurements, so a fixed set of passes is not enough. A wheel, touch, mouse press, key press, or a deliberate layout change (wrap, text size, line navigation) ends the hold immediately, so the reader always wins. Wrapping is applied when the view is created so a mount never reflows the text right after the offset was restored.

An external change reaches a live editor as an in-place document replacement (the body is not rebuilt); that replacement keeps the scroll offset too, because CodeMirror scrolls a moved selection into view.

Only uniform LF or CRLF files are editable. A file with mixed terminators stays readable but read-only: rewriting it as a whole file would change lines nobody edited, which the fidelity rule forbids.

CLASSIFICATION EVIDENCE

分类依据

项目类型插件
功能分类模型与 MCP
规则置信度中

系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek-harness。