codex-team / codex-team/editor.js
Allow block tool render() accept null without throwing error
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
I have a few custom Editor.js block tools that trigger a custom React component that opens a modal and allows the user to walk through a few steps and this component will then add the newly constructed block using `blocks.insert(...)`.
Ideally I would like to be able to return null in my block tool render().
```
render() {
...
return null;
}
```
But doing this throws a console error...

Currently only way to avoid this console error is for my block tool render() to return a node.
```
render() {
...
return document.createElement('div');
}
```
But doing this adds an unnecessary block to the editor which in my application has other unintended consequences. I would like to avoid having to add a lot of extra unnecessary code to handle this additional/unneeded block.

I found one other previous issue (#768) where they also suggested making the appendChild void/null-proof. But looks like a different approach was used to solve that issue.
https://github.com/codex-team/editor.js/issues/768
> another approach would be to accept render function returning void (or null) and make the appendChild void-proof (or null-proof)
Is there a way to achieve what I'm looking to do without updating the appendChild to be null-proof? If not, is this something that could be updated?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.