fix: object/array diff

This commit is contained in:
cha0s 2020-06-20 05:06:22 -05:00
parent c01c0172e8
commit 78cda4d07a

View File

@ -11,18 +11,24 @@ const decorate = compose(
const ObjectRenderer = ({
value,
}) => (
<div className="object">
<span className="bracket open">{'{'}</span>
<pre contentEditable>
<code>
{' '}
{(value ? JSON.stringify(value, null, 2).slice(1).slice(0, -1) : '').trim('\n')}
</code>
</pre>
<span className="bracket close">{'}'}</span>
</div>
);
}) => {
const json = ('object' === typeof value && null !== value)
? JSON.stringify(value, null, 2)
: '{}';
const brackets = '{' === json.slice(0, 1) ? '{}' : '[]';
return (
<div className="object">
<span className="bracket open">{brackets.slice(0, 1)}</span>
<pre contentEditable>
<code>
{' '}
{(value ? json.slice(1).slice(0, -1) : '').trim('\n')}
</code>
</pre>
<span className="bracket close">{brackets.slice(1)}</span>
</div>
);
};
ObjectRenderer.propTypes = {
...propertyPropTypes,