Skip to content

Commit

Permalink
Add open external link in a new tab config option. (#4379)
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema authored Feb 8, 2023
1 parent cac1451 commit 2dc7836
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/4379.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add open external link in a new tab config option. @robgietema
7 changes: 6 additions & 1 deletion packages/volto-slate/src/editor/plugins/Link/render.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import React from 'react';
import { UniversalLink } from '@plone/volto/components';
import config from '@plone/volto/registry';
import { isInternalURL } from '@plone/volto/helpers';

const ViewLink = ({ url, target, download, children }) => {
const { openExternalLinkInNewTab } = config.settings;
return (
<UniversalLink
href={url}
openLinkInNewTab={target === '_blank'}
openLinkInNewTab={
(openExternalLinkInNewTab && !isInternalURL(url)) || target === '_blank'
}
download={download}
>
{children}
Expand Down
1 change: 1 addition & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ let config = {
downloadableObjects: ['File'], //list of content-types for which the direct download of the file will be carried out if the user is not authenticated
viewableInBrowserObjects: [], //ex: ['File']. List of content-types for which the file will be displayed in browser if the user is not authenticated
listingPreviewImageField: 'image', // deprecated from Volto 14 onwards
openExternalLinkInNewTab: false,
notSupportedBrowsers: ['ie'],
defaultPageSize: 25,
isMultilingual: false,
Expand Down

0 comments on commit 2dc7836

Please sign in to comment.