Skip to content

Fix plain text paste being ignored without markdown - #1178

Open
MatheusRich wants to merge 1 commit into
basecamp:mainfrom
MatheusRich:fix-plain-text-paste-with-markdown-disabled
Open

Fix plain text paste being ignored without markdown#1178
MatheusRich wants to merge 1 commit into
basecamp:mainfrom
MatheusRich:fix-plain-text-paste-with-markdown-disabled

Conversation

@MatheusRich

@MatheusRich MatheusRich commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #1055

Pasting plain, non-URL text did nothing whenever supportsMarkdown was false, which happens with markdown: false or in a plain-text-only editor (richText: false).

#pastePlainTextOrURL resolves the clipboard text through the asynchronous item.getAsString callback. The non-markdown branch ignored that resolved text and handed the whole clipboardData to $insertDataTransferForRichText instead. By the time the callback ran, the paste event was over, so that DataTransfer read back empty and nothing got inserted. The URL and Markdown branches worked because they already used the resolved text string.

This PR inserts the resolved text in the non-markdown branch too, rather than re-reading the stale clipboard, and drops the now-unused rich-text path.

A Playwright regression (programmatic_insert_fallback) showed why the earlier synchronous-read approach was wrong: the URL paste path relies on item.getAsString running after the paste command handler, so the lexxy:insert-link replacement fires correctly. The async callback is kept intact; only the non-markdown branch changed.

Copilot AI review requested due to automatic review settings July 2, 2026 19:26

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Lexxy clipboard regression where pasting plain, non-URL text could be ignored when supportsMarkdown is false (e.g., markdown: false or richText: false) by capturing clipboard text synchronously and inserting it directly.

Changes:

  • Replace the async DataTransferItem#getAsString plain-text paste path with a synchronous clipboardData.getData(...) read and direct text insertion.
  • Remove the now-dead rich-text fallback path for plain-text/URL-only clipboard payloads.
  • Add a system regression test covering both markdown: false and rich-text: false configurations.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/system/plain_text_paste_test.rb Adds regression coverage ensuring plain-text paste works when markdown or rich-text mode is disabled.
src/editor/clipboard.js Reads plain text synchronously from clipboardData and inserts captured text directly, avoiding stale DataTransfer reads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Pasting plain, non-URL text did nothing whenever `supportsMarkdown` was
false, which happens with `markdown: false` or in a plain-text-only editor
(`richText: false`).

`#pastePlainTextOrURL` resolves the clipboard text through the asynchronous
`item.getAsString` callback. The non-markdown branch ignored that resolved
text and handed the whole `clipboardData` to `$insertDataTransferForRichText`
instead. By the time the callback ran, the paste event was over, so that
DataTransfer read back empty and nothing got inserted. The URL and Markdown
branches worked because they already used the resolved text string.

This commit inserts the resolved text in the non-markdown branch too, rather
than re-reading the stale clipboard, and drops the now-unused rich-text path.
@MatheusRich
MatheusRich force-pushed the fix-plain-text-paste-with-markdown-disabled branch from 4baa2e6 to 1b1de59 Compare July 2, 2026 19:46
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.

Plain text paste is ignored with markdown: false configured

2 participants