Introduction

In the DSH ecosystem, handling code and configuration files usually requires separate viewers or editors. As a client-side plugin, dock-editor solves the problems of read-only viewers and general-purpose editors that are hard to integrate. It registers itself as the default viewer and provides a unified editing experience through CodeMirror 6.

What It Is

dock-editor is a MIT-licensed text editing plugin maintained by developer AKS1st. It aims to provide DSH users with a fully featured editing environment, supporting core capabilities such as syntax highlighting, undo/redo, file saving, and unsaved changes confirmation.

Core Features

The plugin implements the following core capabilities through CodeMirror 6:

  • Code and configuration highlighting: Supports syntax highlighting for code/configuration files with extensions such as ts/js/json/yaml/toml/ini/css/html/xml/py/sh. It provides line numbers, bracket matching, real-time syntax highlighting, and incremental parsing.
  • VSCode-style search: The search panel is located at the top-right corner of the editor (independent of the CodeMirror panel). It supports Ctrl+F for find, Ctrl+H for replace, and F3/Shift+F3 for jumping. It supports real-time match highlighting, match counts, and navigating up/down. When scrolling, only the editing area scrolls.
  • Editing and shortcuts: Supports Ctrl+S to save, Ctrl+Z/Ctrl+Y to undo/redo, and Ctrl+C/V/X/A to copy/paste/select all. It also supports Alt+↑/↓ to move lines and Ctrl+/ to comment.
  • Security restrictions:
    • Size limit: A single file is limited to 256 KiB when read. Files exceeding the limit show only the first 256 KiB, and saving is disabled.
    • Path restrictions: Reading is not limited to the session workspace (external files can be viewed); writing is limited to the session workspace. Out-of-bounds writes return a 403 error.
    • Binary detection: NUL bytes are detected when reading, so binary files display a notice instead of garbled content.
  • Interaction details: A confirmation dialog appears when closing a window with unsaved changes; the position and size of the floating panel are remembered; automatic line wrapping is enabled by default.

Installation and Enablement

Use the DSH CLI to install:

dsh plugin --profile web add dock-editor

Prerequisites: Requires dock >= 0.1.0 and dock-files >= 0.1.0.

Typical Usage

  • Edit code: Click a file in the file list to enter edit mode directly and enjoy syntax highlighting and automatic completion.
  • Search and replace: Press Ctrl+F in the editor to open the search box. After entering content, use ↑/↓ to switch matches, Enter to lock, and ⇄ to expand/collapse the replace panel.
  • Save file: Press Ctrl+S to save after modifications, or roll back changes with Ctrl+Z.

Applicable Scenarios and Notes

  • Platform requirement: The client platform is Web.
  • Optional dependency: React ^18.2.0 is optional. If not installed, the editor UI remains inactive.
  • Performance overhead: The editor bundle is approximately 1.12 MB, with a gzipped size of about 300 KB.
  • Security note: The /desk-editor route only accepts POST requests from trusted sources (loopback addresses / trustedHosts + same-origin checks).

Summary

dock-editor provides DSH with unified text processing capabilities, from simple configuration viewing to complex code editing. It delivers an experience close to a native IDE through CodeMirror 6.

Plugin directory | GitHub repository