Add workspace comment context menu option to playground (#3708)

* Add WScomment context menu option to playground
This commit is contained in:
Beka Westberg
2020-02-25 14:32:51 -08:00
committed by GitHub
parent 97eb86f988
commit ec8d76f143
2 changed files with 12 additions and 2 deletions

View File

@@ -395,6 +395,7 @@ 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.<!Object>} options List of menu options to add to.
* @param {!Event} e The right-click event that triggered the context menu.
*/
Blockly.WorkspaceSvg.prototype.configureContextMenu;
@@ -1800,7 +1801,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu = function(e) {
// Allow the developer to add or modify menuOptions.
if (this.configureContextMenu) {
this.configureContextMenu(menuOptions);
this.configureContextMenu(menuOptions, e);
}
Blockly.ContextMenu.show(e, menuOptions, this.RTL);

View File

@@ -69,12 +69,18 @@
<script>
// Custom requires for the playground.
// Rendering.
goog.require('Blockly.blockRendering.Debug');
goog.require('Blockly.minimalist.Renderer');
goog.require('Blockly.Themes.Modern');
goog.require('Blockly.Themes.Zelos');
goog.require('Blockly.thrasos.Renderer');
goog.require('Blockly.zelos.Renderer');
// Other.
goog.require('Blockly.WorkspaceCommentSvg');
goog.require('Blockly.WorkspaceCommentSvg.render');
</script>
<script>
'use strict';
@@ -456,7 +462,7 @@ function toggleAccessibilityMode(state) {
}
}
function configureContextMenu(menuOptions) {
function configureContextMenu(menuOptions, e) {
var screenshotOption = {
text: 'Download Screenshot',
enabled: workspace.getTopBlocks().length,
@@ -465,6 +471,9 @@ function configureContextMenu(menuOptions) {
}
};
menuOptions.push(screenshotOption);
// Adds a default-sized workspace comment to the workspace.
menuOptions.push(Blockly.ContextMenu.workspaceCommentOption(workspace, e));
}
function logger(e) {