Skip to content

Commit 8ddb937

Browse files
committed
Up docs
1 parent 4f81fb7 commit 8ddb937

File tree

7 files changed

+61
-36
lines changed

7 files changed

+61
-36
lines changed

docs/api/components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cmp.addType(...);
4343
* `component:drag:start` - Component drag started. Passed an object, to the callback, containing the `target` (component to drag), `parent` (parent of the component) and `index` (component index in the parent)
4444
* `component:drag` - During component drag. Passed the same object as in `component:drag:start` event, but in this case, `parent` and `index` are updated by the current pointer
4545
* `component:drag:end` - Component drag ended. Passed the same object as in `component:drag:start` event, but in this case, `parent` and `index` are updated by the final pointer
46-
* `component:resize` - During component resize.
46+
* `component:resize` - During component resize.
4747

4848
## Methods
4949

docs/api/css_composer.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ Add/update the CssRule.
5353
### Parameters
5454

5555
* `selectors` **[String][8]** Selector string, eg. `.myclass`
56-
* `style` **[Object][10]** Style properties and values (optional, default `{}`)
57-
* `opts` **[Object][10]** Additional properties (optional, default `{}`)
56+
* `style` **[Object][10]** Style properties and values. If the rule exists, styles will be replaced unless `addStyles` option is used. (optional, default `{}`)
57+
* `opts` **[Object][10]** Additional properties. (optional, default `{}`)
5858

59-
* `opts.atRuleType` **[String][8]** At-rule type, eg. `media` (optional, default `''`)
60-
* `opts.atRuleParams` **[String][8]** At-rule parameters, eg. `(min-width: 500px)` (optional, default `''`)
59+
* `opts.atRuleType` **[String][8]** At-rule type, eg. `media`. (optional, default `''`)
60+
* `opts.atRuleParams` **[String][8]** At-rule parameters, eg. `(min-width: 500px)`. (optional, default `''`)
61+
* `opts.addStyles` **[Boolean][11]** If the rule exists already, merge passed styles instead of replacing them. (optional, default `false`)
6162

6263
### Examples
6364

@@ -73,10 +74,15 @@ const rule = css.setRule('.class1:hover', { color: 'red' }, {
7374
atRuleType: 'media',
7475
atRuleParams: '(min-width: 500px)',
7576
});
76-
// output: @media (min-width: 500px) { .class1:hover { color: red } }
77+
// output: `@media (min-width: 500px) { .class1:hover { color: red } }`
78+
79+
// Update styles of existent rule
80+
css.setRule('.class1', { color: 'red', background: 'red' });
81+
css.setRule('.class1', { color: 'blue' }, { addStyles: true });
82+
// output: .class1 { color: blue; background: red }
7783
```
7884

79-
Returns **[CssRule]** The new/updated CssRule
85+
Returns **[CssRule]** The new/updated CssRule.
8086

8187
## getRule
8288

@@ -174,3 +180,5 @@ Returns **this**
174180
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
175181

176182
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
183+
184+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

docs/api/keymaps.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ Add new keymap
6363
* `handler` **([Function][9] | [string][8])** Keymap handler, might be a function
6464
* `opts` **[Object][7]** Options (optional, default `{}`)
6565

66+
* `opts.force` **[Boolean][10]** Force the handler to be executed. (optional, default `false`)
67+
* `opts.prevent` **[Boolean][10]** Prevent default of the original triggered event. (optional, default `false`)
68+
6669
### Examples
6770

6871
```javascript
@@ -71,16 +74,18 @@ keymaps.add('ns:my-keymap', '⌘+j, ⌘+u, ctrl+j, alt+u', editor => {
7174
console.log('do stuff');
7275
});
7376
// or
74-
keymaps.add('ns:my-keymap', '⌘+s, ctrl+s', 'some-gjs-command');
77+
keymaps.add('ns:my-keymap', '⌘+s, ctrl+s', 'some-gjs-command', {
78+
// Prevent the default browser action
79+
prevent: true,
80+
});
7581

