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 ) → Object
CKEDITOR.tools.style.parse#background
Parses the
value
used as abackground
property shorthand and returns information as an object.Note: Currently only the
color
property is extracted. Any other parts will go into theunprocessed
property.var background = CKEDITOR.tools.style.parse.background( '#0C0 url(foo.png)' ); console.log( background ); // Logs: { color: '#0C0', unprocessed: 'url(foo.png)' }
Parameters
value : String
The value of the
background
property.
Returns
Object
An object with information extracted from the background.
Propertiescolor : String
The first color value found. The color format remains the same as in input.
unprocessed : String
The remaining part of the
value
that has not been processed.
-
-
margin( value ) → Object.<String, String>
CKEDITOR.tools.style.parse#margin
Parses the
margin
CSS property shorthand format.console.log( CKEDITOR.tools.parse.margin( '3px 0 2' ) ); // Logs: { top: "3px", right: "0", bottom: "2", left: "0" }
Parameters
value : String
The
margin
property value.
Returns
Object.<String, String>
-
Properties
top : String
Top margin.
right : String
Right margin.
bottom : String
Bottom margin.
left : String
Left margin.
-
since 4.12.0
sideShorthand( value, [ split ] ) → Object.<String, String>
CKEDITOR.tools.style.parse#sideShorthand
Parses the CSS property shorthand format of all
top
,right
,bottom
,left
sides.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 : String
The shorthand property value.
[ split ] : Function
The function used to split the CSS property shorthand. It should return an array of side shorthand parts (see the
split
function in the code listing). If not set, the property value will be split by spaces.
Returns
Object.<String, String>
-
Properties
top : String
Top value.
right : String
Right value.
bottom : String
Bottom value.
left : String
Left value.
-
Searches the
value
for any CSS color occurrences and returns it.Parameters
value : String
Returns
String[]
An array of matched results.