@plone/volto 15.0.0-alpha.1 → 15.0.0-alpha.5

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 (68) hide show
  1. package/.github/workflows/{core-sandbox.yml → coresandbox.yml} +1 -1
  2. package/.storybook/main.js +3 -9
  3. package/CHANGELOG.md +55 -0
  4. package/README.md +1 -0
  5. package/addon-registry.js +16 -11
  6. package/docker-compose.yml +15 -10
  7. package/locales/volto.pot +1 -1
  8. package/package.json +9 -9
  9. package/pyvenv.cfg +3 -0
  10. package/razzle.config.js +13 -13
  11. package/src/actions/language/language.js +7 -2
  12. package/src/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm.jsx +1 -2
  13. package/src/components/manage/AnchorPlugin/components/LinkButton/index.jsx +15 -6
  14. package/src/components/manage/AnchorPlugin/index.jsx +12 -5
  15. package/src/components/manage/AnchorPlugin/utils/EditorUtils.js +8 -7
  16. package/src/components/manage/Blocks/Description/Edit.jsx +33 -19
  17. package/src/components/manage/Blocks/Description/Edit.test.jsx +6 -0
  18. package/src/components/manage/Blocks/HeroImageLeft/Edit.jsx +37 -26
  19. package/src/components/manage/Blocks/HeroImageLeft/Edit.test.jsx +6 -0
  20. package/src/components/manage/Blocks/Listing/View.jsx +1 -1
  21. package/src/components/manage/Blocks/Table/Cell.jsx +40 -14
  22. package/src/components/manage/Blocks/Table/Cell.test.jsx +7 -1
  23. package/src/components/manage/Blocks/Table/Edit.jsx +7 -3
  24. package/src/components/manage/Blocks/Table/Edit.test.jsx +6 -0
  25. package/src/components/manage/Blocks/Table/View.jsx +2 -2
  26. package/src/components/manage/Blocks/Text/Edit.jsx +56 -14
  27. package/src/components/manage/Blocks/Text/Edit.test.jsx +7 -1
  28. package/src/components/manage/Blocks/Text/View.jsx +2 -2
  29. package/src/components/manage/Blocks/Title/Edit.jsx +25 -13
  30. package/src/components/manage/Blocks/Title/Edit.test.jsx +6 -0
  31. package/src/components/manage/Contents/ContentsUploadModal.jsx +3 -1
  32. package/src/components/manage/Sidebar/Sidebar.jsx +5 -1
  33. package/src/components/manage/Toolbar/Toolbar.jsx +3 -1
  34. package/src/components/manage/UniversalLink/UniversalLink.jsx +5 -2
  35. package/src/components/manage/Widgets/UrlWidget.jsx +1 -1
  36. package/src/components/manage/Widgets/WysiwygWidget.jsx +45 -19
  37. package/src/components/manage/Widgets/WysiwygWidget.test.jsx +7 -1
  38. package/src/components/theme/ContactForm/ContactForm.jsx +1 -1
  39. package/src/components/theme/LanguageSelector/LanguageSelector.js +2 -18
  40. package/src/components/theme/Login/Login.jsx +3 -1
  41. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +17 -2
  42. package/src/components/theme/View/LinkView.jsx +3 -3
  43. package/src/config/Loadables.jsx +22 -0
  44. package/src/config/RichTextEditor/Blocks.jsx +25 -20
  45. package/src/config/RichTextEditor/Plugins.jsx +38 -31
  46. package/src/config/RichTextEditor/Styles.jsx +48 -44
  47. package/src/config/RichTextEditor/index.js +25 -0
  48. package/src/config/index.js +14 -18
  49. package/src/helpers/Url/Url.js +32 -1
  50. package/src/helpers/Url/urlRegex.js +7 -1
  51. package/src/helpers/index.js +1 -0
  52. package/src/middleware/api.js +1 -1
  53. package/test-setup-config.js +22 -7
  54. package/{webpack-bundle-analyze-plugin.js → webpack-plugins/webpack-bundle-analyze-plugin.js} +0 -0
  55. package/{webpack-less-plugin.js → webpack-plugins/webpack-less-plugin.js} +0 -0
  56. package/{webpack-relative-resolver.js → webpack-plugins/webpack-relative-resolver.js} +0 -0
  57. package/{webpack-root-resolver.js → webpack-plugins/webpack-root-resolver.js} +0 -0
  58. package/{webpack-sentry-plugin.js → webpack-plugins/webpack-sentry-plugin.js} +0 -0
  59. package/{webpack-svg-plugin.js → webpack-plugins/webpack-svg-plugin.js} +0 -0
  60. package/.surgeignore +0 -2
  61. package/Dockerfile.slim +0 -27
  62. package/patches/fixprettier.patch +0 -11
  63. package/patches/fixstylelint.patch +0 -11
  64. package/src/components/manage/AnchorPlugin/utils/URLUtils.js +0 -36
  65. package/src/components/manage/AnchorPlugin/utils/mailRegex.js +0 -2
  66. package/src/components/manage/AnchorPlugin/utils/telRegex.js +0 -1
  67. package/src/components/manage/AnchorPlugin/utils/urlRegex.js +0 -54
  68. package/styleguide.config.js +0 -42
