diff --git a/package.json b/package.json index 2512f0544a..3f5e615b56 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@entrylabs/entry", "title": "EntryJS", "description": "JavaScript library for visual programming", - "version": "4.0.6", + "version": "4.0.7", "main": "dist/entry.min.js", "homepage": "https://playentry.org", "author": { diff --git a/src/playground/block_view.js b/src/playground/block_view.js index 20effeef37..0cc4402e56 100644 --- a/src/playground/block_view.js +++ b/src/playground/block_view.js @@ -88,7 +88,7 @@ Entry.BlockView = class BlockView { } this.isInBlockMenu = this.getBoard() instanceof Entry.BlockMenu; - this.mouseHandler = function(e) { + this.mouseHandler = function (e) { (_.result(that.block.events, 'mousedown') || []).forEach((fn) => { if (Entry.documentMousedown) { Entry.documentMousedown.notify(e); @@ -1019,9 +1019,9 @@ Entry.BlockView = class BlockView { magnet = this.magnet.previous; const dragHeight = dragBlock.getBelowHeight(); const nextX = _get(dragBlock, 'magnet.next.x'); - transform = `translate(${pos.scaleX + magnet.x - nextX},${pos.scaleY + - magnet.y - - dragHeight})`; + transform = `translate(${pos.scaleX + magnet.x - nextX},${ + pos.scaleY + magnet.y - dragHeight + })`; } const $shadow = $(shadow); @@ -1492,7 +1492,12 @@ Entry.BlockView = class BlockView { return options; function _isDownloadable() { - return Entry.Utils.isChrome() && Entry.type === 'workspace' && !Entry.isMobile(); + return ( + Entry.blockSaveImageEnable && + Entry.Utils.isChrome() && + Entry.type === 'workspace' && + !Entry.isMobile() + ); } } } @@ -1601,7 +1606,7 @@ Entry.BlockView = class BlockView { halfWidth = 20; } return { - getBoundingClientRect: function() { + getBoundingClientRect: function () { const coord = this.getAbsoluteCoordinate(); const boardOffset = this._board.relativeOffset; const magnet = this.magnet[selector]; @@ -1726,7 +1731,7 @@ Entry.BlockView = class BlockView { canvas.height = height; const ctx = canvas.getContext('2d'); - img.onload = function() { + img.onload = function () { try { ctx.drawImage(img, 0, 0, width, height); const data = canvas.toDataURL('image/png'); @@ -1739,7 +1744,7 @@ Entry.BlockView = class BlockView { } }; - img.onerror = function() { + img.onerror = function () { return reject('error occured'); }; img.src = src; diff --git a/src/playground/board.js b/src/playground/board.js index 25f2d39c69..cbd2e204a3 100644 --- a/src/playground/board.js +++ b/src/playground/board.js @@ -202,13 +202,13 @@ Entry.Board = class Board { _addControl() { const dom = this.svgDom; const that = this; - dom.mousedown(function() { + dom.mousedown(function () { that.onMouseDown(...arguments); }); - dom.bind('touchstart', function() { + dom.bind('touchstart', function () { that.onMouseDown(...arguments); }); - dom.on('wheel', function() { + dom.on('wheel', function () { that.mouseWheel(...arguments); }); @@ -1211,7 +1211,10 @@ Entry.Board = class Board { }, { activated: - Entry.type === 'workspace' && Entry.Utils.isChrome() && !Entry.isMobile(), + Entry.blockSaveImageEnable && + Entry.type === 'workspace' && + Entry.Utils.isChrome() && + !Entry.isMobile(), option: { text: Lang.Menus.save_as_image_all, enable: !this.readOnly, @@ -1340,7 +1343,7 @@ Entry.Board = class Board { return this.workspace.trashcan.svgGroup; } else if (key === 'coord') { return { - getBoundingClientRect: function() { + getBoundingClientRect: function () { const halfWidth = 20; const boardOffset = this.relativeOffset; return { diff --git a/src/util/init.js b/src/util/init.js index 33257d5d45..9a3958e0a1 100644 --- a/src/util/init.js +++ b/src/util/init.js @@ -579,6 +579,11 @@ Entry.parseOptions = function (options) { this.iframeDomAccess = 'direct'; } + this.blockSaveImageEnable = options.blockSaveImageEnable; + if (this.blockSaveImageEnable === undefined) { + this.blockSaveImageEnable = true; + } + this.hasVariableManager = options.hasvariablemanager; if (!(this.variableEnable || this.messageEnable || this.listEnable || this.functionEnable)) { this.hasVariableManager = false;