grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

BUG: Style Manage does not hide style blocks

Open cartifon opened this issue 6 years ago • 4 comments

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

cartifon avatar Jul 24 '20 19:07 cartifon

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 !

mcottret avatar Jul 28 '20 12:07 mcottret

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

cartifon avatar Jul 28 '20 13:07 cartifon

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

cartifon avatar Jul 28 '20 14:07 cartifon

@cartifon yeah sure, the content accepts the Component Definition so it'll work with any component property

artf avatar Aug 25 '20 15:08 artf