WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 11 months ago

Last modified 11 months ago

#19992 closed enhancement (fixed)

Auto-fill URL field on Insert/edit link popup

Reported by: tillkruess Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.3.1
Component: Editor Keywords: has-patch
Focuses: Cc:

Description

I'd like to see the following behavior: When I select a plain URL or email address in the editor and click on "Insert/edit link" the URL field is already populated with either the URL or with a "mailto:<email-address>". Any thoughts? I'd more than happy to write a patch.

Attachments (5)

19992.patch (2.8 KB) - added by tillkruess 3 years ago.
19992.diff (3.0 KB) - added by wonderboymusic 12 months ago.
19992.2.diff (2.9 KB) - added by SergeyBiryukov 11 months ago.
19992.3.diff (2.6 KB) - added by SergeyBiryukov 11 months ago.
19992.4.diff (943 bytes) - added by azaozz 11 months ago.

Download all attachments as: .zip

Change History (28)

comment:2 @nacin3 years ago

Sounds good to me.

comment:3 @DrewAPicture3 years ago

  • Cc xoodrew@… added

@tillkruess3 years ago

comment:4 @tillkruess3 years ago

The regular expressions used in the attached patch where taken from jquery.validate.js. Not sure if there are better ones out there or maybe even already in WP?

comment:5 @sabreuse3 years ago

  • Cc sabreuse@… added

comment:6 @SergeyBiryukov3 years ago

  • Keywords has-patch added

comment:7 @tillkruess3 years ago

  • Version changed from 3.3.1 to 3.4

comment:8 @DrewAPicture3 years ago

  • Version changed from 3.4 to 3.3.1

The version field is used to track when an issue was first reported.

comment:9 @ryansatterfield2 years ago

Why does the patch include ftp on line 290? I was going to submit a ticket for mailto: support since I just had a client complain about not being able to link to their email address and only to their site. I am glad there is a patch :).

Last edited 2 years ago by ryansatterfield (previous) (diff)

comment:10 @tillkruess2 years ago

The script catches not only email addresses, it also handles HTTP and FTP URLs.

comment:11 @ryansatterfield2 years ago

Cool. I am always for keeping WordPress as simple as possible and not confusing end-users. Do you agree that it would be easier for most users just to have http, https and mailto? How many people need to link to FTP? If you know about FTP, you probably can add it into the HTML.

@wonderboymusic12 months ago

comment:12 @wonderboymusic12 months ago

  • Milestone changed from Awaiting Review to 4.0

19992.diff refreshes so it applies against modern-day trunk

comment:13 @wonderboymusic12 months ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28705:

When a plain URL or email address is selected in the editor and "Insert/edit link" is clicked, pre-populate the URL field with the URL or mailto:<email-address>.

Props tillkruess.
Fixes #19992.

comment:14 @SergeyBiryukov12 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

These regexes should be put into variables, as suggested in IRC.

comment:15 @azaozz11 months ago

Do we want this to work in the Text editor too? Also, why the "super bulky" regexp? We are not validating user input, just suggesting. Maybe can use something much smaller/faster?

@SergeyBiryukov11 months ago

comment:16 @azaozz11 months ago

In [28750]:

wpLink: use the proper instance of the editor when looking at the selection. Move the email and URL regexp to variables. See #19992

comment:17 @ircbot11 months ago

This ticket was mentioned in IRC in #wordpress-dev by azaozz. View the logs.

@SergeyBiryukov11 months ago

comment:19 @SergeyBiryukov11 months ago

In 28751:

wpLink: use simpler expressions to detect email address or URL. We are not validating user input here, just suggesting.

see #19992.

comment:20 @SergeyBiryukov11 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

@azaozz11 months ago

comment:21 follow-up: @azaozz11 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The last patch was limiting the URLs only to the domain. 19992.4.diff matches whole URLs including query/fragment and fixes double encoding of &. It still excludes IDNs and the new(er) TLDs that are longer than 4 letters. Should we support these?

Last edited 11 months ago by azaozz (previous) (diff)

comment:22 @azaozz11 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 28828:

wpLink: support whole URLs including query/fragment when pre-filling the URL field. Fixes #19992

comment:23 in reply to: ↑ 21 @SergeyBiryukov11 months ago

Replying to azaozz:

It still excludes IDNs and the new(er) TLDs that are longer than 4 letters. Should we support these?

I think it's OK to exclude those for now for the sake of simplicity.

Note: See TracTickets for help on using tickets.