Issue #1115Opened May 15, 2018by Lethrir1 reactions

[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)

artfMay 18, 20181 reactions

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>`
});
lock[bot]September 17, 20190 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.