feat(web): add prompt editor with split-pane and Markdown editing
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
25
web/client/src/hooks/usePrompts.ts
Normal file
25
web/client/src/hooks/usePrompts.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { api } from '@/lib/api';
|
||||
|
||||
export function usePrompts() {
|
||||
const [content, setContent] = useState<string>('');
|
||||
const [path, setPath] = useState<string>('');
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const load = useCallback(async (accountId: string, type: string) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await api.getPrompt(accountId, type);
|
||||
setContent(result.content);
|
||||
setPath(result.path);
|
||||
} catch { setContent(''); setPath(''); }
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
const save = useCallback(async (accountId: string, type: string, newContent: string) => {
|
||||
await api.savePrompt(accountId, type, newContent);
|
||||
setContent(newContent);
|
||||
}, []);
|
||||
|
||||
return { content, path, loading, load, save, setContent };
|
||||
}
|
||||
Reference in New Issue
Block a user