GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

BUG: CSS added via custom code persists after custom code component is removed #6152

Closed stpp2 closed 2 days ago

stpp2 commented 3 weeks ago

GrapesJS version

What browser are you using?

any

Reproducible demo link

https://grapesjs.com/demo

Describe the bug

How to reproduce the bug?

  1. Add custom code component with HTML + CSS
  2. Delete custom code component.

What is the expected behavior? All code should be removed, including CSS

What is the current behavior? custom CSS is not being removed, though the rest is.

gjs.webm

Code of Conduct

mosh-tudor commented 2 weeks ago

@stpp2 This is not really a bug; it's more of a feature. :)

Try using clearStyles:

https://github.com/GrapesJS/grapesjs/blob/d48e1e34a9fa363dcb83fdcca53a89563db17063/packages/core/src/editor/config/config.ts#L260-L272

stpp2 commented 2 weeks ago

Yeah clearStyles is already enabled in my case, but that doesn't seem to work well in many cases. Either way I'd expect the Custom Code component to be somewhat "containerized" so it's not leaving anything in the doc when removed.

artf commented 2 days ago

This is not related to the core and should be addressed at the plugin level. Please create the issue there and we'll try to figure out the right approach.