fix: Fix downloading screenshots on the playground. (#6025)

* fix: Fix downloading screenshots on the playground.

* fix: Resolve lint warning about unused variable.
This commit is contained in:
Aaron Dodson
2022-03-25 08:27:08 -07:00
committed by GitHub
parent 2c15d002ab
commit ca6e590101
3 changed files with 4 additions and 3 deletions

View File

@@ -7,6 +7,7 @@
<!-- This script loads uncompressed when on localhost and loads compressed when it is being hosted.
Please add any other dependencies to playgrounds/prepare.js.-->
<script src="playgrounds/prepare.js"></script>
<script src="playgrounds/screenshot.js"></script>
<script src="../node_modules/@blockly/dev-tools/dist/index.js"></script>
<script type=module>
import Blockly from './playgrounds/blockly.mjs';
@@ -242,7 +243,7 @@ function configureContextMenu(menuOptions, e) {
text: 'Download Screenshot',
enabled: workspace.getTopBlocks().length,
callback: function() {
Blockly.downloadScreenshot(workspace);
downloadScreenshot(workspace);
}
};
menuOptions.push(screenshotOption);

View File

@@ -121,7 +121,7 @@ function configureContextMenu(menuOptions, e) {
text: 'Download Screenshot',
enabled: workspace.getTopBlocks().length,
callback: function() {
Blockly.downloadScreenshot(workspace);
downloadScreenshot(workspace);
}
};
menuOptions.push(screenshotOption);

View File

@@ -95,7 +95,7 @@ function workspaceToSvg_(workspace, callback, customCss) {
* Download a screenshot of the blocks on a Blockly workspace.
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
*/
Blockly.downloadScreenshot = function(workspace) {
function downloadScreenshot(workspace) {
workspaceToSvg_(workspace, function(datauri) {
const a = document.createElement('a');
a.download = 'screenshot.png';