Issue #2917Opened July 24, 2020by cartifon2 reactions

BUG: Style Manage does not hide style blocks

Question

Hey @artf, I'm trying to hide style properties based on the selected element. for example, when I drag and drop an image on my GrapesJS, I would like to show only the width property, but the unstylable/stylable attributes are not working.

Version: "grapesjs": "^0.16.18",

Are you able to reproduce the bug from the demo?

[X] Yes [ ] No

What is the expected behavior? To hide the properties that are not on my array

What is the current behavior? It is not hiding anything.

Are you able to attach screenshots, screencasts or a live demo?

[X] Yes (attach) [ ] No

https://stackblitz.com/edit/grapesjs-stylable

Answers (3)

mcottretJuly 28, 20201 reactions

Hi @cartifon !

I believe the stylable attribute only works on Components & not Blocks as in your example. The following should do the trick:

blocks: [
    {
        id: "image",
        label: "Image",
        // Select the component once it's dropped
        select: true,
        // You can pass components as a JSON instead of a simple HTML string,
        // in this case we also use a defined component type `image`
        content: { type: "image", stylable: ['width'] },
        // This triggers `active` event on dropped components and the `image`
        // reacts by opening the AssetManager
        activate: true
    }
]

Cheers !

cartifonJuly 28, 20201 reactions

I have another question, would the unstylable work in the same way?

cartifonJuly 28, 20200 reactions

Hey @mcottret, thanks for the help. Yes, it does work with that! Maybe the documentation should be more clear on that.

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.