From cbf53f5bda0e68632aa753e418ba481bee0777d1 Mon Sep 17 00:00:00 2001 From: Daria Terekhova Date: Wed, 4 Dec 2024 12:48:05 +0200 Subject: [PATCH 1/4] stop wrong onClickOutside callback --- src/components/bookmarks-panel/bookmarks-panel.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/bookmarks-panel/bookmarks-panel.tsx b/src/components/bookmarks-panel/bookmarks-panel.tsx index 9bffa2e0..2a6d886b 100644 --- a/src/components/bookmarks-panel/bookmarks-panel.tsx +++ b/src/components/bookmarks-panel/bookmarks-panel.tsx @@ -284,9 +284,12 @@ 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} From ca599f01789e6106c3897381b1d04360cb6ecda0 Mon Sep 17 00:00:00 2001 From: Daria Terekhova Date: Wed, 4 Dec 2024 13:37:58 +0200 Subject: [PATCH 2/4] Text wrap fix --- src/components/upload-panel/upload-panel.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/upload-panel/upload-panel.tsx b/src/components/upload-panel/upload-panel.tsx index 00287844..462f53eb 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; `; @@ -176,7 +180,7 @@ export const UploadPanel = ({ {fileUploaded && ( <> - {fileUploaded} + {fileUploaded} )} From 1acd01e1f1f1150617f4d18ea47896fc0f235a34 Mon Sep 17 00:00:00 2001 From: Daria Terekhova Date: Wed, 4 Dec 2024 13:38:10 +0200 Subject: [PATCH 3/4] Only slpk is allowed --- src/components/layers-panel/insert-panel/insert-panel.tsx | 3 ++- src/components/upload-panel/upload-panel.tsx | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 462f53eb..051c8df8 100644 --- a/src/components/upload-panel/upload-panel.tsx +++ b/src/components/upload-panel/upload-panel.tsx @@ -66,6 +66,7 @@ interface UploadProps { fileType: FileType; multipleFiles?: boolean; noPadding?: boolean; + accept?: string; onCancel?: () => void; onFileUploaded?: (fileUploaded: FileUploaded) => Promise | void; onFileEvent?: (files: FileList) => void; @@ -77,6 +78,7 @@ export const UploadPanel = ({ fileType, multipleFiles, noPadding, + accept, onCancel, onFileUploaded, onFileEvent, @@ -121,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(() => { @@ -150,6 +155,7 @@ export const UploadPanel = ({ type="file" multiple={multipleFiles ?? undefined} onChange={onUploadChangeHandler} + accept={accept} /> Date: Wed, 4 Dec 2024 13:40:17 +0200 Subject: [PATCH 4/4] lint fix --- src/components/bookmarks-panel/bookmarks-panel.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/bookmarks-panel/bookmarks-panel.tsx b/src/components/bookmarks-panel/bookmarks-panel.tsx index 2a6d886b..0902b142 100644 --- a/src/components/bookmarks-panel/bookmarks-panel.tsx +++ b/src/components/bookmarks-panel/bookmarks-panel.tsx @@ -288,8 +288,7 @@ export const BookmarksPanel = ({ setPopoverType( bookmarks.length ? PopoverType.uploadWarning : PopoverType.upload ); - },1) - + }, 1); }} onDownloadBookmarks={onDownloadBookmarks} onCollapsed={onCollapsed}