Skip to content

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

Open
@monolithed

Description

@monolithed

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>;

// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions