diff --git a/blocks/rich-text/format-toolbar/index.js b/blocks/rich-text/format-toolbar/index.js index d3e97f8b2e55c..7b02b89141dc8 100644 --- a/blocks/rich-text/format-toolbar/index.js +++ b/blocks/rich-text/format-toolbar/index.js @@ -112,7 +112,11 @@ class FormatToolbar extends Component { setLinkTarget( opensInNewWindow ) { this.setState( { opensInNewWindow } ); if ( this.props.formats.link ) { - this.props.onChange( { link: { value: this.props.formats.link.value, target: opensInNewWindow ? '_blank' : '' } } ); + this.props.onChange( { link: { + value: this.props.formats.link.value, + target: opensInNewWindow ? '_blank' : null, + rel: opensInNewWindow ? 'noreferrer noopener' : null, + } } ); } } @@ -133,7 +137,11 @@ class FormatToolbar extends Component { submitLink( event ) { event.preventDefault(); this.setState( { isEditingLink: false, isAddingLink: false, newLinkValue: '' } ); - this.props.onChange( { link: { value: this.state.newLinkValue, target: this.state.opensInNewWindow ? '_blank' : '' } } ); + this.props.onChange( { link: { + value: this.state.newLinkValue, + target: this.state.opensInNewWindow ? '_blank' : null, + rel: this.state.opensInNewWindow ? 'noreferrer noopener' : null, + } } ); if ( this.state.isAddingLink ) { this.props.speak( __( 'Link added.' ), 'assertive' ); } diff --git a/blocks/rich-text/index.js b/blocks/rich-text/index.js index 9d23fce87f5f3..2164265d46fc1 100644 --- a/blocks/rich-text/index.js +++ b/blocks/rich-text/index.js @@ -744,7 +744,8 @@ export class RichText extends Component { if ( ! anchor ) { this.removeFormat( 'link' ); } - this.applyFormat( 'link', { href: formatValue.value, target: formatValue.target }, anchor ); + const { value: href, ...params } = formatValue; + this.applyFormat( 'link', { href, ...params }, anchor ); } else { this.editor.execCommand( 'Unlink' ); }