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: maintain selection when switching from/to text mode #521

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

josdejong
Copy link
Owner

@josdejong josdejong commented Feb 13, 2025

To achieve this, we first have to implement two helper functions to convert from a text position to a JSONSelection and vice versa: function findTextLocation already exists, and this PR implements a new function findSelectionFromTextLocation.

TODO:

  • work out findSelectionFromTextLocation in detail: it must return KeySelection, ValueSelection, AfterSelection, InsideSelection, and MultiSelection
  • write unit tests
  • in TextMode.svelte, extend the function applyExternalSelectionwith handling the case whenexternalSelectionis aJSONSelection. Use findTextLocation` there.
  • In TreeMode and TableMode extend the function applyExternalSelection to handle the case when externalSelection is a JSONSelection. Use findSelectionFromTextLocation there.
  • Test the performance in case of large documents. If needed, restrict maintaining the selection to small enough documents.
  • Create and export utility functions to convert from JSONSelection to TextSelection

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