Move alert/confirm/prompt to a new file, dialog.js (#5457)

* Migrate prompt/alert/confirm to dedicated module

* Update core/blockly.js to pass through calls to prompt/alert/confirm to core/dialog.js

* Update calls to Blockly.prompt/alert/confirm to dialog.prompt/alert/confirm

* Fix typo and errant redeclaration of Blockly.prompt

* Clarify JSDoc on customizing Blockly.dialog.alert/confirm/prompt
This commit is contained in:
Aaron Dodson
2021-09-14 08:19:53 -07:00
committed by GitHub
parent ff9320f8d9
commit ce8e7921a2
12 changed files with 174 additions and 60 deletions

View File

@@ -22,6 +22,7 @@ goog.require('Blockly.common');
goog.require('Blockly.ComponentManager');
goog.require('Blockly.connectionTypes');
goog.require('Blockly.constants');
goog.require('Blockly.dialog');
goog.require('Blockly.DropDownDiv');
goog.require('Blockly.Events');
/** @suppress {extraRequire} */
@@ -255,41 +256,50 @@ Blockly.hideChaff = function(opt_onlyClosePopups) {
*/
Blockly.getMainWorkspace = Blockly.common.getMainWorkspace;
/**
* Wrapper to window.alert() that app developers may override to
* provide alternatives to the modal browser window.
* @param {string} message The message to display to the user.
* @param {function()=} opt_callback The callback when the alert is dismissed.
*/
Blockly.alert = function(message, opt_callback) {
alert(message);
if (opt_callback) {
opt_callback();
// Add a getter and setter pair for Blockly.alert, for legacy reasons.
Object.defineProperty(Blockly, 'alert', {
set: function(newAlert) {
Blockly.utils.deprecation.warn(
'Blockly.alert', 'September 2021', 'September 2022');
Blockly.dialog.setAlert(newAlert);
},
get: function() {
Blockly.utils.deprecation.warn(
'Blockly.alert', 'September 2021', 'September 2022',
'Blockly.dialog.alert()');
return Blockly.dialog.alert;
}
};
});
/**
* Wrapper to window.confirm() that app developers may override to
* provide alternatives to the modal browser window.
* @param {string} message The message to display to the user.
* @param {!function(boolean)} callback The callback for handling user response.
*/
Blockly.confirm = function(message, callback) {
callback(confirm(message));
};
// Add a getter and setter pair for Blockly.confirm, for legacy reasons.
Object.defineProperty(Blockly, 'confirm', {
set: function(newConfirm) {
Blockly.utils.deprecation.warn(
'Blockly.confirm', 'September 2021', 'September 2022');
Blockly.dialog.setConfirm(newConfirm);
},
get: function() {
Blockly.utils.deprecation.warn(
'Blockly.confirm', 'September 2021', 'September 2022',
'Blockly.dialog.confirm()');
return Blockly.dialog.confirm;
}
});
/**
* Wrapper to window.prompt() that app developers may override to provide
* alternatives to the modal browser window. Built-in browser prompts are
* often used for better text input experience on mobile device. We strongly
* recommend testing mobile when overriding this.
* @param {string} message The message to display to the user.
* @param {string} defaultValue The value to initialize the prompt with.
* @param {!function(?string)} callback The callback for handling user response.
*/
Blockly.prompt = function(message, defaultValue, callback) {
callback(prompt(message, defaultValue));
};
// Add a getter and setter pair for Blockly.prompt, for legacy reasons.
Object.defineProperty(Blockly, 'prompt', {
set: function(newPrompt) {
Blockly.utils.deprecation.warn(
'Blockly.prompt', 'September 2021', 'September 2022');
Blockly.dialog.setPrompt(newPrompt);
},
get: function() {
Blockly.utils.deprecation.warn(
'Blockly.prompt', 'September 2021', 'September 2022',
'Blockly.dialog.prompt()');
return Blockly.dialog.prompt;
}
});
/**
* Helper function for defining a block from JSON. The resulting function has

View File

@@ -22,6 +22,7 @@ const Msg = goog.require('Blockly.Msg');
/* eslint-disable-next-line no-unused-vars */
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const clipboard = goog.require('Blockly.clipboard');
const dialog = goog.require('Blockly.dialog');
const idGenerator = goog.require('Blockly.utils.idGenerator');
const inputTypes = goog.require('Blockly.inputTypes');
const userAgent = goog.require('Blockly.utils.userAgent');
@@ -292,7 +293,7 @@ const registerDeleteAll = function() {
if (deletableBlocks.length < 2) {
deleteNext_(deletableBlocks, eventGroup);
} else {
Blockly.confirm(
dialog.confirm(
Msg['DELETE_ALL_BLOCKS'].replace('%1', deletableBlocks.length),
function(ok) {
if (ok) {

98
core/dialog.js Normal file
View File

@@ -0,0 +1,98 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Wrapper functions around JS functions for showing
* alert/confirmation dialogs.
*/
'use strict';
goog.module('Blockly.dialog');
goog.module.declareLegacyNamespace();
let alertImplementation = function(message, opt_callback) {
window.alert(message);
if (opt_callback) {
opt_callback();
}
};
let confirmImplementation = function(message, callback) {
callback(window.confirm(message));
};
let promptImplementation = function(message, defaultValue, callback) {
callback(window.prompt(message, defaultValue));
};
/**
* Wrapper to window.alert() that app developers may override via setAlert to
* provide alternatives to the modal browser window.
* @param {string} message The message to display to the user.
* @param {function()=} opt_callback The callback when the alert is dismissed.
*/
const alert = function(message, opt_callback) {
alertImplementation(message, opt_callback);
};
exports.alert = alert;
/**
* Sets the function to be run when Blockly.dialog.alert() is called.
* @param {!function(string, function()=)} alertFunction The function to be run.
* @see Blockly.dialog.alert
*/
const setAlert = function(alertFunction) {
alertImplementation = alertFunction;
};
exports.setAlert = setAlert;
/**
* Wrapper to window.confirm() that app developers may override via setConfirm
* to provide alternatives to the modal browser window.
* @param {string} message The message to display to the user.
* @param {!function(boolean)} callback The callback for handling user response.
*/
const confirm = function(message, callback) {
confirmImplementation(message, callback);
};
exports.confirm = confirm;
/**
* Sets the function to be run when Blockly.dialog.confirm() is called.
* @param {!function(string, !function(boolean))} confirmFunction The function
* to be run.
* @see Blockly.dialog.confirm
*/
const setConfirm = function(confirmFunction) {
confirmImplementation = confirmFunction;
};
exports.setConfirm = setConfirm;
/**
* Wrapper to window.prompt() that app developers may override via setPrompt to
* provide alternatives to the modal browser window. Built-in browser prompts
* are often used for better text input experience on mobile device. We strongly
* recommend testing mobile when overriding this.
* @param {string} message The message to display to the user.
* @param {string} defaultValue The value to initialize the prompt with.
* @param {!function(?string)} callback The callback for handling user response.
*/
const prompt = function(message, defaultValue, callback) {
promptImplementation(message, defaultValue, callback);
};
exports.prompt = prompt;
/**
* Sets the function to be run when Blockly.dialog.prompt() is called.
* @param {!function(string, string, !function(?string))} promptFunction The
* function to be run.
* @see Blockly.dialog.prompt
*/
const setPrompt = function(promptFunction) {
promptImplementation = promptFunction;
};
exports.setPrompt = setPrompt;

View File

@@ -13,7 +13,6 @@
goog.module('Blockly.FieldTextInput');
goog.module.declareLegacyNamespace();
const Blockly = goog.require('Blockly');
/* eslint-disable-next-line no-unused-vars */
const BlockSvg = goog.requireType('Blockly.BlockSvg');
const Coordinate = goog.require('Blockly.utils.Coordinate');
@@ -27,6 +26,7 @@ const WidgetDiv = goog.require('Blockly.WidgetDiv');
const WorkspaceSvg = goog.requireType('Blockly.WorkspaceSvg');
const aria = goog.require('Blockly.utils.aria');
const browserEvents = goog.require('Blockly.browserEvents');
const dialog = goog.require('Blockly.dialog');
const dom = goog.require('Blockly.utils.dom');
const fieldRegistry = goog.require('Blockly.fieldRegistry');
const object = goog.require('Blockly.utils.object');
@@ -312,7 +312,7 @@ FieldTextInput.prototype.showEditor_ = function(_opt_e, opt_quietInput) {
* @private
*/
FieldTextInput.prototype.showPromptEditor_ = function() {
Blockly.prompt(Msg['CHANGE_VALUE_TITLE'], this.getText(), function(text) {
dialog.prompt(Msg['CHANGE_VALUE_TITLE'], this.getText(), function(text) {
this.setValue(this.getValueFromEditorText_(text));
}.bind(this));
};

View File

@@ -21,6 +21,7 @@ const Names = goog.require('Blockly.Names');
const VariableModel = goog.require('Blockly.VariableModel');
/* eslint-disable-next-line no-unused-vars */
const Workspace = goog.requireType('Blockly.Workspace');
const dialog = goog.require('Blockly.dialog');
const idGenerator = goog.require('Blockly.utils.idGenerator');
const object = goog.require('Blockly.utils.object');
/** @suppress {extraRequire} */
@@ -233,7 +234,7 @@ VariableMap.prototype.deleteVariableById = function(id) {
const deleteText = Msg['CANNOT_DELETE_VARIABLE_PROCEDURE']
.replace('%1', variableName)
.replace('%2', procedureName);
Blockly.alert(deleteText);
dialog.alert(deleteText);
return;
}
}
@@ -244,7 +245,7 @@ VariableMap.prototype.deleteVariableById = function(id) {
const confirmText = Msg['DELETE_VARIABLE_CONFIRMATION']
.replace('%1', String(uses.length))
.replace('%2', variableName);
Blockly.confirm(confirmText, function(ok) {
dialog.confirm(confirmText, function(ok) {
if (ok && variable) {
map.deleteVariableInternal(variable, uses);
}

View File

@@ -23,6 +23,7 @@ const VariableModel = goog.require('Blockly.VariableModel');
/* eslint-disable-next-line no-unused-vars */
const Workspace = goog.requireType('Blockly.Workspace');
const Xml = goog.require('Blockly.Xml');
const dialog = goog.require('Blockly.dialog');
const utilsXml = goog.require('Blockly.utils.xml');
@@ -267,7 +268,7 @@ const createVariableButtonHandler = function(
msg = Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE'];
msg = msg.replace('%1', existing.name).replace('%2', existing.type);
}
Blockly.alert(msg, function() {
dialog.alert(msg, function() {
promptAndCheckWithAlert(text); // Recurse
});
} else {
@@ -313,7 +314,7 @@ const renameVariable = function(workspace, variable, opt_callback) {
const msg = Msg['VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE']
.replace('%1', existing.name)
.replace('%2', existing.type);
Blockly.alert(msg, function() {
dialog.alert(msg, function() {
promptAndCheckWithAlert(newName); // Recurse
});
} else {
@@ -342,7 +343,7 @@ exports.renameVariable = renameVariable;
* variable name, or null if the user picked something illegal.
*/
const promptName = function(promptText, defaultText, callback) {
Blockly.prompt(promptText, defaultText, function(newVar) {
dialog.prompt(promptText, defaultText, function(newVar) {
// Merge runs of whitespace. Strip leading and trailing whitespace.
// Beyond this, all names are legal.
if (newVar) {

View File

@@ -375,7 +375,7 @@ Code.checkAllGeneratorFunctionsDefined = function(generator) {
if (!valid) {
var msg = 'The generator code for the following blocks not specified for ' +
generator.name_ + ':\n - ' + missingBlockGenerators.join('\n - ');
Blockly.alert(msg); // Assuming synchronous. No callback.
Blockly.dialog.alert(msg); // Assuming synchronous. No callback.
}
return valid;
};

View File

@@ -13,16 +13,16 @@
*/
CustomDialog = {};
/** Override Blockly.alert() with custom implementation. */
Blockly.alert = function(message, callback) {
/** Override Blockly.dialog.alert() with custom implementation. */
Blockly.dialog.setAlert(function(message, callback) {
console.log('Alert: ' + message);
CustomDialog.show('Alert', message, {
onCancel: callback
});
};
});
/** Override Blockly.confirm() with custom implementation. */
Blockly.confirm = function(message, callback) {
/** Override Blockly.dialog.confirm() with custom implementation. */
Blockly.dialog.setConfirm(function(message, callback) {
console.log('Confirm: ' + message);
CustomDialog.show('Confirm', message, {
showOkay: true,
@@ -34,10 +34,10 @@ Blockly.confirm = function(message, callback) {
callback(false);
}
});
};
});
/** Override Blockly.prompt() with custom implementation. */
Blockly.prompt = function(message, defaultValue, callback) {
/** Override Blockly.dialog.prompt() with custom implementation. */
Blockly.dialog.setPrompt(function(message, defaultValue, callback) {
console.log('Prompt: ' + message);
CustomDialog.show('Prompt', message, {
showInput: true,
@@ -51,7 +51,7 @@ Blockly.prompt = function(message, defaultValue, callback) {
}
});
CustomDialog.inputField.value = defaultValue;
};
});
/** Hides any currently visible dialog. */
CustomDialog.hide = function() {

View File

@@ -70,7 +70,7 @@ CustomFields.FieldPitch.prototype.showEditor_ = function() {
var div = Blockly.WidgetDiv.getDiv();
if (!div.firstChild) {
// Mobile interface uses Blockly.prompt.
// Mobile interface uses Blockly.dialog.prompt.
return;
}
// Build the DOM.

View File

@@ -12,7 +12,7 @@ goog.addDependency('../../core/block_animations.js', ['Blockly.blockAnimations']
goog.addDependency('../../core/block_drag_surface.js', ['Blockly.BlockDragSurfaceSvg'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/block_dragger.js', ['Blockly.BlockDragger'], ['Blockly.Events', 'Blockly.Events.BlockDrag', 'Blockly.Events.BlockMove', 'Blockly.InsertionMarkerManager', 'Blockly.blockAnimations', 'Blockly.common', 'Blockly.registry', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/block_svg.js', ['Blockly.BlockSvg'], ['Blockly.ASTNode', 'Blockly.Block', 'Blockly.ContextMenu', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Events.Selected', 'Blockly.FieldLabel', 'Blockly.MarkerManager', 'Blockly.Msg', 'Blockly.RenderedConnection', 'Blockly.TabNavigateCursor', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Xml', 'Blockly.blockAnimations', 'Blockly.browserEvents', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.Svg', 'Blockly.utils.deprecation', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/blockly.js', ['Blockly'], ['Blockly.ComponentManager', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.Ui', 'Blockly.Events.UiBase', 'Blockly.Events.VarCreate', 'Blockly.Procedures', 'Blockly.ShortcutRegistry', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.clipboard', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.inject', 'Blockly.inputTypes', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.toolbox']);
goog.addDependency('../../core/blockly.js', ['Blockly'], ['Blockly.ComponentManager', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.FinishedLoading', 'Blockly.Events.Ui', 'Blockly.Events.UiBase', 'Blockly.Events.VarCreate', 'Blockly.Procedures', 'Blockly.ShortcutRegistry', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.clipboard', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.dialog', 'Blockly.inject', 'Blockly.inputTypes', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.colour', 'Blockly.utils.deprecation', 'Blockly.utils.toolbox']);
goog.addDependency('../../core/blockly_options.js', ['Blockly.BlocklyOptions'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/blocks.js', ['Blockly.Blocks'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/browser_events.js', ['Blockly.browserEvents'], ['Blockly.Touch', 'Blockly.utils.global'], {'lang': 'es6', 'module': 'goog'});
@@ -28,10 +28,11 @@ goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Bl
goog.addDependency('../../core/connection_types.js', ['Blockly.connectionTypes'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/constants.js', ['Blockly.constants'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/contextmenu.js', ['Blockly.ContextMenu'], ['Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Menu', 'Blockly.MenuItem', 'Blockly.Msg', 'Blockly.WidgetDiv', 'Blockly.Xml', 'Blockly.browserEvents', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Rect', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/contextmenu_items.js', ['Blockly.ContextMenuItems'], ['Blockly', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Msg', 'Blockly.clipboard', 'Blockly.inputTypes', 'Blockly.utils.idGenerator', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/contextmenu_items.js', ['Blockly.ContextMenuItems'], ['Blockly', 'Blockly.ContextMenuRegistry', 'Blockly.Events', 'Blockly.Msg', 'Blockly.clipboard', 'Blockly.dialog', 'Blockly.inputTypes', 'Blockly.utils.idGenerator', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/contextmenu_registry.js', ['Blockly.ContextMenuRegistry'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/css.js', ['Blockly.Css'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/delete_area.js', ['Blockly.DeleteArea'], ['Blockly.BlockSvg', 'Blockly.DragTarget', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/dialog.js', ['Blockly.dialog'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/drag_target.js', ['Blockly.DragTarget'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/dropdowndiv.js', ['Blockly.DropDownDiv'], ['Blockly.common', 'Blockly.utils.Rect', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.style'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/events/events.js', ['Blockly.Events'], ['Blockly.registry', 'Blockly.utils.deprecation', 'Blockly.utils.idGenerator'], {'lang': 'es6', 'module': 'goog'});
@@ -74,7 +75,7 @@ goog.addDependency('../../core/field_label_serializable.js', ['Blockly.FieldLabe
goog.addDependency('../../core/field_multilineinput.js', ['Blockly.FieldMultilineInput'], ['Blockly.Css', 'Blockly.Field', 'Blockly.FieldTextInput', 'Blockly.WidgetDiv', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.KeyCodes', 'Blockly.utils.Svg', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/field_number.js', ['Blockly.FieldNumber'], ['Blockly.FieldTextInput', 'Blockly.fieldRegistry', 'Blockly.utils.aria', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/field_registry.js', ['Blockly.fieldRegistry'], ['Blockly.registry'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/field_textinput.js', ['Blockly.FieldTextInput'], ['Blockly', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.WidgetDiv', 'Blockly.browserEvents', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/field_textinput.js', ['Blockly.FieldTextInput'], ['Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.WidgetDiv', 'Blockly.browserEvents', 'Blockly.dialog', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/field_variable.js', ['Blockly.FieldVariable'], ['Blockly.Events.BlockChange', 'Blockly.FieldDropdown', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Variables', 'Blockly.Xml', 'Blockly.fieldRegistry', 'Blockly.internalConstants', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/flyout_base.js', ['Blockly.Flyout'], ['Blockly', 'Blockly.ComponentManager', 'Blockly.DeleteArea', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.VarCreate', 'Blockly.FlyoutMetricsManager', 'Blockly.Gesture', 'Blockly.ScrollbarPair', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.Variables', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.idGenerator', 'Blockly.utils.object', 'Blockly.utils.toolbox', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/flyout_button.js', ['Blockly.FlyoutButton'], ['Blockly.Css', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.style'], {'lang': 'es6', 'module': 'goog'});
@@ -230,9 +231,9 @@ goog.addDependency('../../core/utils/svg_paths.js', ['Blockly.utils.svgPaths'],
goog.addDependency('../../core/utils/toolbox.js', ['Blockly.utils.toolbox'], ['Blockly.Xml', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/utils/useragent.js', ['Blockly.utils.userAgent'], ['Blockly.utils.global'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/utils/xml.js', ['Blockly.utils.xml'], [], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/variable_map.js', ['Blockly.VariableMap'], ['Blockly.Events', 'Blockly.Events.VarDelete', 'Blockly.Events.VarRename', 'Blockly.Msg', 'Blockly.Names', 'Blockly.VariableModel', 'Blockly.utils.idGenerator', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/variable_map.js', ['Blockly.VariableMap'], ['Blockly.Events', 'Blockly.Events.VarDelete', 'Blockly.Events.VarRename', 'Blockly.Msg', 'Blockly.Names', 'Blockly.VariableModel', 'Blockly.dialog', 'Blockly.utils.idGenerator', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/variable_model.js', ['Blockly.VariableModel'], ['Blockly.Events', 'Blockly.Events.VarCreate', 'Blockly.utils.idGenerator'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/variables.js', ['Blockly.Variables'], ['Blockly.Blocks', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Xml', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/variables.js', ['Blockly.Variables'], ['Blockly.Blocks', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Xml', 'Blockly.dialog', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/variables_dynamic.js', ['Blockly.VariablesDynamic'], ['Blockly.Blocks', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Variables', 'Blockly.utils.xml'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/warning.js', ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Events', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
goog.addDependency('../../core/widgetdiv.js', ['Blockly.WidgetDiv'], ['Blockly.common', 'Blockly.utils.deprecation', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});

View File

@@ -255,7 +255,8 @@ suite('Context Menu Items', function() {
test('Deletes all blocks after confirming', function() {
// Mocks the confirmation dialog and calls the callback with 'true' simulating ok.
var confirmStub = sinon.stub(Blockly, 'confirm').callsArgWith(1, true);
var confirmStub = sinon.stub(
Blockly.dialog, 'confirm').callsArgWith(1, true);
this.workspace.newBlock('text');
this.workspace.newBlock('text');
@@ -267,7 +268,8 @@ suite('Context Menu Items', function() {
test('Does not delete blocks if not confirmed', function() {
// Mocks the confirmation dialog and calls the callback with 'false' simulating cancel.
var confirmStub = sinon.stub(Blockly, 'confirm').callsArgWith(1, false);
var confirmStub = sinon.stub(
Blockly.dialog, 'confirm').callsArgWith(1, false);
this.workspace.newBlock('text');
this.workspace.newBlock('text');

View File

@@ -115,7 +115,7 @@ function testAWorkspace() {
test('deleteVariableById(id1) multiple usages confirm', function() {
// Deleting variable with multiple usages triggers confirm dialog.
var stub =
sinon.stub(Blockly, "confirm").callsArgWith(1, true);
sinon.stub(Blockly.dialog, "confirm").callsArgWith(1, true);
this.workspace.deleteVariableById('id1');
sinon.assert.calledOnce(stub);
@@ -128,7 +128,7 @@ function testAWorkspace() {
test('deleteVariableById(id1) multiple usages cancel', function() {
// Deleting variable with multiple usages triggers confirm dialog.
var stub =
sinon.stub(Blockly, "confirm").callsArgWith(1, false);
sinon.stub(Blockly.dialog, "confirm").callsArgWith(1, false);
this.workspace.deleteVariableById('id1');
sinon.assert.calledOnce(stub);