fix: #2029 preserve selected text when pasting a URL by Jocs · Pull Request #5755 · marktext/marktext · GitHub
Skip to content

fix: #2029 preserve selected text when pasting a URL - #5755

Merged
Jocs merged 3 commits into
developfrom
fix/2029-paste-url-over-selection
Oct 15, 2026
Merged

Jocs merged 3 commits into
developfrom
fix/2029-paste-url-over-selection

Conversation

@Jocs

@Jocs Jocs commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Closes #2029

Summary

Pasting a single HTTP(S) URL over selected text in the WYSIWYG editor now keeps that text as the link label. For example, selecting bar in foo bar foo and pasting https://home.com produces foo [bar](https://home.com) foo.

The change supports safe inline selections in paragraphs, headings, lists, quotes, and individual table cells. Plain-text paste still replaces the selection. Code, existing links/images/math, cross-block selections, and partially selected formatting keep their existing paste behavior. One undo restores both the original text and selection.

Type of change

  • Bug fix (non-breaking, fixes an issue)

Test plan

  • Added Muya integration coverage for URL validation, rich clipboard HTML, reverse selections, Unicode, formatting, escaping, table cells, and fallback behavior.
  • 212 clipboard/history unit tests pass.
  • 3 Chromium E2E tests pass, including native plain/HTML clipboard paste, caret position, undo/redo, selection restoration, and plain-text paste.
  • Muya lint, typecheck, and circular dependency checks pass (lint warnings remain).
  • Root lint and desktop typecheck pass (existing lint warnings remain).
  • Tested on macOS.

Notes for reviewers

Page-title fetching is a separate follow-up. This PR preserves the selection before that existing pipeline runs and does not add an Electron dependency to Muya.


By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@Jocs
Jocs force-pushed the fix/2029-paste-url-over-selection branch from c9d6861 to 6ef518e Compare October 15, 2026 12:32
@Jocs
Jocs force-pushed the fix/2029-paste-url-over-selection branch from 6ef518e to fba0bc0 Compare October 15, 2026 12:32
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

@Jocs
Jocs merged commit 0cda325 into develop Oct 15, 2026
8 checks passed
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.

Keep selected text when inserting a URL

1 participant