diff --git a/src/components/bookmarks-panel/bookmarks-panel.tsx b/src/components/bookmarks-panel/bookmarks-panel.tsx index 9bffa2e0..0902b142 100644 --- a/src/components/bookmarks-panel/bookmarks-panel.tsx +++ b/src/components/bookmarks-panel/bookmarks-panel.tsx @@ -284,9 +284,11 @@ export const BookmarksPanel = ({ onEditBookmarks={onEditBookmarksClickHandler} onClearBookmarks={onClearBookmarksClickHandler} onUploadBookmarks={() => { - setPopoverType( - bookmarks.length ? PopoverType.uploadWarning : PopoverType.upload - ); + setTimeout(() => { + setPopoverType( + bookmarks.length ? PopoverType.uploadWarning : PopoverType.upload + ); + }, 1); }} onDownloadBookmarks={onDownloadBookmarks} onCollapsed={onCollapsed} diff --git a/src/components/layers-panel/insert-panel/insert-panel.tsx b/src/components/layers-panel/insert-panel/insert-panel.tsx index c31a88dc..b05da128 100644 --- a/src/components/layers-panel/insert-panel/insert-panel.tsx +++ b/src/components/layers-panel/insert-panel/insert-panel.tsx @@ -247,8 +247,9 @@ export const InsertPanel = ({ onChange={handleInputChange} /> { handleInputChange({ target: { files, name: "URL" } }); }} fileType={FileType.binary} /> diff --git a/src/components/upload-panel/upload-panel.tsx b/src/components/upload-panel/upload-panel.tsx index 00287844..051c8df8 100644 --- a/src/components/upload-panel/upload-panel.tsx +++ b/src/components/upload-panel/upload-panel.tsx @@ -43,6 +43,10 @@ const FileTextItem = styled.div` const DragAndDropFileText = styled(FileTextItem)` color: ${({ theme }) => theme.colors.fontColor}; +`; + +const UploadedFileText = styled(FileTextItem)` + color: ${({ theme }) => theme.colors.fontColor}; word-break: break-all; `; @@ -62,6 +66,7 @@ interface UploadProps { fileType: FileType; multipleFiles?: boolean; noPadding?: boolean; + accept?: string; onCancel?: () => void; onFileUploaded?: (fileUploaded: FileUploaded) => Promise | void; onFileEvent?: (files: FileList) => void; @@ -73,6 +78,7 @@ export const UploadPanel = ({ fileType, multipleFiles, noPadding, + accept, onCancel, onFileUploaded, onFileEvent, @@ -117,6 +123,9 @@ export const UploadPanel = ({ e.stopPropagation(); setDragActive(false); if (e.dataTransfer.files?.[0]) { + if (accept && !e.dataTransfer.files?.[0].name.endsWith(accept)) { + return; + } setFileUploaded(e.dataTransfer.files[0].name); onFileEvent?.(e.dataTransfer.files); readFile(e.dataTransfer.files).catch(() => { @@ -146,6 +155,7 @@ export const UploadPanel = ({ type="file" multiple={multipleFiles ?? undefined} onChange={onUploadChangeHandler} + accept={accept} /> - {fileUploaded} + {fileUploaded} )}