const block = Blockly.Blocks[blockId];
if (block.init) {
const oldInit = block.init;
block.init = function() {
if (oldInit) oldInit.call(this);
// create whatever class name you want, assuming you want a different one for each type of block
const className = 'custom_' + blockId;
// This adds a class to the whole block, you'd have to use the right css selector to grab .blocklyText that is a descendant of this class
Blockly.utils.dom.addClass(this.getSvgRoot(), className);
};
}
Sadly it's just not very easy to change the default block definitions.