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