Browse Source

Add Modal API in docs

docs
Artur Arseniev 8 years ago
parent
commit
b2f1235a7d
  1. 1
      docs/.vuepress/config.js
  2. 5
      docs/api.js
  3. 60
      docs/api/modal_dialog.md
  4. 21
      src/modal_dialog/index.js

1
docs/.vuepress/config.js

@ -64,6 +64,7 @@ module.exports = {
['/api/device_manager', 'Device Manager'],
['/api/selector_manager', 'Selector Manager'],
['/api/css_composer', 'CSS Composer'],
['/api/modal_dialog', 'Modal'],
],
'/': [
'',

5
docs/api.js

@ -15,10 +15,9 @@ const cmds = [
// ['storage_manager/index.js', 'storage_manager.md'],
// ['device_manager/index.js', 'device_manager.md'],
// ['selector_manager/index.js', 'selector_manager.md'],
['css_composer/index.js', 'css_composer.md'],
/*
['css_composer/index.js', 'css_composer.md'],
// ['css_composer/index.js', 'css_composer.md'],
['modal_dialog/index.js', 'modal_dialog.md'],
/*
['rich_text_editor/index.js', 'rich_text_editor.md'],
['keymaps/index.js', 'keymaps.md'],
['undo_manager/index.js', 'undo_manager.md'],*/

60
docs/api/modal_dialog.md

@ -2,20 +2,30 @@
## Modal
- [open][1]
- [close][2]
- [isOpen][3]
- [setTitle][4]
- [getTitle][5]
- [setContent][6]
- [getContent][7]
You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object][1]
Before using the methods you should get first the module from the editor instance, in this way:
```js
const editor = grapesjs.init({
modal: {
// options
}
})
```
Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance
```js
var modal = editor.Modal;
const modal = editor.Modal;
```
- [open][2]
- [close][3]
- [isOpen][4]
- [setTitle][5]
- [getTitle][6]
- [setContent][7]
- [getContent][8]
## open
Open the modal window
@ -32,7 +42,7 @@ Returns **this**
Checks if the modal window is open
Returns **[Boolean][8]**
Returns **[Boolean][9]**
## setTitle
@ -40,7 +50,7 @@ Set the title to the modal window
### Parameters
- `title` **[string][9]** Title
- `title` **[string][10]** Title
### Examples
@ -54,7 +64,7 @@ Returns **this**
Returns the title of the modal window
Returns **[string][9]**
Returns **[string][10]**
## setContent
@ -62,7 +72,7 @@ Set the content of the modal window
### Parameters
- `content` **([string][9] \| [HTMLElement][10])** Content
- `content` **([string][10] \| [HTMLElement][11])** Content
### Examples
@ -76,24 +86,26 @@ Returns **this**
Get the content of the modal window
Returns **[string][9]**
Returns **[string][10]**
[1]: https://github.com/artf/grapesjs/blob/master/src/modal_dialog/config/config.js
[1]: #open
[2]: #open
[2]: #close
[3]: #close
[3]: #isopen
[4]: #isopen
[4]: #settitle
[5]: #settitle
[5]: #gettitle
[6]: #gettitle
[6]: #setcontent
[7]: #setcontent
[7]: #getcontent
[8]: #getcontent
[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/String
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[10]: https://developer.mozilla.org/docs/Web/HTML/Element
[11]: https://developer.mozilla.org/docs/Web/HTML/Element

21
src/modal_dialog/index.js

@ -1,4 +1,19 @@
/**
* You can customize the initial state of the module from the editor initialization, by passing the following [Configuration Object](https://github.com/artf/grapesjs/blob/master/src/modal_dialog/config/config.js)
* ```js
* const editor = grapesjs.init({
* modal: {
* // 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 modal = editor.Modal;
* ```
*
* * [open](#open)
* * [close](#close)
* * [isOpen](#isopen)
@ -7,13 +22,9 @@
* * [setContent](#setcontent)
* * [getContent](#getcontent)
*
* Before using the methods you should get first the module from the editor instance, in this way:
*
* ```js
* var modal = editor.Modal;
* ```
* @module Modal
*/
module.exports = () => {
var c = {},
defaults = require('./config/config'),

Loading…
Cancel
Save