Skip to content

Commit 1f2229a

Browse files
committed
Adding graphology JSON support for imports
1 parent 80ef917 commit 1f2229a

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/core/graph/import/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export const importFile = asyncAction(async (file: NonNullable<GraphOrigin>) =>
6363
case "graphml":
6464
graph = graphml.parse(Graph, content, { addMissingNodes: true });
6565
break;
66+
case "json":
67+
graph = Graph.from(JSON.parse(content));
68+
break;
6669
default:
6770
graph = null;
6871
break;

src/locales/dev.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@
305305
"title": "Open a graph file",
306306
"local": {
307307
"title": "Open a local file",
308-
"dragndrop_text": "Drag'n'drop a GEXF or GRAPHML file",
308+
"dragndrop_text": "Drag'n'drop a GEXF, GRAPHML or JSON file",
309309
"success": "File {{filename}} has been successfully loaded",
310310
"error": "An error occurred while opening the file. Please check that the file is a valid."
311311
},
312312
"remote": {
313313
"title": "Open an url",
314-
"url-field": "URL of a GEXF or GRAPHML file",
314+
"url-field": "URL of a GEXF, GRAPHML or JSON file",
315315
"success": "File {{filename}} has been successfully loaded",
316316
"error": "An error occurred while opening the file. Please check your connectivity and that the file is a valid."
317317
},

src/views/graphPage/modals/open/LocalFileModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const LocalFileModal: FC<ModalProps<unknown>> = ({ cancel }) => {
2727
value={file}
2828
onChange={(file) => setFile(file)}
2929
helpText={t("graph.open.local.dragndrop_text").toString()}
30-
accept={{ "application/graph": [".gexf", ".graphml"] }}
30+
accept={{ "application/graph": [".gexf", ".graphml"], "application/json": [".json"] }}
3131
/>
3232
{importStateType === "loading" && <Loader />}
3333
</>

0 commit comments

Comments
 (0)