blocks-react-renderer icon indicating copy to clipboard operation
blocks-react-renderer copied to clipboard

[bug]: TextInlineNode and other types aren't exported

Open monolithed opened this issue 1 year ago • 1 comments

What version of @strapi/blocks-react-renderer are you using?

What's Wrong?

The following types aren't exported: TextInlineNode, ParagraphBlockNode, QuoteBlockNode, CodeBlockNode, HeadingBlockNode, ListBlockNode, and ImageBlockNode;

This will help iterate over the nodes like:


type Child = React.ReactElement<TextInlineNode>;

React.Children.map(children, (node) => {
          if (React.isValidElement(node)) {
                   const {props: {code, text}, ...props} = node as Child;

                     if (node.type !== 'text') {
                         return node;
                     }
         }
         
         return node;
});

To Reproduce

Expected Behaviour

Workaround


// HeadingBlockNode
import type {RootNode, GetPropsFromNode} from '@strapi/blocks-react-renderer/dist/BlocksRenderer';

type HeadingBlockNode = Extract<RootNode, {type: 'heading'}>;
type Props = GetPropsFromNode<HeadingBlockNode>;

// ...

monolithed avatar Nov 25 '24 19:11 monolithed

And BlocksRendererProps, GetPropsFromNode please

monolithed avatar Nov 29 '24 14:11 monolithed