Skip to content

Commit ebe0858

Browse files
authored
Merge pull request #215
feat: replace text inputs with code editor in JSON tools
2 parents d8b214e + 4cec13d commit ebe0858

File tree

7 files changed

+33
-14
lines changed

7 files changed

+33
-14
lines changed

src/pages/tools/json/escape-json/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import ToolContent from '@components/ToolContent';
3-
import ToolTextInput from '@components/input/ToolTextInput';
3+
import ToolCodeInput from '@components/input/ToolCodeInput';
44
import ToolTextResult from '@components/result/ToolTextResult';
55
import { escapeJson } from './service';
66
import { CardExampleType } from '@components/examples/ToolExamples';
@@ -88,7 +88,12 @@ export default function EscapeJsonTool({
8888
<ToolContent
8989
title={title}
9090
inputComponent={
91-
<ToolTextInput title="Input JSON" value={input} onChange={setInput} />
91+
<ToolCodeInput
92+
title="Input JSON"
93+
value={input}
94+
onChange={setInput}
95+
language="json"
96+
/>
9297
}
9398
resultComponent={
9499
<ToolTextResult

src/pages/tools/json/json-to-xml/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from 'react';
22
import ToolContent from '@components/ToolContent';
3-
import ToolTextInput from '@components/input/ToolTextInput';
3+
import ToolCodeInput from '@components/input/ToolCodeInput';
44
import ToolTextResult from '@components/result/ToolTextResult';
55
import { convertJsonToXml } from './service';
66
import { CardExampleType } from '@components/examples/ToolExamples';
@@ -84,7 +84,12 @@ export default function JsonToXml({ title }: ToolComponentProps) {
8484
compute={compute}
8585
exampleCards={exampleCards}
8686
inputComponent={
87-
<ToolTextInput title="Input Json" value={input} onChange={setInput} />
87+
<ToolCodeInput
88+
title="Input Json"
89+
value={input}
90+
onChange={setInput}
91+
language="json"
92+
/>
8893
}
8994
resultComponent={
9095
<ToolTextResult title="Output XML" value={result} extension={'xml'} />

src/pages/tools/json/minify/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import ToolContent from '@components/ToolContent';
3-
import ToolTextInput from '@components/input/ToolTextInput';
3+
import ToolCodeInput from '@components/input/ToolCodeInput';
44
import ToolTextResult from '@components/result/ToolTextResult';
55
import { minifyJson } from './service';
66
import { CardExampleType } from '@components/examples/ToolExamples';
@@ -60,10 +60,11 @@ export default function MinifyJson({ title }: ToolComponentProps) {
6060
<ToolContent
6161
title={title}
6262
inputComponent={
63-
<ToolTextInput
63+
<ToolCodeInput
6464
title={t('minify.inputTitle')}
6565
value={input}
6666
onChange={setInput}
67+
language="json"
6768
/>
6869
}
6970
resultComponent={

src/pages/tools/json/prettify/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Box } from '@mui/material';
22
import React, { useRef, useState } from 'react';
3-
import ToolTextInput from '@components/input/ToolTextInput';
3+
import ToolCodeInput from '@components/input/ToolCodeInput';
44
import ToolTextResult from '@components/result/ToolTextResult';
55
import { beautifyJson } from './service';
66
import ToolInfo from '@components/ToolInfo';
@@ -130,10 +130,11 @@ export default function PrettifyJson({ title }: ToolComponentProps) {
130130
title={title}
131131
input={input}
132132
inputComponent={
133-
<ToolTextInput
133+
<ToolCodeInput
134134
title={t('prettify.inputTitle')}
135135
value={input}
136136
onChange={setInput}
137+
language="json"
137138
/>
138139
}
139140
resultComponent={

src/pages/tools/json/stringify/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box } from '@mui/material';
22
import React, { useState } from 'react';
33
import ToolContent from '@components/ToolContent';
4-
import ToolTextInput from '@components/input/ToolTextInput';
4+
import ToolCodeInput from '@components/input/ToolCodeInput';
55
import ToolTextResult from '@components/result/ToolTextResult';
66
import { stringifyJson } from './service';
77
import { ToolComponentProps } from '@tools/defineTool';
@@ -103,10 +103,11 @@ export default function StringifyJson({ title }: ToolComponentProps) {
103103
compute={compute}
104104
exampleCards={exampleCards}
105105
inputComponent={
106-
<ToolTextInput
106+
<ToolCodeInput
107107
title="JavaScript Object/Array"
108108
value={input}
109109
onChange={setInput}
110+
language="json"
110111
/>
111112
}
112113
resultComponent={

src/pages/tools/json/tsv-to-json/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
22
import ToolContent from '@components/ToolContent';
3-
import ToolTextInput from '@components/input/ToolTextInput';
3+
import ToolCodeInput from '@components/input/ToolCodeInput';
44
import ToolTextResult from '@components/result/ToolTextResult';
55
import { convertTsvToJson } from './service';
66
import { CardExampleType } from '@components/examples/ToolExamples';
@@ -216,7 +216,12 @@ export default function TsvToJson({
216216
exampleCards={exampleCards}
217217
getGroups={getGroups}
218218
inputComponent={
219-
<ToolTextInput title="Input TSV" value={input} onChange={setInput} />
219+
<ToolCodeInput
220+
title="Input TSV"
221+
value={input}
222+
onChange={setInput}
223+
language="tsv"
224+
/>
220225
}
221226
resultComponent={
222227
<ToolTextResult title="Output JSON" value={result} extension={'json'} />

src/pages/tools/json/validateJson/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import ToolTextInput from '@components/input/ToolTextInput';
2+
import ToolCodeInput from '@components/input/ToolCodeInput';
33
import ToolTextResult from '@components/result/ToolTextResult';
44
import { CardExampleType } from '@components/examples/ToolExamples';
55
import { validateJson } from './service';
@@ -65,10 +65,11 @@ export default function ValidateJson({ title }: ToolComponentProps) {
6565
<ToolContent
6666
title={title}
6767
inputComponent={
68-
<ToolTextInput
68+
<ToolCodeInput
6969
title={t('validateJson.inputTitle')}
7070
value={input}
7171
onChange={setInput}
72+
language="json"
7273
/>
7374
}
7475
resultComponent={

0 commit comments

Comments
 (0)