Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

375
Visualizações
I failed to make blocks ordering with BlockManager

Using grapesjs with custom blocks I need

  1. Collapse all, but extend only 1 block
  2. to order them . I managed to make point 1), but searching for decision of point2) I found this branch : https://github.com/artf/grapesjs/issues/780

and I do it as with timer:

let has_opened_block= false
setTimeout(() => {
    console.log('setTimeout::')
    var closedBlocks = ['Templates', 'Blocks', 'Images', 'Basic', 'Extra', 'forms'];  // I need to collapse these blocks and move them to the bottom


    gjsEditor.Blocks.getCategories().forEach(ct => {

        ct.set('open', false);
        if(!has_opened_block) {  // to open only 1st block which is not in closedBlocks                    
            if (!closedBlocks.includes(ct.id)) {
                has_opened_block = true
                ct.set('open', true);
            }
        }
    });



    const bm = gjsEditor.BlockManager;
    var blocksToRender= [ // I want to see these blocks at top
        bm.get('h2'),
        bm.get('d5'),
        bm.get('f4')
    ]
    for (var i=0; i< closedBlocks.length;i++) { // I want to see all blocks which are not in blocksToRender at bottom
        blocksToRender[blocksToRender.length]= bm.get(closedBlocks[i])
    }
    bm.render( blocksToRender )



}, 8000)

But as result I see 9 blocks, but which looks like empty : https://prnt.sc/86w-dqziZakn

Also I can not drag and drop content of these blocks - nothing is dropped.

What is wrong in my blocks ordering ?

Thanks!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda