HI
Iam not sure how to change the svg content -- all the controll what we create in blockly Workspace will render as an svg element ,
I have tried for changing the html element of image and its working , but if we save the xml and restore its not retaining the value .
For changing the property of image while creating you should give the name for image .
Blockly.Blocks['image_type'] = {
init: function() {
this.appendDummyInput()
this.setColour(230);
this.setTooltip('');
this.setHelpUrl('');
}
};
Blockly.JavaScript['image_type'] = function(block) {
// TODO: Assemble JavaScript into code variable.
var code = '...;\n';
return code;
};
after you render the block in workspace
var allblocks = Blockly.mainWorkspace.getAllBlocks()
this will have all blocks and know the block name or block id loop in allblocks get the block detail , for now if we render only one block i take position 0 as reference
var myfield = allblocks[0].getField("myimage");
myfield.imageElement_.style.width = "30px"
myfield.imageElement_.style.height = "30px"
then the image will increase or decrease according to it
through this you can add any html events to element
myfield.imageElement_.onmouseover = function(e){console.log("mouse event ")};