_buildMenuForScratchBlocks (menuName, menuItems, categoryInfo) {
        const menuId = this._makeExtensionMenuId(menuName, categoryInfo.id);

        /** @TODO: support dynamic menus when 'menuItems' is a method name string (see extension spec) */
        if (typeof menuItems === 'string') {
            throw new Error(`Dynamic extension menus are not yet supported. Menu name: ${menuName}`);
        }
        const options = menuItems.map(item => {
            switch (typeof item) {
            case 'string':
                return [item, item];
            case 'object':
                return [item.text, item.value];
            default:
                throw new Error(`Can't interpret menu item: ${item}`);
            }
        });

        return {
            json: {
                message0: '%1',
                type: menuId,
                inputsInline: true,
                output: 'String',
                colour: categoryInfo.color1,
                colourSecondary: categoryInfo.color2,
                colourTertiary: categoryInfo.color3,
                outputShape: ScratchBlocksConstants.OUTPUT_SHAPE_ROUND,
                args0: [
                    {
                        type: 'field_dropdown',
                        name: menuName,
                        options: options
                    }
                ]
            }
        };
    }
/**
     * Build the scratch-blocks JSON for a menu. Note that scratch-blocks treats menus as a special kind of block.
     * @param {string} menuName - the name of the menu
     * @param {array} menuItems - the list of items for this menu
     * @param {CategoryInfo} categoryInfo - the category for this block
     * @returns {object} - a JSON-esque object ready for scratch-blocks' consumption
     * @private
     */
Build the scratch-blocks JSON for a menu. Note that scratch-blocks treats menus as a special kind of block.
Build the scratch - blocks JSON for a menu . Note that scratch - blocks treats menus as a special kind of block .
_buildMenuForScratchBlocks (menuName, menuItems, categoryInfo) {
        const menuId = this._makeExtensionMenuId(menuName, categoryInfo.id);
        if (typeof menuItems === 'string') {
            throw new Error(`Dynamic extension menus are not yet supported. Menu name: ${menuName}`);
        }
        const options = menuItems.map(item => {
            switch (typeof item) {
            case 'string':
                return [item, item];
            case 'object':
                return [item.text, item.value];
            default:
                throw new Error(`Can't interpret menu item: ${item}`);
            }
        });
        return {
            json: {
                message0: '%1',
                type: menuId,
                inputsInline: true,
                output: 'String',
                colour: categoryInfo.color1,
                colourSecondary: categoryInfo.color2,
                colourTertiary: categoryInfo.color3,
                outputShape: ScratchBlocksConstants.OUTPUT_SHAPE_ROUND,
                args0: [
                    {
                        type: 'field_dropdown',
                        name: menuName,
                        options: options
                    }
                ]
            }
        };
    }
_buildMenuForScratchBlocks ( menuName , menuItems , categoryInfo ) { const menuId = this . _makeExtensionMenuId ( menuName , categoryInfo . id ) ; if ( typeof menuItems === 'string' ) { throw new Error ( ` ${ menuName } ` ) ; } const options = menuItems . map ( item => { switch ( typeof item ) { case 'string' : return [ item , item ] ; case 'object' : return [ item . text , item . value ] ; default : throw new Error ( ` ${ item } ` ) ; } } ) ; return { json : { message0 : '%1' , type : menuId , inputsInline : true , output : 'String' , colour : categoryInfo . color1 , colourSecondary : categoryInfo . color2 , colourTertiary : categoryInfo . color3 , outputShape : ScratchBlocksConstants . OUTPUT_SHAPE_ROUND , args0 : [ { type : 'field_dropdown' , name : menuName , options : options } ] } } ; }
Build the scratch-blocks JSON for a menu.
Build the scratch - blocks JSON for a menu .
/** @TODO: support dynamic menus when 'menuItems' is a method name string (see extension spec) */