Skip to content

Commit d277b62

Browse files
committed
add UI drag-drop and manual file supported for embedded images
1 parent 3d9d8a8 commit d277b62

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/component/fileBrowser.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ const LocalFileBrowser = ({ superState, dispatcher }) => {
5353
}, [superState.fileState]);
5454

5555
const handleSelectFile = (data) => {
56-
const fileExtensions = ['jpeg', 'jpg', 'png', 'exe'];
56+
const fileExtensions = ['exe'];
5757
const fileExt = data.fileObj.name.split('.').pop().toLowerCase();
5858
if (fileExtensions.includes(fileExt)) {
5959
// eslint-disable-next-line no-alert
6060
alert('Wrong file extension');
6161
return;
6262
}
6363

64-
if (fileExt === 'graphml' || fileExt === 'json') {
64+
const allowedExts = ['graphml', 'json', 'png', 'jpg', 'jpeg'];
65+
if (allowedExts.includes(fileExt)) {
6566
let foundi = -1;
6667
superState.graphs.forEach((g, i) => {
6768
if ((g.fileName === data.fileObj.name)) {
@@ -140,6 +141,8 @@ const LocalFileBrowser = ({ superState, dispatcher }) => {
140141
accept: {
141142
'text/graphml': ['.graphml'],
142143
'application/json': ['.json'],
144+
'image/png': ['.png'],
145+
'image/jpeg': ['.jpg', '.jpeg'],
143146
},
144147
},
145148
],
@@ -207,7 +210,7 @@ const LocalFileBrowser = ({ superState, dispatcher }) => {
207210
ref={fileRef}
208211
onClick={(e) => { e.target.value = null; }}
209212
style={{ display: 'none' }}
210-
accept=".graphml,.json"
213+
accept=".graphml,.json,.png,.jpg,.jpeg"
211214
onChange={(e) => readFile(superState, dispatcher, e.target.files[0])}
212215
/>
213216
)}

0 commit comments

Comments
 (0)