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

Getting target="_blank" to work for links #14

Closed
TheBigK opened this issue May 8, 2018 · 3 comments
Closed

Getting target="_blank" to work for links #14

TheBigK opened this issue May 8, 2018 · 3 comments
Labels

Comments

@TheBigK
Copy link

TheBigK commented May 8, 2018

Steve,

I'm trying hard to get target="_blank" working in my links. I've tried -

'Attr.AllowedFrameTargets' => ['_blank'], and
'HTML.Allowed' => 'a[href|target|rel]',

but it still throws message that "Attribute 'target' in element 'a' not supported (for information on implementing this, see the support forums) ",

Would really appreciate if you could suggest a way to make this work. I've spent at least 4 hours on this, but without success.

@stevebauman
Copy link
Owner

stevebauman commented Jul 19, 2018

Hi @TheBigK,

You'll need to add that attribute to your purifier definition as shown in the example in the readme for compatibility with the trix editor:

https://github.com/stevebauman/purify#custom-configuration-rules

protected function setupDefinitions(HTMLPurifier_HTMLDefinition $def)
{
    $def->addAttribute('a', 'target', 'Text');
}

@peterarends
Copy link

I couldn't get @stevebauman's solution to work, but I stumbled on this config option:
'HTML.TargetBlank' => true which works perfectly for my case. Hope it helps someone.

@decadence
Copy link

@peterarends thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants