Skip to content

Commit

Permalink
fix: ArgumentsInEvidence block now uses Slate
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliaghisini committed Oct 6, 2023
1 parent 00d0bdc commit 19f01c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import cx from 'classnames';
import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';
import { UniversalLink } from '@plone/volto/components';
import { TextBlockView } from '@plone/volto-slate/blocks/Text';
import config from '@plone/volto/registry';

const messages = defineMessages({
vedi: {
Expand Down
26 changes: 16 additions & 10 deletions src/components/ItaliaTheme/Blocks/ArgumentsInEvidence/Block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
CardText,
CardReadMore,
} from 'design-react-kit';
import redraft from 'redraft';

import { UniversalLink } from '@plone/volto/components';
import { flattenToAppURL } from '@plone/volto/helpers';
import { ArgumentIcon } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
import config from '@plone/volto/registry';
import { TextBlockView } from '@plone/volto-slate/blocks/Text';

const messages = defineMessages({
text: {
Expand All @@ -37,6 +37,8 @@ const Block = ({
block,
onChange,
intl,
index,
...otherProps
}) => {
const argument = data?.argument ? data?.argument[0] : null;

Expand All @@ -49,21 +51,25 @@ const Block = ({
<CardText tag="p">{argument?.description}</CardText>
{inEditMode ? (
<TextEditorWidget
{...otherProps}
data={data}
block={block}
fieldName="title"
selected={selected}
block={block}
onChangeBlock={onChange}
placeholder={intl.formatMessage(messages.text)}
focusOn={focusOn}
onChangeBlock={(block, _data) => {
onChange({ ...data, title: _data.value });
}}
setSelected={() => {
focusOn('title');
}}
/>
) : (
<div>
{redraft(
data.title,
config.settings.richtextViewSettings.ToHTMLRenderers,
config.settings.richtextViewSettings.ToHTMLOptions,
)}
<TextBlockView
id={otherProps.id + '-' + index}
data={{ value: data.title }}
/>
</div>
)}
{argument && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Body extends SubblockEdit {
return (
<Subblock subblock={this} className="subblock-edit">
<Block
{...this.props}
data={this.props.data}
index={this.props.index}
key={this.props.index}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Edit extends SubblocksEdit {
<BodyWrapper data={this.props.data} inEditMode={false}>
{this.state.subblocks.map((subblock, subindex) => (
<Body
{...this.props}
data={subblock}
index={subindex}
key={subblock.id}
Expand Down

0 comments on commit 19f01c3

Please sign in to comment.