Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

fix: widget

AykutSarac231136c807a6
diff --git a/src/containers/Home/index.tsx b/src/containers/Home/index.tsx
index bab64a39..43df09dc 100644
--- a/src/containers/Home/index.tsx
+++ b/src/containers/Home/index.tsx
@@ -102,7 +102,7 @@ const PreviewSection = () => {
<Styles.StyledPreviewFrame
title="Preview Embed"
id="jcPreview"
- src={`${baseURL}/widget?json=63b73305c358219fbc421adf`}
+ src={`${baseURL}/widget?json=644248e080ba36d1e7e833dc`}
loading="eager"
/>
</Styles.StyledPreviewSection>
diff --git a/src/store/useFile.ts b/src/store/useFile.ts
index a59c9405..ed451f00 100644
--- a/src/store/useFile.ts
+++ b/src/store/useFile.ts
@@ -46,6 +46,9 @@ const initialStates = {
export type FileStates = typeof initialStates;
+const regex =
+ "((http|https)://)(www.)?[a-zA-Z0-9@:%._\\+~#?&//=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%._\\+~#?&//=]*)";
+
const debouncedUpdateJson = debounce(
(value: unknown) => useJson.getState().setJson(JSON.stringify(value, null, 2)),
800
@@ -116,16 +119,21 @@ const useFile = create<FileStates & JsonActions>()((set, get) => ({
return useJson.setState({ json: jsonStr, loading: false });
} catch (error) {
get().clear();
+ useJson.setState({ loading: false });
+ useGraph.setState({ loading: false });
toast.error("Failed to fetch document from URL!");
}
}
},
fetchFile: async id => {
try {
+ if (regex.match(id)) return get().fetchUrl(id);
+
const file = await getFromCloud(id);
get().setFile(file);
} catch (error) {
useJson.setState({ loading: false });
+ useGraph.setState({ loading: false });
console.error(error);
}
},