@plone/volto 15.0.0-alpha.4 → 15.0.0-alpha.8

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 (238) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +7 -6
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -1
  3. package/.github/workflows/docs.yml +15 -55
  4. package/CHANGELOG.md +57 -2
  5. package/CODE_OF_CONDUCT.md +0 -1
  6. package/COMMITLINT.md +19 -21
  7. package/README.md +1 -1
  8. package/SECURITY.md +0 -1
  9. package/addon-registry.js +6 -3
  10. package/dist/assets.json +1 -0
  11. package/dist/chunks.json +572 -0
  12. package/dist/loadable-stats.json +2099 -0
  13. package/dist/public/android-chrome-192x192.png +0 -0
  14. package/dist/public/android-chrome-512x512.png +0 -0
  15. package/dist/public/apple-touch-icon.png +0 -0
  16. package/dist/public/favicon-16x16.png +0 -0
  17. package/dist/public/favicon-32x32.png +0 -0
  18. package/dist/public/favicon.ico +0 -0
  19. package/dist/public/icon.svg +13 -0
  20. package/dist/public/index.html.spa +34 -0
  21. package/dist/public/robots.txt +2 -0
  22. package/dist/public/site.webmanifest +19 -0
  23. package/dist/public/static/css/15.2cdd5437.chunk.css +409 -0
  24. package/dist/public/static/css/15.2cdd5437.chunk.css.map +1 -0
  25. package/dist/public/static/css/8.37cef611.chunk.css +2 -0
  26. package/dist/public/static/css/8.37cef611.chunk.css.map +1 -0
  27. package/dist/public/static/css/client.4cb92c57.chunk.css +8 -0
  28. package/dist/public/static/css/client.4cb92c57.chunk.css.map +1 -0
  29. package/dist/public/static/css/plone-volto-components-manage-Widgets-DatetimeWidget.c847a331.chunk.css +2 -0
  30. package/dist/public/static/css/plone-volto-components-manage-Widgets-DatetimeWidget.c847a331.chunk.css.map +1 -0
  31. package/dist/public/static/js/0.3e794c57.chunk.js +2 -0
  32. package/dist/public/static/js/0.3e794c57.chunk.js.map +1 -0
  33. package/dist/public/static/js/1.fece2b93.chunk.js +3 -0
  34. package/dist/public/static/js/1.fece2b93.chunk.js.LICENSE.txt +8 -0
  35. package/dist/public/static/js/1.fece2b93.chunk.js.map +1 -0
  36. package/dist/public/static/js/15.2cdd5437.chunk.js +3 -0
  37. package/dist/public/static/js/15.2cdd5437.chunk.js.LICENSE.txt +120 -0
  38. package/dist/public/static/js/15.2cdd5437.chunk.js.map +1 -0
  39. package/dist/public/static/js/16.a3a0662d.chunk.js +3 -0
  40. package/dist/public/static/js/16.a3a0662d.chunk.js.LICENSE.txt +8 -0
  41. package/dist/public/static/js/16.a3a0662d.chunk.js.map +1 -0
  42. package/dist/public/static/js/17.9478c50d.chunk.js +2 -0
  43. package/dist/public/static/js/17.9478c50d.chunk.js.map +1 -0
  44. package/dist/public/static/js/18.388e65d0.chunk.js +2 -0
  45. package/dist/public/static/js/18.388e65d0.chunk.js.map +1 -0
  46. package/dist/public/static/js/19.7c6b4a80.chunk.js +2 -0
  47. package/dist/public/static/js/19.7c6b4a80.chunk.js.map +1 -0
  48. package/dist/public/static/js/2.e6b0d690.chunk.js +2 -0
  49. package/dist/public/static/js/2.e6b0d690.chunk.js.map +1 -0
  50. package/dist/public/static/js/20.ada67f0e.chunk.js +3 -0
  51. package/dist/public/static/js/20.ada67f0e.chunk.js.LICENSE.txt +8 -0
  52. package/dist/public/static/js/20.ada67f0e.chunk.js.map +1 -0
  53. package/dist/public/static/js/21.3de49ac8.chunk.js +2 -0
  54. package/dist/public/static/js/21.3de49ac8.chunk.js.map +1 -0
  55. package/dist/public/static/js/22.ecefb8f2.chunk.js +2 -0
  56. package/dist/public/static/js/22.ecefb8f2.chunk.js.map +1 -0
  57. package/dist/public/static/js/23.3027bc00.chunk.js +2 -0
  58. package/dist/public/static/js/23.3027bc00.chunk.js.map +1 -0
  59. package/dist/public/static/js/24.aaaf4abf.chunk.js +2 -0
  60. package/dist/public/static/js/24.aaaf4abf.chunk.js.map +1 -0
  61. package/dist/public/static/js/25.c4d7d5e0.chunk.js +2 -0
  62. package/dist/public/static/js/25.c4d7d5e0.chunk.js.map +1 -0
  63. package/dist/public/static/js/26.d59ac3c1.chunk.js +2 -0
  64. package/dist/public/static/js/26.d59ac3c1.chunk.js.map +1 -0
  65. package/dist/public/static/js/27.266d95dd.chunk.js +2 -0
  66. package/dist/public/static/js/27.266d95dd.chunk.js.map +1 -0
  67. package/dist/public/static/js/28.d965d304.chunk.js +2 -0
  68. package/dist/public/static/js/28.d965d304.chunk.js.map +1 -0
  69. package/dist/public/static/js/29.7d8d1992.chunk.js +2 -0
  70. package/dist/public/static/js/29.7d8d1992.chunk.js.map +1 -0
  71. package/dist/public/static/js/3.025ba843.chunk.js +2 -0
  72. package/dist/public/static/js/3.025ba843.chunk.js.map +1 -0
  73. package/dist/public/static/js/30.a3d54e31.chunk.js +2 -0
  74. package/dist/public/static/js/30.a3d54e31.chunk.js.map +1 -0
  75. package/dist/public/static/js/31.9edf64ee.chunk.js +2 -0
  76. package/dist/public/static/js/31.9edf64ee.chunk.js.map +1 -0
  77. package/dist/public/static/js/32.649dbfc2.chunk.js +2 -0
  78. package/dist/public/static/js/32.649dbfc2.chunk.js.map +1 -0
  79. package/dist/public/static/js/33.45949ca4.chunk.js +2 -0
  80. package/dist/public/static/js/33.45949ca4.chunk.js.map +1 -0
  81. package/dist/public/static/js/34.084257cf.chunk.js +2 -0
  82. package/dist/public/static/js/34.084257cf.chunk.js.map +1 -0
  83. package/dist/public/static/js/35.00679602.chunk.js +3 -0
  84. package/dist/public/static/js/35.00679602.chunk.js.LICENSE.txt +37 -0
  85. package/dist/public/static/js/35.00679602.chunk.js.map +1 -0
  86. package/dist/public/static/js/36.4a29fdbd.chunk.js +3 -0
  87. package/dist/public/static/js/36.4a29fdbd.chunk.js.LICENSE.txt +7 -0
  88. package/dist/public/static/js/36.4a29fdbd.chunk.js.map +1 -0
  89. package/dist/public/static/js/37.fbbe07b3.chunk.js +3 -0
  90. package/dist/public/static/js/37.fbbe07b3.chunk.js.LICENSE.txt +14 -0
  91. package/dist/public/static/js/37.fbbe07b3.chunk.js.map +1 -0
  92. package/dist/public/static/js/38.b31c59ad.chunk.js +3 -0
  93. package/dist/public/static/js/38.b31c59ad.chunk.js.LICENSE.txt +8 -0
  94. package/dist/public/static/js/38.b31c59ad.chunk.js.map +1 -0
  95. package/dist/public/static/js/39.69d6a789.chunk.js +2 -0
  96. package/dist/public/static/js/39.69d6a789.chunk.js.map +1 -0
  97. package/dist/public/static/js/4.bdc4a5c5.chunk.js +2 -0
  98. package/dist/public/static/js/4.bdc4a5c5.chunk.js.map +1 -0
  99. package/dist/public/static/js/40.90de6e4a.chunk.js +2 -0
  100. package/dist/public/static/js/40.90de6e4a.chunk.js.map +1 -0
  101. package/dist/public/static/js/7.7acc66bc.chunk.js +2 -0
  102. package/dist/public/static/js/7.7acc66bc.chunk.js.map +1 -0
  103. package/dist/public/static/js/8.37cef611.chunk.js +3 -0
  104. package/dist/public/static/js/8.37cef611.chunk.js.LICENSE.txt +25 -0
  105. package/dist/public/static/js/8.37cef611.chunk.js.map +1 -0
  106. package/dist/public/static/js/client.4cb92c57.chunk.js +2 -0
  107. package/dist/public/static/js/client.4cb92c57.chunk.js.map +1 -0
  108. package/dist/public/static/js/draft-js-lib-isSoftNewlineEvent.6cd05e34.chunk.js +2 -0
  109. package/dist/public/static/js/draft-js-lib-isSoftNewlineEvent.6cd05e34.chunk.js.map +1 -0
  110. package/dist/public/static/js/moment.2caa76d1.chunk.js +2 -0
  111. package/dist/public/static/js/moment.2caa76d1.chunk.js.map +1 -0
  112. package/dist/public/static/js/plone-volto-components-manage-Widgets-DatetimeWidget.c847a331.chunk.js +2 -0
  113. package/dist/public/static/js/plone-volto-components-manage-Widgets-DatetimeWidget.c847a331.chunk.js.map +1 -0
  114. package/dist/public/static/js/plone-volto-components-theme-View-EventView.433dd14b.chunk.js +2 -0
  115. package/dist/public/static/js/plone-volto-components-theme-View-EventView.433dd14b.chunk.js.map +1 -0
  116. package/dist/public/static/js/react-dates.f71abb7c.chunk.js +2 -0
  117. package/dist/public/static/js/react-dates.f71abb7c.chunk.js.map +1 -0
  118. package/dist/public/static/js/react-simple-code-editor.33478dc3.chunk.js +2 -0
  119. package/dist/public/static/js/react-simple-code-editor.33478dc3.chunk.js.map +1 -0
  120. package/dist/public/static/js/runtime~client.d372df0e.js +2 -0
  121. package/dist/public/static/js/runtime~client.d372df0e.js.map +1 -0
  122. package/dist/public/static/media/Logo.16e25cdf.svg +21 -0
  123. package/dist/public/static/media/block-image.8a4a14d5.svg +8 -0
  124. package/dist/public/static/media/block-maps.731e84f6.svg +7 -0
  125. package/dist/public/static/media/block-video.832fa3ff.svg +7 -0
  126. package/dist/public/static/media/default-image.9451b251.svg +13 -0
  127. package/dist/public/static/media/flags.9c74e172.png +0 -0
  128. package/dist/public/static/media/icons.022583c4.svg +320 -0
  129. package/dist/public/static/media/icons.06400145.ttf +0 -0
  130. package/dist/public/static/media/icons.dbc1ef8b.eot +0 -0
  131. package/dist/public/static/media/icons.df45b7de.woff +0 -0
  132. package/dist/server.js +2 -0
  133. package/locales/ca/LC_MESSAGES/volto.po +14 -0
  134. package/locales/ca.json +1 -1
  135. package/locales/de/LC_MESSAGES/volto.po +14 -0
  136. package/locales/de.json +1 -1
  137. package/locales/en/LC_MESSAGES/volto.po +14 -0
  138. package/locales/en.json +1 -1
  139. package/locales/es/LC_MESSAGES/volto.po +14 -0
  140. package/locales/es.json +1 -1
  141. package/locales/eu/LC_MESSAGES/volto.po +14 -0
  142. package/locales/eu.json +1 -1
  143. package/locales/fr/LC_MESSAGES/volto.po +14 -0
  144. package/locales/fr.json +1 -1
  145. package/locales/it/LC_MESSAGES/volto.po +14 -0
  146. package/locales/it.json +1 -1
  147. package/locales/ja/LC_MESSAGES/volto.po +14 -0
  148. package/locales/ja.json +1 -1
  149. package/locales/nl/LC_MESSAGES/volto.po +14 -0
  150. package/locales/nl.json +1 -1
  151. package/locales/pt/LC_MESSAGES/volto.po +14 -0
  152. package/locales/pt.json +1 -1
  153. package/locales/pt_BR/LC_MESSAGES/volto.po +14 -0
  154. package/locales/pt_BR.json +1 -1
  155. package/locales/ro/LC_MESSAGES/volto.po +14 -0
  156. package/locales/ro.json +1 -1
  157. package/locales/volto.pot +15 -1
  158. package/logos/Logo.png +0 -0
  159. package/logos/volto-colorful.png +0 -0
  160. package/logos/volto-colorful.svg +35 -0
  161. package/logos/volto-guide.png +0 -0
  162. package/logos/volto-h-transparent.svg +6 -0
  163. package/logos/volto-transparent.png +0 -0
  164. package/logos/volto-transparent.svg +19 -0
  165. package/logos/volto-transparent2.svg +5 -0
  166. package/logos/volto-yellow.svg +29 -0
  167. package/logos/volto.sketch +0 -0
  168. package/netlify.toml +2 -0
  169. package/package.json +6 -2
  170. package/razzle.config.js +2 -2
  171. package/src/actions/language/language.js +7 -2
  172. package/src/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +1 -2
  173. package/src/components/manage/AnchorPlugin/components/LinkButton/index.jsx +15 -6
  174. package/src/components/manage/AnchorPlugin/index.jsx +12 -5
  175. package/src/components/manage/AnchorPlugin/utils/EditorUtils.js +8 -7
  176. package/src/components/manage/Blocks/Description/Edit.jsx +33 -19
  177. package/src/components/manage/Blocks/Description/Edit.test.jsx +6 -0
  178. package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +37 -26
  179. package/src/components/manage/Blocks/HeroImageLeft/Edit.test.jsx +6 -0
  180. package/src/components/manage/Blocks/Search/README.md +20 -0
  181. package/src/components/manage/Blocks/Search/components/CheckboxFacet.jsx +16 -3
  182. package/src/components/manage/Blocks/Search/components/DateRangeFacet.jsx +120 -0
  183. package/src/components/manage/Blocks/Search/components/DateRangeFacet.test.jsx +34 -0
  184. package/src/components/manage/Blocks/Search/components/DateRangeFacetFilterListEntry.jsx +39 -0
  185. package/src/components/manage/Blocks/Search/components/Facets.jsx +24 -25
  186. package/src/components/manage/Blocks/Search/components/FilterList.jsx +37 -67
  187. package/src/components/manage/Blocks/Search/components/FilterList.test.jsx +49 -1
  188. package/src/components/manage/Blocks/Search/components/SelectFacet.jsx +9 -0
  189. package/src/components/manage/Blocks/Search/components/SelectFacetFilterListEntry.jsx +42 -0
  190. package/src/components/manage/Blocks/Search/components/SelectStyling.jsx +1 -1
  191. package/src/components/manage/Blocks/Search/components/ToggleFacet.jsx +38 -0
  192. package/src/components/manage/Blocks/Search/components/ToggleFacetFilterListEntry.jsx +39 -0
  193. package/src/components/manage/Blocks/Search/components/base.js +52 -0
  194. package/src/components/manage/Blocks/Search/components/index.js +5 -0
  195. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +68 -27
  196. package/src/components/manage/Blocks/Search/schema.js +7 -4
  197. package/src/components/manage/Blocks/Search/utils.js +16 -0
  198. package/src/components/manage/Blocks/Table/Cell.jsx +40 -14
  199. package/src/components/manage/Blocks/Table/Cell.test.jsx +7 -1
  200. package/src/components/manage/Blocks/Table/Edit.jsx +7 -3
  201. package/src/components/manage/Blocks/Table/Edit.test.jsx +6 -0
  202. package/src/components/manage/Blocks/Table/View.jsx +2 -2
  203. package/src/components/manage/Blocks/Text/Edit.jsx +56 -14
  204. package/src/components/manage/Blocks/Text/Edit.test.jsx +7 -1
  205. package/src/components/manage/Blocks/Text/View.jsx +2 -2
  206. package/src/components/manage/Blocks/Title/Edit.jsx +25 -13
  207. package/src/components/manage/Blocks/Title/Edit.test.jsx +6 -0
  208. package/src/components/manage/Sidebar/Sidebar.jsx +5 -1
  209. package/src/components/manage/Toolbar/Toolbar.jsx +3 -1
  210. package/src/components/manage/UniversalLink/UniversalLink.jsx +5 -2
  211. package/src/components/manage/Widgets/DatetimeWidget.jsx +3 -1
  212. package/src/components/manage/Widgets/UrlWidget.jsx +1 -1
  213. package/src/components/manage/Widgets/WysiwygWidget.jsx +45 -19
  214. package/src/components/manage/Widgets/WysiwygWidget.test.jsx +7 -1
  215. package/src/components/theme/View/LinkView.jsx +1 -1
  216. package/src/components/theme/View/View.jsx +5 -1
  217. package/src/config/Blocks.jsx +31 -0
  218. package/src/config/Loadables.jsx +22 -0
  219. package/src/config/RichTextEditor/Blocks.jsx +25 -20
  220. package/src/config/RichTextEditor/Plugins.jsx +38 -31
  221. package/src/config/RichTextEditor/Styles.jsx +48 -44
  222. package/src/config/RichTextEditor/index.js +25 -0
  223. package/src/config/index.js +14 -18
  224. package/src/helpers/Api/Api.js +18 -4
  225. package/src/helpers/Extensions/index.js +1 -1
  226. package/src/helpers/Extensions/withBlockExtensions.js +4 -0
  227. package/src/helpers/Extensions/withBlockExtensions.test.js +26 -1
  228. package/src/helpers/Url/Url.js +32 -1
  229. package/src/helpers/Url/urlRegex.js +7 -1
  230. package/src/helpers/index.js +2 -0
  231. package/src/middleware/api.js +21 -2
  232. package/src/server.jsx +9 -2
  233. package/test-setup-config.js +22 -7
  234. package/theme/themes/pastanaga/extras/blocks.less +29 -0
  235. package/src/components/manage/AnchorPlugin/utils/URLUtils.js +0 -36
  236. package/src/components/manage/AnchorPlugin/utils/mailRegex.js +0 -2
  237. package/src/components/manage/AnchorPlugin/utils/telRegex.js +0 -1
  238. package/src/components/manage/AnchorPlugin/utils/urlRegex.js +0 -54
