Grapesjs: [QUESTION] Why stylable and unstylable props not working?

Created on 24 Sep 2019  路  3Comments  路  Source: artf/grapesjs

First of all, excellent project! I love it! Very complete all-around. I've been reading and re-reading the doc and it is a steep learning curve.

Anyway, I would like to serve a template to the user with restrictions in styling. I have been trying to use stylable and unstylable props like this:

<h1 data-gjs-unstylable={["float"]}>Title</h1>

But yet the float style shows in the style manager. Why?

Is there any other way to customize the style manager based on the component? For example, if #site-logo is selected, the style manager shows the asset uploader and a text field (fallback).

All 3 comments

Hi there! for your first problem: i think this property must be specified on your component type definition.
for your case it would be something like this:

 editor.DomComponents.addType('my-h1',{
            isComponent:(el) => {
              if(el.tagName === 'H1'){
                  return true
              }
            },
            model:{
                defaults:{
                    tagName:'h1',
                    unstylable:['float'],
                }
            }
        })

for your second problem, see if this can help you out.
cheers.

I see! Thanks man! I will give it a go. :)

@ColdTuna
You wrote the attribute incorrectly, it should be
<h1 data-gjs-unstylable="[\"float\"]">Title</h1>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andre2 picture andre2  路  3Comments

applibs picture applibs  路  3Comments

krunal039 picture krunal039  路  3Comments

alibouaziz picture alibouaziz  路  3Comments

kickbk picture kickbk  路  3Comments