Grapesjs: Collapsed Category in Blocks when Grapes Editor is loaded

Created on 24 Oct 2017  路  7Comments  路  Source: artf/grapesjs

Hello,
I want all the categories listed in Blocks, must be initially in collapsed condition when the Grapes JS Editor is loaded. How can I do that? Also, if any one category is clicked, all others gets closed just like accordion. Is this possible?

image

Thanks!

outdated

Most helpful comment

Try with this

const categories = editor.BlockManager.getCategories();
categories.each(category => {
    category.set('open', false).on('change:open', opened => {
        opened.get('open') && categories.each(category => {
            category !== opened && category.set('open', false)
        })
    })
})

All 7 comments

Try with this

const categories = editor.BlockManager.getCategories();
categories.each(category => {
    category.set('open', false).on('change:open', opened => {
        opened.get('open') && categories.each(category => {
            category !== opened && category.set('open', false)
        })
    })
})

Wow man, Thanks a lot!

Sneak Peak:
image
:heart_eyes:

awesome 馃槏

i know we can add a class for font-awsome etc, but how did you changed it to show previews/custom thumbnails?

Give your custom class and set styles with the background image
Eg Code:

In bm.add block

attributes: {
  class: 'custom-icon flowz-callToAction-style-2',
  title: 'Style 2',
},

and in CSS

.custom-icon {
  padding:0 !important;
  width:100px !important;
  height:50px !important; 
  min-height: auto !important
}
.flowz-callToAction-style-2{
  background:url(screenshots/callToAction/2.jpg) no-repeat;
  background-size:100% 100%
}

Thanks, sometimes the answer's something so simple, you can't just get it on your head hahah :P

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

faizansaiyed picture faizansaiyed  路  3Comments

Snarkly picture Snarkly  路  3Comments

ionic666 picture ionic666  路  3Comments

YashPrince picture YashPrince  路  3Comments

desilvaNSP picture desilvaNSP  路  3Comments