gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Add `tel:` when linking phone numbers

Open jeryj opened this issue 1 year ago • 1 comments

What problem does this address?

When adding a link to email addresses, we automatically apply the mailto: for the link. It would be great to do this for telephone numbers too.

What is your proposed solution?

Follow the same route as https://github.com/WordPress/gutenberg/pull/14857. The biggest hurdle would be getting the regex for phone numbers.

jeryj avatar Aug 26 '24 15:08 jeryj

Hi @jeryj I have raised a PR for the same.

Phone Number Regex: ^\+?(\d{1,3})?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

  • Optional country code: With or without + (e.g., +1, 1, +44).
  • Area code: 3 digits, with or without parentheses (e.g., 123, (123)).
  • Separators: Optional hyphen, dot, or space between parts.
  • Local number: 3 digits
  • Separators: Optional hyphen, dot, or space between parts.
  • Local number: 4 digits

devansh016 avatar Aug 29 '24 06:08 devansh016