Skip to content
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

Open hyperlinks in separate tab? #94

Closed
alvaro1728 opened this issue Sep 9, 2020 · 2 comments
Closed

Open hyperlinks in separate tab? #94

alvaro1728 opened this issue Sep 9, 2020 · 2 comments

Comments

@alvaro1728
Copy link

Is there a way to add target="_blank" to hyperlinks?

Thanks,
Alvaro

@mohsen1
Copy link
Owner

mohsen1 commented Sep 9, 2020

No, but I will accept a PR that adds an optional method to the configuration for determining if a link should be opened in a new tab or not:

import JSONFormatter from 'json-formatter-js'

const myJSON = {external_link: 'http://example.com',  internal_link: 'https://my-domain.com' };

const formatter = new JSONFormatter(myJSON, 1, {
  getTargetForHyperlink(link: string) {
   const url = new URL(link);
   return url.hostname === 'my-domain.com' ? '_self' : '_blank';
  }
});

document.body.appendChild(formatter.render());

@mohsen1
Copy link
Owner

mohsen1 commented Apr 9, 2024

This can be addressed with #17 which is a TODO in this repo

@mohsen1 mohsen1 closed this as completed Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants