portabletext / portabletext/react-portabletext

unknownBlockStyle is not working / does nothing

Open
#116 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triaged
Dominant language
TypeScript
Stars
377
Forks
31
Avg merge
23h 42m
Merged PRs (30d)
9

Description

The component override unknownBlockStyle is not working. It seems that when you provide a block component override, it is merged with the default block-styles, so that there never is an "unknown" block.
For instance if you define

  block: {
    // Ex. 1: customizing common block types
    h1: ({children}) => <h1 className="text-2xl">{children}</h1>,
    blockquote: ({children}) => <blockquote className="border-l-purple-500">{children}</blockquote>,
  },
  unknownBlockStyle: ({children}) => <BlockWrapper>{children}</BlockWrapper>,
}

the block style 'normal' should render with BlockWrapper, but instead gets render with the default component (<p>)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied components example with a block style of "normal", then trace the component override handling for block styles and unknownBlockStyle. Done means the normal block style uses the provided BlockWrapper instead of the default paragraph component, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.