@plone/volto 19.0.0-alpha.20 → 19.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +23 -5
  2. package/README.md +4 -4
  3. package/locales/ca/LC_MESSAGES/volto.po +5 -0
  4. package/locales/ca.json +1 -1
  5. package/locales/de/LC_MESSAGES/volto.po +5 -0
  6. package/locales/de.json +1 -1
  7. package/locales/en/LC_MESSAGES/volto.po +5 -0
  8. package/locales/en.json +1 -1
  9. package/locales/es/LC_MESSAGES/volto.po +5 -0
  10. package/locales/es.json +1 -1
  11. package/locales/eu/LC_MESSAGES/volto.po +5 -0
  12. package/locales/eu.json +1 -1
  13. package/locales/fi/LC_MESSAGES/volto.po +5 -0
  14. package/locales/fi.json +1 -1
  15. package/locales/fr/LC_MESSAGES/volto.po +5 -0
  16. package/locales/fr.json +1 -1
  17. package/locales/hi/LC_MESSAGES/volto.po +5 -0
  18. package/locales/hi.json +1 -1
  19. package/locales/it/LC_MESSAGES/volto.po +5 -0
  20. package/locales/it.json +1 -1
  21. package/locales/ja/LC_MESSAGES/volto.po +5 -0
  22. package/locales/ja.json +1 -1
  23. package/locales/nl/LC_MESSAGES/volto.po +5 -0
  24. package/locales/nl.json +1 -1
  25. package/locales/pt/LC_MESSAGES/volto.po +5 -0
  26. package/locales/pt.json +1 -1
  27. package/locales/pt_BR/LC_MESSAGES/volto.po +5 -0
  28. package/locales/pt_BR.json +1 -1
  29. package/locales/ro/LC_MESSAGES/volto.po +5 -0
  30. package/locales/ro.json +1 -1
  31. package/locales/ru/LC_MESSAGES/volto.po +5 -0
  32. package/locales/ru.json +1 -1
  33. package/locales/volto.pot +5 -0
  34. package/locales/zh_CN/LC_MESSAGES/volto.po +5 -0
  35. package/locales/zh_CN.json +1 -1
  36. package/package.json +6 -6
  37. package/src/components/manage/Add/Add.jsx +7 -3
  38. package/src/components/manage/Contents/DropZoneContent.jsx +15 -0
  39. package/src/components/manage/Form/Form.jsx +3 -3
  40. package/src/components/manage/Multilingual/CompareLanguages.jsx +6 -6
  41. package/src/components/manage/Multilingual/ManageTranslations.jsx +4 -4
  42. package/src/components/manage/Multilingual/TranslationObject.jsx +2 -2
  43. package/src/components/manage/Toolbar/Toolbar.jsx +14 -4
  44. package/src/components/manage/Toolbar/Types.jsx +6 -4
  45. package/src/components/theme/LanguageSelector/LanguageSelector.tsx +3 -3
  46. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +40 -10
  47. package/src/helpers/Blocks/Blocks.js +8 -9
  48. package/theme/themes/pastanaga/extras/toolbar.less +10 -5
