Skip to content

Commit

Permalink
only pick text if pasting text and files
Browse files Browse the repository at this point in the history
  • Loading branch information
reiji-h committed Sep 11, 2024
1 parent a4dae48 commit f68146f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
return;
}

if (onUpload != null && event.clipboardData.types.includes('Files')) {
onUpload(Array.from(event.clipboardData.files));
}

if (event.clipboardData.types.includes('text/plain')) {

const textData = event.clipboardData.getData('text/plain');
Expand All @@ -114,6 +110,10 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {

codeMirrorEditor?.replaceText(adjusted);
}
else if (onUpload != null && event.clipboardData.types.includes('Files')) {
onUpload(Array.from(event.clipboardData.files));
}

};

const extension = EditorView.domEventHandlers({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export const useFileDropzone = (props: Props): FileDropzoneState => {

}, [onUpload, setIsUploading, acceptedUploadFileType]);

let accept: Accept | undefined;
if (acceptedUploadFileType === AcceptedUploadFileType.IMAGE) {
accept = { 'image/*': [] };
}
const accept: Accept | undefined = (acceptedUploadFileType === AcceptedUploadFileType.IMAGE) ? { 'image/*': [] } : undefined;

const dzState = useDropzone({
onDrop: dropHandler,
Expand Down

0 comments on commit f68146f

Please sign in to comment.