-
-
Notifications
You must be signed in to change notification settings - Fork 31
Override isCollection for custom objects #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey, thanks for the suggestion. I actually had to deal with this issue myself when I made a custom handler for And yeah, I had the exact same issue -- the json-edit-react/src/helpers.ts Lines 19 to 20 in dc278d2
But yeah, that's pretty specific for Dates, and as you've shown, there are other object types that we might want to not display as collections. I like your suggestion of an addition |
That would be fantastic, thanks! And there's no rush of course–if it takes longer than a week that's perfectly fine too. 😄 We've come up with a very silly workaround (which I won't admit publicly) in the meantime… |
* Evaluate custom nodes in parent, create "Enhanced Link" component * Update README.md
Okay, I've done this but not published a release yet, will release later this weekend.
Ha, some ugly CSS hackery I'm guessing? |
Hi @markdascher, this is done now and available in v1.27.0 I've called the prop There are a couple of example implementations:
Hope that works well for you. If you think your custom "lossless number" component would be useful, you might want to contribute it to the Custom Component library :) |
Suggestion
Provide some way to use custom objects without treating them all as collections. There's a
showCollectionWrapper
property which sounds close, except it just hides the braces. It doesn't get rid of the extra line break, expand/contract functionality, etc. Maybe something likeisCollection: false
in customNodeDefinitions.In our case, only "plain" Objects are collections, since we're parsing JSON (override some specific nodes with a custom object) and then passing in the result. So some logic like
value.constructor === Object
might also work. That probably wouldn't work in general, though.Use case
We'd like to parse JSON using the lossless-json library, which puts numbers into a LosslessNumber type. The purpose is to show formatted JSON that doesn't modify the input at all. It doesn't translate
1.0000
into1
or translate123456789012345678901234567890
into1.2345678901234568e+29
, etc.We can almost make this work with json-edit-react already, but it treats LosslessNumber as a collection.
The text was updated successfully, but these errors were encountered: