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.
TypeScript clipboardclipboard-managerdesktop-appdrag-and-dropelectronopen-sourceproductivityproductivity-toolwindows
feat(ui): zero-cost offline URL previews and rich link flyout cards
Deepender2501e4d996e2fb
diff --git a/src/components/ClipboardItem.tsx b/src/components/ClipboardItem.tsxindex 268e4c1..26912ad 100644--- a/src/components/ClipboardItem.tsx+++ b/src/components/ClipboardItem.tsx@@ -24,7 +24,8 @@ import { useDragOut } from '../hooks/useDragOut'import { basename, formatBytes, previewText, relativeTime, formatImageDisplayName } from '../lib/format'import { getFileKind } from '../lib/fileType'import { playButtonClickSound, playToggleSound, playDeleteSound, playCardExpandSound } from '../lib/soundEffects'-import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ExpandIcon, ContractIcon, ExternalLinkIcon } from './icons'+import { CopyIcon, FileKindIcon, ImageIcon, LinkIcon, GlobeIcon, PinIcon, PinFillIcon, TrashIcon, MinusIcon, ChevronUpIcon, ExpandIcon, ContractIcon, ExternalLinkIcon } from './icons'+import { parseUrlPreview } from '../lib/urlPreview'import '../styles/item.css'import { tryPaste } from '../lib/tryPaste'@@ -628,10 +629,20 @@ function Preview({ item }: { item: ClipboardItemDto }) {switch (item.data.kind) {case 'text':if (item.data.isUrl) {+ const info = parseUrlPreview(item.data.text)return (- <>- <div className="preview single">{item.data.text}</div>- </>+ <div className="link-preview-card">+ <div className="link-preview-header">+ <div className="link-brand-pill">+ <GlobeIcon width={12} height={12} style={{ color: 'rgba(255, 255, 255, 0.75)', flexShrink: 0 }} />+ <span className="link-service">{info.serviceName}</span>+ <span className="link-dot">·</span>+ <span className="link-domain">{info.domain}</span>+ </div>+ </div>+ {info.title && <div className="link-title">{info.title}</div>}+ <div className="preview single link-url">{item.data.text}</div>+ </div>)}return <div className="preview">{previewText(item.data.text)}</div>diff --git a/src/components/PreviewFlyout.tsx b/src/components/PreviewFlyout.tsxindex fe8d92d..d270e67 100644--- a/src/components/PreviewFlyout.tsx+++ b/src/components/PreviewFlyout.tsx@@ -3,7 +3,8 @@ import { motion, AnimatePresence } from 'framer-motion'import { useStore } from '../store/appStore'import { formatBytes, formatImageDisplayName } from '../lib/format'import { getFileKind } from '../lib/fileType'-import { FileKindIcon, FolderOpenIcon, CopyIcon, CheckIcon, ExternalLinkIcon, CloseIcon } from './icons'+import { FileKindIcon, FolderOpenIcon, CopyIcon, CheckIcon, ExternalLinkIcon, CloseIcon, GlobeIcon } from './icons'+import { parseUrlPreview } from '../lib/urlPreview'import { createPortal } from 'react-dom'import { useAdaptiveSpring } from '../hooks/useAdaptiveSpring'import { useDragOut } from '../hooks/useDragOut'@@ -563,6 +564,95 @@ function PreviewContent({const isCode = looksLikeCode(text)const isUrl = item.data.isUrl+ if (isUrl) {+ const info = parseUrlPreview(item.data.text)+ return (+ <div+ onClick={(e) => {+ const sel = window.getSelection()?.toString()+ if (sel && sel.trim().length > 0) return+ e.stopPropagation()+ tryPaste(() => useStore.getState().paste(item.id))+ }}+ title={t('flyout.clickToPaste')}+ style={{ position: 'relative', display: 'flex', flexDirection: 'column', gap: 14, cursor: 'pointer' }}+ >+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 10 }}>+ <div style={{+ display: 'inline-flex',+ alignItems: 'center',+ gap: 6,+ background: 'rgba(255, 255, 255, 0.08)',+ border: '1px solid rgba(255, 255, 255, 0.14)',+ borderRadius: 999,+ padding: '3px 10px'+ }}>+ <GlobeIcon width={13} height={13} style={{ color: 'rgba(255, 255, 255, 0.85)', flexShrink: 0 }} />+ <span style={{ fontSize: 12, fontWeight: 600, color: '#ffffff', fontFamily: SYS_FONT }}>{info.serviceName}</span>+ <span style={{ fontSize: 11, color: 'rgba(255, 255, 255, 0.35)' }}>·</span>+ <span style={{ fontSize: 11.5, color: 'rgba(255, 255, 255, 0.65)', fontFamily: SYS_FONT }}>{info.domain}</span>+ </div>++ <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>+ <QuickActionButton+ title={t('flyout.openLink')}+ icon={ExternalLinkIcon}+ onClick={() => window.open(item.data.text, '_blank')}+ />+ <QuickActionButton+ title={t('flyout.copyText')}+ icon={CopyIcon}+ onClick={() => navigator.clipboard.writeText(item.data.text)}+ />+ </div>+ </div>++ {info.title && (+ <div style={{+ fontSize: 16,+ fontWeight: 600,+ color: '#ffffff',+ lineHeight: 1.35,+ fontFamily: SYS_FONT,+ wordBreak: 'break-word'+ }}>+ {info.title}+ </div>+ )}++ <div+ onClick={(e) => {+ e.stopPropagation()+ window.open(item.data.text, '_blank')+ }}+ style={{+ padding: '10px 12px',+ background: 'rgba(255, 255, 255, 0.04)',+ border: '1px solid rgba(255, 255, 255, 0.08)',+ borderRadius: 10,+ fontSize: 12.5,+ color: 'rgba(255, 255, 255, 0.80)',+ fontFamily: SYS_FONT,+ wordBreak: 'break-all',+ lineHeight: 1.45,+ cursor: 'pointer',+ transition: 'background 0.15s ease, border-color 0.15s ease'+ }}+ onMouseEnter={(e) => {+ e.currentTarget.style.background = 'rgba(255, 255, 255, 0.08)'+ e.currentTarget.style.borderColor = 'rgba(255, 255, 255, 0.16)'+ }}+ onMouseLeave={(e) => {+ e.currentTarget.style.background = 'rgba(255, 255, 255, 0.04)'+ e.currentTarget.style.borderColor = 'rgba(255, 255, 255, 0.08)'+ }}+ >+ {item.data.text}+ </div>+ </div>+ )+ }+return (<divonClick={(e) => {@@ -575,13 +665,6 @@ function PreviewContent({style={{ position: 'relative', display: 'flex', flexDirection: 'column', gap: 10, cursor: 'pointer' }}><div style={{ display: 'flex', justifyContent: 'flex-end', gap: 6, position: 'sticky', top: 0, zIndex: 2 }}>- {isUrl && (- <QuickActionButton- title={t('flyout.openLink')}- icon={ExternalLinkIcon}- onClick={() => window.open(item.data.text, '_blank')}- />- )}<QuickActionButtontitle={t('flyout.copyText')}icon={CopyIcon}@@ -589,29 +672,16 @@ function PreviewContent({/></div><div style={{- color: isUrl ? '#60a5fa' : 'rgba(255,255,255,0.88)',+ color: 'rgba(255,255,255,0.88)',whiteSpace: 'pre-wrap',wordBreak: 'break-word',fontSize: isCode ? 12 : 13.5,lineHeight: isCode ? 1.65 : 1.7,fontFamily: isCode ? CODE_FONT : SYS_FONT,fontWeight: 400,- letterSpacing: isCode ? 0 : '0.01em',- textDecoration: isUrl ? 'underline' : 'none'+ letterSpacing: isCode ? 0 : '0.01em'}}>- {isUrl ? (- <span- onClick={(e) => {- e.stopPropagation()- window.open(item.data.text, '_blank')- }}- style={{ cursor: 'pointer' }}- >- {text}- </span>- ) : (- text- )}+ {text}</div></div>)diff --git a/src/components/icons.tsx b/src/components/icons.tsxindex 415e60c..b7e3aab 100644--- a/src/components/icons.tsx+++ b/src/components/icons.tsx@@ -38,7 +38,8 @@ import {LogOut,Coffee,Heart,- Star+ Star,+ Globe} from 'lucide-react'import { getFileKindByExt } from '../lib/fileType'@@ -47,6 +48,7 @@ type P = SVGProps<SVGSVGElement>export const CoffeeIcon = (p: P) => <Coffee size={p.width ?? 16} strokeWidth={2.2} {...(p as any)} />export const HeartIcon = (p: P) => <Heart size={p.width ?? 16} strokeWidth={2.2} {...(p as any)} />export const StarIcon = (p: P) => <Star size={p.width ?? 16} strokeWidth={2.2} {...(p as any)} />+export const GlobeIcon = (p: P) => <Globe size={p.width ?? 16} {...(p as any)} />export const KofiLogo = (p: P) => (<svg viewBox="0 0 24 24" width={p.width ?? 18} height={p.height ?? 18} fill="currentColor" {...(p as any)}>diff --git a/src/lib/urlPreview.ts b/src/lib/urlPreview.tsnew file mode 100644index 0000000..f545cc7--- /dev/null+++ b/src/lib/urlPreview.ts@@ -0,0 +1,132 @@+/**+ * Zero-cost offline URL preview parser.+ * Extracts rich metadata, brand badges, and titles from URLs in < 0.1ms without internet.+ */++export interface UrlPreviewInfo {+ url: string+ domain: string+ serviceName: string+ title?: string+ brandColor: string+ faviconUrl: string+}++const BRAND_PRESETS: Record<string, { serviceName: string; brandColor: string }> = {+ 'github.com': { serviceName: 'GitHub', brandColor: '#24292e' },+ 'youtube.com': { serviceName: 'YouTube', brandColor: '#ff0000' },+ 'youtu.be': { serviceName: 'YouTube', brandColor: '#ff0000' },+ 'pinterest.com': { serviceName: 'Pinterest', brandColor: '#e60023' },+ 'instagram.com': { serviceName: 'Instagram', brandColor: '#e1306c' },+ 'twitter.com': { serviceName: 'X / Twitter', brandColor: '#1da1f2' },+ 'x.com': { serviceName: 'X', brandColor: '#14171a' },+ 'reddit.com': { serviceName: 'Reddit', brandColor: '#ff4500' },+ 'linkedin.com': { serviceName: 'LinkedIn', brandColor: '#0a66c2' },+ 'wikipedia.org': { serviceName: 'Wikipedia', brandColor: '#636466' },+ 'figma.com': { serviceName: 'Figma', brandColor: '#f24e1e' },+ 'dribbble.com': { serviceName: 'Dribbble', brandColor: '#ea4c89' },+ 'stackoverflow.com': { serviceName: 'Stack Overflow', brandColor: '#f48024' },+ 'spotify.com': { serviceName: 'Spotify', brandColor: '#1ed760' },+ 'medium.com': { serviceName: 'Medium', brandColor: '#000000' },+ 'npmjs.com': { serviceName: 'NPM', brandColor: '#cb3837' },+ 'amazon.com': { serviceName: 'Amazon', brandColor: '#ff9900' },+ 'notion.so': { serviceName: 'Notion', brandColor: '#000000' },+ 'vercel.com': { serviceName: 'Vercel', brandColor: '#000000' },+ 'discord.com': { serviceName: 'Discord', brandColor: '#5865f2' },+ 'facebook.com': { serviceName: 'Facebook', brandColor: '#1877f2' },+ 'openai.com': { serviceName: 'ChatGPT', brandColor: '#10a37f' },+ 'chatgpt.com': { serviceName: 'ChatGPT', brandColor: '#10a37f' },+ 'docs.google.com': { serviceName: 'Google Docs', brandColor: '#4285f4' },+ 'drive.google.com': { serviceName: 'Google Drive', brandColor: '#0f9d58' },+}++export function parseUrlPreview(rawUrl: string): UrlPreviewInfo {+ let urlObj: URL | null = null+ try {+ urlObj = new URL(rawUrl.startsWith('http') ? rawUrl : `https://${rawUrl}`)+ } catch {+ return {+ url: rawUrl,+ domain: rawUrl,+ serviceName: 'Web Link',+ brandColor: '#3f3f46',+ faviconUrl: '',+ }+ }++ const hostname = urlObj.hostname.replace(/^www\./, '').toLowerCase()+ const path = urlObj.pathname+ const pathSegments = path.split('/').filter(Boolean)++ let serviceName = ''+ let brandColor = '#3f3f46'+ let title: string | undefined = undefined++ // Match brand presets+ for (const [key, preset] of Object.entries(BRAND_PRESETS)) {+ if (hostname === key || hostname.endsWith(`.${key}`)) {+ serviceName = preset.serviceName+ brandColor = preset.brandColor+ break+ }+ }++ // Fallback Service Name from Domain+ if (!serviceName) {+ const parts = hostname.split('.')+ const mainName = parts.length >= 2 ? parts[parts.length - 2] : hostname+ serviceName = mainName.charAt(0).toUpperCase() + mainName.slice(1)+ }++ // Smart Offline Title & Breadcrumb Extraction+ if (hostname.includes('github.com')) {+ if (pathSegments.length >= 2) {+ const repo = `${pathSegments[0]}/${pathSegments[1]}`+ if (pathSegments.length >= 4 && (pathSegments[2] === 'issues' || pathSegments[2] === 'pull')) {+ title = `${repo} · ${pathSegments[2] === 'issues' ? 'Issue' : 'PR'} #${pathSegments[3]}`+ } else {+ title = repo+ }+ }+ } else if (hostname.includes('pinterest.com')) {+ if (pathSegments.length >= 2 && pathSegments[0] === 'pin') {+ title = `Pin #${pathSegments[1]}`+ } else if (pathSegments.length >= 1) {+ title = `@${pathSegments[0]}`+ }+ } else if (hostname.includes('wikipedia.org')) {+ if (pathSegments.length >= 2 && pathSegments[0] === 'wiki') {+ title = decodeURIComponent(pathSegments[1]).replace(/_/g, ' ')+ }+ } else if (hostname.includes('reddit.com')) {+ if (pathSegments.length >= 2 && pathSegments[0] === 'r') {+ title = `r/${pathSegments[1]}`+ }+ } else if (hostname.includes('youtube.com') || hostname.includes('youtu.be')) {+ const v = urlObj.searchParams.get('v')+ if (v) {+ title = `Video (${v})`+ } else if (pathSegments.length > 0) {+ title = `Video (${pathSegments[0]})`+ }+ } else if (pathSegments.length > 0) {+ const lastSeg = pathSegments[pathSegments.length - 1]+ const cleanSeg = decodeURIComponent(lastSeg)+ .replace(/[-_]/g, ' ')+ .replace(/\.(html?|php|aspx?)$/i, '')+ if (cleanSeg.length > 3 && !/^[0-9a-f]{8,}$/i.test(cleanSeg)) {+ title = cleanSeg.charAt(0).toUpperCase() + cleanSeg.slice(1)+ }+ }++ const faviconUrl = `https://www.google.com/s2/favicons?domain=${hostname}&sz=32`++ return {+ url: rawUrl,+ domain: hostname,+ serviceName,+ title,+ brandColor,+ faviconUrl,+ }+}diff --git a/src/styles/item.css b/src/styles/item.cssindex 30bea9d..baf4887 100644--- a/src/styles/item.css+++ b/src/styles/item.css@@ -195,6 +195,56 @@color: rgba(255, 255, 255, 0.9);}+/* Smart Link Preview Card */+.link-preview-card {+ display: flex;+ flex-direction: column;+ gap: 6px;+ width: 100%;+}+.link-preview-header {+ display: flex;+ align-items: center;+}+.link-brand-pill {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ background: rgba(255, 255, 255, 0.07);+ border: 1px solid rgba(255, 255, 255, 0.12);+ border-radius: 999px;+ padding: 3px 10px;+}+.link-service {+ font-size: calc(11.5px * var(--font-scale, 1));+ font-weight: 600;+ color: #ffffff;+ letter-spacing: -0.01em;+}+.link-dot {+ font-size: 10px;+ color: rgba(255, 255, 255, 0.35);+}+.link-domain {+ font-size: calc(11px * var(--font-scale, 1));+ color: rgba(255, 255, 255, 0.65);+ font-weight: 450;+}+.link-title {+ font-size: calc(13px * var(--font-scale, 1));+ font-weight: 550;+ color: rgba(255, 255, 255, 0.95);+ line-height: 1.35;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.link-url {+ font-size: calc(11.5px * var(--font-scale, 1));+ color: rgba(255, 255, 255, 0.70);+ word-break: break-all;+}+/* Image thumbnails */.thumb {width: 100%;