Issue #2079💬 AnsweredOpened June 15, 2019by froderf0 reactions

Make Css style to not be returned

Quick answerby froderf

Read full answer below ↓

Question

How to prevent the CSS of a block/component to be not returned when we used editor.getCss();

it's like https://grapesjs.com/docs/api/component.html#tohtml

but should be something like toCSS inside custom component

Answers (3)

froderfJune 15, 2019
toHTML() {
          return '';
        },
        toCSS() {
          return '';
        },
artfJune 15, 2019

The component has the getStyle method which returns an object like this { color: 'red'}. If the returning object is empty no rule will be created in the code, but the same is applied in the canvas, so you won't see your styles. What you can do is create a custom component like this: So before expor...

froderfJuly 23, 2019

@artf the solution "getStyle()" that you provided can only be applied to what if this component has a class of "isNewComponent" and has style of is possible for the editor to not include the above style (with a class) when we call editor.getCss();

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.