Browse Source

Add getProject / loadProject methods

pull/4214/head
Artur Arseniev 5 years ago
parent
commit
72e913ae19
  1. 19
      src/editor/index.js
  2. 16
      src/storage_manager/config/config.js

19
src/editor/index.js

@ -439,12 +439,16 @@ export default (config = {}, opts = {}) => {
}, },
/** /**
* Get the JSON data object, which could be stored and loaded back with `editor.loadData(json)` * Get the JSON project data, which could be stored and loaded back with `editor.loadProject(json)`
* @returns {Object} * @returns {Object}
* @example * @example
* console.log(editor.storeData()); * console.log(editor.getProject());
* // { pages: [...], styles: [...], ... } * // { pages: [...], styles: [...], ... }
*/ */
getProject() {
return em.storeData();
},
storeData() { storeData() {
return em.storeData(); return em.storeData();
}, },
@ -459,12 +463,15 @@ export default (config = {}, opts = {}) => {
}, },
/** /**
* Load data from the JSON data object * Load data from the JSON project
* @param {Object} data Data to load * @param {Object} data Project to load
* @return {Object} Loaded object
* @example * @example
* editor.loadData({ pages: [...], styles: [...], ... }) * editor.loadProject({ pages: [...], styles: [...], ... })
*/ */
loadProject(data) {
return em.loadData(data);
},
loadData(data) { loadData(data) {
return em.loadData(data); return em.loadData(data);
}, },

16
src/storage_manager/config/config.js

@ -3,10 +3,10 @@ export default {
id: 'gjs-', id: 'gjs-',
// Enable/Disable autosaving // Enable/Disable autosaving
autosave: 1, autosave: true,
// Indicates if load data inside editor after init // Indicates if load data inside editor after init
autoload: 1, autoload: true,
// Indicates which storage to use. Available: local | remote // Indicates which storage to use. Available: local | remote
type: 'local', type: 'local',
@ -16,20 +16,20 @@ export default {
stepsBeforeSave: 1, stepsBeforeSave: 1,
//Enable/Disable components model (JSON format) //Enable/Disable components model (JSON format)
storeComponents: 1, storeComponents: true,
//Enable/Disable styles model (JSON format) //Enable/Disable styles model (JSON format)
storeStyles: 1, storeStyles: true,
//Enable/Disable saving HTML template //Enable/Disable saving HTML template
storeHtml: 1, storeHtml: true,
//Enable/Disable saving CSS template //Enable/Disable saving CSS template
storeCss: 1, storeCss: true,
// ONLY FOR LOCAL STORAGE // ONLY FOR LOCAL STORAGE
// If enabled, checks if browser supports Local Storage // If enabled, checks if browser supports Local Storage
checkLocal: 1, checkLocal: true,
// ONLY FOR REMOTE STORAGE // ONLY FOR REMOTE STORAGE
// Custom parameters to pass with the remote storage request, eg. csrf token // Custom parameters to pass with the remote storage request, eg. csrf token
@ -63,5 +63,5 @@ export default {
// currentOpts => { // currentOpts => {
// return currentOpts.method === 'post' ? { method: 'patch' } : {}; // return currentOpts.method === 'post' ? { method: 'patch' } : {};
// } // }
fetchOptions: '' fetchOptions: '',
}; };

Loading…
Cancel
Save