All Projects → Ju99ernaut → grapesjs-template-manager

Ju99ernaut / grapesjs-template-manager

Licence: MIT License
Template and page manager for grapesjs

Programming Languages

javascript
184084 projects - #8 most used programming language
SCSS
7915 projects
HTML
75241 projects

Projects that are alternatives of or similar to grapesjs-template-manager

lockbox-datastore
Experimental Data Storage module for Firefox Lockbox project, not being actively developed
Stars: ✭ 26 (-23.53%)
Mutual labels:  storage
ddrive
A lightweight cloud storage system using discord as storage device written in nodejs
Stars: ✭ 25 (-26.47%)
Mutual labels:  storage
ltss
Long time state storage (LTSS) custom component for Home Assistant using Timescale DB
Stars: ✭ 34 (+0%)
Mutual labels:  storage
eloquent-mongodb-repository
Eloquent MongoDB Repository Implementation
Stars: ✭ 18 (-47.06%)
Mutual labels:  storage
kubernetes
Quobyte / Kubernetes integration (DEPRECATED - use Quobyte CSI)
Stars: ✭ 24 (-29.41%)
Mutual labels:  storage
benji
📁 This library is a Scala reactive DSL for object storage (e.g. S3/Amazon, S3/CEPH, Google Cloud Storage).
Stars: ✭ 18 (-47.06%)
Mutual labels:  storage
GekkoFS
Ephemeral distributed filesystem build up from the local storage of several nodes. It is an evolution of AdaFS done inside the NGIO project by BSC in collaboration with JGU.
Stars: ✭ 34 (+0%)
Mutual labels:  storage
ioBroker.history
manages state history
Stars: ✭ 26 (-23.53%)
Mutual labels:  storage
carina
Carina: an high performance and ops-free local storage for kubernetes
Stars: ✭ 256 (+652.94%)
Mutual labels:  storage
ceph-cheatsheet
All™ you ever wanted to know about operating a Ceph cluster!
Stars: ✭ 84 (+147.06%)
Mutual labels:  storage
arc gcs
Provides an Arc backend for Google Cloud Storage
Stars: ✭ 48 (+41.18%)
Mutual labels:  storage
jiva
CAS Data Engine - iSCSI Distributed Block Storage Controller built-in Go
Stars: ✭ 121 (+255.88%)
Mutual labels:  storage
nativestor
NativeStor provide kubernetes local storage which is light weight and high performance
Stars: ✭ 20 (-41.18%)
Mutual labels:  storage
hermitage-skeleton
Hermitage Skeleton
Stars: ✭ 16 (-52.94%)
Mutual labels:  storage
aws-backup-automation
AWS CloudFormation templates and Python code for AWS blog post on how to automate centralized backup at scale across AWS services using AWS Backup.
Stars: ✭ 12 (-64.71%)
Mutual labels:  storage
Kvpbase
Scalable, simple RESTful object storage platform, written in C#
Stars: ✭ 43 (+26.47%)
Mutual labels:  storage
nft.storage
😋 Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin.
Stars: ✭ 309 (+808.82%)
Mutual labels:  storage
aus driver amazon s3
Provides a TYPO3 FAL driver for the Amazon Web Service S3
Stars: ✭ 15 (-55.88%)
Mutual labels:  storage
elemental-lowcode
Elemental lowcode development platform.
Stars: ✭ 44 (+29.41%)
Mutual labels:  storage
fbind
A versatile Android mounting utility for folders, EXT4 images, LUKS/LUKS2 encrypted volumes, regular partitions and more.
Stars: ✭ 42 (+23.53%)
Mutual labels:  storage

Grapesjs Project Manager

Requires GrapesJS v0.17.3 or higher.

Project, template and page manager for grapesjs. This version makes use of the PageManager and has different plugin and package name, the previous version which doesn't make use of the PageManager can be found here.

Project Project settings
Screenshot (224) Screenshot (226)
Pages Page settings
Screenshot (225) Screenshot (227)

HTML

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

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

JS

const editor = grapesjs.init({
  container: '#gjs',
  height: '100%',
  fromElement: true,
  pageManager: true, // This should be set to true
  storageManager:  {
    type: 'indexeddb',
    // ...
  },
  plugins: ['grapesjs-project-manager'],
});

// Running commands from panels
const pn = editor.Panels;
pn.addButton('options', {
    id: 'open-templates',
    className: 'fa fa-folder-o',
    attributes: {
        title: 'Open projects and templates'
    },
    command: 'open-templates', //Open modal 
});
pn.addButton('views', {
    id: 'open-pages',
    className: 'fa fa-file-o',
    attributes: {
        title: 'Take Screenshot'
    },
    command: 'open-pages',
    togglable: false
});

CSS

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

Summary

  • Plugin name: grapesjs-project-manager
  • Commands
    • open-templates
    • open-pages
    • open-settings
    • get-uuidv4
    • take-screenshot
    • save-as-template
    • delete-template
  • Storages
    • indexeddb
    • firestore
    • rest-api

Options

