Skip to content

Commit

Permalink
feat: fixing the json does not render properly
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Oct 21, 2023
1 parent 770197a commit f5b54a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/renderer/datatype/JsonType.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import BaseType from './BaseType';
import deepEqual from 'deep-equal';

export default class JsonType implements BaseType<object> {
protected value?: object | null;
export default class JsonType implements BaseType<object | string> {
protected value?: object | string | null;

constructor(value?: object | string | null) {
if (typeof value === 'object') this.value = value;
else if (typeof value === 'string') {
try {
this.value = JSON.parse(value);
} catch {
this.value = undefined;
this.value = value;
}
} else {
this.value = value;
Expand Down Expand Up @@ -69,7 +69,7 @@ export default class JsonType implements BaseType<object> {
return stringValue.includes(search);
}

getValue(): object | null | undefined {
getValue(): object| string | null | undefined {
return this.value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ function TableCellJsonEditor({
);
}

function TableCellJsonContent({ value }: TableEditableContentProps) {
function TableCellJsonContent({ value }: TableEditableContentProps<JsonType>) {
return (
<TableCellContent
value={value}
value={value.toNullableString()}
badge="json"
mono
displayString={value ? JSON.stringify(value) : undefined}
/>
);
}
Expand All @@ -88,7 +87,7 @@ const TableCellJson = createTableCellType({
return new JsonType(null);
},
onCopy: (value: JsonType) => {
return JSON.stringify(value);
return value.toString();
},
onPaste: (value: string) => {
return { accept: true, value: new JsonType(value) };
Expand Down

0 comments on commit f5b54a1

Please sign in to comment.