Free and Open source Web Builder Framework. Next generation tool for building templates without coding
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

2.9 KiB

CssRule

Extends Model.extend(Styleable)

Properties

  • selectors Array<Selector> Array of selectors
  • style Object Object containing style definitions
  • selectorsAdd String? Additional string css selectors
  • atRuleType String? Type of at-rule, eg. media, 'font-face'
  • mediaText String? At-rule value, eg. (max-width: 1000px)
  • singleAtRule Boolean? This property is used only on at-rules, like 'page' or 'font-face', where the block containes only style declarations
  • state String? State of the rule, eg: hover, focused
  • important (Boolean | Array<String>)? If true, sets !important on all properties. You can also pass an array to specify properties on which use important
  • stylable Boolean? Indicates if the rule is stylable from the editor

getAtRule

Returns the at-rule statement when exists, eg. @media (...), @keyframes

Examples

const cssRule = editor.Css.setRule('.class1', { color: 'red' }, {
 atRuleType: 'media',
 atRuleParams: '(min-width: 500px)'
});
cssRule.getAtRule(); // "@media (min-width: 500px)"

Returns String

selectorsToString

Return selectors of the rule as a string

Parameters

  • opts Object? Options (optional, default {})

    • opts.skipState Boolean? Skip state from the result

Examples

const cssRule = editor.Css.setRule('.class1:hover', { color: 'red' });
cssRule.selectorsToString(); // ".class1:hover"
cssRule.selectorsToString({ skipState: true }); // ".class1"

Returns String

getDeclaration

Get declaration block (without the at-rule statement)

Parameters

  • opts Object Options (same as in selectorsToString) (optional, default {})

Examples

const cssRule = editor.Css.setRule('.class1', { color: 'red' }, {
 atRuleType: 'media',
 atRuleParams: '(min-width: 500px)'
});
cssRule.getDeclaration() // ".class1{color:red;}"

Returns String

toCSS

Return the CSS string of the rule

Parameters

  • opts Object Options (same as in getDeclaration) (optional, default {})

Examples

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 CSS string