Coder Social home page Coder Social logo

chenmingqiang23 / grapesjs-export Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grapesjs/export

0.0 0.0 0.0 1.09 MB

Export GrapesJS templates in a zip archive

License: BSD 3-Clause "New" or "Revised" License

TypeScript 84.94% HTML 15.06%

grapesjs-export's Introduction

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

<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

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

$ git clone https://github.com/GrapesJS/export.git.git
$ cd grapesjs-plugin-export

Install it

$ npm i

Start the dev server

$ npm start

License

BSD 3-Clause

grapesjs-export's People

Contributors

artf avatar tomhatzer avatar snyk-bot avatar visudade avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.