Skip to content

Commit

Permalink
Merge branch 'main' into plip6320-Vite-as-Volto-bundler
Browse files Browse the repository at this point in the history
* main:
  Slate Italian translations (#6563)
  Release 18.5.0
  Fix robots.txt in devmode (#6571)
  added swedish translation (#6557)
  Depth search issue (#6558)
  Block examples documentation (#6560)
  Fixed folder contents issues with persistent selection (#6554)
  Fix redirects to MDN responsive images (#6552)
  Bugfix remove query string inclusion in body class generation logic (#6547)
  Show related items (#4381)
  Update links to kitconcept.com
  Release 18.4.0
  Release @plone/components 3.0.1
  Release @plone/types 1.2.0
  Fix precedence of the quanta layer by adding a base layer for all the… (#6539)
  Add monorepo structure to the README (#6542)
  • Loading branch information
sneridagh committed Jan 10, 2025
2 parents 4a6db26 + 467e0a3 commit 8330fd9
Show file tree
Hide file tree
Showing 129 changed files with 6,946 additions and 140 deletions.
40 changes: 32 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ You can build your own or choose from the community released ones:
You can try a Volto online demo at [https://demo.plone.org/](https://demo.plone.org/).


## Monorepo structure

Since version 18.0.0-alpha4, the Volto core repository has had the shape of a monorepo, where "mono" means "single" and "repo" is short for "repository".
This means that several apps and libraries related to each other are stored in the same repository.
They are managed together but released individually.
This allows the code to be shared effectively, and unifies tracking of changes across all of the apps and libraries.

| Package | Location |
|---|---|
| [`@plone/client`](https://www.npmjs.com/package/@plone/client) | [`packages/client`](https://github.com/plone/volto/tree/main/packages/client#readme) |
| [`@plone/components`](https://www.npmjs.com/package/@plone/components) | [`packages/components`](https://github.com/plone/volto/tree/main/packages/components#readme) |
| [`@plone/generator-volto`](https://www.npmjs.com/package/@plone/generator-volto) | [`packages/generator-volto`](https://github.com/plone/volto/tree/main/packages/generator-volto#readme) |
| [`@plone/helpers`](https://www.npmjs.com/package/@plone/helpers) | [`packages/helpers`](https://github.com/plone/volto/tree/main/packages/helpers#readme) |
| [`@plone/providers`](https://www.npmjs.com/package/@plone/providers) | [`packages/providers`](https://github.com/plone/volto/tree/main/packages/providers#readme) |
| [`@plone/registry`](https://www.npmjs.com/package/@plone/registry) | [`packages/registry`](https://github.com/plone/volto/tree/main/packages/registry#readme) |
| [`@plone/scripts`](https://www.npmjs.com/package/@plone/scripts) | [`packages/scripts`](https://github.com/plone/volto/tree/main/packages/scripts#readme) |
| [`@plone/types`](https://www.npmjs.com/package/@plone/types) | [`packages/types`](https://github.com/plone/volto/tree/main/packages/types#readme) |
| none | [`packages/volto-guillotina`](https://github.com/plone/volto/tree/main/packages/volto-guillotina) |
| [`@plone/volto-slate`](https://www.npmjs.com/package/@plone/volto-slate) | [`packages/volto-slate`](https://github.com/plone/volto/tree/main/packages/volto-slate#readme) |
| [`@plone/volto-testing`](https://www.npmjs.com/package/@plone/volto-testing) | [`packages/volto-testing`](https://github.com/plone/volto/tree/main/packages/volto-testing) |

See also [Monorepo structure](https://6.docs.plone.org/volto/contributing/developing-core.html#monorepo-structure).


## Create a Volto project

To start a new project using Volto, follow the [Plone installation documentation](https://6.docs.plone.org/install/create-project.html).
Expand Down Expand Up @@ -118,12 +142,12 @@ To ensure your website gets the greatest exposure, add it both to [Awesome Volto
- [Debako Udala / Ayuntamiento de Deba](https://www.deba.eus/eu) (Website of the municipality of Deba, developed by [CodeSyntax](https://www.codesyntax.com/en), 2022)
- [European Environment Agency](https://www.eea.europa.eu/en) (Website of the European Environment Agency. Developed by [Eau de Web](https://eaudeweb.ro), 2023)
- [Energy Climate Union portal for Europe](https://climate-energy.eea.europa.eu/) (Thematic website focusing on European strides towards mitigating climate change, developed by [Eau de Web](https://eaudeweb.ro/), 2020)
- [Excellence at Humboldt-Universität zu Berlin](https://www.alles-beginnt-mit-einer-frage.de) (Website for the excellence initiative of the [Humboldt University Berlin](https://www.hu-berlin.de/de), developed by [kitconcept GmbH](https://kitconcept.com), 2019)
- [Excellence at Humboldt-Universität zu Berlin](https://www.alles-beginnt-mit-einer-frage.de) (Website for the excellence initiative of the [Humboldt University Berlin](https://www.hu-berlin.de/de), developed by [kitconcept GmbH](https://kitconcept.com/en), 2019)
- [Forest Information System for Europe](https://forest.eea.europa.eu) (Thematic website focusing on European forests, developed by [Eau de Web](https://eaudeweb.ro/), 2019)
- [Forschungszentrum Jülich](https://www.fz-juelich.de/de) (Website for Forschungzentrum Jülich, which is one of the largest research institutions in Europe, developed by [kitconcept GmbH](https://kitconcept.com), 2022)
- [German Aerospace Center (DLR)](https://www.dlr.de/de) (The German Aerospace Center (DLR) is the Federal Republic of Germany's research center for aeronautics. With more than 10.000 employees and a yearly budget of more than 1 billion euros, it is one of the largest research institutions in Germany, developed by [kitconcept GmbH](https://kitconcept.com), 2023)
- [Helmholtz-Institut Erlangen-Nürnberg für Erneuerbare Energien (HI-ERN)](https://www.hi-ern.de/de) (Website for HI ERN, a research institution for renewable energies, developed by [kitconcept GmbH](https://kitconcept.com), 2022)
- [Humboldt Labor](https://www.humboldtforum.org/de/programm/dauerangebot/ausstellung/nach-der-natur-14144/) (The Humboldt Lab is a website where the Humboldt University Berlin presents its latest research projects and findings. Developed by [WLDX](https://wldx.de/) and [kitconcept GmbH](https://kitconcept.com), 2020)
- [Forschungszentrum Jülich](https://www.fz-juelich.de/de) (Website for Forschungzentrum Jülich, which is one of the largest research institutions in Europe, developed by [kitconcept GmbH](https://kitconcept.com/en), 2022)
- [German Aerospace Center (DLR)](https://www.dlr.de/de) (The German Aerospace Center (DLR) is the Federal Republic of Germany's research center for aeronautics. With more than 10.000 employees and a yearly budget of more than 1 billion euros, it is one of the largest research institutions in Germany, developed by [kitconcept GmbH](https://kitconcept.com/en), 2023)
- [Helmholtz-Institut Erlangen-Nürnberg für Erneuerbare Energien (HI-ERN)](https://www.hi-ern.de/de) (Website for HI ERN, a research institution for renewable energies, developed by [kitconcept GmbH](https://kitconcept.com/en), 2022)
- [Humboldt Labor](https://www.humboldtforum.org/de/programm/dauerangebot/ausstellung/nach-der-natur-14144/) (The Humboldt Lab is a website where the Humboldt University Berlin presents its latest research projects and findings. Developed by [WLDX](https://wldx.de/) and [kitconcept GmbH](https://kitconcept.com/en), 2020)
- [ILPO](https://ilpo.jyu.fi/) (the registration portal of continuous learning at the University of Jyväskylä. Developed by University of Jyväskylä, 2022)
- [Industrial Emissions portal for Europe](https://industry.eea.europa.eu) (Thematic website focusing on European industrial emissions, developed by [Eau de Web](https://eaudeweb.ro/), 2020)
- [Jobfamilie MEDICE](https://jobfamilie.medice.de/de) (Carrer website for MEDICE Arzneimittel Pütter GmbH & Co. KG), developed by [Werkbank GmbH](https://werkbank.de/), 2020)
Expand All @@ -135,13 +159,13 @@ To ensure your website gets the greatest exposure, add it both to [Awesome Volto
- [ResOU](https://resou.osaka-u.ac.jp/ja) (ResOU is introducing official researched releases by the University of Osaka, Japan. Developed by [CMScom](https://www.cmscom.jp), 2020)
- [Stradanove](https://www.stradanove.it/) (Website of the Department of Youth Policies of the Municipality of Modena, developed by [RedTurtle](https://www.redturtle.it), 2020)
- [Study guide at University of Jyväskylä](https://studyguide.jyu.fi/2020/en/) (Static website where [Volto is used as a headless CMS for authoring additional content](https://tech.blog.jyu.fi/2020/06/plone-volto-hasura-gatsbyjs-mashup/), 2020)
- [Talke Carrer Website](https://karriere.talke.com/) (Carrer website for [Talke](https://www.talke.com), one of the leading a chemical and petrochemical logistics companies in Germany, developed by [kitconcept GmbH](https://kitconcept.com), 2020)
- [Talke Carrer Website](https://karriere.talke.com/) (Carrer website for [Talke](https://www.talke.com), one of the leading a chemical and petrochemical logistics companies in Germany, developed by [kitconcept GmbH](https://kitconcept.com/en), 2020)
- [UEU](https://www.ueu.eus) (Website for Udako Euskal Unibertsitatea, a non-profit University offering all its service only in Basque: courses, publications, ... developed by [CodeSyntax](https://www.codesyntax.com/en), 2023)
- [Unione dei Comuni della Val Bisenzio](https://www.bisenzio.it/) (Website of the Municipality union of Val Bisenzio. Developed by [RedTurtle](https://www.redturtle.it), 2021)
- [VHS Ehrenamtsportal](https://vhs-ehrenamtsportal.de) (Website to help volunteers that help refugees for the [German Adult Education Association](https://www.volkshochschule.de/), developed by [kitconcept GmbH](https://kitconcept.com), 2018)
- [VHS Ehrenamtsportal](https://vhs-ehrenamtsportal.de) (Website to help volunteers that help refugees for the [German Adult Education Association](https://www.volkshochschule.de/), developed by [kitconcept GmbH](https://kitconcept.com/en), 2018)
- [VisitModena](https://www.visitmodena.it/it) (Tourist website of the Municipality of Modena, developed by [RedTurtle](https://www.redturtle.it), 2020)
- [WISE-Freshwater](https://water.europa.eu/freshwater) (WISE-Freshwater, the Freshwater Information System for Europe. Developed by [Eau de web](https://eaudeweb.ro) for the European Environmental Agency, 2021)
- [Zeelandia](https://www.zeelandia.de/) (Corporate website for one of the leading bakery ingredients manufacturers in Germany, developed by [kitconcept GmbH](https://kitconcept.com), 2019)
- [Zeelandia](https://www.zeelandia.de/) (Corporate website for one of the leading bakery ingredients manufacturers in Germany, developed by [kitconcept GmbH](https://kitconcept.com/en), 2019)


### Open-source websites built with Volto
Expand Down
6 changes: 6 additions & 0 deletions docs/source/_static/add-document.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/pen.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/source/blocks/anatomy.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ You can use all these props to render your edit block and model its behavior.
Volto later then 16.0.0 ships with a set of default Edit and View components.
The view component is mostly a placeholder, with an auto-generated listing of
the block fields, while the default Edit component is the most interesting, as
it can use the `schema` that you can specify in the block configuration to
it can use the `blockSchema` that you can specify in the block configuration to
automatically render a form for the Block settings, in the Volto Sidebar. In
the main editing area, it will render the view component, so for many blocks
you can just develop a schema and the View component.
Expand Down
74 changes: 47 additions & 27 deletions docs/source/blocks/editcomponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ myst:

The edit component part of a block anatomy is specially different to the view component because they have to support the UX for editing the block.
This UX can be very complex depending on the kind of block and the feature that it is trying to provide.
The project requirements will tell how far you should go with the UX story of each tile, and how complex it will become.
The project requirements will tell how far you should go with the UX story of each block, and how complex it will become.
You can use all the props that the edit component is receiving to model the UX for the block and how it will render.

See the complete list of {ref}`block-edit-component-props-label`.
Expand All @@ -28,22 +28,36 @@ You need to instantiate it this way:
```jsx
import { SidebarPortal } from '@plone/volto/components';

[...]
const Edit = (props) => {
const { selected } = props;
return (

[...]

<SidebarPortal selected={this.props.selected}>
// ...
</SidebarPortal>
<SidebarPortal selected={selected}>
// ...
</SidebarPortal>
)

}
```

Everything that's inside the `SidebarPortal` component will be rendered in the sidebar. If you need an extra layer of configuration within `SidebarPortal`, you can use `SidebarPopup`.

```jsx

import { SidebarPopup } from '@plone/volto/components';

<SidebarPopup open={this.props.sidebarOpen}>
...
</SidebarPopup>
const Edit = (props) => {
const { sidebarOpen } = props;

return (
[...]

<SidebarPopup open={sidebarOpen}>
...
</SidebarPopup>
)
}
```

## Schema driven automated block settings forms
Expand Down Expand Up @@ -107,24 +121,30 @@ import schema from './schema';
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
import { Icon } from '@plone/volto/components';

<SidebarPortal selected={this.props.selected}>
<BlockDataForm
icon={<Icon size="24px" name={nameSVG} />}
schema={schema}
title={schema.title}
headerActions={<button onClick={() => {}}>Action</button>}
footer={<div>I am footer</div>}
onChangeField={(id, value) => {
this.props.onChangeBlock(this.props.block, {
...this.props.data,
[id]: value,
});
}}
onChangeBlock={onChangeBlock}
formData={this.props.data}
block={block}
/>
</SidebarPortal>;
const Edit = (props) => {
const {selected, block, data, onChangeBlock} = props;

return (
<SidebarPortal selected={selected}>
<BlockDataForm
icon={<Icon size="24px" name={nameSVG} />}
schema={schema}
title={schema.title}
headerActions={<button onClick={() => {}}>Action</button>}
footer={<div>I am footer</div>}
onChangeField={(id, value) => {
onChangeBlock(block, {
...data,
[id]: value,
});
}}
onChangeBlock={onChangeBlock}
formData={data}
block={block}
/>
</SidebarPortal>;
)
}
```

## Object Browser
Expand Down
154 changes: 154 additions & 0 deletions docs/source/blocks/examples/custom-schema-and-view.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
---
myst:
html_meta:
'description': 'Volto block with custom schema and view components'
'property=og:description': 'Volto block with custom schema and view components'
'property=og:title': 'Volto block with custom schema and view components'
'keywords': 'Volto, React, blocks, grid, container, Plone'
---

(custom-schema-and-view)=

# Block with a custom schema

You can create a block with several settings defined using a schema, and let Volto render the edit form by itself.

To do so, define the schema, the view component, and configure the block settings.

## Preparations

In your Volto add-on, create a subfolder {file}`ExampleBlock01` inside the {file}`components` folder to save all the files required to create a block.

## Schema

Create a {file}`Schema.js` file inside the {file}`ExampleBlock01` folder, with the following contents.

```js
import messages from './messages';

const Schema = ({ intl }) => {
return {
title: intl.formatMessage(messages.block01),
block: 'block01',
fieldsets: [
{
id: 'default',
title: intl.formatMessage(messages.default),
fields: ['url', 'title'],
},
],

properties: {
url: {
title: intl.formatMessage(messages.URL),
widget: 'url',
},
title: {
title: intl.formatMessage(messages.title),
},
},
required: [],
};
};

export default Schema;
```

## Messages

As you may have noted, you prepared the block for internationalization.
{term}`Internationalization` (i18n) is the process of creating user interfaces which are suitable for different languages and cultural contexts.
To add translatable messages, create a file {file}`messages.js` in the same {file}`ExampleBlock01` folder with the following contents.

```js
import { defineMessages } from 'react-intl';

const messages = defineMessages({
block01: {
id: 'block01',
defaultMessage: 'Block 01',
},
default: {
id: 'default',
defaultMessage: 'Default',
},
URL: {
id: 'URL',
defaultMessage: 'URL',
},
title: {
id: 'title',
defaultMessage: 'Title',
},
});

export default messages;
```

## View component

The view component will have all the required logic to show the information saved on the block.
It will be a small HTML fragment.

Create a file {file}`View.jsx` in the {file}`ExampleBlock01` folder with the following contents.

```jsx
import cx from 'classnames';
import React from 'react';

const View = (props) => {
// - `data` holds the values entered in the block edit form.
// - `className` holds the CSS class names injected into this block
// by Volto's `styleClassNameExtenders`.
// - `style` holds the CSS properties injected into this block
// by Volto's `Block Style Wrapper`.
const { data, className, style } = props;
return (
<div className={cx('block', 'block01', className)} style={style}>
I am the Block view component!
<ul>
<li>Title: {data.title}</li>
<li>URL: {data.url}</li>
</ul>
</div>
);
};

export default View;
```

## Block configuration

With all the block components ready, you need to register the block into Volto.

To do so, open your add-on's {file}`index.js` file, and insert the following contents before the last `return config;` statement.

```js
config.blocks.blocksConfig.block01 = {
id: 'block01', // this is the block id, it must match the id on the previous line
title: 'Block 01', // this is the block title
view: View01, // this is the block's view component
// We do not need a specific edit component, Volto will use the default
// edit: null;
blockSchema: Schema01, // this is the schema that will be used to render the edit form
icon: imagesSVG, // this is the image that will be shown in the block selector
sidebarTab: 1, // this is set to 1 to have the `Block` tab selected in the sidebar
// editor when editing this block
};
```

At the top of the file, import the relevant components as follows.

```js
import View01 from './components/ExampleBlock01/View';
import Schema01 from './components/ExampleBlock01/Schema';

// This is the icon we use for the example, use a meaningful one or provide your own image.
import imagesSVG from '@plone/volto/icons/images.svg';
```

## See it in action

Your block is ready to be used in your site.

Restart your Volto site, and now you can add the new block from the block chooser found in the {guilabel}`Edit` <img alt="Edit icon" src="../../_static/pen.svg" class="inline"> or {guilabel}`Add` <img alt="Add icon" src="../../_static/add-document.svg" class="inline"> content views.
Loading

0 comments on commit 8330fd9

Please sign in to comment.