7682
// listen to events
77-
editor.on('keymap:emit', (id, shortcut, e) => {
83+
editor.on('keymap:emit', (id, shortcut, event) => {
7884
// ...
7985
})
8086
```
8187

8288
Returns **[Object][7]** Added keymap
83-
or just a command id as a string
8489

8590
## get
8691

@@ -152,3 +157,5 @@ Returns **this**
152157
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
153158

154159
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
160+
161+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

docs/api/pages.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ const pageManager = editor.Pages;
4848

4949
[Component]: component.html
5050

51+
## select
52+
53+
Select the page.
54+
55+
Type: [boolean][9]
56+
5157
## getAll
5258

5359
Get all pages
@@ -58,16 +64,16 @@ Get all pages
5864
const arrayOfPages = pageManager.getAll();
5965
```
6066

61-
Returns **[Array][9]<[Page]>**
67+
Returns **[Array][10]<[Page]>**
6268

6369
## add
6470

6571
Add new page
6672

6773
### Parameters
6874

69-
* `props` **[Object][10]** Page properties
70-
* `opts` **[Object][10]?** Options (optional, default `{}`)
75+
* `props` **[Object][11]** Page properties
76+
* `opts` **[Object][11]?** Options (optional, default `{}`)
7177

7278
### Examples
7379

@@ -87,7 +93,7 @@ Remove page
8793

8894
### Parameters
8995

90-
* `page` **([String][11] | [Page])** Page or page id
96+
* `page` **([String][12] | [Page])** Page or page id
9197
* `opts` **any** (optional, default `{}`)
9298

9399
### Examples
@@ -107,7 +113,7 @@ Get page by id
107113

108114
### Parameters
109115

110-
* `id` **[String][11]** Page id
116+
* `id` **[String][12]** Page id
111117

112118
### Examples
113119

@@ -141,16 +147,16 @@ const wrappers = pageManager.getAllWrappers();
141147
const allImages = wrappers.map(wrp => wrp.findType('image')).flat();
142148
```
143149

144-
Returns **[Array][9]<[Component]>**
150+
Returns **[Array][10]<[Component]>**
145151

146152
## select
147153

148154
Change the selected page. This will switch the page rendered in canvas
149155

150156
### Parameters
151157

152-
* `page` **([String][11] | [Page])** Page or page id
153-
* `opts` (optional, default `{}`)
158+
* `page` **([String][12] | [Page])** Page or page id
159+
* `opts` **SetOptions** (optional, default `{}`)
154160

155161
### Examples
156162

@@ -191,8 +197,10 @@ Returns **[Page]**
191197

192198
[8]: #getselected
193199

194-
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
200+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
201+
202+
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
195203

196-
[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
204+
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
197205

198-
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
206+
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

docs/api/panels.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ Add new panel to the collection
5050
### Examples
5151

5252
```javascript
53-
var newPanel = panelManager.addPanel({
54-
id: 'myNewPanel',
55-
visible : true,
56-
buttons : [...],
53+
const newPanel = panelManager.addPanel({
54+
id: 'myNewPanel',
55+
visible: true,
56+
buttons: [...],
5757
});
5858
```
5959

@@ -65,21 +65,19 @@ Remove a panel from the collection
6565

6666
### Parameters
6767

68-
* `panel` **([Object][11] | Panel | [String][12])** Object with right properties or an instance of Panel or Painel id
68+
* `panel` **(Panel | [String][12])** Panel instance or panel id
6969

7070
### Examples
7171

7272
```javascript
73-
const newPanel = panelManager.removePanel({
74-
id: 'myNewPanel',
75-
visible : true,
76-
buttons : [...],
77-
});
73+
const somePanel = panelManager.getPanel('somePanel');
74+
const removedPanel = panelManager.removePanel(somePanel);
7875

79-
const newPanel = panelManager.removePanel('myNewPanel');
76+
// or by id
77+
const removedPanel = panelManager.removePanel('myNewPanel');
8078
```
8179

82-
Returns **Panel** Removed panel. Useful in case passed argument was an Object
80+
Returns **Panel** Removed panel
8381

8482
## getPanel
8583

@@ -92,7 +90,7 @@ Get panel by ID
9290
### Examples
9391

9492
```javascript
95-
var myPanel = panelManager.getPanel('myNewPanel');
93+
const myPanel = panelManager.getPanel('myPanel');
9694
```
9795

9896
Returns **(Panel | null)**
@@ -109,7 +107,7 @@ Add button to the panel
109107
### Examples
110108

111109
```javascript
112-
var newButton = panelManager.addButton('myNewPanel',{
110+
const newButton = panelManager.addButton('myNewPanel',{
113111
id: 'myNewButton',
114112
className: 'someClass',
115113
command: 'someCommand',
@@ -174,7 +172,7 @@ Get button from the panel
174172
### Examples
175173

176174
```javascript
177-
var button = panelManager.getButton('myPanel','myButton');
175+
const button = panelManager.getButton('myPanel', 'myButton');
178176
```
179177

180178
Returns **(Button | null)**

src/css_composer/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import EditorModel from '../editor/model/Editor';
4040
import Component from '../dom_components/model/Component';
4141
import { ObjectAny } from '../common';
4242

43+
/** @private */
4344
interface RuleOptions {
4445
/**
4546
* At-rule type, eg. `media`
@@ -50,6 +51,8 @@ interface RuleOptions {
5051
*/
5152
atRuleParams?: string;
5253
}
54+
55+
/** @private */
5356
interface SetRuleOptions extends RuleOptions {
5457
/**
5558
* If the rule exists already, merge passed styles instead of replacing them.

src/dom_components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
* * `component:drag:start` - Component drag started. Passed an object, to the callback, containing the `target` (component to drag), `parent` (parent of the component) and `index` (component index in the parent)
3939
* * `component:drag` - During component drag. Passed the same object as in `component:drag:start` event, but in this case, `parent` and `index` are updated by the current pointer
4040
* * `component:drag:end` - Component drag ended. Passed the same object as in `component:drag:start` event, but in this case, `parent` and `index` are updated by the final pointer
41+
* * `component:resize` - During component resize.
4142
*
4243
* ## Methods
4344
* * [getWrapper](#getwrapper)

0 commit comments

Comments
 (0)