Skip to content

Commit

Permalink
contextmenu.blockcollapseoption
Browse files Browse the repository at this point in the history
  • Loading branch information
jwklong authored Dec 8, 2024
1 parent d1db727 commit 97cfd95
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,31 @@ Blockly.ContextMenu.blockDuplicateOption = function(block, event) {
return duplicateOption;
};

/**
* Make a context menu option for adding or removing comments on the current
* block.
* @param {!Blockly.BlockSvg} block The block where the right-click originated.
* @return {!Object} A menu option, containing text, enabled, and a callback.
* @package
*/
Blockly.ContextMenu.blockCollapseOption = function(block) {
var commentOption = {
enabled: true
};
if (block.isCollapsed()) {
commentOption.text = "Expand block";
commentOption.callback = function() {
block.setCollapsed(false)
};
} else {
commentOption.text = "Collapse block";
commentOption.callback = function() {
block.setCollapsed(true)
};
}
return commentOption;
};

/**
* Make a context menu option for adding or removing comments on the current
* block.
Expand Down

0 comments on commit 97cfd95

Please sign in to comment.