From 7bddb8723908232ef5ce79780276684c61c2d6c7 Mon Sep 17 00:00:00 2001 From: Austin Cory Bart Date: Thu, 17 Sep 2020 01:59:14 -0400 Subject: [PATCH] Latest generated block_mirror.js file --- dist/block_mirror.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dist/block_mirror.js b/dist/block_mirror.js index a2ce0dc..9d14368 100644 --- a/dist/block_mirror.js +++ b/dist/block_mirror.js @@ -1191,10 +1191,9 @@ BlockMirrorBlockEditor.prototype.loadBlocklyCSS = function () { BlockMirrorBlockEditor.prototype.getPngFromBlocks = function (callback) { - this.loadBlocklyCSS(); - try { - // Retreive the entire canvas, strip some unnecessary tags + this.loadBlocklyCSS(); // Retreive the entire canvas, strip some unnecessary tags + var blocks = this.workspace.svgBlockCanvas_.cloneNode(true); blocks.removeAttribute("width"); blocks.removeAttribute("height"); // Ensure that we have some content @@ -1227,6 +1226,12 @@ BlockMirrorBlockEditor.prototype.getPngFromBlocks = function (callback) { var canvas = document.createElement("canvas"); canvas.width = bbox.width; canvas.height = bbox.height; + + if (!canvas.width || !canvas.height) { + callback("", img); + return; + } + var ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0); var canvasUrl; @@ -1304,6 +1309,10 @@ BlockMirrorTextToBlocks.prototype.convertSource = function (filename, python_sou while (ast === null) { if (python_source.trim() === "") { + if (badChunks.length) { + xml.appendChild(BlockMirrorTextToBlocks.raw_block(badChunks.join("\n"))); + } + return { "xml": BlockMirrorTextToBlocks.xmlToString(xml), "error": null, @@ -2848,7 +2857,7 @@ BlockMirrorBlockEditor.prototype.TOOLBOXES = { }, TOOLBOX_CATEGORY.CALCULATIONS, TOOLBOX_CATEGORY.CONVERSIONS, { name: "Conditions", colour: "LOGIC", - blocks: ['___ == ___', '___ < ___', '___ and ___', 'not ___'] + blocks: ['___ == ___', '___ and ___', 'not ___'] }, TOOLBOX_CATEGORY.INPUT, '', TOOLBOX_CATEGORY.SEP, '', { name: "Assignment", colour: "VARIABLES",