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(clipboard): add emoji picker and harden long-text history
Deepender25cd4ef4b65af8
diff --git a/LICENSE b/LICENSEindex 261eeb9..6353c2d 100644--- a/LICENSE+++ b/LICENSE@@ -199,3 +199,10 @@WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.++------------------------------------------------------------------------+Third-party artwork++Twemoji graphics © Twitter, Inc. and other contributors.+Licensed under CC-BY 4.0. https://github.com/twitter/twemoji+------------------------------------------------------------------------diff --git a/electron/clipboard/formats.ts b/electron/clipboard/formats.tsindex fdb1671..6b86374 100644--- a/electron/clipboard/formats.ts+++ b/electron/clipboard/formats.ts@@ -558,11 +558,16 @@ export function isUrlText(s: string): boolean {* read); over-clearing when two same-dimension images are involved is the* documented, acceptable trade-off.*/-export function signatureMatchesItem(sig: string, data: ItemData): boolean {+export function signatureMatchesItem(sig: string, data: ItemData, fullText?: string): boolean {const bare = sig.replace(/^seq:\d+:/, '')switch (data.kind) {- case 'text':- return bare === `text:${data.text}`+ case 'text': {+ const body = fullText && fullText.length > 0 ? fullText : data.text+ if (bare === `text:${body}`) return true+ // Long items store only a 300-char preview; the OS clipboard still has the full string.+ if (data.hasFullPayload && data.text && bare.startsWith(`text:${data.text}`)) return true+ return false+ }case 'files':return bare === `files:${data.paths.join('\n')}`case 'image':diff --git a/electron/main/imageProtocol.ts b/electron/main/imageProtocol.tsindex 336221a..274c52a 100644--- a/electron/main/imageProtocol.ts+++ b/electron/main/imageProtocol.ts@@ -1,4 +1,4 @@-import { readdirSync } from 'node:fs'+import { existsSync, readdirSync } from 'node:fs'import { basename, dirname, extname, join, resolve } from 'node:path'import { APP_CONFIG } from './config'@@ -34,6 +34,33 @@ export function thumbnailUrlForFile(filePath: string): string {return `${APP_CONFIG.imageProtocol}://thumb/file/${encodeURIComponent(filePath.replace(/\\/g, '/'))}`}+const EMOJI_FILE_RE = /^[0-9a-f][0-9a-f0-9-]*\.png$/++/** Directory of Twemoji 64px PNGs (dev: node_modules, packaged: extraResources). */+export function emojiAssetDir(opts: { packaged: boolean; resourcesPath: string; appPath: string; cwd: string }): string {+ if (opts.packaged) return join(opts.resourcesPath, 'emoji', '64')+ const candidates = [+ join(opts.cwd, 'node_modules', 'emoji-datasource-twitter', 'img', 'twitter', '64'),+ join(opts.appPath, 'node_modules', 'emoji-datasource-twitter', 'img', 'twitter', '64')+ ]+ return candidates.find((dir) => existsSync(dir)) ?? candidates[0]+}++/**+ * Resolve a picker glyph filename to an on-disk PNG. Rejects anything that+ * is not a lowercase hex-and-hyphen name so the protocol cannot escape the+ * emoji asset directory.+ */+export function resolveEmojiAsset(assetDir: string, fileName: string): string | null {+ const name = fileName.toLowerCase()+ if (!EMOJI_FILE_RE.test(name)) return null+ const baseDir = resolve(assetDir)+ const filePath = resolve(join(baseDir, name))+ if (dirname(filePath) !== baseDir) return null+ if (!existsSync(filePath)) return null+ return filePath+}+/*** Resolve an edgelocal image id to the staged file without allowing the id to* select paths or arbitrary file types. Clipboard captures are PNG, whilediff --git a/electron/main/index.ts b/electron/main/index.tsindex 1f7e192..bc5c911 100644--- a/electron/main/index.ts+++ b/electron/main/index.ts@@ -25,7 +25,7 @@ import { flushStagedTempRegistry } from './stagedTemp'import { extname, normalize } from 'node:path'import { existsSync, createReadStream } from 'node:fs'import { createHash } from 'node:crypto'-import { resolveStoredImage } from './imageProtocol'+import { resolveStoredImage, resolveEmojiAsset, emojiAssetDir } from './imageProtocol'import { getThumbnailPayload, thumbnailCacheControl } from './thumbnailCache'// Edge-Drop renders a small, mostly static transparent panel. Chromium's GPU@@ -161,6 +161,27 @@ app.on('activate', () => {function registerImageProtocol(): void {protocol.handle(APP_CONFIG.imageProtocol, async (request) => {try {+ if (request.url.startsWith(`${APP_CONFIG.imageProtocol}://emoji/`)) {+ const fileName = decodeURIComponent(request.url.slice(`${APP_CONFIG.imageProtocol}://emoji/`.length).split('?')[0] ?? '')+ const dir = emojiAssetDir({+ packaged: app.isPackaged,+ resourcesPath: process.resourcesPath,+ appPath: app.getAppPath(),+ cwd: process.cwd()+ })+ const filePath = resolveEmojiAsset(dir, fileName)+ if (!filePath) return new Response('Not found', { status: 404 })+ const stream = createReadStream(filePath)+ const body = new Response(stream as unknown as ReadableStream<Uint8Array>).body+ return new Response(body, {+ status: 200,+ headers: new Headers({+ 'Content-Type': 'image/png',+ 'Cache-Control': 'public, max-age=31536000, immutable'+ })+ })+ }+// List cards request bounded raster thumbnails. Do not hand an original// multi-megapixel file to Chromium merely to paint a 50–240px card.if (request.url.startsWith(`${APP_CONFIG.imageProtocol}://thumb/`)) {diff --git a/electron/main/ipc.ts b/electron/main/ipc.tsindex 5d2dda1..2a3e89a 100644--- a/electron/main/ipc.ts+++ b/electron/main/ipc.ts@@ -18,12 +18,13 @@ import { getOnboardingWindow } from './onboardingWindow'import { rebuildTrayMenu } from './tray'import { startDragOut, resolveDragData, prestageDrag, stageDragFile } from './drag'import { clipboardSignature, formatTabularDataForClipboard, signatureMatchesItem } from '../clipboard/formats'-import type { ItemData, MergeResult } from '../../shared/types'+import type { ClipboardItem, ItemData, MergeResult } from '../../shared/types'import { quitAndInstallUpdate, checkForUpdatesManual, startUpdateDownload, syncAutoUpdaterState } from './updater'import { createId } from '../store/ids'import { isStoreBuild } from './config'import { applyLaunchAtLogin, refreshLaunchAtLoginFromOs } from './loginItems'import { toUnpackagedFilePath, toUnpackagedFilePaths } from '../store/paths'+import { isPasteableEmoji } from '../../shared/emoji'export { isStoreBuild }@@ -39,8 +40,12 @@ export { isStoreBuild }* clipboard; deleting an old history entry that the user has since replaced* must never wipe their current clipboard contents.*/-function clipboardMatchesItem(data: ItemData): boolean {- return signatureMatchesItem(clipboardSignature(), data)+function clipboardMatchesItem(item: ClipboardItem): boolean {+ const fullText =+ item.data.kind === 'text' && item.data.hasFullPayload+ ? getStore().getFullText(item.id)+ : undefined+ return signatureMatchesItem(clipboardSignature(), item.data, fullText)}/** Fire a transient toast to the renderer (best-effort; renderer may be closed). */@@ -241,30 +246,43 @@ export function registerIpc(): void {handle('item:delete', (id) => {const item = getStore().get(id)- // Resolve clipboard ownership BEFORE mutating the store: if this exact- // content still sits on the system clipboard it must be cleared first so- // (a) the staged-temp cleanup inside delete() can never yank a file from- // under a live OS clipboard reference, and (b) resyncSignature() below- // locks onto an EMPTY clipboard, making an immediate re-copy of the same- // content a detectable change instead of an invisible no-op.- if (item && clipboardMatchesItem(item.data)) {- clipboard.clear()+ const watcher = getWatcher()+ // Pause first: an in-flight settle timer from the copy that created this+ // item would otherwise readClipboard() after we splice and put it back.+ watcher.setPaused(true)+ try {+ // Resolve clipboard ownership BEFORE mutating the store: if this exact+ // content still sits on the system clipboard it must be cleared first so+ // (a) the staged-temp cleanup inside delete() can never yank a file from+ // under a live OS clipboard reference, and (b) resyncSignature() below+ // locks onto an EMPTY clipboard, making an immediate re-copy of the same+ // content a detectable change instead of an invisible no-op.+ if (item && clipboardMatchesItem(item)) {+ clipboard.clear()+ }+ getStore().delete(id)+ } finally {+ watcher.resyncSignature()+ watcher.setPaused(loadSettings().incognito)}- getStore().delete(id)- getWatcher().resyncSignature()pushState.items()return getStore().toDto()})handle('item:delete-batch', (ids) => {if (!ids || ids.length === 0) return getStore().toDto()- const items = ids.map((id) => getStore().get(id)).filter(Boolean)- // Single ownership pass before removal (same rule as single delete).- if (items.some((item) => item && clipboardMatchesItem(item.data))) {- clipboard.clear()+ const items = ids.map((id) => getStore().get(id)).filter((item): item is ClipboardItem => !!item)+ const watcher = getWatcher()+ watcher.setPaused(true)+ try {+ if (items.some((item) => clipboardMatchesItem(item))) {+ clipboard.clear()+ }+ getStore().deleteBatch(ids)+ } finally {+ watcher.resyncSignature()+ watcher.setPaused(loadSettings().incognito)}- getStore().deleteBatch(ids)- getWatcher().resyncSignature()pushState.items()return getStore().toDto()})@@ -369,6 +387,8 @@ export function registerIpc(): void {// ---------------------------------------------------------------------------let _lastPasteTime = 0const PASTE_GUARD_MS = 600+ let _lastEmojiPasteTime = 0+ const EMOJI_PASTE_GUARD_MS = 180handle('item:paste', async (id) => {const now = Date.now()@@ -492,6 +512,33 @@ export function registerIpc(): void {return true})+ handle('emoji:paste', async (text) => {+ if (!isPasteableEmoji(text)) return false+ const now = Date.now()+ if (now - _lastEmojiPasteTime < EMOJI_PASTE_GUARD_MS) return false+ _lastEmojiPasteTime = now++ const watcher = getWatcher()+ watcher.setPaused(true)+ try {+ // Write + Ctrl+V only. Do NOT add() to history — picker inserts are a+ // paste tool, not a capture. resyncSignature() so this write is not+ // seen as a new capture when the watcher resumes. A later copy of the+ // same emoji from another app still lands: signatures include the Win32+ // sequence number, so an outside Ctrl+C is a new seq and is recorded.+ clipboard.writeText(text.trim())+ setTimeout(() => {+ simulatePaste()+ }, 40)+ } finally {+ setTimeout(() => {+ watcher.resyncSignature()+ watcher.setPaused(loadSettings().incognito)+ }, 350)+ }+ return true+ })+handle('item:add-files', (paths) => {const result = addFiles(paths)// If a large drop was split into several stacks, let the user know whydiff --git a/electron/preload/index.ts b/electron/preload/index.tsindex 871f37f..4c4bc1a 100644--- a/electron/preload/index.ts+++ b/electron/preload/index.ts@@ -187,6 +187,7 @@ const api = {copySubitem: (req: import('../../shared/types').DragRequest) => invoke('item:copy-subitem', req),pasteItem: (id: string) => invoke('item:paste', id),pasteSubitem: (req: import('../../shared/types').DragRequest) => invoke('item:paste-subitem', req),+ pasteEmoji: (text: string) => invoke('emoji:paste', text),installUpdate: () => invoke('app:install-update'),checkForUpdatesManual: () => invoke('updater:check-manual'),startUpdateDownload: () => invoke('updater:start-download'),diff --git a/electron/store/ItemStore.ts b/electron/store/ItemStore.tsindex 0b4c3a5..67469f8 100644--- a/electron/store/ItemStore.ts+++ b/electron/store/ItemStore.ts@@ -142,7 +142,14 @@ export class ItemStore {private rebuildIndex(): void {this.sigToId.clear()- for (const it of this.items) this.sigToId.set(contentSignature(it.data), it.id)+ for (const it of this.items) {+ if (it.data.kind === 'text' && it.data.hasFullPayload) {+ const full = this.getFullText(it.id)+ this.sigToId.set(contentSignature({ ...it.data, text: full }), it.id)+ } else {+ this.sigToId.set(contentSignature(it.data), it.id)+ }+ }}private persistTimer: ReturnType<typeof setTimeout> | null = null@@ -176,9 +183,9 @@ export class ItemStore {encrypted: true,payload: encryptedBuf.toString('base64')}- writeFileSync(file, JSON.stringify(envelope, null, 2), 'utf8')+ writeFileSync(file, JSON.stringify(envelope), 'utf8')} else {- writeFileSync(file, JSON.stringify(indexObj, null, 2), 'utf8')+ writeFileSync(file, JSON.stringify(indexObj), 'utf8')}} catch (err) {console.error('[ItemStore] Persistence failed:', err)diff --git a/package-lock.json b/package-lock.jsonindex 034e456..70b5e85 100644--- a/package-lock.json+++ b/package-lock.json@@ -15,6 +15,7 @@"@radix-ui/react-separator": "^1.1.11","@resvg/resvg-js": "^2.6.2","electron-updater": "^6.8.9",+ "emoji-datasource-twitter": "^16.0.0","framer-motion": "^11.0.24","gsap": "^3.15.0","koffi": "^3.1.2",@@ -4415,6 +4416,12 @@"node": ">=6 <7 || >=8"}},+ "node_modules/emoji-datasource-twitter": {+ "version": "16.0.0",+ "resolved": "https://registry.npmjs.org/emoji-datasource-twitter/-/emoji-datasource-twitter-16.0.0.tgz",+ "integrity": "sha512-7F+uCuHH+7Qnrc15P5tnbvKkg9E6tlzi4MnT2uW1RlN4pLYTza6cP/dstIfSDMtpjFLWuZewWg8jBbuL2eyELQ==",+ "license": "MIT"+ },"node_modules/emoji-regex": {"version": "8.0.0","resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",diff --git a/package.json b/package.jsonindex 8519d07..f47ccaa 100644--- a/package.json+++ b/package.json@@ -38,6 +38,10 @@{"from": "resources/startup/EdgeDropStartup.exe","to": "startup/EdgeDropStartup.exe"+ },+ {+ "from": "node_modules/emoji-datasource-twitter/img/twitter/64",+ "to": "emoji/64"}],"asarUnpack": [@@ -110,6 +114,7 @@"@radix-ui/react-separator": "^1.1.11","@resvg/resvg-js": "^2.6.2","electron-updater": "^6.8.9",+ "emoji-datasource-twitter": "^16.0.0","framer-motion": "^11.0.24","gsap": "^3.15.0","koffi": "^3.1.2",diff --git a/shared/bridge.ts b/shared/bridge.tsindex ca84ed8..78a89c8 100644--- a/shared/bridge.ts+++ b/shared/bridge.ts@@ -21,6 +21,7 @@ export interface EdgeApi {copySubitem: (req: DragRequest) => Promise<boolean>pasteItem: (id: string) => Promise<boolean>pasteSubitem: (req: DragRequest) => Promise<boolean>+ pasteEmoji: (text: string) => Promise<boolean>installUpdate: () => Promise<void>checkForUpdatesManual: () => Promise<{ status: string; version?: string; error?: string }>startUpdateDownload: () => Promise<void>diff --git a/shared/emoji.ts b/shared/emoji.tsnew file mode 100644index 0000000..2830f8f--- /dev/null+++ b/shared/emoji.ts@@ -0,0 +1,9 @@+/** Shared emoji-paste guards used by main (IPC) and renderer tests. */++export function isPasteableEmoji(text: string): boolean {+ if (typeof text !== 'string') return false+ const s = text.trim()+ if (s.length < 1 || s.length > 64) return false+ if (/[\n\r\t]/.test(s)) return false+ return true+}diff --git a/shared/ipc.ts b/shared/ipc.tsindex 5e44724..6eeb5fe 100644--- a/shared/ipc.ts+++ b/shared/ipc.ts@@ -50,6 +50,9 @@ export interface InvokeMap {/** Copy a sub-item and paste it directly into the active application. */'item:paste-subitem': { args: [req: DragRequest]; result: boolean }+ /** Write a Unicode emoji to the clipboard and Ctrl+V into the still-focused app. Does not close the shelf. */+ 'emoji:paste': { args: [text: string]; result: boolean }+/** Add local file paths dragged into the shelf. */'item:add-files': { args: [paths: string[]]; result: ClipboardItemDto[] }diff --git a/src/components/EmojiPicker.tsx b/src/components/EmojiPicker.tsxnew file mode 100644index 0000000..72d68fb--- /dev/null+++ b/src/components/EmojiPicker.tsx@@ -0,0 +1,367 @@+/**+ * Unicode emoji library. Glyphs are Twemoji; paste is the character itself.+ * No text field — categories + click — so the shelf never takes OS focus.+ */+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'+import {+ CATEGORY_ORDER,+ emojiGlyphUrl,+ hasSkinTones,+ pushRecent,+ resolveGlyph,+ skinChoices,+ unifiedToNative,+ type EmojiCatalog,+ type EmojiCategoryId,+ type EmojiEntry+} from '../lib/emoji/catalog'+import { loadEmojiCatalog } from '../lib/emoji/load'+import { loadRecents, saveRecents } from '../lib/emoji/prefs'+import { useStore } from '../store/appStore'+import { playButtonClickSound } from '../lib/soundEffects'+import { useTranslation } from '../i18n'+import {+ TrashIcon,+ EmojiSmileIcon,+ EmojiClockIcon,+ EmojiPawIcon,+ EmojiFoodIcon,+ EmojiPlaneIcon,+ EmojiTrophyIcon,+ EmojiBulbIcon,+ EmojiShapesIcon+} from './icons'+import type { SVGProps } from 'react'++type IconCmp = (p: SVGProps<SVGSVGElement>) => JSX.Element++const CATEGORY_ICONS: Record<EmojiCategoryId, IconCmp> = {+ recents: EmojiClockIcon,+ smileys: EmojiSmileIcon,+ animals: EmojiPawIcon,+ food: EmojiFoodIcon,+ travel: EmojiPlaneIcon,+ activities: EmojiTrophyIcon,+ objects: EmojiBulbIcon,+ symbols: EmojiShapesIcon+}++const COLS = 7+const ROW_H = 36+const PASTE_GAP_MS = 180+const TONE_POP_W = 216+const TONE_POP_H = 44++interface TonePopup {+ entry: EmojiEntry+ left: number+ top: number+ place: 'above' | 'below'+}++function Glyph({ file, size = 22 }: { file: string; size?: number }) {+ return (+ <img+ className="emoji-glyph"+ src={emojiGlyphUrl(file)}+ alt=""+ width={size}+ height={size}+ draggable={false}+ decoding="async"+ style={{ width: size, height: size }}+ />+ )+}++export function EmojiPicker() {+ const { t } = useTranslation()+ const pasteEmoji = useStore((s) => s.pasteEmoji)+ const category = useStore((s) => s.emojiCategory)+ const setCategory = useStore((s) => s.setEmojiCategory)+ const [catalog, setCatalog] = useState<EmojiCatalog | null>(null)+ const [failed, setFailed] = useState(false)+ const [recents, setRecents] = useState<string[]>(loadRecents)+ const [scrollTop, setScrollTop] = useState(0)+ const [viewH, setViewH] = useState(320)+ const [tonePop, setTonePop] = useState<TonePopup | null>(null)+ const [hoveredCat, setHoveredCat] = useState<{+ label: string+ left: number+ } | null>(null)+ const scrollerRef = useRef<HTMLDivElement>(null)+ const pickerRef = useRef<HTMLDivElement>(null)+ const lastPasteAt = useRef(0)++ const shownCats = useMemo(() => {+ return CATEGORY_ORDER.filter((c) => c.id !== 'recents' || recents.length > 0)+ }, [recents])++ const selectCategory = useCallback((id: EmojiCategoryId) => {+ playButtonClickSound()+ setTonePop(null)+ setHoveredCat(null)+ setCategory(id)+ setScrollTop(0)+ if (scrollerRef.current) scrollerRef.current.scrollTop = 0+ }, [setCategory])++ useEffect(() => {+ let alive = true+ loadEmojiCatalog()+ .then((c) => {+ if (!alive) return+ setCatalog(c)+ if (loadRecents().length > 0 && category === 'smileys') {+ setCategory('recents')+ }+ })+ .catch(() => {+ if (alive) setFailed(true)+ })+ return () => {+ alive = false+ }+ }, [])++ useEffect(() => {+ setTonePop(null)+ setHoveredCat(null)+ setScrollTop(0)+ if (scrollerRef.current) scrollerRef.current.scrollTop = 0+ }, [category])++ useEffect(() => {+ const el = scrollerRef.current+ if (!el) return+ const ro = new ResizeObserver(() => setViewH(el.clientHeight))+ ro.observe(el)+ setViewH(el.clientHeight)+ return () => ro.disconnect()+ }, [catalog])++ const items = useMemo(() => {+ if (!catalog) return [] as Array<{ key: string; file: string; entry: EmojiEntry }>+ if (category === 'recents') {+ const out: Array<{ key: string; file: string; entry: EmojiEntry }> = []+ for (const u of recents) {+ const g = resolveGlyph(catalog, u)+ if (g) out.push({ key: g.unified, file: g.file, entry: g.entry })+ }+ return out+ }+ const spec = CATEGORY_ORDER.find((c) => c.id === category)+ if (!spec || !spec.sources || spec.sources.length === 0) return []+ const out: Array<{ key: string; file: string; entry: EmojiEntry }> = []+ for (const src of spec.sources) {+ const list = catalog.byCategory[src] ?? []+ for (const entry of list) {+ out.push({ key: entry.unified, file: entry.file, entry })+ }+ }+ return out+ }, [catalog, category, recents])++ const rows = Math.ceil(items.length / COLS)+ const overscan = 3+ const startRow = Math.max(0, Math.floor(scrollTop / ROW_H) - overscan)+ const visibleRows = Math.ceil(viewH / ROW_H) + overscan * 2+ const endRow = Math.min(rows, startRow + visibleRows)++ const onPaste = useCallback(+ (unified: string) => {+ const now = Date.now()+ if (now - lastPasteAt.current < PASTE_GAP_MS) return+ lastPasteAt.current = now+ playButtonClickSound()+ void pasteEmoji(unifiedToNative(unified))+ const next = pushRecent(recents, unified)+ setRecents(next)+ saveRecents(next)+ setTonePop(null)+ },+ [pasteEmoji, recents]+ )++ const openTonePop = (entry: EmojiEntry, cell: HTMLElement) => {+ const picker = pickerRef.current+ if (!picker) return+ const pr = picker.getBoundingClientRect()+ const cr = cell.getBoundingClientRect()+ const center = cr.left - pr.left + cr.width / 2+ const left = Math.min(pr.width - TONE_POP_W / 2 - 8, Math.max(TONE_POP_W / 2 + 8, center))+ const spaceAbove = cr.top - pr.top+ const place: 'above' | 'below' = spaceAbove >= TONE_POP_H + 10 ? 'above' : 'below'+ const top = place === 'above' ? cr.top - pr.top : cr.bottom - pr.top+ setTonePop({ entry, left, top, place })+ setHoveredCat(null)+ }++ return (+ <div+ className="emoji-picker"+ ref={pickerRef}+ onPointerDown={(e) => {+ const t = e.target as HTMLElement+ if (!t.closest('[data-tone-popup], [data-has-skins]')) setTonePop(null)+ }}+ >+ <div className="emoji-cat-bar" role="tablist" aria-label={t('emoji.categories')}>+ {shownCats.map((c) => {+ const Icon = CATEGORY_ICONS[c.id]+ const active = category === c.id+ const label = t(c.labelKey)+ return (+ <button+ key={c.id}+ type="button"+ role="tab"+ data-cat={c.id}+ aria-selected={active}+ aria-label={label}+ tabIndex={-1}+ className={`emoji-cat-btn${active ? ' active' : ''}`}+ onPointerEnter={(e) => {+ const picker = pickerRef.current+ if (!picker) return+ const pr = picker.getBoundingClientRect()+ const cr = e.currentTarget.getBoundingClientRect()+ const center = cr.left - pr.left + cr.width / 2+ setHoveredCat({+ label,+ left: center+ })+ }}+ onPointerLeave={() => setHoveredCat(null)}+ onClick={(e) => {+ e.currentTarget.blur()+ setHoveredCat(null)+ selectCategory(c.id)+ }}+ >+ <Icon width={16} height={16} />+ </button>+ )+ })}+ </div>++ {hoveredCat && (+ <div+ className="emoji-cat-tooltip"+ style={{ left: hoveredCat.left }}+ aria-hidden+ >+ {hoveredCat.label}+ </div>+ )}++ {failed ? (+ <div className="emoji-status">{t('emoji.loadFailed')}</div>+ ) : !catalog ? (+ <div className="emoji-skel" aria-hidden>+ {Array.from({ length: 28 }, (_, i) => (+ <i key={i} />+ ))}+ </div>+ ) : items.length === 0 ? (+ <div className="emoji-empty">{t('emoji.emptyRecents')}</div>+ ) : (+ <div+ ref={scrollerRef}+ className="emoji-grid"+ onScroll={(e) => {+ setScrollTop((e.currentTarget as HTMLDivElement).scrollTop)+ setTonePop(null)+ setHoveredCat(null)+ }}+ >+ <div style={{ height: startRow * ROW_H }} />+ {Array.from({ length: endRow - startRow }, (_, i) => {+ const row = startRow + i+ const slice = items.slice(row * COLS, row * COLS + COLS)+ return (+ <div key={row} className="emoji-row">+ {slice.map((item) => {+ const skinnable = hasSkinTones(item.entry)+ return (+ <button+ key={item.key}+ type="button"+ tabIndex={-1}+ className="emoji-cell"+ data-has-skins={skinnable ? '' : undefined}+ title={unifiedToNative(item.key)}+ onClick={(e) => {+ e.currentTarget.blur()+ if (skinnable) {+ if (tonePop?.entry.unified === item.entry.unified) {+ setTonePop(null)+ return+ }+ playButtonClickSound()+ openTonePop(item.entry, e.currentTarget)+ return+ }+ onPaste(item.key)+ }}+ >+ <Glyph file={item.file} size={26} />+ </button>+ )+ })}+ </div>+ )+ })}+ <div style={{ height: Math.max(0, (rows - endRow) * ROW_H) }} />+ </div>+ )}++ {category === 'recents' && recents.length > 0 && (+ <div className="emoji-recents-footer">+ <button+ type="button"+ className="emoji-recents-clear-btn"+ title={t('emoji.clearRecents') || 'Clear'}+ onClick={() => {+ playButtonClickSound()+ setRecents([])+ saveRecents([])+ setCategory('smileys')+ }}+ >+ <TrashIcon width={12} height={12} />+ <span>{t('emoji.clearRecents') || 'Clear'}</span>+ </button>+ </div>+ )}++ {tonePop && (+ <div+ data-tone-popup+ className={`emoji-tone-pop emoji-tone-pop-${tonePop.place}`}+ role="listbox"+ aria-label={t('emoji.skinTone')}+ style={{ left: tonePop.left, top: tonePop.top }}+ >+ {skinChoices(tonePop.entry).map((choice) => (+ <button+ key={choice.unified}+ type="button"+ tabIndex={-1}+ className="emoji-tone-choice"+ aria-label={choice.unified}+ onClick={(e) => {+ e.currentTarget.blur()+ onPaste(choice.unified)+ }}+ >+ <Glyph file={choice.file} size={24} />+ </button>+ ))}+ </div>+ )}+ </div>+ )+}++export default EmojiPickerdiff --git a/src/components/Header.tsx b/src/components/Header.tsxindex 4e67ad1..6505d1c 100644--- a/src/components/Header.tsx+++ b/src/components/Header.tsx@@ -35,6 +35,7 @@ export function Header() {const typeFilter = useStore((s) => s.typeFilter)const setTypeFilter = useStore((s) => s.setTypeFilter)+ const emojiOpen = useStore((s) => s.emojiOpen)const FILTERS: { id: import('../../shared/types').TypeFilter; label: string }[] = [{ id: 'all', label: t('filters.all') },@@ -57,6 +58,10 @@ export function Header() {<span style={{ fontSize: 13, fontWeight: 600, color: '#8e8e93', letterSpacing: '0.01em', paddingLeft: 6, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: 170 }}>{settingsSubView === 'changelog' ? t('header.whatsNew') : t('header.settings')}</span>+ ) : emojiOpen ? (+ <span style={{ fontSize: 13, fontWeight: 600, color: '#8e8e93', letterSpacing: '0.01em', paddingLeft: 6, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: 170 }}>+ Emoji+ </span>) : (<divclassName="filter-segmented-track"diff --git a/src/components/Panel.tsx b/src/components/Panel.tsxindex b3776ec..9e87eec 100644--- a/src/components/Panel.tsx+++ b/src/components/Panel.tsx@@ -13,6 +13,9 @@ import { useStore } from '../store/appStore'import { PANEL_LEAVE_EVENT, PANEL_ENTER_EVENT } from '../hooks/useEdgeHover'import { Header } from './Header'import { ItemList } from './ItemList'+import { EmojiPicker } from './EmojiPicker'+import { ClipboardIcon, EmojiSmileIcon, ChevronLeftIcon } from './icons'+import { playButtonClickSound } from '../lib/soundEffects'import { Settings } from './Settings'import { ToastStack } from './Toast'import { ClearMenu } from './ClearMenu'@@ -37,6 +40,8 @@ export function Panel() {const settingsOpen = useStore((s) => s.settingsOpen)const setSettingsOpen = useStore((s) => s.setSettingsOpen)const setQuery = useStore((s) => s.setQuery)+ const emojiOpen = useStore((s) => s.emojiOpen)+ const setEmojiOpen = useStore((s) => s.setEmojiOpen)const edgeHintActive = useStore((s) => s.edgeHintActive)useEffect(() => {@@ -47,11 +52,12 @@ export function Panel() {if (!useStore.getState().open) {setSettingsOpen(false)setQuery('')+ setEmojiOpen(false)}}, 400)return () => window.clearTimeout(timer)}- }, [open, setSettingsOpen, setQuery])+ }, [open, setSettingsOpen, setQuery, setEmojiOpen])const screenH = typeof window !== 'undefined' ? window.innerHeight : 800const pFrac = settings.panelHeight || 0.6@@ -354,19 +360,56 @@ export function Panel() {</motion.div>) : (<motion.div- key="list"- initial={{ opacity: 1, x: isRight ? 8 : -8 }}- animate={{ opacity: 1, x: 0 }}- exit={{ opacity: 0, x: isRight ? -8 : 8 }}+ key={emojiOpen ? 'emoji' : 'list'}+ initial={{ opacity: 0, y: emojiOpen ? 8 : -8 }}+ animate={{ opacity: 1, y: 0 }}+ exit={{ opacity: 0, y: emojiOpen ? -8 : 8 }}transition={{ type: 'spring', stiffness: 500, damping: 32, mass: 0.5 }}style={{ gridArea: '1 / 1 / 2 / 2', display: 'flex', flexDirection: 'column', overflow: 'hidden', position: 'relative' }}>- <ItemList />+ {emojiOpen ? <EmojiPicker /> : <ItemList />}<div className="footer" style={{ position: 'relative' }}>- <span className="count">- {filteredCount} {t('item.items')}- </span>+ <div style={{ display: 'flex', alignItems: 'center', gap: 8, flexShrink: 0 }}>+ {emojiOpen ? (+ <button+ type="button"+ className="footer-back-pill"+ title={t('onboarding.back')}+ tabIndex={-1}+ onClick={(e) => {+ e.currentTarget.blur()+ playButtonClickSound()+ setEmojiOpen(false)+ }}+ >+ <ChevronLeftIcon width={13} height={13} />+ <ClipboardIcon width={13} height={13} />+ <span>{t('onboarding.back')}</span>+ </button>+ ) : (+ <div className="footer-capsule">+ <span className="footer-capsule-count" title={`${filteredCount}`}>+ {filteredCount}+ </span>+ <div className="footer-capsule-divider" />+ <button+ type="button"+ className="footer-capsule-btn"+ title="Emoji"+ tabIndex={-1}+ onClick={(e) => {+ e.currentTarget.blur()+ playButtonClickSound()+ setEmojiOpen(true)+ }}+ >+ <EmojiSmileIcon width={15} height={15} />+ </button>+ </div>+ )}+ </div><div className="spacer" />+ {!emojiOpen && (<ClearMenuitems={filteredItems}disabled={recent.length === 0}@@ -380,6 +423,7 @@ export function Panel() {}}}/>+ )}</div></motion.div>)}diff --git a/src/components/icons.tsx b/src/components/icons.tsxindex 78a9527..795ee14 100644--- a/src/components/icons.tsx+++ b/src/components/icons.tsx@@ -2,7 +2,7 @@* Official Lucide React Icon Suite for Edge-Drop.* Powered by lucide-react — ultra-crisp 24x24 vector icons.*/-import type { SVGProps } from 'react'+import type { ReactNode, SVGProps } from 'react'import {Info,Sparkles,@@ -31,7 +31,8 @@ import {Coffee,Heart,Star,- RotateCcw+ RotateCcw,+ Clipboard} from 'lucide-react'type P = SVGProps<SVGSVGElement>@@ -85,6 +86,110 @@ export const ExpandIcon = (p: P) => <Maximize2 size={p.width ?? 16} {...(p as anexport const ContractIcon = (p: P) => <Minimize2 size={p.width ?? 16} {...(p as any)} />export const FolderOpenIcon = (p: P) => <FolderOpen size={p.width ?? 16} {...(p as any)} />export const CheckIcon = (p: P) => <Check size={p.width ?? 16} {...(p as any)} />+export const ClipboardIcon = (p: P) => <Clipboard size={p.width ?? 16} strokeWidth={2.1} {...(p as any)} />++/** Category marks — optical 16px line icons, lighter than Lucide at this size. */+const CAT_STROKE = {+ fill: 'none',+ stroke: 'currentColor',+ strokeWidth: 1.65,+ strokeLinecap: 'round' as const,+ strokeLinejoin: 'round' as const+}++function CatSvg({ children, ...p }: P & { children: ReactNode }) {+ return (+ <svg viewBox="0 0 24 24" width={p.width ?? 18} height={p.height ?? 18} fill="none" aria-hidden {...(p as any)}>+ {children}+ </svg>+ )+}++export const EmojiSmileIcon = (p: P) => (+ <CatSvg {...p}>+ <circle cx="12" cy="12" r="8.25" {...CAT_STROKE} />+ <circle cx="9.15" cy="10.2" r="1.05" fill="currentColor" stroke="none" />+ <circle cx="14.85" cy="10.2" r="1.05" fill="currentColor" stroke="none" />+ <path d="M8.6 14.15c.95 1.55 2.05 2.2 3.4 2.2s2.45-.65 3.4-2.2" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiClockIcon = (p: P) => (+ <CatSvg {...p}>+ <circle cx="12" cy="12" r="8.25" {...CAT_STROKE} />+ <path d="M12 7.6v5.05l3.35 1.9" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiUserIcon = (p: P) => (+ <CatSvg {...p}>+ <circle cx="9.2" cy="9" r="2.35" {...CAT_STROKE} />+ <path d="M4.7 17.4c.35-2.45 2.15-3.85 4.5-3.85 2.35 0 4.15 1.4 4.5 3.85" {...CAT_STROKE} />+ <circle cx="15.35" cy="9.15" r="2.05" {...CAT_STROKE} />+ <path d="M13.2 13.85c1.55-.7 3.4-.55 4.85.7.95.8 1.5 1.9 1.7 2.85" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiPawIcon = (p: P) => (+ <CatSvg {...p}>+ <path d="M7.35 10.4 9.2 5.7l2.15 4.5" {...CAT_STROKE} />+ <path d="M12.65 10.2 14.8 5.7l1.85 4.7" {...CAT_STROKE} />+ <circle cx="12" cy="13.55" r="5.05" {...CAT_STROKE} />+ <circle cx="9.9" cy="13.1" r="0.85" fill="currentColor" stroke="none" />+ <circle cx="14.1" cy="13.1" r="0.85" fill="currentColor" stroke="none" />+ <path d="M10.4 15.55c.5.7 1 .95 1.6.95s1.1-.25 1.6-.95" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiFoodIcon = (p: P) => (+ <CatSvg {...p}>+ <path d="M7.1 5v3.6M9.3 5v3.6M11.5 5v3.6" {...CAT_STROKE} />+ <path d="M9.3 8.6v10.6" {...CAT_STROKE} />+ <path d="M15.6 5.2v14" {...CAT_STROKE} />+ <path d="M15.6 5.2c2.35.15 2.7 2.55.15 4.15" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiPlaneIcon = (p: P) => (+ <CatSvg {...p}>+ <circle cx="12" cy="12" r="8.25" {...CAT_STROKE} />+ <ellipse cx="12" cy="12" rx="3.4" ry="8.25" {...CAT_STROKE} />+ <path d="M4 12h16" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiTrophyIcon = (p: P) => (+ <CatSvg {...p}>+ <circle cx="12" cy="11.2" r="6.1" {...CAT_STROKE} />+ <path d="M9.4 14.7 8.2 19.2h7.6L14.6 14.7" {...CAT_STROKE} />+ <path d="M9.1 19.2h5.8" {...CAT_STROKE} />+ <path d="M12 7.4v3.7" {...CAT_STROKE} />+ <path d="M10.35 9.55h3.3" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiBulbIcon = (p: P) => (+ <CatSvg {...p}>+ <path d="M12 5.5 19 9.15v7.4L12 20.5 5 16.55V9.15z" {...CAT_STROKE} />+ <path d="M5 9.15 12 12.85 19 9.15" {...CAT_STROKE} />+ <path d="M12 12.85V20.5" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiShapesIcon = (p: P) => (+ <CatSvg {...p}>+ <circle cx="9.1" cy="9.2" r="3.15" {...CAT_STROKE} />+ <rect x="12.7" y="12.35" width="6.3" height="6.3" rx="1.15" {...CAT_STROKE} />+ <path d="M8.35 14.55 5.4 19.6h5.9z" {...CAT_STROKE} />+ </CatSvg>+)++export const EmojiFlagIcon = (p: P) => (+ <CatSvg {...p}>+ <path d="M7.2 4.6v14.8" {...CAT_STROKE} />+ <path d="M7.2 5.4h9.3l-1.7 3.35 1.7 3.35H7.2" {...CAT_STROKE} />+ </CatSvg>+)import { CustomFileIcon, FileStackPhoto } from './CustomFileIcon'export { CustomFileIcon, CustomFileIcon as FileKindIcon, FileStackPhoto }diff --git a/src/hooks/useFilteredItems.ts b/src/hooks/useFilteredItems.tsindex ad1d084..580860a 100644--- a/src/hooks/useFilteredItems.ts+++ b/src/hooks/useFilteredItems.ts@@ -28,14 +28,6 @@ function matches(it: ClipboardItemDto, q: string): boolean {import { isImagePath } from '../lib/format'-function isImageItem(it: ClipboardItemDto): boolean {- if (it.data.kind === 'image' || it.data.kind === 'image-collection') return true- if (it.data.kind === 'files' && it.data.paths.length > 0) {- return it.data.paths.every((p) => isImagePath(p))- }- return false-}-function matchesType(it: ClipboardItemDto, filter: TypeFilter): boolean {if (filter === 'all') return trueswitch (filter) {diff --git a/src/i18n/translations.ts b/src/i18n/translations.tsindex 81a1b6b..543098a 100644--- a/src/i18n/translations.ts+++ b/src/i18n/translations.ts@@ -150,6 +150,27 @@ export interface TranslationKeys {clearAll?: stringclearAllConfirm?: string}+ emoji?: {+ open: string+ backToClipboard: string+ recents: string+ smileys: string+ people: string+ animals: string+ food: string+ travel: string+ activities: string+ objects: string+ symbols: string+ flags: string+ categories: string+ emptyRecents: string+ skinTone: string+ loadFailed: string+ prevCategory?: string+ nextCategory?: string+ clearRecents?: string+ }fileKinds: {pdf: stringword: string@@ -589,6 +610,27 @@ export const en: TranslationKeys = {"singleFile": "1 file","scrollToTop": "Scroll to top"},+ "emoji": {+ "open": "Emoji",+ "backToClipboard": "Clipboard",+ "recents": "Recents",+ "smileys": "Smileys",+ "people": "People",+ "animals": "Animals",+ "food": "Food",+ "travel": "Travel",+ "activities": "Activity",+ "objects": "Objects",+ "symbols": "Symbols",+ "flags": "Flags",+ "categories": "Emoji categories",+ "emptyRecents": "Pasted emoji will show up here",+ "skinTone": "Skin tone",+ "loadFailed": "Could not load emoji",+ "prevCategory": "Previous category",+ "nextCategory": "Next category",+ "clearRecents": "Clear recents"+ },"fileKinds": {"pdf": "PDF","word": "Word",diff --git a/src/lib/emoji/catalog.ts b/src/lib/emoji/catalog.tsnew file mode 100644index 0000000..3ec2260--- /dev/null+++ b/src/lib/emoji/catalog.ts@@ -0,0 +1,189 @@+/**+ * Compact Unicode emoji catalog.+ *+ * Artwork in the picker is Twemoji (CC-BY 4.0, Twitter/X and contributors).+ * Paste is always the Unicode character — the receiving app draws it with+ * its own font. See https://github.com/twitter/twemoji+ */++export interface EmojiSourceSkin {+ unified: string+ image?: string+ has_img_twitter?: boolean+}++export interface EmojiSourceEntry {+ unified: string+ name?: string+ short_name?: string+ image?: string+ category: string+ sort_order?: number+ has_img_twitter?: boolean+ obsoleted_by?: string+ skin_variations?: Record<string, EmojiSourceSkin>+}++export interface EmojiSkin {+ unified: string+ file: string+}++export interface EmojiEntry {+ unified: string+ name?: string+ shortName?: string+ file: string+ category: string+ sort: number+ skins?: Record<string, EmojiSkin>+}++export interface EmojiCatalog {+ byCategory: Record<string, EmojiEntry[]>+ byUnified: Map<string, EmojiEntry>+ all: EmojiEntry[]+}++export const SKIN_TONE_KEYS = ['1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'] as const+export type SkinToneKey = (typeof SKIN_TONE_KEYS)[number]++export const SKIN_TONES: ReadonlyArray<{ id: number; key: SkinToneKey | null; color: string; label: string }> = [+ { id: 0, key: null, color: '#FFCC4D', label: 'Default' },+ { id: 1, key: '1F3FB', color: '#F7D7C4', label: 'Light' },+ { id: 2, key: '1F3FC', color: '#E0BB95', label: 'Medium-light' },+ { id: 3, key: '1F3FD', color: '#BF8F68', label: 'Medium' },+ { id: 4, key: '1F3FE', color: '#9B643D', label: 'Medium-dark' },+ { id: 5, key: '1F3FF', color: '#5A4637', label: 'Dark' }+]++export const CATEGORY_ORDER = [+ { id: 'recents', sources: [] as const, labelKey: 'emoji.recents' },+ { id: 'smileys', sources: ['Smileys & Emotion', 'People & Body'] as const, labelKey: 'emoji.smileys' },+ { id: 'animals', sources: ['Animals & Nature'] as const, labelKey: 'emoji.animals' },+ { id: 'food', sources: ['Food & Drink'] as const, labelKey: 'emoji.food' },+ { id: 'travel', sources: ['Travel & Places'] as const, labelKey: 'emoji.travel' },+ { id: 'activities', sources: ['Activities'] as const, labelKey: 'emoji.activities' },+ { id: 'objects', sources: ['Objects'] as const, labelKey: 'emoji.objects' },+ { id: 'symbols', sources: ['Symbols', 'Flags'] as const, labelKey: 'emoji.symbols' }+] as const++export type EmojiCategoryId = (typeof CATEGORY_ORDER)[number]['id']++const SKIP_CATEGORIES = new Set(['Component'])++export { isPasteableEmoji } from '../../../shared/emoji'++export function unifiedToNative(unified: string): string {+ return unified+ .split('-')+ .filter(Boolean)+ .map((h) => String.fromCodePoint(parseInt(h, 16)))+ .join('')+}++export function emojiGlyphUrl(file: string): string {+ return `edgelocal://emoji/${file.toLowerCase()}`+}++function fileOf(image: string | undefined, unified: string): string {+ if (image && image.toLowerCase().endsWith('.png')) return image.toLowerCase()+ return `${unified.toLowerCase()}.png`+}++function cleanEmojiName(rawName?: string, rawShort?: string): string | undefined {+ if (!rawName) return rawShort ? `:${rawShort}:` : undefined+ let name = rawName.split(':')[0].trim()+ name = name.replace(/^flag for\s+/i, '').replace(/^flag:\s+/i, '')+ return name.toLowerCase().replace(/(^|\s)\S/g, (t) => t.toUpperCase())+}++export function buildCatalog(raw: readonly EmojiSourceEntry[]): EmojiCatalog {+ const all: EmojiEntry[] = []+ const byCategory: Record<string, EmojiEntry[]> = {}+ const byUnified = new Map<string, EmojiEntry>()++ for (const src of raw) {+ if (!src || src.has_img_twitter === false) continue+ if (SKIP_CATEGORIES.has(src.category)) continue+ if (src.obsoleted_by) continue+ if (!src.unified || !src.category) continue++ const skins: Record<string, EmojiSkin> = {}+ if (src.skin_variations) {+ for (const key of SKIN_TONE_KEYS) {+ const v = src.skin_variations[key]+ if (!v || v.has_img_twitter === false || !v.unified) continue+ skins[key] = { unified: v.unified, file: fileOf(v.image, v.unified) }+ }+ }++ const entry: EmojiEntry = {+ unified: src.unified,+ name: cleanEmojiName(src.name, src.short_name),+ shortName: src.short_name ? `:${src.short_name}:` : undefined,+ file: fileOf(src.image, src.unified),+ category: src.category,+ sort: typeof src.sort_order === 'number' ? src.sort_order : 9999,+ skins: Object.keys(skins).length > 0 ? skins : undefined+ }+ all.push(entry)+ byUnified.set(entry.unified, entry)+ if (entry.skins) {+ for (const skin of Object.values(entry.skins)) {+ byUnified.set(skin.unified, entry)+ }+ }+ const bucket = byCategory[entry.category] ?? (byCategory[entry.category] = [])+ bucket.push(entry)+ }++ for (const list of Object.values(byCategory)) {+ list.sort((a, b) => a.sort - b.sort || a.unified.localeCompare(b.unified))+ }+ all.sort((a, b) => a.sort - b.sort || a.unified.localeCompare(b.unified))++ return { byCategory, byUnified, all }+}++export function applySkin(entry: EmojiEntry, toneKey: SkinToneKey | null): { unified: string; file: string } {+ if (!toneKey || !entry.skins?.[toneKey]) {+ return { unified: entry.unified, file: entry.file }+ }+ return entry.skins[toneKey]+}++export function hasSkinTones(entry: EmojiEntry): boolean {+ return !!entry.skins && Object.keys(entry.skins).length > 0+}++/** Default glyph plus every available Fitzpatrick variant for the popup. */+export function skinChoices(entry: EmojiEntry): Array<{ unified: string; file: string; key: SkinToneKey | null }> {+ const base = { unified: entry.unified, file: entry.file, key: null as SkinToneKey | null }+ if (!entry.skins) return [base]+ const variants = SKIN_TONE_KEYS.flatMap((key) => {+ const skin = entry.skins?.[key]+ return skin ? [{ unified: skin.unified, file: skin.file, key }] : []+ })+ return [base, ...variants]+}++/** Resolve a base or skin-tone unified code to its parent entry and PNG. */+export function resolveGlyph(+ catalog: EmojiCatalog,+ unified: string+): { entry: EmojiEntry; unified: string; file: string } | null {+ const entry = catalog.byUnified.get(unified)+ if (!entry) return null+ if (entry.unified === unified) return { entry, unified, file: entry.file }+ const skin = entry.skins ? Object.values(entry.skins).find((s) => s.unified === unified) : undefined+ if (skin) return { entry, unified: skin.unified, file: skin.file }+ return { entry, unified: entry.unified, file: entry.file }+}++export const MAX_RECENTS = 7 * 11 // 77 items (exactly 11 full rows in the 7-column grid)++export function pushRecent(recents: readonly string[], unified: string): string[] {+ const next = [unified, ...recents.filter((u) => u !== unified)]+ return next.slice(0, MAX_RECENTS)+}diff --git a/src/lib/emoji/emoji-datasource-twitter.d.ts b/src/lib/emoji/emoji-datasource-twitter.d.tsnew file mode 100644index 0000000..9a9af38--- /dev/null+++ b/src/lib/emoji/emoji-datasource-twitter.d.ts@@ -0,0 +1,4 @@+declare module 'emoji-datasource-twitter/emoji.json' {+ const data: import('./catalog').EmojiSourceEntry[]+ export default data+}diff --git a/src/lib/emoji/load.ts b/src/lib/emoji/load.tsnew file mode 100644index 0000000..6bcfcdb--- /dev/null+++ b/src/lib/emoji/load.ts@@ -0,0 +1,13 @@+import { buildCatalog, type EmojiCatalog, type EmojiSourceEntry } from './catalog'++let pending: Promise<EmojiCatalog> | null = null++export function loadEmojiCatalog(): Promise<EmojiCatalog> {+ if (!pending) {+ pending = import('emoji-datasource-twitter/emoji.json').then((mod) => {+ const raw = (mod as { default?: EmojiSourceEntry[] }).default ?? (mod as unknown as EmojiSourceEntry[])+ return buildCatalog(Array.isArray(raw) ? raw : [])+ })+ }+ return pending+}diff --git a/src/lib/emoji/prefs.ts b/src/lib/emoji/prefs.tsnew file mode 100644index 0000000..cbebb0e--- /dev/null+++ b/src/lib/emoji/prefs.ts@@ -0,0 +1,47 @@+/** Local, renderer-only emoji picker preferences. Not part of Settings IPC. */++const RECENTS_KEY = 'edge-drop.emoji.recents'+const TONE_KEY = 'edge-drop.emoji.skinTone'++function storage(): Storage | null {+ try {+ const g = globalThis as { localStorage?: Storage }+ return g.localStorage ?? null+ } catch {+ return null+ }+}++export function loadRecents(): string[] {+ const raw = storage()?.getItem(RECENTS_KEY)+ if (!raw) return []+ try {+ const parsed = JSON.parse(raw) as unknown+ if (!Array.isArray(parsed)) return []+ return parsed.filter((v): v is string => typeof v === 'string' && v.length > 0 && v.length < 80)+ } catch {+ return []+ }+}++export function saveRecents(unifieds: readonly string[]): void {+ try {+ storage()?.setItem(RECENTS_KEY, JSON.stringify(unifieds))+ } catch {+ /* quota / private mode */+ }+}++export function loadSkinToneId(): number {+ const raw = storage()?.getItem(TONE_KEY)+ const n = raw == null ? 0 : Number(raw)+ return Number.isInteger(n) && n >= 0 && n <= 5 ? n : 0+}++export function saveSkinToneId(id: number): void {+ try {+ storage()?.setItem(TONE_KEY, String(id))+ } catch {+ /* ignore */+ }+}diff --git a/src/lib/urlPreview.ts b/src/lib/urlPreview.tsindex f545cc7..e3c7393 100644--- a/src/lib/urlPreview.ts+++ b/src/lib/urlPreview.ts@@ -40,6 +40,15 @@ const BRAND_PRESETS: Record<string, { serviceName: string; brandColor: string }>'drive.google.com': { serviceName: 'Google Drive', brandColor: '#0f9d58' },}+/** decodeURIComponent throws URIError on truncated %XX — never throw from render. */+export function safeDecodeURIComponent(value: string): string {+ try {+ return decodeURIComponent(value)+ } catch {+ return value+ }+}+export function parseUrlPreview(rawUrl: string): UrlPreviewInfo {let urlObj: URL | null = nulltry {@@ -96,7 +105,7 @@ export function parseUrlPreview(rawUrl: string): UrlPreviewInfo {}} else if (hostname.includes('wikipedia.org')) {if (pathSegments.length >= 2 && pathSegments[0] === 'wiki') {- title = decodeURIComponent(pathSegments[1]).replace(/_/g, ' ')+ title = safeDecodeURIComponent(pathSegments[1]).replace(/_/g, ' ')}} else if (hostname.includes('reddit.com')) {if (pathSegments.length >= 2 && pathSegments[0] === 'r') {@@ -111,10 +120,10 @@ export function parseUrlPreview(rawUrl: string): UrlPreviewInfo {}} else if (pathSegments.length > 0) {const lastSeg = pathSegments[pathSegments.length - 1]- const cleanSeg = decodeURIComponent(lastSeg)+ const cleanSeg = safeDecodeURIComponent(lastSeg).replace(/[-_]/g, ' ').replace(/\.(html?|php|aspx?)$/i, '')- if (cleanSeg.length > 3 && !/^[0-9a-f]{8,}$/i.test(cleanSeg)) {+ if (cleanSeg.length > 3 && !/^[0-9a-f]{8,}$/i.test(cleanSeg) && !/%[0-9A-Fa-f]{0,1}$/.test(lastSeg)) {title = cleanSeg.charAt(0).toUpperCase() + cleanSeg.slice(1)}}diff --git a/src/main.tsx b/src/main.tsxindex 37e43bb..3b4e048 100644--- a/src/main.tsx+++ b/src/main.tsx@@ -9,6 +9,7 @@ import './styles/global.css'import './styles/panel.css'import './styles/item.css'import './styles/settings.css'+import './styles/emoji.css'const container = document.getElementById('root')if (!container) throw new Error('#root element not found')diff --git a/src/store/appStore.ts b/src/store/appStore.tsindex 6050f07..3c1f1b1 100644--- a/src/store/appStore.ts+++ b/src/store/appStore.ts@@ -33,6 +33,11 @@ interface AppState {open: boolean/** Settings sheet visibility. */settingsOpen: boolean+ /** Emoji library view (replaces the clipboard list). */+ emojiOpen: boolean+ setEmojiOpen: (open: boolean) => void+ emojiCategory: import('../lib/emoji/catalog').EmojiCategoryId+ setEmojiCategory: (cat: import('../lib/emoji/catalog').EmojiCategoryId) => void/** Active view mode within settings ('main' | 'changelog'). */settingsSubView: 'main' | 'changelog'setSettingsSubView: (subView: 'main' | 'changelog') => void@@ -110,6 +115,7 @@ interface AppState {copySubitem: (req: DragRequest) => Promise<void>paste: (id: string) => Promise<void>pasteSubitem: (req: DragRequest) => Promise<void>+ pasteEmoji: (text: string) => Promise<void>patchSettings: (patch: Partial<Settings>) => Promise<void>refreshLaunchAtLogin: () => Promise<void>setTutorialStep: (step: number) => void@@ -132,6 +138,26 @@ export const useStore = create<AppState>((set, get) => ({},open: false,settingsOpen: false,+ emojiOpen: false,+ emojiCategory: 'smileys',+ setEmojiCategory: (emojiCategory) => set({ emojiCategory }),+ setEmojiOpen: (emojiOpen) => {+ if (emojiOpen) {+ set({+ emojiOpen: true,+ settingsOpen: false,+ settingsSubView: 'main',+ previewItemId: null,+ previewItemRect: null,+ previewFlyoutRect: null,+ styleFlyoutOpen: false,+ expandedStackId: null+ })+ edge.setPreviewMode(false)+ } else {+ set({ emojiOpen: false })+ }+ },settingsSubView: 'main',setSettingsSubView: (subView) => set({ settingsSubView: subView }),dragActive: false,@@ -315,7 +341,8 @@ export const useStore = create<AppState>((set, get) => ({previewItemRect: null,previewFlyoutRect: null,styleFlyoutOpen: false,- expandedStackId: null+ expandedStackId: null,+ emojiOpen: settingsOpen ? false : get().emojiOpen})},setDragActive: (dragActive) => set({ dragActive }),@@ -454,6 +481,15 @@ export const useStore = create<AppState>((set, get) => ({await edge.pasteSubitem(req)},+ async pasteEmoji(text) {+ set({ isInternalCopying: true })+ try {+ await edge.pasteEmoji(text)+ } finally {+ setTimeout(() => set({ isInternalCopying: false }), 400)+ }+ },+async patchSettings(patch) {const next = await edge.updateSettings(patch)set({ settings: next })diff --git a/src/styles/emoji.css b/src/styles/emoji.cssnew file mode 100644index 0000000..4ca63d7--- /dev/null+++ b/src/styles/emoji.css@@ -0,0 +1,251 @@+/* Emoji picker — matches the blade: deep black, pills, compositor-only motion. */++.emoji-picker {+ flex: 1;+ min-height: 0;+ display: flex;+ flex-direction: column;+ position: relative;+ z-index: 1;+}++/* Sleek 8-Category Pill Bar (Zero Horizontal Scroll, Zero Arrows, Fits Perfectly) */+.emoji-cat-bar {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 1px;+ background: rgba(255, 255, 255, 0.05);+ border: 1px solid rgba(255, 255, 255, 0.10);+ border-radius: 999px;+ padding: 3px 4px;+ margin: 2px var(--pad) 8px;+ height: 36px;+ box-sizing: border-box;+ flex-shrink: 0;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);+}++.emoji-cat-btn {+ flex: 1;+ height: 28px;+ min-width: 0;+ display: grid;+ place-items: center;+ border-radius: 999px;+ background: transparent;+ border: 1px solid transparent;+ cursor: pointer;+ color: rgba(255, 255, 255, 0.60);+ padding: 0;+ transition: all 0.16s cubic-bezier(0.22, 1, 0.36, 1);+}+.emoji-cat-btn:hover {+ background: rgba(255, 255, 255, 0.10);+ color: #ffffff;+ transform: scale(1.08);+}+.emoji-cat-btn.active {+ background: rgba(255, 255, 255, 0.18);+ border-color: rgba(255, 255, 255, 0.28);+ color: #ffffff;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);+}+.emoji-cat-btn:active {+ transform: scale(0.94);+}++.emoji-grid {+ flex: 1;+ min-height: 0;+ overflow-y: auto;+ overflow-x: hidden;+ padding: 4px var(--pad) 8px;+ scrollbar-width: none;+ overscroll-behavior-y: contain;+ -webkit-mask-image: linear-gradient(to bottom, transparent 0px, #000 8px, #000 calc(100% - 8px), transparent 100%);+ mask-image: linear-gradient(to bottom, transparent 0px, #000 8px, #000 calc(100% - 8px), transparent 100%);+}+.emoji-grid::-webkit-scrollbar {+ display: none;+}++.emoji-row {+ display: grid;+ grid-template-columns: repeat(7, 1fr);+ gap: 2px;+ height: 36px;+}++.emoji-cell {+ width: 100%;+ height: 36px;+ display: grid;+ place-items: center;+ border: none;+ background: transparent;+ border-radius: 10px;+ cursor: pointer;+ padding: 0;+ color: inherit;+ position: relative;+ transform: translateZ(0);+ transition: transform 0.14s cubic-bezier(0.22, 1, 0.36, 1),+ background 0.14s cubic-bezier(0.22, 1, 0.36, 1);+ -webkit-user-drag: none;+ user-select: none;+}+.emoji-cell:hover {+ background: rgba(255, 255, 255, 0.14);+ transform: scale(1.16);+ z-index: 2;+}+.emoji-cell:active {+ transform: scale(0.92);+ background: rgba(255, 255, 255, 0.22);+}++.emoji-glyph {+ width: 26px;+ height: 26px;+ display: block;+ pointer-events: none;+ -webkit-user-drag: none;+ user-select: none;+ object-fit: contain;+ transition: filter 0.14s ease;+}+.emoji-cell:hover .emoji-glyph {+ filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));+}++/* Fast Category Glass Tooltip */+.emoji-cat-tooltip {+ position: absolute;+ top: 48px;+ z-index: 10;+ padding: 4px 10px;+ border-radius: 999px;+ background: rgba(18, 18, 24, 0.94);+ backdrop-filter: blur(16px);+ -webkit-backdrop-filter: blur(16px);+ border: 1px solid rgba(255, 255, 255, 0.18);+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);+ transform: translateX(-50%);+ pointer-events: none;+ white-space: nowrap;+ font-size: 11.5px;+ font-weight: 500;+ color: rgba(255, 255, 255, 0.92);+ letter-spacing: 0.01em;+ animation: emojiCatTooltipFade 0.12s cubic-bezier(0.22, 1, 0.36, 1);+}++@keyframes emojiCatTooltipFade {+ from {+ opacity: 0;+ transform: translate(-50%, -4px) scale(0.96);+ }+ to {+ opacity: 1;+ transform: translate(-50%, 0) scale(1);+ }+}++/* Recents Clear Button */+.emoji-recents-footer {+ display: flex;+ justify-content: center;+ align-items: center;+ padding: 4px var(--pad) 8px;+ flex-shrink: 0;+}++.emoji-recents-clear-btn {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ padding: 4px 12px;+ border-radius: 999px;+ background: rgba(255, 255, 255, 0.06);+ border: 1px solid rgba(255, 255, 255, 0.12);+ color: rgba(255, 255, 255, 0.65);+ font-size: 11.5px;+ font-weight: 500;+ cursor: pointer;+ transition: all 0.15s cubic-bezier(0.22, 1, 0.36, 1);+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);+}+.emoji-recents-clear-btn:hover {+ background: rgba(239, 68, 68, 0.16);+ border-color: rgba(239, 68, 68, 0.35);+ color: #ff6b6b;+ transform: scale(1.04);+}+.emoji-recents-clear-btn:active {+ transform: scale(0.96);+}++.emoji-tone-pop {+ position: absolute;+ z-index: 8;+ display: flex;+ align-items: center;+ gap: 2px;+ padding: 4px;+ border-radius: 14px;+ background: #141418;+ border: 1px solid rgba(255, 255, 255, 0.16);+ box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);+ transform: translate(-50%, calc(-100% - 8px));+ pointer-events: auto;+}+.emoji-tone-pop-below {+ transform: translate(-50%, 8px);+}+.emoji-tone-choice {+ width: 32px;+ height: 32px;+ display: grid;+ place-items: center;+ border: none;+ background: transparent;+ border-radius: 10px;+ cursor: pointer;+ padding: 0;+ transition: background var(--dur-fast) var(--ease-out),+ transform var(--dur-fast) var(--ease-out);+}+.emoji-tone-choice:hover {+ background: rgba(255, 255, 255, 0.12);+ transform: scale(1.1);+}+.emoji-tone-choice:active {+ transform: scale(0.94);+}++.emoji-empty,+.emoji-status {+ flex: 1;+ display: flex;+ align-items: center;+ justify-content: center;+ padding: 16px;+ text-align: center;+ color: var(--text-tertiary);+ font-size: calc(12.5px * var(--font-scale, 1));+}++.emoji-skel {+ display: grid;+ grid-template-columns: repeat(7, 1fr);+ gap: 6px;+ padding: 12px var(--pad);+}+.emoji-skel i {+ display: block;+ aspect-ratio: 1;+ border-radius: 10px;+ background: rgba(255, 255, 255, 0.06);+}+diff --git a/src/styles/panel.css b/src/styles/panel.cssindex 4211690..32686d7 100644--- a/src/styles/panel.css+++ b/src/styles/panel.css@@ -335,15 +335,15 @@display: flex;align-items: center;justify-content: space-between;- gap: 12px;- padding: 12px var(--pad) 14px;+ gap: 8px;+ padding: 8px var(--pad) 12px;position: relative;z-index: 1;background: transparent;-webkit-font-smoothing: antialiased;}.footer .count {- font-size: calc(12.5px * var(--font-scale, 1));+ font-size: calc(12px * var(--font-scale, 1));font-weight: 500;color: #e4e4e7;letter-spacing: 0.01em;@@ -355,24 +355,114 @@.footer .spacer {flex: 1;}++/* Glass capsule: item count + emoji button */+.footer-capsule {+ display: inline-flex;+ align-items: center;+ height: 28px;+ background: rgba(255, 255, 255, 0.06);+ border: 1px solid rgba(255, 255, 255, 0.12);+ border-radius: 999px;+ padding: 0 3px 0 9px;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);+ transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);+}+.footer-capsule:hover {+ background: rgba(255, 255, 255, 0.09);+ border-color: rgba(255, 255, 255, 0.18);+}+.footer-capsule-count {+ font-size: calc(11.5px * var(--font-scale, 1));+ font-weight: 600;+ color: rgba(255, 255, 255, 0.75);+ font-variant-numeric: tabular-nums;+ letter-spacing: 0.02em;+ padding-right: 7px;+ user-select: none;+}+.footer-capsule-divider {+ width: 1px;+ height: 14px;+ background: rgba(255, 255, 255, 0.12);+ margin-right: 3px;+}+.footer-capsule-btn {+ width: 22px;+ height: 22px;+ border-radius: 999px;+ display: grid;+ place-items: center;+ background: transparent;+ border: none;+ color: rgba(255, 255, 255, 0.75);+ cursor: pointer;+ padding: 0;+ transition: all 0.15s ease;+}+.footer-capsule-btn:hover {+ background: rgba(255, 255, 255, 0.16);+ color: #ffffff;+ transform: scale(1.08);+}+.footer-capsule-btn:active {+ transform: scale(0.94);+}++/* Return to clipboard pill */+.footer-back-pill {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ height: 28px;+ background: rgba(255, 255, 255, 0.08);+ border: 1px solid rgba(255, 255, 255, 0.14);+ border-radius: 999px;+ padding: 0 12px 0 8px;+ color: #f4f4f5;+ font-size: calc(11.5px * var(--font-scale, 1));+ font-weight: 600;+ cursor: pointer;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);+ transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);+}+.footer-back-pill:hover {+ background: rgba(255, 255, 255, 0.16);+ border-color: rgba(255, 255, 255, 0.24);+ color: #ffffff;+ transform: translateY(-1px);+}+.footer-back-pill:active {+ transform: scale(0.96);+}++/* Clear button */.footer .text-btn {- font-size: calc(12.5px * var(--font-scale, 1));+ height: 28px;+ display: inline-flex;+ align-items: center;+ gap: 6px;+ font-size: calc(11.5px * var(--font-scale, 1));font-weight: 500;- color: #f4f4f5;- background: rgba(255, 255, 255, 0.08);- border: 1px solid rgba(255, 255, 255, 0.15);- padding: 5px 12px;- border-radius: var(--radius-pill);+ color: rgba(255, 255, 255, 0.85);+ background: rgba(255, 255, 255, 0.06);+ border: 1px solid rgba(255, 255, 255, 0.12);+ padding: 0 11px;+ border-radius: 999px;cursor: pointer;white-space: nowrap;flex-shrink: 0;- transition: all var(--dur-fast) var(--ease-out);+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);+ transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);}.footer .text-btn:hover:not(:disabled) {- background: rgba(255, 255, 255, 0.15);- border-color: rgba(255, 255, 255, 0.25);+ background: rgba(255, 255, 255, 0.12);+ border-color: rgba(255, 255, 255, 0.20);color: #ffffff;- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);+ transform: translateY(-1px);+}+.footer .text-btn:active:not(:disabled) {+ transform: scale(0.96);}.footer .text-btn:disabled {opacity: 0.35;@@ -381,9 +471,9 @@background: rgba(255, 255, 255, 0.03);}.footer .text-btn.danger:hover:not(:disabled) {- color: #ff8080;- border-color: rgba(255, 128, 128, 0.3);- background: rgba(255, 80, 80, 0.15);+ color: #ff9494;+ border-color: rgba(255, 100, 100, 0.35);+ background: rgba(255, 70, 70, 0.14);}/* ----------------------------------------------------------------- */diff --git a/tests/emojiCatalog.test.ts b/tests/emojiCatalog.test.tsnew file mode 100644index 0000000..8653bbc--- /dev/null+++ b/tests/emojiCatalog.test.ts@@ -0,0 +1,138 @@+import { describe, expect, it } from 'vitest'+import {+ applySkin,+ buildCatalog,+ hasSkinTones,+ isPasteableEmoji,+ pushRecent,+ resolveGlyph,+ skinChoices,+ unifiedToNative,+ type EmojiSourceEntry+} from '../src/lib/emoji/catalog'+import { resolveEmojiAsset, emojiAssetDir } from '../electron/main/imageProtocol'+import { mkdirSync, rmSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'++const sample: EmojiSourceEntry[] = [+ {+ unified: '1F600',+ image: '1f600.png',+ category: 'Smileys & Emotion',+ sort_order: 1,+ has_img_twitter: true+ },+ {+ unified: '1F44B',+ image: '1f44b.png',+ category: 'People & Body',+ sort_order: 2,+ has_img_twitter: true,+ skin_variations: {+ '1F3FB': { unified: '1F44B-1F3FB', image: '1f44b-1f3fb.png', has_img_twitter: true },+ '1F3FC': { unified: '1F44B-1F3FC', image: '1f44b-1f3fc.png', has_img_twitter: true }+ }+ },+ {+ unified: '1F3FB',+ image: '1f3fb.png',+ category: 'Component',+ sort_order: 3,+ has_img_twitter: true+ },+ {+ unified: '263A-FE0F',+ image: '263a-fe0f.png',+ category: 'Smileys & Emotion',+ sort_order: 4,+ has_img_twitter: true,+ obsoleted_by: '1F642'+ }+]++describe('emoji catalog', () => {+ it('groups twitter glyphs and skips components and obsolete entries', () => {+ const cat = buildCatalog(sample)+ expect(cat.all.map((e) => e.unified)).toEqual(['1F600', '1F44B'])+ expect(cat.byCategory['Smileys & Emotion']).toHaveLength(1)+ expect(cat.byCategory['Component']).toBeUndefined()+ })++ it('converts unified sequences to native characters', () => {+ expect(unifiedToNative('1F600')).toBe('😀')+ expect(unifiedToNative('1F44B-1F3FB')).toBe('👋🏻')+ })++ it('applies skin tone only when a variant exists', () => {+ const cat = buildCatalog(sample)+ const wave = cat.byUnified.get('1F44B')!+ const grin = cat.byUnified.get('1F600')!+ expect(applySkin(wave, '1F3FB')).toEqual({ unified: '1F44B-1F3FB', file: '1f44b-1f3fb.png' })+ expect(applySkin(grin, '1F3FB')).toEqual({ unified: '1F600', file: '1f600.png' })+ expect(applySkin(wave, null)).toEqual({ unified: '1F44B', file: '1f44b.png' })+ })++ it('resolves a skin-tone unified back to its parent and file', () => {+ const cat = buildCatalog(sample)+ const g = resolveGlyph(cat, '1F44B-1F3FB')+ expect(g?.entry.unified).toBe('1F44B')+ expect(g?.file).toBe('1f44b-1f3fb.png')+ expect(g?.unified).toBe('1F44B-1F3FB')+ expect(resolveGlyph(cat, '1F600')?.file).toBe('1f600.png')+ })++ it('lists default plus available skin choices for the popup', () => {+ const cat = buildCatalog(sample)+ const wave = cat.byUnified.get('1F44B')!+ const grin = cat.byUnified.get('1F600')!+ expect(hasSkinTones(wave)).toBe(true)+ expect(hasSkinTones(grin)).toBe(false)+ expect(skinChoices(grin)).toHaveLength(1)+ expect(skinChoices(wave).map((c) => c.unified)).toEqual(['1F44B', '1F44B-1F3FB', '1F44B-1F3FC'])+ })++ it('caps recents and moves the latest to front', () => {+ const first = pushRecent([], '1F600')+ const second = pushRecent(first, '1F44B')+ const again = pushRecent(second, '1F600')+ expect(again).toEqual(['1F600', '1F44B'])+ })++ it('rejects non-emoji paste payloads', () => {+ expect(isPasteableEmoji('😀')).toBe(true)+ expect(isPasteableEmoji('👋🏻')).toBe(true)+ expect(isPasteableEmoji('')).toBe(false)+ expect(isPasteableEmoji('hello\nworld')).toBe(false)+ expect(isPasteableEmoji('x'.repeat(65))).toBe(false)+ })+})++describe('emoji asset protocol', () => {+ it('only serves hex-named pngs inside the asset directory', () => {+ const dir = join(tmpdir(), `ed-emoji-${Date.now()}`)+ mkdirSync(dir, { recursive: true })+ try {+ writeFileSync(join(dir, '1f600.png'), 'png')+ writeFileSync(join(dir, 'secret.txt'), 'no')+ expect(resolveEmojiAsset(dir, '1f600.png')?.endsWith('1f600.png')).toBe(true)+ expect(resolveEmojiAsset(dir, '1F600.PNG')).toBeTruthy()+ expect(resolveEmojiAsset(dir, '../secret.txt')).toBeNull()+ expect(resolveEmojiAsset(dir, 'secret.txt')).toBeNull()+ expect(resolveEmojiAsset(dir, '1f600.png.exe')).toBeNull()+ expect(resolveEmojiAsset(dir, '')).toBeNull()+ } finally {+ rmSync(dir, { recursive: true, force: true })+ }+ })++ it('points packaged builds at extraResources', () => {+ const dir = emojiAssetDir({+ packaged: true,+ resourcesPath: 'C:\\res',+ appPath: 'C:\\app',+ cwd: 'C:\\cwd'+ })+ expect(dir.replace(/\\/g, '/')).toBe('C:/res/emoji/64')+ })+})diff --git a/tests/itemCopyPromote.test.ts b/tests/itemCopyPromote.test.tsindex b3c4d35..e4ad8c0 100644--- a/tests/itemCopyPromote.test.ts+++ b/tests/itemCopyPromote.test.ts@@ -46,30 +46,23 @@ describe('copy-promotion correctness (self-duplication regression)', () => {try { rmSync(fsRoots.home, { recursive: true, force: true }) } catch { /* ignore */ }})- it('LONG TEXT HAZARD: re-adding the full payload creates a DUPLICATE (why touch() is mandatory)', () => {- // Documents the exact defect: item:copy used to promote via add(fullText).- // The trap springs AFTER an index rebuild (restart/merge/split): stored- // items carry 300-char preview signatures, so the full payload re-add- // misses and creates a SECOND entry.+ it('after restart, re-adding the full payload matches the stored preview (no duplicate)', () => {const store = makeStore()store.add({ kind: 'text', text: LONG_TEXT, isUrl: false }, 10)const id = store.list()[0].id- store.persistSync() // flush the debounced write before "restarting"+ store.persistSync()- // Force the rebuild path a restart takes: fresh instance -> load.const reopened = makeStore()reopened.load()expect(reopened.list()).toHaveLength(1)- expect(reopened.list()[0].data.text.length).toBe(300) // preview stored+ expect(reopened.list()[0].data.text.length).toBe(300)const fullPayload = reopened.getFullText(id)expect(fullPayload).toBe(LONG_TEXT)reopened.add({ kind: 'text', text: fullPayload, isUrl: false }, 10)-- // This assertion PINS the hazard: if anyone reintroduces add()-promotion,- // this expectation fails and explains why.- expect(reopened.list()).toHaveLength(2)+ expect(reopened.list()).toHaveLength(1)+ expect(reopened.list()[0].hitCount).toBe(2)})it('SAFE PATH: touch() promotes without changing count, content, or signature', () => {diff --git a/tests/signatureMatch.test.ts b/tests/signatureMatch.test.tsindex 6a1c8e8..679a470 100644--- a/tests/signatureMatch.test.ts+++ b/tests/signatureMatch.test.ts@@ -33,6 +33,21 @@ describe('signatureMatchesItem — ownership matching with seq prefixes', () =>expect(signatureMatchesItem('seq:9:text:https://example.com/a', data)).toBe(true)})+ it('matches a long text whose store preview is a prefix of the live clipboard', () => {+ const full = 'https://www.amazon.co.jp/' + 'A'.repeat(400)+ const preview = full.slice(0, 300)+ const data: ItemData = {+ kind: 'text',+ text: preview,+ isUrl: true,+ hasFullPayload: true,+ previewText: preview+ }+ expect(signatureMatchesItem(`seq:12:text:${full}`, data, full)).toBe(true)+ expect(signatureMatchesItem(`seq:12:text:${full}`, data)).toBe(true)+ expect(signatureMatchesItem('seq:12:text:https://other.example/', data)).toBe(false)+ })+it('matches FILES by exact path list, ignoring the sequence number', () => {const data: ItemData = { kind: 'files', paths: ['C:\\a.pdf', 'C:\\b.txt'] }expect(signatureMatchesItem('seq:7:files:C:\\a.pdf\nC:\\b.txt', data)).toBe(true)diff --git a/tests/urlPreview.test.ts b/tests/urlPreview.test.tsnew file mode 100644index 0000000..a1cea81--- /dev/null+++ b/tests/urlPreview.test.ts@@ -0,0 +1,38 @@+import { describe, expect, it } from 'vitest'+import { parseUrlPreview, safeDecodeURIComponent } from '../src/lib/urlPreview'++describe('safeDecodeURIComponent', () => {+ it('decodes a complete sequence', () => {+ expect(safeDecodeURIComponent('%E3%82%AF')).toBe('ク')+ })++ it('returns the raw string instead of throwing on a truncated %XX', () => {+ expect(() => safeDecodeURIComponent('%E3%82')).not.toThrow()+ expect(safeDecodeURIComponent('%E3%82')).toBe('%E3%82')+ expect(safeDecodeURIComponent('foo%')).toBe('foo%')+ })+})++describe('parseUrlPreview never throws on truncated long URLs', () => {+ it('survives a cut in the middle of a percent-encoded Japanese path', () => {+ const truncated =+ 'https://www.amazon.co.jp/%E3%82%AF%E3%83%AF%E3%83%88%E3%82%B8%E3%83%A3%E3%83%91%E3%83%B3/' ++ 'dp/B0EXAMPLE/%E3%82%B8%'+ expect(() => parseUrlPreview(truncated)).not.toThrow()+ const info = parseUrlPreview(truncated)+ expect(info.domain).toContain('amazon.co.jp')+ expect(info.serviceName.length).toBeGreaterThan(0)+ })++ it('survives an incomplete UTF-8 percent triplet in the last segment', () => {+ const truncated = 'https://www.amazon.co.jp/foo/%E3%82'+ expect(() => parseUrlPreview(truncated)).not.toThrow()+ const info = parseUrlPreview(truncated)+ expect(info.domain).toBe('amazon.co.jp')+ })++ it('still titles a well-formed last segment', () => {+ const info = parseUrlPreview('https://example.com/hello-world')+ expect(info.title).toBe('Hello world')+ })+})