Class

Config (utils)

@ckeditor/ckeditor5-utils/src/config

class

Handles a configuration dictionary.

Filtering

Properties

  • _config : Object

    private

    Store for the whole configuration.

Methods

  • constructor( [ configurations ], [ defaultConfigurations ] )

    Creates an instance of the Config class.

    Parameters

    [ configurations ] : Object

    The initial configurations to be set. Usually, provided by the user.

    [ defaultConfigurations ] : Object

    The default configurations. Usually, provided by the system.

  • define( name, value )

    Does exactly the same as set with one exception – passed configuration extends existing one, but does not overwrite already defined values.

    This method is supposed to be called by plugin developers to setup plugin's configurations. It would be rarely used for other needs.

    Parameters

    name : String | Object

    The configuration name or an object from which take properties as configuration entries. Configuration names are case-sensitive.

    value : *

    The configuration value. Used if a name is passed.

  • get( name ) → *

    Gets the value for a configuration entry.

    config.get( 'name' );
    

    Deep configurations can be retrieved by separating each part with a dot.

    config.get( 'toolbar.collapsed' );

    Parameters

    name : String

    The configuration name. Configuration names are case-sensitive.

    Returns

    *

    The configuration value or undefined if the configuration entry was not found.

  • names() → Iterable.<String>

    Iterates over all top level configuration names.

    Returns

    Iterable.<String>
  • set( name, value )

    Set configuration values.

    It accepts both a name/value pair or an object, which properties and values will be used to set configurations.

    It also accepts setting a "deep configuration" by using dots in the name. For example, 'resize.width' sets the value for the width configuration in the resize subset.

    config.set( 'width', 500 );
    config.set( 'toolbar.collapsed', true );
    
    // Equivalent to:
    config.set( {
    	width: 500
    	toolbar: {
    		collapsed: true
    	}
    } );
    

    Passing an object as the value will amend the configuration, not replace it.

    config.set( 'toolbar', {
    	collapsed: true,
    } );
    
    config.set( 'toolbar', {
    	color: 'red',
    } );
    
    config.get( 'toolbar.collapsed' ); // true
    config.get( 'toolbar.color' ); // 'red'

    Parameters

    name : String | Object

    The configuration name or an object from which take properties as configuration entries. Configuration names are case-sensitive.

    value : *

    The configuration value. Used if a name is passed.

  • _getFromSource( source, name ) → *

    private

    Get specified configuration from specified source (nested object).

    Parameters

    source : Object

    level of nested object.

    name : String

    The configuration name. Configuration names are case-sensitive.

    Returns

    *

    The configuration value or undefined if the configuration entry was not found.

  • _setObjectToTarget( target, configuration, [ isDefine ] )

    private

    Iterates through passed object and calls _setToTarget method with object key and value for each property.

    Parameters

    target : Object

    Nested config object.

    configuration : Object

    Configuration data set

    [ isDefine ] : Boolean

    Defines if passed configuration is default configuration or not.

  • _setToTarget( target, name, value, [ isDefine ] )

    private

    Saves passed configuration to the specified target (nested object).

    Parameters

    target : Object

    Nested config object.

    name : String | Object

    The configuration name or an object from which take properties as configuration entries. Configuration names are case-sensitive.

    value : *

    The configuration value. Used if a name is passed.

    [ isDefine ] : Boolean

    Define if passed configuration should overwrite existing one.

    Defaults to false