Skip to content

Commit

Permalink
Fix the onPaste logic of the SmartTextarea
Browse files Browse the repository at this point in the history
The SmartTextarea component now handles the 'onPaste' event more precisely. When the clipboard contains the text and the image in the same time, both are pasted.
  • Loading branch information
davidmz committed Sep 20, 2024
1 parent 6f6b49c commit e6d041f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.135.0] - Not released
### Fixed
- The SmartTextarea component now handles the 'onPaste' event more precisely.
When the clipboard contains the text and the image in the same time, both are
pasted.

## [1.134.4] - 2024-08-26
### Changed
Expand Down
8 changes: 0 additions & 8 deletions src/components/smart-textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ function useFile(onFile, ref) {

const items = [...e.clipboardData.items];

// If there is some plain text in clipboard, use it and don't try to find image
if (items.some((it) => it.type.startsWith('text/plain'))) {
return;
}

const imagePromises = [];
for (const it of items) {
if (!it.type.startsWith('image/')) {
Expand All @@ -208,9 +203,6 @@ function useFile(onFile, ref) {
imagePromises.push(Promise.resolve(blob));
}
}
if (imagePromises.length > 0) {
e.preventDefault();
}

// Call 'onFile' in order of imagePromises
imagePromises.reduce(async (prev, it) => {
Expand Down

0 comments on commit e6d041f

Please sign in to comment.