Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Volto 18 #195

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"peerDependencies": {
"@plone-collective/volto-slots-editor": "*",
"@plone/volto": ">= 16.20.1 < 17.0.0",
"@plone/volto": ">= 18.0.0-alpha.30",
"react": ">= 16.8.0",
"react-dom": ">= 16.8.0",
"volto-form-block": ">=3.0.0"
Expand Down
81 changes: 27 additions & 54 deletions razzle.extend.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,45 @@ const fileLoaderFinder = makeLoaderFinder('file-loader');
const plugins = (defaultPlugins) => {
return [...defaultPlugins];
};
const modifyWebpackConfig = (config, { target, dev }, webpack) => {
const fileLoader = config.module.rules.find(fileLoaderFinder);
fileLoader.exclude = [
/@mdi\/svg\/.*\.svg$/,
/@material-design-icons\/svg\/filled\.svg$/,
/nsw-design-system-plone6\/.*\.svg$/,
...fileLoader.exclude,
];

const MDISVGLOADER = {
test: /@mdi\/svg\/.*\.svg$/,
use: [
{
loader: 'svg-loader',
},
{
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ convertPathData: false },
{ removeUselessStrokeAndFill: true },
{ removeViewBox: false },
],
const svgoOptions = {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
convertPathData: false,
removeViewBox: false,
},
},
],
};
const MATERIALICONSSVGLOADER = {
test: /@material-design-icons\/svg\/filled\.svg$/,
use: [
{
loader: 'svg-loader',
},
{
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ convertPathData: false },
{ removeUselessStrokeAndFill: true },
{ removeViewBox: false },
],
},
},
],
};
const NSWSVGLOEADER = {
test: /nsw-design-system-plone6\/.*\.svg$/,
},
'removeTitle',
'removeUselessStrokeAndFill',
],
};

function createSVGLoader(test) {
return {
test: test,
use: [
{
loader: 'svg-loader',
},
{
loader: 'svgo-loader',
options: {
plugins: [
{ removeTitle: true },
{ convertPathData: false },
{ removeUselessStrokeAndFill: false },
{ removeViewBox: false },
],
},
options: svgoOptions,
},
],
};
}

const modifyWebpackConfig = (config, { target, dev }, webpack) => {
const fileLoader = config.module.rules.find(fileLoaderFinder);
fileLoader.exclude = [/@mdi\/svg\/.*\.svg$/, /@material-design-icons\/svg\/filled\.svg$/, /nsw-design-system-plone6\/.*\.svg$/, ...fileLoader.exclude];

const MDISVGLOADER = createSVGLoader(/@mdi\/svg\/.*\.svg$/);
const MATERIALICONSSVGLOADER = createSVGLoader(/@material-design-icons\/svg\/filled\.svg$/);
const NSWSVGLOEADER = createSVGLoader(/nsw-design-system-plone6\/.*\.svg$/);

webpack.module.rules.push(MDISVGLOADER);
webpack.module.rules.push(MATERIALICONSSVGLOADER);
Expand Down
15 changes: 0 additions & 15 deletions src/config/apiExpanders.js

This file was deleted.

244 changes: 122 additions & 122 deletions src/config/blocks/variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,132 +50,132 @@ const blockVariations = {
template: CardListing,
},
],
hero: [
{
id: 'default',
title: 'Default',
isDefault: true,
},
{
id: 'heroWithLinks',
title: 'Text links',
template: HeroWithLinks,
schemaEnhancer: ({ schema, formData, intl }) => {
schema.properties.linksTitle = {
title: intl.formatMessage(messages.linksTitle),
type: 'string',
};
schema.properties.links = {
title: intl.formatMessage(messages.links),
widget: 'object_list',
schema: {
title: intl.formatMessage(messages.link),
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['title', 'url'],
},
],
properties: {
title: {
title: intl.formatMessage(messages.title),
},
url: {
title: intl.formatMessage(messages.link),
widget: 'object_browser',
mode: 'link',
},
},
},
};
// hero: [
// {
// id: 'default',
// title: 'Default',
// isDefault: true,
// },
// {
// id: 'heroWithLinks',
// title: 'Text links',
// template: HeroWithLinks,
// schemaEnhancer: ({ schema, formData, intl }) => {
// schema.properties.linksTitle = {
// title: intl.formatMessage(messages.linksTitle),
// type: 'string',
// };
// schema.properties.links = {
// title: intl.formatMessage(messages.links),
// widget: 'object_list',
// schema: {
// title: intl.formatMessage(messages.link),
// fieldsets: [
// {
// id: 'default',
// title: 'Default',
// fields: ['title', 'url'],
// },
// ],
// properties: {
// title: {
// title: intl.formatMessage(messages.title),
// },
// url: {
// title: intl.formatMessage(messages.link),
// widget: 'object_browser',
// mode: 'link',
// },
// },
// },
// };

const defaultFieldsetIndex = schema.fieldsets.findIndex(
(fieldset) => fieldset.id === 'default',
);
// const defaultFieldsetIndex = schema.fieldsets.findIndex(
// (fieldset) => fieldset.id === 'default',
// );

schema.fieldsets[defaultFieldsetIndex].fields = [
...schema.fieldsets[defaultFieldsetIndex].fields,
'linksTitle',
'links',
];
return schema;
},
},
{
id: 'heroWithLinkList',
title: 'Link list',
template: HeroWithLinkList,
schemaEnhancer: ({ schema, formData, intl }) => {
schema.properties.linksTitle = {
title: intl.formatMessage(messages.linksTitle),
type: 'string',
};
schema.properties.links = {
title: intl.formatMessage(messages.links),
widget: 'object_list',
schema: {
title: intl.formatMessage(messages.link),
fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['title', 'url'],
},
],
properties: {
title: {
title: intl.formatMessage(messages.title),
},
url: {
title: intl.formatMessage(messages.link),
widget: 'object_browser',
mode: 'link',
},
},
},
};
// schema.fieldsets[defaultFieldsetIndex].fields = [
// ...schema.fieldsets[defaultFieldsetIndex].fields,
// 'linksTitle',
// 'links',
// ];
// return schema;
// },
// },
// {
// id: 'heroWithLinkList',
// title: 'Link list',
// template: HeroWithLinkList,
// schemaEnhancer: ({ schema, formData, intl }) => {
// schema.properties.linksTitle = {
// title: intl.formatMessage(messages.linksTitle),
// type: 'string',
// };
// schema.properties.links = {
// title: intl.formatMessage(messages.links),
// widget: 'object_list',
// schema: {
// title: intl.formatMessage(messages.link),
// fieldsets: [
// {
// id: 'default',
// title: 'Default',
// fields: ['title', 'url'],
// },
// ],
// properties: {
// title: {
// title: intl.formatMessage(messages.title),
// },
// url: {
// title: intl.formatMessage(messages.link),
// widget: 'object_browser',
// mode: 'link',
// },
// },
// },
// };

