Report an issue
Class

CKEDITOR.tools.style.parse

class since 4.6.1

The namespace with helper functions to parse some common CSS properties.

Filtering

Properties

Methods

  • background( value ) → Object

    Parses the value used as a background property shorthand and returns information as an object.

    Note: Currently only the color property is extracted. Any other parts will go into the unprocessed 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.

    Properties
    color : 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.

  • deprecated 4.12.0

    border( value ) → border

    Parameters

    value : String

    The border property value.

    Returns

    border

    Border style.

  • margin( value ) → Object.<String, String>

    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>

    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.

  • private

    _findColor( value ) → String[]

    Searches the value for any CSS color occurrences and returns it.

    Parameters

    value : String

    Returns

    String[]

    An array of matched results.