@@ -10,6 +10,10 @@ const MultilingualRedirector = (props) => {
10
10
  const [cookies] = useCookies();
11
11
  const site = useSelector((state) => state.site.data);
12
12
  const isMultilingual = site.features?.multilingual;
13
+ const availableLanguages = useSelector(
14
+ (state) => state.site?.data?.['plone.available_languages'],
15
+ );
16
+ const currentLanguage = useSelector((state) => state.intl.locale);
13
17
  const redirectToLanguage =
14
18
  cookies['I18N_LANGUAGE'] || site['plone.default_language'];
15
19
  const dispatch = useDispatch();
@@ -18,21 +22,47 @@ const MultilingualRedirector = (props) => {
18
22
  // ToDo: Add means to support language negotiation (with config)
19
23
  // const detectedLang = (navigator.language || navigator.userLanguage).substring(0, 2);
20
24
  let mounted = true;
21
- if (isMultilingual && pathname === '/') {
22
- const langFileName = toGettextLang(redirectToLanguage);
23
- import(
24
- /* @vite-ignore */ '@root/../locales/' + langFileName + '.json'
25
- ).then((locale) => {
26
- if (mounted) {
27
- dispatch(changeLanguage(redirectToLanguage, locale.default));
25
+
26
+ const performLanguageSwitch = (targetLang) => {
27
+ const langFileName = toGettextLang(targetLang);
28
+ import(/* @vite-ignore */ '@root/../locales/' + langFileName + '.json')
29
+ .then((locale) => {
30
+ if (mounted) {
31
+ dispatch(changeLanguage(targetLang, locale.default));
32
+ }
33
+ })
34
+ .catch(() => {
35
+ // If locale file doesn't exist, still switch language with empty locale
36
+ if (mounted) {
37
+ dispatch(changeLanguage(targetLang, {}));
38
+ }
39
+ });
40
+ };
41
+
42
+ if (isMultilingual) {
43
+ if (pathname === '/') {
44
+ performLanguageSwitch(redirectToLanguage);
45
+ } else {
46
+ const lang = pathname.split('/')[1];
47
+ if (
48
+ availableLanguages?.includes(lang) &&
49
+ lang !== toBackendLang(currentLanguage)
50
+ ) {
51
+ performLanguageSwitch(lang);
28
52
  }
29
- });
53
+ }
30
54
  }
31
55
  return () => {
32
56
  mounted = false;
33
57
  };
34
- }, [pathname, dispatch, redirectToLanguage, isMultilingual]);
35
-
58
+ }, [
59
+ pathname,
60
+ dispatch,
61
+ redirectToLanguage,
62
+ isMultilingual,
63
+ availableLanguages,
64
+ currentLanguage,
65
+ ]);
36
66
  return pathname === '/' && isMultilingual ? (
37
67
  <Redirect to={`/${toBackendLang(redirectToLanguage)}`} />
38
68
  ) : (
@@ -90,10 +90,9 @@ export const getBlocks = (properties) => {
90
90
  const blocksFieldName = getBlocksFieldname(properties);
91
91
  const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
92
92
  return (
93
- properties[blocksLayoutFieldname]?.items?.map((n) => [
94
- n,
95
- properties[blocksFieldName][n],
96
- ]) || []
93
+ properties?.[blocksLayoutFieldname]?.items
94
+ ?.map((n) => [n, properties?.[blocksFieldName]?.[n]])
95
+ .filter(([, block]) => block !== undefined) || []
97
96
  );
98
97
  };
99
98
 
@@ -812,12 +811,12 @@ export function findBlocks(blocks = {}, types, result = []) {
812
811
  export const getBlocksHierarchy = (properties) => {
813
812
  const blocksFieldName = getBlocksFieldname(properties);
814
813
  const blocksLayoutFieldname = getBlocksLayoutFieldname(properties);
815
- return properties[blocksLayoutFieldname]?.items?.map((n) => ({
814
+ return properties?.[blocksLayoutFieldname]?.items?.map((n) => ({
816
815
  id: n,
817
- title: properties[blocksFieldName][n]?.['@type'],
818
- data: properties[blocksFieldName][n],
819
- children: isBlockContainer(properties[blocksFieldName][n])
820
- ? getBlocksHierarchy(properties[blocksFieldName][n])
816
+ title: properties?.[blocksFieldName]?.[n]?.['@type'],
817
+ data: properties?.[blocksFieldName]?.[n],
818
+ children: isBlockContainer(properties?.[blocksFieldName]?.[n])
819
+ ? getBlocksHierarchy(properties?.[blocksFieldName]?.[n])
821
820
  : [],
822
821
  }));
823
822
  };
@@ -129,10 +129,6 @@ body:not(.has-sidebar):not(.has-sidebar-collapsed) {
129
129
  }
130
130
 
131
131
  .toolbar-handler {
132
- .toolbar-handler-button {
133
- opacity: 0.3;
134
- }
135
-
136
132
  // State colors
137
133
  .published:before {
138
134
  background: @teal-blue;
@@ -259,6 +255,15 @@ body:not(.has-sidebar):not(.has-sidebar-collapsed) {
259
255
  height: 4px;
260
256
  background-color: red;
261
257
  content: '';
258
+ opacity: 0.65;
259
+ }
260
+
261
+ &:hover,
262
+ &:focus {
263
+ &::before {
264
+ opacity: 1;
265
+ transition: opacity 0.3s;
266
+ }
262
267
  }
263
268
  }
264
269
  }
@@ -714,7 +719,7 @@ body:not(.has-sidebar):not(.has-sidebar-collapsed) {
714
719
  }
715
720
 
716
721
  .compare-languages {
717
- @media (max-width: @largestMobileScreen - 1) {
722
+ @media (max-width: calc(@largestMobileScreen - 1px)) {
718
723
  position: fixed;
719
724
  top: 101px;
720
725
  left: 0;