YYsuni / react18-json-view

JSON viewer for react18
https://jv.yysuni.com/
MIT License
236 stars 15 forks source link

pretty-print copied json by default #26

Closed marcklingen closed 7 months ago

marcklingen commented 7 months ago

I suggest to default to pretty-printed json when copying a node.

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
json-view ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 2:35am
react18-json-view ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 30, 2023 2:35am
YYsuni commented 7 months ago

It does look better, I see… umm… will it have any impact on other users’ copying?

YYsuni commented 7 months ago

Ok, I will make improvements based on this.

marcklingen commented 7 months ago

Agree, it changes the behavior and we don't know if someone relies on it.

Alternatively, making the 'space' parameter configurable via an optional prop could also work.

YYsuni commented 7 months ago

Agree, it changes the behavior and we don't know if someone relies on it.

Alternatively, making the 'space' parameter configurable via an optional prop could also work.

I add a new parameter customizeCopy, and you can import the internal stringfy and set: customizeCopy: (node: any) => stringify(node, 4).

This approach will provide better scalability, I thought 🙌.

Additionally, you can directly try it out on the storybook.

0.2.7-canary.2

marcklingen commented 7 months ago

Thanks @YYsuni! Added it to our project here (needed to copy your whole function to retain some of the capabilities): https://github.com/langfuse/langfuse/pull/621/files#diff-aa90080c04079bff9605508968f2106518fc1418f230e8ce1e73569cdc5d96b6