@@ -59,7 +59,7 @@ jobs:
59
59
  # CI: true
60
60
 
61
61
  - name: Cypress Core Sandbox Acceptance Tests
62
- run: yarn ci:cypress:run:core-sandbox
62
+ run: yarn ci:cypress:run:coresandbox
63
63
 
64
64
  # Upload Cypress screenshots
65
65
  - uses: actions/upload-artifact@v1
@@ -5,7 +5,7 @@ const fileLoaderFinder = makeLoaderFinder('file-loader');
5
5
 
6
6
  const projectRootPath = path.resolve('.');
7
7
  const createAddonsLoader = require('../create-addons-loader');
8
- const lessPlugin = require('../webpack-less-plugin');
8
+ const lessPlugin = require('../webpack-plugins/webpack-less-plugin');
9
9
 
10
10
  const createConfig = require('../node_modules/razzle/config/createConfigAsync.js');
11
11
  const razzleConfig = require(path.join(projectRootPath, 'razzle.config.js'));
@@ -31,14 +31,8 @@ const SVGLOADER = {
31
31
  };
32
32
 
33
33
  module.exports = {
34
- stories: [
35
- '../src/**/*.stories.mdx',
36
- '../src/**/*.stories.@(js|jsx|ts|tsx)'
37
- ],
38
- addons: [
39
- '@storybook/addon-links',
40
- '@storybook/addon-essentials',
41
- ],
34
+ stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
35
+ addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
42
36
  webpackFinal: async (config, { configType }) => {
43
37
  // `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
44
38
  // You can change the configuration based on that.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # Change Log
2
2
 
3
+ ## 15.0.0-alpha.5 (2022-02-16)
4
+
5
+ ### Breaking
6
+
7
+ - Lazyload draftjs library. See the upgrade guide on how that impacts you, in case you have extended the rich text editor configuration @tiberiuichim @kreafox
8
+ See https://docs.voltocms.com/upgrade-guide/ for more information.
9
+
10
+ ### Feature
11
+
12
+ - Add `cookiesExpire` value to config to control the cookie expiration @giuliaghisini
13
+
14
+ ## 15.0.0-alpha.4 (2022-02-16)
15
+
16
+ ### Breaking
17
+
18
+ - Markup change in `LinkView` component.
19
+ - Rename `core-sandbox` to `coresandbox` for sake of consistency @sneridagh
20
+ - Extend the original intent and rename `RAZZLE_TESTING_ADDONS` to `ADDONS`. @sneridagh
21
+ See https://docs.voltocms.com/upgrade-guide/ for more information.
22
+
23
+ ### Internal
24
+
25
+ - House cleanup, remove some unused files in the root @sneridagh
26
+ - Move Webpack related files to `webpack-plugins` folder @sneridagh
27
+ - Remove unused Dockerfiles @sneridagh
28
+ - Update Docker compose to latest images and best practices @sneridagh
29
+
30
+ ## 15.0.0-alpha.3 (2022-02-11)
31
+
32
+ ### Bugfix
33
+
34
+ - Fix the upload image in contents view @iFlameing
35
+ - add "view" id to contact-form container for main content skiplink @ThomasKindermann
36
+ - Fix loading indicator positioning on Login form submit @sneridagh
37
+
38
+ ### Internal
39
+
40
+ - Add new RawMaterial Volto websites in production @nzambello
41
+
42
+ ## 15.0.0-alpha.2 (2022-02-10)
43
+
44
+ ### Breaking
45
+
46
+ - Language Switcher no longer takes care of the change of the language on the Redux Store. This responsability has been unified in the `MultilingualRedirector` @sneridagh
47
+
48
+ ### Bugfix
49
+
50
+ - Prevent the MultilingualRedirector to force 4 content load when switching the language @reebalazs
51
+
52
+ ### Documentation
53
+
54
+ - Upgrade Guide i18n: Make clear what's project, what add-on. @ksuess
55
+
3
56
  ## 15.0.0-alpha.1 (2022-02-09)
4
57
 
5
58
  ### Bugfix
@@ -421,6 +474,8 @@ See https://docs.voltocms.com/upgrade-guide/ for more information about all the
421
474
  - Update to plone.restapi 8.16.2 (revert missing_value PR) @sneridagh
422
475
  - Update all requirements and the reasoning behind them in builds @sneridagh
423
476
  - Update Plone version in api backend to 5.2.6. Update README and cleanup @fredvd
477
+ - Various local development build improvements @rpatterson
478
+ - Document CI changelog verifier failure details that mislead contributors
424
479
  - Document CI changelog verifier failure details that mislead contributors @rpatterson
425
480
  - Updated italian translation @pnicolli
426
481
 
package/README.md CHANGED
@@ -161,6 +161,7 @@ Volto is actively developed since 2017 and used in production since 2018 on the
161
161
  - [EEA-IMSv4](https://www.eea.europa.eu/ims) (EEA Indicator Management System v4. Developed by [Eau de web](https://eaudeweb.ro) for the European Environmental Agency, 2021)
162
162
  - [Memori](https://memori.ai/en) (Corporate website for Memori, startup specialising in technologies applied to the experience of memory through the development of Artificial Intelligences. Developed by [RawMaterial](https://rawmaterial.it/en), 2021)
163
163
  - [TwinCreator](https://twincreator.com/en) (TwinCreator allows you to design and train multiple AI’s through simple conversation through NLP. Developed by [RawMaterial](https://rawmaterial.it/en), 2021)
164
+ - [MemoryTwin](https://memorytwin.com/en) (Product website, MemoryTwin allows you to create your personal artificial intelligence, able to remember and speak. Developed by [RawMaterial](https://rawmaterial.it/en), 2022)
164
165
 
165
166
  Please create a new [issue](https://github.com/plone/volto/issues/new) or [pull request](https://github.com/plone/volto/pulls) to add your Volto-site here!
166
167
 
package/addon-registry.js CHANGED
@@ -124,7 +124,7 @@ class AddonConfigurationRegistry {
124
124
 
125
125
  this.initDevelopmentPackages();
126
126
  this.initPublishedPackages();
127
- this.initTestingPackages();
127
+ this.initAddonsFromEnvVar();
128
128
 
129
129
  this.dependencyGraph = buildDependencyGraph(
130
130
  this.resultantMergedAddons,
@@ -203,15 +203,16 @@ class AddonConfigurationRegistry {
203
203
  }
204
204
  }
205
205
 
206
- initTestingPackages() {
207
- if (process.env.RAZZLE_TESTING_ADDONS) {
208
- process.env.RAZZLE_TESTING_ADDONS.split(',').forEach(
209
- this.initTestingPackage.bind(this),
206
+ initAddonsFromEnvVar() {
207
+ if (process.env.ADDONS) {
208
+ process.env.ADDONS.split(',').forEach(
209
+ this.initAddonFromEnvVar.bind(this),
210
210
  );
211
211
  }
212
212
  }
213
213
 
214
- initTestingPackage(name) {
214
+ initAddonFromEnvVar(name) {
215
+ // First lookup in the packages folder, local to the root (either vanilla Volto or project)
215
216
  const normalizedAddonName = name.split(':')[0];
216
217
  const testingPackagePath = `${this.projectRootPath}/packages/${normalizedAddonName}/src`;
217
218
  if (fs.existsSync(testingPackagePath)) {
@@ -233,6 +234,10 @@ class AddonConfigurationRegistry {
233
234
  this.packages[normalizedAddonName] || {},
234
235
  pkg,
235
236
  );
237
+ } else {
238
+ // Fallback in case the addon is released (not in packages folder nor in development, but in node_modules)
239
+ const normalizedAddonName = name.split(':')[0];
240
+ this.initPublishedPackage(normalizedAddonName);
236
241
  }
237
242
  }
238
243
 
@@ -385,14 +390,14 @@ class AddonConfigurationRegistry {
385
390
  }
386
391
 
387
392
  /**
388
- * Allow testing packages addons to customize Volto and other addons.
393
+ * Allow packages from addons set in env vars to customize Volto and other addons.
389
394
  *
390
- * Same as the above one, but specific for Volto testing addons
395
+ * Same as the above one, but specific for Volto addons coming from env vars
391
396
  */
392
- getTestingAddonCustomizationPaths() {
397
+ getAddonsFromEnvVarCustomizationPaths() {
393
398
  let aliases = {};
394
- if (process.env.RAZZLE_TESTING_ADDONS) {
395
- process.env.RAZZLE_TESTING_ADDONS.split(',').forEach((addon) => {
399
+ if (process.env.ADDONS) {
400
+ process.env.ADDONS.split(',').forEach((addon) => {
396
401
  const normalizedAddonName = addon.split(':')[0];
397
402
  const testingPackagePath = `${this.projectRootPath}/packages/${normalizedAddonName}/src`;
398
403
  if (fs.existsSync(testingPackagePath)) {
@@ -1,22 +1,27 @@
1
1
  version: '3.3'
2
2
  services:
3
3
 
4
- plone:
4
+ backend:
5
+ image: plone/plone-backend:6.0.0a3
6
+ # Plone 5.2 series can be used too
7
+ # image: plone/plone-backend:5.2.7
5
8
  ports:
6
9
  - '8080:8080'
7
10
  environment:
8
11
  - SITE=Plone
9
- - ADDONS=plone.volto
12
+ - 'ADDONS=plone.restapi==8.21.0 plone.volto==4.0.0a3 plone.rest==2.0.0a2 plone.app.iterate==4.0.2 plone.app.vocabularies==4.3.0'
10
13
  - 'PROFILES=plone.volto:default-homepage'
11
- image: plone
12
14
 
13
15
  frontend:
16
+ image: 'plone/plone-frontend:latest'
14
17
  ports:
15
18
  - '3000:3000'
16
- image: 'plone/volto:slim'
17
- # Use just 'plone/volto' image and set the env var in case you want to
18
- # use any released Volto addons
19
- # image: 'plone/volto'
20
- # environment:
21
- # - INTERNAL_API_PATH=plone:8080/Plone
22
- # - ADDONS="volto-slate:asDefault"
19
+ restart: always
20
+ environment:
21
+ # These are needed in a Docker environment since the
22
+ # routing needs to be amended. You can point to the
23
+ # internal network alias.
24
+ RAZZLE_INTERNAL_API_PATH: http://backend:8080/Plone
25
+ RAZZLE_DEV_PROXY_API_PATH: http://backend:8080/Plone
26
+ depends_on:
27
+ - backend
package/locales/volto.pot CHANGED
@@ -1,7 +1,7 @@
1
1
  msgid ""
2
2
  msgstr ""
3
3
  "Project-Id-Version: Plone\n"
4
- "POT-Creation-Date: 2022-02-07T09:39:49.063Z\n"
4
+ "POT-Creation-Date: 2022-02-11T10:44:54.533Z\n"
5
5
  "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
6
  "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
7
  "MIME-Version: 1.0\n"
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "15.0.0-alpha.1",
12
+ "version": "15.0.0-alpha.5",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -52,12 +52,12 @@
52
52
  "patches": "/bin/bash patches/patchit.sh > /dev/null 2>&1 ||true",
53
53
  "deduplicate": "yarn-deduplicate yarn.lock",
54
54
  "cypress:open": "NODE_ENV=production CYPRESS_API=plone cypress open",
55
- "cypress:open:core-sandbox": "NODE_ENV=production CYPRESS_API=plone cypress open --config integrationFolder='cypress/tests/core-sandbox'",
55
+ "cypress:open:coresandbox": "NODE_ENV=production CYPRESS_API=plone cypress open --config integrationFolder='cypress/tests/coresandbox'",
56
56
  "cypress:open:multilingual": "NODE_ENV=production CYPRESS_API=plone cypress open --config integrationFolder='cypress/tests/multilingual'",
57
57
  "cypress:open:workingCopy": "NODE_ENV=production CYPRESS_API=plone cypress open --config integrationFolder='cypress/tests/workingCopy'",
58
58
  "cypress:open:guillotina": "NODE_ENV=production CYPRESS_API=guillotina cypress open --config-file cypress/cypress.guillotina.json",
59
59
  "cypress:run": "NODE_ENV=production CYPRESS_API=plone CYPRESS_RETRIES=2 cypress run",
60
- "cypress:run:core-sandbox": "NODE_ENV=production CYPRESS_API=plone cypress run --config integrationFolder='cypress/tests/core-sandbox'",
60
+ "cypress:run:coresandbox": "NODE_ENV=production CYPRESS_API=plone cypress run --config integrationFolder='cypress/tests/coresandbox'",
61
61
  "cypress:run:multilingual": "NODE_ENV=production CYPRESS_API=plone cypress run --config integrationFolder='cypress/tests/multilingual'",
62
62
  "cypress:run:workingCopy": "NODE_ENV=production CYPRESS_API=plone cypress run --config integrationFolder='cypress/tests/workingCopy'",
63
63
  "cypress:run:guillotina": "NODE_ENV=production CYPRESS_API=guillotina cypress run --config integrationFolder='cypress/tests/guillotina'",
@@ -65,19 +65,19 @@
65
65
  "cy:test:fixture:setup": "node cypress/support/reset-fixture.js",
66
66
  "cy:test:fixture:teardown": "node cypress/support/reset-fixture.js teardown",
67
67
  "ci:start-api-plone": "make test-acceptance-server",
68
- "ci:start-api-plone-core-sandbox": "make test-acceptance-server-coresandbox",
68
+ "ci:start-api-plone-coresandbox": "make test-acceptance-server-coresandbox",
69
69
  "ci:start-api-plone-multilingual": "make test-acceptance-server-multilingual",
70
70
  "ci:start-api-plone-workingCopy": "make test-acceptance-server-workingcopy",
71
71
  "ci:start-api-guillotina": "make test-acceptance-guillotina",
72
72
  "ci:start-frontend": "RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run",
73
- "ci:start-frontend-core-sandbox": "RAZZLE_TESTING_ADDONS=core-sandbox RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run:core-sandbox",
74
- "ci:start-frontend-multilingual": "RAZZLE_TESTING_ADDONS=core-sandbox:multilingualFixture RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run:multilingual",
75
- "ci:start-frontend-workingCopy": "RAZZLE_TESTING_ADDONS=core-sandbox:workingCopyFixture RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run:workingCopy",
73
+ "ci:start-frontend-coresandbox": "ADDONS=coresandbox RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run:coresandbox",
74
+ "ci:start-frontend-multilingual": "ADDONS=coresandbox:multilingualFixture RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run:multilingual",
75
+ "ci:start-frontend-workingCopy": "ADDONS=coresandbox:workingCopyFixture RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 cypress:run:workingCopy",
76
76
  "ci:start-project-frontend": "cd my-volto-app && RAZZLE_API_PATH=http://localhost:55001/plone yarn build && start-test start:prod http://localhost:3000 'cd .. && yarn cypress:run'",
77
- "ci:start-frontend-guillotina": "RAZZLE_TESTING_ADDONS=volto-guillotina RAZZLE_API_PATH=http://localhost:8081/db/web RAZZLE_LEGACY_TRAVERSE=true yarn build && start-test start:prod http://localhost:3000 cypress:run:guillotina",
77
+ "ci:start-frontend-guillotina": "ADDONS=volto-guillotina RAZZLE_API_PATH=http://localhost:8081/db/web RAZZLE_LEGACY_TRAVERSE=true yarn build && start-test start:prod http://localhost:3000 cypress:run:guillotina",
78
78
  "ci:cypress:run": "start-test ci:start-api-plone http-get://localhost:55001/plone ci:start-frontend",
79
79
  "ci:cypress:project:run": "start-test ci:start-api-plone http-get://localhost:55001/plone ci:start-project-frontend",
80
- "ci:cypress:run:core-sandbox": "start-test ci:start-api-plone-core-sandbox http-get://localhost:55001/plone ci:start-frontend-core-sandbox",
80
+ "ci:cypress:run:coresandbox": "start-test ci:start-api-plone-coresandbox http-get://localhost:55001/plone ci:start-frontend-coresandbox",
81
81
  "ci:cypress:run:multilingual": "start-test ci:start-api-plone-multilingual http-get://localhost:55001/plone ci:start-frontend-multilingual",
82
82
  "ci:cypress:run:workingCopy": "start-test ci:start-api-plone-workingCopy http-get://localhost:55001/plone ci:start-frontend-workingCopy",
83
83
  "ci:cypress:run:guillotina": "start-test ci:start-api-guillotina http-get://localhost:8081 ci:start-frontend-guillotina",
package/pyvenv.cfg ADDED
@@ -0,0 +1,3 @@
1
+ home = /opt/homebrew/Cellar/python@3.8/3.8.12_1/bin
2
+ include-system-site-packages = false
3
+ version = 3.8.12
package/razzle.config.js CHANGED
@@ -5,8 +5,8 @@ const nodeExternals = require('webpack-node-externals');
5
5
  const LoadablePlugin = require('@loadable/webpack-plugin');
6
6
  const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
7
7
  const fs = require('fs');
8
- const RootResolverPlugin = require('./webpack-root-resolver');
9
- const RelativeResolverPlugin = require('./webpack-relative-resolver');
8
+ const RootResolverPlugin = require('./webpack-plugins/webpack-root-resolver');
9
+ const RelativeResolverPlugin = require('./webpack-plugins/webpack-relative-resolver');
10
10
  const createAddonsLoader = require('./create-addons-loader');
11
11
  const AddonConfigurationRegistry = require('./addon-registry');
12
12
  const CircularDependencyPlugin = require('circular-dependency-plugin');
@@ -181,13 +181,13 @@ const defaultModify = ({
181
181
  // Disabling the ESlint pre loader
182
182
  config.module.rules.splice(0, 1);
183
183
 
184
- let testingAddons = [];
185
- if (process.env.RAZZLE_TESTING_ADDONS) {
186
- testingAddons = process.env.RAZZLE_TESTING_ADDONS.split(',');
184
+ let addonsFromEnvVar = [];
185
+ if (process.env.ADDONS) {
186
+ addonsFromEnvVar = process.env.ADDONS.split(',');
187
187
  }
188
188
 
189
189
  const addonsLoaderPath = createAddonsLoader(
190
- [...registry.getAddonDependencies(), ...testingAddons],
190
+ [...registry.getAddonDependencies(), ...addonsFromEnvVar],
191
191
  registry.packages,
192
192
  );
193
193
 
@@ -197,8 +197,8 @@ const defaultModify = ({
197
197
  ];
198
198
 
199
199
  config.resolve.alias = {
200
- ...registry.getTestingAddonCustomizationPaths(),
201
200
  ...registry.getAddonCustomizationPaths(),
201
+ ...registry.getAddonsFromEnvVarCustomizationPaths(),
202
202
  ...registry.getProjectCustomizationPaths(),
203
203
  ...config.resolve.alias,
204
204
  '../../theme.config$': `${projectRootPath}/theme/theme.config`,
@@ -237,8 +237,8 @@ const defaultModify = ({
237
237
  addonsAsExternals = registry.addonNames.map((addon) => new RegExp(addon));
238
238
  }
239
239
 
240
- if (process.env.RAZZLE_TESTING_ADDONS) {
241
- testingAddons.forEach((addon) => {
240
+ if (process.env.ADDONS) {
241
+ addonsFromEnvVar.forEach((addon) => {
242
242
  const normalizedAddonName = addon.split(':')[0];
243
243
  const p = fs.realpathSync(
244
244
  registry.packages[normalizedAddonName].modulePath,
@@ -275,10 +275,10 @@ const defaultModify = ({
275
275
  const addonExtenders = registry.getAddonExtenders().map((m) => require(m));
276
276
 
277
277
  const defaultPlugins = [
278
- { object: require('./webpack-less-plugin')({ registry }) },
279
- { object: require('./webpack-sentry-plugin') },
280
- { object: require('./webpack-svg-plugin') },
281
- { object: require('./webpack-bundle-analyze-plugin') },
278
+ { object: require('./webpack-plugins/webpack-less-plugin')({ registry }) },
279
+ { object: require('./webpack-plugins/webpack-sentry-plugin') },
280
+ { object: require('./webpack-plugins/webpack-svg-plugin') },
281
+ { object: require('./webpack-plugins/webpack-bundle-analyze-plugin') },
282
282
  { object: require('./jest-extender-plugin') },
283
283
  ];
284
284
 
@@ -1,16 +1,21 @@
1
1
  import { updateIntl } from 'react-intl-redux';
2
2
  import { normalizeLanguageName } from '@plone/volto/helpers';
3
3
  import Cookies from 'universal-cookie';
4
+ import config from '@plone/volto/registry';
4
5
 
5
6
  export function changeLanguageCookies(language) {
6
7
  const cookies = new Cookies();
7
8
 
8
9
  cookies.set('lang', normalizeLanguageName(language), {
9
- expires: new Date((2 ** 31 - 1) * 1000),
10
+ expires: new Date(
11
+ new Date().getTime() + config.settings.cookieExpires * 1000,
12
+ ),
10
13
  path: '/',
11
14
  });
12
15
  cookies.set('I18N_LANGUAGE', normalizeLanguageName(language) || '', {
13
- expires: new Date((2 ** 31 - 1) * 1000),
16
+ expires: new Date(
17
+ new Date().getTime() + config.settings.cookieExpires * 1000,
18
+ ),
14
19
  path: '/',
15
20
  });
16
21
  }
@@ -13,14 +13,13 @@ import {
13
13
  addAppURL,
14
14
  isInternalURL,
15
15
  flattenToAppURL,
16
+ URLUtils,
16
17
  } from '@plone/volto/helpers';
17
18
 
18
19
  import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
19
20
  import { Input, Form, Button } from 'semantic-ui-react';
20
21
  import { defineMessages, injectIntl } from 'react-intl';
21
22
 
22
- import URLUtils from '@plone/volto/components/manage/AnchorPlugin/utils/URLUtils';
23
-
24
23
  import clearSVG from '@plone/volto/icons/clear.svg';
25
24
  import navTreeSVG from '@plone/volto/icons/nav.svg';
26
25
  import aheadSVG from '@plone/volto/icons/ahead.svg';
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import EditorUtils from '../../utils/EditorUtils';
5
- import DraftEditorUtils from 'draft-js-plugins-utils';
5
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
6
6
  import AddLinkForm from '@plone/volto/components/manage/AnchorPlugin/components/LinkButton/AddLinkForm';
7
7
  import Icon from '@plone/volto/components/theme/Icon/Icon';
8
8
 
@@ -26,6 +26,13 @@ class LinkButton extends Component {
26
26
  onOverrideContent: PropTypes.func.isRequired,
27
27
  };
28
28
 
29
+ constructor(props) {
30
+ super(props);
31
+
32
+ this.DraftEditorUtils = props.draftJsPluginsUtils.default;
33
+ this.EditorUtils = EditorUtils(props);
34
+ }
35
+
29
36
  static defaultProps = {
30
37
  placeholder: '',
31
38
  };
@@ -38,7 +45,7 @@ class LinkButton extends Component {
38
45
  e.preventDefault();
39
46
  e.stopPropagation();
40
47
  const { ownTheme, placeholder, onOverrideContent } = this.props;
41
- const link = EditorUtils.getCurrentEntity(
48
+ const link = this.EditorUtils.getCurrentEntity(
42
49
  this.props.getEditorState(),
43
50
  )?.getData()?.url;
44
51
 
@@ -52,12 +59,14 @@ class LinkButton extends Component {
52
59
  onChangeBlock={() => {}}
53
60
  onClear={() => {
54
61
  this.props.setEditorState(
55
- DraftEditorUtils.removeLinkAtSelection(this.props.getEditorState()),
62
+ this.DraftEditorUtils.removeLinkAtSelection(
63
+ this.props.getEditorState(),
64
+ ),
56
65
  );
57
66
  }}
58
67
  onChangeValue={(url) => {
59
68
  this.props.setEditorState(
60
- DraftEditorUtils.createLinkAtSelection(
69
+ this.DraftEditorUtils.createLinkAtSelection(
61
70
  this.props.getEditorState(),
62
71
  url,
63
72
  ),
@@ -75,7 +84,7 @@ class LinkButton extends Component {
75
84
  */
76
85
  render() {
77
86
  const { theme } = this.props;
78
- const hasLinkSelected = EditorUtils.hasEntity(
87
+ const hasLinkSelected = this.EditorUtils.hasEntity(
79
88
  this.props.getEditorState(),
80
89
  'LINK',
81
90
  );
@@ -114,4 +123,4 @@ class LinkButton extends Component {
114
123
  }
115
124
  }
116
125
 
117
- export default LinkButton;
126
+ export default injectLazyLibs(['draftJs', 'draftJsPluginsUtils'])(LinkButton);
@@ -1,11 +1,10 @@
1
1
  import decorateComponentWithProps from 'decorate-component-with-props';
2
- import { EditorState, Modifier } from 'draft-js';
3
2
 
4
3
  import DefaultLink from './components/Link';
5
4
  import LinkButton from './components/LinkButton';
6
5
  import linkStrategy, { matchesEntityType } from './linkStrategy';
7
6
 
8
- function removeEntity(editorState) {
7
+ function unboundRemoveEntity(editorState) {
9
8
  const contentState = editorState.getCurrentContent();
10
9
  const selectionState = editorState.getSelection();
11
10
  const startKey = selectionState.getStartKey();
@@ -30,13 +29,13 @@ function removeEntity(editorState) {
30
29
  },
31
30
  );
32
31
 
33
- const newContentState = Modifier.applyEntity(
32
+ const newContentState = this.Modifier.applyEntity(
34
33
  contentState,
35
34
  entitySelection,
36
35
  null,
37
36
  );
38
37
 
39
- const newEditorState = EditorState.push(
38
+ const newEditorState = this.EditorState.push(
40
39
  editorState,
41
40
  newContentState,
42
41
  'apply-entity',
@@ -49,7 +48,15 @@ export default (config = {}) => {
49
48
  // ToDo: Get rif of the remainings of having the original CSS modules
50
49
  const defaultTheme = {};
51
50
 
52
- const { theme = defaultTheme, placeholder, Link, linkTarget } = config;
51
+ const {
52
+ theme = defaultTheme,
53
+ placeholder,
54
+ Link,
55
+ linkTarget,
56
+ libraries,
57
+ } = config;
58
+
59
+ const removeEntity = unboundRemoveEntity.bind(libraries);
53
60
 
54
61
  return {
55
62
  decorators: [
@@ -1,22 +1,23 @@
1
- import { RichUtils, EditorState } from 'draft-js';
2
-
3
- export default {
1
+ export default ({ draftJs }) => ({
4
2
  createLinkAtSelection(editorState, url) {
5
3
  const contentState = editorState
6
4
  .getCurrentContent()
7
5
  .createEntity('LINK', 'MUTABLE', { url });
8
6
  const entityKey = contentState.getLastCreatedEntityKey();
9
- const withLink = RichUtils.toggleLink(
7
+ const withLink = draftJs.RichUtils.toggleLink(
10
8
  editorState,
11
9
  editorState.getSelection(),
12
10
  entityKey,
13
11
  );
14
- return EditorState.forceSelection(withLink, editorState.getSelection());
12
+ return draftJs.EditorState.forceSelection(
13
+ withLink,
14
+ editorState.getSelection(),
15
+ );
15
16
  },
16
17
 
17
18
  removeLinkAtSelection(editorState) {
18
19
  const selection = editorState.getSelection();
19
- return RichUtils.toggleLink(editorState, selection, null);
20
+ return draftJs.RichUtils.toggleLink(editorState, selection, null);
20
21
  },
21
22
 
22
23
  getCurrentEntityKey(editorState) {
@@ -41,4 +42,4 @@ export default {
41
42
  const entity = this.getCurrentEntity(editorState);
42
43
  return entity && entity.getType() === entityType;
43
44
  },
44
- };
45
+ });
@@ -4,13 +4,12 @@
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';
13
11
  import cx from 'classnames';
12
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
14
13
  import config from '@plone/volto/registry';
15
14
 
16
15
  const messages = defineMessages({
@@ -20,14 +19,6 @@ const messages = defineMessages({
20
19
  },
21
20
  });
22
21
 
23
- const blockRenderMap = Map({
24
- unstyled: {
25
- element: 'div',
26
- },
27
- });
28
-
29
- const extendedBlockRenderMap = DefaultDraftBlockRenderMap.merge(blockRenderMap);
30
-
31
22
  /**
32
23
  * Edit description block class.
33
24
  * @class Edit
@@ -72,12 +63,29 @@ class Edit extends Component {
72
63
  super(props);
73
64
 
74
65
  if (!__SERVER__) {
66
+ const { Editor, EditorState, DefaultDraftBlockRenderMap } = props.draftJs;
67
+ const { Map } = props.immutableLib;
68
+
69
+ this.Editor = Editor;
70
+ this.EditorState = EditorState;
71
+ this.stateFromHTML = props.draftJsImportHtml.stateFromHTML;
72
+
73
+ const blockRenderMap = Map({
74
+ unstyled: {
75
+ element: 'div',
76
+ },
77
+ });
78
+
79
+ this.extendedBlockRenderMap = DefaultDraftBlockRenderMap.merge(
80
+ blockRenderMap,
81
+ );
82
+
75
83
  let editorState;
76
84
  if (props.properties && props.properties.description) {
77
- const contentState = stateFromHTML(props.properties.description);
78
- editorState = EditorState.createWithContent(contentState);
85
+ const contentState = this.stateFromHTML(props.properties.description);
86
+ editorState = this.EditorState.createWithContent(contentState);
79
87
  } else {
80
- editorState = EditorState.createEmpty();
88
+ editorState = this.EditorState.createEmpty();
81
89
  }
82
90
  this.state = { editorState, focus: false };
83
91
  }
@@ -109,11 +117,11 @@ class Edit extends Component {
109
117
  this.props.properties.description !== nextProps.properties.description &&
110
118
  !this.state.focus
111
119
  ) {
112
- const contentState = stateFromHTML(nextProps.properties.description);
120
+ const contentState = this.stateFromHTML(nextProps.properties.description);
113
121
  this.setState({
114
122
  editorState: nextProps.properties.description
115
- ? EditorState.createWithContent(contentState)
116
- : EditorState.createEmpty(),
123
+ ? this.EditorState.createWithContent(contentState)
124
+ : this.EditorState.createEmpty(),
117
125
  });
118
126
  }
119
127
 
@@ -163,6 +171,9 @@ class Edit extends Component {
163
171
  if (__SERVER__) {
164
172
  return <div />;
165
173
  }
174
+
175
+ const Editor = this.Editor;
176
+
166
177
  return (
167
178
  <div
168
179
  className={cx('block description', { selected: this.props.selected })}
@@ -171,7 +182,7 @@ class Edit extends Component {
171
182
  onChange={this.onChange}
172
183
  editorState={this.state.editorState}
173
184
  readOnly={!this.props.editable}
174
- blockRenderMap={extendedBlockRenderMap}
185
+ blockRenderMap={this.extendedBlockRenderMap}
175
186
  handleReturn={() => {
176
187
  if (this.props.data?.disableNewBlocks) {
177
188
  return 'handled';
@@ -223,4 +234,7 @@ class Edit extends Component {
223
234
  }
224
235
  }
225
236
 
226
- export default injectIntl(Edit);
237
+ export default compose(
238
+ injectLazyLibs(['draftJs', 'immutableLib', 'draftJsImportHtml']),
239
+ injectIntl,
240
+ )(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