Skip to content

Add clipboard image paste support#27

Merged
adbenitez merged 3 commits intomainfrom
copilot/allow-paste-image-from-clipboard
Jan 30, 2026
Merged

Add clipboard image paste support#27
adbenitez merged 3 commits intomainfrom
copilot/allow-paste-image-from-clipboard

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

Users can now paste images from clipboard directly into post/comment textareas. Previously, images could only be attached via the file picker button.

Implementation

  • Added onPaste handler to <textarea> in Draft.tsx
  • Intercepts ClipboardEvent, extracts File from clipboardData.items
  • Delegates to existing onFileSelected() for validation, resize, and state management
  • Prevents default paste behavior for images to avoid data URL insertion
const handlePaste = useCallback(
  async (event: React.ClipboardEvent<HTMLTextAreaElement>) => {
    const items = event.clipboardData?.items;
    for (let i = 0; i < items.length; i++) {
      if (items[i].type.startsWith("image/")) {
        event.preventDefault();
        const file = items[i].getAsFile();
        if (file) await onFileSelected(file);
        break;
      }
    }
  },
  [onFileSelected]
);

Screenshot

Pasted image successfully attached with Pixel It! button:

Pasted Image

Original prompt

This section details on the original issue you should resolve

<issue_title>allow to paste image from clipboard</issue_title>
<issue_description>currently only way to attach image is by using the gallery/image button, it is needed to support attaching image by pasting image from clipboard </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 30, 2026 16:39
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for pasting images from clipboard Add clipboard image paste support Jan 30, 2026
Copilot AI requested a review from adbenitez January 30, 2026 16:44
@adbenitez adbenitez marked this pull request as ready for review January 30, 2026 18:17
@adbenitez adbenitez merged commit 2f79118 into main Jan 30, 2026
1 check passed
@adbenitez adbenitez deleted the copilot/allow-paste-image-from-clipboard branch January 30, 2026 18:18
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.

allow to paste image from clipboard

2 participants