@plone/volto 18.0.0-alpha.41 → 18.0.0-alpha.43

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 (187) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/finalreleasechangelog.py +48 -0
  3. package/locales/ca/LC_MESSAGES/volto.po +39 -13
  4. package/locales/ca.json +1 -1
  5. package/locales/de/LC_MESSAGES/volto.po +40 -14
  6. package/locales/de.json +1 -1
  7. package/locales/en/LC_MESSAGES/volto.po +39 -13
  8. package/locales/en.json +1 -1
  9. package/locales/es/LC_MESSAGES/volto.po +40 -14
  10. package/locales/es.json +1 -1
  11. package/locales/eu/LC_MESSAGES/volto.po +40 -14
  12. package/locales/eu.json +1 -1
  13. package/locales/fi/LC_MESSAGES/volto.po +40 -14
  14. package/locales/fi.json +1 -1
  15. package/locales/fr/LC_MESSAGES/volto.po +40 -14
  16. package/locales/fr.json +1 -1
  17. package/locales/hi/LC_MESSAGES/volto.po +40 -14
  18. package/locales/hi.json +1 -1
  19. package/locales/it/LC_MESSAGES/volto.po +40 -14
  20. package/locales/it.json +1 -1
  21. package/locales/ja/LC_MESSAGES/volto.po +39 -13
  22. package/locales/ja.json +1 -1
  23. package/locales/nl/LC_MESSAGES/volto.po +39 -13
  24. package/locales/nl.json +1 -1
  25. package/locales/pt/LC_MESSAGES/volto.po +39 -13
  26. package/locales/pt.json +1 -1
  27. package/locales/pt_BR/LC_MESSAGES/volto.po +40 -14
  28. package/locales/pt_BR.json +1 -1
  29. package/locales/ro/LC_MESSAGES/volto.po +39 -13
  30. package/locales/ro.json +1 -1
  31. package/locales/volto.pot +40 -14
  32. package/locales/zh_CN/LC_MESSAGES/volto.po +40 -14
  33. package/locales/zh_CN.json +1 -1
  34. package/package.json +5 -6
  35. package/razzle.config.js +3 -3
  36. package/src/components/index.js +0 -1
  37. package/src/components/manage/Actions/Actions.stories.jsx +138 -0
  38. package/src/components/manage/Add/Add.jsx +7 -4
  39. package/src/components/manage/BlockChooser/BlockChooser.jsx +9 -1
  40. package/src/components/manage/Blocks/Block/BlocksForm.jsx +5 -0
  41. package/src/components/manage/Blocks/Block/Edit.jsx +24 -8
  42. package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +17 -1
  43. package/src/components/manage/Blocks/Block/Order/Item.jsx +8 -2
  44. package/src/components/manage/Blocks/Block/Order/Order.jsx +2 -0
  45. package/src/components/manage/Blocks/Container/Data.jsx +10 -2
  46. package/src/components/manage/Blocks/Grid/View.jsx +3 -0
  47. package/src/components/manage/Blocks/Image/ImageSidebar.jsx +10 -2
  48. package/src/components/manage/Blocks/LeadImage/Edit.jsx +74 -126
  49. package/src/components/manage/Blocks/Listing/ListingData.jsx +10 -2
  50. package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
  51. package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +2 -0
  52. package/src/components/manage/Blocks/Search/SearchBlockView.jsx +18 -2
  53. package/src/components/manage/Blocks/Search/components/SortOn.jsx +82 -55
  54. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +1 -1
  55. package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +107 -176
  56. package/src/components/manage/Blocks/Teaser/Data.jsx +10 -2
  57. package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +15 -8
  58. package/src/components/manage/Blocks/ToC/Edit.jsx +36 -28
  59. package/src/components/manage/Blocks/Video/Edit.jsx +105 -172
  60. package/src/components/manage/Blocks/Video/Edit.stories.jsx +57 -0
  61. package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
  62. package/src/components/manage/Contents/Contents.jsx +4 -1
  63. package/src/components/manage/Contents/ContentsBreadcrumbs.stories.jsx +46 -0
  64. package/src/components/manage/Contents/ContentsPropertiesModal.jsx +85 -52
  65. package/src/components/manage/Contents/ContentsUploadModal.jsx +230 -323
  66. package/src/components/manage/Contents/ContentsUploadModal.stories.jsx +56 -0
  67. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +323 -441
  68. package/src/components/manage/Controlpanels/Aliases.jsx +452 -580
  69. package/src/components/manage/Controlpanels/Aliases.stories.jsx +74 -0
  70. package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -0
  71. package/src/components/manage/Controlpanels/Controlpanel.jsx +41 -2
  72. package/src/components/manage/Controlpanels/Controlpanel.test.jsx +55 -24
  73. package/src/components/manage/Controlpanels/DatabaseInformation.jsx +162 -229
  74. package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +74 -122
  75. package/src/components/manage/Controlpanels/UndoControlpanel.jsx +3 -3
  76. package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +28 -12
  77. package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +12 -4
  78. package/src/components/manage/Display/Display.jsx +92 -148
  79. package/src/components/manage/Display/Display.stories.jsx +46 -0
  80. package/src/components/manage/Edit/Edit.jsx +2 -4
  81. package/src/components/manage/Form/Form.jsx +85 -20
  82. package/src/components/manage/Form/InlineForm.jsx +2 -4
  83. package/src/components/manage/Form/ModalForm.jsx +1 -1
  84. package/src/components/manage/History/History.jsx +1 -1
  85. package/src/components/manage/Pluggable/Pluggable.test.js +1 -1
  86. package/src/components/manage/Preferences/ChangePassword.jsx +94 -172
  87. package/src/components/manage/Preferences/ChangePassword.stories.jsx +41 -0
  88. package/src/components/manage/Preferences/PersonalInformation.jsx +50 -115
  89. package/src/components/manage/Preferences/PersonalPreferences.jsx +46 -100
  90. package/src/components/manage/Preferences/PersonalPreferences.stories.jsx +48 -0
  91. package/src/components/manage/Toolbar/More.jsx +308 -399
  92. package/src/components/manage/Toolbar/Toolbar.jsx +1 -1
  93. package/src/components/manage/Widgets/ArrayWidget.jsx +2 -2
  94. package/src/components/manage/Widgets/DatetimeWidget.jsx +121 -175
  95. package/src/components/manage/Widgets/ImageWidget.jsx +6 -5
  96. package/src/components/manage/Widgets/RecurrenceWidget/EndField.jsx +7 -1
  97. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +80 -31
  98. package/src/components/manage/Widgets/ReferenceWidget.jsx +134 -210
  99. package/src/components/theme/Register/Register.jsx +70 -142
  100. package/src/components/theme/Register/Register.stories.jsx +49 -0
  101. package/src/components/theme/Search/Search.jsx +13 -5
  102. package/src/components/theme/Tags/Tags.jsx +19 -10
  103. package/src/components/theme/Tags/Tags.test.jsx +9 -11
  104. package/src/components/theme/View/AlbumView.jsx +122 -167
  105. package/src/components/theme/View/LinkView.jsx +4 -0
  106. package/src/components/theme/View/LinkView.test.jsx +2 -0
  107. package/src/components/theme/View/View.jsx +0 -13
  108. package/src/components/theme/View/View.test.jsx +0 -3
  109. package/src/config/ControlPanels.js +49 -43
  110. package/src/config/Widgets.jsx +1 -1
  111. package/src/config/config.test.js +1 -0
  112. package/src/config/index.js +23 -2
  113. package/src/config/slots.js +12 -0
  114. package/src/config/validation.ts +155 -0
  115. package/src/helpers/Blocks/Blocks.js +12 -7
  116. package/src/helpers/Blocks/Blocks.test.js +15 -0
  117. package/src/helpers/Blocks/cloneBlocks.ts +1 -1
  118. package/src/helpers/Extensions/withBlockExtensions.jsx +1 -1
  119. package/src/helpers/FormValidation/FormValidation.jsx +128 -172
  120. package/src/helpers/FormValidation/FormValidation.test.js +836 -8
  121. package/src/helpers/FormValidation/validators.ts +203 -0
  122. package/src/helpers/MessageLabels/MessageLabels.js +28 -0
  123. package/src/helpers/Url/Url.test.js +19 -6
  124. package/src/helpers/Url/urlRegex.js +1 -1
  125. package/src/helpers/User/User.js +1 -1
  126. package/src/helpers/index.js +2 -0
  127. package/src/hooks/client/useClient.js +1 -1
  128. package/src/middleware/api.js +4 -2
  129. package/src/middleware/index.js +1 -0
  130. package/src/middleware/userSessionReset.js +46 -0
  131. package/src/store.js +2 -0
  132. package/test-setup-config.jsx +10 -0
  133. package/theme/themes/default/modules/embed.variables +1 -1
  134. package/theme/themes/pastanaga/collections/form.overrides +34 -0
  135. package/theme/themes/pastanaga/extras/blocks.less +6 -0
  136. package/theme/themes/pastanaga/extras/sidebar.less +4 -0
  137. package/theme/themes/pastanaga/extras/toolbar.less +10 -3
  138. package/tsconfig.declarations.json +3 -2
  139. package/types/components/index.d.ts +0 -1
  140. package/types/components/manage/Actions/Actions.stories.d.ts +8 -0
  141. package/types/components/manage/Blocks/Block/Order/Order.d.ts +2 -1
  142. package/types/components/manage/Blocks/LeadImage/Edit.d.ts +14 -5
  143. package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +0 -5
  144. package/types/components/manage/Blocks/ToC/Edit.d.ts +1 -6
  145. package/types/components/manage/Blocks/Video/Edit.d.ts +1 -1
  146. package/types/components/manage/Blocks/Video/Edit.stories.d.ts +8 -0
  147. package/types/components/manage/Contents/ContentsBreadcrumbs.stories.d.ts +8 -0
  148. package/types/components/manage/Contents/ContentsUploadModal.d.ts +14 -2
  149. package/types/components/manage/Contents/ContentsUploadModal.stories.d.ts +8 -0
  150. package/types/components/manage/Contents/index.d.ts +1 -1
  151. package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +2 -2
  152. package/types/components/manage/Controlpanels/Aliases.d.ts +2 -2
  153. package/types/components/manage/Controlpanels/Aliases.stories.d.ts +8 -0
  154. package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +2 -2
  155. package/types/components/manage/Controlpanels/Groups/RenderGroups.d.ts +10 -5
  156. package/types/components/manage/Controlpanels/index.d.ts +4 -4
  157. package/types/components/manage/Display/Display.stories.d.ts +8 -0
  158. package/types/components/manage/Preferences/ChangePassword.d.ts +2 -2
  159. package/types/components/manage/Preferences/ChangePassword.stories.d.ts +8 -0
  160. package/types/components/manage/Preferences/PersonalInformation.d.ts +7 -2
  161. package/types/components/manage/Preferences/PersonalPreferences.d.ts +5 -1
  162. package/types/components/manage/Preferences/PersonalPreferences.stories.d.ts +8 -0
  163. package/types/components/manage/Toolbar/More.d.ts +8 -5
  164. package/types/components/manage/Widgets/DatetimeWidget.d.ts +0 -85
  165. package/types/components/manage/Widgets/DatetimeWidget.stories.d.ts +0 -1
  166. package/types/components/manage/Widgets/ReferenceWidget.d.ts +27 -2
  167. package/types/components/manage/Widgets/index.d.ts +1 -1
  168. package/types/components/theme/Register/Register.d.ts +2 -2
  169. package/types/components/theme/Register/Register.stories.d.ts +9 -0
  170. package/types/components/theme/Tags/Tags.d.ts +15 -7
  171. package/types/components/theme/View/AlbumView.d.ts +3 -17
  172. package/types/config/ControlPanels.d.ts +8 -0
  173. package/types/config/RichTextEditor/ToHTML.d.ts +1 -1
  174. package/types/config/Widgets.d.ts +3 -3
  175. package/types/config/slots.d.ts +21 -0
  176. package/types/config/validation.d.ts +3 -0
  177. package/types/helpers/Blocks/Blocks.d.ts +6 -0
  178. package/types/helpers/Extensions/withBlockExtensions.d.ts +1 -1
  179. package/types/helpers/FormValidation/FormValidation.d.ts +2 -0
  180. package/types/helpers/FormValidation/validators.d.ts +29 -0
  181. package/types/helpers/MessageLabels/MessageLabels.d.ts +36 -0
  182. package/types/helpers/User/User.d.ts +1 -1
  183. package/types/helpers/index.d.ts +2 -2
  184. package/types/middleware/index.d.ts +1 -0
  185. package/types/middleware/userSessionReset.d.ts +5 -0
  186. package/src/components/theme/SocialSharing/SocialSharing.jsx +0 -48
  187. package/src/components/theme/SocialSharing/SocialSharing.test.jsx +0 -14
