diff --git a/accessible/clipboard.service.js b/accessible/clipboard.service.js index dc3853832..61510b94f 100644 --- a/accessible/clipboard.service.js +++ b/accessible/clipboard.service.js @@ -27,10 +27,6 @@ blocklyApp.ClipboardService = ng.core.Class({ blocklyApp.NotificationsService, blocklyApp.UtilsService, blocklyApp.AudioService, function(_notificationsService, _utilsService, _audioService) { - this.clipboardBlockXml_ = null; - this.clipboardBlockPreviousConnection_ = null; - this.clipboardBlockNextConnection_ = null; - this.clipboardBlockOutputConnection_ = null; this.markedConnection_ = null; this.notificationsService = _notificationsService; this.utilsService = _utilsService; @@ -44,15 +40,6 @@ blocklyApp.ClipboardService = ng.core.Class({ Blockly.OPPOSITE_TYPE[blockConnection.type] == connection.type && connection.checkType_(blockConnection)); }, - isCompatibleWithClipboard: function(connection) { - var previousConnection = this.clipboardBlockPreviousConnection_; - var nextConnection = this.clipboardBlockNextConnection_; - var outputConnection = this.clipboardBlockOutputConnection_; - return Boolean( - this.areConnectionsCompatible_(connection, previousConnection) || - this.areConnectionsCompatible_(connection, nextConnection) || - this.areConnectionsCompatible_(connection, outputConnection)); - }, getMarkedConnectionBlock: function() { if (!this.markedConnection_) { return null; @@ -102,48 +89,6 @@ blocklyApp.ClipboardService = ng.core.Class({ this.markedConnection_ = connection; this.notificationsService.speak(Blockly.Msg.ADDED_LINK_MSG); }, - cut: function(block) { - this.copy(block); - block.dispose(true); - }, - copy: function(block) { - this.clipboardBlockXml_ = Blockly.Xml.blockToDom(block); - Blockly.Xml.deleteNext(this.clipboardBlockXml_); - this.clipboardBlockPreviousConnection_ = block.previousConnection; - 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 - // already joined to something, use the 'nextConnection' of the - // previous block instead in order to do an insertion. - if (inputConnection.type == Blockly.PREVIOUS_STATEMENT && - inputConnection.isConnected()) { - connection = inputConnection.targetConnection; - } - - var reconstitutedBlock = Blockly.Xml.domToBlock(blocklyApp.workspace, - this.clipboardBlockXml_); - switch (connection.type) { - case Blockly.NEXT_STATEMENT: - connection.connect(reconstitutedBlock.previousConnection); - break; - case Blockly.PREVIOUS_STATEMENT: - connection.connect(reconstitutedBlock.nextConnection); - break; - default: - connection.connect(reconstitutedBlock.outputConnection); - } - this.audioService.playConnectSound(); - this.notificationsService.speak( - this.utilsService.getBlockDescription(reconstitutedBlock) + ' ' + - Blockly.Msg.PASTED_BLOCK_FROM_CLIPBOARD_MSG); - return reconstitutedBlock.id; - }, pasteToMarkedConnection: function(block) { var xml = Blockly.Xml.blockToDom(block); var reconstitutedBlock = Blockly.Xml.domToBlock( diff --git a/accessible/tree.service.js b/accessible/tree.service.js index ae6b2aae2..d374d7e32 100644 --- a/accessible/tree.service.js +++ b/accessible/tree.service.js @@ -266,46 +266,6 @@ blocklyApp.TreeService = ng.core.Class({ deleteBlockFunc, treeId, nextActiveDesc.id); } }, - cutBlock_: function(block, blockRootNode) { - var blockDescription = this.utilsService.getBlockDescription(block); - - var that = this; - this.removeBlockAndSetFocus(block, blockRootNode, function() { - that.clipboardService.cut(block); - }); - - setTimeout(function() { - if (that.utilsService.isWorkspaceEmpty()) { - that.notificationsService.speak( - blockDescription + ' cut. Workspace is empty.'); - } else { - that.notificationsService.speak( - blockDescription + ' cut. Now on workspace.'); - } - }); - }, - copyBlock_: function(block) { - var blockDescription = this.utilsService.getBlockDescription(block); - this.clipboardService.copy(block); - this.notificationsService.speak( - blockDescription + ' ' + Blockly.Msg.COPIED_BLOCK_MSG); - }, - 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() { - that.focusOnBlock(newBlockId); - }); - }, showBlockOptionsModal: function(block, blockRootNode) { var that = this; var actionButtonsInfo = []; @@ -430,28 +390,12 @@ blocklyApp.TreeService = ng.core.Class({ return; } - if (e.altKey) { + if (e.altKey || e.ctrlKey) { // Do not intercept combinations such as Alt+Home. return; } - if (e.ctrlKey) { - var blockRootNode = this.getCurrentBlockRootNode_(activeDesc); - var block = this.getBlockFromRootNode_(blockRootNode); - - if (e.keyCode == 88) { - // Cut block. - this.cutBlock_(block, blockRootNode); - } else if (e.keyCode == 67) { - // Copy block. - this.copyBlock_(block); - } else if (e.keyCode == 86) { - // Paste block, if possible. - var targetConnection = - e.shiftKey ? block.previousConnection : block.nextConnection; - this.pasteToConnection(block, targetConnection); - } - } else if (document.activeElement.tagName == 'INPUT') { + if (document.activeElement.tagName == 'INPUT') { // For input fields, only Esc and Tab keystrokes are handled specially. if (e.keyCode == 27 || e.keyCode == 9) { // For Esc and Tab keys, the focus is removed from the input field. diff --git a/accessible/workspace-tree.component.js b/accessible/workspace-tree.component.js index ff99a1a17..13ae7c6a7 100644 --- a/accessible/workspace-tree.component.js +++ b/accessible/workspace-tree.component.js @@ -198,8 +198,5 @@ blocklyApp.WorkspaceTreeComponent = ng.core.Component({ generateAriaLabelledByAttr: function(mainLabel, secondLabel) { return this.utilsService.generateAriaLabelledByAttr( mainLabel, secondLabel); - }, - isCompatibleWithClipboard: function(connection) { - return this.clipboardService.isCompatibleWithClipboard(connection); } });