feat: add text selection across multiple text views (MVP)#15
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds cross-block text selection functionality for markdown text on macOS, allowing users to select text across multiple markdown blocks in a single selection. This is an MVP (Minimum Viable Product) implementation that improves the user experience when copying text from messages.
Changes:
- Added new
SelectableMarkdownTextcomponent that combines multiple markdown blocks into a single selectable NSTextView - Modified
MarkdownTextto conditionally use the new selection mode via an environment value on macOS - Enabled cross-block text selection in
MessageBodyby default for message content
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| SelectableMarkdownText.swift | New component implementing multi-block text selection using NSTextView with custom clipboard handling for Discord markdown |
| MarkdownText.swift | Added environment key and conditional rendering to support cross-block selection mode on macOS |
| MessageBody.swift | Enabled the cross-block text selection feature for message content |
llsc12
left a comment
There was a problem hiding this comment.
These changes make MarkdownText ignore block elements, meaning things like codeblocks, lists and more do not show up anymore.
|
For now, it might be best to look into this later since it seems a lot more difficult to tackle than anticipated. Tagging as help needed. |
|
yes help wanted indeed. i built a small prototype with NSAttributedString with code blocks. Since HighlightSwift already has an option to return NSattributed text, this is fine. Lists shouldn't be too hard, looks like NSAttributedString has built-in styling for it the problem is with the codeblock styling, I have to create a custom model with ObservableObject to read the rects of the code and return/update where to draw the background and to put the copy button (feels more complicated than it has to be) This is probably not inexpensive but I think it's possible to get away with it if we only do it for the content onscreen. If this really tanks performance i hope we could have a toggle (which shouldn't be hard since none of this will be on iOS anyway?) And for custom emojis I think I can use NSTextAttachment. I think with how this is going there is no chance of cross message select, which is unfortunate |
Screen.Recording.2026-02-01.at.20.52.18.mov
theres a tiny bug regarding the lines when selecting wildly. otherwise very usable.