ThemeManager

See source code
Table of contents

Manages the editor's color themes.

Stores named theme definitions (each containing light and dark color palettes alongside shared properties like font size). The current theme is resolved by combining the current theme name with the user's color mode preference.

Terminology: - Theme (TLTheme): A named set of colors and typographic values for both light and dark modes. - Color mode ('light' | 'dark'): The resolved appearance mode, derived from the user's colorScheme preference ('light' | 'dark' | 'system'). Access via getColorMode().

class ThemeManager {}

Constructor

Constructs a new instance of the ThemeManager class

Parameters

NameDescription

editor

Editor;

options

{
  initial: TLThemeId;
  themes: TLThemes;
};

Methods

dispose( )

Clean up any resources held by the manager.

dispose(): void;

getColorMode( )

Get the current color mode based on the user's dark mode preference.

getColorMode(): "dark" | "light";

getCurrentTheme( )

getCurrentTheme(): TLTheme;

getCurrentThemeId( )

Get the id of the current theme.

getCurrentThemeId(): TLThemeId;

getTheme( )

Get a single theme definition by id.

getTheme(id: TLThemeId): TLTheme | undefined;

Parameters

NameDescription

id

Returns

TLTheme | undefined;

getThemes( )

Get all registered theme definitions.

getThemes(): TLThemes;

setCurrentTheme( )

Set the current theme by id. The theme must have been previously registered.

setCurrentTheme(id: TLThemeId): void;

Parameters

NameDescription

id

Returns

void;

updateTheme( )

Register or update a named theme definition.

updateTheme(theme: TLTheme): void;

Parameters

NameDescription

theme

TLTheme;

Returns

void;

updateThemes( )

Replace all theme definitions, or update them via a callback that receives a deep copy.

updateThemes(themes: ((themes: TLThemes) => TLThemes) | TLThemes): void;

Parameters

NameDescription

themes

((themes: TLThemes) => TLThemes) | TLThemes;

Returns

void;

Prev
TextManager
Next
TransformedGeometry2d