mirror of https://github.com/artf/grapesjs.git
4 changed files with 96 additions and 5 deletions
@ -0,0 +1,83 @@ |
|||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> |
|||
|
|||
## getAtRule |
|||
|
|||
Return the at-rule statement when exists, eg. '@media (...)', '@keyframes' |
|||
|
|||
### Examples |
|||
|
|||
```javascript |
|||
const cssRule = editor.Css.setRule('.class1', { color: 'red' }, { |
|||
atRuleType: 'media', |
|||
atRuleParams: '(min-width: 500px)' |
|||
}); |
|||
cssRule.getAtRule(); // "@media (min-width: 500px)" |
|||
``` |
|||
|
|||
Returns **[String][1]** |
|||
|
|||
## selectorsToString |
|||
|
|||
Return selectors of the rule as a string |
|||
|
|||
### Parameters |
|||
|
|||
* `opts` **[Object][2]?** Options (optional, default `{}`) |
|||
|
|||
* `opts.skipState` **[Boolean][3]?** Skip state from the result |
|||
|
|||
### Examples |
|||
|
|||
```javascript |
|||
const cssRule = editor.Css.setRule('.class1:hover', { color: 'red' }); |
|||
cssRule.selectorsToString(); // ".class1:hover" |
|||
cssRule.selectorsToString({ skipState: true }); // ".class1" |
|||
``` |
|||
|
|||
Returns **[String][1]** |
|||
|
|||
## getDeclaration |
|||
|
|||
Get declaration block (without the at-rule statement) |
|||
|
|||
### Parameters |
|||
|
|||
* `opts` **[Object][2]** Options (same as in `selectorsToString`) (optional, default `{}`) |
|||
|
|||
### Examples |
|||
|
|||
```javascript |
|||
const cssRule = editor.Css.setRule('.class1', { color: 'red' }, { |
|||
atRuleType: 'media', |
|||
atRuleParams: '(min-width: 500px)' |
|||
}); |
|||
cssRule.getDeclaration() // ".class1{color:red;}" |
|||
``` |
|||
|
|||
Returns **[String][1]** |
|||
|
|||
## toCSS |
|||
|
|||
Return the CSS string of the rule |
|||
|
|||
### Parameters |
|||
|
|||
* `opts` **[Object][2]** Options (same as in `getDeclaration`) (optional, default `{}`) |
|||
|
|||
### Examples |
|||
|
|||
```javascript |
|||
const cssRule = editor.Css.setRule('.class1', { color: 'red' }, { |
|||
atRuleType: 'media', |
|||
atRuleParams: '(min-width: 500px)' |
|||
}); |
|||
cssRule.toCSS() // "@media (min-width: 500px){.class1{color:red;}}" |
|||
``` |
|||
|
|||
Returns **[String][1]** CSS string |
|||
|
|||
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
|||
|
|||
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
|||
|
|||
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
|||
Loading…
Reference in new issue