typograph-editor-documentation
    Preparing search index...

    Class MenuAPI

    Index

    Constructors

    Methods

    • Add a custom item to an existing menu. The item is disabled until a validator is registered for its ID.

      Parameters

      • menuTitleId: string

        Menu to add the item to, e.g. "menutitle-file"

      • descriptor: CustomMenuItemDescriptor

        Label and optional shortcut text

      • position: MenuItemPosition = 'end'

        Where to insert the item (default: 'end')

      Returns void

    • Prevent a menu item from appearing when its menu is opened. Call showItem() to restore it.

      Parameters

      • itemId: string

        e.g. "menutitle-file_Save_as_Template"

      Returns void

    • Remove a top-level menu title from the menu bar. The menu is not destroyed; call showMenu() to restore it.

      Parameters

      • menuTitleId: string

        e.g. "menutitle-help"

      Returns void

    • Internal

      Parameters

      • menuTitleId: string

      Returns boolean

    • Register an action for a menu item. Called when the user clicks the item. Return true to suppress the editor's built-in action; return false or nothing to also run the built-in action. Replaces any previously registered action for this item.

      Parameters

      • itemId: string

        Item ID, e.g. "menutitle-file_Save"

      • fn: MenuAction

        Action callback

      Returns void

    • Register a validator for a menu item. Called each time the menu opens to determine enabled/disabled state. Return true to enable, false to disable, null to defer to the editor's built-in logic. Replaces any previously registered validator for this item.

      Parameters

      • itemId: string

        Item ID, e.g. "menutitle-file_Save"

      • fn: MenuValidator

        Validator callback

      Returns void

    • Internal

      Parameters

      • id: string

      Returns boolean

    • Internal

      Parameters

      • id: string

      Returns boolean

    • Restore a previously hidden menu item.

      Parameters

      • itemId: string

        e.g. "menutitle-file_Save_as_Template"

      Returns void

    • Restore a previously hidden menu title to the menu bar.

      Parameters

      • menuTitleId: string

        e.g. "menutitle-help"

      Returns void

    • Remove a previously registered action. The editor's built-in action resumes for this item.

      Parameters

      • itemId: string

        Item ID

      Returns void

    • Remove a previously registered validator. The editor's built-in enabled/disabled logic resumes for this item.

      Parameters

      • itemId: string

        Item ID

      Returns void