Issue #3119Opened November 6, 2020by makkaronis4e0 reactions

[QUESTION] How to create custom block made of grapesjs components?

Question

Hi, i want to have custom blocks made of grapesjs components.

I found solution how to add components: https://github.com/artf/grapesjs/issues/1334#issuecomment-411519845 but i'm struggling with adding CSS (eaiher as string or as object).

Answers (3)

artfNovember 9, 20200 reactions

You should be able to do something like this:

...
components: [
  { tagName: 'h1', components: 'Some <b>content</b>', },
  '<style>....</style>'
]
makkaronis4eNovember 9, 20200 reactions

@artf thanks it works, but i found bug there.

When you drop this block on canvas it works ok, but if you delete this element from canvas or clear whole canvas, then drop this block on canvas 2nd time, it will lose css. 2nd time, 3rd time.. doesnt matter, If you removed element from canvas once, it will lose style for next drops.

artfNovember 18, 20200 reactions

@makkaronis4e for such a case, I'd ask you a reproducible demo, please

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.