-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add support to sync node expand/collapse operations across editors #1440
Conversation
* Added onExpand callback option to be passed while creating JSONEditor * The callback is invoked when the expand/collapse is done non-programatically
Thanks @himanshu520 , your PR looks good at first sight. I'll review it soon. |
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.
The PR looks good, exactly what we're looking for 👌. Thanks for the clear description in the docs.
I made one inline comment, and I have one more question: can you add a new, minimal example in the /examples
section demonstrating two editors which keep their expanded state in sync? Is useful for users and also for you and me manually testing whether all works as expected.
docs/api.md
Outdated
@@ -679,6 +693,24 @@ Destroy the editor. Clean up DOM, event listeners, and web workers. | |||
|
|||
Expand all fields. Only applicable for mode 'tree', 'view', and 'form'. | |||
|
|||
#### `JSONEditor.expand(path, isExpand, recursive)` |
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.
Thinking aloud here: it may be nice to change the signature
JSONEditor.expand(path, isExpand, recursive)
to
JSONEditor.expand({path, isExpand, recursive})
Then you can pass the options even more easily from one editor to an other:
const editor1 = new JSONEditor(container1, { onExpand: (props) => editor2.expand(props) })
const editor2 = new JSONEditor(container2, { onExpand: (props) => editor1.expand(props) })
What do you think?
* Added JSONEditor.expand() method
* Added examples/25_sync_node_expand.html
Thanks for reviewing. I have updated the PR as per suggestions, please have a look again. PS - I would like to add that though |
Thanks @himanshu520 , looks good 👌 . You're right, expanding only works if a path exists. I'll add a remark on top in the example explaining this. |
Published now in |
The above two additions would allow library users to sync node expand/collapse operations when having multiple editors (#1217).