Skip to content

Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.

feat(url): add direct open-in-browser action button and interactive link previews

Deepender25e75f0364dfa0
diff --git a/src/components/ClipboardItem.tsx b/src/components/ClipboardItem.tsx
index 6378e12..91d65d8 100644
--- a/src/components/ClipboardItem.tsx
+++ b/src/components/ClipboardItem.tsx
@@ -23,7 +23,7 @@ import { useStore } from '../store/appStore'
import { useDragOut } from '../hooks/useDragOut'
import { basename, formatBytes, previewText, relativeTime } from '../lib/format'
import { getFileKind } from '../lib/fileType'
-import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ExpandIcon, ContractIcon } from './icons'
+import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ExpandIcon, ContractIcon, ExternalLinkIcon } from './icons'
import '../styles/item.css'
import { tryPaste } from '../lib/tryPaste'
@@ -201,6 +201,19 @@ function ClipboardItemBase({ item }: Props) {
}}>
<CopyIcon />
</button>
+ {item.data.kind === 'text' && item.data.isUrl && (
+ <button
+ className="act"
+ title="Open link in default browser"
+ onClick={(e) => {
+ e.stopPropagation()
+ e.currentTarget.blur()
+ window.open((item.data as any).text, '_blank')
+ }}
+ >
+ <ExternalLinkIcon />
+ </button>
+ )}
<button
className={`act${isPreviewing ? ' preview-contract active' : ' preview-expand'}`}
title={isPreviewing ? 'Close Preview' : 'Expand Preview'}
diff --git a/src/components/PreviewFlyout.tsx b/src/components/PreviewFlyout.tsx
index 2e1a5af..f5f8d90 100644
--- a/src/components/PreviewFlyout.tsx
+++ b/src/components/PreviewFlyout.tsx
@@ -3,7 +3,7 @@ import { motion, AnimatePresence } from 'framer-motion'
import { useStore } from '../store/appStore'
import { formatBytes } from '../lib/format'
import { getFileKind } from '../lib/fileType'
-import { FileKindIcon, FolderOpenIcon, CopyIcon, CheckIcon } from './icons'
+import { FileKindIcon, FolderOpenIcon, CopyIcon, CheckIcon, ExternalLinkIcon } from './icons'
import { createPortal } from 'react-dom'
import { useAdaptiveSpring } from '../hooks/useAdaptiveSpring'
import { useDragOut } from '../hooks/useDragOut'
@@ -265,6 +265,8 @@ function PreviewContent({ item }: { item: any }) {
? item.data.text.slice(0, 20000) + '\n\n… (content truncated)'
: item.data.text
const isCode = looksLikeCode(text)
+ const isUrl = item.data.isUrl
+
return (
<div
onClick={(e) => {
@@ -276,7 +278,14 @@ function PreviewContent({ item }: { item: any }) {
title="Click to paste"
style={{ position: 'relative', display: 'flex', flexDirection: 'column', gap: 10, cursor: 'pointer' }}
>
- <div style={{ display: 'flex', justifyContent: 'flex-end', position: 'sticky', top: 0, zIndex: 2 }}>
+ <div style={{ display: 'flex', justifyContent: 'flex-end', gap: 6, position: 'sticky', top: 0, zIndex: 2 }}>
+ {isUrl && (
+ <QuickActionButton
+ title="Open Link"
+ icon={ExternalLinkIcon}
+ onClick={() => window.open(item.data.text, '_blank')}
+ />
+ )}
<QuickActionButton
title="Copy Text"
icon={CopyIcon}
@@ -284,7 +293,7 @@ function PreviewContent({ item }: { item: any }) {
/>
</div>
<div style={{
- color: 'rgba(255,255,255,0.88)',
+ color: isUrl ? '#60a5fa' : 'rgba(255,255,255,0.88)',
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
fontSize: isCode ? 12 : 13.5,
@@ -292,8 +301,21 @@ function PreviewContent({ item }: { item: any }) {
fontFamily: isCode ? CODE_FONT : SYS_FONT,
fontWeight: 400,
letterSpacing: isCode ? 0 : '0.01em',
+ textDecoration: isUrl ? 'underline' : 'none'
}}>
- {text}
+ {isUrl ? (
+ <span
+ onClick={(e) => {
+ e.stopPropagation()
+ window.open(item.data.text, '_blank')
+ }}
+ style={{ cursor: 'pointer' }}
+ >
+ {text}
+ </span>
+ ) : (
+ text
+ )}
</div>
</div>
)
diff --git a/src/components/icons.tsx b/src/components/icons.tsx
index 257357f..e2f660f 100644
--- a/src/components/icons.tsx
+++ b/src/components/icons.tsx
@@ -14,6 +14,15 @@ const base = (p: P): P => ({
...p
})
+export const ExternalLinkIcon = (p: P) => (
+ <svg {...base(p)}>
+ <g fill="currentColor" fillRule="evenodd" clipRule="evenodd">
+ <path d="M14 4a1 1 0 0 1 1-1h5a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0V6.414l-8.293 8.293a1 1 0 0 1-1.414-1.414L17.586 5H15a1 1 0 0 1-1-1Z" />
+ <path d="M5 5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 1 1 2 0v5a4 4 0 0 1-4 4H5a4 4 0 0 1-4-4V7a4 4 0 0 1 4-4h5a1 1 0 1 1 0 2H5Z" />
+ </g>
+ </svg>
+)
+
export const SearchIcon = (p: P) => (
<svg {...base(p)}>
<g> <g fill="currentColor" fillRule="evenodd" clipRule="evenodd"> <path d="M11 17a6 6 0 1 0 0-12a6 6 0 0 0 0 12m0 2a8 8 0 1 0 0-16a8 8 0 0 0 0 16" /> <path d="M15.32 15.29a1 1 0 0 1 1.414.005l3.975 4a1 1 0 0 1-1.418 1.41l-3.975-4a1 1 0 0 1 .004-1.414Z" /> </g> </g>