@@ -5,18 +5,19 @@
5
5
 
6
6
  import React, { Component } from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import Editor from 'draft-js-plugins-editor';
9
- import { convertFromRaw, convertToRaw, EditorState, RichUtils } from 'draft-js';
10
- import createInlineToolbarPlugin from 'draft-js-inline-toolbar-plugin';
8
+ import { compose } from 'redux';
11
9
 
12
- import isSoftNewlineEvent from 'draft-js/lib/isSoftNewlineEvent';
13
10
  import { defineMessages, injectIntl } from 'react-intl';
14
11
  import { includes, isEqual } from 'lodash';
15
- import { filterEditorState } from 'draftjs-filters';
16
12
  import config from '@plone/volto/registry';
17
13
 
14
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
18
15
  import { BlockChooserButton } from '@plone/volto/components';
19
16
 
17
+ import loadable from '@loadable/component';
18
+
19
+ const Editor = loadable(() => import('draft-js-plugins-editor'));
20
+
20
21
  const messages = defineMessages({
21
22
  text: {
22
23
  id: 'Type text…',
@@ -29,7 +30,7 @@ const messages = defineMessages({
29
30
  * @class Edit
30
31
  * @extends Component
31
32
  */
32
- class Edit extends Component {
33
+ export class EditComponent extends Component {
33
34
  /**
34
35
  * Property types.
35
36
  * @property {Object} propTypes Property types.
@@ -77,6 +78,13 @@ class Edit extends Component {
77
78
  constructor(props) {
78
79
  super(props);
79
80
 
81
+ const { settings } = config;
82
+
83
+ this.draftConfig = settings.richtextEditorSettings(props);
84
+
85
+ const { EditorState, convertFromRaw } = props.draftJs;
86
+ const createInlineToolbarPlugin = props.draftJsInlineToolbarPlugin.default;
87
+
80
88
  if (!__SERVER__) {
81
89
  let editorState;
82
90
  if (props.data && props.data.text) {
@@ -88,7 +96,7 @@ class Edit extends Component {
88
96
  }
89
97
 
90
98
  const inlineToolbarPlugin = createInlineToolbarPlugin({
91
- structure: config.settings.richTextEditorInlineToolbarButtons,
99
+ structure: this.draftConfig.richTextEditorInlineToolbarButtons,
92
100
  });
93
101
 
94
102
  this.state = {
@@ -128,6 +136,7 @@ class Edit extends Component {
128
136
  //nothing is selected, move focus to end
129
137
  // See https://github.com/draft-js-plugins/draft-js-plugins/issues/800
130
138
  setTimeout(this.node.focus, 0);
139
+ const { EditorState } = this.props.draftJs;
131
140
 
132
141
  this.setState({
133
142
  editorState: EditorState.moveFocusToEnd(this.state.editorState),
@@ -137,6 +146,7 @@ class Edit extends Component {
137
146
  }
138
147
 
139
148
  componentDidUpdate(prevProps) {
149
+ const { convertToRaw, EditorState, convertFromRaw } = this.props.draftJs;
140
150
  if (
141
151
  !isEqual(this.props.data, prevProps.data) &&
142
152
  !isEqual(
@@ -179,6 +189,9 @@ class Edit extends Component {
179
189
  const shouldFilterPaste =
180
190
  editorState.getLastChangeType() === 'insert-fragment';
181
191
 
192
+ const { convertToRaw } = this.props.draftJs;
193
+ const { filterEditorState } = this.props.draftJsFilters;
194
+
182
195
  if (
183
196
  !isEqual(
184
197
  convertToRaw(editorState.getCurrentContent()),
@@ -217,6 +230,8 @@ class Edit extends Component {
217
230
  * @returns {string} Markup for the component.
218
231
  */
219
232
  render() {
233
+ // console.log('draft config', this.draftConfig);
234
+
220
235
  if (__SERVER__) {
221
236
  return <div />;
222
237
  }
@@ -229,7 +244,10 @@ class Edit extends Component {
229
244
  const disableNewBlocks =
230
245
  this.props.data?.disableNewBlocks || this.props.detached;
231
246
  const { InlineToolbar } = this.state.inlineToolbarPlugin;
232
- const { settings } = config;
247
+ // const { settings } = config;
248
+
249
+ const isSoftNewlineEvent = this.props.draftJsLibIsSoftNewlineEvent.default;
250
+ const { RichUtils } = this.props.draftJs;
233
251
 
234
252
  return (
235
253
  <>
@@ -239,11 +257,12 @@ class Edit extends Component {
239
257
  editorState={this.state.editorState}
240
258
  plugins={[
241
259
  this.state.inlineToolbarPlugin,
242
- ...settings.richTextEditorPlugins,
260
+ // ...settings.richTextEditorPlugins,
261
+ ...this.draftConfig.richTextEditorPlugins,
243
262
  ]}
244
- blockRenderMap={settings.extendedBlockRenderMap}
245
- blockStyleFn={settings.blockStyleFn}
246
- customStyleMap={settings.customStyleMap}
263
+ blockRenderMap={this.draftConfig.extendedBlockRenderMap}
264
+ blockStyleFn={this.draftConfig.blockStyleFn}
265
+ customStyleMap={this.draftConfig.customStyleMap}
247
266
  placeholder={placeholder}
248
267
  handleReturn={(e) => {
249
268
  if (isSoftNewlineEvent(e)) {
@@ -260,7 +279,7 @@ class Edit extends Component {
260
279
  anchorKey,
261
280
  );
262
281
  const blockType = currentContentBlock.getType();
263
- if (!includes(settings.listBlockTypes, blockType)) {
282
+ if (!includes(this.draftConfig.listBlockTypes, blockType)) {
264
283
  this.props.onSelectBlock(
265
284
  this.props.onAddBlock(
266
285
  config.settings.defaultBlockType,
@@ -329,4 +348,27 @@ class Edit extends Component {
329
348
  }
330
349
  }
331
350
 
332
- export default injectIntl(Edit);
351
+ export const Edit = compose(
352
+ injectIntl,
353
+ injectLazyLibs([
354
+ 'draftJs',
355
+ 'draftJsLibIsSoftNewlineEvent',
356
+ 'draftJsFilters',
357
+ 'draftJsInlineToolbarPlugin',
358
+ 'draftJsBlockBreakoutPlugin',
359
+ 'draftJsCreateInlineStyleButton',
360
+ 'draftJsCreateBlockStyleButton',
361
+ 'immutableLib',
362
+ // TODO: add all plugin dependencies, also in Wysiwyg and Cell
363
+ ]),
364
+ )(EditComponent);
365
+
366
+ const Preloader = (props) => {
367
+ const [loaded, setLoaded] = React.useState(false);
368
+ React.useEffect(() => {
369
+ Editor.load().then(() => setLoaded(true));
370
+ }, []);
371
+ return loaded ? <Edit {...props} /> : null;
372
+ };
373
+
374
+ export default Preloader;
@@ -3,12 +3,18 @@ import renderer from 'react-test-renderer';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
 
6
- import Edit from './Edit';
6
+ import { Edit } from './Edit';
7
7
 
8
8
  const mockStore = configureStore();
9
9
 
10
10
  global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
11
11
 
12
+ jest.mock('@plone/volto/helpers/Loadable/Loadable');
13
+ beforeAll(
14
+ async () =>
15
+ await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
16
+ );
17
+
12
18
  test('renders an edit text block component', () => {
13
19
  const store = mockStore({
14
20
  intl: {
@@ -17,8 +17,8 @@ const View = ({ data }) =>
17
17
  data.text ? (
18
18
  redraft(
19
19
  data.text,
20
- config.settings.ToHTMLRenderers,
21
- config.settings.ToHTMLOptions,
20
+ config.settings.richtextViewSettings.ToHTMLRenderers,
21
+ config.settings.richtextViewSettings.ToHTMLOptions,
22
22
  )
23
23
  ) : (
24
24
  <br />
@@ -4,12 +4,11 @@
4
4
  */
5
5
 
6
6
  import React, { Component } from 'react';
7
- import { Map } from 'immutable';
7
+ import { compose } from 'redux';
8
8
  import PropTypes from 'prop-types';
9
- import { stateFromHTML } from 'draft-js-import-html';
10
9
  import { isEqual } from 'lodash';
11
- import { Editor, DefaultDraftBlockRenderMap, EditorState } from 'draft-js';
12
10
  import { defineMessages, injectIntl } from 'react-intl';
11
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
13
12
  import config from '@plone/volto/registry';
14
13
 
15
14
  const messages = defineMessages({
@@ -19,14 +18,6 @@ const messages = defineMessages({
19
18
  },
20
19
  });
21
20
 
22
- const blockRenderMap = Map({
23
- unstyled: {
24
- element: 'h1',
25
- },
26
- });
27
-
28
- const extendedBlockRenderMap = DefaultDraftBlockRenderMap.merge(blockRenderMap);
29
-
30
21
  /**
31
22
  * Edit title block class.
32
23
  * @class Edit
@@ -71,6 +62,19 @@ class Edit extends Component {
71
62
  super(props);
72
63
 
73
64
  if (!__SERVER__) {
65
+ const { Map } = props.immutableLib;
66
+ const { DefaultDraftBlockRenderMap, EditorState } = props.draftJs;
67
+ const { stateFromHTML } = props.draftJsImportHtml;
68
+
69
+ const blockRenderMap = Map({
70
+ unstyled: {
71
+ element: 'h1',
72
+ },
73
+ });
74
+
75
+ this.extendedBlockRenderMap = DefaultDraftBlockRenderMap.merge(
76
+ blockRenderMap,
77
+ );
74
78
  let editorState;
75
79
  if (props.properties && props.properties.title) {
76
80
  const contentState = stateFromHTML(props.properties.title);
@@ -117,6 +121,9 @@ class Edit extends Component {
117
121
  this.props.properties.title !== nextProps.properties.title &&
118
122
  !this.state.focus
119
123
  ) {
124
+ const { stateFromHTML } = this.props.draftJsImportHtml;
125
+ const { EditorState } = this.props.draftJs;
126
+
120
127
  const contentState = stateFromHTML(nextProps.properties.title);
121
128
  this.setState({
122
129
  editorState: nextProps.properties.title
@@ -156,6 +163,8 @@ class Edit extends Component {
156
163
  return <div />;
157
164
  }
158
165
 
166
+ const { Editor } = this.props.draftJs;
167
+
159
168
  const placeholder =
160
169
  this.props.data.placeholder ||
161
170
  this.props.intl.formatMessage(messages.title);
@@ -165,7 +174,7 @@ class Edit extends Component {
165
174
  readOnly={!this.props.editable}
166
175
  onChange={this.onChange}
167
176
  editorState={this.state.editorState}
168
- blockRenderMap={extendedBlockRenderMap}
177
+ blockRenderMap={this.extendedBlockRenderMap}
169
178
  handleReturn={() => {
170
179
  if (this.props.data.disableNewBlocks) {
171
180
  return 'handled';
@@ -208,4 +217,7 @@ class Edit extends Component {
208
217
  }
209
218
  }
210
219
 
211
- export default injectIntl(Edit);
220
+ export default compose(
221
+ injectLazyLibs(['draftJs', 'immutableLib', 'draftJsImportHtml']),
222
+ injectIntl,
223
+ )(Edit);
@@ -5,6 +5,12 @@ import { Provider } from 'react-intl-redux';
5
5
 
6
6
  import Edit from './Edit';
7
7
 
8
+ jest.mock('@plone/volto/helpers/Loadable/Loadable');
9
+ beforeAll(
10
+ async () =>
11
+ await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
12
+ );
13
+
8
14
  const mockStore = configureStore();
9
15
 
10
16
  global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
@@ -18,6 +18,8 @@ import { setSidebarTab } from '@plone/volto/actions';
18
18
  import expandSVG from '@plone/volto/icons/left-key.svg';
19
19
  import collapseSVG from '@plone/volto/icons/right-key.svg';
20
20
 
21
+ import config from '@plone/volto/registry';
22
+
21
23
  const messages = defineMessages({
22
24
  document: {
23
25
  id: 'Document',
@@ -98,7 +100,9 @@ class Sidebar extends Component {
98
100
  onToggleExpanded() {
99
101
  const { cookies } = this.props;
100
102
  cookies.set('sidebar_expanded', !this.state.expanded, {
101
- expires: new Date((2 ** 31 - 1) * 1000),
103
+ expires: new Date(
104
+ new Date().getTime() + config.settings.cookieExpires * 1000,
105
+ ),
102
106
  path: '/',
103
107
  });
104
108
  this.setState({
@@ -232,7 +232,9 @@ class Toolbar extends Component {
232
232
  handleShrink = () => {
233
233
  const { cookies } = this.props;
234
234
  cookies.set('toolbar_expanded', !this.state.expanded, {
235
- expires: new Date((2 ** 31 - 1) * 1000),
235
+ expires: new Date(
236
+ new Date().getTime() + config.settings.cookieExpires * 1000,
237
+ ),
236
238
  path: '/',
237
239
  });
238
240
  this.setState(
@@ -7,8 +7,11 @@ import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { Link } from 'react-router-dom';
9
9
  import { useSelector } from 'react-redux';
10
- import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers/Url/Url';
11
- import URLUtils from '@plone/volto/components/manage/AnchorPlugin/utils/URLUtils';
10
+ import {
11
+ flattenToAppURL,
12
+ isInternalURL,
13
+ URLUtils,
14
+ } from '@plone/volto/helpers/Url/Url';
12
15
  import { matchPath } from 'react-router';
13
16
 
14
17
  import config from '@plone/volto/registry';
@@ -178,7 +178,9 @@ export class DatetimeWidgetComponent extends Component {
178
178
  onFocusChange = ({ focused }) => this.setState({ focused });
179
179
 
180
180
  render() {
181
- const { id, noPastDates, resettable, intl, reactDates } = this.props;
181
+ const { id, resettable, intl, reactDates, widgetOptions } = this.props;
182
+ const noPastDates =
183
+ this.props.noPastDates || widgetOptions?.pattern_options?.noPastDates;
182
184
  const moment = this.props.moment.default;
183
185
  const datetime = this.getInternalValue();
184
186
  const dateOnly = this.getDateOnly();
@@ -12,11 +12,11 @@ import {
12
12
  addAppURL,
13
13
  isInternalURL,
14
14
  flattenToAppURL,
15
+ URLUtils,
15
16
  } from '@plone/volto/helpers';
16
17
  import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
17
18
  import clearSVG from '@plone/volto/icons/clear.svg';
18
19
  import navTreeSVG from '@plone/volto/icons/nav.svg';
19
- import URLUtils from '@plone/volto/components/manage/AnchorPlugin/utils/URLUtils';
20
20
 
21
21
  /** Widget to edit urls
22
22
  *
@@ -6,16 +6,11 @@
6
6
  import React, { Component } from 'react';
7
7
  import ReactDOMServer from 'react-dom/server';
8
8
  import PropTypes from 'prop-types';
9
- import { Provider } from 'react-redux';
10
- import { connect } from 'react-redux';
9
+ import { connect, Provider } from 'react-redux';
11
10
  import { compose } from 'redux';
12
- import Editor from 'draft-js-plugins-editor';
13
- import { stateFromHTML } from 'draft-js-import-html';
14
- import { convertToRaw, EditorState } from 'draft-js';
15
11
  import redraft from 'redraft';
16
12
  import { Form, Label, TextArea } from 'semantic-ui-react';
17
13
  import { map } from 'lodash';
18
- import createInlineToolbarPlugin from 'draft-js-inline-toolbar-plugin';
19
14
  import { defineMessages, injectIntl } from 'react-intl';
20
15
  import configureStore from 'redux-mock-store';
21
16
  import { MemoryRouter } from 'react-router-dom';
@@ -23,6 +18,11 @@ import config from '@plone/volto/registry';
23
18
 
24
19
  import { FormFieldWrapper } from '@plone/volto/components';
25
20
 
21
+ import loadable from '@loadable/component';
22
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
23
+
24
+ const Editor = loadable(() => import('draft-js-plugins-editor'));
25
+
26
26
  const messages = defineMessages({
27
27
  default: {
28
28
  id: 'Default',
@@ -67,7 +67,7 @@ const messages = defineMessages({
67
67
  * ```
68
68
  *
69
69
  */
70
- class WysiwygWidget extends Component {
70
+ class WysiwygWidgetComponent extends Component {
71
71
  /**
72
72
  * Property types.
73
73
  * @property {Object} propTypes Property types.
@@ -161,11 +161,17 @@ class WysiwygWidget extends Component {
161
161
  constructor(props) {
162
162
  super(props);
163
163
 
164
+ const { stateFromHTML } = props.draftJsImportHtml;
165
+ const { EditorState } = props.draftJs;
166
+ const createInlineToolbarPlugin = props.draftJsInlineToolbarPlugin.default;
167
+
168
+ this.draftConfig = config.settings.richtextEditorSettings(props);
169
+
164
170
  if (!__SERVER__) {
165
171
  let editorState;
166
172
  if (props.value && props.value.data) {
167
173
  const contentState = stateFromHTML(props.value.data, {
168
- customBlockFn: config.settings.FromHTMLCustomBlockFn,
174
+ customBlockFn: this.draftConfig.FromHTMLCustomBlockFn,
169
175
  });
170
176
  editorState = EditorState.createWithContent(contentState);
171
177
  } else {
@@ -173,7 +179,7 @@ class WysiwygWidget extends Component {
173
179
  }
174
180
 
175
181
  const inlineToolbarPlugin = createInlineToolbarPlugin({
176
- structure: config.settings.richTextEditorInlineToolbarButtons,
182
+ structure: this.draftConfig.richTextEditorInlineToolbarButtons,
177
183
  });
178
184
 
179
185
  this.state = { editorState, inlineToolbarPlugin };
@@ -220,7 +226,7 @@ class WysiwygWidget extends Component {
220
226
  * @returns {undefined}
221
227
  */
222
228
  onChange(editorState) {
223
- const { settings } = config;
229
+ const { convertToRaw } = this.props.draftJs;
224
230
  this.setState({ editorState });
225
231
  const mockStore = configureStore();
226
232
 
@@ -240,8 +246,8 @@ class WysiwygWidget extends Component {
240
246
  <MemoryRouter>
241
247
  {redraft(
242
248
  convertToRaw(editorState.getCurrentContent()),
243
- settings.ToHTMLRenderers,
244
- settings.ToHTMLOptions,
249
+ config.settings.richtextViewSettings.ToHTMLRenderers,
250
+ config.settings.richtextViewSettings.ToHTMLOptions,
245
251
  )}
246
252
  </MemoryRouter>
247
253
  </Provider>,
@@ -288,7 +294,6 @@ class WysiwygWidget extends Component {
288
294
  );
289
295
  }
290
296
  const { InlineToolbar } = this.state.inlineToolbarPlugin;
291
- const { settings } = config;
292
297
 
293
298
  return (
294
299
  <FormFieldWrapper {...this.props} className="wysiwyg">
@@ -302,12 +307,12 @@ class WysiwygWidget extends Component {
302
307
  editorState={this.state.editorState}
303
308
  plugins={[
304
309
  this.state.inlineToolbarPlugin,
305
- ...settings.richTextEditorPlugins,
310
+ ...this.draftConfig.richTextEditorPlugins,
306
311
  ]}
307
312
  placeholder={this.props.placeholder}
308
- blockRenderMap={settings.extendedBlockRenderMap}
309
- blockStyleFn={settings.blockStyleFn}
310
- customStyleMap={settings.customStyleMap}
313
+ blockRenderMap={this.draftConfig.extendedBlockRenderMap}
314
+ blockStyleFn={this.draftConfig.blockStyleFn}
315
+ customStyleMap={this.draftConfig.customStyleMap}
311
316
  />
312
317
  {this.props.onChange && <InlineToolbar />}
313
318
  </>
@@ -320,12 +325,33 @@ class WysiwygWidget extends Component {
320
325
  }
321
326
  }
322
327
 
323
- export default compose(
328
+ export const WysiwygWidget = compose(
324
329
  injectIntl,
330
+ injectLazyLibs([
331
+ 'draftJs',
332
+ 'draftJsBlockBreakoutPlugin',
333
+ 'draftJsCreateBlockStyleButton',
334
+ 'draftJsCreateInlineStyleButton',
335
+ 'draftJsFilters',
336
+ 'draftJsImportHtml',
337
+ 'draftJsInlineToolbarPlugin',
338
+ 'draftJsLibIsSoftNewlineEvent',
339
+ 'immutableLib',
340
+ ]),
325
341
  connect(
326
342
  (state, props) => ({
327
343
  token: state.userSession.token,
328
344
  }),
329
345
  {},
330
346
  ),
331
- )(WysiwygWidget);
347
+ )(WysiwygWidgetComponent);
348
+
349
+ const Preloader = (props) => {
350
+ const [loaded, setLoaded] = React.useState(false);
351
+ React.useEffect(() => {
352
+ Editor.load().then(() => setLoaded(true));
353
+ }, []);
354
+ return loaded ? <WysiwygWidget {...props} /> : null;
355
+ };
356
+
357
+ export default Preloader;
@@ -3,12 +3,18 @@ import renderer from 'react-test-renderer';
3
3
  import configureStore from 'redux-mock-store';
4
4
  import { Provider } from 'react-intl-redux';
5
5
 
6
- import WysiwygWidget from './WysiwygWidget';
6
+ import { WysiwygWidget } from './WysiwygWidget';
7
7
 
8
8
  global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
9
9
 
10
10
  const mockStore = configureStore();
11
11
 
12
+ jest.mock('@plone/volto/helpers/Loadable/Loadable');
13
+ beforeAll(
14
+ async () =>
15
+ await require('@plone/volto/helpers/Loadable/Loadable').__setLoadables(),
16
+ );
17
+
12
18
  test('renders a wysiwyg widget component', () => {
13
19
  const store = mockStore({
14
20
  intl: {
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
9
9
  import { Link } from 'react-router-dom';
10
10
  import { Container } from 'semantic-ui-react';
11
- import URLUtils from '@plone/volto/components/manage/AnchorPlugin/utils/URLUtils';
11
+ import { URLUtils } from '@plone/volto/helpers';
12
12
  import { FormattedMessage } from 'react-intl';
13
13
 
14
14
  /**
@@ -7,6 +7,7 @@ import React, { Component } from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { connect } from 'react-redux';
9
9
  import { compose } from 'redux';
10
+ import { Redirect } from 'react-router-dom';
10
11
  import { Portal } from 'react-portal';
11
12
  import { injectIntl } from 'react-intl';
12
13
  import qs from 'query-string';
@@ -21,6 +22,7 @@ import { listActions, getContent } from '@plone/volto/actions';
21
22
  import {
22
23
  BodyClass,
23
24
  getBaseUrl,
25
+ flattenToAppURL,
24
26
  getLayoutFieldname,
25
27
  } from '@plone/volto/helpers';
26
28
 
@@ -194,7 +196,9 @@ class View extends Component {
194
196
  */
195
197
  render() {
196
198
  const { views } = config;
197
- if (this.props.error && !this.props.connectionRefused) {
199
+ if (this.props.error && this.props.error.code === 301) {
200
+ return <Redirect to={flattenToAppURL(this.props.error.url)} />;
201
+ } else if (this.props.error && !this.props.connectionRefused) {
198
202
  let FoundView;
199
203
  if (this.props.error.status === undefined) {
200
204
  // For some reason, while development and if CORS is in place and the
@@ -56,6 +56,11 @@ import TopSideFacets from '@plone/volto/components/manage/Blocks/Search/layout/T
56
56
  import {
57
57
  SelectFacet,
58
58
  CheckboxFacet,
59
+ DateRangeFacet,
60
+ ToggleFacet,
61
+ ToggleFacetFilterListEntry,
62
+ SelectFacetFilterListEntry,
63
+ DateRangeFacetFilterListEntry,
59
64
  } from '@plone/volto/components/manage/Blocks/Search/components';
60
65
  import getListingBlockAsyncData from '@plone/volto/components/manage/Blocks/Listing/getAsyncData';
61
66
 
@@ -438,12 +443,38 @@ const blocksConfig = {
438
443
  title: 'Select',
439
444
  view: SelectFacet,
440
445
  isDefault: true,
446
+ schemaEnhancer: SelectFacet.schemaEnhancer,
447
+ stateToValue: SelectFacet.stateToValue,
448
+ valueToQuery: SelectFacet.valueToQuery,
449
+ filterListComponent: SelectFacetFilterListEntry,
441
450
  },
442
451
  {
443
452
  id: 'checkboxFacet',
444
453
  title: 'Checkbox',
445
454
  view: CheckboxFacet,
446
455
  isDefault: false,
456
+ schemaEnhancer: CheckboxFacet.schemaEnhancer,
457
+ stateToValue: CheckboxFacet.stateToValue,
458
+ valueToQuery: CheckboxFacet.valueToQuery,
459
+ filterListComponent: SelectFacetFilterListEntry,
460
+ },
461
+ {
462
+ id: 'daterangeFacet',
463
+ title: 'Date range',
464
+ view: DateRangeFacet,
465
+ isDefault: false,
466
+ stateToValue: DateRangeFacet.stateToValue,
467
+ valueToQuery: DateRangeFacet.valueToQuery,
468
+ filterListComponent: DateRangeFacetFilterListEntry,
469
+ },
470
+ {
471
+ id: 'toggleFacet',
472
+ title: 'Toggle',
473
+ view: ToggleFacet,
474
+ isDefault: false,
475
+ stateToValue: ToggleFacet.stateToValue,
476
+ valueToQuery: ToggleFacet.valueToQuery,
477
+ filterListComponent: ToggleFacetFilterListEntry,
447
478
  },
448
479
  ],
449
480
  },
@@ -32,4 +32,26 @@ export const loadables = {
32
32
  reactDnd: loadable.lib(() => import('react-dnd')),
33
33
  reactDndHtml5Backend: loadable.lib(() => import('react-dnd-html5-backend')),
34
34
  reactBeautifulDnd: loadable.lib(() => import('react-beautiful-dnd')),
35
+
36
+ // draftjs libs
37
+ immutableLib: loadable.lib(() => import('immutable')),
38
+ draftJs: loadable.lib(() => import('draft-js')),
39
+ draftJsLibIsSoftNewlineEvent: loadable.lib(() =>
40
+ import('draft-js/lib/isSoftNewlineEvent'),
41
+ ),
42
+ draftJsFilters: loadable.lib(() => import('draftjs-filters')),
43
+ draftJsInlineToolbarPlugin: loadable.lib(() =>
44
+ import('draft-js-inline-toolbar-plugin'),
45
+ ),
46
+ draftJsImportHtml: loadable.lib(() => import('draft-js-import-html')),
47
+ draftJsBlockBreakoutPlugin: loadable.lib(() =>
48
+ import('draft-js-block-breakout-plugin'),
49
+ ),
50
+ draftJsCreateInlineStyleButton: loadable.lib(() =>
51
+ import('draft-js-buttons/lib/utils/createInlineStyleButton'),
52
+ ),
53
+ draftJsCreateBlockStyleButton: loadable.lib(() =>
54
+ import('draft-js-buttons/lib/utils/createBlockStyleButton'),
55
+ ),
56
+ draftJsPluginsUtils: loadable.lib(() => import('draft-js-plugins-utils')),
35
57
  };