Hi Beka,
Thanks a lot for your explanation, I've missed that behavior. Thus, I try to implement your advice, but what I would like, is to avoid duplicating all blocks defined in my toolbox in other xml strings to keep maintenance easy.
That's why I've implemented a parser of my "central" toolbox as to retrieve all information (categories, blocks etc.):
Here is the code :
var xmlToolbox = Blockly.Xml.textToDom(mytoolbox);
//Here I get categories (to generate H1 title tag in my live HTML doc) : works great
this.categories = Array.from(xmlToolbox.getElementsByTagName("category"))
//Then I get all blocks by category : works great
this.categories.map((category) => {
Array.from(category.getElementsByTagName("block")).map((block) => {
Blockly.Xml.domToWorkspace(block, mysmallWorkspacededicatedtothisblock); //doesn't work : no warning, but the workspace doesn't render it !
})
Unfortunately, it doesn't work, maybe it misses the root xml element.
I try to put the block within a xml doc created as follow :
xmldoc = document.implementation.createDocument(
"xml",
null
);
xmldoc.appendChild(block); //generate a bug
It seems that I'm close, but it doesn't work neither...
Thanks for your encouragement for the docs :-)
Chris