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

API for expand and collapse #458

Merged
merged 21 commits into from
Jul 5, 2024
Merged

API for expand and collapse #458

merged 21 commits into from
Jul 5, 2024

Conversation

josdejong
Copy link
Owner

Implements a solution for #249

Initially I've tried to make the existing expand method more flexible, but it turns out there are a couple different use cases that can't be supported in an easy way by a single callback function, and the expand and collapse functionality is not symmetric. So, I ended up implementing 4 use cases in two methods:

// expand all nodes along the path, and update the visible sections of an array if needed 
// (for example used by `editor.scrollTo`)
editor.expand(path: JSONPath)

// expand all nodes along the path, and recursively expand part or all of the nested children inside the node 
// depending on the callback (used on Ctrl+Click on an expand button)
editor.expand(path: JSONPath, callback: (relativePath: JSONPath) => boolean)

// collapse a single node at the path 
// does not collapse parent nodes along the path, and does not collapse nested children
editor.collapse(path: JSONPath)

// collapse a single node at the path and collapse all of its children when recursive is true
editor.collapse(path: JSONPath, recursive: boolean)

Note that this is a breaking change, and will be merged in the v1 branch.

@josdejong josdejong merged commit 1e1e85c into v1 Jul 5, 2024
3 checks passed
@josdejong josdejong deleted the feat/expand-and-collapse branch July 5, 2024 09:53
@josdejong josdejong mentioned this pull request Jul 30, 2024
Merged
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant