Issue #780💬 AnsweredOpened January 19, 2018by JulyanoF2 reactions

How to reorder BlockManager Blocks?

快速解答by artf1

Don't remove them, just update and render

Read full answer below ↓

Question

I'm trying to reorder these blocks, removing all of them from BlockManager and adding one by one in my order preference, but it's still not working.

Someone knows what is the rule to ordenate them?

Answers (3)

artfJanuary 22, 2018

Don't remove them, just update and render

const bm = editor.BlockManager;
const colmBlock = bm.get('column3').set({
	label: 'Clm label'
})
bm.render([
	colmBlock,
	//...
]);
chiqui3dJanuary 29, 2018

@artf It would not be ideal to add an order option like this for blocks and panels.

 bm.add('section-hero', {
        label: 'Hero section',
         order:1, // 1,2,3,4...
        category: 'Sections',
        content: '<header class="header-banner"> <div class="container-width">' +
            '<div class="logo-container"><div class="logo">GrapesJS</div></div>' +
            '<nav class="navbar">' +
            '<div class="menu-item">BUILDER</div><div class="menu-item">TEMPLATE</div><div class="menu-item">WEB</div>' +
            '</nav><div class="clearfix"></div>' +
            '<div class="lead-title">Build your templates without coding</div>' +
            '<div class="lead-btn">Try it now</div></div></header>',
        attributes: { class: 'gjs-fonts gjs-f-hero' }
    });
artfJanuary 19, 2018

@JulyanoF you can re-render them in this way

const bm = editor.BlockManager;
bm.render([
	bm.get('column3'), 
	bm.get('column2'), 
	bm.get('column1')
]);

or, if it's just about reordering inside their categories, you can rely on order css property as its container is flex

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 →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.