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

CKEditor diverting the Link Open in a new tab, all the links back to toggle 'off #280

Closed
pbmills opened this issue Aug 11, 2024 · 1 comment
Labels

Comments

@pbmills
Copy link

pbmills commented Aug 11, 2024

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

  1. Clicking the Link and turning the toggle ON.
  2. Saving the Entry.

Screenshot 2024-08-12 at 8 50 53 AM

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]
@pbmills pbmills added the bug label Aug 11, 2024
@pbmills pbmills changed the title CKEditor remove the Link Open in a new tab, it's diverting all the links back to toggle 'off CKEditor diverting the Link Open in a new tab, all the links back to toggle 'off Aug 11, 2024
@jeroenlammerts
Copy link

jeroenlammerts commented Aug 12, 2024

I ran into the same issue, this is more a ckeditor bug for a long time ckeditor/ckeditor5#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. #263

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

2 participants