Skip to content

Allow selecting and copying text in preview and source markdown views - #460

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
strayge:fix/markdown-text-selection
Nov 15, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
strayge:fix/markdown-text-selection

Conversation

@strayge

@strayge strayge commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Text in a Markdown pane cannot be selected, in either preview or source mode, so nothing shown there can be copied except through the toolbar's whole-document Copy button.

Change

  • .markdown-pane__content (preview) and .markdown-pane__source (source view, including the single <pre> used for very large files) set user-select: text.
  • The per-code-block Copy button is user-select: none, so its label is not copied along with the code.
  • A blank line in the source view renders a <br> instead of a space. A space was copied as a trailing space on every blank line, and an empty span drops the line from the copied text altogether.

Copying uses Electron's default Edit menu (Ctrl+C) and wmux's existing Ctrl+Shift+C shortcut; neither needed changes.

Testing

  • npm test: 414 files passed, 2 skipped; 6701 tests passed, 10 skipped. No existing test covers the Markdown pane, and jsdom cannot exercise selection, so no test was added.
  • npm run typecheck and eslint on MarkdownPane.tsx are clean.
  • Checked by hand in wmux:
    • In preview, selecting across headings, lists, a table and a code block and copying works.
    • Double-click selects a word and triple-click a line.

Known limitations

  • List bullets and numbers are not copied. They are drawn by CSS (::marker), not text, and Chromium leaves them out of plain-text copies. Restoring them would take a custom copy handler.
  • Links: a drag that starts on a link drags the link instead of selecting text, and double-clicking a link opens it on the first click.
  • Math and diagrams: rendered KaTeX math and mermaid diagrams may not copy as readable text.

The app disables text selection on <html>, and Chromium passes that down,
so nothing in a Markdown pane could be selected. The preview and source
views now opt back in. The code-block Copy button is excluded so its label
is not copied with the code, and a blank source line renders a <br> instead
of a space, so a copied selection keeps blank lines without trailing
spaces.
@amirlehmam
amirlehmam merged commit 42c6df4 into amirlehmam:master Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants