Hello,
There is no built-in way to convert javascript code to blocks. The reasons for this are:
1) Blockly doesn't support all javascript features. Eg anonymous functions, destructuring, etc.
2) Custom blocks may have arbitrary shapes and generate arbitrary code, which makes it hard to go from code -> blocks automatically :/
However! If you have a custom constrained version of javascript that you want to support (eg no anonymous functions, etc) it /should/ be possible to build something that converts from a string of javascript code to blocks =) But it would still be pretty tricky! You'll have to tokenize the string somehow, and create a way to map from those tokens to your blocks, and create a way to make sure they connect correctly. If you can get that working you should be golden.
I hope that helps! If you have any further questions please reply!
--Beka