I implemented this little hacky tacky chunk of code. I didn't find another way myself and haven't revisited.
// Some blocks need custom IDs generated for them, for example, the choose block.
// Generate a new question nanoid on create (including handling the case
// where a block is duplicated and we can't keep the same question id it already has)
// We have to look at all descendants of block being created as well
if (event.type == Blockly.Events.BLOCK_CREATE) {
const block = workspace.getBlockById(event.blockId)
if (block) {
const allDescendantBlocks = block.getDescendants(false)
allDescendantBlocks.forEach((d) => {
if (d.type == 'choose') {
;(d as any).questionId = safeNanoid()
}
if (d.type == 'choice') {
;(d as any).answerId = safeNanoid()
;(d as any).tag = ''
}
})
}
}