Skip to content

Commit 927fd70

Browse files
committed
Update docs
1 parent 5b1742d commit 927fd70

File tree

2 files changed

+73
-21
lines changed

2 files changed

+73
-21
lines changed

docs/api/canvas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const editor = grapesjs.init({
1515
Once the editor is instantiated you can use its API. Before using these methods you should get the module from the instance
1616

1717
```js
18-
const blockManager = editor.Canvas;
18+
const canvas = editor.Canvas;
1919
```
2020

2121
- [getConfig][2]

docs/api/commands.md

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ const commands = editor.Commands;
2020

2121
- [add][2]
2222
- [get][3]
23-
- [has][4]
24-
- [run][5]
25-
- [stop][6]
23+
- [getAll][4]
24+
- [has][5]
25+
- [run][6]
26+
- [stop][7]
27+
- [isActive][8]
28+
- [getActive][9]
2629

2730
## add
2831

2932
Add new command to the collection
3033

3134
### Parameters
3235

33-
- `id` **[string][7]** Command's ID
34-
- `command` **([Object][8] \| [Function][9])** Object representing your command,
36+
- `id` **[string][10]** Command's ID
37+
- `command` **([Object][11] \| [Function][12])** Object representing your command,
3538
By passing just a function it's intended as a stateless command
3639
(just like passing an object with only `run` method).
3740

@@ -57,7 +60,7 @@ Get command by ID
5760

5861
### Parameters
5962

60-
- `id` **[string][7]** Command's ID
63+
- `id` **[string][10]** Command's ID
6164

6265
### Examples
6366

@@ -66,26 +69,32 @@ var myCommand = commands.get('myCommand');
6669
myCommand.run();
6770
```
6871

69-
Returns **[Object][8]** Object representing the command
72+
Returns **[Object][11]** Object representing the command
7073

7174
## has
7275

7376
Check if command exists
7477

7578
### Parameters
7679

77-
- `id` **[string][7]** Command's ID
80+
- `id` **[string][10]** Command's ID
7881

79-
Returns **[Boolean][10]**
82+
Returns **[Boolean][13]**
83+
84+
## getAll
85+
86+
Get an object containing all the commands
87+
88+
Returns **[Object][11]**
8089

8190
## run
8291

8392
Execute the command
8493

8594
### Parameters
8695

87-
- `id` **[String][7]** Command ID
88-
- `options` **[Object][8]** Options (optional, default `{}`)
96+
- `id` **[String][10]** Command ID
97+
- `options` **[Object][11]** Options (optional, default `{}`)
8998

9099
### Examples
91100

@@ -101,8 +110,8 @@ Stop the command
101110

102111
### Parameters
103112

104-
- `id` **[String][7]** Command ID
105-
- `options` **[Object][8]** Options (optional, default `{}`)
113+
- `id` **[String][10]** Command ID
114+
- `options` **[Object][11]** Options (optional, default `{}`)
106115

107116
### Examples
108117

@@ -112,22 +121,65 @@ commands.stop('myCommand', { someOption: 1 });
112121

113122
Returns **any** The return is defined by the command
114123

124+
## isActive
125+
126+
Check if the command is active. You activate commands with `run`
127+
and disable them with `stop`. If the command was created without `stop`
128+
method it can't be registered as active
129+
130+
### Parameters
131+
132+
- `id` **[String][10]** Command id
133+
134+
### Examples
135+
136+
```javascript
137+
const cId = 'some-command';
138+
commands.run(cId);
139+
commands.isActive(cId);
140+
// -> true
141+
commands.stop(cId);
142+
commands.isActive(cId);
143+
// -> false
144+
```
145+
146+
Returns **[Boolean][13]**
147+
148+
## getActive
149+
150+
Get all active commands
151+
152+
### Examples
153+
154+
```javascript
155+
console.log(commands.getActive());
156+
// -> { someCommand: itsLastReturn, anotherOne: ... };
157+
```
158+
159+
Returns **[Object][11]**
160+
115161
[1]: https://github.com/artf/grapesjs/blob/master/src/commands/config/config.js
116162

117163
[2]: #add
118164

119165
[3]: #get
120166

121-
[4]: #has
167+
[4]: #getall
168+
169+
[5]: #has
170+
171+
[6]: #run
172+
173+
[7]: #stop
122174

123-
[5]: #run
175+
[8]: #isactive
124176

125-
[6]: #stop
177+
[9]: #getactive
126178

127-
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
179+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
128180

129-
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
181+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
130182

131-
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
183+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
132184

133-
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
185+
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

0 commit comments

Comments
 (0)