Skip to content

Commit 2cf6852

Browse files
committed
Change downloaded workspace file extension to .ccbe
This commit modifies the src/index.js file to change the file extension of the downloaded workspace from .json to .ccbe. This change is to standardize the file format for the Blockly editor.
1 parent cdf2e4c commit 2cf6852

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import {shadowBlockConversionChangeListener} from '@blockly/shadow-block-convert
1212

1313
const secret = require('./secret.json');
1414

15+
// Variables
16+
const version = "1.1.4";
17+
const date = new Date().toUTCString();
18+
19+
1520
Blockly.common.defineBlocks(blocks);
1621
Object.assign(luaGenerator.forBlock, forBlock);
1722

@@ -46,25 +51,29 @@ const downloadButton = document.getElementById('downloadButton');
4651
const loadButton = document.getElementById('loadButton');
4752

4853
const downloadWorkspace = () => {
49-
const json = save(ws);
54+
const json = {
55+
"version": version,
56+
"date": date,
57+
"workspace": save(ws)
58+
}
5059
const blob = new Blob([json], { type: 'application/json' });
5160
const url = URL.createObjectURL(blob);
5261
const a = document.createElement('a');
5362
a.href = url;
54-
a.download = fileName.value || 'workspace.json';
63+
a.download = (fileName.value || 'workspace.json') + '.ccbe';
5564
a.click();
5665
};
5766

5867
const loadWorkspace = () => {
5968
const input = document.createElement('input');
6069
input.type = 'file';
61-
input.accept = '.json';
70+
input.accept = '.ccbe';
6271
input.click();
6372
input.onchange = () => {
6473
const file = input.files[0];
6574
const reader = new FileReader();
6675
reader.onload = () => {
67-
load(ws, reader.result);
76+
load(ws, reader.result['workspace']);
6877
};
6978
reader.readAsText(file);
7079
};

0 commit comments

Comments
 (0)