-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windows: Implement copy/paste images #17852
Merged
mikayla-maki
merged 24 commits into
zed-industries:main
from
JunkuiZhang:windows/cp-img
Sep 30, 2024
Merged
windows: Implement copy/paste images #17852
mikayla-maki
merged 24 commits into
zed-industries:main
from
JunkuiZhang:windows/cp-img
Sep 30, 2024
Conversation
This file contains 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
cla-bot
bot
added
the
cla-signed
The user has signed the Contributor License Agreement
label
Sep 15, 2024
The reason why a GIF does not animate is most likely because the img element does not have an element id to allow it to animate across frames. |
Thank you! |
noaccOS
pushed a commit
to noaccOS/zed
that referenced
this pull request
Oct 19, 2024
**Clipboard Behavior on Windows Under This PR:** | User Action | Zed’s Behavior | | ------------------- | -------------------------------------------------- | | Paste PNG | Worked | | Paste JPEG | Worked | | Paste WebP | Worked, but not in the way you expect (see Issue section below) | | Paste GIF | Partially worked (see Issue section below) | | Paste SVG | Partially worked (see Issue section below) | | Paste BMP | Worked, but not in the way you expect (see Issue section below) | | Paste TIFF | Worked, but not in the way you expect (see Issue section below) | | Paste Files | Worked, same behavior as macOS | | Copy image in Zed | Not tested, as I couldn’t find a way to copy images | --- **Differences Between the Windows and macOS Clipboard** The clipboard functionality on Windows differs significantly from macOS. On macOS, there can be multiple items in the clipboard, whereas, on Windows, the clipboard holds only a single item. You can retrieve different formats from the clipboard, but they are all just different representations of the same item. For example, when you copy a JPG image from Microsoft Word, the clipboard will contain data in several formats: - Microsoft Office proprietary data - JPG format data - PNG format data - SVG format data Please note that these formats all represent the same image, just in different formats. This is due to compatibility concerns on Windows, as various applications support different formats. Ideally, multiple formats should be placed on the clipboard to support more software. However, in general, supporting PNG will cover 99% of software, like Chrome, which only supports PNG and BMP formats. Additionally, since the clipboard on Windows only contains a single item, special handling is required when copying multiple objects, such as text and images. For instance, if you copy both text and an image simultaneously in Microsoft Word, Microsoft places the following data on the clipboard: - Microsoft Office proprietary data containing a lot of content such as text fonts, sizes, italics, positioning, image size, content, etc. - RTF data representing the above content in RTF format - HTML data representing the content in HTML format - Plain text data Therefore, for the current `ClipboardItem` implementation, if there are multiple `ClipboardEntry` objects to be placed on the clipboard, RTF or HTML formats are required. This PR does not support this scenario, and only supports copying or pasting a single item from the clipboard. --- **Known Issues** - **WebP, BMP, TIFF**: These formats are not explicitly supported in this PR. However, as mentioned earlier, in most cases, there are corresponding PNG format data on the clipboard. This PR retrieves data via PNG format, so users copying images in these formats from other sources will still see the images displayed correctly. - **GIF**: In this PR, GIFs are displayed, but for GIF images with multiple frames, the image will not animate and will freeze on a single frame. Since I observed the same behavior on macOS, I believe this is not an issue with this PR. - **SVG**: In this PR, only the top-left corner of the SVG image is displayed. Again, I observed the same behavior on macOS, so I believe this issue is not specific to this PR. --- I hope this provides a clearer understanding. Any feedback or suggestions on how to improve this are welcome. Release Notes: - N/A
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.
Clipboard Behavior on Windows Under This PR:
Differences Between the Windows and macOS Clipboard
The clipboard functionality on Windows differs significantly from macOS. On macOS, there can be multiple items in the clipboard, whereas, on Windows, the clipboard holds only a single item. You can retrieve different formats from the clipboard, but they are all just different representations of the same item.
For example, when you copy a JPG image from Microsoft Word, the clipboard will contain data in several formats:
Please note that these formats all represent the same image, just in different formats. This is due to compatibility concerns on Windows, as various applications support different formats. Ideally, multiple formats should be placed on the clipboard to support more software. However, in general, supporting PNG will cover 99% of software, like Chrome, which only supports PNG and BMP formats.
Additionally, since the clipboard on Windows only contains a single item, special handling is required when copying multiple objects, such as text and images. For instance, if you copy both text and an image simultaneously in Microsoft Word, Microsoft places the following data on the clipboard:
Therefore, for the current
ClipboardItem
implementation, if there are multipleClipboardEntry
objects to be placed on the clipboard, RTF or HTML formats are required. This PR does not support this scenario, and only supports copying or pasting a single item from the clipboard.Known Issues
WebP, BMP, TIFF: These formats are not explicitly supported in this PR. However, as mentioned earlier, in most cases, there are corresponding PNG format data on the clipboard. This PR retrieves data via PNG format, so users copying images in these formats from other sources will still see the images displayed correctly.
GIF: In this PR, GIFs are displayed, but for GIF images with multiple frames, the image will not animate and will freeze on a single frame. Since I observed the same behavior on macOS, I believe this is not an issue with this PR.
SVG: In this PR, only the top-left corner of the SVG image is displayed. Again, I observed the same behavior on macOS, so I believe this issue is not specific to this PR.
I hope this provides a clearer understanding. Any feedback or suggestions on how to improve this are welcome.
Release Notes: