Refactor Settings, FileTree, GitPanel, Shell, and CodeEditor components (#402)

This commit is contained in:
Haileyesus
2026-02-25 19:07:07 +03:00
committed by GitHub
parent 23801e9cc1
commit 5e3a7b69d7
149 changed files with 11627 additions and 8453 deletions

50
src/utils/clipboard.ts Normal file
View File

@@ -0,0 +1,50 @@
function fallbackCopyToClipboard(text: string): boolean {
if (!text || typeof document === 'undefined') {
return false;
}
const textarea = document.createElement('textarea');
textarea.value = text;
textarea.setAttribute('readonly', '');
textarea.style.position = 'fixed';
textarea.style.opacity = '0';
textarea.style.pointerEvents = 'none';
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
let copied = false;
try {
copied = document.execCommand('copy');
} catch {
copied = false;
} finally {
document.body.removeChild(textarea);
}
return copied;
}
export async function copyTextToClipboard(text: string): Promise<boolean> {
if (!text) {
return false;
}
let copied = false;
try {
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text);
copied = true;
}
} catch {
copied = false;
}
if (!copied) {
copied = fallbackCopyToClipboard(text);
}
return copied;
}

View File

@@ -1,37 +0,0 @@
import { api } from './api';
export async function transcribeWithWhisper(audioBlob, onStatusChange) {
const formData = new FormData();
const fileName = `recording_${Date.now()}.webm`;
const file = new File([audioBlob], fileName, { type: audioBlob.type });
formData.append('audio', file);
const whisperMode = window.localStorage.getItem('whisperMode') || 'default';
formData.append('mode', whisperMode);
try {
// Start with transcribing state
if (onStatusChange) {
onStatusChange('transcribing');
}
const response = await api.transcribe(formData);
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new Error(
errorData.error ||
`Transcription error: ${response.status} ${response.statusText}`
);
}
const data = await response.json();
return data.text || '';
} catch (error) {
if (error.name === 'TypeError' && error.message.includes('fetch')) {
throw new Error('Cannot connect to server. Please ensure the backend is running.');
}
throw error;
}
}