function(menuOptions) {
    // Add the edit option at the end.
    menuOptions.push(Blockly.Procedures.makeEditOption(this));

    // Find the delete option and update its callback to be specific to
    // functions.
    for (var i = 0, option; option = menuOptions[i]; i++) {
      if (option.text == Blockly.Msg.DELETE_BLOCK) {
        var input = this.getInput('custom_block');
        // this is the root block, not the shadow block.
        if (input && input.connection && input.connection.targetBlock()) {
          var procCode = input.connection.targetBlock().getProcCode();
        } else {
          return;
        }
        var rootBlock = this;
        option.callback = function() {
          var didDelete = Blockly.Procedures.deleteProcedureDefCallback(
              procCode, rootBlock);
          if (!didDelete) {
            // TODO:(#1151)
            alert('To delete a block definition, first remove all uses of the block');
          }
        };
      }
    }
    // Find and remove the duplicate option
    for (var i = 0, option; option = menuOptions[i]; i++) {
      if (option.text == Blockly.Msg.DUPLICATE) {
        menuOptions.splice(i, 1);
        break;
      }
    }
  }
function(menuOptions) {
    // Add the edit option at the end.
    menuOptions.push(Blockly.Procedures.makeEditOption(this));

    // Find the delete option and update its callback to be specific to
    // functions.
    for (var i = 0, option; option = menuOptions[i]; i++) {
      if (option.text == Blockly.Msg.DELETE_BLOCK) {
        var input = this.getInput('custom_block');
        // this is the root block, not the shadow block.
        if (input && input.connection && input.connection.targetBlock()) {
          var procCode = input.connection.targetBlock().getProcCode();
        } else {
          return;
        }
        var rootBlock = this;
        option.callback = function() {
          var didDelete = Blockly.Procedures.deleteProcedureDefCallback(
              procCode, rootBlock);
          if (!didDelete) {
            // TODO:(#1151)
            alert('To delete a block definition, first remove all uses of the block');
          }
        };
      }
    }
    // Find and remove the duplicate option
    for (var i = 0, option; option = menuOptions[i]; i++) {
      if (option.text == Blockly.Msg.DUPLICATE) {
        menuOptions.splice(i, 1);
        break;
      }
    }
  }
function ( menuOptions ) { // Add the edit option at the end. menuOptions . push ( Blockly . Procedures . makeEditOption ( this ) ) ; // Find the delete option and update its callback to be specific to // functions. for ( var i = 0 , option ; option = menuOptions [ i ] ; i ++ ) { if ( option . text == Blockly . Msg . DELETE_BLOCK ) { var input = this . getInput ( 'custom_block' ) ; // this is the root block, not the shadow block. if ( input && input . connection && input . connection . targetBlock ( ) ) { var procCode = input . connection . targetBlock ( ) . getProcCode ( ) ; } else { return ; } var rootBlock = this ; option . callback = function ( ) { var didDelete = Blockly . Procedures . deleteProcedureDefCallback ( procCode , rootBlock ) ; if ( ! didDelete ) { // TODO:(#1151) alert ( 'To delete a block definition, first remove all uses of the block' ) ; } } ; } } // Find and remove the duplicate option for ( var i = 0 , option ; option = menuOptions [ i ] ; i ++ ) { if ( option . text == Blockly . Msg . DUPLICATE ) { menuOptions . splice ( i , 1 ) ; break ; } } }
Add the "edit" option and removes the "duplicate" option from the context
menu.
@param {!Array.<!Object>} menuOptions List of menu options to edit.
@this Blockly.Block
Add the edit option and removes the duplicate option from the context menu .
Add the edit option to the menu.