verbb / vizy

A flexible visual editor for Craft CMS
Other
43 stars 8 forks source link

Can't remove rel="noopener noreferrer nofollow" from inline links #159

Closed svale closed 2 years ago

svale commented 2 years ago

Hi!

We are seeing an issue where inline links in the Vizy text editor are stuck with a rel="noopener noreferrer nofollow" attribute. This is reasonable (though perhaps preferable with just noopener noreferrer) for links opening in new windows. However it is unfortunate for other (and especially internal) links.

Internal links could be an entry or plain link format, but either way they should not have the rel-attribute if not target is not _blank. They also seem to get stuck with an empty target-attribute.

image

Steps to reproduce

  1. Add an inline link in Vizy text editor
  2. Check html source

Additional info

Additional context Perhaps the issue could be resolved by more actively unsetting the attribute in https://github.com/verbb/vizy/blob/58a30d991a8fde69682382e36ecd958febe15262/src/marks/Link.php#L22 E.g:

       if (isset($this->attrs['target']) && $this->attrs['target'] === '_blank') {
            $this->attrs['rel'] = 'noopener noreferrer nofollow';
        } else {
          unset($this->attrs['rel'])
        }

Thank you for providing fantastic plugins!

engram-design commented 2 years ago

Not quite sure why I added nofollow. But yes, it should only be applying this for links that have a new window option set. Looks like this is a Tiptap inherited thing. But also, to be fair this is only in the editor, not when we output the content of the field via Twig.

Fixed for the next release. To get the fix early, change your verbb/vizy requirement in composer.json to:

"require": {
  "verbb/vizy": "dev-craft-3 as 1.0.15",
  "...": "..."
}

Then run composer update.

engram-design commented 2 years ago

Fixed in 1.0.16