-
Notifications
You must be signed in to change notification settings - Fork 297
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
Communication
: Allow users to paste images from the clipboard
#9637
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every thing works well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested locally and works as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual tested on TS2 in Chrome. Worked as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approve code
I left 2 comments that could be addressed, however, I have no hard feelings there and it might be a matter of taste anyways
for (const clipboardItem of clipboardItems) { | ||
for (const type of clipboardItem.types) { | ||
if (type.startsWith('image/')) { | ||
// Map image type to extension. | ||
const extension = type.replace('image/', ''); | ||
const blob = await clipboardItem.getType(type); | ||
files.push(new File([blob], `image.${extension}`, { type })); | ||
break; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should be a method on its own, from my point of view it would make the method easier to understand if it was a method with a descriptive name
export class MockClipboardItem { | ||
types: string[]; | ||
|
||
getType(_type: string): Promise<Blob> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be worth adding a comment in the code here as well 😅
Checklist
General
Client
Motivation and Context
It's currently not possible to (like on GitHub) paste images into the Markdown editor using the keyboard shortcut CTRL+V/Cmd+V.
Description
Added a paste listener that checks for images (and only images) in the clipboard and embeds them in the editor. Also, added some basic tests to improve the coverage.
Steps for Testing
Prerequisites:
Testserver States
Note
These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.
Review Progress
Code Review
Manual Tests
Test Coverage
Client
Screenshots
Screencast.from.29.10.2024.14_41_19.webm
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests