|
|
|
@ -1,24 +1,49 @@ |
|
|
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> |
|
|
|
|
|
|
|
## index |
|
|
|
## StorageManager |
|
|
|
|
|
|
|
Before using methods you should get first the module from the editor instance, in this way: |
|
|
|
You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object][1] |
|
|
|
|
|
|
|
```js |
|
|
|
var storageManager = editor.StorageManager; |
|
|
|
const editor = grapesjs.init({ |
|
|
|
storageManager: { |
|
|
|
// options |
|
|
|
} |
|
|
|
}) |
|
|
|
``` |
|
|
|
|
|
|
|
Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance |
|
|
|
|
|
|
|
```js |
|
|
|
const storageManager = editor.StorageManager; |
|
|
|
``` |
|
|
|
|
|
|
|
- [getConfig][2] |
|
|
|
- [isAutosave][3] |
|
|
|
- [setAutosave][4] |
|
|
|
- [getStepsBeforeSave][5] |
|
|
|
- [setStepsBeforeSave][6] |
|
|
|
- [setStepsBeforeSave][6] |
|
|
|
- [getStorages][7] |
|
|
|
- [getCurrent][8] |
|
|
|
- [getCurrentStorage][9] |
|
|
|
- [setCurrent][10] |
|
|
|
- [add][11] |
|
|
|
- [get][12] |
|
|
|
- [store][13] |
|
|
|
- [load][14] |
|
|
|
|
|
|
|
## getConfig |
|
|
|
|
|
|
|
Get configuration object |
|
|
|
|
|
|
|
Returns **[Object][1]** |
|
|
|
Returns **[Object][15]** |
|
|
|
|
|
|
|
## isAutosave |
|
|
|
|
|
|
|
Checks if autosave is enabled |
|
|
|
|
|
|
|
Returns **[Boolean][2]** |
|
|
|
Returns **[Boolean][16]** |
|
|
|
|
|
|
|
## setAutosave |
|
|
|
|
|
|
|
@ -26,7 +51,7 @@ Set autosave value |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `v` **[Boolean][2]** |
|
|
|
- `v` **[Boolean][16]** |
|
|
|
|
|
|
|
Returns **this** |
|
|
|
|
|
|
|
@ -34,7 +59,7 @@ Returns **this** |
|
|
|
|
|
|
|
Returns number of steps required before trigger autosave |
|
|
|
|
|
|
|
Returns **[number][3]** |
|
|
|
Returns **[number][17]** |
|
|
|
|
|
|
|
## setStepsBeforeSave |
|
|
|
|
|
|
|
@ -42,7 +67,7 @@ Set steps required before trigger autosave |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `v` **[number][3]** |
|
|
|
- `v` **[number][17]** |
|
|
|
|
|
|
|
Returns **this** |
|
|
|
|
|
|
|
@ -52,10 +77,10 @@ Add new storage |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `id` **[string][4]** Storage ID |
|
|
|
- `storage` **[Object][1]** Storage wrapper |
|
|
|
- `storage.load` **[Function][5]** Load method |
|
|
|
- `storage.store` **[Function][5]** Store method |
|
|
|
- `id` **[string][18]** Storage ID |
|
|
|
- `storage` **[Object][15]** Storage wrapper |
|
|
|
- `storage.load` **[Function][19]** Load method |
|
|
|
- `storage.store` **[Function][19]** Store method |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -87,21 +112,21 @@ Returns storage by id |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `id` **[string][4]** Storage ID |
|
|
|
- `id` **[string][18]** Storage ID |
|
|
|
|
|
|
|
Returns **([Object][1] | null)** |
|
|
|
Returns **([Object][15] | null)** |
|
|
|
|
|
|
|
## getStorages |
|
|
|
|
|
|
|
Returns all storages |
|
|
|
|
|
|
|
Returns **[Array][6]** |
|
|
|
Returns **[Array][20]** |
|
|
|
|
|
|
|
## getCurrent |
|
|
|
|
|
|
|
Returns current storage type |
|
|
|
|
|
|
|
Returns **[string][4]** |
|
|
|
Returns **[string][18]** |
|
|
|
|
|
|
|
## setCurrent |
|
|
|
|
|
|
|
@ -109,7 +134,7 @@ Set current storage type |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `id` **[string][4]** Storage ID |
|
|
|
- `id` **[string][18]** Storage ID |
|
|
|
|
|
|
|
Returns **this** |
|
|
|
|
|
|
|
@ -119,8 +144,8 @@ Store key-value resources in the current storage |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `data` **[Object][1]** Data in key-value format, eg. {item1: value1, item2: value2} |
|
|
|
- `clb` **[Function][5]** Callback function |
|
|
|
- `data` **[Object][15]** Data in key-value format, eg. {item1: value1, item2: value2} |
|
|
|
- `clb` **[Function][19]** Callback function |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -128,7 +153,7 @@ Store key-value resources in the current storage |
|
|
|
storageManager.store({item1: value1, item2: value2}); |
|
|
|
``` |
|
|
|
|
|
|
|
Returns **([Object][1] | null)** |
|
|
|
Returns **([Object][15] | null)** |
|
|
|
|
|
|
|
## load |
|
|
|
|
|
|
|
@ -136,8 +161,8 @@ Load resource from the current storage by keys |
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
- `keys` **([string][4] \| [Array][6]<[string][4]>)** Keys to load |
|
|
|
- `clb` **[Function][5]** Callback function |
|
|
|
- `keys` **([string][18] \| [Array][20]<[string][18]>)** Keys to load |
|
|
|
- `clb` **[Function][19]** Callback function |
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
@ -156,14 +181,42 @@ Get current storage |
|
|
|
|
|
|
|
Returns **Storage** |
|
|
|
|
|
|
|
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|
|
|
[1]: https://github.com/artf/grapesjs/blob/master/src/storage_manager/config/config.js |
|
|
|
|
|
|
|
[2]: #getconfig |
|
|
|
|
|
|
|
[3]: #isautosave |
|
|
|
|
|
|
|
[4]: #setautosave |
|
|
|
|
|
|
|
[5]: #getstepsbeforesave |
|
|
|
|
|
|
|
[6]: #setstepsbeforesave |
|
|
|
|
|
|
|
[7]: #getstorages |
|
|
|
|
|
|
|
[8]: #getcurrent |
|
|
|
|
|
|
|
[9]: #getcurrentstorage |
|
|
|
|
|
|
|
[10]: #setcurrent |
|
|
|
|
|
|
|
[11]: #add |
|
|
|
|
|
|
|
[12]: #get |
|
|
|
|
|
|
|
[13]: #store |
|
|
|
|
|
|
|
[14]: #load |
|
|
|
|
|
|
|
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|
|
|
|
|
|
|
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|
|
|
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|
|
|
|
|
|
|
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number |
|
|
|
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number |
|
|
|
|
|
|
|
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|
|
|
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|
|
|
|
|
|
|
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function |
|
|
|
[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function |
|
|
|
|
|
|
|
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array |
|
|
|
[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array |
|
|
|
|