diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 4a3adb510..0a2af7229 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -268,6 +268,13 @@ Blockly.WorkspaceSvg.prototype.flyoutButtonCallbacks_ = {}; */ Blockly.WorkspaceSvg.prototype.toolboxCategoryCallbacks_ = {}; +/** + * Developers may define this function to add custom menu options to the + * workspace's context menu or edit the workspace-created set of menu options. + * @param {!Array.} options List of menu options to add to. + */ +Blockly.WorkspaceSvg.prototype.configureContextMenu = null; + /** * In a flyout, the target workspace where blocks should be placed after a drag. * Otherwise null. @@ -1310,6 +1317,11 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { }; menuOptions.push(deleteOption); + // Allow the developer to add or modify menuOptions. + if (this.configureContextMenu) { + this.configureContextMenu(menuOptions); + } + Blockly.ContextMenu.show(e, menuOptions, this.RTL); };