@ -50,15 +50,6 @@ editor.on('EVENT-NAME', (some, argument) => {
* `block:drag` - Dragging block, the block's model and the drag event are passed as arguments
* `block:drag` - Dragging block, the block's model and the drag event are passed as arguments
* `block:drag:stop` - Dragging of the block is stopped. As agruments for the callback you get, the dropped component model (if dropped successfully) and the model of the block
* `block:drag:stop` - Dragging of the block is stopped. As agruments for the callback you get, the dropped component model (if dropped successfully) and the model of the block
### Assets
* `asset:add` - New asset added
* `asset:remove` - Asset removed
* `asset:upload:start` - Before the upload is started
* `asset:upload:end` - After the upload is ended
* `asset:upload:error` - On any error in upload, passes the error as an argument
* `asset:upload:response` - On upload response, passes the result as an argument
### Keymaps
### Keymaps
* `keymap:add` - New keymap added. The new keyamp object is passed as an argument
* `keymap:add` - New keymap added. The new keyamp object is passed as an argument
@ -118,21 +109,25 @@ By changing `result.content` you're able to customize what is dropped
* `run` - Triggered on run of any command. The id and the result are passed as arguments to the callback
* `run` - Triggered on run of any command. The id and the result are passed as arguments to the callback
* `stop` - Triggered on stop of any command. The id and the result are passed as arguments to the callback
* `stop` - Triggered on stop of any command. The id and the result are passed as arguments to the callback
### Assets
Check the [Assets][2] module.
### Modal
### Modal
Check the [Modal][2] module.
Check the [Modal][3 ] module.
### Devices
### Devices
Check the [Devices][3 ] module.
Check the [Devices][4 ] module.
### Parser
### Parser
Check the [Parser][4 ] module.
Check the [Parser][5 ] module.
### Pages
### Pages
Check the [Pages][5 ] module.
Check the [Pages][6 ] module.
### General
### General
@ -148,7 +143,7 @@ Returns configuration object
### Parameters
### Parameters
* `prop` ** [string][6 ]?** Property name
* `prop` ** [string][7 ]?** Property name
Returns **any** Returns the configuration object or
Returns **any** Returns the configuration object or
the value of the specified property
the value of the specified property
@ -159,12 +154,12 @@ Returns HTML built inside canvas
### Parameters
### Parameters
* `opts` ** [Object][7 ]** Options (optional, default `{}` )
* `opts` ** [Object][8 ]** Options (optional, default `{}` )
* `opts.component` * *Component?** Return the HTML of a specific Component
* `opts.component` * *Component?** Return the HTML of a specific Component
* `opts.cleanId` * *[Boolean][8 ]** Remove unnecessary IDs (eg. those created automatically) (optional, default `false` )
* `opts.cleanId` * *[Boolean][9 ]** Remove unnecessary IDs (eg. those created automatically) (optional, default `false` )
Returns ** [string][6 ]** HTML string
Returns ** [string][7 ]** HTML string
## getCss
## getCss
@ -172,13 +167,13 @@ Returns CSS built inside canvas
### Parameters
### Parameters
* `opts` ** [Object][7 ]** Options (optional, default `{}` )
* `opts` ** [Object][8 ]** Options (optional, default `{}` )
* `opts.component` * *Component?** Return the CSS of a specific Component
* `opts.component` * *Component?** Return the CSS of a specific Component
* `opts.json` * *[Boolean][8 ]** Return an array of CssRules instead of the CSS string (optional, default `false` )
* `opts.json` * *[Boolean][9 ]** Return an array of CssRules instead of the CSS string (optional, default `false` )
* `opts.avoidProtected` * *[Boolean][8 ]** Don't include protected CSS (optional, default `false` )
* `opts.avoidProtected` * *[Boolean][9 ]** Don't include protected CSS (optional, default `false` )
Returns ** ([String][6] | [Array][9 ]\<CssRule>)** CSS string or array of CssRules
Returns ** ([String][7] | [Array][10 ]\<CssRule>)** CSS string or array of CssRules
## getJs
## getJs
@ -186,11 +181,11 @@ Returns JS of all components
### Parameters
### Parameters
* `opts` ** [Object][7 ]** Options (optional, default `{}` )
* `opts` ** [Object][8 ]** Options (optional, default `{}` )
* `opts.component` * *Component?** Get the JS of a specific component
* `opts.component` * *Component?** Get the JS of a specific component
Returns ** [String][6 ]** JS string
Returns ** [String][7 ]** JS string
## getComponents
## getComponents
@ -210,8 +205,8 @@ Set components inside editor's canvas. This method overrides actual components
### Parameters
### Parameters
* `components` ** ([Array][9]< [Object][7]> | [Object][7] | [string][6 ])** HTML string or components model
* `components` ** ([Array][10]< [Object][8]> | [Object][8] | [string][7 ])** HTML string or components model
* `opt` ** [Object][7]** the options object to be used by the \[setComponents][em#setComponents][10 ] method (optional, default `{}` )
* `opt` ** [Object][8]** the options object to be used by the \[setComponents][em#setComponents][11 ] method (optional, default `{}` )
### Examples
### Examples
@ -233,10 +228,10 @@ Add components
### Parameters
### Parameters
* `components` ** ([Array][9]< [Object][7]> | [Object][7] | [string][6 ])** HTML string or components model
* `components` ** ([Array][10]< [Object][8]> | [Object][8] | [string][7 ])** HTML string or components model
* `opts` ** [Object][7 ]** Options
* `opts` ** [Object][8 ]** Options
* `opts.avoidUpdateStyle` * *[Boolean][8 ]** If the HTML string contains styles,
* `opts.avoidUpdateStyle` * *[Boolean][9 ]** If the HTML string contains styles,
by default, they will be created and, if already exist, updated. When this option
by default, they will be created and, if already exist, updated. When this option
is true, styles already created will not be updated. (optional, default `false` )
is true, styles already created will not be updated. (optional, default `false` )
@ -252,13 +247,13 @@ editor.addComponents({
});
});
```
```
Returns ** [Array][9 ]\<Component>**
Returns ** [Array][10 ]\<Component>**
## getStyle
## getStyle
Returns style in JSON format object
Returns style in JSON format object
Returns ** [Object][7 ]**
Returns ** [Object][8 ]**
## setStyle
## setStyle
@ -266,7 +261,7 @@ Set style inside editor's canvas. This method overrides actual style
### Parameters
### Parameters
* `style` ** ([Array][9]< [Object][7]> | [Object][7] | [string][6 ])** CSS string or style model
* `style` ** ([Array][10]< [Object][8]> | [Object][8] | [string][7 ])** CSS string or style model
* `opt` (optional, default `{}` )
* `opt` (optional, default `{}` )
### Examples
### Examples
@ -288,7 +283,7 @@ Add styles to the editor
### Parameters
### Parameters
* `style` ** ([Array][9]< [Object][7]> | [Object][7] | [string][6 ])** CSS string or style model
* `style` ** ([Array][10]< [Object][8]> | [Object][8] | [string][7 ])** CSS string or style model
* `opts` (optional, default `{}` )
* `opts` (optional, default `{}` )
### Examples
### Examples
@ -297,7 +292,7 @@ Add styles to the editor
editor.addStyle('.cls{color: red}');
editor.addStyle('.cls{color: red}');
```
```
Returns ** [Array][9 ]\<CssRule>** Array of created CssRule instances
Returns ** [Array][10 ]\<CssRule>** Array of created CssRule instances
## getSelected
## getSelected
@ -309,7 +304,7 @@ Returns **Model**
Returns an array of all selected components
Returns an array of all selected components
Returns ** [Array][9 ]**
Returns ** [Array][10 ]**
## getSelectedToStyle
## getSelectedToStyle
@ -327,10 +322,10 @@ Select a component
### Parameters
### Parameters
* `el` ** (Component | [HTMLElement][11 ])** Component to select
* `el` ** (Component | [HTMLElement][12 ])** Component to select
* `opts` ** [Object][7 ]?** Options
* `opts` ** [Object][8 ]?** Options
* `opts.scroll` * *[Boolean][8 ]?** Scroll canvas to the selected element
* `opts.scroll` * *[Boolean][9 ]?** Scroll canvas to the selected element
### Examples
### Examples
@ -349,7 +344,7 @@ Add component to selection
### Parameters
### Parameters
* `el` ** (Component | [HTMLElement][11] | [Array][9 ])** Component to select
* `el` ** (Component | [HTMLElement][12] | [Array][10 ])** Component to select
### Examples
### Examples
@ -365,7 +360,7 @@ Remove component from selection
### Parameters
### Parameters
* `el` ** (Component | [HTMLElement][11] | [Array][9 ])** Component to select
* `el` ** (Component | [HTMLElement][12] | [Array][10 ])** Component to select
### Examples
### Examples
@ -381,7 +376,7 @@ Toggle component selection
### Parameters
### Parameters
* `el` ** (Component | [HTMLElement][11] | [Array][9 ])** Component to select
* `el` ** (Component | [HTMLElement][12] | [Array][10 ])** Component to select
### Examples
### Examples
@ -413,7 +408,7 @@ change the canvas to the proper width
### Parameters
### Parameters
* `name` ** [string][6 ]** Name of the device
* `name` ** [string][7 ]** Name of the device
### Examples
### Examples
@ -435,7 +430,7 @@ console.log(device);
// 'Tablet'
// 'Tablet'
```
```
Returns ** [string][6 ]** Device name
Returns ** [string][7 ]** Device name
## runCommand
## runCommand
@ -443,8 +438,8 @@ Execute command
### Parameters
### Parameters
* `id` ** [string][6 ]** Command ID
* `id` ** [string][7 ]** Command ID
* `options` ** [Object][7 ]** Custom options (optional, default `{}` )
* `options` ** [Object][8 ]** Custom options (optional, default `{}` )
### Examples
### Examples
@ -460,8 +455,8 @@ Stop the command if stop method was provided
### Parameters
### Parameters
* `id` ** [string][6 ]** Command ID
* `id` ** [string][7 ]** Command ID
* `options` ** [Object][7 ]** Custom options (optional, default `{}` )
* `options` ** [Object][8 ]** Custom options (optional, default `{}` )
### Examples
### Examples
@ -477,9 +472,9 @@ Store data to the current storage
### Parameters
### Parameters
* `clb` ** [Function][12 ]** Callback function
* `clb` ** [Function][13 ]** Callback function
Returns ** [Object][7 ]** Stored data
Returns ** [Object][8 ]** Stored data
## storeData
## storeData
@ -492,7 +487,7 @@ console.log(editor.storeData());
// { pages: [...], styles: [...], ... }
// { pages: [...], styles: [...], ... }
```
```
Returns ** [Object][7 ]**
Returns ** [Object][8 ]**
## load
## load
@ -500,9 +495,9 @@ Load data from the current storage
### Parameters
### Parameters
* `clb` ** [Function][12 ]** Callback function
* `clb` ** [Function][13 ]** Callback function
Returns ** [Object][7 ]** Stored data
Returns ** [Object][8 ]** Stored data
## loadData
## loadData
@ -510,7 +505,7 @@ Load data from the JSON data object
### Parameters
### Parameters
* `data` ** [Object][7 ]** Data to load
* `data` ** [Object][8 ]** Data to load
### Examples
### Examples
@ -518,21 +513,21 @@ Load data from the JSON data object
editor.loadData({ pages: [...], styles: [...], ... })
editor.loadData({ pages: [...], styles: [...], ... })
```
```
Returns ** [Object][7 ]** Loaded object
Returns ** [Object][8 ]** Loaded object
## getContainer
## getContainer
Returns container element. The one which was indicated as 'container'
Returns container element. The one which was indicated as 'container'
on init method
on init method
Returns ** [HTMLElement][11 ]**
Returns ** [HTMLElement][12 ]**
## getDirtyCount
## getDirtyCount
Return the count of changes made to the content and not yet stored.
Return the count of changes made to the content and not yet stored.
This count resets at any `store()`
This count resets at any `store()`
Returns ** [number][13 ]**
Returns ** [number][14 ]**
## refresh
## refresh
@ -545,9 +540,9 @@ refresh you'll get misleading position of tools
### Parameters
### Parameters
* `opts`
* `opts`
* `options` ** [Object][7 ]?** Options
* `options` ** [Object][8 ]?** Options
* `options.tools` * *[Boolean][8 ]** Update the position of tools (eg. rich text editor, component highlighter, etc.) (optional, default `false` )
* `options.tools` * *[Boolean][9 ]** Update the position of tools (eg. rich text editor, component highlighter, etc.) (optional, default `false` )
## setCustomRte
## setCustomRte
@ -555,7 +550,7 @@ Replace the built-in Rich Text Editor with a custom one.
### Parameters
### Parameters
* `obj` ** [Object][7 ]** Custom RTE Interface
* `obj` ** [Object][8 ]** Custom RTE Interface
### Examples
### Examples
@ -595,7 +590,7 @@ custom parser, pass `null` as the argument
### Parameters
### Parameters
* `parser` ** ([Function][12 ] | null)** Parser function
* `parser` ** ([Function][13 ] | null)** Parser function
### Examples
### Examples
@ -617,11 +612,11 @@ Returns **this**
## setDragMode
## setDragMode
Change the global drag mode of components.
Change the global drag mode of components.
To get more about this feature read: [https://github.com/artf/grapesjs/issues/1936][14 ]
To get more about this feature read: [https://github.com/artf/grapesjs/issues/1936][15 ]
### Parameters
### Parameters
* `value` ** [String][6 ]** Drag mode, options: 'absolute' | 'translate'
* `value` ** [String][7 ]** Drag mode, options: 'absolute' | 'translate'
Returns **this**
Returns **this**
@ -632,10 +627,10 @@ Trigger event log message
### Parameters
### Parameters
* `msg` **any** Message to log
* `msg` **any** Message to log
* `opts` ** [Object][7 ]** Custom options (optional, default `{}` )
* `opts` ** [Object][8 ]** Custom options (optional, default `{}` )
* `opts.ns` * *[String][6 ]** Namespace of the log (eg. to use in plugins) (optional, default `''` )
* `opts.ns` * *[String][7 ]** Namespace of the log (eg. to use in plugins) (optional, default `''` )
* `opts.level` * *[String][6 ]** Level of the log, `debug` , `info` , `warning` , `error` (optional, default `'debug'` )
* `opts.level` * *[String][7 ]** Level of the log, `debug` , `info` , `warning` , `error` (optional, default `'debug'` )
### Examples
### Examples
@ -657,11 +652,11 @@ Translate label
### Parameters
### Parameters
* `args` ** ...any**
* `args` ** ...any**
* `key` ** [String][6 ]** Label to translate
* `key` ** [String][7 ]** Label to translate
* `opts` ** [Object][7 ]?** Options for the translation
* `opts` ** [Object][8 ]?** Options for the translation
* `opts.params` * *[Object][7 ]?** Params for the translation
* `opts.params` * *[Object][8 ]?** Params for the translation
* `opts.noWarn` * *[Boolean][8 ]?** Avoid warnings in case of missing resources
* `opts.noWarn` * *[Boolean][9 ]?** Avoid warnings in case of missing resources
### Examples
### Examples
@ -673,7 +668,7 @@ editor.t('msg2', { params: { test: 'hello' } });
editor.t('msg2', { params: { test: 'hello' }, l: 'it' });
editor.t('msg2', { params: { test: 'hello' }, l: 'it' });
```
```
Returns ** [String][6 ]**
Returns ** [String][7 ]**
## on
## on
@ -681,8 +676,8 @@ Attach event
### Parameters
### Parameters
* `event` ** [string][6 ]** Event name
* `event` ** [string][7 ]** Event name
* `callback` ** [Function][12 ]** Callback function
* `callback` ** [Function][13 ]** Callback function
Returns **this**
Returns **this**
@ -692,8 +687,8 @@ Attach event and detach it after the first run
### Parameters
### Parameters
* `event` ** [string][6 ]** Event name
* `event` ** [string][7 ]** Event name
* `callback` ** [Function][12 ]** Callback function
* `callback` ** [Function][13 ]** Callback function
Returns **this**
Returns **this**
@ -703,8 +698,8 @@ Detach event
### Parameters
### Parameters
* `event` ** [string][6 ]** Event name
* `event` ** [string][7 ]** Event name
* `callback` ** [Function][12 ]** Callback function
* `callback` ** [Function][13 ]** Callback function
Returns **this**
Returns **this**
@ -714,7 +709,7 @@ Trigger event
### Parameters
### Parameters
* `event` ** [string][6 ]** Event to trigger
* `event` ** [string][7 ]** Event to trigger
Returns **this**
Returns **this**
@ -726,7 +721,7 @@ Destroy the editor
Render editor
Render editor
Returns ** [HTMLElement][11 ]**
Returns ** [HTMLElement][12 ]**
## html
## html
@ -734,8 +729,8 @@ Print safe HTML by using ES6 tagged template strings.
### Parameters
### Parameters
* `literals` ** [Array][9]< [String][6 ]>**
* `literals` ** [Array][10]< [String][7 ]>**
* `substs` ** [Array][9]< [String][6 ]>**
* `substs` ** [Array][10]< [String][7 ]>**
### Examples
### Examples
@ -746,32 +741,34 @@ const safeStr = '<b>Hello</b>';
const strHtml = editor.html`Escaped ${unsafeStr}, unescaped $${safeStr}`;
const strHtml = editor.html`Escaped ${unsafeStr}, unescaped $${safeStr}`;
```
```
Returns ** [String][6 ]**
Returns ** [String][7 ]**
[1]: https://github.com/artf/grapesjs/blob/master/src/editor/config/config.js
[1]: https://github.com/artf/grapesjs/blob/master/src/editor/config/config.js
[2]: /api/modal_dialog.html
[2]: /api/assets.html
[3]: /api/modal_dialog.html
[3]: /api/device_manager.html
[4 ]: /api/device_manager.html
[4 ]: /api/parser.html
[5 ]: /api/parser.html
[5 ]: /api/pages.html
[6 ]: /api/pages.html
[6 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[7 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[7 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[8 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[8 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[9 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[9 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[10 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[10 ]: em#setComponents
[11 ]: em#setComponents
[11 ]: https://developer.mozilla.org/docs/Web/HTML/Element
[12 ]: https://developer.mozilla.org/docs/Web/HTML/Element
[12 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[13 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[13 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[14 ]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[14 ]: https://github.com/artf/grapesjs/issues/1936
[15 ]: https://github.com/artf/grapesjs/issues/1936