Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
monolithed opened this issue Nov 25, 2024 · 1 comment
Open

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

monolithed opened this issue Nov 25, 2024 · 1 comment
Labels
issue: bug Issue reporting a bug

Comments

@monolithed
Copy link

monolithed commented Nov 25, 2024

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 monolithed added the issue: bug Issue reporting a bug label Nov 25, 2024
@monolithed
Copy link
Author

monolithed commented Nov 29, 2024

And BlocksRendererProps, GetPropsFromNode please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug
Projects
None yet
Development

No branches or pull requests

1 participant