TagSpaces is an offline, open source, document manager with tagging support
chore: added copy and paste in the open link dialog
Ilian Sapundshievfe04da16f21e
diff --git a/src/renderer/components/dialogs/OpenLinkDialog.tsx b/src/renderer/components/dialogs/OpenLinkDialog.tsxindex fe3c8aec8..fca1bbc47 100644--- a/src/renderer/components/dialogs/OpenLinkDialog.tsx+++ b/src/renderer/components/dialogs/OpenLinkDialog.tsx@@ -24,6 +24,8 @@ import TextField from '@mui/material/TextField';import DialogActions from '@mui/material/DialogActions';import DialogContent from '@mui/material/DialogContent';import DialogTitle from '@mui/material/DialogTitle';+import Menu from '@mui/material/Menu';+import MenuItem from '@mui/material/MenuItem';import FormControl from '@mui/material/FormControl';import InputAdornment from '@mui/material/InputAdornment';import Dialog from '@mui/material/Dialog';@@ -88,6 +90,44 @@ function OpenLinkDialog(props: Props) {setDisableConfirmButton(true);}+ const [contextMenu, setContextMenu] = React.useState<{+ mouseX: number;+ mouseY: number;+ } | null>(null);++ const handleContextMenu = (event) => {+ event.preventDefault();+ setContextMenu(+ contextMenu === null+ ? {+ mouseX: event.clientX + 2,+ mouseY: event.clientY - 6,+ }+ : null,+ );+ };++ const handleClose = () => {+ setContextMenu(null);+ };++ async function handleCopy() {+ try {+ await navigator.clipboard.writeText(linkURL);+ handleClose();+ } catch (error) {+ console.error(error.message);+ handleClose();+ }+ }++ async function handlePaste() {+ navigator.clipboard.readText().then((clipText) => {+ setLinkURL(clipText);+ handleClose();+ });+ }+return (<Dialogopen={open}@@ -113,6 +153,8 @@ function OpenLinkDialog(props: Props) {autoFocusname="name"label={t('core:link')}+ onContextMenu={handleContextMenu}+ style={{ cursor: 'context-menu' }}onChange={(event) => {const { target } = event;setLinkURL(target.value);@@ -127,6 +169,19 @@ function OpenLinkDialog(props: Props) {),}}/>+ <Menu+ open={contextMenu !== null}+ onClose={handleClose}+ anchorReference="anchorPosition"+ anchorPosition={+ contextMenu !== null+ ? { top: contextMenu.mouseY, left: contextMenu.mouseX }+ : undefined+ }+ >+ <MenuItem onClick={handleCopy}>Copy</MenuItem>+ <MenuItem onClick={handlePaste}>Paste</MenuItem>+ </Menu></FormControl></DialogContent><DialogActions>