BUG: Deleting a component without deleting its corresponding style
Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
latest version of Chrome
Reproducible demo link
https://grapesjs.com/demo.html
Describe the bug
How to reproduce the bug? <img width="1665" alt="image" src="https://github.com/GrapesJS/grapesjs/assets/114127651/657cbaf6-7e87-4702-ac7f-36c710464728">
What is the expected behavior? it's style maybe reduce,
What is the current behavior? First of all, my editor only uses one page. Every time I switch pages, it will replace the current configuration with a page from the backend. Therefore, when I implement the public header and tail, I can use editor.CodeManager.getCode(component , 'html', {cssc: editor.CssComposer}); to replace the component, but I cannot use editor.CodeManager.getCode(component, 'css', {cssc: editor.CssComposer}) to replace the style, which will cause if If I operate (delete and add components) the components inside the head and tail multiple times, a lot of redundant styles will appear.
If is necessary to execute some code in order to reproduce the bug, paste it here below:
https://github.com/GrapesJS/grapesjs/issues/5263
I copying all matched styles ,so I can paste anywhere , even cross-browser paste, I find this to be extremely useful. When I delete a component, it does not remove the corresponding styles. This is a major issue, And when I copy and paste multiple times on the same website, it leads to a lot of redundant styles and easily causes style conflicts. so I can't simply expect those styles to be deleted. If possible, I would appreciate some suggestions.
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (2)
Extended idea from https://github.com/GrapesJS/grapesjs/issues/1855
Here it's explained how to create components with related styles https://grapesjs.com/docs/modules/Components.html#components-css
Only in that case, it would be safe for the editor to delete related styles.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5263
BUG: Deleting a component without deleting its corresponding style, will adding new components later cause style conflicts?
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? latest version of Chrome Reproducible demo...
Issue #4257
BUG: Background modification doesn't work for non-images
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v100 Reproducible demo link https:/...
Issue #4376
BUG: Unselected custom component will also listen to event 'styleable:change'
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? chrome 100 Reproducible demo link https://...
Issue #4249
BUG: image src won't change in exported HTML
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? chrome 100 Reproducible demo link https://...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.