Closed rhoenerSBS closed 3 months ago
That method is only valid once the default block manager is already rendered. If you need to rerender at the beginning you can subscribe to the event of block manager activation.
editor.on('command:run:open-blocks', () => {
const blocks = editor.BlockManager.getAll();
const filtered = blocks.filter(block => block.getLabel() == 'Text');
editor.BlockManager.render(filtered);
});
Thank you @artf
GrapesJS version
What browser are you using?
Chrome v123
Reproducible demo link
https://jsfiddle.net/7xu0efLc/3/
Describe the bug
The GrapesJs docs show that it is supposedly possible to filter the blocks and rerender the BlockManager with the filtered list of blocks. (see docs https://grapesjs.com/docs/api/block_manager.html#render) In the fiddle you can see, that it's not working. Only the Text Block should be visible.
How to reproduce the bug?
What is the expected behavior? BlockManager should be able to render with filtered List of blocks.
What is the current behavior? Blocks are not filtered.
Code of Conduct