✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
Merge branch 'main' into fix/align-object-child
AykutSarac08afad8fe047
diff --cc src/utils/jsonParser.tsindex faf1ede4,09b6ab85..c7f2092e--- a/src/utils/jsonParser.ts+++ b/src/utils/jsonParser.ts@@@ -1,23 -1,31 +1,31 @@@-import { Node, parseTree } from "jsonc-parser";+import { Node, NodeType, parseTree } from "jsonc-parser";+ import useGraph from "src/store/useGraph";+ import useStored from "src/store/useStored";++ const calculateSize = (text: string | [string, string][], isParent = false) => {+ const isFolded = useGraph.getState().foldNodes;+ const isImagePreview = useStored.getState().imagePreview;+ let lineCounts = 1;+ let lineLengths: number[] = [];++ if (typeof text === "string") {+ lineLengths.push(text.length);+ } else {+ lineCounts = text.map(([k, v]) => {+ const length = `${k}: ${v}`.length;+ const line = length > 150 ? 150 : length;+ lineLengths.push(line);+ return `${k}: ${v}`;+ }).length;+ }- const calculateSize = (- text: string | [string, string][],- isParent = false,- isFolded: boolean- ) => {- let value = "";-- if (typeof text === "string") value = text;- else value = text.map(([k, v]) => `${k}: ${v}`).join("\n");-- const lineCount = value.split("\n");- const lineLengths = lineCount.map(line => line.length);- const longestLine = lineLengths.sort((a, b) => b - a)[0];+ const longestLine = Math.max(...lineLengths);const getWidth = () => {+ if (text.length === 0) return 35;if (Array.isArray(text) && !text.length) return 40;- if (!isFolded) return 35 + longestLine * 8 + (isParent ? 60 : 0);- if (isParent) return 170;+ if (!isFolded) return 35 + longestLine * 7.8 + (isParent ? 60 : 0);+ if (isParent && isFolded) return 170;return 200;};