skip to Main Content

I use GrapesJs and I want to update the html content of a component.
So I use the components method of a component : cmp.components('<h1 style="text-align:left">Hello</h1>').
But when I retrieve the html content of my component (cmp.toHTML()) the style is not here.

2

Answers


  1. Chosen as BEST ANSWER

    It was an issue with my grapesjs version. I was in 0.21.1 and the problem disappears using 0.21.5.


  2. You can replace cmp.components(…) with below code

    cmp.addComponent({
      tagName: 'h1',
      content: 'Hello', // Text inside component
      style: { text-align: 'right'},
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search