-
Notifications
You must be signed in to change notification settings - Fork 872
improvement: Wrap output for lists and dictionaries #2995
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
akshayka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. The UI is a bit obtrusive and distracting, and I can imagine it interfering with many people's existing apps.
Some thoughts.
Could the same functionality be done in a much less obtrusive way? Not using the switch component, but making it appear as if it were a native part of the JSON viewer. In fact, does the JSON component we use have this capability?
|
I'm open to different options! Switch was just the first that came to mind. And we're using texteainc/json-viewer, which doesn't seem to have wrapping capability. |
|
Would a right click toggle or context menu option be preferable? A global keyboard shortcut would be even more hidden. |
|
@wasimsandhu Thanks for the flexibility. Here is what I suggest.
In this way, when a long string is displayed, it won't eat up a ton of vertical space, but when the user expands it, they can still see the full text. |
|
That sounds great! Made the changes. The only problem is that |
| {isCollapsed ? ( | ||
| <span onClick={() => setIsCollapsed(false)}> | ||
| {props.text.slice(0, 500)} | ||
| {props.text.length > 500 && "..."} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this changes the default case such that all text is hidden at 500. that is ok w/ me, but just point that out.
so if you have a lot of keys you want to expand, you'd have to click all of them (maybe not a common case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay I'll add a comment there. as an aside, this is making me think that having a dedicated JSON viewer / editor plugin (outside the default one for outputs) would be nice to have...
edit: nevermind, looks like that's what mo.tree is for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that's what mo.tree is for.
akshayka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't played with it, but from the screenshot LGTM
|
hi, this is not working for defaultdict |
|
that was fast! |


📝 Summary
Completes #2977.
🔍 Description of Changes
Add switch to wrap text for list and dictionary (JSON) outputs. Makes it easier to read long string outputs 🙂
Before:
After:
📋 Checklist
📜 Reviewers
@akshayka OR @mscolnick