Skip to content

Commit

Permalink
fix: allow specifying the function to be used for prompting about var…
Browse files Browse the repository at this point in the history
…iable creation/edits (#106)
  • Loading branch information
gonfunko authored Aug 5, 2024
1 parent 7478546 commit 4cfe66f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ import {
*/
const CLOUD_PREFIX = "☁ ";

let prompt = null;

export function setPromptHandler(handler) {
prompt = handler;
}

/**
* Create a new variable on the given workspace.
* @param {!Blockly.Workspace} workspace The workspace on which to create the
Expand Down Expand Up @@ -70,7 +76,7 @@ export function createVariable(workspace, opt_callback, opt_type) {
var validate = nameValidator.bind(null, opt_type);

// Prompt the user to enter a name for the variable
Blockly.dialog.prompt(
prompt(
newMsg,
"",
function (text, additionalVars, variableOptions) {
Expand Down Expand Up @@ -309,7 +315,7 @@ export function renameVariable(workspace, variable, opt_callback) {
promptDefaultText = promptDefaultText.substring(CLOUD_PREFIX.length);
}

Blockly.dialog.prompt(
prompt(
promptText,
promptDefaultText,
function (newName, additionalVars) {
Expand Down

0 comments on commit 4cfe66f

Please # to comment.