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

[SuperEditor][SuperReader] - Add queries for attributions and attributed spans at the document level #2363

Open
matthew-carroll opened this issue Oct 4, 2024 · 0 comments
Labels
area_super_reader Related to SuperReader area_supereditor Pertains to SuperEditor bounty_junior time: 5

Comments

@matthew-carroll
Copy link
Contributor

It's tedious to try to query attribution data at the document level. Given a selection, you have to obtain all nodes for that selection. Then, you need to remove non-text nodes. Then you need to handle possible partial selection in the first node and last node. And then you need to query each text node for its own attributions and attribution ranges.

At the document level the user should be able to:

  • Check if an attribution(s) spans the entirety of a selection
  • Check if an attribution(s) appears anywhere in a selection
  • Get spans for an attribution(s) within a selection

When checking for attributions in a selection, the user should be able to specify whether the existence of non-text content in that selection voids the check, or whether the non-text content is ignored.

When reporting spans we'll need a new data structure. That data structure needs to hold a node ID, along with a set of attribution spans.

An example of where this is useful: The user wants to toggle a font color for the current selection. The toggle behavior should remove the font color, if the entire selection already has the given font color. Otherwise, if none of the selection has the font color, or only part of the selection has the font color, then the font color should be applied.

The above example is fairly straight forward when working with a single AttributedText. But doing this at the document level runs into the issues above.

@matthew-carroll matthew-carroll added area_supereditor Pertains to SuperEditor bounty_junior area_super_reader Related to SuperReader time: 5 labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area_super_reader Related to SuperReader area_supereditor Pertains to SuperEditor bounty_junior time: 5
Projects
None yet
Development

No branches or pull requests

1 participant