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 in new tab setting not preserved #330

Closed
palomamtnez opened this issue Dec 8, 2024 · 1 comment
Closed

Open in new tab setting not preserved #330

palomamtnez opened this issue Dec 8, 2024 · 1 comment
Labels

Comments

@palomamtnez
Copy link

Description

I’ve updated my plugin configuration to enable links to open in new tabs by adding the following setting:

  alignment: {
    options: ['left', 'right', 'center', 'justify'],
  },
  code: {
    indentSequence: '  ',
  },
  link: {
    decorators: {
      openInNewTab: {
        mode: 'manual',
        label: 'Open in new tab?',
        attributes: {
          target: '_blank',
          rel: 'noopener noreferrer',
        },
      },
    },
  },
};

The "Open in new tab" toggle is now displayed as expected. However, when I enable the toggle and save the link, the setting is not preserved. Upon inspecting the saved link, the "Open in new tab" toggle is visible but remains turned off, as if the change wasn’t saved.

Could someone help me troubleshoot this issue?

Additional info

  • Craft version: 5.4.3
  • PHP version: 8.3.13
  • Database driver & version: MySQL 8.0.35
  • Plugins & versions:
    "craftcms/ckeditor": "4.2.0",
    "craftcms/cms": "5.4.3",
    "craftpulse/craft-colour-swatches": "5.0.2",
    "nystudio107/craft-seomatic": "5.1.3",
    "spicyweb/craft-embedded-assets": "5.1.2",
    "spicyweb/craft-neo": "5.2.5",
    "verbb/hyper": "2.0.5",
    "verbb/navigation": "3.0.4",
    "vlucas/phpdotenv": "^5.4.0"
@palomamtnez palomamtnez added the bug label Dec 8, 2024
@i-just
Copy link
Contributor

i-just commented Dec 10, 2024

Hi, thanks for getting in touch! It sounds like your HTML Purifier config needs some adjusting. Check which config file is used by the CKEditor field you're seeing this behaviour in (Settings > Fields > your field > Advanced).

To allow target="_blank", you need:

"Attr.AllowedFrameTargets": [
    "_blank"
],

To allow the rel attribute with the values you specified in your CKEditor Config, you need:

"Attr.AllowedRel": [
    "noopener",
    "noreferrer"
],

I hope this helps!

I'll close this now, but feel free to reply if you run into any further issues.

@i-just i-just closed this as completed Dec 10, 2024
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