Trilium Frontend API
    Preparing search index...

    Class Config<Cfg>

    Handles a configuration dictionary.

    Type Parameters

    • Cfg

      A type of the configuration dictionary.

    Index

    Constructors

    Methods

    Constructors

    • Creates an instance of the ~Config class.

      Type Parameters

      • Cfg

      Parameters

      • Optionalconfigurations: Partial<Cfg>

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

      • OptionaldefaultConfigurations: Partial<Cfg>

        The default configurations. Usually, provided by the system.

      Returns Config<Cfg>

    Methods

    • Does exactly the same as #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.

      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

      KEY_VALUE

    • Does exactly the same as #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.

      Parameters

      • config: Partial<Cfg>

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

      Returns void

      CONFIG_OBJECT

    • 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 GetSubConfig<Cfg, K>

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

    • Iterates over all top level configuration names.

      Returns Iterable<string>

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

      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:CONFIG_OBJECT.

      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

      KEY_VALUE

    • 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:KEY_VALUE.

      Parameters

      • config: Partial<Cfg>

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

      Returns void

      CONFIG_OBJECT