Option Description Default
dbName Database name gjs
objectStoreName Collection name templates
loadFirst Load first template in storage true
components Default components since fromElement is not supported undefined
style Default style since fromElement is not supported undefined
indexeddbVersion IndexedDB schema version 5
onDelete On successful template deletion Function(Check source)
onDeleteError On error template deletion Function(Check source)
onScreenShotError On error capturing screenshot Function(Check source)
quality Generated screenshot quality .01
mdlTitle Modal title Project Manager
apiKey Firebase API key
authDomain Firebase Auth domain
projectId Cloud Firestore project ID
firebaseConfig Extra firebase app credentials {}
enableOffline Enable Firestore support for offline data persistence true
settings Firestore database settings { timestampsInSnapshots: true }
uuidInPath Add uuid as path parameter on store for rest-api(useful for validation) true
size Display estimated project sizes true
currentPageOpen Send feedback when open is clicked on current page check source
ì18n I18n object containing language more info {}
  • Setting loadFirst to false prevents overwritting the contents of the editor with the contents of the first template in storage.
  • Only use options for Firebase when using Cloud Firestore storage.
  • dbName and indexeddbVersion only apply to indexddb storage.
  • objectStoreName acts as collection name for both firestore and indexeddb.
  • When uuidInPath is set to false the store request will be http://endpoint/store/ instead of http://endpoint/store/{uuid}

Local/IndexedDB

window.editor = grapesjs.init({
  container: '#gjs',
  // ...
  pageManager: true,
  storageManager:  {
    type: 'indexeddb'
  },
  plugins: ['grapesjs-project-manager'],
  pluginsOpts: {
    'grapesjs-project-manager': { /* Options */ }
  }
});

Firestore

Tested on firebase v8+. Firebase v9+ not yet supported.

Configure firestore access rules for your app. Add libraries to head of document:

<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.3.1/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.3.1/firebase-firestore.js"></script>

Add credentials:

window.editor = grapesjs.init({
  container: '#gjs',
  // ...
  pageManager: true,
  storageManager:  {
    type: 'firestore'
  },
  plugins: ['grapesjs-project-manager'],
  pluginsOpts: {
    'grapesjs-project-manager': { 
      // Firebase API key
      apiKey: 'FIREBASE_API_KEY',
      // Firebase Auth domain
      authDomain: 'app-id-00a00.firebaseapp.com',
      // Cloud Firestore project ID
      projectId: 'app-id-00a00',
    }
  }
});

Remote/REST-API

Example backend https://github.com/Ju99ernaut/gjs-api

window.editor = grapesjs.init({
  container: '#gjs',
  // ...
  pageManager: true,
  storageManager:  {
    type: 'rest-api',
    // the URIs below can be the same depending on your API design 
    urlStore: 'https://endpoint/store/',// POST
    urlLoad: 'https://endpoint/load/',// GET
    urlDelete: 'https://endpoint/delete/',// DELETE
    params: { _some_token: '...' },
    headers: { Authorization: 'Basic ...' }
  },
  plugins: ['grapesjs-project-manager'],
  pluginsOpts: {
    'grapesjs-project-manager': { /* options */ }
  }
});

The backend schema can be something like:

GET https://api/templates/ load all templates

Returns

[
    {
      "id": "UUIDv4",
      "name": "Page name",
      "template": false,
      "thumbnail": "",
      "description": "No description",
      "gjs-assets": "[]",
      "gjs-pages": "[]",
      "gjs-styles": "[]",
      "updated_at": ""
    }
]

POST https://api/templates/{idx: UUIDv4} store template

Expects

{
  "id": "UUIDv4",
  "name": "Page name",
  "template": false,
  "thumbnail": "",
  "description": "No description",
  "gjs-assets": "[]",
  "gjs-pages": "[]",
  "gjs-styles": "[]",
  "updated_at": ""
}

GET https://api/templates/{idx: UUIDv4} load template

Returns

{
  "id": "UUIDv4",
  "name": "Page name",
  "template": false,
  "thumbnail": "",
  "description": "No description",
  "gjs-assets": "[]",
  "gjs-pages": "[]",
  "gjs-styles": "[]",
  "updated_at": ""
}

DELETE https://api/templates/{idx: UUIDv4} delete template

Which would have the following setup:

window.editor = grapesjs.init({
  container: '#gjs',
  // ...
  storageManager:  {
    type: 'rest-api',
    // the URIs below can be the same depending on your API design 
    urlStore: 'https://api/templates/',// POST
    urlLoad: 'https://api/templates/',// GET
    urlDelete: 'https://api/templates/',// DELETE
  },
  plugins: ['grapesjs-template-manager'],
  pluginsOpts: {
    'grapesjs-template-manager': { /* options */ }
  }
});

All the fields are generated from the editor so you just need to setup your API to receive and return data in that format. I'd recommend you check the network tab so you get a more accurate format for the payloads.

Download

  • CDN
    • https://unpkg.com/grapesjs-project-manager
  • NPM
    • npm i grapesjs-project-manager
  • GIT
    • git clone https://github.com/Ju99ernaut/grapesjs-template-manager.git

Usage

Directly in the browser

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/grapesjs-project-manager/dist/grapesjs-project-manager.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-project-manager.min.js"></script>

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

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

Modern javascript

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

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

Development

Clone the repository

$ git clone https://github.com/Ju99ernaut/grapesjs-template-manager.git
$ cd grapesjs-template-manager

Install dependencies

$ npm i

Build css or watch scss

$ npm run build:css

OR

$ npm run watch:scss

Start the dev server

$ npm start

Build the source

$ npm run build

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].