feat(desktop): pasting a link over selected composer text now hyperlinks it - #96034
Open
teknium1 wants to merge 1 commit into
Open
feat(desktop): pasting a link over selected composer text now hyperlinks it#96034teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
…aste Pasting exactly one http(s) link while composer text is selected now turns the selection into a markdown link ([selected text](url)) instead of replacing it — the behavior every rich text editor ships. - resolveExactLinkPaste(): recognizes a clipboard payload that is exactly one supported link (bare or <...>-wrapped, host required, no prose or trailing punctuation) and returns the href. - selectionLinkLabel(): the selected composer text eligible for linking; rejects collapsed selections, selections spanning ref chips or line breaks, and whitespace-only selections. - markdownLinkFor(): builds the markdown link, escaping square brackets. - handlePaste wires the three together ahead of the @url: chip path; any non-qualifying paste falls through to existing behavior. Adapted from Buzz's TipTap link-mark approach to Hermes' contenteditable composer: we emit a markdown link (the composer's native rich construct) rather than a ProseMirror mark.
Contributor
૮ >ﻌ< ა ci reviewran on d76bd67 — Port from block/buzz#6684: hyperlink selected composer text
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Pasting exactly one
http(s)link while composer text is selected now turns that text into a markdown link ([selected text](url)) instead of replacing it — the behavior every rich text editor ships. Ported from block/buzz#6684.Changes
apps/desktop/src/app/chat/composer/url-refs.tsresolveExactLinkPaste()— recognizes a clipboard payload that is exactly one supported link (bare or<…>-wrapped, host required, no surrounding prose or trailing sentence punctuation) and returns the href.selectionLinkLabel()— the selected composer text eligible for linking; rejects collapsed selections, selections outside the editor, selections spanning ref chips or line breaks, and whitespace-only selections.markdownLinkFor()— builds the markdown link, escaping[/]in the label.apps/desktop/src/app/chat/composer/index.tsx—handlePastechecks the pair ahead of the@url:chip path; any non-qualifying paste (prose, multiple links, chip/multiline selection, no selection) falls through to existing behavior unchanged.apps/desktop/src/app/chat/composer/url-refs.test.ts— 13 new tests covering accept/reject shapes for all three helpers.Ours vs theirs
Buzz's composer is TipTap/ProseMirror, so their implementation applies a
linkmark over the selection and collapses the caret. Hermes' composer is a contenteditable with its own chip/ref pipeline — the natural equivalent is emitting a markdown link throughinsertComposerContentsAtCaret(replacing the selection), which round-trips through the draft store and renders as a link downstream. Their deep-link canonicalization is Buzz-specific and was not ported; our recognizer reuses the composer's existingURL_RE/splitUrlTail/hasHostprimitives so link acceptance stays consistent with the@url:chip path.Validation
vitest --project ui url-refs.test.tsvitest --project ui src/app/chat/composer/tsc -p . --noEmiteslinton touched filesInfographic