@@ -15,7 +15,7 @@ context.keys().forEach(context);
1515const blocklyDiv = document . getElementById ( 'blocklyDiv' ) ;
1616
1717if ( ! blocklyDiv ) {
18- throw new Error ( `div with id 'blocklyDiv' not found` ) ;
18+ throw new Error ( `div with id 'blocklyDiv' not found` ) ;
1919}
2020const toolboxElement = document . createElement ( "xml" ) ;
2121toolboxElement . innerHTML = toolbox ;
@@ -38,12 +38,12 @@ const ws = Blockly.inject(blocklyDiv, {
3838 media : 'https://blockly-demo.appspot.com/static/media/' ,
3939 modalInputs : true ,
4040 move : {
41- scrollbars : {
41+ scrollbars : {
4242 horizontal : true ,
4343 vertical : true
44- } ,
45- drag : true ,
46- wheel : true
44+ } ,
45+ drag : true ,
46+ wheel : true
4747 } ,
4848 oneBasedIndex : false ,
4949 plugins : {
@@ -248,15 +248,15 @@ ws.addChangeListener(Blockly.Events.disableOrphans);
248248
249249if ( ws ) {
250250 ws . addChangeListener ( ( e : Blockly . Events . Abstract ) => {
251- if (
252- e . isUiEvent ||
253- e . type == Blockly . Events . FINISHED_LOADING ||
254- ws . isDragging ( )
255- ) {
256- return ;
257- }
258- Compiler . compile ( ws ) ;
259- } ) ;
251+ if (
252+ e . isUiEvent ||
253+ e . type == Blockly . Events . FINISHED_LOADING ||
254+ ws . isDragging ( )
255+ ) {
256+ return ;
257+ }
258+ Compiler . compile ( ws ) ;
259+ } ) ;
260260}
261261
262262const canvas = document . querySelector ( '#raymarcherDiv canvas' ) as HTMLCanvasElement ;
@@ -265,6 +265,15 @@ const canvas = document.querySelector('#raymarcherDiv canvas') as HTMLCanvasElem
265265( window as any ) . Workspace = ws ;
266266( window as any ) . Serializer = Serializer ;
267267( window as any ) . Canvas = canvas ;
268+ ( window as any ) . saveAs = function ( ) {
269+ Serializer . createFile ( ws , "Untitled Project" , canvas ) . then ( blob => { // temp
270+ const a = document . createElement ( 'a' ) ;
271+ a . href = URL . createObjectURL ( blob ) ;
272+ a . download = 'Untitled Project.mblks' ;
273+ a . click ( ) ;
274+ URL . revokeObjectURL ( a . href ) ;
275+ } ) ;
276+ }
268277
269278// might replace this with react based UI at some point
270279// TODO: fix corner resize
0 commit comments