-
-
Notifications
You must be signed in to change notification settings - Fork 597
feat: More generic type guards #1919
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
packages/core/src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts
Outdated
Show resolved
Hide resolved
if ( | ||
editorHasBlockWithTypeAndProps(editor, "heading", { | ||
level: defaultBlockSpecs["heading"].config.propSchema.level, | ||
isToggleable: { |
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.
Let's think ahead here & try to figure out how this would work for both the current schema system & a zod-based one. I'm not sure that we should have to pass a propschema into this function.
I guess there are two types of checks we may want:
- checking that a prop exists in the schema (i.e. does this editor even support toggle blocks)
- checking that a prop matches a shape we expect for this function (i.e. is
isToggleable
a boolean)
How might we express that with zod?
I think in zod, whether a prop exists is easy, is there a zod validator for this key. (I also have the feeling this is the more common check).
Then to actually check if it fits what we expect, we would have to run the validator?
So maybe these checks should be de-coupled, i.e. separate checks?
No description provided.