@plone/volto 17.6.1 → 17.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/addon-registry.js +34 -1
- package/package.json +1 -1
- package/packages/volto-slate/news/5347.bugfix +1 -0
- package/packages/volto-slate/news/5517.feature +1 -0
- package/packages/volto-slate/package.json +1 -1
- package/packages/volto-slate/src/blocks/Text/DefaultTextBlockEditor.jsx +4 -0
- package/packages/volto-slate/src/editor/extensions/insertData.js +3 -1
- package/packages/volto-slate/src/editor/extensions/normalizeExternalData.js +1 -1
- package/packages/volto-slate/src/utils/blocks.js +6 -2
- package/src/components/manage/Add/Add.jsx +6 -0
- package/src/components/manage/BlockChooser/BlockChooser.jsx +3 -1
- package/src/components/manage/BlockChooser/BlockChooserButton.jsx +5 -0
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +4 -0
- package/src/components/manage/Blocks/Block/DefaultEdit.jsx +3 -1
- package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +10 -2
- package/src/components/manage/Blocks/Block/Settings.jsx +10 -1
- package/src/components/manage/Blocks/Block/StyleWrapper.jsx +7 -1
- package/src/components/manage/Blocks/Container/Data.jsx +4 -1
- package/src/components/manage/Blocks/Grid/View.jsx +2 -1
- package/src/components/manage/Blocks/HeroImageLeft/Data.jsx +3 -1
- package/src/components/manage/Blocks/Image/ImageSidebar.jsx +4 -1
- package/src/components/manage/Blocks/Image/View.jsx +2 -1
- package/src/components/manage/Blocks/Listing/ListingData.jsx +4 -1
- package/src/components/manage/Blocks/Listing/View.jsx +2 -1
- package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
- package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +4 -0
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +46 -4
- package/src/components/manage/Blocks/Teaser/Data.jsx +4 -1
- package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +2 -2
- package/src/components/manage/Blocks/ToC/Edit.jsx +2 -0
- package/src/components/manage/Blocks/Video/Body.jsx +52 -22
- package/src/components/manage/Blocks/Video/Body.test.jsx +167 -0
- package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +2 -2
- package/src/components/manage/Edit/Edit.jsx +1 -0
- package/src/components/manage/Form/Form.jsx +14 -3
- package/src/components/manage/Sidebar/SidebarPopup.jsx +1 -1
- package/src/components/manage/Widgets/RecurrenceWidget/EndField.jsx +7 -1
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +79 -31
- package/src/components/theme/Image/Image.jsx +4 -2
- package/src/components/theme/Image/Image.test.jsx +32 -0
- package/src/components/theme/Login/Login.jsx +12 -2
- package/src/components/theme/Navigation/Navigation.jsx +34 -32
- package/src/components/theme/PreviewImage/PreviewImage.jsx +7 -2
- package/src/components/theme/Sitemap/Sitemap.jsx +4 -4
- package/src/components/theme/Sitemap/Sitemap.test.jsx +52 -0
- package/src/components/theme/Unauthorized/Unauthorized.jsx +12 -11
- package/src/helpers/Blocks/Blocks.js +67 -3
- package/src/helpers/Blocks/Blocks.test.js +57 -0
- package/src/helpers/Extensions/withBlockSchemaEnhancer.js +20 -9
- package/src/helpers/Url/Url.js +5 -4
- package/src/helpers/Url/Url.test.js +52 -0
- package/src/helpers/index.js +1 -0
- package/types/components/manage/Blocks/Image/View.d.ts +2 -1
- package/types/components/manage/Blocks/Video/Body.d.ts +5 -0
- package/types/components/manage/Blocks/Video/Body.test.d.ts +1 -0
- package/types/helpers/Blocks/Blocks.d.ts +3 -1
- package/types/helpers/Extensions/withBlockSchemaEnhancer.d.ts +3 -1
- package/apps/plone/node_modules/.bin/acorn +0 -17
- package/apps/plone/node_modules/.bin/addon +0 -17
- package/apps/plone/node_modules/.bin/autoprefixer +0 -17
- package/apps/plone/node_modules/.bin/browserslist +0 -17
- package/apps/plone/node_modules/.bin/build-storybook +0 -17
- package/apps/plone/node_modules/.bin/changelogupdater +0 -17
- package/apps/plone/node_modules/.bin/eslint +0 -17
- package/apps/plone/node_modules/.bin/eslint-config-prettier +0 -17
- package/apps/plone/node_modules/.bin/i18n +0 -17
- package/apps/plone/node_modules/.bin/jest +0 -17
- package/apps/plone/node_modules/.bin/lessc +0 -17
- package/apps/plone/node_modules/.bin/missdev +0 -17
- package/apps/plone/node_modules/.bin/prettier +0 -17
- package/apps/plone/node_modules/.bin/razzle +0 -17
- package/apps/plone/node_modules/.bin/server-test +0 -17
- package/apps/plone/node_modules/.bin/start-server-and-test +0 -17
- package/apps/plone/node_modules/.bin/start-storybook +0 -17
- package/apps/plone/node_modules/.bin/start-test +0 -17
- package/apps/plone/node_modules/.bin/storybook-server +0 -17
- package/apps/plone/node_modules/.bin/stylelint +0 -17
- package/apps/plone/node_modules/.bin/tlds +0 -17
- package/apps/plone/node_modules/.bin/ts-jest +0 -17
- package/apps/plone/node_modules/.bin/tsc +0 -17
- package/apps/plone/node_modules/.bin/tsserver +0 -17
- package/apps/plone/node_modules/.bin/uuid +0 -17
- package/apps/plone/node_modules/.bin/webpack +0 -17
- package/apps/plone/node_modules/.bin/webpack-dev-server +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/acorn +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/addon +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/browserslist +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/changelogupdater +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/eslint +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/eslint-config-prettier +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/i18n +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/prettier +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/release-it +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/stylelint +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/tsc +0 -17
- package/apps/plone/src/addons/volto-volto-project/node_modules/.bin/tsserver +0 -17
- package/packages/volto-slate/build/messages/src/blocks/Table/TableBlockEdit.json +0 -90
- package/packages/volto-slate/build/messages/src/blocks/Text/DefaultTextBlockEditor.json +0 -6
- package/packages/volto-slate/build/messages/src/blocks/Text/DetachedTextBlockEditor.json +0 -6
- package/packages/volto-slate/build/messages/src/blocks/Text/SlashMenu.json +0 -6
- package/packages/volto-slate/build/messages/src/editor/plugins/AdvancedLink/index.json +0 -10
- package/packages/volto-slate/build/messages/src/editor/plugins/Link/index.json +0 -10
- package/packages/volto-slate/build/messages/src/editor/plugins/Table/index.json +0 -30
- package/packages/volto-slate/build/messages/src/elementEditor/messages.json +0 -10
- package/packages/volto-slate/build/messages/src/widgets/HtmlSlateWidget.json +0 -6
- package/packages/volto-slate/build/messages/src/widgets/RichTextWidgetView.json +0 -6
|
@@ -48,40 +48,42 @@ const Navigation = (props) => {
|
|
|
48
48
|
}
|
|
49
49
|
setisMobileMenuOpen(false);
|
|
50
50
|
};
|
|
51
|
-
|
|
52
51
|
return (
|
|
53
52
|
<nav className="navigation" id="navigation" aria-label="Site">
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
'
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<span className="hamburger-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
53
|
+
{items?.length ? (
|
|
54
|
+
<div className="hamburger-wrapper mobile tablet only">
|
|
55
|
+
<button
|
|
56
|
+
className={cx('hamburger hamburger--spin', {
|
|
57
|
+
'is-active': isMobileMenuOpen,
|
|
58
|
+
})}
|
|
59
|
+
aria-label={
|
|
60
|
+
isMobileMenuOpen
|
|
61
|
+
? intl.formatMessage(messages.closeMobileMenu, {
|
|
62
|
+
type: type,
|
|
63
|
+
})
|
|
64
|
+
: intl.formatMessage(messages.openMobileMenu, {
|
|
65
|
+
type: type,
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
title={
|
|
69
|
+
isMobileMenuOpen
|
|
70
|
+
? intl.formatMessage(messages.closeMobileMenu, {
|
|
71
|
+
type: type,
|
|
72
|
+
})
|
|
73
|
+
: intl.formatMessage(messages.openMobileMenu, {
|
|
74
|
+
type: type,
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
type="button"
|
|
78
|
+
onClick={toggleMobileMenu}
|
|
79
|
+
>
|
|
80
|
+
<span className="hamburger-box">
|
|
81
|
+
<span className="hamburger-inner" />
|
|
82
|
+
</span>
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
) : null}
|
|
86
|
+
|
|
85
87
|
<Menu
|
|
86
88
|
stackable
|
|
87
89
|
pointing
|
|
@@ -11,12 +11,17 @@ function PreviewImage({ item, alt, image_field, showDefault = true, ...rest }) {
|
|
|
11
11
|
const Image = config.getComponent({ name: 'Image' }).component;
|
|
12
12
|
|
|
13
13
|
const image = (
|
|
14
|
-
<Image
|
|
14
|
+
<Image
|
|
15
|
+
item={item}
|
|
16
|
+
image_field={image_field || item.image_field}
|
|
17
|
+
alt={alt}
|
|
18
|
+
{...rest}
|
|
19
|
+
/>
|
|
15
20
|
);
|
|
16
21
|
|
|
17
22
|
if (!image && !showDefault) return null;
|
|
18
23
|
|
|
19
|
-
if (
|
|
24
|
+
if (image_field || item?.image_field) {
|
|
20
25
|
return image;
|
|
21
26
|
} else {
|
|
22
27
|
return (
|
|
@@ -33,16 +33,16 @@ export function getSitemapPath(pathname = '', lang) {
|
|
|
33
33
|
function Sitemap(props) {
|
|
34
34
|
const {
|
|
35
35
|
location: { pathname },
|
|
36
|
-
|
|
36
|
+
lang,
|
|
37
37
|
getNavigation,
|
|
38
38
|
} = props;
|
|
39
39
|
|
|
40
40
|
useEffect(() => {
|
|
41
41
|
const { settings } = config;
|
|
42
|
-
const
|
|
43
|
-
const path = getSitemapPath(pathname,
|
|
42
|
+
const language = settings.isMultilingual ? `${toBackendLang(lang)}` : null;
|
|
43
|
+
const path = getSitemapPath(pathname, language);
|
|
44
44
|
getNavigation(path, 4);
|
|
45
|
-
}, [pathname,
|
|
45
|
+
}, [pathname, lang, getNavigation]);
|
|
46
46
|
|
|
47
47
|
const renderItems = (items) => {
|
|
48
48
|
return (
|
|
@@ -3,6 +3,7 @@ import renderer from 'react-test-renderer';
|
|
|
3
3
|
import configureStore from 'redux-mock-store';
|
|
4
4
|
import { Provider } from 'react-intl-redux';
|
|
5
5
|
import { MemoryRouter } from 'react-router-dom';
|
|
6
|
+
import config from '@plone/volto/registry';
|
|
6
7
|
|
|
7
8
|
import { __test__ as Sitemap, getSitemapPath } from './Sitemap';
|
|
8
9
|
|
|
@@ -55,6 +56,57 @@ describe('Sitemap', () => {
|
|
|
55
56
|
});
|
|
56
57
|
});
|
|
57
58
|
|
|
59
|
+
describe('Sitemap in a multilingual site', () => {
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
config.settings.isMultilingual = true;
|
|
62
|
+
config.settings.supportedLanguages = ['en', 'es'];
|
|
63
|
+
});
|
|
64
|
+
it('renders a sitemap component', () => {
|
|
65
|
+
const store = mockStore({
|
|
66
|
+
navigation: {
|
|
67
|
+
url: 'http://localhost:8080/Plone/en/@navigation',
|
|
68
|
+
items: [
|
|
69
|
+
{
|
|
70
|
+
url: 'http://localhost:8080/Plone/en/page-1',
|
|
71
|
+
description: '',
|
|
72
|
+
items: [
|
|
73
|
+
{
|
|
74
|
+
url: 'http://localhost:8080/Plone/en/page-1/page-1-2',
|
|
75
|
+
description: '',
|
|
76
|
+
title: 'Page 1-2',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
url: 'http://localhost:8080/Plone/en/page-1/page-1-3',
|
|
80
|
+
description: '',
|
|
81
|
+
title: 'Page 1-3',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
title: 'Page 1-3',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
url: 'http://localhost:8080/Plone/en/page-2',
|
|
88
|
+
description: '',
|
|
89
|
+
title: 'Page 2',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
intl: {
|
|
94
|
+
locale: 'en',
|
|
95
|
+
messages: {},
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
const component = renderer.create(
|
|
99
|
+
<Provider store={store}>
|
|
100
|
+
<MemoryRouter>
|
|
101
|
+
<Sitemap location={{ pathname: '/en/' }} />
|
|
102
|
+
</MemoryRouter>
|
|
103
|
+
</Provider>,
|
|
104
|
+
);
|
|
105
|
+
const json = component.toJSON();
|
|
106
|
+
expect(json).toMatchSnapshot();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
58
110
|
describe('getSitemapPath', () => {
|
|
59
111
|
it('accepts empty path', () => {
|
|
60
112
|
expect(getSitemapPath('', null)).toBe('');
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module components/theme/Unauthorized/Unauthorized
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
1
|
import { FormattedMessage } from 'react-intl';
|
|
7
2
|
import { Link } from 'react-router-dom';
|
|
8
3
|
import { Container } from 'semantic-ui-react';
|
|
@@ -11,11 +6,6 @@ import { useLocation } from 'react-router-dom';
|
|
|
11
6
|
import { withServerErrorCode } from '@plone/volto/helpers/Utils/Utils';
|
|
12
7
|
import { getBaseUrl } from '@plone/volto/helpers';
|
|
13
8
|
|
|
14
|
-
/**
|
|
15
|
-
* unauthorized function.
|
|
16
|
-
* @function Unauthorized
|
|
17
|
-
* @returns {string} Markup of the unauthorized page.
|
|
18
|
-
*/
|
|
19
9
|
const Unauthorized = () => {
|
|
20
10
|
const error_message = useSelector((state) => state.apierror?.message);
|
|
21
11
|
let location = useLocation();
|
|
@@ -32,7 +22,18 @@ const Unauthorized = () => {
|
|
|
32
22
|
defaultMessage="You are trying to access a protected resource, please {login} first."
|
|
33
23
|
values={{
|
|
34
24
|
login: (
|
|
35
|
-
<Link
|
|
25
|
+
<Link
|
|
26
|
+
to={{
|
|
27
|
+
pathname: `${getBaseUrl(location.pathname)}/login`,
|
|
28
|
+
state: {
|
|
29
|
+
// This is needed to cover the use case of being logged in in
|
|
30
|
+
// another backend (eg. in development), having a token for
|
|
31
|
+
// localhost and try to use it, the login route has to know that
|
|
32
|
+
// it's the same as it comes from a logout
|
|
33
|
+
isLogout: true,
|
|
34
|
+
},
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
36
37
|
<FormattedMessage id="log in" defaultMessage="log in" />
|
|
37
38
|
</Link>
|
|
38
39
|
),
|
|
@@ -517,7 +517,10 @@ export function applySchemaDefaults({ data = {}, schema, intl }) {
|
|
|
517
517
|
* @param {Object} params An object with data, intl and anything else
|
|
518
518
|
* @return {Object} Derived data, with the defaults extracted from the schema
|
|
519
519
|
*/
|
|
520
|
-
export function applyBlockDefaults(
|
|
520
|
+
export function applyBlockDefaults(
|
|
521
|
+
{ data, intl, navRoot, contentType, ...rest },
|
|
522
|
+
blocksConfig,
|
|
523
|
+
) {
|
|
521
524
|
// We pay attention to not break on a missing (invalid) block.
|
|
522
525
|
const block_type = data?.['@type'];
|
|
523
526
|
const { blockSchema } =
|
|
@@ -528,7 +531,13 @@ export function applyBlockDefaults({ data, intl, ...rest }, blocksConfig) {
|
|
|
528
531
|
typeof blockSchema === 'function'
|
|
529
532
|
? blockSchema({ data, intl, ...rest })
|
|
530
533
|
: blockSchema;
|
|
531
|
-
schema = applySchemaEnhancer({
|
|
534
|
+
schema = applySchemaEnhancer({
|
|
535
|
+
schema,
|
|
536
|
+
formData: data,
|
|
537
|
+
intl,
|
|
538
|
+
navRoot,
|
|
539
|
+
contentType,
|
|
540
|
+
});
|
|
532
541
|
|
|
533
542
|
return applySchemaDefaults({ data, schema, intl });
|
|
534
543
|
}
|
|
@@ -554,7 +563,7 @@ export const styleToClassName = (key, value, prefix = '') => {
|
|
|
554
563
|
};
|
|
555
564
|
|
|
556
565
|
export const buildStyleClassNamesFromData = (obj = {}, prefix = '') => {
|
|
557
|
-
//
|
|
566
|
+
// style wrapper object has the form:
|
|
558
567
|
// const styles = {
|
|
559
568
|
// color: 'red',
|
|
560
569
|
// backgroundColor: '#AABBCC',
|
|
@@ -562,6 +571,7 @@ export const buildStyleClassNamesFromData = (obj = {}, prefix = '') => {
|
|
|
562
571
|
// Returns: ['has--color--red', 'has--backgroundColor--AABBCC']
|
|
563
572
|
|
|
564
573
|
return Object.entries(obj)
|
|
574
|
+
.filter(([k, v]) => !k.startsWith('--'))
|
|
565
575
|
.reduce(
|
|
566
576
|
(acc, [k, v]) => [
|
|
567
577
|
...acc,
|
|
@@ -593,6 +603,60 @@ export const buildStyleClassNamesExtenders = ({
|
|
|
593
603
|
);
|
|
594
604
|
};
|
|
595
605
|
|
|
606
|
+
/**
|
|
607
|
+
* Converts a name+value style pair (ex: color/red) to a pair of [k, v],
|
|
608
|
+
* such as ["color", "red"] so it can be converted back to an object.
|
|
609
|
+
* For now, only covering the 'CSSProperty' use case.
|
|
610
|
+
*/
|
|
611
|
+
export const styleDataToStyleObject = (key, value, prefix = '') => {
|
|
612
|
+
if (prefix) {
|
|
613
|
+
return [`--${prefix}${key.replace('--', '')}`, value];
|
|
614
|
+
} else {
|
|
615
|
+
return [key, value];
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Generate styles object from data
|
|
621
|
+
*
|
|
622
|
+
* @function buildStyleObjectFromData
|
|
623
|
+
* @param {Object} obj A style wrapper object data
|
|
624
|
+
* @param {string} prefix The prefix (could be dragged from a recursive call, initially empty)
|
|
625
|
+
* @return {Object} The style object ready to be passed as prop
|
|
626
|
+
*/
|
|
627
|
+
export const buildStyleObjectFromData = (obj = {}, prefix = '') => {
|
|
628
|
+
// style wrapper object has the form:
|
|
629
|
+
// const styles = {
|
|
630
|
+
// color: 'red',
|
|
631
|
+
// '--background-color': '#AABBCC',
|
|
632
|
+
// }
|
|
633
|
+
// Returns: {'--background-color: '#AABBCC'}
|
|
634
|
+
|
|
635
|
+
return Object.fromEntries(
|
|
636
|
+
Object.entries(obj)
|
|
637
|
+
.filter(([k, v]) => k.startsWith('--') || isObject(v))
|
|
638
|
+
.reduce(
|
|
639
|
+
(acc, [k, v]) => [
|
|
640
|
+
...acc,
|
|
641
|
+
// Kept for easy debugging
|
|
642
|
+
// ...(() => {
|
|
643
|
+
// if (isObject(v)) {
|
|
644
|
+
// return Object.entries(
|
|
645
|
+
// buildStyleObjectFromData(v, `${prefix}${k}--`),
|
|
646
|
+
// );
|
|
647
|
+
// }
|
|
648
|
+
// return [styleDataToStyleObject(k, v, prefix)];
|
|
649
|
+
// })(),
|
|
650
|
+
...(isObject(v)
|
|
651
|
+
? Object.entries(buildStyleObjectFromData(v, `${prefix}${k}--`))
|
|
652
|
+
: [styleDataToStyleObject(k, v, prefix)]),
|
|
653
|
+
],
|
|
654
|
+
[],
|
|
655
|
+
)
|
|
656
|
+
.filter((v) => !!v),
|
|
657
|
+
);
|
|
658
|
+
};
|
|
659
|
+
|
|
596
660
|
/**
|
|
597
661
|
* Return previous/next blocks given the content object and the current block id
|
|
598
662
|
*
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
applySchemaDefaults,
|
|
19
19
|
buildStyleClassNamesFromData,
|
|
20
20
|
buildStyleClassNamesExtenders,
|
|
21
|
+
buildStyleObjectFromData,
|
|
21
22
|
getPreviousNextBlock,
|
|
22
23
|
blocksFormGenerator,
|
|
23
24
|
findBlocks,
|
|
@@ -1066,6 +1067,62 @@ describe('Blocks', () => {
|
|
|
1066
1067
|
};
|
|
1067
1068
|
expect(buildStyleClassNamesFromData(styles)).toEqual([]);
|
|
1068
1069
|
});
|
|
1070
|
+
|
|
1071
|
+
it('It does not output any className for style converter values', () => {
|
|
1072
|
+
const styles = {
|
|
1073
|
+
color: 'red',
|
|
1074
|
+
'--background-color': '#FFF',
|
|
1075
|
+
};
|
|
1076
|
+
expect(buildStyleClassNamesFromData(styles)).toEqual(['has--color--red']);
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
it.skip('It does not output any className for unknown converter values', () => {
|
|
1080
|
+
const styles = {
|
|
1081
|
+
color: 'red',
|
|
1082
|
+
'backgroundColor:style': '#FFF',
|
|
1083
|
+
};
|
|
1084
|
+
expect(buildStyleClassNamesFromData(styles)).toEqual(['has--color--red']);
|
|
1085
|
+
});
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
describe('buildStyleObjectFromData', () => {
|
|
1089
|
+
it('Understands style converter for style values, no styles found', () => {
|
|
1090
|
+
const styles = {
|
|
1091
|
+
color: 'red',
|
|
1092
|
+
backgroundColor: '#FFF',
|
|
1093
|
+
};
|
|
1094
|
+
expect(buildStyleObjectFromData(styles)).toEqual({});
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
it('Understands style converter for style values', () => {
|
|
1098
|
+
const styles = {
|
|
1099
|
+
color: 'red',
|
|
1100
|
+
'--background-color': '#FFF',
|
|
1101
|
+
};
|
|
1102
|
+
expect(buildStyleObjectFromData(styles)).toEqual({
|
|
1103
|
+
'--background-color': '#FFF',
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
it('Supports multiple nested levels', () => {
|
|
1108
|
+
const styles = {
|
|
1109
|
+
'--color': 'red',
|
|
1110
|
+
backgroundColor: '#AABBCC',
|
|
1111
|
+
nested: {
|
|
1112
|
+
l1: 'white',
|
|
1113
|
+
'--foo': 'white',
|
|
1114
|
+
level2: {
|
|
1115
|
+
'--foo': '#fff',
|
|
1116
|
+
bar: '#000',
|
|
1117
|
+
},
|
|
1118
|
+
},
|
|
1119
|
+
};
|
|
1120
|
+
expect(buildStyleObjectFromData(styles)).toEqual({
|
|
1121
|
+
'--color': 'red',
|
|
1122
|
+
'--nested--foo': 'white',
|
|
1123
|
+
'--nested--level2--foo': '#fff',
|
|
1124
|
+
});
|
|
1125
|
+
});
|
|
1069
1126
|
});
|
|
1070
1127
|
|
|
1071
1128
|
describe('getPreviousNextBlock', () => {
|
|
@@ -199,6 +199,8 @@ export const applySchemaEnhancer = ({
|
|
|
199
199
|
formData,
|
|
200
200
|
intl,
|
|
201
201
|
blocksConfig = config.blocks.blocksConfig,
|
|
202
|
+
navRoot,
|
|
203
|
+
contentType,
|
|
202
204
|
}) => {
|
|
203
205
|
let schema, schemaEnhancer;
|
|
204
206
|
|
|
@@ -215,6 +217,8 @@ export const applySchemaEnhancer = ({
|
|
|
215
217
|
schema: cloneDeepSchema(originalSchema),
|
|
216
218
|
formData,
|
|
217
219
|
intl,
|
|
220
|
+
navRoot,
|
|
221
|
+
contentType,
|
|
218
222
|
});
|
|
219
223
|
return schema || originalSchema;
|
|
220
224
|
}
|
|
@@ -230,12 +234,15 @@ export const applySchemaEnhancer = ({
|
|
|
230
234
|
schema: cloneDeepSchema(originalSchema),
|
|
231
235
|
formData,
|
|
232
236
|
intl,
|
|
237
|
+
navRoot,
|
|
238
|
+
contentType,
|
|
233
239
|
})
|
|
234
240
|
: cloneDeepSchema(originalSchema);
|
|
235
241
|
|
|
236
242
|
// Finalize the schema with a schemaEnhancer in the block config;
|
|
237
243
|
schemaEnhancer = blocksConfig?.[blockType]?.schemaEnhancer;
|
|
238
|
-
if (schemaEnhancer)
|
|
244
|
+
if (schemaEnhancer)
|
|
245
|
+
schema = schemaEnhancer({ schema, formData, intl, navRoot, contentType });
|
|
239
246
|
|
|
240
247
|
return schema || originalSchema;
|
|
241
248
|
};
|
|
@@ -248,7 +255,7 @@ export const applySchemaEnhancer = ({
|
|
|
248
255
|
* - adds the variation selection input (as a choice widget)
|
|
249
256
|
*/
|
|
250
257
|
export const withVariationSchemaEnhancer = (FormComponent) => (props) => {
|
|
251
|
-
const { formData, schema: originalSchema } = props;
|
|
258
|
+
const { formData, schema: originalSchema, navRoot, contentType } = props;
|
|
252
259
|
const intl = useIntl();
|
|
253
260
|
|
|
254
261
|
const blocksConfig = getBlocksConfig(props);
|
|
@@ -256,15 +263,10 @@ export const withVariationSchemaEnhancer = (FormComponent) => (props) => {
|
|
|
256
263
|
const blockType = formData['@type'];
|
|
257
264
|
const variations = blocksConfig[blockType]?.variations || [];
|
|
258
265
|
|
|
259
|
-
let schema =
|
|
260
|
-
schema: originalSchema,
|
|
261
|
-
formData,
|
|
262
|
-
intl,
|
|
263
|
-
blocksConfig,
|
|
264
|
-
});
|
|
266
|
+
let schema = cloneDeepSchema(originalSchema);
|
|
265
267
|
|
|
266
268
|
if (variations.length > 1) {
|
|
267
|
-
addExtensionFieldToSchema({
|
|
269
|
+
schema = addExtensionFieldToSchema({
|
|
268
270
|
schema,
|
|
269
271
|
name: 'variation',
|
|
270
272
|
items: variations,
|
|
@@ -274,6 +276,15 @@ export const withVariationSchemaEnhancer = (FormComponent) => (props) => {
|
|
|
274
276
|
});
|
|
275
277
|
}
|
|
276
278
|
|
|
279
|
+
schema = applySchemaEnhancer({
|
|
280
|
+
schema,
|
|
281
|
+
formData,
|
|
282
|
+
intl,
|
|
283
|
+
blocksConfig,
|
|
284
|
+
navRoot,
|
|
285
|
+
contentType,
|
|
286
|
+
});
|
|
287
|
+
|
|
277
288
|
return <FormComponent {...props} schema={schema} />;
|
|
278
289
|
};
|
|
279
290
|
|
package/src/helpers/Url/Url.js
CHANGED
|
@@ -366,19 +366,20 @@ export const URLUtils = {
|
|
|
366
366
|
* @returns {object} New object with the flattened scale URLs
|
|
367
367
|
*/
|
|
368
368
|
export function flattenScales(path, image) {
|
|
369
|
-
function removeObjectIdFromURL(
|
|
370
|
-
return scale.replace(`${
|
|
369
|
+
function removeObjectIdFromURL(basePath, scale) {
|
|
370
|
+
return scale.replace(`${basePath}/`, '');
|
|
371
371
|
}
|
|
372
372
|
if (!image) return;
|
|
373
373
|
|
|
374
|
+
const basePath = image.base_path || path;
|
|
374
375
|
const imageInfo = {
|
|
375
376
|
...image,
|
|
376
|
-
download: flattenToAppURL(removeObjectIdFromURL(
|
|
377
|
+
download: flattenToAppURL(removeObjectIdFromURL(basePath, image.download)),
|
|
377
378
|
};
|
|
378
379
|
|
|
379
380
|
Object.keys(imageInfo.scales).forEach((key) => {
|
|
380
381
|
imageInfo.scales[key].download = flattenToAppURL(
|
|
381
|
-
removeObjectIdFromURL(
|
|
382
|
+
removeObjectIdFromURL(basePath, image.scales[key].download),
|
|
382
383
|
);
|
|
383
384
|
});
|
|
384
385
|
|
|
@@ -351,6 +351,7 @@ describe('Url', () => {
|
|
|
351
351
|
);
|
|
352
352
|
});
|
|
353
353
|
});
|
|
354
|
+
|
|
354
355
|
describe('flattenScales', () => {
|
|
355
356
|
it('flattenScales image is not set', () => {
|
|
356
357
|
const id = '/halfdome2022-2.jpg';
|
|
@@ -405,6 +406,57 @@ describe('Url', () => {
|
|
|
405
406
|
width: 1182,
|
|
406
407
|
});
|
|
407
408
|
});
|
|
409
|
+
|
|
410
|
+
it('[preview_image_link] flattenScales test from the catalog', () => {
|
|
411
|
+
const id = '/halfdome2022-2.jpg';
|
|
412
|
+
const image = {
|
|
413
|
+
base_path: '/broccoli.jpg',
|
|
414
|
+
'content-type': 'image/jpeg',
|
|
415
|
+
download: '@@images/image-1182-cf763ae23c52340d8a17a7afdb26c8cb.jpeg',
|
|
416
|
+
filename: 'halfdome2022.jpg',
|
|
417
|
+
height: 665,
|
|
418
|
+
scales: {
|
|
419
|
+
great: {
|
|
420
|
+
download:
|
|
421
|
+
'@@images/image-1200-539ab119ebadc7d011798980a4a5e8d4.jpeg',
|
|
422
|
+
height: 665,
|
|
423
|
+
width: 1182,
|
|
424
|
+
},
|
|
425
|
+
huge: {
|
|
426
|
+
download:
|
|
427
|
+
'@@images/image-1600-188968febc677890c1b99d5339f9bef1.jpeg',
|
|
428
|
+
height: 665,
|
|
429
|
+
width: 1182,
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
size: 319364,
|
|
433
|
+
width: 1182,
|
|
434
|
+
};
|
|
435
|
+
expect(flattenScales(id, image)).toStrictEqual({
|
|
436
|
+
base_path: '/broccoli.jpg',
|
|
437
|
+
'content-type': 'image/jpeg',
|
|
438
|
+
download: '@@images/image-1182-cf763ae23c52340d8a17a7afdb26c8cb.jpeg',
|
|
439
|
+
filename: 'halfdome2022.jpg',
|
|
440
|
+
height: 665,
|
|
441
|
+
scales: {
|
|
442
|
+
great: {
|
|
443
|
+
download:
|
|
444
|
+
'@@images/image-1200-539ab119ebadc7d011798980a4a5e8d4.jpeg',
|
|
445
|
+
height: 665,
|
|
446
|
+
width: 1182,
|
|
447
|
+
},
|
|
448
|
+
huge: {
|
|
449
|
+
download:
|
|
450
|
+
'@@images/image-1600-188968febc677890c1b99d5339f9bef1.jpeg',
|
|
451
|
+
height: 665,
|
|
452
|
+
width: 1182,
|
|
453
|
+
},
|
|
454
|
+
},
|
|
455
|
+
size: 319364,
|
|
456
|
+
width: 1182,
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
|
|
408
460
|
it('flattenScales test from serialization', () => {
|
|
409
461
|
const id = 'http://localhost:3000/halfdome2022-2.jpg';
|
|
410
462
|
const image = {
|
package/src/helpers/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export function View({ className, data, detached, properties }: {
|
|
1
|
+
export function View({ className, data, detached, properties, style }: {
|
|
2
2
|
className: any;
|
|
3
3
|
data: any;
|
|
4
4
|
detached: any;
|
|
5
5
|
properties: any;
|
|
6
|
+
style: any;
|
|
6
7
|
}): JSX.Element;
|
|
7
8
|
export namespace View {
|
|
8
9
|
namespace propTypes {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -133,7 +133,7 @@ export function applySchemaDefaults({ data, schema, intl }: {
|
|
|
133
133
|
* @param {Object} params An object with data, intl and anything else
|
|
134
134
|
* @return {Object} Derived data, with the defaults extracted from the schema
|
|
135
135
|
*/
|
|
136
|
-
export function applyBlockDefaults({ data, intl, ...rest }: any, blocksConfig: any): any;
|
|
136
|
+
export function applyBlockDefaults({ data, intl, navRoot, contentType, ...rest }: any, blocksConfig: any): any;
|
|
137
137
|
/**
|
|
138
138
|
* Given a `block` object and a list of block types, return a list of block ids matching the types
|
|
139
139
|
*
|
|
@@ -146,4 +146,6 @@ export function getBlocks(properties: any): any[];
|
|
|
146
146
|
export function styleToClassName(key: any, value: any, prefix?: string): any;
|
|
147
147
|
export function buildStyleClassNamesFromData(obj?: {}, prefix?: string): any;
|
|
148
148
|
export function buildStyleClassNamesExtenders({ block, content, data, classNames, }: any): any[];
|
|
149
|
+
export function styleDataToStyleObject(key: any, value: any, prefix?: string): any[];
|
|
150
|
+
export function buildStyleObjectFromData(obj?: any, prefix?: string): any;
|
|
149
151
|
export function getPreviousNextBlock({ content, block }: any): any[];
|
|
@@ -21,11 +21,13 @@ export function addExtensionFieldToSchema({ schema, name, items, intl, title, de
|
|
|
21
21
|
export function withBlockSchemaEnhancer(FormComponent: any, extensionName?: string, insertFieldToOrder?: typeof _addField): ({ ...props }: {
|
|
22
22
|
[x: string]: any;
|
|
23
23
|
}) => JSX.Element;
|
|
24
|
-
export function applySchemaEnhancer({ schema: originalSchema, formData, intl, blocksConfig, }: {
|
|
24
|
+
export function applySchemaEnhancer({ schema: originalSchema, formData, intl, blocksConfig, navRoot, contentType, }: {
|
|
25
25
|
schema: any;
|
|
26
26
|
formData: any;
|
|
27
27
|
intl: any;
|
|
28
28
|
blocksConfig?: any;
|
|
29
|
+
navRoot: any;
|
|
30
|
+
contentType: any;
|
|
29
31
|
}): any;
|
|
30
32
|
export function withVariationSchemaEnhancer(FormComponent: any): (props: any) => JSX.Element;
|
|
31
33
|
export namespace EMPTY_STYLES_SCHEMA {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
-
esac
|
|
7
|
-
|
|
8
|
-
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/acorn@8.11.2/node_modules/acorn/bin/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/acorn@8.11.2/node_modules/acorn/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/acorn@8.11.2/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/node_modules"
|
|
10
|
-
else
|
|
11
|
-
export NODE_PATH="/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/acorn@8.11.2/node_modules/acorn/bin/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/acorn@8.11.2/node_modules/acorn/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/acorn@8.11.2/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
-
fi
|
|
13
|
-
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../../../../node_modules/.pnpm/acorn@8.11.2/node_modules/acorn/bin/acorn" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../../../../node_modules/.pnpm/acorn@8.11.2/node_modules/acorn/bin/acorn" "$@"
|
|
17
|
-
fi
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
-
esac
|
|
7
|
-
|
|
8
|
-
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/Users/sneridagh/Development/plone/volto/packages/scripts/addon/node_modules:/Users/sneridagh/Development/plone/volto/packages/scripts/node_modules:/Users/sneridagh/Development/plone/volto/packages/node_modules:/Users/sneridagh/Development/plone/volto/node_modules:/Users/sneridagh/Development/plone/node_modules:/Users/sneridagh/Development/node_modules:/Users/sneridagh/node_modules:/Users/node_modules:/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/node_modules"
|
|
10
|
-
else
|
|
11
|
-
export NODE_PATH="/Users/sneridagh/Development/plone/volto/packages/scripts/addon/node_modules:/Users/sneridagh/Development/plone/volto/packages/scripts/node_modules:/Users/sneridagh/Development/plone/volto/packages/node_modules:/Users/sneridagh/Development/plone/volto/node_modules:/Users/sneridagh/Development/plone/node_modules:/Users/sneridagh/Development/node_modules:/Users/sneridagh/node_modules:/Users/node_modules:/node_modules:/Users/sneridagh/Development/plone/volto/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
-
fi
|
|
13
|
-
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../@plone/scripts/addon/index.js" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../@plone/scripts/addon/index.js" "$@"
|
|
17
|
-
fi
|