grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

[QUESTION][REQUEST] How to remove a block?

Open froderf opened this issue 7 years ago • 4 comments

editor.DomComponents.getWrapper().getEl().insertAdjacentHTML('beforeBegin', letBlock)

letBlock letblock is a variable that contains HTML.

Question:

  1. How to remove this adjacent HTML?
  2. is there a function like "insertAdjacentCSS()"?

froderf avatar Jul 24 '19 13:07 froderf

You touched on a few questions here, but to get to your first in your headline; reference the BlockManager api docs here

e.g. BlockManager.remove('custom-block-id')

zgover avatar Jul 24 '19 15:07 zgover

You're mixing too much stuff in one question and without any context

artf avatar Jul 24 '19 21:07 artf

@artf I just wanted to remove the new block that I added via editor.DomComponents.getWrapper().getEl().insertAdjacentHTML();

froderf avatar Jul 26 '19 01:07 froderf

Blocks are those: https://grapesjs.com/docs/modules/Blocks.html

editor.DomComponents.getWrapper().getEl().insertAdjacentHTML(); you're not removing "blocks", you're dealing with native DOM elements there. Probably you need to remove a Component, in that case use component.remove()

artf avatar Jul 30 '19 22:07 artf