@plone/volto 17.0.0-alpha.20 → 17.0.0-alpha.21
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/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +19 -0
- package/cypress/support/commands.js +2 -1
- package/cypress/support/e2e.js +1 -2
- package/locales/ca/LC_MESSAGES/volto.po +10 -1
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +10 -1
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +10 -1
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +10 -1
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +10 -1
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +10 -1
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +10 -1
- package/locales/fr.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +11 -2
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +10 -1
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +10 -1
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +10 -1
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +10 -1
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +10 -1
- package/locales/ro.json +1 -1
- package/locales/volto.pot +10 -1
- package/locales/zh_CN/LC_MESSAGES/volto.po +10 -1
- package/locales/zh_CN.json +1 -1
- package/package.json +4 -4
- package/packages/volto-slate/package.json +1 -1
- package/src/components/index.js +1 -0
- package/src/components/manage/Blocks/Image/Edit.jsx +40 -5
- package/src/components/manage/Blocks/Image/Edit.test.jsx +2 -0
- package/src/components/manage/Blocks/Image/ImageSidebar.jsx +64 -15
- package/src/components/manage/Blocks/Image/View.jsx +25 -5
- package/src/components/manage/Blocks/Image/View.test.jsx +20 -0
- package/src/components/manage/Blocks/Image/schema.js +1 -9
- package/src/components/manage/Blocks/Image/utils.js +14 -0
- package/src/components/manage/Blocks/LeadImage/Edit.jsx +32 -10
- package/src/components/manage/Blocks/LeadImage/Edit.test.jsx +11 -1
- package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.jsx +28 -9
- package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.test.jsx +8 -2
- package/src/components/manage/Blocks/LeadImage/View.jsx +50 -38
- package/src/components/manage/Blocks/LeadImage/View.test.jsx +11 -1
- package/src/components/manage/Blocks/Listing/SummaryTemplate.jsx +1 -1
- package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +13 -23
- package/src/components/manage/Contents/Contents.jsx +8 -6
- package/src/components/manage/Sidebar/AlignBlock.jsx +1 -1
- package/src/components/theme/Image/Image.jsx +96 -0
- package/src/components/theme/Image/Image.test.jsx +125 -0
- package/src/components/theme/Logo/Logo.jsx +2 -0
- package/src/components/theme/PreviewImage/PreviewImage.jsx +25 -14
- package/src/components/theme/PreviewImage/PreviewImage.test.js +39 -16
- package/src/components/theme/View/AlbumView.jsx +11 -15
- package/src/components/theme/View/EventView.jsx +30 -23
- package/src/components/theme/View/ImageView.jsx +5 -2
- package/src/components/theme/View/ImageView.test.jsx +4 -0
- package/src/components/theme/View/ListingView.jsx +5 -3
- package/src/components/theme/View/NewsItemView.jsx +7 -13
- package/src/components/theme/View/SummaryView.jsx +4 -3
- package/src/config/Blocks.jsx +2 -0
- package/src/config/Components.jsx +2 -1
- package/src/helpers/Url/Url.js +22 -1
- package/src/helpers/Url/Url.test.js +41 -0
- package/test-setup-config.js +9 -1
- package/theme/themes/pastanaga/extras/blocks.less +2 -0
- package/theme/themes/pastanaga/extras/main.less +5 -0
- package/src/components/manage/Blocks/Teaser/utils.js +0 -44
- package/src/components/manage/Blocks/Teaser/utils.test.jsx +0 -229
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
isCmsUi,
|
|
11
11
|
isInternalURL,
|
|
12
12
|
isUrl,
|
|
13
|
+
getFieldURL,
|
|
13
14
|
normalizeUrl,
|
|
14
15
|
removeProtocol,
|
|
15
16
|
addAppURL,
|
|
@@ -260,6 +261,46 @@ describe('Url', () => {
|
|
|
260
261
|
expect(isUrl(href)).toBe(false);
|
|
261
262
|
});
|
|
262
263
|
});
|
|
264
|
+
describe('getFieldURL', () => {
|
|
265
|
+
it('returns app URL if the field is a string', () => {
|
|
266
|
+
const field = `${settings.apiPath}/foo/bar`;
|
|
267
|
+
expect(getFieldURL(field)).toBe('/foo/bar');
|
|
268
|
+
});
|
|
269
|
+
it('returns app URL if the field is an object with "@id"', () => {
|
|
270
|
+
const field = { '@id': '/foo/bar' };
|
|
271
|
+
expect(getFieldURL(field)).toBe('/foo/bar');
|
|
272
|
+
});
|
|
273
|
+
it('returns app URL if the field is an object with type URL', () => {
|
|
274
|
+
const field = { '@type': 'URL', value: '/foo/bar' };
|
|
275
|
+
expect(getFieldURL(field)).toBe('/foo/bar');
|
|
276
|
+
});
|
|
277
|
+
it('returns app URL if the field is an object with url or href properties', () => {
|
|
278
|
+
const fieldUrl = { url: '/foo/bar' };
|
|
279
|
+
const fieldHref = { href: '/foo/bar' };
|
|
280
|
+
expect(getFieldURL(fieldUrl)).toBe('/foo/bar');
|
|
281
|
+
expect(getFieldURL(fieldHref)).toBe('/foo/bar');
|
|
282
|
+
});
|
|
283
|
+
it('returns array of app URL if the field is an array of strings', () => {
|
|
284
|
+
const field = [
|
|
285
|
+
`${settings.apiPath}/foo/bar/1`,
|
|
286
|
+
`${settings.apiPath}/foo/bar/2`,
|
|
287
|
+
];
|
|
288
|
+
expect(getFieldURL(field)).toStrictEqual(['/foo/bar/1', '/foo/bar/2']);
|
|
289
|
+
});
|
|
290
|
+
it('returns array of app URL if the field is an array of objects', () => {
|
|
291
|
+
const field = [
|
|
292
|
+
{
|
|
293
|
+
'@type': 'URL',
|
|
294
|
+
value: `${settings.apiPath}/foo/bar/1`,
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
'@type': 'URL',
|
|
298
|
+
value: `${settings.apiPath}/foo/bar/2`,
|
|
299
|
+
},
|
|
300
|
+
];
|
|
301
|
+
expect(getFieldURL(field)).toStrictEqual(['/foo/bar/1', '/foo/bar/2']);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
263
304
|
describe('normalizeUrl', () => {
|
|
264
305
|
it('normalizeUrl test', () => {
|
|
265
306
|
const href = `www.example.com`;
|
package/test-setup-config.js
CHANGED
|
@@ -173,7 +173,15 @@ config.set('widgets', {
|
|
|
173
173
|
default: BaseWidget('default'),
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
config.set('components', {
|
|
176
|
+
config.set('components', {
|
|
177
|
+
PreviewImage: {
|
|
178
|
+
component: (props) => <img alt="PreviewImage component mock" {...props} />,
|
|
179
|
+
},
|
|
180
|
+
Image: {
|
|
181
|
+
// eslint-disable-next-line jsx-a11y/img-redundant-alt
|
|
182
|
+
component: (props) => <img alt="Image component mock" {...props} />,
|
|
183
|
+
},
|
|
184
|
+
});
|
|
177
185
|
config.set('experimental', {
|
|
178
186
|
addBlockButton: {
|
|
179
187
|
enabled: false,
|
|
@@ -811,6 +811,7 @@ body.has-toolbar.has-sidebar-collapsed .ui.wrapper > .ui.inner.block.full {
|
|
|
811
811
|
.listing-item a {
|
|
812
812
|
display: flex;
|
|
813
813
|
width: 100%;
|
|
814
|
+
align-items: flex-start;
|
|
814
815
|
|
|
815
816
|
@media only screen and (max-width: (@largestMobileScreen)) {
|
|
816
817
|
flex-direction: column;
|
|
@@ -822,6 +823,7 @@ body.has-toolbar.has-sidebar-collapsed .ui.wrapper > .ui.inner.block.full {
|
|
|
822
823
|
|
|
823
824
|
img {
|
|
824
825
|
width: 15%;
|
|
826
|
+
height: auto;
|
|
825
827
|
margin-right: 20px;
|
|
826
828
|
|
|
827
829
|
@media only screen and (max-width: (@largestMobileScreen)) {
|
|
@@ -645,6 +645,11 @@ body.has-toolbar-collapsed .mobile-menu {
|
|
|
645
645
|
transition: transform 0.5s cubic-bezier(0.09, 0.11, 0.24, 0.91);
|
|
646
646
|
}
|
|
647
647
|
|
|
648
|
+
img.responsive {
|
|
649
|
+
max-width: 100%;
|
|
650
|
+
height: auto;
|
|
651
|
+
}
|
|
652
|
+
|
|
648
653
|
// Deprecated as per https://github.com/plone/volto/issues/1265
|
|
649
654
|
// @import 'utils';
|
|
650
655
|
@import (multiple) '../extras/fonts';
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { isInternalURL } from '@plone/volto/helpers';
|
|
2
|
-
import config from '@plone/volto/registry';
|
|
3
|
-
|
|
4
|
-
export function getTeaserImageURL({ href, image, align }) {
|
|
5
|
-
// The default scale used in teasers is the 'teaser' scale
|
|
6
|
-
// except if it's customized otherwise in the teaser block settings
|
|
7
|
-
// or if the teaser is center (top)
|
|
8
|
-
const imageScale =
|
|
9
|
-
align === 'center'
|
|
10
|
-
? 'great'
|
|
11
|
-
: config.blocks.blocksConfig['teaser'].imageScale || 'teaser';
|
|
12
|
-
|
|
13
|
-
if (image) {
|
|
14
|
-
// If the image is overriden locally in the teaser block
|
|
15
|
-
if (isInternalURL(image['@id'])) {
|
|
16
|
-
// If it's internal check if image_scales catalog info is present
|
|
17
|
-
if (image?.image_scales?.[image?.image_field]) {
|
|
18
|
-
return `${image['@id']}/${
|
|
19
|
-
image.image_scales[image.image_field]?.[0].scales[imageScale]
|
|
20
|
-
?.download || image.image_scales[image.image_field]?.[0].download
|
|
21
|
-
}`;
|
|
22
|
-
} else {
|
|
23
|
-
// If not, fallback to content scale URL shortcut
|
|
24
|
-
return `${image['@id']}/@@images/${image.image_field}/${imageScale}`;
|
|
25
|
-
}
|
|
26
|
-
} else {
|
|
27
|
-
// If it's external, return the plain URL
|
|
28
|
-
return image['@id'];
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
// If the image is not overriden
|
|
32
|
-
if (href?.image_scales?.[href?.image_field]) {
|
|
33
|
-
return `${href['@id']}/${
|
|
34
|
-
href.image_scales[href.image_field]?.[0].scales[imageScale]?.download ||
|
|
35
|
-
href.image_scales[href.image_field]?.[0].download
|
|
36
|
-
}`;
|
|
37
|
-
} else {
|
|
38
|
-
// If not, fallback to content scale URL shortcut
|
|
39
|
-
return `${href['@id']}/@@images/${
|
|
40
|
-
href.image_field || 'preview_image'
|
|
41
|
-
}/${imageScale}`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { getTeaserImageURL } from './utils';
|
|
2
|
-
import config from '@plone/volto/registry';
|
|
3
|
-
|
|
4
|
-
beforeAll(() => {
|
|
5
|
-
config.blocks.blocksConfig.teaser = {};
|
|
6
|
-
config.blocks.blocksConfig.teaser.imageScale = 'teaser';
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
describe('getTeaserImageURL tests', () => {
|
|
10
|
-
it('getTeaserImageURL internal URL - no overriden', () => {
|
|
11
|
-
const align = 'left';
|
|
12
|
-
const href = {
|
|
13
|
-
'@id': '/document',
|
|
14
|
-
image_field: 'preview_image',
|
|
15
|
-
image_scales: {
|
|
16
|
-
preview_image: [
|
|
17
|
-
{
|
|
18
|
-
download: '@@images/default_original_URL',
|
|
19
|
-
scales: {
|
|
20
|
-
teaser: {
|
|
21
|
-
download: '@@images/teaser_scale_URL',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const image = undefined;
|
|
29
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
30
|
-
'/document/@@images/teaser_scale_URL',
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('getTeaserImageURL internal URL - no overriden - no scale', () => {
|
|
35
|
-
const align = 'left';
|
|
36
|
-
const href = {
|
|
37
|
-
'@id': '/document',
|
|
38
|
-
image_field: 'preview_image',
|
|
39
|
-
image_scales: {
|
|
40
|
-
preview_image: [
|
|
41
|
-
{
|
|
42
|
-
download: '@@images/default_original_URL',
|
|
43
|
-
scales: {},
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
const image = undefined;
|
|
49
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
50
|
-
'/document/@@images/default_original_URL',
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('getTeaserImageURL internal URL - no overriden - no catalog image info', () => {
|
|
55
|
-
const align = 'left';
|
|
56
|
-
const href = {
|
|
57
|
-
'@id': '/document',
|
|
58
|
-
image_field: 'image',
|
|
59
|
-
image_scales: {
|
|
60
|
-
preview_image: [
|
|
61
|
-
{
|
|
62
|
-
download: '@@images/default_original_URL',
|
|
63
|
-
scales: {},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
const image = undefined;
|
|
69
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
70
|
-
'/document/@@images/image/teaser',
|
|
71
|
-
);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('getTeaserImageURL internal URL - no overriden - center', () => {
|
|
75
|
-
const align = 'center';
|
|
76
|
-
const href = {
|
|
77
|
-
'@id': '/document',
|
|
78
|
-
image_field: 'preview_image',
|
|
79
|
-
image_scales: {
|
|
80
|
-
preview_image: [
|
|
81
|
-
{
|
|
82
|
-
download: '@@images/default_original_URL',
|
|
83
|
-
scales: {
|
|
84
|
-
great: {
|
|
85
|
-
download: '@@images/great_scale_URL',
|
|
86
|
-
},
|
|
87
|
-
teaser: {
|
|
88
|
-
download: '@@images/teaser_scale_URL',
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
const image = undefined;
|
|
96
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
97
|
-
'/document/@@images/great_scale_URL',
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('getTeaserImageURL internal URL - no overriden - center - no great scale', () => {
|
|
102
|
-
const align = 'center';
|
|
103
|
-
const href = {
|
|
104
|
-
'@id': '/document',
|
|
105
|
-
image_field: 'preview_image',
|
|
106
|
-
image_scales: {
|
|
107
|
-
preview_image: [
|
|
108
|
-
{
|
|
109
|
-
download: '@@images/default_original_URL',
|
|
110
|
-
scales: {
|
|
111
|
-
teaser: {
|
|
112
|
-
download: '@@images/teaser_scale_URL',
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
const image = undefined;
|
|
120
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
121
|
-
'/document/@@images/default_original_URL',
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('getTeaserImageURL internal URL - image overriden', () => {
|
|
126
|
-
const align = 'left';
|
|
127
|
-
const href = {
|
|
128
|
-
'@id': '/document',
|
|
129
|
-
image_field: 'preview_image',
|
|
130
|
-
image_scales: {
|
|
131
|
-
preview_image: [
|
|
132
|
-
{
|
|
133
|
-
download: '@@images/default_original_URL',
|
|
134
|
-
scales: {
|
|
135
|
-
teaser: {
|
|
136
|
-
download: '@@images/teaser_scale_URL',
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
const image = {
|
|
144
|
-
'@id': '/document/image',
|
|
145
|
-
image_field: 'image',
|
|
146
|
-
image_scales: {
|
|
147
|
-
image: [
|
|
148
|
-
{
|
|
149
|
-
download: '@@images/overriden_image_default_original_URL',
|
|
150
|
-
scales: {
|
|
151
|
-
teaser: {
|
|
152
|
-
download: '@@images/overriden_image_teaser_scale_URL',
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
160
|
-
'/document/image/@@images/overriden_image_teaser_scale_URL',
|
|
161
|
-
);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('getTeaserImageURL internal URL - image overriden - center - no great scale', () => {
|
|
165
|
-
const align = 'center';
|
|
166
|
-
const href = {
|
|
167
|
-
'@id': '/document',
|
|
168
|
-
image_field: 'preview_image',
|
|
169
|
-
image_scales: {
|
|
170
|
-
preview_image: [
|
|
171
|
-
{
|
|
172
|
-
download: '@@images/default_original_URL',
|
|
173
|
-
scales: {
|
|
174
|
-
teaser: {
|
|
175
|
-
download: '@@images/teaser_scale_URL',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
const image = {
|
|
183
|
-
'@id': '/document/image',
|
|
184
|
-
image_field: 'image',
|
|
185
|
-
image_scales: {
|
|
186
|
-
image: [
|
|
187
|
-
{
|
|
188
|
-
download: '@@images/overriden_image_default_original_URL',
|
|
189
|
-
scales: {
|
|
190
|
-
teaser: {
|
|
191
|
-
download: '@@images/overriden_image_teaser_scale_URL',
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
],
|
|
196
|
-
},
|
|
197
|
-
};
|
|
198
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
199
|
-
'/document/image/@@images/overriden_image_default_original_URL',
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('getTeaserImageURL internal URL - image overriden - external', () => {
|
|
204
|
-
const align = 'left';
|
|
205
|
-
const href = {
|
|
206
|
-
'@id': '/document',
|
|
207
|
-
image_field: 'preview_image',
|
|
208
|
-
image_scales: {
|
|
209
|
-
preview_image: [
|
|
210
|
-
{
|
|
211
|
-
download: '@@images/default_original_URL',
|
|
212
|
-
scales: {
|
|
213
|
-
teaser: {
|
|
214
|
-
download: '@@images/teaser_scale_URL',
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
],
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
const image = {
|
|
222
|
-
'@id': 'https://plone.org/document/image.png',
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
expect(getTeaserImageURL({ href, image, align })).toBe(
|
|
226
|
-
'https://plone.org/document/image.png',
|
|
227
|
-
);
|
|
228
|
-
});
|
|
229
|
-
});
|