mirror of
https://github.com/google/blockly.git
synced 2026-01-04 23:50:12 +01:00
Add workspace comment context menu option to playground (#3708)
* Add WScomment context menu option to playground
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user