fixed pasting files and images

This commit is contained in:
or-else
2022-05-17 15:53:11 -07:00
parent a9e4f644a2
commit ec01ac2a50
6 changed files with 12 additions and 15 deletions
+1 -1
View File
@@ -199,7 +199,7 @@ export function blobToBase64(blob) {
// File pasted from the clipboard. It's either an inline image or a file attachment. // File pasted from the clipboard. It's either an inline image or a file attachment.
export function filePasted(event, onImageSuccess, onAttachmentSuccess, onError) { export function filePasted(event, onImageSuccess, onAttachmentSuccess, onError) {
const items = (event.clipboardData || event.originalEvent.clipboardData || {}).items; const items = (event.clipboardData || event.originalEvent.clipboardData || {}).items;
if (!Array.isArray(items)) { if (!items || !items.length) {
return false; return false;
} }
+2 -6
View File
@@ -104,12 +104,8 @@ class SendMessage extends React.PureComponent {
} }
// FIXME: handle large files too. // FIXME: handle large files too.
if (filePasted(e, if (filePasted(e,
(bits, mime, width, height, fname) => { file => { this.props.onAttachImage(file); },
this.props.onAttachImage(mime, bits, width, height, fname); file => { this.props.onAttachFile(file); },
},
(mime, bits, fname) => {
this.props.onAttachFile(mime, bits, fname);
},
this.props.onError)) { this.props.onError)) {
// If a file was pasted, don't paste base64 data into input field. // If a file was pasted, don't paste base64 data into input field.
+6 -5
View File
@@ -2288,8 +2288,9 @@ function blobToBase64(blob) {
} }
function filePasted(event, onImageSuccess, onAttachmentSuccess, onError) { function filePasted(event, onImageSuccess, onAttachmentSuccess, onError) {
const items = (event.clipboardData || event.originalEvent.clipboardData || {}).items; const items = (event.clipboardData || event.originalEvent.clipboardData || {}).items;
console.log("pasted items", items);
if (!Array.isArray(items)) { if (!items || !items.length) {
return false; return false;
} }
@@ -14725,10 +14726,10 @@ class SendMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
return; return;
} }
if ((0,_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_5__.filePasted)(e, (bits, mime, width, height, fname) => { if ((0,_lib_blob_helpers_js__WEBPACK_IMPORTED_MODULE_5__.filePasted)(e, file => {
this.props.onAttachImage(mime, bits, width, height, fname); this.props.onAttachImage(file);
}, (mime, bits, fname) => { }, file => {
this.props.onAttachFile(mime, bits, fname); this.props.onAttachFile(file);
}, this.props.onError)) { }, this.props.onError)) {
e.preventDefault(); e.preventDefault();
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long