Skip to content

Reading pane: a picture in a message is copied as a picture, with Copy or a right click - #2283

Draft
CODEX-cpp wants to merge 12 commits into
UCSLabs:mainfrom
CODEX-cpp:feat/copy-picture-as-image
Draft

CODEX-cpp wants to merge 12 commits into
UCSLabs:mainfrom
CODEX-cpp:feat/copy-picture-as-image

Conversation

@CODEX-cpp

Copy link
Copy Markdown
Contributor

Closes #2282

Builds on #2237 (a draft until that is merged): the commits of that pull request are in this one too.

What changes for the person using MailCraft

A picture in a message can be copied as a picture, and pasted into a drawing program, a folder or a document:

  • A selection that is one picture and no words (Ctrl+C or Copy) puts the picture on the clipboard as a picture. It used to say "Select some text first" and copy nothing.
  • A right click on a picture selects it when it is not in what is selected, so that Copy takes that picture alone; "Copy" was greyed out there.
  • With words in the selection, or Select All, the copy is as Reading pane: Copy keeps the look and the pictures of the text, for a signature or a message it is pasted into #2237 makes it: the text with its look and the pictures as HTML.
  • Where the system has no place for a picture on its clipboard, the copy goes as HTML as before; one that goes nowhere leaves the clipboard as it was.

The picture is read in the sizes a picture from the clipboard is taken in (4096 pixels a side), and a moving GIF goes as its first frame.

How it was checked

  • New tests in reading/tests/copy_html.rs (a selection that is one picture is that picture, with no text; words or a second picture are not a lone picture). cargo test -p mailcraft-ui-egui --lib reading: 350 passed, 0 failed. cargo fmt --check, cargo clippy -p mailcraft-ui-egui --all-targets -- -D warnings, cargo xtask release-notes and docs-log are clean; cargo check -p mailcraft builds.

  • In a clean Windows sandbox, with a message that is one picture and another with words around it: Ctrl+A and Ctrl+C on the picture alone gives a 240 by 140 picture on the clipboard (the build without this change gives nothing); on the message with words, the clipboard has the text, the HTML with its picture and the bold; a right click on the picture, then Copy, gives the picture and no text.

  • It also fixes a count of the reading pane's source files in reading/tests.rs that Reading pane: Copy keeps the look and the pictures of the text, for a signature or a message it is pasted into #2237 left at 30 (copy_html.rs is the 31st), which fails without it.

  • Not run: the full cargo xtask ci; macOS, Linux and Wayland (the clipboard writes a picture through arboard); selecting the picture with a drag of the mouse (Select All and the right click were).

  • cargo xtask ci passes

  • A crash or data-loss fix has its regression test

  • "Allow edits by maintainers" is ticked (the box beside Create pull request)

  • I have signed the CLA, or will by commenting on this pull request

Human-reviewed, AI-assisted, nobody's mailbox harmed.

Ctrl+C or Copy on a selection in a message put plain text on the clipboard
and nothing else, so a signature, a message or a document it was pasted into
lost its bold, colours, sizes and links.

The copy now writes HTML beside the text. It is made from the spans each
text was laid out from (kept on TextItem::spans, as the message gave them,
not as the pane draws them: a dark window's light text would not be read on a
signature's white page): bold, italic, underline, strike-through, colour,
highlight, size, font, and links a message may have (http, https, mailto,
tel). Everything is escaped, and a system that cannot take HTML gets the text
alone, as before. Pictures are not copied.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…message

A picture that is shown, whole in the copied selection, now goes in the HTML
as an <img> that carries its own bytes (data:), at the width it is shown and
with its description. edit.paste takes such pictures out of the pasted HTML,
checks them to be pictures by their own bytes, and keeps them where they
stood: in the open signature, within its caps (256 KB each, 512 KB in all, ten
at most; the note says when one was left out), or in the message being
written, within its own. Nothing is fetched. A plain-text message keeps none.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…abs#2275)

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
A selection of a message that was one picture and no words had no text, so a copy
said "Select some text first" and put nothing on the clipboard; and even a picture
inside a text only went as HTML, never as a picture a drawing program, a folder or
a document pastes. A copy of a lone picture now puts the picture on the clipboard
as a picture (`RichClipboard::put_image`; the system's own clipboard takes its
pixels), and where the system cannot, it goes as HTML like any other. A selection
with words keeps the copy with its look.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
copy_html.rs is a new file of the reading pane that the test of what the pane names
(nothing that could fetch) counts: 31 files, not 30.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
…annot be copied leaves the clipboard as it is

Fragments named for UCSLabs#2282.

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
@coderabbitai

coderabbitai Bot commented Dec 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

A picture in a message cannot be copied as a picture

1 participant