feat: add isBinaryData utility function and integrate it into paste handling; add drag and drop functionality when creating a paste

This commit is contained in:
2026-01-19 03:37:28 -05:00
parent 1ed21789e6
commit bf0eac9ed8
3 changed files with 192 additions and 80 deletions
+13
View File
@@ -24,6 +24,19 @@ export function extractDateFromUUIDv7(uuid?: string): Date | null {
return new Date(parseInt(timestampHex, 16));
}
export function isBinaryData(buffer: ArrayBuffer | Uint8Array): boolean {
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
if (bytes.includes(0)) return true;
try {
new TextDecoder('utf-8', { fatal: true }).decode(bytes);
return false;
} catch {
return true;
}
}
export function extractError(resData: unknown): string | null {
if (!resData || typeof resData !== 'object') return null;