# Config

class

Handles a configuration dictionary.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L17)

<a id="type-parameters">

## Type parameters

### `Cfg`

A type of the configuration dictionary.

<a id="properties">

## Properties

<a id="member-_config">

### `_config: Record<string, any>` _(private)_

Store for the whole configuration.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L21)

<a id="methods">

## Methods

<a id="function-constructor">

### `constructor( configurations?, defaultConfigurations? )`

Creates an instance of the [`Config`](module_utils_config-Config.md) class.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L29)

#### Type parameters

* `Cfg`

  A type of the configuration dictionary.

#### 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.

<a id="function-define:CONFIG_OBJECT">

### `define( config ) → void`

Does exactly the same as [`set`](#function-set:CONFIG_OBJECT) 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.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L134)

#### Parameters

* `config: Partial<Cfg>`

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

#### Returns

* `void`

<a id="function-define:KEY_VALUE">

### `define( name, value ) → void`

Does exactly the same as [`set`](#function-set:KEY_VALUE) 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.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L121)

#### 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`

<a id="function-get">

### `get( name ) → GetSubConfig<Cfg, K> | undefined`

Gets the value for a configuration entry.

```typescript
config.get( 'name' );
```

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

```typescript
config.get( 'toolbar.collapsed' );
```

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L158)

#### Type parameters

* `K: extends string`

#### Parameters

* `name: K`

  The configuration name. Configuration names are case-sensitive.

#### Returns

* `GetSubConfig<Cfg, K> | undefined`

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

<a id="function-names">

### `names() → Iterable<string>`

Iterates over all top level configuration names.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L165)

#### Returns

* `Iterable<string>`

<a id="function-set:CONFIG_OBJECT">

### `set( config ) → void`

Set configuration values.

It accepts an object, which properties and values will be used to set configurations.

```typescript
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.

```typescript
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`](#function-set:KEY_VALUE).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L104)

#### Parameters

* `config: Partial<Cfg>`

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

#### Returns

* `void`

<a id="function-set:KEY_VALUE">

### `set( name, value ) → void`

Set configuration values.

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.

```typescript
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`](#function-set:CONFIG_OBJECT).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L62)

#### 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`

<a id="function-_getFromSource">

### `_getFromSource( source, name ) → any` _(private)_

Get specified configuration from specified source (nested object).

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L235)

#### 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.

<a id="function-_setObjectToTarget">

### `_setObjectToTarget( target, configuration, isDefine? ) → void` _(private)_

Iterates through passed object and calls [`_setToTarget`](#function-_setToTarget) method with object key and value for each property.

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L264)

#### Parameters

* `target: any`

  Nested config object.

* `configuration: any`

  Configuration data set

* `isDefine?: boolean`

  Defines if passed configuration is default configuration or not.

#### Returns

* `void`

<a id="function-_setToTarget">

### `_setToTarget( target, name, value, isDefine ) → void` _(private)_

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

[See source](https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-utils/src/config.ts#L180)

#### 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`

---

Full index of the CKEditor 5 API reference: [llms.txt](llms.txt)
