Skip to content

Commit

Permalink
add LegacyWrapper for BMv3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
danalvrz committed Jun 5, 2024
1 parent 09f5097 commit 9f5895a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/volto-heading-block/src/components/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@ import React from 'react';
import { withBlockExtensions } from '@plone/volto/helpers';
import cx from 'classnames';
import config from '@plone/volto/registry';
import { MaybeWrap } from '@plone/volto/components';

const HeadingView = (props) => {
const { className, data } = props;
const { className, data, blocksConfig } = props;
const Element = data.tag || 'h2';
const show_alignment = config.blocks?.blocksConfig?.heading?.show_alignment;
const isBlockModelv3 = blocksConfig?.heading?.blockModel === 3;

const LegacyWrapper = ({ className, children }) => (
<div className={cx('block heading', className)}>{children}</div>
);

return (
<>
{data && (
<div className={cx('block heading', className)}>
<MaybeWrap
condition={!isBlockModelv3}
as={LegacyWrapper}
className={className}
>
<div className="heading-wrapper">
<Element
style={show_alignment ? { textAlign: data.alignment } : {}}
Expand All @@ -20,7 +30,7 @@ const HeadingView = (props) => {
{data?.heading || ''}
</Element>
</div>
</div>
</MaybeWrap>
)}
</>
);
Expand Down

0 comments on commit 9f5895a

Please sign in to comment.