-
-
Notifications
You must be signed in to change notification settings - Fork 555
Props complexity for custom blocks #444
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
Comments
Props only taking primitive types is indeed a design choice that we've made, though it's largely due to copy/paste actually. Basically, by rendering out a block's type and props to HTML attributes, we can recreate the block without having to implement custom parsing logic for it, meaning custom blocks can be copied and pasted within BlockNote, without consumers having to explicitly tell BlockNote how certain HTML elements should be parsed. The issue with using arrays/JSON as props is that now these also have to be rendered out to HTML attributes in order to keep this working, which as you can imagine, makes the DOM quite cluttered. While we're still looking for good ways to improve this, you can still make it work now. Let's say you want to add a prop to a custom block, the prop is called |
This makes some sense, but you could also allow complex props and require the implementation of the |
True, it's still something we'll have to discuss but a good suggestio imo, @YousefED thoughts on this? |
I don't know if it could help, but some editors like Notion or EditorJs (the editor that I currently use) use a JSON representation of the blocks inside the clipboard. This solution could be interesting for browser that support it and for copy and pasting between BlockNote editors. Unfortunately, it's not supported by Firefox (and maybe others?), I think. |
Uh oh!
There was an error while loading. Please reload this page.
Is your feature request related to a problem? Please describe.
I currently try to benchmark BlockNote for my use cases, including complex custom blocks, currently, the type system is only allowing props to be
string
,number
orboolean
, and for example, my use case is a block that have an array of object containing a title and some text, each element of the array is a possible display of the block, this doesn't look possible (or with many@ts-ignore
?) maybe I'm missing something or do something wrong.Describe the solution you'd like
Being able to have complex props types
Describe alternatives you've considered
Encode my objects/array to JSON, but it's messy and really not great
Additional context
The text was updated successfully, but these errors were encountered: