Skip to content

Commit 15d5790

Browse files
committed
format document
1 parent 1706200 commit 15d5790

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

src/editor.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ context.keys().forEach(context);
1515
const blocklyDiv = document.getElementById('blocklyDiv');
1616

1717
if (!blocklyDiv) {
18-
throw new Error(`div with id 'blocklyDiv' not found`);
18+
throw new Error(`div with id 'blocklyDiv' not found`);
1919
}
2020
const toolboxElement = document.createElement("xml");
2121
toolboxElement.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

249249
if (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

262262
const 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

Comments
 (0)