diff --git a/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx b/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx index 03690cf92..664ebb37e 100644 --- a/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx +++ b/src/components/ItaliaTheme/View/Commons/RichTextRender.jsx @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; -import { flattenDeep, values } from 'lodash'; +import { values } from 'lodash'; import { flattenHTMLToAppURL } from '@plone/volto/helpers'; import { hasBlocksData } from '@plone/volto/helpers'; import { RenderBlocks } from 'design-comuni-plone-theme/components/ItaliaTheme/View'; @@ -11,14 +11,16 @@ const richTextHasContent = (data) => { //ReactDOMServer.renderToStaticMarkup(RenderBlocks({ data: data })), const renderedBlocks = RenderBlocks({ data: data }); - const textBlocks = values(data.blocks).filter((b) => b['@type'] === 'text'); + const textBlocks = values(data.blocks).filter( + (b) => b['@type'] === 'slate', + ); const noTextBlocks = values(data.blocks).filter( - (b) => b['@type'] !== 'text', + (b) => b['@type'] !== 'slate', ); - const textContent = flattenDeep( - textBlocks?.map((block) => block.text?.blocks?.map((b) => b.text) ?? []), - )?.filter((b) => b != null && b.trim().length > 0)?.[0]; + const textContent = textBlocks?.filter( + (b) => b.plaintext != null && b.plaintext?.trim().length > 0, + )?.[0]; return ( renderedBlocks !== null && diff --git a/src/config/Slate/Alignment/index.js b/src/config/Slate/Alignment/index.js index ee6525fcb..cc5fc991f 100644 --- a/src/config/Slate/Alignment/index.js +++ b/src/config/Slate/Alignment/index.js @@ -10,7 +10,11 @@ const messages = defineMessages({ }); export const AlignElement = ({ attributes, children, element }) => { - return

{children}

; + return ( +

+ {children} +

+ ); }; const AlignButton = (props) => { diff --git a/src/config/Slate/config.js b/src/config/Slate/config.js index 7af224a5d..12df14280 100644 --- a/src/config/Slate/config.js +++ b/src/config/Slate/config.js @@ -1,4 +1,6 @@ //config.settings.slate.contextToolbarButtons +import RichTextWidget from '@plone/volto-slate/widgets/RichTextWidget'; +import HtmlSlateWidget from '@plone/volto-slate/widgets/HtmlSlateWidget'; import installAlignment from 'design-comuni-plone-theme/config/Slate/Alignment'; import installHeadings from 'design-comuni-plone-theme/config/Slate/Headings'; import installUnderline from 'design-comuni-plone-theme/config/Slate/Underline'; @@ -29,5 +31,27 @@ export default function applyItaliaSlateConfig(config) { config.settings.slate.expandedToolbarButtons = config.settings.slate.toolbarButtons.filter( (b) => b !== 'callout', ); + + //add wrapper public-ui to widgets + config.widgets.widget.slate = (props) => ( +
+ +
+ ); + config.widgets.widget.slate_richtext = (props) => ( +
+ +
+ ); + config.widgets.widget.slate_html = (props) => ( +
+ +
+ ); + config.widgets.widget.richtext = (props) => ( +
+ +
+ ); return config; }