diff --git a/packages/volto-heading-block/src/components/Edit.jsx b/packages/volto-heading-block/src/components/Edit.jsx index 8639098..5377564 100644 --- a/packages/volto-heading-block/src/components/Edit.jsx +++ b/packages/volto-heading-block/src/components/Edit.jsx @@ -1,9 +1,10 @@ import React from 'react'; import ContentEditable from 'react-contenteditable'; import { withBlockExtensions } from '@plone/volto/helpers'; -import { SidebarPortal } from '@plone/volto/components'; +import { SidebarPortal, MaybeWrap } from '@plone/volto/components'; import HeadingSidebar from './Sidebar'; import config from '@plone/volto/registry'; +import cx from 'classnames'; // Source: https://stackoverflow.com/questions/5796718/html-entity-decode var decodeHTMLEntities = (function () { @@ -60,56 +61,70 @@ class HeadingEdit extends React.Component { }; render = () => { - const { block, data, onChangeBlock, selected } = this.props; - const show_alignment = config.blocks?.blocksConfig?.heading?.show_alignment; + const { block, data, onChangeBlock, selected, blocksConfig, className } = + this.props; + const show_alignment = blocksConfig?.heading?.show_alignment; + const isBlockModelv3 = blocksConfig?.heading?.blockModel === 3; + + const LegacyWrapper = ({ className, children }) => ( +
{children}
+ ); return ( -
-
- { - if (e.key === 'Enter') { - e.preventDefault(); - e.stopPropagation(); - this.props.onSelectBlock( - this.props.onAddBlock( - config.settings.defaultBlockType, - this.props.index + 1, - ), - ); - } else if (e.key === 'ArrowUp') { - e.preventDefault(); - e.stopPropagation(); - this.props.onFocusPreviousBlock( - this.props.block, - this.editable.current, - ); - } else if (e.key === 'ArrowDown') { - e.preventDefault(); - e.stopPropagation(); - this.props.onFocusNextBlock( - this.props.block, - this.editable.current, - ); - } - }} - /> - - - -
-
+ <> + {data && ( + +
+ { + if (e.key === 'Enter') { + e.preventDefault(); + e.stopPropagation(); + this.props.onSelectBlock( + this.props.onAddBlock( + config.settings.defaultBlockType, + this.props.index + 1, + ), + ); + } else if (e.key === 'ArrowUp') { + e.preventDefault(); + e.stopPropagation(); + this.props.onFocusPreviousBlock( + this.props.block, + this.editable.current, + ); + } else if (e.key === 'ArrowDown') { + e.preventDefault(); + e.stopPropagation(); + this.props.onFocusNextBlock( + this.props.block, + this.editable.current, + ); + } + }} + /> + + + +
+
+ )} + ); }; }