diff --git a/pxtblocks/blocklyloader.ts b/pxtblocks/blocklyloader.ts index e851855aeffe..cd243e0f25ef 100644 --- a/pxtblocks/blocklyloader.ts +++ b/pxtblocks/blocklyloader.ts @@ -716,7 +716,8 @@ namespace pxt.blocks { block.setPreviousStatement(!(hasHandlers && !fn.attributes.handlerStatement) && fn.retType == "void"); block.setNextStatement(!(hasHandlers && !fn.attributes.handlerStatement) && fn.retType == "void"); - block.setTooltip(/^__/.test(fn.namespace) ? "" : fn.attributes.jsDoc); + block.setTooltip((/^__/.test(fn.namespace) ? "" : fn.attributes.jsDoc) + (pxt.blocks.showBlockIdInTooltip ? " (id: '" + fn.attributes.blockId + "')" : "")); + function buildBlockFromDef(def: pxtc.ParsedBlockDef, expanded = false) { let anonIndex = 0; let firstParam = !expanded && !!comp.thisParameter; diff --git a/pxtlib/blocks.ts b/pxtlib/blocks.ts index c952112c4ba9..f1752e54d49f 100644 --- a/pxtlib/blocks.ts +++ b/pxtlib/blocks.ts @@ -3,6 +3,8 @@ namespace pxt.blocks { const THIS_NAME = "this"; + export let showBlockIdInTooltip: boolean = false; + // The JS Math functions supported in the blocks. The order of this array // determines the order of the dropdown in the math_js_op block export const MATH_FUNCTIONS = { @@ -806,5 +808,20 @@ namespace pxt.blocks { ) }) } + + if (pxt.blocks.showBlockIdInTooltip) { + for (const id of Object.keys(_blockDefinitions)) { + const tooltip = _blockDefinitions[id].tooltip; + if (typeof tooltip === "object" && tooltip !== null) { + for (const innerKey in tooltip) { + if (tooltip.hasOwnProperty(innerKey)) { + (_blockDefinitions[id].tooltip as any)[innerKey] = `${tooltip[innerKey]} (id: ${id})`; + } + } + } else { + _blockDefinitions[id].tooltip = `${_blockDefinitions[id].tooltip} (id: ${id})`; + } + } + } } } diff --git a/webapp/src/app.tsx b/webapp/src/app.tsx index 94bf1cb9f79e..1d2080c4f51a 100644 --- a/webapp/src/app.tsx +++ b/webapp/src/app.tsx @@ -5750,6 +5750,9 @@ document.addEventListener("DOMContentLoaded", async () => { } else if (optsQuery["consoleticks"] == "2" || optsQuery["consoleticks"] == "short") { pxt.analytics.consoleTicks = pxt.analytics.ConsoleTickOptions.Short; } + if (optsQuery["tooltipblockids"] == "1") { + pxt.blocks.showBlockIdInTooltip = true; + } initGitHubDb();