diff --git a/accessible/clipboard.service.js b/accessible/clipboard.service.js
index 98764d2b6..9a7e7451a 100644
--- a/accessible/clipboard.service.js
+++ b/accessible/clipboard.service.js
@@ -111,6 +111,9 @@ blocklyApp.ClipboardService = ng.core
this.clipboardBlockNextConnection_ = block.nextConnection;
this.clipboardBlockOutputConnection_ = block.outputConnection;
},
+ isClipboardEmpty: function() {
+ return !this.clipboardBlockXml_;
+ },
pasteFromClipboard: function(inputConnection) {
var connection = inputConnection;
// If the connection is a 'previousConnection' and that connection is
diff --git a/accessible/toolbox-tree.component.js b/accessible/toolbox-tree.component.js
index be14f33ff..ee60a4d22 100644
--- a/accessible/toolbox-tree.component.js
+++ b/accessible/toolbox-tree.component.js
@@ -34,13 +34,6 @@ blocklyApp.ToolboxTreeComponent = ng.core
[attr.aria-level]="level">
- -
-
-
-
@@ -88,8 +81,8 @@ blocklyApp.ToolboxTreeComponent = ng.core
var idKeys = ['toolboxBlockRoot', 'blockSummaryLabel'];
if (this.displayBlockMenu) {
idKeys = idKeys.concat([
- 'workspaceCopy', 'workspaceCopyButton', 'blockCopy',
- 'blockCopyButton', 'sendToSelected', 'sendToSelectedButton']);
+ 'workspaceCopy', 'workspaceCopyButton', 'sendToSelected',
+ 'sendToSelectedButton']);
}
this.idMap = {};
@@ -136,11 +129,6 @@ blocklyApp.ToolboxTreeComponent = ng.core
'Now on copied block in workspace.');
});
},
- copyToClipboard: function() {
- this.clipboardService.copy(this.block);
- this.notificationsService.setStatusMessage(
- this.getBlockDescription() + ' ' + Blockly.Msg.COPIED_BLOCK_MSG);
- },
copyToMarkedSpot: function() {
var blockDescription = this.getBlockDescription();
// Clean up the active desc for the destination tree.
diff --git a/accessible/tree.service.js b/accessible/tree.service.js
index d303591b7..6635b7319 100644
--- a/accessible/tree.service.js
+++ b/accessible/tree.service.js
@@ -335,13 +335,16 @@ blocklyApp.TreeService = ng.core
this.notificationsService.setStatusMessage(
blockDescription + ' ' + Blockly.Msg.COPIED_BLOCK_MSG);
},
- pasteToConnection_: function(block, connection) {
+ pasteToConnection: function(block, connection) {
+ if (this.clipboardService.isClipboardEmpty()) {
+ return;
+ }
+
var destinationTreeId = this.getTreeIdForBlock(
connection.getSourceBlock().id);
this.clearActiveDesc(destinationTreeId);
var newBlockId = this.clipboardService.pasteFromClipboard(connection);
-
// Invoke a digest cycle, so that the DOM settles.
var that = this;
setTimeout(function() {
@@ -410,7 +413,7 @@ blocklyApp.TreeService = ng.core
// Paste block, if possible.
var targetConnection =
e.shiftKey ? block.previousConnection : block.nextConnection;
- this.pasteToConnection_(block, targetConnection);
+ this.pasteToConnection(block, targetConnection);
}
} else if (document.activeElement.tagName == 'INPUT') {
// For input fields, only Esc and Tab keystrokes are handled specially.
diff --git a/accessible/workspace-tree.component.js b/accessible/workspace-tree.component.js
index eb8361ff1..b7763fbc9 100644
--- a/accessible/workspace-tree.component.js
+++ b/accessible/workspace-tree.component.js
@@ -119,24 +119,6 @@ blocklyApp.WorkspaceTreeComponent = ng.core
block, document.getElementById(this.idMap['blockRoot']),
deleteBlockFunc);
},
- cutBlock_: function() {
- var blockDescription = this.getBlockDescription();
-
- var that = this;
- this.removeBlockAndSetFocus_(this.block, function() {
- that.clipboardService.cut(that.block);
- });
-
- setTimeout(function() {
- if (that.utilsService.isWorkspaceEmpty()) {
- that.notificationsService.setStatusMessage(
- blockDescription + ' cut. Workspace is empty.');
- } else {
- that.notificationsService.setStatusMessage(
- blockDescription + ' cut. Now on workspace.');
- }
- });
- },
deleteBlock_: function() {
var blockDescription = this.getBlockDescription();
@@ -156,19 +138,6 @@ blocklyApp.WorkspaceTreeComponent = ng.core
}
});
},
- pasteToConnection_: function(connection) {
- var destinationTreeId = this.treeService.getTreeIdForBlock(
- connection.getSourceBlock().id);
- this.treeService.clearActiveDesc(destinationTreeId);
-
- var newBlockId = this.clipboardService.pasteFromClipboard(connection);
-
- // Invoke a digest cycle, so that the DOM settles.
- var that = this;
- setTimeout(function() {
- that.treeService.focusOnBlock(newBlockId);
- });
- },
moveToMarkedSpot_: function() {
var blockDescription = this.getBlockDescription();
var oldDestinationTreeId = this.treeService.getTreeIdForBlock(
@@ -203,60 +172,17 @@ blocklyApp.WorkspaceTreeComponent = ng.core
'. Now on moved block in workspace.');
});
},
- copyBlock_: function() {
- this.clipboardService.copy(this.block);
- this.notificationsService.setStatusMessage(
- this.getBlockDescription() + ' ' + Blockly.Msg.COPIED_BLOCK_MSG);
- },
markSpotBefore_: function() {
this.clipboardService.markConnection(this.block.previousConnection);
},
markSpotAfter_: function() {
this.clipboardService.markConnection(this.block.nextConnection);
},
- pasteToNextConnection_: function() {
- this.pasteToConnection_(this.block.nextConnection);
- },
- pasteToPreviousConnection_: function() {
- this.pasteToConnection_(this.block.previousConnection);
- },
ngOnInit: function() {
var that = this;
// Generate a list of action buttons.
this.actionButtonsInfo = [{
- baseIdKey: 'cut',
- translationIdForText: 'CUT_BLOCK',
- action: that.cutBlock_.bind(that),
- isDisabled: function() {
- return false;
- }
- }, {
- baseIdKey: 'copy',
- translationIdForText: 'COPY_BLOCK',
- action: that.copyBlock_.bind(that),
- isDisabled: function() {
- return false;
- }
- }, {
- baseIdKey: 'pasteBefore',
- translationIdForText: 'PASTE_BEFORE',
- action: that.pasteToPreviousConnection_.bind(that),
- isDisabled: function() {
- return Boolean(
- !that.block.previousConnection ||
- !that.isCompatibleWithClipboard(that.block.previousConnection));
- }
- }, {
- baseIdKey: 'pasteAfter',
- translationIdForText: 'PASTE_AFTER',
- action: that.pasteToNextConnection_.bind(that),
- isDisabled: function() {
- return Boolean(
- !that.block.nextConnection ||
- !that.isCompatibleWithClipboard(that.block.nextConnection));
- }
- }, {
baseIdKey: 'markBefore',
translationIdForText: 'MARK_SPOT_BEFORE',
action: that.markSpotBefore_.bind(that),
@@ -301,7 +227,7 @@ blocklyApp.WorkspaceTreeComponent = ng.core
baseIdKey: 'paste',
translationIdForText: 'PASTE',
action: function(connection) {
- that.pasteToConnection_(connection);
+ that.treeService.pasteToConnection(that.block, connection);
},
isDisabled: function(connection) {
return !that.isCompatibleWithClipboard(connection);