const defaultFieldsetIndex = schema.fieldsets.findIndex(
(fieldset) => fieldset.id === 'default',
);
// const defaultFieldsetIndex = schema.fieldsets.findIndex(
// (fieldset) => fieldset.id === 'default',
// );

schema.fieldsets[defaultFieldsetIndex].fields = [
...schema.fieldsets[defaultFieldsetIndex].fields,
'linksTitle',
'links',
];
return schema;
},
},
{
id: 'heroWithBlocks',
title: 'With blocks',
template: HeroWithBlocks,
},
{
id: 'heroWithDropdownQuickNavigation',
title: 'With quick navigation',
template: HeroWithDropdownQuickNavigation,
schemaEnhancer: ({ schema, formData, intl }) => {
const dropdownQuickNavigationSchema = DropdownQuickNavigationSchema({
intl,
});
schema.properties = {
...schema.properties,
...dropdownQuickNavigationSchema.properties,
};
const variationFieldset = {
id: 'dropdownQuickNavVariation',
title: 'Quick Navigation Settings',
fields: [...dropdownQuickNavigationSchema.fieldsets[0].fields],
required: [...dropdownQuickNavigationSchema.fieldsets[0].required],
};
schema.fieldsets.push(variationFieldset);
return schema;
},
},
],
// schema.fieldsets[defaultFieldsetIndex].fields = [
// ...schema.fieldsets[defaultFieldsetIndex].fields,
// 'linksTitle',
// 'links',
// ];
// return schema;
// },
// },
// {
// id: 'heroWithBlocks',
// title: 'With blocks',
// template: HeroWithBlocks,
// },
// {
// id: 'heroWithDropdownQuickNavigation',
// title: 'With quick navigation',
// template: HeroWithDropdownQuickNavigation,
// schemaEnhancer: ({ schema, formData, intl }) => {
// const dropdownQuickNavigationSchema = DropdownQuickNavigationSchema({
// intl,
// });
// schema.properties = {
// ...schema.properties,
// ...dropdownQuickNavigationSchema.properties,
// };
// const variationFieldset = {
// id: 'dropdownQuickNavVariation',
// title: 'Quick Navigation Settings',
// fields: [...dropdownQuickNavigationSchema.fieldsets[0].fields],
// required: [...dropdownQuickNavigationSchema.fieldsets[0].required],
// };
// schema.fieldsets.push(variationFieldset);
// return schema;
// },
// },
// ],
};

// Add schema enhancers to specific variations of existing blocks
Expand Down
2 changes: 0 additions & 2 deletions src/config/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import updateApiExpandersConfig from './apiExpanders';
import updateAsyncConnectConfig from './asyncConnect';
import updateBlocksConfig from './blocks';
import updateLoadablesConfig from './loadables';
Expand All @@ -15,7 +14,6 @@ export const applyAddonConfig = (config) => {
// Settings may be used by other configs
updateSettingsConfig(config);

updateApiExpandersConfig(config);
updateAsyncConnectConfig(config);
updateBlocksConfig(config);
updateLoadablesConfig(config);
Expand Down
Loading