grapesjs_codeapps
Version:
Free and Open Source Web Builder Framework/SC Modification
88 lines (57 loc) • 1.75 kB
Markdown
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object][1]
```js
const editor = grapesjs.init({
deviceManager: {
// 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 deviceManager = editor.DeviceManager;
```
- [add][2]
- [get][3]
- [getAll][4]
Add new device to the collection. URLs are supposed to be unique
- `name` **[string][5]** Device name
- `width` **[string][5]** Width of the device
- `opts` **[Object][6]** Custom options
```javascript
deviceManager.add('Tablet', '900px');
deviceManager.add('Tablet2', '900px', {
height: '300px',
widthMedia: '810px', // the width that will be used for the CSS media
});
```
Returns **Device** Added device
Return device by name
- `name` **[string][5]** Name of the device
```javascript
var device = deviceManager.get('Tablet');
console.log(JSON.stringify(device));
// {name: 'Tablet', width: '900px'}
```
Return all devices
```javascript
var devices = deviceManager.getAll();
console.log(JSON.stringify(devices));
// [{name: 'Desktop', width: ''}, ...]
```
Returns **Collection**
[]: https://github.com/artf/grapesjs/blob/master/src/device_manager/config/config.js
[]:
[]:
[]:
[]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object