✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
fix: styling & fetch url
AykutSaracb5c8a1d14e63
diff --git a/src/containers/Editor/LiveEditor/Tools.tsx b/src/containers/Editor/LiveEditor/Tools.tsxindex 20b80e6f..72a796e0 100644--- a/src/containers/Editor/LiveEditor/Tools.tsx+++ b/src/containers/Editor/LiveEditor/Tools.tsx@@ -180,7 +180,7 @@ export const Tools: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) =></StyledToolElement>)}{!isWidget && (- <Group spacing="xs" position="left" w="100%">+ <Group spacing="xs" position="left" w="100%" noWrap><StyledToolElement as="a" title="Herowand" href="https://jsoncrack.com"><Flex gap="xs" align="center" justify="center"><StyledLogo@@ -279,7 +279,7 @@ export const Tools: React.FC<{ isWidget?: boolean }> = ({ isWidget = false }) =></StyledToolElement></Group>)}- <Group spacing="xs" position="right" w="100%">+ <Group spacing="xs" position="right" w="100%" noWrap><StyledToolElement title="Zoom Out" onClick={zoomOut}><AiOutlineMinus size="18" /></StyledToolElement>diff --git a/src/store/useFile.ts b/src/store/useFile.tsindex ed451f00..c6111724 100644--- a/src/store/useFile.ts+++ b/src/store/useFile.ts@@ -46,8 +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 isURL = new RegExp(+ /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/+);const debouncedUpdateJson = debounce((value: unknown) => useJson.getState().setJson(JSON.stringify(value, null, 2)),@@ -105,29 +106,23 @@ const useFile = create<FileStates & JsonActions>()((set, get) => ({}},fetchUrl: async url => {- const isURL = new RegExp(- /^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/- );-- if (isURL.test(url)) {- try {- const res = await fetch(url);- const json = await res.json();- const jsonStr = JSON.stringify(json, null, 2);+ try {+ const res = await fetch(url);+ const json = await res.json();+ const jsonStr = JSON.stringify(json, null, 2);- useGraph.getState().setGraph(jsonStr);- 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!");- }+ useGraph.getState().setGraph(jsonStr);+ 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);+ if (isURL.test(id)) return get().fetchUrl(id);const file = await getFromCloud(id);get().setFile(file);