You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use a function to generate the filename, eg. filename: editor => 'my-file.zip',
null
root
Use the root object to create the folder structure of your zip (async functions are supported), eg. `
{
css: {
'style.css': ed => ed.getCss(),
'some-file.txt': 'My custom content',
},
img: async ed => {
const images = await fetchImagesByStructue(ed.getComponents());
return images;
// Where `images` is an object like this:
// { 'img1.png': '...png content', 'img2.jpg': '...jpg content' }
},
'index.html': ed => `<body>${ed.getHtml()}</body>`
}
|{ ...check the source }` |
Download
CDN
https://unpkg.com/grapesjs-plugin-export
NPM
npm i grapesjs-plugin-export
GIT
git clone https://github.com/GrapesJS/export.git
Usage
Directly in the browser
<linkhref="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/><scriptsrc="https://unpkg.com/grapesjs"></script><scriptsrc="path/to/grapesjs-plugin-export.min.js"></script><divid="gjs"></div><scripttype="text/javascript">vareditor=grapesjs.init({container : '#gjs',// ...plugins: ['grapesjs-plugin-export'],pluginsOpts: {'grapesjs-plugin-export': {/* options */}}});// You can also call the command wherever you want in this wayeditor.runCommand('gjs-export-zip');</script>