mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: replace navigator.clipboard with copyToClipboard utility
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { apiDelete, apiGet, apiPost, apiPut, clearToken } from "@/lib/api";
|
import { apiDelete, apiGet, apiPost, apiPut, clearToken } from "@/lib/api";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn, copyToClipboard } from "@/lib/utils";
|
||||||
import { GemLogo } from "../common/gem-logo";
|
import { GemLogo } from "../common/gem-logo";
|
||||||
|
|
||||||
interface SettingsDialogProps {
|
interface SettingsDialogProps {
|
||||||
@@ -1144,11 +1144,12 @@ function ApiKeysSection() {
|
|||||||
}
|
}
|
||||||
}, [keyName, loadKeys]);
|
}, [keyName, loadKeys]);
|
||||||
|
|
||||||
const copyKey = useCallback((key: string) => {
|
const copyKey = useCallback(async (key: string) => {
|
||||||
navigator.clipboard.writeText(key).then(() => {
|
const ok = await copyToClipboard(key);
|
||||||
|
if (ok) {
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
setTimeout(() => setCopied(false), 2000);
|
setTimeout(() => setCopied(false), 2000);
|
||||||
});
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const deleteKey = useCallback(
|
const deleteKey = useCallback(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Check, Copy, Loader2 } from "lucide-react";
|
import { Check, Copy, Loader2 } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { copyToClipboard } from "@/lib/utils";
|
||||||
import { useFileStore } from "@/stores/file-store";
|
import { useFileStore } from "@/stores/file-store";
|
||||||
|
|
||||||
function getToken(): string {
|
function getToken(): string {
|
||||||
@@ -44,12 +45,10 @@ export function BarcodeReadSettings() {
|
|||||||
|
|
||||||
const copyText = async () => {
|
const copyText = async () => {
|
||||||
if (!result?.text) return;
|
if (!result?.text) return;
|
||||||
try {
|
const ok = await copyToClipboard(result.text);
|
||||||
await navigator.clipboard.writeText(result.text);
|
if (ok) {
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
setTimeout(() => setCopied(false), 1500);
|
setTimeout(() => setCopied(false), 1500);
|
||||||
} catch {
|
|
||||||
// Fallback: silent fail
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Check, Copy, Loader2 } from "lucide-react";
|
import { Check, Copy, Loader2 } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { copyToClipboard } from "@/lib/utils";
|
||||||
import { useFileStore } from "@/stores/file-store";
|
import { useFileStore } from "@/stores/file-store";
|
||||||
|
|
||||||
function getToken(): string {
|
function getToken(): string {
|
||||||
@@ -43,12 +44,10 @@ export function ColorPaletteSettings() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const copyColor = async (color: string, idx: number) => {
|
const copyColor = async (color: string, idx: number) => {
|
||||||
try {
|
const ok = await copyToClipboard(color);
|
||||||
await navigator.clipboard.writeText(color);
|
if (ok) {
|
||||||
setCopiedIdx(idx);
|
setCopiedIdx(idx);
|
||||||
setTimeout(() => setCopiedIdx(null), 1500);
|
setTimeout(() => setCopiedIdx(null), 1500);
|
||||||
} catch {
|
|
||||||
// Fallback: silent fail
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Check, Copy } from "lucide-react";
|
import { Check, Copy } from "lucide-react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { ProgressCard } from "@/components/common/progress-card";
|
import { ProgressCard } from "@/components/common/progress-card";
|
||||||
import { generateId } from "@/lib/utils";
|
import { copyToClipboard, generateId } from "@/lib/utils";
|
||||||
import { useFileStore } from "@/stores/file-store";
|
import { useFileStore } from "@/stores/file-store";
|
||||||
|
|
||||||
function getToken(): string {
|
function getToken(): string {
|
||||||
@@ -118,10 +118,12 @@ export function OcrSettings() {
|
|||||||
|
|
||||||
const handleCopy = async () => {
|
const handleCopy = async () => {
|
||||||
if (text) {
|
if (text) {
|
||||||
await navigator.clipboard.writeText(text);
|
const ok = await copyToClipboard(text);
|
||||||
|
if (ok) {
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
setTimeout(() => setCopied(false), 2000);
|
setTimeout(() => setCopied(false), 2000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const hasFile = files.length > 0;
|
const hasFile = files.length > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user