Config (utils)
@ckeditor/ckeditor5-utils/src/config
Handles a configuration dictionary.
Filtering
Properties
-
_config : Object
module:utils/config~Config#_config
private
Store for the whole configuration.
Methods
-
constructor( [ configurations ], [ defaultConfigurations ] )
module:utils/config~Config#constructor
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 )
module:utils/config~Config#define
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 ) → *
module:utils/config~Config#get
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>
module:utils/config~Config#names
Iterates over all top level configuration names.
Returns
Iterable.<String>
-
set( name, value )
module:utils/config~Config#set
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 thewidth
configuration in theresize
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 ) → *
module:utils/config~Config#_getFromSource
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 ] )
module:utils/config~Config#_setObjectToTarget
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 ] )
module:utils/config~Config#_setToTarget
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
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.