@samatawy/diagrams
    Preparing search index...

    Class ThemeRegistry

    A static registry for diagram editor UI themes.

    Themes are partial DiagramTheme token sets. When applied to an element they are set as CSS custom properties and inherited by all children — so any editor component rendered inside that element picks up the theme automatically, whether inside a full DiagramEditor or a hand-wired custom layout.

    Precedence (lowest → highest):

    1. Built-in defaults
    2. setDefaults() overrides
    3. Named theme tokens
    4. Inline overrides passed to apply()
    Index

    Constructors

    Methods

    • Overrides one or more global default token values. Useful when you want to adjust the baseline without creating a named theme. The changes apply to all themes and persist until resetDefaults() is called. Note that existing themes are not affected; they will continue to inherit the old defaults until re-applied.

      Parameters

      • vars: DiagramTheme

        Partial token set with new default values.

      Returns void

    • Registers a named theme. Themes are partial; unspecified tokens fall back to the current defaults when resolved.

      Parameters

      • name: string

        Unique name for the theme.

      • theme: DiagramTheme

        Partial token set defining the theme. Only tokens that differ from the defaults need to be included.

      Returns void

    • Unregisters a named theme.

      Parameters

      • name: string

        The name of the theme to unregister.

      Returns void

    • Checks if a theme with the given name is registered.

      Parameters

      • name: string

        The name of the theme to check.

      Returns boolean

      True if the theme is registered, otherwise false.

    • Returns a list of all registered theme names.

      Returns string[]

      An array of registered theme names.

    • Resolves a final token map by merging in order: current defaults → named theme (if any) → optional inline overrides. Returns a plain object; nothing is applied to the DOM.

      Parameters

      • Optionaltheme: string | DiagramTheme

        A registered theme name or an inline theme object.

      • Optionaloverrides: DiagramTheme

        Optional inline token overrides applied on top of the resolved theme.

      Returns DiagramTheme

      The final resolved theme object.

    • Applies a theme to an element as CSS custom properties. The vars are scoped to that element and inherited by all children, so any editor component rendered inside it consumes the theme automatically.

      Parameters

      • element: HTMLElement

        The element to receive the CSS custom properties.

      • Optionaltheme: string | DiagramTheme

        A registered theme name, an inline DiagramTheme object, or omit to apply the current defaults only.

      • Optionaloverrides: DiagramTheme

        Extra token overrides applied on top of the resolved theme.

      Returns void

    • Removes all CSS custom properties that were set by this registry on the element. Properties belonging to other systems are not touched.

      Parameters

      • element: HTMLElement

        The element to clean up.

      Returns void