# grapesjs-plugin-export

> Export GrapesJS templates to ZIP

Latest version **1.0.12** (published 2023-06-12) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install grapesjs-plugin-export
pnpm add grapesjs-plugin-export
yarn add grapesjs-plugin-export
bun add grapesjs-plugin-export
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2023-06-12 |
| First published | 2016-08-09 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 357 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 85 |
| Author | Artur Arseniev |
| Maintainers | artf |
| Keywords | grapesjs, template, export, zip |

## Links

- npm: https://www.npmjs.com/package/grapesjs-plugin-export
- Repository: https://github.com/GrapesJS/export
- Homepage: https://github.com/GrapesJS/export#readme
- Issues: https://github.com/GrapesJS/export/issues
- npm.io page: https://npm.io/package/grapesjs-plugin-export

## Dependencies (1)

- [@types/file-saver](https://npm.io/package/@types/file-saver.md) ^2.0.5

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.12 (latest) — 2023-06-12
- 1.0.11 — 2022-08-04
- 1.0.7 — 2018-09-30
- 1.0.5 — 2018-09-20
- 0.1.5 — 2017-11-19
- 0.1.2 — 2016-08-30
- 0.1.1 — 2016-08-09

## 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 => `<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
```html
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-plugin-export.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
  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');
</script>
```

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

---
_Source: https://npm.io/package/grapesjs-plugin-export · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