@@ -55,7 +55,6 @@ import ImageWidget from '@plone/volto/components/manage/Widgets/ImageWidget';
55
55
  // Widgets mapping
56
56
  export const widgetMapping = {
57
57
  id: {
58
- schema: SchemaWidget,
59
58
  subjects: TokenWidget,
60
59
  query: QuerystringWidget,
61
60
  recurrence: RecurrenceWidget,
@@ -89,6 +88,7 @@ export const widgetMapping = {
89
88
  autocomplete: SelectAutoComplete,
90
89
  color_picker: ColorPickerWidget,
91
90
  select: SelectWidget,
91
+ schema: SchemaWidget,
92
92
  },
93
93
  vocabulary: {
94
94
  'plone.app.vocabularies.Catalog': ObjectBrowserWidget,
@@ -221,6 +221,7 @@ test('test navigation controlpanel fields', () => {
221
221
  const not_in_navigation = [
222
222
  'generate_tabs',
223
223
  'navigation_depth',
224
+ 'nonfolderish_tabs',
224
225
  'sort_tabs_on',
225
226
  'sort_tabs_reversed',
226
227
  'sitemap_depth',
@@ -18,6 +18,7 @@ import {
18
18
  import { components } from './Components';
19
19
  import { loadables } from './Loadables';
20
20
  import { workflowMapping } from './Workflows';
21
+ import slots from './slots';
21
22
 
22
23
  import { contentIcons } from './ContentIcons';
23
24
  import { styleClassNameConverters, styleClassNameExtenders } from './Style';
@@ -25,6 +26,7 @@ import {
25
26
  controlPanelsIcons,
26
27
  filterControlPanels,
27
28
  filterControlPanelsSchema,
29
+ unwantedControlPanelsFields,
28
30
  } from './ControlPanels';
29
31
 
30
32
  import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons';
@@ -32,6 +34,7 @@ import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons';
32
34
  import ConfigRegistry from '@plone/volto/registry';
33
35
 
34
36
  import { getSiteAsyncPropExtender } from '@plone/volto/helpers';
37
+ import { registerValidators } from './validation';
35
38
 
36
39
  const host = process.env.HOST || 'localhost';
37
40
  const port = process.env.PORT || '3000';
@@ -97,7 +100,7 @@ let config = {
97
100
  process.env.RAZZLE_INTERNAL_API_PATH ||
98
101
  process.env.RAZZLE_API_PATH ||
99
102
  'http://localhost:8080/Plone', // Set it to '' for disabling the proxy
100
- // proxyRewriteTarget Set it for set a custom target for the proxy or overide the internal VHM rewrite
103
+ // proxyRewriteTarget Set it for set a custom target for the proxy or override the internal VHM rewrite
101
104
  // proxyRewriteTarget: '/VirtualHostBase/http/localhost:8080/Plone/VirtualHostRoot/_vh_api'
102
105
  // proxyRewriteTarget: 'https://myvoltositeinproduction.com'
103
106
  proxyRewriteTarget: process.env.RAZZLE_PROXY_REWRITE_TARGET || undefined,
@@ -152,6 +155,7 @@ let config = {
152
155
  controlPanelsIcons,
153
156
  filterControlPanels,
154
157
  filterControlPanelsSchema,
158
+ unwantedControlPanelsFields,
155
159
  externalRoutes: [
156
160
  // URL to be considered as external
157
161
  // {
@@ -167,6 +171,7 @@ let config = {
167
171
  ],
168
172
  showSelfRegistration: false,
169
173
  contentMetadataTagsImageField: 'image',
174
+ contentPropertiesSchemaEnhancer: null,
170
175
  hasWorkingCopySupport: false,
171
176
  maxUndoLevels: 200, // undo history size for the main form
172
177
  addonsInfo: addonsInfo,
@@ -209,8 +214,9 @@ let config = {
209
214
  },
210
215
  addonRoutes: [],
211
216
  addonReducers: {},
212
- slots: {},
213
217
  components,
218
+ slots: {},
219
+ utilities: {},
214
220
  };
215
221
 
216
222
  // The apiExpanders depends on a config of the object, so it's done here
@@ -238,5 +244,20 @@ ConfigRegistry.addonRoutes = config.addonRoutes;
238
244
  ConfigRegistry.addonReducers = config.addonReducers;
239
245
  ConfigRegistry.components = config.components;
240
246
  ConfigRegistry.slots = config.slots;
247
+ ConfigRegistry.utilities = config.utilities;
248
+
249
+ // Register slots
250
+ Object.entries(slots).forEach(([slotName, components]) => {
251
+ components.forEach(({ name, component, predicates = [] }) => {
252
+ ConfigRegistry.registerSlotComponent({
253
+ slot: slotName,
254
+ name,
255
+ component,
256
+ predicates,
257
+ });
258
+ });
259
+ });
260
+
261
+ registerValidators(ConfigRegistry);
241
262
 
242
263
  applyAddonConfiguration(ConfigRegistry);
@@ -0,0 +1,12 @@
1
+ import { Tags } from '@plone/volto/components';
2
+
3
+ const slots = {
4
+ belowContent: [
5
+ {
6
+ name: 'tags',
7
+ component: Tags,
8
+ },
9
+ ],
10
+ };
11
+
12
+ export default slots;
@@ -0,0 +1,155 @@
1
+ import { ConfigType } from '@plone/registry';
2
+
3
+ import {
4
+ minLengthValidator,
5
+ maxLengthValidator,
6
+ urlValidator,
7
+ emailValidator,
8
+ isNumberValidator,
9
+ maximumValidator,
10
+ minimumValidator,
11
+ isIntegerValidator,
12
+ maxItemsValidator,
13
+ minItemsValidator,
14
+ hasUniqueItemsValidator,
15
+ startEventDateRangeValidator,
16
+ endEventDateRangeValidator,
17
+ patternValidator,
18
+ } from '@plone/volto/helpers/FormValidation/validators';
19
+
20
+ const registerValidators = (config: ConfigType) => {
21
+ config.registerUtility({
22
+ name: 'minLength',
23
+ type: 'validator',
24
+ dependencies: { fieldType: 'string' },
25
+ method: minLengthValidator,
26
+ });
27
+
28
+ config.registerUtility({
29
+ name: 'maxLength',
30
+ type: 'validator',
31
+ dependencies: { fieldType: 'string' },
32
+ method: maxLengthValidator,
33
+ });
34
+
35
+ config.registerUtility({
36
+ name: 'pattern',
37
+ type: 'validator',
38
+ dependencies: { fieldType: 'string' },
39
+ method: patternValidator,
40
+ });
41
+
42
+ config.registerUtility({
43
+ name: 'minLength',
44
+ type: 'validator',
45
+ dependencies: { fieldType: 'password' },
46
+ method: minLengthValidator,
47
+ });
48
+
49
+ config.registerUtility({
50
+ name: 'maxLength',
51
+ type: 'validator',
52
+ dependencies: { fieldType: 'password' },
53
+ method: maxLengthValidator,
54
+ });
55
+
56
+ config.registerUtility({
57
+ name: 'pattern',
58
+ type: 'validator',
59
+ dependencies: { fieldType: 'password' },
60
+ method: patternValidator,
61
+ });
62
+
63
+ config.registerUtility({
64
+ name: 'email',
65
+ type: 'validator',
66
+ dependencies: { widget: 'email' },
67
+ method: emailValidator,
68
+ });
69
+
70
+ config.registerUtility({
71
+ name: 'url',
72
+ type: 'validator',
73
+ dependencies: { widget: 'url' },
74
+ method: urlValidator,
75
+ });
76
+
77
+ config.registerUtility({
78
+ name: 'number',
79
+ type: 'validator',
80
+ dependencies: { fieldType: 'number' },
81
+ method: isNumberValidator,
82
+ });
83
+
84
+ config.registerUtility({
85
+ name: 'minimum',
86
+ type: 'validator',
87
+ dependencies: { fieldType: 'number' },
88
+ method: minimumValidator,
89
+ });
90
+
91
+ config.registerUtility({
92
+ name: 'maximum',
93
+ type: 'validator',
94
+ dependencies: { fieldType: 'number' },
95
+ method: maximumValidator,
96
+ });
97
+
98
+ config.registerUtility({
99
+ name: 'integer',
100
+ type: 'validator',
101
+ dependencies: { fieldType: 'integer' },
102
+ method: isIntegerValidator,
103
+ });
104
+
105
+ config.registerUtility({
106
+ name: 'minimum',
107
+ type: 'validator',
108
+ dependencies: { fieldType: 'integer' },
109
+ method: minimumValidator,
110
+ });
111
+
112
+ config.registerUtility({
113
+ name: 'maximum',
114
+ type: 'validator',
115
+ dependencies: { fieldType: 'integer' },
116
+ method: maximumValidator,
117
+ });
118
+
119
+ config.registerUtility({
120
+ name: 'maxItems',
121
+ type: 'validator',
122
+ dependencies: { fieldType: 'array' },
123
+ method: maxItemsValidator,
124
+ });
125
+
126
+ config.registerUtility({
127
+ name: 'minItems',
128
+ type: 'validator',
129
+ dependencies: { fieldType: 'array' },
130
+ method: minItemsValidator,
131
+ });
132
+
133
+ config.registerUtility({
134
+ name: 'uniqueItems',
135
+ type: 'validator',
136
+ dependencies: { fieldType: 'array' },
137
+ method: hasUniqueItemsValidator,
138
+ });
139
+
140
+ config.registerUtility({
141
+ name: 'dateRangeValidator',
142
+ type: 'validator',
143
+ dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'start' },
144
+ method: startEventDateRangeValidator,
145
+ });
146
+
147
+ config.registerUtility({
148
+ name: 'dateRangeValidator',
149
+ type: 'validator',
150
+ dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'end' },
151
+ method: endEventDateRangeValidator,
152
+ });
153
+ };
154
+
155
+ export { registerValidators };
@@ -161,7 +161,7 @@ export function addBlock(formData, type, index, blocksConfig) {
161
161
 
162
162
  return [
163
163
  id,
164
- _applyBlockInitialValue({
164
+ applyBlockInitialValue({
165
165
  id,
166
166
  value,
167
167
  blocksConfig,
@@ -197,8 +197,12 @@ export function addBlock(formData, type, index, blocksConfig) {
197
197
  * to call `onChangeBlock` at their creation time, as this is prone to racing
198
198
  * issue on block data storage.
199
199
  */
200
- const _applyBlockInitialValue = ({ id, value, blocksConfig, formData }) => {
201
- const blocksFieldname = getBlocksFieldname(formData);
200
+ export const applyBlockInitialValue = ({
201
+ id,
202
+ value,
203
+ blocksConfig,
204
+ formData,
205
+ }) => {
202
206
  const type = value['@type'];
203
207
  blocksConfig = blocksConfig || config.blocks.blocksConfig;
204
208
 
@@ -208,6 +212,7 @@ const _applyBlockInitialValue = ({ id, value, blocksConfig, formData }) => {
208
212
  value,
209
213
  formData,
210
214
  });
215
+ const blocksFieldname = getBlocksFieldname(formData);
211
216
  formData[blocksFieldname][id] = value;
212
217
  }
213
218
 
@@ -238,7 +243,7 @@ export function mutateBlock(formData, id, value, blocksConfig) {
238
243
  const trailId = formData[blocksLayoutFieldname].items[index];
239
244
  if (trailId) {
240
245
  const block = formData[blocksFieldname][trailId];
241
- newFormData = _applyBlockInitialValue({
246
+ newFormData = applyBlockInitialValue({
242
247
  id,
243
248
  value,
244
249
  blocksConfig,
@@ -256,7 +261,7 @@ export function mutateBlock(formData, id, value, blocksConfig) {
256
261
  }
257
262
 
258
263
  const idTrailingBlock = uuid();
259
- newFormData = _applyBlockInitialValue({
264
+ newFormData = applyBlockInitialValue({
260
265
  id,
261
266
  value,
262
267
  blocksConfig,
@@ -307,8 +312,8 @@ export function insertBlock(
307
312
  });
308
313
 
309
314
  const newBlockId = uuid();
310
- const newFormData = _applyBlockInitialValue({
311
- id,
315
+ const newFormData = applyBlockInitialValue({
316
+ id: newBlockId,
312
317
  value,
313
318
  blocksConfig,
314
319
  formData: {
@@ -511,6 +511,21 @@ describe('Blocks', () => {
511
511
  });
512
512
  });
513
513
 
514
+ it('initializes data for new block with initialValue in insertBlock', () => {
515
+ const [newId, form] = insertBlock(
516
+ {
517
+ blocks: { a: { value: 1 }, b: { value: 2 } },
518
+ blocks_layout: { items: ['a', 'b'] },
519
+ },
520
+ 'b',
521
+ { '@type': 'dummyText' },
522
+ );
523
+ expect(form.blocks[newId]).toStrictEqual({
524
+ '@type': 'dummyText',
525
+ marker: true,
526
+ });
527
+ });
528
+
514
529
  it('initializes data for new block based on schema defaults', () => {
515
530
  const [newId, form] = addBlock(
516
531
  {
@@ -4,7 +4,7 @@ import {
4
4
  getBlocksFieldname,
5
5
  getBlocksLayoutFieldname,
6
6
  hasBlocksData,
7
- } from './Blocks';
7
+ } from '@plone/volto/helpers/Blocks/Blocks';
8
8
  import config from '@plone/registry';
9
9
 
10
10
  export function cloneBlocks(blocksData) {
@@ -51,7 +51,7 @@ export function resolveExtension(name, extensions, data) {
51
51
  * - extensions is the blocksConfig extensions object for that block
52
52
  * - resolvedExtensions is an object with
53
53
  * `{ variation, <someExtensionA>, <someExtensionB> }` and each of these
54
- * fields hold the coresponding definition object from the block's
54
+ * fields hold the corresponding definition object from the block's
55
55
  * configuration.
56
56
  */
57
57
  export function resolveBlockExtensions(data, blocksConfig) {