https://github.com/grapesjs/export
Export GrapesJS templates in a zip archive
https://github.com/grapesjs/export
Last synced: about 1 year ago
JSON representation
Export GrapesJS templates in a zip archive
- Host: GitHub
- URL: https://github.com/grapesjs/export
- Owner: GrapesJS
- License: bsd-3-clause
- Created: 2016-08-08T21:23:17.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-09-17T21:45:01.000Z (almost 3 years ago)
- Last Synced: 2024-05-16T01:02:36.004Z (about 2 years ago)
- Language: TypeScript
- Homepage:
- Size: 1.06 MB
- Stars: 69
- Watchers: 6
- Forks: 66
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [GrapesJS Export](http://grapesjs.com)
This plugin adds the possibility to export template in a zip archive.
Demo: http://grapesjs.com/demo.html
## Summary
* Plugin name: `grapesjs-plugin-export`
* Commands: `gjs-export-zip`
## Options
|Option|Description|Default|
|-|-|-
| `addExportBtn` | Add a button inside the export dialog | `true` |
| `btnLabel` | Label to the export button | `Export to ZIP` |
| `filenamePfx` | ZIP filename prefix | `grapesjs_template` |
| `filename` | 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 => `${ed.getHtml()}`
}
`
| `{ ...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
```html
var editor = grapesjs.init({
container : '#gjs',
// ...
plugins: ['grapesjs-plugin-export'],
pluginsOpts: {
'grapesjs-plugin-export': { /* options */ }
}
});
// You can also call the command wherever you want in this way
editor.runCommand('gjs-export-zip');
```
Modern javascript
```js
import grapesjs from 'grapesjs';
import thePlugin from 'grapesjs-plugin-export';
const editor = grapesjs.init({
container : '#gjs',
// ...
plugins: [thePlugin],
pluginsOpts: {
[thePlugin]: { /* options */ }
}
// or
plugins: [
editor => thePlugin(editor, { /* options */ }),
],
});
```
## Development
Clone the repository
```sh
$ git clone https://github.com/GrapesJS/export.git.git
$ cd grapesjs-plugin-export
```
Install it
```sh
$ npm i
```
Start the dev server
```sh
$ npm start
```
## License
BSD 3-Clause