|
1 | 1 | import GTM from '../../../common/gtm';
|
2 | 2 | import { translate, translateLangToLang } from '../../../common/i18n';
|
3 | 3 | import { getLanguage } from '../../../common/lang';
|
| 4 | +import { save } from './utils'; |
4 | 5 |
|
5 | 6 | /* eslint-disable */
|
6 | 7 | Blockly.WorkspaceAudio.prototype.preload = function() {};
|
@@ -376,3 +377,29 @@ Blockly.WorkspaceAudio.prototype.preload = function() {
|
376 | 377 | }
|
377 | 378 | }
|
378 | 379 | };
|
| 380 | + |
| 381 | +// https://groups.google.com/forum/#!msg/blockly/eS1V49pI9c8/VEh5UuUcBAAJ |
| 382 | +const addDownloadOption = (callback, options, block) => { |
| 383 | + options.push({ |
| 384 | + text: translate('Download'), |
| 385 | + enabled: true, |
| 386 | + callback: () => { |
| 387 | + const xml = Blockly.Xml.textToDom('<xml xmlns="http://www.w3.org/1999/xhtml" collection="false"></xml>'); |
| 388 | + xml.appendChild(Blockly.Xml.blockToDom(block)); |
| 389 | + save('binary-bot-block', true, xml); |
| 390 | + }, |
| 391 | + }); |
| 392 | + callback(options); |
| 393 | +}; |
| 394 | + |
| 395 | +const originalCustomContextVarFn = |
| 396 | + Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN.customContextMenu; |
| 397 | +Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN.customContextMenu = function(options) { |
| 398 | + addDownloadOption(originalCustomContextVarFn.bind(this), options, this); |
| 399 | +}; |
| 400 | + |
| 401 | +const originalCustomContextLoopFn = |
| 402 | + Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN.customContextMenu; |
| 403 | +Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN.customContextMenu = function(options) { |
| 404 | + addDownloadOption(originalCustomContextLoopFn.bind(this), options, this); |
| 405 | +}; |
0 commit comments