Skip to content

Commit

Permalink
feat: added option to insert blocks view to the selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Wagner3UB committed Apr 12, 2024
1 parent b2d9998 commit 3b846fd
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ For the content select you could decide to repeat one or more one of this option
- blocks
- image

Or you can define a specific render of a content type from config:

```jsx
config.settings['volto-repeatable-content-block'] = {
...config.settings['volto-repeatable-content-block'],
renderer: {
...(config.settings['volto-repeatable-content-block']?.renderer ?? {}),

FaqFolder: FaqFolderView, // this is the component to render the object type FaqFolder
},
},
```
## Development
You can develop an add-on in isolation using the boilerplate already provided by the add-on generator.
Expand Down
1 change: 1 addition & 0 deletions src/RepeatableContentBlock/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const Body = ({ content, edit, data }) => {

return showHeader || renderContent ? (
<>
{content && data.title && <h2 className="mt-5 mb-4">{data.title}</h2>}
{content && showHeader && (
<div className="repeatable-block-header">
{data.showContentImage && (
Expand Down
8 changes: 8 additions & 0 deletions src/RepeatableContentBlock/RenderContentContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import PropTypes from 'prop-types';
import { hasBlocksData } from '@plone/volto/helpers';
import RenderBlocks from '../helpers/RenderBlocks';
import './style.css';
import config from '@plone/volto/registry';

const RenderContentContent = ({ content }) => {
const renderer =
config.settings['volto-repeatable-content-block']?.renderer?.[
content?.['@type']
];
if (renderer) {
return renderer({ content });
}
const blocks = hasBlocksData(content)
? RenderBlocks({ content: content })
: null;
Expand Down
16 changes: 16 additions & 0 deletions src/RepeatableContentBlock/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ const messages = defineMessages({
id: 'imageFullWidth',
defaultMessage: 'Show full-width image (if available)',
},
title: {
id: 'title',
defaultMessage: 'Title',
},
});

const Sidebar = ({ block, data, onChangeBlock, openObjectBrowser }) => {
Expand Down Expand Up @@ -65,6 +69,18 @@ const Sidebar = ({ block, data, onChangeBlock, openObjectBrowser }) => {
</header>

<Segment className="form">
<TextWidget
id="title"
title={intl.formatMessage(messages.title)}
required={false}
value={data.title}
onChange={(name, value) => {
onChangeBlock(block, {
...data,
[name]: value,
});
}}
/>
<TextWidget
id="href"
title={intl.formatMessage(messages.select_content)}
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export default (config) => {
},
sidebarTab: 1,
};

return config;
};

0 comments on commit 3b846fd

Please sign in to comment.