[BUG] core:canvas-clear removes CSS Composer Styles
Question
I am using the core:canvas-clear command assigned to a button but when this is pressed, the styles setup through the CSS Composer are also being removed.
Grape Version: 0.14.15 Browser: Chrome 66.0.3359.139 (Official Build) (64-bit)
I have setup a script to recreate this at https://jsfiddle.net/pzacf7zg/
Reproduction steps: Drag a 'Foo Block' to the canvas Observer that the block is styled Click the Trash icon to clear the canvas Drag a new 'Foo Block' to the canvas Observe that the styling is not applied this time Refresh the page Observe that the previously un-styled element has become styled
Answers (2)
Hi @Lethrir as you can see this is the command and the behavour is totally intended. This also shows you how ridiculously the command is, so you can create your own via Commands API
editor.Commands.add('clear-html', () => editor.DomComponents.clear() );
I'd also suggest to create blocks with their own styles, just to keep thing modular and independent (in that case you'll gonna care less about document's styles)
blockManager.add('foo-block', {
label: 'Foo Block',
content: `<div class="foo">Foo</div>
<style>
.foo {
...
}
</style>`
});
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #895
[Bug] Update script won't refresh component script properly after autoloading component from html in localStorage
I'm using GrapesJS v0.14.5 in a local copy. OS: Ubuntu 16.04 LTS Browser: Chrome Version 64.0.3282.140 (Official Build) (64-bit) I think I...
Issue #809
[Bug]: CSS not added when blocks are drag and dropped after core:canvas-clear command invoked
I'm using grapesjs-blocks-basic plugin that has a number of column blocks. When I drag and drop these blocs onto the canvas they are displa...
Issue #1896
[BUG] Component from custom plugin is not recognized
OS: Windows 10 x64 Browser: Chrome 72.0.3626.121 x64 GrapesJS: v0.14.55 Hello, I have some custom components (bootstrap tabs) in a plugin,...
Issue #1513
[Bug] Duplicate CSS written under media queries
Hey @artf Great work on the project! I noticed something and I am able to reproduce it on my local machine too. Any css written under media...
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.