Adding a button inside a Block draggable button #4009
-
Hello Just started playing around with GrapeJS, although i never did any javascript programming before (my work is mostly C,C++,JAVA). For today i managed to implement it with my custom php page manager, all connected to an headless cms with a really nice API, where i can save and fetch the page html and css! For my second functionality i wanted to be able to save and load user blocks from the database, for this i was able to add a button where it will save the block to DB and add it to the editor right bar (which i also load on editor init): As you can see on the image you have that small floppy icon on the toolbar which allows us to save any block as a "User Block" that gets loaded to the editor tab both when you save it and when the editor loads! Really happy with this... until i noticed i also need a way to delete the block! So i managed to add that ugly (for now) delete button on each block: editor.BlockManager.add(element.name, { I know i cannot make it work with the onclick="myFunction()" thats just there as an example. So the question is, is there any way i can add a delete button to the block that will trigger an editor.command? Thank you!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @johnkeel-thork if you need more control over your rendered blocks the best approach is to create your own block manager https://grapesjs.com/docs/modules/Blocks.html#customization |
Beta Was this translation helpful? Give feedback.
Hi @johnkeel-thork if you need more control over your rendered blocks the best approach is to create your own block manager https://grapesjs.com/docs/modules/Blocks.html#customization