Autolinker.js icon indicating copy to clipboard operation
Autolinker.js copied to clipboard

More customizable newWindow option

Open danny-does-stuff opened this issue 8 years ago • 10 comments
trafficstars

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.

danny-does-stuff avatar Mar 01 '17 19:03 danny-does-stuff

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?

gregjacobs avatar Mar 14 '17 01:03 gregjacobs

Btw, would you have any time to take a stab at it and create a pull request?

gregjacobs avatar Mar 14 '17 01:03 gregjacobs

Yes, will look at that when I have some time!

olafleur avatar Mar 14 '17 11:03 olafleur

@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!

gregjacobs avatar Mar 14 '17 14:03 gregjacobs

Ha! Ha! Ok ! Then if you need help @dannyharding10 feel free to ask ! :)

olafleur avatar Mar 14 '17 16:03 olafleur

Yeah I'll take a look, thanks! I will start with the second option I suggested.

danny-does-stuff avatar Mar 14 '17 17:03 danny-does-stuff

@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.

danny-does-stuff avatar Mar 24 '17 02:03 danny-does-stuff

dist is for the generated code, so you should do your modifications in src

olafleur avatar Mar 24 '17 13:03 olafleur

+1 for this issue, emails shouldn't open new tab. @dannyharding10 did you managed to make a PR for this?

cooervo avatar Feb 10 '18 20:02 cooervo

@cooervo I never really got deep into it, go ahead and work on it if you want!

danny-does-stuff avatar Feb 11 '18 00:02 danny-does-stuff