Autolinker.js
Autolinker.js copied to clipboard
More customizable newWindow option
The newWindow option should be more customizable. Currently, newWindow is set to true by default, which makes all links, including phone numbers and emails, to open in a new tab.
The best enhancement would be to allow specifying a boolean for newWindow for each type, like so:
Autolinker.link( text, {
newWindow: {
urls: true,
email: false,
phone: false
}
});
An alternative (or in addition to the above) solution would be to allow newWindow to be specified on the respective option, like so:
Autolinker.link( text, {
newWindow: true,
email: {
newWindow: false
},
phone: {
newWindow: false
}
});
This change would allow a more customizable user experience.
Hey @dannyharding10. Good call, I guess phone numbers probably shouldn't even be opened in a new window by default. For email, that one's debatable (can depend on if users are using an email application or webmail), but making it customizable would definitely be useful.
I like your second suggestion. Thoughts @olafleur?
Btw, would you have any time to take a stab at it and create a pull request?
Yes, will look at that when I have some time!
@olafleur Sorry, I meant if @dannyharding10 had some time for a PR, but if you have some time too then of course that would be good!
Ha! Ha! Ok ! Then if you need help @dannyharding10 feel free to ask ! :)
Yeah I'll take a look, thanks! I will start with the second option I suggested.
@gregjacobs just to make sure I am working in the right spot, do I add this change to dist/Autolinker.js or src/Autolinker.js or somewhere else? I'm sure there are other files I'll be adding to, but which one of these do I start with? Thanks.
dist is for the generated code, so you should do your modifications in src
+1 for this issue, emails shouldn't open new tab. @dannyharding10 did you managed to make a PR for this?
@cooervo I never really got deep into it, go ahead and work on it if you want!