Issue #2638💬 AnsweredOpened March 11, 2020by orionseye1 reactions

Adding new category for later use (without blocks yet)

快速解答by artf1

Once the category is created you can use its ID in this way category: 'some-cat'

Read full answer below ↓

Question

How do i define a new category, to use for later blocks i create ..without yet assigning a block to it.. and keep it closed by default?

I mean this one can be used to for a block added, but what if i have multiple blocks to add to same category again and again? Is there a way to have the category id, label, open state defined elswhere, instead repeating the process?

editor.BlockManager.add('block-id', {
    ...
    label: 'Label content',
    category: {
        id: 'some-cat', 
        label: 'Some cat', 
        open: true
    }
})

To collapse the default ones i used editor.BlockManager.getCategories().each(ctg => ctg.set('open', false))

Answers (1)

artfMarch 18, 2020

Once the category is created you can use its ID in this way category: 'some-cat'

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.