diff --git a/package.json b/package.json index 5b0d86449..2f3c80fec 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "scratch-render": "0.1.0-prerelease.20190312125229", "scratch-storage": "1.2.2", "scratch-svg-renderer": "0.2.0-prerelease.20190329052730", - "scratch-vm": "0.2.0-prerelease.20190326160300", + "scratch-vm": "0.2.0-prerelease.20190329172358", "selenium-webdriver": "3.6.0", "startaudiocontext": "1.2.1", "style-loader": "^0.23.0", diff --git a/src/containers/blocks.jsx b/src/containers/blocks.jsx index ecb998ea4..d79c7e9c7 100644 --- a/src/containers/blocks.jsx +++ b/src/containers/blocks.jsx @@ -96,6 +96,21 @@ class Blocks extends React.Component { ); this.workspace = this.ScratchBlocks.inject(this.blocks, workspaceConfig); + // Register buttons under new callback keys for creating variables, + // lists, and procedures from extensions. + + const toolboxWorkspace = this.workspace.getFlyout().getWorkspace(); + + const varListButtonCallback = type => + (() => this.ScratchBlocks.Variables.createVariable(this.workspace, null, type)); + const procButtonCallback = () => { + this.ScratchBlocks.Procedures.createProcedureDefCallback_(this.workspace); + }; + + toolboxWorkspace.registerButtonCallback('MAKE_A_VARIABLE', varListButtonCallback('')); + toolboxWorkspace.registerButtonCallback('MAKE_A_LIST', varListButtonCallback('list')); + toolboxWorkspace.registerButtonCallback('MAKE_A_PROCEDURE', procButtonCallback); + // Store the xml of the toolbox that is actually rendered. // This is used in componentDidUpdate instead of prevProps, because // the xml can change while e.g. on the costumes tab. diff --git a/src/containers/sb-file-uploader.jsx b/src/containers/sb-file-uploader.jsx index de89b3afd..cc2e488b5 100644 --- a/src/containers/sb-file-uploader.jsx +++ b/src/containers/sb-file-uploader.jsx @@ -118,12 +118,6 @@ class SBFileUploader extends React.Component { const filename = this.fileToUpload && this.fileToUpload.name; this.props.vm.loadProject(this.reader.result) .then(() => { - // Remove the hash if any (without triggering a hash change event or a reload) - try { // Can fail e.g. when GUI is loaded from static file (integration tests) - history.replaceState({}, document.title, '.'); - } catch { - // No fallback, just do not trigger promise catch below - } this.props.onLoadingFinished(this.props.loadingState, true); // Reset the file input after project is loaded // This is necessary in case the user wants to reload a project