From 4cfe66fa0419e6140ff6f7cad1c1bfc884917a72 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 5 Aug 2024 13:32:31 -0700 Subject: [PATCH] fix: allow specifying the function to be used for prompting about variable creation/edits (#106) --- src/variables.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/variables.js b/src/variables.js index a171730293..7fac2359aa 100644 --- a/src/variables.js +++ b/src/variables.js @@ -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 @@ -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) { @@ -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) {