✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
fix: update json deleting/adding keys
AykutSaracc828b04004f9
diff --git a/src/containers/Modals/NodeModal/index.tsx b/src/containers/Modals/NodeModal/index.tsxindex d86f31c1..ae6174e2 100644--- a/src/containers/Modals/NodeModal/index.tsx+++ b/src/containers/Modals/NodeModal/index.tsx@@ -113,11 +113,6 @@ export const NodeModal: React.FC<ModalProps> = ({ opened, onClose }) => {<CodeBlock maw={600}>{nodeData}</CodeBlock>)}</Stack>- {editMode && (- <Text color="dimmed" fz="xs">- Keys cannot be renamed and will be added as a new field.- </Text>- )}{isEditVisible && (<Stack spacing="xs">{editMode ? (diff --git a/src/store/useFile.ts b/src/store/useFile.tsindex 8abe15f3..49f2bbeb 100644--- a/src/store/useFile.ts+++ b/src/store/useFile.ts@@ -48,14 +48,31 @@ const initialStates = {export type FileStates = typeof initialStates;-const isURL =- /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi;+const isURL = (value: string) => {+ return /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi.test(+ value+ );+};const debouncedUpdateJson = debounce((value: unknown) => useJson.getState().setJson(JSON.stringify(value, null, 2)),800);+const filterArrayAndObjectFields = (obj: object) => {+ const result = {};++ for (let key in obj) {+ if (obj.hasOwnProperty(key)) {+ if (Array.isArray(obj[key]) || typeof obj[key] === "object") {+ result[key] = obj[key];+ }+ }+ }++ return result;+};+const useFile = create<FileStates & JsonActions>()((set, get) => ({...initialStates,clear: () => {@@ -94,7 +111,7 @@ const useFile = create<FileStates & JsonActions>()((set, get) => ({},fetchFile: async id => {try {- if (isURL.test(id)) return get().fetchUrl(id);+ if (isURL(id)) return get().fetchUrl(id);const file = await getFromCloud(id);get().setFile(file);@@ -115,7 +132,7 @@ const useFile = create<FileStates & JsonActions>()((set, get) => ({// check if array string valueif (typeof changedValue !== "string") {tempValue = {- ...pathJson,+ ...filterArrayAndObjectFields(pathJson),...changedValue,};} else {