CKEDITOR.tools.style.parse
The namespace with helper functions to parse some common CSS properties.
Filtering
Properties
-
This list is deprecated, use CKEDITOR.tools.color.namedColors instead.
Methods
-
background( value ) → ObjectCKEDITOR.tools.style.parse#backgroundParses the
valueused as abackgroundproperty shorthand and returns information as an object.Note: Currently only the
colorproperty is extracted. Any other parts will go into theunprocessedproperty.var background = CKEDITOR.tools.style.parse.background( '#0C0 url(foo.png)' ); console.log( background ); // Logs: { color: '#0C0', unprocessed: 'url(foo.png)' }Parameters
value : StringThe value of the
backgroundproperty.
Returns
ObjectAn object with information extracted from the background.
Propertiescolor : StringThe first color value found. The color format remains the same as in input.
unprocessed : StringThe remaining part of the
valuethat has not been processed.
-
-
margin( value ) → Object.<String, String>CKEDITOR.tools.style.parse#marginParses the
marginCSS property shorthand format.console.log( CKEDITOR.tools.parse.margin( '3px 0 2' ) ); // Logs: { top: "3px", right: "0", bottom: "2", left: "0" }Parameters
value : StringThe
marginproperty value.
Returns
Object.<String, String>-
Properties
top : StringTop margin.
right : StringRight margin.
bottom : StringBottom margin.
left : StringLeft margin.
-
since 4.12.0
sideShorthand( value, [ split ] ) → Object.<String, String>CKEDITOR.tools.style.parse#sideShorthandParses the CSS property shorthand format of all
top,right,bottom,leftsides.console.log( CKEDITOR.tools.style.parse.sideShorthand( 'solid dotted' ) ); // Logs: { top: 'solid', right: 'dotted', bottom: 'solid', left: 'dotted' } console.log( CKEDITOR.tools.style.parse.sideShorthand( 'foo baz', split ) ); // Logs: { top: 'foo', right: 'baz', bottom: 'foo', left: 'baz' } console.log( CKEDITOR.tools.style.parse.sideShorthand( 'something else', split ) ); // Logs: { top: 'bar', right: 'quix', bottom: 'bar', left: 'quix' } function split( value ) { return value.match( /(foo|baz)/g ) || [ 'bar', 'quix' ]; }Parameters
value : StringThe shorthand property value.
[ split ] : FunctionThe function used to split the CSS property shorthand. It should return an array of side shorthand parts (see the
splitfunction in the code listing). If not set, the property value will be split by spaces.
Returns
Object.<String, String>-
Properties
top : StringTop value.
right : StringRight value.
bottom : StringBottom value.
left : StringLeft value.
-
Searches the
valuefor any CSS color occurrences and returns it.Parameters
value : String
Returns
String[]An array of matched results.