CKEditor diverting the Link Open in a new tab, all the links back to toggle 'off
Description
I'm sliding the toggle to 'on', hitting the tick and it looks like job done, but when I save, it's diverting all the links back to toggle 'off' and links aren't opening in a new tab.
Steps to reproduce
- Clicking the Link and turning the toggle ON.
- Saving the Entry.
CKEditor -> Javascript [Config options].
return {
link: {
decorators: {
openInNewTab: {
mode: 'manual',
label: 'Open in a new tab',
attributes: {
target: '_blank',
rel: 'noopener noreferrer'
}
}
}
}
}
Additional info
- Craft version: 5.2.10
- PHP version: 8.2
- Plugins & versions: CKEditor [4.1.0]
I ran into the same issue, this is more a ckeditor bug for a long time https://github.com/ckeditor/ckeditor5/issues/12394
Our workaround is to remove the rel in the config.
options:
link:
decorators:
openInNewTab:
attributes:
target: _blank
label: 'Open in a new tab'
mode: manual
By default the htmlpurifier adds the rel noopener, noreferrer on save with the settings HTML.TargetNoopener and HTML.TargetNoreferrer which are default true, you can add these settings also to be sure. I added the following to my config/htmlpurifier/Default.json
{
"Attr.AllowedRel": [
"noopener",
"noreferrer"
],
}
http://htmlpurifier.org/live/configdoc/plain.html
Also you don't see the rel when using the source button in the ckeditor, but if you view the text on your site it is actually added. https://github.com/craftcms/ckeditor/issues/263