Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jan 27, 2022
1 parent 03fcff0 commit 20bf7e9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
16 changes: 14 additions & 2 deletions docs/api/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ component.get('tagName');
* `selectable` **[Boolean][3]?** Allow component to be selected when clicked. Default: `true`
* `hoverable` **[Boolean][3]?** Shows a highlight outline when hovering on the element if `true`. Default: `true`
* `void` **[Boolean][3]?** This property is used by the HTML exporter as void elements don't have closing tags, eg. `<br/>`, `<hr/>`, etc. Default: `false`
* `style` **[Object][2]?** Component default style, eg. `{ width: '100px', height: '100px', 'background-color': 'red' }`
* `styles` **[String][1]?** Component related styles, eg. `.my-component-class { color: red }`
* `content` **[String][1]?** Content of the component (not escaped) which will be appended before children rendering. Default: `''`
* `icon` **[String][1]?** Component's icon, this string will be inserted before the name (in Layers and badge), eg. it can be an HTML string '<i class="fa fa-square-o"></i>'. Default: `''`
Expand Down Expand Up @@ -632,8 +633,9 @@ Return HTML string of the component
* `opts` **[Object][2]** Options (optional, default `{}`)

* `opts.tag` **[String][1]?** Custom tagName
* `opts.attributes` **([Object][2] | [Function][4])** You can pass an object of custom attributes to replace
with the current one or you can even pass a function to generate attributes dynamically (optional, default `null`)
* `opts.attributes` **([Object][2] | [Function][4])** You can pass an object of custom attributes to replace with the current ones or you can even pass a function to generate attributes dynamically. (optional, default `null`)
* `opts.withProps` **[Boolean][3]?** Include component properties as `data-gjs-*` attributes. This allows you to have re-importable HTML.
* `opts.altQuoteAttr` **[Boolean][3]?** In case the attribute value contains a `"` char, instead of escaping it (`attr="value &quot;"`), the attribute will be quoted using single quotes (`attr='value "'`).

#### Examples

Expand Down Expand Up @@ -662,6 +664,16 @@ component.toHTML({

Returns **[String][1]** HTML string

### getInnerHTML

Get inner HTML of the component

#### Parameters

* `opts` **[Object][2]** Same options of `toHTML` (optional, default `{}`)

Returns **[String][1]** HTML string

### getChangedProps

Return an object containing only changed props
Expand Down
1 change: 1 addition & 0 deletions docs/api/editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Returns CSS built inside canvas
* `opts.component` **Component?** Return the CSS of a specific Component
* `opts.json` **[Boolean][18]** Return an array of CssRules instead of the CSS string (optional, default `false`)
* `opts.avoidProtected` **[Boolean][18]** Don't include protected CSS (optional, default `false`)
* `opts.onlyMatched` **[Boolean][18]** Return only rules matched by the passed component. (optional, default `false`)

Returns **([String][16] | [Array][19]\<CssRule>)** CSS string or array of CssRules

Expand Down
8 changes: 6 additions & 2 deletions docs/api/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Parse HTML string and return the object containing the Component Definition
* `options` **[Object][5]?** Options (optional, default `{}`)

* `options.htmlType` **[String][6]?** [HTML mime type][7] to parse
* `options.allowScripts` **[Boolean][8]** Allow `<script>` tags (optional, default `false`)
* `options.allowUnsafeAttr` **[Boolean][8]** Allow unsafe HTML attributes (eg. `on*` inline event handlers) (optional, default `false`)

### Examples

Expand Down Expand Up @@ -83,7 +85,7 @@ const res = Parser.parseCss('.cls { color: red }');
// [{ ... }]
```

Returns **[Array][8]<[Object][5]>** Array containing the result
Returns **[Array][9]<[Object][5]>** Array containing the result

[1]: https://github.com/artf/grapesjs/blob/master/src/parser/config/config.js

Expand All @@ -99,4 +101,6 @@ Returns **[Array][8]<[Object][5]>** Array containing the result

[7]: https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02

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

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

0 comments on commit 20bf7e9

Please sign in to comment.