|
|
@ -31,18 +31,17 @@ const assetManager = editor.AssetManager; |
|
|
|
|
|
|
|
|
## Methods |
|
|
## Methods |
|
|
|
|
|
|
|
|
* [add][2] |
|
|
* [open][2] |
|
|
* [get][3] |
|
|
* [close][3] |
|
|
* [getAll][4] |
|
|
* [isOpen][4] |
|
|
* [getAllVisible][5] |
|
|
* [add][5] |
|
|
* [remove][6] |
|
|
* [get][6] |
|
|
* [store][7] |
|
|
* [getAll][7] |
|
|
* [load][8] |
|
|
* [getAllVisible][8] |
|
|
* [getContainer][9] |
|
|
* [remove][9] |
|
|
* [getAssetsEl][10] |
|
|
* [store][10] |
|
|
* [addType][11] |
|
|
* [load][11] |
|
|
* [getType][12] |
|
|
* [getContainer][12] |
|
|
* [getTypes][13] |
|
|
|
|
|
|
|
|
|
|
|
[Asset]: asset.html |
|
|
[Asset]: asset.html |
|
|
|
|
|
|
|
|
@ -52,10 +51,10 @@ Open the asset manager. |
|
|
|
|
|
|
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `options` **[Object][14]?** Options for the asset manager. (optional, default `{}`) |
|
|
* `options` **[Object][13]?** Options for the asset manager. (optional, default `{}`) |
|
|
|
|
|
|
|
|
* `options.types` **[Array][15]<[String][16]>** Types of assets to show. (optional, default `['image']`) |
|
|
* `options.types` **[Array][14]<[String][15]>** Types of assets to show. (optional, default `['image']`) |
|
|
* `options.select` **[Function][17]?** Type of operation to perform on asset selection. If not specified, nothing will happen. |
|
|
* `options.select` **[Function][16]?** Type of operation to perform on asset selection. If not specified, nothing will happen. |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
|
|
|
|
|
|
@ -85,14 +84,26 @@ Close the asset manager. |
|
|
assetManager.close(); |
|
|
assetManager.close(); |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
## isOpen |
|
|
|
|
|
|
|
|
|
|
|
Checks if the asset manager is open |
|
|
|
|
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
|
|
|
|
```javascript |
|
|
|
|
|
assetManager.isOpen(); // true | false |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
Returns **[Boolean][17]** |
|
|
|
|
|
|
|
|
## add |
|
|
## add |
|
|
|
|
|
|
|
|
Add new asset/s to the collection. URLs are supposed to be unique |
|
|
Add new asset/s to the collection. URLs are supposed to be unique |
|
|
|
|
|
|
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `asset` **([String][16] | [Object][14] | [Array][15]<[String][16]> | [Array][15]<[Object][14]>)** URL strings or an objects representing the resource. |
|
|
* `asset` **([String][15] | [Object][13] | [Array][14]<[String][15]> | [Array][14]<[Object][13]>)** URL strings or an objects representing the resource. |
|
|
* `opts` **[Object][14]?** Options (optional, default `{}`) |
|
|
* `opts` **[Object][13]?** Options (optional, default `{}`) |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
|
|
|
|
|
|
@ -119,7 +130,7 @@ Return asset by URL |
|
|
|
|
|
|
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `src` **[String][16]** URL of the asset |
|
|
* `src` **[String][15]** URL of the asset |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
|
|
|
|
|
|
@ -147,7 +158,7 @@ Remove asset |
|
|
|
|
|
|
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `asset` **([String][16] | [Asset])** Asset or asset URL |
|
|
* `asset` **([String][15] | [Asset])** Asset or asset URL |
|
|
* `opts` |
|
|
* `opts` |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
@ -167,7 +178,7 @@ Store assets data to the selected storage |
|
|
|
|
|
|
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `noStore` **[Boolean][18]** If true, won't store |
|
|
* `noStore` **[Boolean][17]** If true, won't store |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
|
|
|
|
|
|
@ -175,7 +186,7 @@ Store assets data to the selected storage |
|
|
var assets = assetManager.store(); |
|
|
var assets = assetManager.store(); |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
Returns **[Object][14]** Data to store |
|
|
Returns **[Object][13]** Data to store |
|
|
|
|
|
|
|
|
## load |
|
|
## load |
|
|
|
|
|
|
|
|
@ -184,7 +195,7 @@ The fetched data will be added to the collection. |
|
|
|
|
|
|
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `data` **[Object][14]** Object of data to load (optional, default `{}`) |
|
|
* `data` **[Object][13]** Object of data to load (optional, default `{}`) |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
|
|
|
|
|
|
@ -194,19 +205,13 @@ var assets = assetManager.load({ |
|
|
}) |
|
|
}) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
Returns **[Object][14]** Loaded assets |
|
|
Returns **[Object][13]** Loaded assets |
|
|
|
|
|
|
|
|
## getContainer |
|
|
## getContainer |
|
|
|
|
|
|
|
|
Return the Asset Manager Container |
|
|
Return the Asset Manager Container |
|
|
|
|
|
|
|
|
Returns **[HTMLElement][19]** |
|
|
Returns **[HTMLElement][18]** |
|
|
|
|
|
|
|
|
## getAssetsEl |
|
|
|
|
|
|
|
|
|
|
|
Get assets element container |
|
|
|
|
|
|
|
|
|
|
|
Returns **[HTMLElement][19]** |
|
|
|
|
|
|
|
|
|
|
|
## render |
|
|
## render |
|
|
|
|
|
|
|
|
@ -215,7 +220,7 @@ Render assets |
|
|
### Parameters |
|
|
### Parameters |
|
|
|
|
|
|
|
|
* `assts` |
|
|
* `assts` |
|
|
* `assets` **[array][15]** Assets to render, without the argument will render all global assets |
|
|
* `assets` **[array][14]** Assets to render, without the argument will render all global assets |
|
|
|
|
|
|
|
|
### Examples |
|
|
### Examples |
|
|
|
|
|
|
|
|
@ -230,82 +235,40 @@ assetManager.render(assets.filter( |
|
|
)); |
|
|
)); |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
Returns **[HTMLElement][19]** |
|
|
Returns **[HTMLElement][18]** |
|
|
|
|
|
|
|
|
## addType |
|
|
|
|
|
|
|
|
|
|
|
Add new type. If you want to get more about type definition we suggest to read the [module's page][20] |
|
|
|
|
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
|
|
|
|
* `id` **[string][16]** Type ID |
|
|
|
|
|
* `definition` **[Object][14]** Definition of the type. Each definition contains |
|
|
|
|
|
`model` (business logic), `view` (presentation logic) |
|
|
|
|
|
and `isType` function which recognize the type of the |
|
|
|
|
|
passed entity |
|
|
|
|
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
|
|
|
|
```javascript |
|
|
|
|
|
assetManager.addType('my-type', { |
|
|
|
|
|
model: {}, |
|
|
|
|
|
view: {}, |
|
|
|
|
|
isType: (value) => {}, |
|
|
|
|
|
}) |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
## getType |
|
|
|
|
|
|
|
|
|
|
|
Get type |
|
|
|
|
|
|
|
|
|
|
|
### Parameters |
|
|
|
|
|
|
|
|
|
|
|
* `id` **[string][16]** Type ID |
|
|
|
|
|
|
|
|
|
|
|
Returns **[Object][14]** Type definition |
|
|
|
|
|
|
|
|
|
|
|
## getTypes |
|
|
|
|
|
|
|
|
|
|
|
Get types |
|
|
|
|
|
|
|
|
|
|
|
Returns **[Array][15]** |
|
|
|
|
|
|
|
|
|
|
|
[1]: https://github.com/artf/grapesjs/blob/master/src/asset_manager/config/config.js |
|
|
[1]: https://github.com/artf/grapesjs/blob/master/src/asset_manager/config/config.js |
|
|
|
|
|
|
|
|
[2]: #add |
|
|
[2]: #open |
|
|
|
|
|
|
|
|
[3]: #get |
|
|
|
|
|
|
|
|
|
|
|
[4]: #getall |
|
|
|
|
|
|
|
|
|
|
|
[5]: #getallvisible |
|
|
[3]: #close |
|
|
|
|
|
|
|
|
[6]: #remove |
|
|
[4]: #isopen |
|
|
|
|
|
|
|
|
[7]: #store |
|
|
[5]: #add |
|
|
|
|
|
|
|
|
[8]: #load |
|
|
[6]: #get |
|
|
|
|
|
|
|
|
[9]: #getcontainer |
|
|
[7]: #getall |
|
|
|
|
|
|
|
|
[10]: #getassetsel |
|
|
[8]: #getallvisible |
|
|
|
|
|
|
|
|
[11]: #addtype |
|
|
[9]: #remove |
|
|
|
|
|
|
|
|
[12]: #gettype |
|
|
[10]: #store |
|
|
|
|
|
|
|
|
[13]: #gettypes |
|
|
[11]: #load |
|
|
|
|
|
|
|
|
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|
|
[12]: #getcontainer |
|
|
|
|
|
|
|
|
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array |
|
|
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|
|
|
|
|
|
|
|
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|
|
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array |
|
|
|
|
|
|
|
|
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function |
|
|
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|
|
|
|
|
|
|
|
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|
|
[16]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function |
|
|
|
|
|
|
|
|
[19]: https://developer.mozilla.org/docs/Web/HTML/Element |
|
|
[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|
|
|
|
|
|
|
|
[20]: /modules/Assets.html |
|
|
[18]: https://developer.mozilla.org/docs/Web/HTML/Element |
|
|
|