FEAT: Adding options to properties list array in style manager
Question
Hi,
How can I add buildProps to properties list such that when an option is selected, the properties of that option will be displayed
An example of what I am trying to achieve on the flex property.
{
name: 'Layout',
open: true,
buildProps: ['display'],
properties: [
{
type: 'radio',
property: 'display',
list: [
{
title: 'Block',
name: '<span class="material-icons">calendar_view_day</span>',
value: 'block',
},
{
title: 'Flex',
name: '<span class="material-icons">calendar_view_week</span>',
value: 'flex',
buildProps: ['direction', 'align-content', 'align-items', 'align-self', 'justify-content', 'justify-items', 'justify-self'],
},
{
title: 'Grid',
name: '<span class="material-icons">grid_on</span>',
value: 'grid',
},
{
title: 'Inline-block',
name: '<span class="material-icons">padding</span>',
value: 'inline-block',
},
{
title: 'Inline',
name: '<span class="material-icons">horizontal_distribute</span>',
value: 'inline',
},
{
title: 'None',
name: '<span class="material-icons">visibility_off</span>',
value: 'none',
},
]
}
]
}

Answers (3)
I believe you can move the build props out of the properties list and still achieve what you're trying, the built in flex box related properties only show when a component has display: flex. It's also important to note that buildProps are just built in presets of inputs so they cannot be embedded into other inputs i.e the properties list
{
name: 'Layout',
open: true,
buildProps: ['display', 'direction', 'align-content', 'align-items', 'align-self', 'justify-content', 'justify-items', 'justify-self'],
properties: [
{
type: 'radio',
property: 'display',
list: [
{
title: 'Block',
name: '<span class="material-icons">calendar_view_day</span>',
value: 'block',
},
{
title: 'Flex',
name: '<span class="material-icons">calendar_view_week</span>',
value: 'flex',
},
{
title: 'Grid',
name: '<span class="material-icons">grid_on</span>',
value: 'grid',
},
{
title: 'Inline-block',
name: '<span class="material-icons">padding</span>',
value: 'inline-block',
},
{
title: 'Inline',
name: '<span class="material-icons">horizontal_distribute</span>',
value: 'inline',
},
{
title: 'None',
name: '<span class="material-icons">visibility_off</span>',
value: 'none',
},
]
}
]
}
Thank you. I tried it but the grid properties are not working. Might have to implement it manually but am not sure on how best to approach the problem.
There's no buildProps for grid properties so you'll have to build those from scratch, unfortunately docs don't have much info on custom properties probably you'll have to piece things together from the API reference https://grapesjs.com/docs/api/style_manager.html#stylemanager
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3123
FEAT: Add 'inline-flex' to display selector in Style Manager
What are you trying to add to GrapesJS? Display style inline-flex. Description: Currently the display selector of the Style Manager has onl...
Issue #3067
FEAT: remove 'display: block' inline style from Style Manager sectors and properties
What are you trying to add to GrapesJS? Improve visibility for Style Manager sectors and properties. Describe your feature request detailed...
Issue #2458
[Question] Setting of default value for css property in StyleManager config does not affect style of new added block?
I have a question. When css property is added to StyleManager configuration, for example I added color and set defaults to green (just for...
Issue #1614
[Bug]: adding css variables as style manager property
trying to add css variable to style manager causing error: Uncaught TypeError: Cannot read property 'toUpperCase' of undefined fiddle Am i...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.