I would assume that the remove() function would be required in such project, there's adding, getting, but not removing selected block, I would like to remove button block, and add my own - so I can make my own styles for it.
I second this, I ended up editing grapesjs and adding my own for the time being as it's pretty simple, I can make a merge request or if @artf can update it whenever possible to add the remove function :)
For the time being you can place this in your block_manager/index.js and re-compile grapesjs:
/**
* Remove block by id
* @param {string} id Block id
*/
remove(id) {
return blocks.remove(id);
},
Agree, I'll add it soon, for the moment you can use this editor.BlockManager.getAll().remove('block-id')
Awesome, thank you for the project :)
Any way to remove block by category?
@Geczy probably something like this
const bm = editor.BlockManager;
const blocks = bm.getAll();
const toRemove = blocks.filter(block => block.get('category') === ...);
toRemove.forEach(block => bm.remove(block.get('id')))
I believe the docs should also be updated regarding this change
https://github.com/artf/grapesjs/wiki/API-Block-Manager
@cmoutafidis you're looking in the wrong place https://grapesjs.com/docs/api/block_manager.html
Most helpful comment
Agree, I'll add it soon, for the moment you can use this
editor.BlockManager.getAll().remove('block-id')