Back to Grapesjs

Selector

docs/api/selector.md

0.22.162.0 KB
Original Source
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

Selector

Properties

  • name String Selector name, eg. my-class
  • label String Selector label, eg. My Class
  • type Number? Type of the selector. 1 (class) | 2 (id)
  • active Boolean? If not active, it's not selectable by the Style Manager.
  • private Boolean? If true, it can't be seen by the Style Manager, but it will be rendered in the canvas and in export code.
  • protected Boolean? If true, it can't be removed from the attached component.

toString

Get selector as a string.

Examples

javascript
// Given such selector: { name: 'my-selector', type: 2 }
console.log(selector.toString());
// -> `#my-selector`

Returns String

getName

Get selector name.

Examples

javascript
// Given such selector: { name: 'my-selector', label: 'My selector' }
console.log(selector.getName());
// -> `my-selector`

Returns String

getLabel

Get selector label.

Examples

javascript
// Given such selector: { name: 'my-selector', label: 'My selector' }
console.log(selector.getLabel());
// -> `My selector`

Returns String

setLabel

Update selector label.

Parameters

Examples

javascript
// Given such selector: { name: 'my-selector', label: 'My selector' }
selector.setLabel('New Label')
console.log(selector.getLabel());
// -> `New Label`

getActive

Get selector active state.

Returns Boolean

setActive

Update selector active state.

Parameters