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][SuperText][AttributedText] - Leading and trailing space around desired text fragments #2315

Open
matthew-carroll opened this issue Sep 14, 2024 · 0 comments
Assignees
Labels
area_attributed_text Related to attributed_text area_super_reader Related to SuperReader area_super_text area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField bounty_junior f:clickup time:10 Spend 10 hours or less

Comments

@matthew-carroll
Copy link
Contributor

Consider inline code styling. Inline code typically includes 3 elements different from the text around it: a monospace font, a rounded rectangle behind the text, and extra space at the leading and trailing edge of every such rectangle.

There are some other use-cases that want something similar.

The most complete way to implement such a capability is a line-based flow layout, which supports arbitrary widgets within text, within widgets, within text, etc. But this requires a re-write of Flutter's RenderParagraph and even the text painter.

At the moment, we already support custom fonts for text runs. We also support displaying highlights with rounded corners behind arbitrary text runs. The one thing we're missing is the extra space at the leading and trailing edges of those background rectangles.

Without a new text layout system, I don't think we can add space at the leading and trailing edge of every rectangle (consider multiple lines of wrapped text). However, I do believe we can hack some space at the leading and trailing edge of the entire inline code text block:

This is regular text and |---this is hypothetical inline code---|.

Flutter supports widgets within text. Flutter's problem is that it doesn't apply line-based layout to said widgets. However, in this case, we should be able to use Flutter's standard inline widget behavior to add SizedBoxs just before and after the desired text run. From there, we need to update selection computation to never allow selection of just the SizedBox. E.g., the caret either sits to the left of the leading SizedBox, or the caret sits to the right of the first character in the code box.

@matthew-carroll matthew-carroll added area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField bounty_junior time:10 Spend 10 hours or less area_attributed_text Related to attributed_text area_super_text area_super_reader Related to SuperReader f:clickup labels Sep 14, 2024
@matthew-carroll matthew-carroll self-assigned this Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area_attributed_text Related to attributed_text area_super_reader Related to SuperReader area_super_text area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField bounty_junior f:clickup time:10 Spend 10 hours or less
Projects
None yet
Development

No branches or pull requests

1 participant