mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
feat: make isMutator public (#6316)
* feat: make isMutator public * fix: move isFlyout and isMutator to getters * chore: delete change detector test
This commit is contained in:
@@ -255,7 +255,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
|
||||
this.workspace_.setMetricsManager(
|
||||
new FlyoutMetricsManager(this.workspace_, this));
|
||||
|
||||
this.workspace_.isFlyout = true;
|
||||
this.workspace_.internalIsFlyout = true;
|
||||
// Keep the workspace visibility consistent with the flyout's visibility.
|
||||
this.workspace_.setVisible(this.isVisible_);
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ export class Mutator extends Icon {
|
||||
workspaceOptions.languageTree = toolbox.convertToolboxDefToJson(quarkXml);
|
||||
}
|
||||
this.workspace_ = this.newWorkspaceSvg(workspaceOptions);
|
||||
this.workspace_.isMutator = true;
|
||||
this.workspace_.internalIsMutator = true;
|
||||
this.workspace_.addChangeListener(eventUtils.disableOrphans);
|
||||
|
||||
// Mutator flyouts go inside the mutator workspace's <g> rather than in
|
||||
|
||||
@@ -61,14 +61,27 @@ export class Workspace implements IASTNodeLocation {
|
||||
*/
|
||||
rendered = false;
|
||||
|
||||
/**
|
||||
* Is this workspace the surface for a flyout?
|
||||
* @internal
|
||||
*/
|
||||
internalIsFlyout = false;
|
||||
|
||||
/** Is this workspace the surface for a flyout? */
|
||||
isFlyout = false;
|
||||
get isFlyout(): boolean {
|
||||
return this.internalIsFlyout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this workspace the surface for a mutator?
|
||||
* @internal
|
||||
*/
|
||||
isMutator = false;
|
||||
internalIsMutator = false;
|
||||
|
||||
/** Is this workspace the surface for a mutator? */
|
||||
get isMutator(): boolean {
|
||||
return this.internalIsMutator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the workspace is currently in the process of a bulk
|
||||
|
||||
@@ -124,48 +124,6 @@ suite('WorkspaceSvg', function() {
|
||||
});
|
||||
});
|
||||
|
||||
suite('addTopBlock', function() {
|
||||
setup(function() {
|
||||
this.targetWorkspace = new Blockly.Workspace();
|
||||
this.workspace.isFlyout = true;
|
||||
this.workspace.targetWorkspace = this.targetWorkspace;
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
"type": "get_var_block",
|
||||
"message0": "%1",
|
||||
"args0": [
|
||||
{
|
||||
"type": "field_variable",
|
||||
"name": "VAR",
|
||||
"variableTypes": ["", "type1", "type2"],
|
||||
},
|
||||
],
|
||||
}]);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
// Have to dispose of the main workspace after the flyout workspace
|
||||
// because it holds the variable map.
|
||||
// Normally the main workspace disposes of the flyout workspace.
|
||||
workspaceTeardown.call(this, this.targetWorkspace);
|
||||
});
|
||||
|
||||
test('Trivial Flyout is True', function() {
|
||||
this.targetWorkspace.createVariable('name1', '', '1');
|
||||
|
||||
// Flyout.init usually does this binding.
|
||||
this.workspace.variableMap_ = this.targetWorkspace.getVariableMap();
|
||||
|
||||
Blockly.Events.disable();
|
||||
const block = new Blockly.Block(this.workspace, 'get_var_block');
|
||||
block.inputList[0].fieldRow[0].setValue('1');
|
||||
Blockly.Events.enable();
|
||||
|
||||
this.workspace.removeTopBlock(block);
|
||||
this.workspace.addTopBlock(block);
|
||||
assertVariableValues(this.workspace, 'name1', '', '1');
|
||||
});
|
||||
});
|
||||
|
||||
suite('Viewport change events', function() {
|
||||
function resetEventHistory(eventsFireStub, changeListenerSpy) {
|
||||
eventsFireStub.resetHistory();
|
||||
|
||||
Reference in New Issue
Block a user