-
Notifications
You must be signed in to change notification settings - Fork 185
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
Phone number support #133
Comments
+1 I'm using linkify for a mobile app and people are creating messages with phone numbers. This would be a huge plus for me. |
Hey @rlaferla, I created a class that creates anchors for US phone numbers:
|
+1 , Would be a huge improvement for mobile app ! |
how can add above for my linkify-string.js simple javascript file i want to support for us phone number? |
+1 will phone number parsing be implemented? |
@nfrasser I'm willing to code this feature and raise a PR if you could help me figure out the scope of this. As linkify promotes it's a zero dependency plugin, would it be fine to use external library like google's libphonenumber for the number recognition part? Until there's a support, this is my workaround which works fine with multiple numbers. Hope you guys find it useful. import { findPhoneNumbersInText } from 'libphonenumber-js'
telify = (origText) => {
let newText = origText
const getPhoneNum = findPhoneNumbersInText(newText);
if (newText?.length) {
getPhoneNum.forEach((match) => {
const pattern = origText.substring(match.startsAt, match.endsAt);
newText = newText.replace( pattern, `<a href="tel:${match.number.number}")>${pattern}</a>`);
});
}
return newText;
}
// usage > telify("Hey! you can call me at +1 (501) 234-5678 or in my local no# +91 50123-45678 ^_^ ") |
I'm trying to write a plugin out of this, but not able to figure it out. Is there any guides on writing custom plugin? |
+1 |
+1 |
Need (800) 555-1212 -> tel: url...
The text was updated successfully, but these errors were encountered: