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

Can only select text from one paragraph at a time #264

Open
everuribe opened this issue Oct 6, 2023 · 12 comments
Open

Can only select text from one paragraph at a time #264

everuribe opened this issue Oct 6, 2023 · 12 comments

Comments

@everuribe
Copy link

Describe the bug
When multiple paragraph strings are presented in a MarkdownUI view, the user can only select text from one paragraph at a time.

Checklist

  • ✅ I can reproduce this issue with a vanilla SwiftUI project.
  • ✅ I can reproduce this issue using the main branch of this package.
  • ✅ This bug hasn't been addressed in an existing GitHub issue.

Steps to reproduce
Explanation of how to reproduce the incorrect behavior. This could include an attached project, a link to code, or a Markdown-formatted text exhibiting the issue.

  1. Display multi-paragraph text broken up by newlines

Expected behavior
Should be able to select across all paragraphs (except maybe if broken up by a different markdown section type)

Screenshots
image

Version information

  • MarkdownUI: 2.2.0
  • OS: macOS Sonoma
  • Xcode: 15.0
@gonzalezreal
Copy link
Owner

Hi @everuribe,

This is a known issue of MarkdownUI. The current implementation combines multiple Text and Image views into containing layout views, which makes text selection work only at a paragraph level. I don't have a solution at the moment, but I am trying different things to make text selection work.

@everuribe
Copy link
Author

Thanks for the context! I guess it relies on newlines to be able to switch to a different markdown type and therefore view but maybe we can detect if it's just a continuation of the same markdown type and keep it in the same Text view? I assume this is already happening for code blocks.

@gonzalezreal
Copy link
Owner

It's a bit more complicated than that. It doesn't rely on newlines, as spacing is configurable per block. On top of that, styling adds yet another layer of indirection. Regarding code blocks, those are rendered in a single view, so it works as you would expect.

As a workaround, you could add a gesture to the Markdown view that displays a context menu with an item to copy the contents.

@wyk111wyk
Copy link

I found it's not working on Mac Catalyst

@leecaa leecaa mentioned this issue May 24, 2024
3 tasks
@mattcorey
Copy link

1 for this one - I'll add that being able to highlight individual words, as is typically seen when using Edit Menus would be ideal, however being able to copy an entire view, rather than one paragraph at a time would be a decent fallback.

I know this is not (shockingly) possible with a SwiftUI Text view, and I'm not particularly optimistic about finding a way to implement it, but wanted to add this feedback

@will-lumley
Copy link

1 on this issue. Would love to be able to do this at some point.

@mergesort
Copy link

I was just checking in/wanted to voice my support on this as well, since I'm looking to add a feature that would let users highlight specific text in a Reader Mode I'm implementing. Thanks for the great library!

@itsthisjustin
Copy link

In case it helps prioritize this, we are switching off this library on our next project specifically because of this issue. The number one request from users is the ability to simply copy the formatted text out like any other app would.

@mattcorey
Copy link

Same - I ended up rolling my own UIViewRepresentable based on UITextView to support this feature, but would move back to this component in a heartbeat if this were to be prioritized

@longseespace
Copy link

I'm on the same boat. Is there a way to fund this?

@gonzalezreal
Copy link
Owner

Hi all,

As mentioned in a previous comment, fixing this issue is challenging. The key is accessing and controlling the text layout(s) in a view hierarchy.

I am working on a replacement for SwiftUI Text view based on Canvas and Core Text, and the results look promising. However, there is still a lot of work to do, and I can't provide an ETA.

Thank you for being so patient!

@will-lumley
Copy link

Amazing, thanks @gonzalezreal for the update, much appreciated!

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

No branches or pull requests

8 participants