Skip to content

Commit

Permalink
Up docs
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jul 4, 2023
1 parent 4f81fb7 commit 8ddb937
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/api/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cmp.addType(...);
* `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)
* `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
* `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
* `component:resize` - During component resize.
* `component:resize` - During component resize.

## Methods

Expand Down
20 changes: 14 additions & 6 deletions docs/api/css_composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ Add/update the CssRule.
### Parameters

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

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

### Examples

Expand All @@ -73,10 +74,15 @@ const rule = css.setRule('.class1:hover', { color: 'red' }, {
atRuleType: 'media',
atRuleParams: '(min-width: 500px)',
});
// output: @media (min-width: 500px) { .class1:hover { color: red } }
// output: `@media (min-width: 500px) { .class1:hover { color: red } }`

// Update styles of existent rule
css.setRule('.class1', { color: 'red', background: 'red' });
css.setRule('.class1', { color: 'blue' }, { addStyles: true });
// output: .class1 { color: blue; background: red }
```

Returns **[CssRule]** The new/updated CssRule
Returns **[CssRule]** The new/updated CssRule.

## getRule

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

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
13 changes: 10 additions & 3 deletions docs/api/keymaps.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Add new keymap
* `handler` **([Function][9] | [string][8])** Keymap handler, might be a function
* `opts` **[Object][7]** Options (optional, default `{}`)

* `opts.force` **[Boolean][10]** Force the handler to be executed. (optional, default `false`)
* `opts.prevent` **[Boolean][10]** Prevent default of the original triggered event. (optional, default `false`)

### Examples

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

// listen to events
editor.on('keymap:emit', (id, shortcut, e) => {
editor.on('keymap:emit', (id, shortcut, event) => {
// ...
})
```

Returns **[Object][7]** Added keymap
or just a command id as a string

## get

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

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
30 changes: 19 additions & 11 deletions docs/api/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ const pageManager = editor.Pages;

[Component]: component.html

## select

Select the page.

Type: [boolean][9]

## getAll

Get all pages
Expand All @@ -58,16 +64,16 @@ Get all pages
const arrayOfPages = pageManager.getAll();
```

Returns **[Array][9]<[Page]>**
Returns **[Array][10]<[Page]>**

## add

Add new page

### Parameters

* `props` **[Object][10]** Page properties
* `opts` **[Object][10]?** Options (optional, default `{}`)
* `props` **[Object][11]** Page properties
* `opts` **[Object][11]?** Options (optional, default `{}`)

### Examples

Expand All @@ -87,7 +93,7 @@ Remove page

### Parameters

* `page` **([String][11] | [Page])** Page or page id
* `page` **([String][12] | [Page])** Page or page id
* `opts` **any** (optional, default `{}`)

### Examples
Expand All @@ -107,7 +113,7 @@ Get page by id

### Parameters

* `id` **[String][11]** Page id
* `id` **[String][12]** Page id

### Examples

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

Returns **[Array][9]<[Component]>**
Returns **[Array][10]<[Component]>**

## select

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

### Parameters

* `page` **([String][11] | [Page])** Page or page id
* `opts` (optional, default `{}`)
* `page` **([String][12] | [Page])** Page or page id
* `opts` **SetOptions** (optional, default `{}`)

### Examples

Expand Down Expand Up @@ -191,8 +197,10 @@ Returns **[Page]**

[8]: #getselected

[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
28 changes: 13 additions & 15 deletions docs/api/panels.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ Add new panel to the collection
### Examples

```javascript
var newPanel = panelManager.addPanel({
id: 'myNewPanel',
visible : true,
buttons : [...],
const newPanel = panelManager.addPanel({
id: 'myNewPanel',
visible: true,
buttons: [...],
});
```

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

### Parameters

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

### Examples

```javascript
const newPanel = panelManager.removePanel({
id: 'myNewPanel',
visible : true,
buttons : [...],
});
const somePanel = panelManager.getPanel('somePanel');
const removedPanel = panelManager.removePanel(somePanel);

const newPanel = panelManager.removePanel('myNewPanel');
// or by id
const removedPanel = panelManager.removePanel('myNewPanel');
```

Returns **Panel** Removed panel. Useful in case passed argument was an Object
Returns **Panel** Removed panel

## getPanel

Expand All @@ -92,7 +90,7 @@ Get panel by ID
### Examples

```javascript
var myPanel = panelManager.getPanel('myNewPanel');
const myPanel = panelManager.getPanel('myPanel');
```

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

```javascript
var newButton = panelManager.addButton('myNewPanel',{
const newButton = panelManager.addButton('myNewPanel',{
id: 'myNewButton',
className: 'someClass',
command: 'someCommand',
Expand Down Expand Up @@ -174,7 +172,7 @@ Get button from the panel
### Examples

```javascript
var button = panelManager.getButton('myPanel','myButton');
const button = panelManager.getButton('myPanel', 'myButton');
```

Returns **(Button | null)**
Expand Down
3 changes: 3 additions & 0 deletions src/css_composer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import EditorModel from '../editor/model/Editor';
import Component from '../dom_components/model/Component';
import { ObjectAny } from '../common';

/** @private */
interface RuleOptions {
/**
* At-rule type, eg. `media`
Expand All @@ -50,6 +51,8 @@ interface RuleOptions {
*/
atRuleParams?: string;
}

/** @private */
interface SetRuleOptions extends RuleOptions {
/**
* If the rule exists already, merge passed styles instead of replacing them.
Expand Down
1 change: 1 addition & 0 deletions src/dom_components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* * `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)
* * `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
* * `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
* * `component:resize` - During component resize.
*
* ## Methods
* * [getWrapper](#getwrapper)
Expand Down

0 comments on commit 8ddb937

Please sign in to comment.