Browse Source

Add UndoManager API in docs

docs
Artur Arseniev 8 years ago
parent
commit
4ce90f04c1
  1. 1
      docs/.vuepress/config.js
  2. 29
      docs/api.js
  3. 58
      docs/api/undo_manager.md
  4. 21
      src/undo_manager/index.js

1
docs/.vuepress/config.js

@ -67,6 +67,7 @@ module.exports = {
['/api/modal_dialog', 'Modal'],
['/api/rich_text_editor', 'Rich Text Editor'],
['/api/keymaps', 'Keymaps'],
['/api/undo_manager', 'Undo Manager'],
],
'/': [
'',

29
docs/api.js

@ -5,22 +5,21 @@ const docRoot = __dirname;
const srcRoot = path.join(docRoot, '../src/');
const binRoot = path.join(docRoot, '../node_modules/.bin/');
const cmds = [
// ['editor/index.js', 'editor.md'],
// ['asset_manager/index.js', 'assets.md'],
// ['block_manager/index.js', 'block_manager.md'],
// ['commands/index.js', 'commands.md'],
// ['dom_components/index.js', 'components.md'],
// ['panels/index.js', 'panels.md'],
// ['style_manager/index.js', 'style_manager.md'],
// ['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'],
// ['modal_dialog/index.js', 'modal_dialog.md'],
// ['rich_text_editor/index.js', 'rich_text_editor.md'],
['editor/index.js', 'editor.md'],
['asset_manager/index.js', 'assets.md'],
['block_manager/index.js', 'block_manager.md'],
['commands/index.js', 'commands.md'],
['dom_components/index.js', 'components.md'],
['panels/index.js', 'panels.md'],
['style_manager/index.js', 'style_manager.md'],
['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'],
['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'],*/
['undo_manager/index.js', 'undo_manager.md'],
].map(entry =>
`${binRoot}documentation build ${srcRoot}/${entry[0]} -o ${docRoot}/api/${entry[1]} -f md --shallow --markdown-toc false`)
.join(' && ');

58
docs/api/undo_manager.md

@ -2,14 +2,28 @@
## UndoManager
This module allows to manage the stack of changes applied in canvas
You can access the module in this way
This module allows to manage the stack of changes applied in canvas.
Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance
```js
const um = editor.UndoManager;
```
- [getConfig][1]
- [add][2]
- [remove][3]
- [removeAll][4]
- [start][5]
- [stop][6]
- [undo][7]
- [undoAll][8]
- [redo][9]
- [redoAll][10]
- [hasUndo][11]
- [hasRedo][12]
- [getStack][13]
- [clear][14]
## getConfig
Get module configurations
@ -21,7 +35,7 @@ const config = um.getConfig();
// { ... }
```
Returns **[Object][1]** Configuration object
Returns **[Object][15]** Configuration object
## add
@ -150,7 +164,7 @@ Checks if exists an available undo
um.hasUndo();
```
Returns **[Boolean][2]**
Returns **[Boolean][16]**
## hasRedo
@ -162,7 +176,7 @@ Checks if exists an available redo
um.hasRedo();
```
Returns **[Boolean][2]**
Returns **[Boolean][16]**
## getStack
@ -189,6 +203,34 @@ um.clear();
Returns **this**
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[1]: #getconfig
[2]: #add
[3]: #remove
[4]: #removeall
[5]: #start
[6]: #stop
[7]: #undo
[8]: #undoall
[9]: #redo
[10]: #redoall
[11]: #hasundo
[12]: #hasredo
[13]: #getstack
[14]: #clear
[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

21
src/undo_manager/index.js

@ -1,12 +1,29 @@
/**
* This module allows to manage the stack of changes applied in canvas
* This module allows to manage the stack of changes applied in canvas.
* Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance
*
* You can access the module in this way
* ```js
* const um = editor.UndoManager;
* ```
*
* * [getConfig](#getconfig)
* * [add](#add)
* * [remove](#remove)
* * [removeAll](#removeall)
* * [start](#start)
* * [stop](#stop)
* * [undo](#undo)
* * [undoAll](#undoall)
* * [redo](#redo)
* * [redoAll](#redoall)
* * [hasUndo](#hasundo)
* * [hasRedo](#hasredo)
* * [getStack](#getstack)
* * [clear](#clear)
*
* @module UndoManager
*/
import UndoManager from 'backbone-undo';
module.exports = () => {

Loading…
Cancel
Save