Skip to content
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

feat: focus a specific path #335

Open
jeremysf opened this issue May 26, 2023 · 2 comments
Open

feat: focus a specific path #335

jeremysf opened this issue May 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@jeremysf
Copy link

First off, thank you so much for this project!

I'm trying to use it to implement a real-time debugger for our graphical editor which can convert the graphical data being edited to JSON.

Somewhat related to #326, I'd like to be able to specify a path (similar string|number format to the onChange() function) that will cause the viewer to expand objects and scroll to focus the path.

I want to use this to be able to do a custom search inside the JSON and tell the json-viewer to jump to the location, but I also want to be able to interact with our graphical data and jump the json-viewer to correlate to the graphical element. Somewhat like "inspect element" in the Webkit Inspector.

Happy to do the work, but would love any pointers/ideas for the best way to approach such a patch.

@pionxzh
Copy link
Collaborator

pionxzh commented May 26, 2023

Hi, thanks for using json-viewer.

I think we will need an API to control the collapse/expansion of a field programmatically to achieve this. #326 describes a need to pre-define a rule to control the expansion. I need time to think about how to support both use cases. And for the "jumping to", it's a little bit tricky, to be honest. The viewer itself shouldn't provide APIs to "scroll", the cleanest approach will be provides enough information on the DOM structure for people to construct the selector. So that you can do things like

setExpansion(path, true)
setTimeout(()=> {
  scrollToElement(selector)
}, 0)

For the interaction part, could you elaborate more? You should be able to customize the appearance of graphical data already.

@pionxzh pionxzh added the enhancement New feature or request label May 26, 2023
@jeremysf
Copy link
Author

Thank you so much for the speedy reply!

What you describe would be awesome.

As for the interaction, I was being unclear. The setExpansion() type API and ability to construct a selector you describe would cover everything I want to be able to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants