Coder Social home page Coder Social logo

dipaksarkar / grapesjs-templates Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.28 MB

Simple projects and templates manage plugin for GrapesJS

License: MIT License

JavaScript 96.54% HTML 2.16% SCSS 1.30%
grapesjs grapesjs-builder grapesjs-editor grapesjs-plugin grapesjs-pages

grapesjs-templates's Introduction

Grapesjs Templates

Simple projects and templates manage plugin for GrapesJS

npm Version npm Downloads github Stars Bundlephobia License

DEMO

HTML

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-templates"></script>

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

JS

const editor = grapesjs.init({
	container: '#gjs',
  height: '100%',
  fromElement: true,
  storageManager: false,
  plugins: ['grapesjs-templates'],
  pluginsOpts: {
    'grapesjs-templates': { 
      templates: 'http://localhost:3000/templates',
      projects: 'http://localhost:3000/projects',
    }
  }
});

CSS

body, html {
  margin: 0;
  height: 100%;
}

Summary

Plugin name: grapesjs-templates

Options

Option Description Default
templates API endpoint for templates. null
projects API endpoint for projects. null
onLoad Method to load projects or templates. undefined
onStore Method to store data. undefined
onDelete Method to delete a project. undefined

Let me know if you need further assistance!

Option Details

  • templates:

    • Type: String or null
    • Description: API endpoint for templates.
    • Default: null
  • projects:

    • Type: String or null
    • Description: API endpoint for projects.
    • Default: null
  • onLoad:

    • Type: Function
    • Description: Method to load projects or templates.
    • Default: undefined
    • Parameters:
      • type (String): Type of data to load (templates or projects).
    • Returns:
      • Array or null: Array of loaded data or null if not found.
  • onStore:

    • Type: Function
    • Description: Method to store data.
    • Default: undefined
    • Parameters:
      • payload (Object): Data to be stored.
    • Returns:
      • Boolean: true if stored successfully, false otherwise.
  • onDelete:

    • Type: Function
    • Description: Method to delete a project.
    • Default: undefined
    • Parameters:
      • id (String): ID of the project to delete.
    • Returns:
      • Boolean: true if deletion is successful, false otherwise.

Download

  • CDN
    • https://unpkg.com/grapesjs-templates
  • NPM
    • npm i grapesjs-templates
  • GIT
    • git clone https://github.com/dipaksarkar/grapesjs-templates.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-templates.min.js"></script>

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

<script type="text/javascript">
  var editor = grapesjs.init({
      container: '#gjs',
      // ...
      plugins: ['grapesjs-templates'],
      pluginsOpts: {
        'grapesjs-templates': { /* options */ }
      }
  });
</script>

Modern javascript

import grapesjs from 'grapesjs';
import plugin from 'grapesjs-templates';
import 'grapesjs/dist/css/grapes.min.css';

const editor = grapesjs.init({
  container : '#gjs',
  // ...
  plugins: [plugin],
  pluginsOpts: {
    [plugin]: { /* options */ }
  }
  // or
  plugins: [
    editor => plugin(editor, { /* options */ }),
  ],
});

Development

Clone the repository

$ git clone https://github.com/dipaksarkar/grapesjs-templates.git
$ cd grapesjs-templates

Install dependencies

$ npm i

Start the dev server

$ npm start

Build the source

$ npm run build

License

MIT

grapesjs-templates's People

Contributors

dipaksarkar avatar

Watchers

 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.