feat: add "Copy as Image" plugin for LLM-friendly text-to-image clipboard copy#261
Draft
feat: add "Copy as Image" plugin for LLM-friendly text-to-image clipboard copy#261
Conversation
…pact PNG Renders grabbed text content onto a canvas using a compact 12px monospace font and copies the resulting PNG image to the clipboard. The image is designed to be LLM-parseable while staying token-efficient (small dimensions, minimal padding). New files: - utils/render-text-to-image.ts: canvas text rendering → PNG blob - utils/copy-image-to-clipboard.ts: clipboard write via ClipboardItem API - core/plugins/copy-image.ts: plugin wiring (context menu action) Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
@react-grab/cli
grab
@react-grab/amp
@react-grab/claude-code
@react-grab/codex
@react-grab/copilot
@react-grab/cursor
@react-grab/droid
@react-grab/gemini
@react-grab/opencode
react-grab
@react-grab/relay
@react-grab/utils
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new "Copy as Image" context menu action that renders the grabbed text content into a compact PNG image and copies it to the clipboard. The image is designed to be parseable by LLMs while staying token-efficient (small pixel dimensions, minimal padding).
What it does
When a user selects "Copy as Image" from the context menu, the plugin:
Fileusing the component/element display name (e.g.TodoList.png)ClipboardItemAPIDesign decisions
Fileobject — the clipboard image is named after the component (componentName) or element tag (tagName), so paste targets that respect filenames will show a meaningful nameNew files
utils/render-text-to-image.tsutils/copy-image-to-clipboard.tsFile, clipboard write viaClipboardItemAPIcore/plugins/copy-image.tsConstants added to
constants.tsTEXT_IMAGE_FONT_SIZE_PX(12)TEXT_IMAGE_LINE_HEIGHT_PX(15)TEXT_IMAGE_PADDING_PX(8)TEXT_IMAGE_FONT_FAMILY("monospace")TEXT_IMAGE_BACKGROUND_COLOR/TEXT_IMAGE_TEXT_COLORTEXT_IMAGE_TAB_SIZE_SPACES(2)Checks
Summary by cubic
Adds a “Copy as Image” action that turns grabbed text into a compact PNG and copies it to the clipboard. On modern clipboards, it writes text, HTML, and the PNG together to make pasting easier.
ClipboardItemto writetext/plain,text/html, andimage/pngin one go; falls back to legacy copy with metadata when needed.Written for commit b238633. Summary will update on new commits.