Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: custom block context menus #5976

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,6 @@ class Block {
*/
this.loadExtraState = undefined;

/**
* An optional method called by the default mutator UI which allows the
* block to "explode" itself into smaller sub blocks. This function should
* return a "top block" which is the main block in the mutator workspace
* that sub-blocks connect to.
* @type {undefined|?function():!Block}
*/
this.decompose = undefined;

/**
* An optional method called by the deafult mutator UI which allows the
* block to configure itself based on the configuration of sub-blocks in
* the mutator workspace. This function should accept the "top block" which
* was returned by `decompose` as a paramter.
* @type {undefined|?function(!Block)}
*/
this.compose = undefined;

/**
* An optional method called by the default mutator UI which gives the block
* a chance to save information about what child blocks are connected to
* what mutated connections.
* @type {undefined|?function(!Block)}
*/
this.saveConnections = undefined;

/**
* An optional property for suppressing adding STATEMENT_PREFIX and
Expand Down
14 changes: 11 additions & 3 deletions core/block_svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class BlockSvg extends Block {
* mutation dialog button and UI to appear.
* @type {undefined|?function(WorkspaceSvg):!BlockSvg}
*/
this.decompose = undefined;
this.decompose = this.decompose;

/**
* An optional method called when a mutator dialog saves its content.
Expand All @@ -119,13 +119,21 @@ class BlockSvg extends Block {
* method for the default mutation dialog button and UI to appear.
* @type {undefined|?function(!BlockSvg)}
*/
this.compose = undefined;
this.compose = this.compose;

/**
* An optional method called by the default mutator UI which gives the block
* a chance to save information about what child blocks are connected to
* what mutated connections.
* @type {undefined|?function(!BlockSvg)}
*/
this.saveConnections = this.saveConnections;

/**
* An optional method for defining custom block context menu items.
* @type {undefined|?function(!Array<!Object>)}
*/
this.customContextMenu = undefined;
this.customContextMenu = this.customContextMenu;

/**
* An property used internally to reference the block's rendering debugger.
Expand Down
2 changes: 1 addition & 1 deletion tests/deps.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.