Issue #2917πŸ’¬ AnsweredOpened July 24, 2020by cartifon2 reactions

Style Manage does not hide style blocks

Quick answerby mcottret❀ 1

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

Read full answer below ↓

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)

mcottretβ€’ July 28, 2020

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 !

cartifonβ€’ July 28, 2020

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

cartifonβ€’ July 28, 2020

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.