diff --git a/src/webview/openshift-terminal/app/terminalInstance.tsx b/src/webview/openshift-terminal/app/terminalInstance.tsx index bcb0d85df..b1ab9a611 100644 --- a/src/webview/openshift-terminal/app/terminalInstance.tsx +++ b/src/webview/openshift-terminal/app/terminalInstance.tsx @@ -3,7 +3,7 @@ * Licensed under the MIT License. See LICENSE file in the project root for license information. *-----------------------------------------------------------------------------------------------*/ -import { Box, Button, Paper, Stack, Typography } from '@mui/material'; +import { Box, Button, Paper, Stack, Typography, debounce } from '@mui/material'; import React from 'react'; import { VSCodeMessage } from './vscodeMessage'; import { Terminal, ITheme } from 'xterm'; @@ -20,10 +20,11 @@ const TerminalContextMenu = (props: { onClearHandler: React.MouseEventHandler; onCopyHandler: React.MouseEventHandler; onSelectAllHandler: React.MouseEventHandler; + onPasteHandler: React.MouseEventHandler; }) => { return ( - + + @@ -139,6 +163,13 @@ export const TerminalInstance = (props: { setContextMenuOpen(false); }; + const handlePaste = () => { + void navigator.clipboard.readText().then((clipboardContent: string) => { + term.paste(clipboardContent); + }); + setContextMenuOpen(false); + }; + const handleSelectAll = () => { term.selectAll(); setContextMenuOpen(false); @@ -152,7 +183,7 @@ export const TerminalInstance = (props: { uuid: props.uuid, }, }); - } + }; // The xtermjs addon that can be used to resize the terminal according to the size of the div const fitAddon = React.useMemo(() => { @@ -165,7 +196,7 @@ export const TerminalInstance = (props: { kind: 'openExternal', data: { uuid: props.uuid, - url: uri + url: uri, }, }); } @@ -190,6 +221,17 @@ export const TerminalInstance = (props: { term.selectAll(); keyboardEvent.stopPropagation(); return false; + } else if (keyboardEvent.code === 'KeyV') { + // Ctrl+Shift+V pastes + debounce(() => { + void navigator.clipboard + .readText() // + .then((clipboardContent: string) => { + term.paste(clipboardContent); + }); + }); + keyboardEvent.stopPropagation(); + return false; } } @@ -363,11 +405,11 @@ export const TerminalInstance = (props: { return (