Config (utils)
@ckeditor/ckeditor5-utils/src/config
Handles a configuration dictionary.
Filtering
Type parameters
-
Cfg
A type of the configuration dictionary.
Properties
-
Store for the whole configuration.
Methods
-
constructor( [ configurations ], [ defaultConfigurations ] )
module:utils/config~Config#constructor
Creates an instance of the
Config
class.Type parameters
Cfg
Parameters
[ configurations ] : Partial<Cfg>
The initial configurations to be set. Usually, provided by the user.
[ defaultConfigurations ] : Partial<Cfg>
The default configurations. Usually, provided by the system.
-
define( config ) → void
module:utils/config~Config#define:CONFIG_OBJECT
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
config : Partial<Cfg>
The configuration object from which take properties as configuration entries. Configuration names are case-sensitive.
Returns
void
-
define( name, value ) → void
module:utils/config~Config#define:KEY_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.
Type parameters
K : extends string
Parameters
name : K
The configuration name. Configuration names are case-sensitive.
value : GetSubConfig<Cfg, K>
The configuration value.
Returns
void
-
get( name ) → undefined | GetSubConfig<Cfg, K>
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' );
Type parameters
K : extends string
Parameters
name : K
The configuration name. Configuration names are case-sensitive.
Returns
undefined | GetSubConfig<Cfg, K>
The configuration value or
undefined
if the configuration entry was not found.
-
names() → Iterable<string>
module:utils/config~Config#names
-
set( config ) → void
module:utils/config~Config#set:CONFIG_OBJECT
Set configuration values.
It accepts an object, which properties and values will be used to set configurations.
config.set( { width: 500 toolbar: { collapsed: true } } ); // Equivalent to: config.set( 'width', 500 ); config.set( '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'
It accepts both a name/value pair or an object, which properties and values will be used to set configurations. See
set
.Parameters
config : Partial<Cfg>
The configuration object from which take properties as configuration entries. Configuration names are case-sensitive.
Returns
void
-
set( name, value ) → void
module:utils/config~Config#set:KEY_VALUE
Set configuration values.
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( 'resize.width', 500 );
It accepts both a name/value pair or an object, which properties and values will be used to set configurations. See
set
.Type parameters
K : extends string
Parameters
name : K
The configuration name. Configuration names are case-sensitive.
value : GetSubConfig<Cfg, K>
The configuration value.
Returns
void
-
Get specified configuration from specified source (nested object).
Parameters
source : any
level of nested object.
name : string
The configuration name. Configuration names are case-sensitive.
Returns
any
The configuration value or
undefined
if the configuration entry was not found.
-
private
_setObjectToTarget( target, configuration, [ isDefine ] ) → void
module:utils/config~Config#_setObjectToTarget
Iterates through passed object and calls
_setToTarget
method with object key and value for each property.Parameters
target : any
Nested config object.
configuration : any
Configuration data set
[ isDefine ] : boolean
Defines if passed configuration is default configuration or not.
Returns
void
-
Saves passed configuration to the specified target (nested object).
Parameters
target : any
Nested config object.
name : any
The configuration name or an object from which take properties as configuration entries. Configuration names are case-sensitive.
value : any
The configuration value. Used if a name is passed.
isDefine : boolean
Define if passed configuration should overwrite existing one.
Defaults to
false
Returns
void
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.