If a shape has onSingleClicked event in Excel Online, it will be able to run a command after clicking on a shape.
A temporary solution is to use shape's onActivated event in Excel Online, but this trick doesn't work in Excel desktop.
Work with Events using the Excel JavaScript API - Office Add-ins | Microsoft Docs