grapesjs
grapesjs copied to clipboard
[QUESTION]: I'm trying to duplicate the page, but the styles are not geting applied due to the Ids, changes to -2,-3 at the end.
const duplicatePage = (editor) => {
let components = editor.getHtml();
let css = editor.getCss();
let newPage = editor.Pages.add({
styles: css,
component: components,
});
editor.Pages.select(newPage);
};
This is what my function looks like. I am trying duplicate the page, the HTML part is fine but as css is applied through ids, when a new page render the ids changes with -2 in end of them. Is there any to prevent it, or any other way of doing this?
@sanchit36 Hello, are you solving the problem? Can you tell how?
I also need to know, if this has been resolved and how.
Use this
const page = editor?.Pages.getSelected();
editor?.Pages.add({
id: (page.get('name') || page.id) + '-copy',
component: page.getMainComponent().clone()
}, { select: true });```
@vlont Thanks!