@samatawy/diagrams
    Preparing search index...

    Class FontSelect

    A dropdown control for selecting font families. Emits a 'fontchange' event when the selected font changes. Example usage: const fontSelect = new FontSelect(document.getElementById('font-select'), { fonts: ['Arial', 'Verdana', 'Tahoma'], showPreview: true, });

    Index

    Constructors

    Properties

    host: HTMLElement
    config: Required<Omit<FontSelectConfig, "fonts">> & { fonts: string[] }
    selected: string
    trigger: HTMLButtonElement
    triggerPreview: HTMLSpanElement
    menu: HTMLDivElement

    Accessors

    Methods

    • Sets the available font options and optionally selects a font.

      Parameters

      • fonts: string[]

        An array of font family names.

      • OptionalselectedFont: string

        The font to select. Defaults to the first font in the array.

      Returns void

    • Handles the click event on the trigger button. Toggles the open/closed state of the dropdown menu.

      Returns void

    • Handles the click event on the document to close the menu when clicking outside.

      Parameters

      • event: Event

      Returns void

    • Handles the click event on a font option. Selects the clicked font and closes the menu.

      Parameters

      • event: Event

        The click event.

      Returns void

    • Replaces the current option list with a new set of font families.

      Parameters

      • fonts: string[]

        The font family strings to render.

      Returns void

    • Builds a single option button with an optional font-preview span.

      Parameters

      • font: string

        The CSS font-family string for this option.

      Returns HTMLButtonElement

      The constructed option button element.

    • Updates the internal selection state, syncs the trigger and option list, and optionally emits 'fontchange'.

      Parameters

      • font: string

        The new font family to select.

      • emit: boolean = true

        Whether to dispatch the change event. Defaults to true.

      Returns void