how to run code in codemirror

I wanna make an map demo page to show how to use the npm package. The problem is how to display the map in the map area after I type the code in the code area and click the ‘run’ button. Can anybody knows? Thx.