Skip to content

Commit 34a982c

Browse files
committed
update defaultJson
1 parent 0ee978c commit 34a982c

File tree

3 files changed

+42
-27
lines changed

3 files changed

+42
-27
lines changed

src/features/editor/views/GraphView/CustomNode/TextNode.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled from "styled-components";
33
import { MdLink, MdLinkOff } from "react-icons/md";
44
import type { CustomNodeProps } from "src/features/editor/views/GraphView/CustomNode";
@@ -72,6 +72,12 @@ const Node = ({ node, x, y, hasCollapse = false }: CustomNodeProps) => {
7272
validateHiddenNodes();
7373
};
7474

75+
const childrenCountText = useMemo(() => {
76+
if (type === "object") return `{${childrenCount}}`;
77+
if (type === "array") return `[${childrenCount}]`;
78+
return "";
79+
}, [childrenCount, type]);
80+
7581
return (
7682
<Styled.StyledForeignObject width={width} height={height} x={0} y={0}>
7783
{isImage ? (
@@ -90,7 +96,7 @@ const Node = ({ node, x, y, hasCollapse = false }: CustomNodeProps) => {
9096
<TextRenderer>{value}</TextRenderer>
9197
</Styled.StyledKey>
9298
{isParent && childrenCount > 0 && childrenCountVisible && (
93-
<Styled.StyledChildrenCount>[{childrenCount}]</Styled.StyledChildrenCount>
99+
<Styled.StyledChildrenCount>{childrenCountText}</Styled.StyledChildrenCount>
94100
)}
95101
{isParent && hasCollapse && collapseButtonVisible && (
96102
<StyledExpand aria-label="Expand" onClick={handleExpand}>

src/features/editor/views/GraphView/lib/utils/calculateNodeSize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ type Size = { width: number; height: number };
77
export const isContentImage = (value: Text) => {
88
if (typeof value !== "string") return false;
99

10-
const isImageURL = /(https?:\/\/.*\.(?:png|jpg|gif))/i.test(value);
10+
const isImageURL = /(https?:\/\/.*\.(?:png|jpg|gif|svg))/i.test(value);
1111
const isBase64 = value.startsWith("data:image/") && value.includes("base64");
1212

1313
return isImageURL || isBase64;

src/store/useFile.ts

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,46 @@ import useJson from "./useJson";
1111

1212
const defaultJson = JSON.stringify(
1313
{
14-
squadName: "Super hero squad",
15-
homeTown: "Metro City",
16-
formed: 2016,
17-
secretBase: "Super tower",
18-
active: true,
19-
members: [
14+
appName: "JSON Crack",
15+
author: "Aykut Saraç",
16+
launched: 2022,
17+
openSource: true,
18+
stars: 34633,
19+
alternative: {
20+
appName: "ToDiagram",
21+
detail: "New powerful JSON editor.",
22+
website: "https://todiagram.com",
23+
brandColor: "#fe5e49",
24+
paid: true,
25+
},
26+
milestones: [
2027
{
21-
name: "Molecule Man",
22-
age: 29,
23-
secretIdentity: "Dan Jukes",
24-
powers: ["Radiation resistance", "Turning tiny", "Radiation blast"],
28+
title: "Launch",
29+
year: 2022,
30+
detail: "Released the first version.",
2531
},
2632
{
27-
name: "Madame Uppercut",
28-
age: 39,
29-
secretIdentity: "Jane Wilson",
30-
powers: ["Million tonne punch", "Damage resistance", "Superhuman reflexes"],
33+
title: "10K Stars",
34+
date: 2022,
35+
detail: "Achieved 10,000 stars on GitHub.",
3136
},
3237
{
33-
name: "Eternal Flame",
34-
age: 1000000,
35-
secretIdentity: "Unknown",
36-
powers: [
37-
"Immortality",
38-
"Heat Immunity",
39-
"Inferno",
40-
"Teleportation",
41-
"Interdimensional travel",
42-
],
38+
title: "20K Stars",
39+
date: 2023,
40+
detail: "Achieved 20,000 stars on GitHub.",
41+
},
42+
{
43+
title: "30K Stars",
44+
date: 2024,
45+
detail: "Achieved 30,000 stars on GitHub.",
4346
},
4447
],
48+
social: {
49+
github: "https://github.com/AykutSarac/jsoncrack.com",
50+
twitter: "https://x.com/jsoncrack",
51+
linkedin: "https://www.linkedin.com/company/todiagram",
52+
},
53+
images: ["http://localhost:3000/assets/logo.svg"],
4554
},
4655
null,
4756
2

0 commit comments

Comments
 (0)