-
-
Couldn't load subscription status.
- Fork 624
fix: BlockTypeSelect item filtering based on schema
#2112
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@nperez0111 sort of related but only tangentially - I noticed that switching to the default block configuration example and then back to any other one doesn't revert the heading prop schema back to having 6 levels. It's stuck having the 3 levels. I traced the issue back to Could you take a look at it? |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
packages/react/src/components/FormattingToolbar/DefaultSelects/BlockTypeSelect.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this with fresh eyes again, and I'm thinking that the editorHasBlockWithType type guards should maybe be gated within the BlockTypeSelect component's filteredItems instead. Take this for example:
{
name: editor.dictionary.slash_menu.quote.title,
type: "quote",
icon: RiQuoteText,
isSelected: (block) => block.type === "quote",
}Like, can't we know exactly what block this is trying to select based on the type & optional props object? This would allow us to filter the list down & cut down on the type guards needed.
Maybe this is over complicating it, but having a filter for this sort of thing is sort of useful generically, like in the slash menu, block type select & other places surely
Summary
This PR makes the
BlockTypeSelectfilter its default items based on whether they're allowed in the schema, same as how the slash menu already works.Rationale
You can configure things like allowed levels for the default heading block, but the
BlockTypeSelectwon't reflect this change.Changes
blockTypeSelectItemstogetDefaultBlockTypeSelectItems.Impact
N/A
Testing
Not sure how feasible testing smth like this is atm. We'd have to set up component testing across all of the examples.
Screenshots/Video
N/A
Checklist
Additional Notes