Skip to content

Commit

Permalink
Prepare for Block Model v3, backwards compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
danalvrz committed Mar 14, 2024
1 parent 8f65a28 commit 6a69434
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/components/Data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { BlockDataForm } from '@plone/volto/components';
import { SeparatorSchema } from './schema';

const SeparatorData = (props) => {
const { block, data, onChangeBlock } = props;
const { data, block, onChangeBlock, schemaEnhancer, navRoot, contentType } =
props;
const intl = useIntl();
const schema = SeparatorSchema({ ...props, intl });
const schema = schemaEnhancer
? schemaEnhancer(SeparatorSchema({ ...props, intl }), props)
: SeparatorSchema({ ...props, intl });

return (
<BlockDataForm
Expand All @@ -18,9 +21,12 @@ const SeparatorData = (props) => {
[id]: value,
});
}}
onChangeBlock={onChangeBlock}
formData={data}
fieldIndex={data.index}
block={block}
navRoot={navRoot}
contentType={contentType}
/>
);
};
Expand Down
18 changes: 13 additions & 5 deletions src/components/View.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import React from 'react';
import cx from 'classnames';
import { MaybeWrap } from '@plone/volto/components';

const SeparatorView = (props) => {
//eslint-disable-next-line
const { className, data, style } = props;
const LegacyWrapper = (props) => (
<div className={cx('block separator', props.className)}>{props.children}</div>
);

const SeparatorView = ({ data, isEditMode, className, blocksConfig }) => {
const isBlockModelv3 = blocksConfig?.separator?.v3;
return (
<div className={cx('block separator', className)} style={style}>
<MaybeWrap
condition={!isBlockModelv3}
as={LegacyWrapper}
className={className}
>
<div className="line" />
</div>
</MaybeWrap>
);
};

Expand Down

0 comments on commit 6a69434

Please sign in to comment.