Skip to content

Commit

Permalink
Merge pull request #2755 from entrylabs/feature/aidt_example0523
Browse files Browse the repository at this point in the history
blockSaveImageEnable 옵션 추가
  • Loading branch information
kimorkim authored May 23, 2024
2 parents d22d85f + b7f56fe commit 5c75e1c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
21 changes: 13 additions & 8 deletions src/playground/block_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
);
}
}
}
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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');
Expand All @@ -1739,7 +1744,7 @@ Entry.BlockView = class BlockView {
}
};

img.onerror = function() {
img.onerror = function () {
return reject('error occured');
};
img.src = src;
Expand Down
13 changes: 8 additions & 5 deletions src/playground/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/util/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5c75e1c

Please sign in to comment.