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

Links: Automatically Format a New Hyperlink With Title Text From the Link Destination #20442

Open
lancewillett opened this issue Feb 25, 2020 · 6 comments
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.

Comments

@lancewillett
Copy link
Contributor

This change would immediately improve readability across a third of the web.

How might we encourage more useful and readable link titles instead of bare URLs or "here" or "#"? My suggestion is to adopt a common pattern from other editors such as Bear, GitHub, Asana, and Google Docs.

Automatically format a new hyperlink with title text from the link destination.

Typical workflow has one too many steps. When adding a link into the editor, I often go to the target page and copy/paste the URL first into the editor. Then, as a second step, I copy/paste the title text of the page as a "paste over" action to format the URL.

What if that second step is automated? What if Gutenberg goes to the target, async, and retrieves the title text? It could be the default behavior and create more readable links.

Other editors:

GitHub formats GitHub internal URLs this way, after saving the comment by replacing the bare URL with a full hyperlink.

Asana creates an inline hyperlink to other Asana links immediately after you paste the bare URL, using an async process, which updates in the textarea without a prompt.

Bear (the Mac and iOS app) does it on paste, with any bare URL.

Google Docs prompts you to replace the text automatically for other Google documents when you hover over the bare URL.

CC @mtias and @karmatosed in case this is previously suggested and I missed it.

@lancewillett lancewillett added [Type] Enhancement A suggestion for improvement. [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) labels Feb 25, 2020
@lancewillett
Copy link
Contributor Author

lancewillett commented Feb 25, 2020

Bear app:

bear

Google Docs:

google-doc

github

#18061

Oh — I was wrong about GitHub behavior; it doesn't pull the full title, just the issue number.

@karmatosed
Copy link
Member

karmatosed commented May 12, 2020

I love this idea. It feels like a small but easy step to improving the experience. My first feelings are that making this as automated as possible is the best path. As you can edit later, just having the best guess feels right.

What if that second step is automated? What if Gutenberg goes to the target, async, and retrieves the title text? It could be the default behavior and create more readable links.

This feels like worth moving into PR and then seeing if we want to iterate.

@karmatosed karmatosed added the Needs Dev Ready for, and needs developer efforts label May 12, 2020
@karmatosed
Copy link
Member

I'm going to add a visual of what code outputs today on add a link:

image

One iteration might be to allow editing of link titles and anything brought in as details.

@designsimply
Copy link
Member

#11930 was a similar request except it was specifically for the search option in the link inserter when adding a link to an existing post or page from the same site. It was a really nice enhancement! See #21240. Props @pwkip cc @aduth.

FWIW, I would love to see an update like this!

@pwkip
Copy link
Contributor

pwkip commented May 14, 2020

Thanks for the props :) I do believe this made sense for internal links. For external ones I'm not so sure if it would be better.

My thoughts:

  • pasting an external link in the editor already tries to do some smart stuff by converting it to an embed code. Which I personally find frustrating sometimes. adding more "smart" stuff on top of this, might be a bit much.
  • A web page title is often not the same as the post title. For example a post with the title "My thoughts about external links" will have a public title of: "My thoughts about external links - Bobby's super nice blog - Just another WordPress Site". We could also crawl the entire page and get the first <h1>, but then we are assuming that everyone is writing semantically correct websites. (which is very much not the case)

I'm not opposed the idea if we could make it work in a good way.. but I do believe it should be optional. After inserting the link add option: "attempt to replace this link with title"

@pipetko
Copy link

pipetko commented Nov 24, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) Needs Dev Ready for, and needs developer efforts [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants