GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

[Question] Can multiple Webpage Builder tabs be opened? #2699

Closed dilancastillo closed 4 years ago

dilancastillo commented 4 years ago

In advance, thank you very much for this powerful tool, I want to comment that I have a website with several html views and access each one from the navbar, can I open several tabs of Webpage Builder to edit each one of these views separately ?

Thank you very much for your attention.

pouyamiralayi commented 4 years ago

Hi @dilancastillo here is how to implement a multi page scenario: #1331 comment Cheers!

dilancastillo commented 4 years ago

@pouyamiralayi thank you very much

dilancastillo commented 4 years ago

hey @pouyamiralayi , I wanted to tell you that I reviewed the comment you recommended and I have a problem, I did a test by placing a simple component but it does not appear on the canvas, how should I put html and css components?

const editor = grapesjs.init({ height: '100%', fromElement: true, showOffsets: 1, noticeOnUnload: 0, allowScripts: 1, container: '#gjs', current: 1, pages: [ { components: [<div><h1>Hola mundo</h1></div>], style: [] }, { components: [], style: [] }, ], plugins: ['gjs-preset-webpage'], pluginsOpts: { 'gjs-preset-webpage': {

        }
    },
    storageManager: {
        id: 'gjs-',
        type: 'local',
        autosave: true,
        autoload: false,
        stepsBeforeSave: 1,
    },
});
const currentPage = pages[currentIndex];
currentPage.components = editor.getComponents();
currentPage.style = editor.getStyle();

const nextPage = pages[nextIndex];
editor.setComponents(nextPage.components);
editor.setStyle(nextPage.style);
dilancastillo commented 4 years ago

I would greatly appreciate your help

pouyamiralayi commented 4 years ago

Hi @dilancastillo the related approach should not be placed in your initialization config. pages object is a proposed data structure which you should consider in your environment, like a window.pages global variable or etc. Take a look at my own implementation which is using localStorage. Cheers!

dilancastillo commented 4 years ago

Hello @pouyamiralayi , your explanation is very helpful and I thank you very much for the support