Remove clipboard buttons to simplify UI.

This commit is contained in:
Sean Lip
2016-09-19 16:04:08 -07:00
parent ee403c6a95
commit 284f71c46a
4 changed files with 12 additions and 92 deletions

View File

@@ -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

View File

@@ -34,13 +34,6 @@ blocklyApp.ToolboxTreeComponent = ng.core
[attr.aria-level]="level">
<label #blockSummaryLabel [id]="idMap['blockSummaryLabel']">{{getBlockDescription()}}</label>
<ol role="group" *ngIf="displayBlockMenu">
<li [id]="idMap['blockCopy']" role="treeitem" *ngIf="!isWorkspaceEmpty()"
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['blockCopyButton'], 'blockly-button')"
[attr.aria-level]="level + 2">
<button [id]="idMap['blockCopyButton']" (click)="copyToClipboard()" tabindex="-1">
{{'COPY_TO_CLIPBOARD'|translate}}
</button>
</li>
<li [id]="idMap['sendToSelected']" role="treeitem" *ngIf="!isWorkspaceEmpty()"
[attr.aria-labelledBy]="generateAriaLabelledByAttr(idMap['sendToSelectedButton'], 'blockly-button', !canBeCopiedToMarkedConnection())"
[attr.aria-level]="level + 2">
@@ -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.

View File

@@ -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.

View File

@@ -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);