Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions packages/volto-slate/src/editor/plugins/Link/render.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import React from 'react';
import { useSelector } from 'react-redux';
import cx from 'classnames';
import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
import config from '@plone/volto/registry';
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers/Url/Url';

const ViewLink = ({ url, target, download, children }) => {
const { openExternalLinkInNewTab } = config.settings;
const token = useSelector((state) => state.userSession?.token);
let href = url;

if (
!token &&
config.settings.viewableInBrowserObjects?.includes('File') &&
url.includes('/@@download/file')
) {
href = url.replace('/@@download/file', '/@@display-file/file');
}

return (
<UniversalLink
href={url}
href={href}
openLinkInNewTab={
(openExternalLinkInNewTab && !isInternalURL(url)) || target === '_blank'
(openExternalLinkInNewTab && !isInternalURL(href)) || target === '_blank'
}
download={download}
>
Expand All @@ -35,19 +47,19 @@ export const LinkElement = (props) => {
>
{Array.isArray(children)
? children.map((child, i) => {
if (child?.props?.decorations) {
const isSelection =
child.props.decorations.findIndex((deco) => deco.isSelection) >
-1;
if (isSelection)
return (
<span className="highlight-selection" key={`${i}-sel`}>
{child}
</span>
);
}
return child;
})
if (child?.props?.decorations) {
const isSelection =
child.props.decorations.findIndex((deco) => deco.isSelection) >
-1;
if (isSelection)
return (
<span className="highlight-selection" key={`${i}-sel`}>
{child}
</span>
);
}
return child;
})
: children}
</a>
);
Expand Down
11 changes: 7 additions & 4 deletions packages/volto/webpack-plugins/webpack-less-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ module.exports = (userOptions = {}) => ({
include: [
path.resolve('./theme'),
path.resolve('./src'),
/node_modules\/@plone\/volto\/theme/,
/packages\/volto\/theme/,
/plone\.volto\/theme/,
/node_modules\/semantic-ui-less/,
/node_modules[\\/]@plone[\\/]volto[\\/]theme/,
/packages[\\/]volto[\\/]theme/,
/plone\.volto[\\/]theme/,
/node_modules[\\/]semantic-ui-less/,
// This is a hack to make sure semantic-ui-less is included in the build
// even if it is a symlink (pnpm)
path.dirname(require.resolve('semantic-ui-less/package.json')),
...Object.values(registry.getResolveAliases()),
],
use: isServer
Expand Down