feat: modularize block system (#718)

This commit is contained in:
Jeremy 2025-01-27 14:19:47 +05:30 committed by GitHub
parent 5e8cddc886
commit 38527ff92e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 684 additions and 604 deletions

View file

@ -10,14 +10,14 @@ import { Suggestion } from '@/lib/db/schema';
type EditorProps = {
content: string;
saveContent: (updatedContent: string, debounce: boolean) => void;
onSaveContent: (updatedContent: string, debounce: boolean) => void;
status: 'streaming' | 'idle';
isCurrentVersion: boolean;
currentVersionIndex: number;
suggestions: Array<Suggestion>;
};
function PureCodeEditor({ content, saveContent, status }: EditorProps) {
function PureCodeEditor({ content, onSaveContent, status }: EditorProps) {
const containerRef = useRef<HTMLDivElement>(null);
const editorRef = useRef<EditorView | null>(null);
@ -54,7 +54,7 @@ function PureCodeEditor({ content, saveContent, status }: EditorProps) {
if (transaction) {
const newContent = update.state.doc.toString();
saveContent(newContent, true);
onSaveContent(newContent, true);
}
}
});
@ -69,7 +69,7 @@ function PureCodeEditor({ content, saveContent, status }: EditorProps) {
editorRef.current.setState(newState);
}
}, [saveContent]);
}, [onSaveContent]);
useEffect(() => {
if (editorRef.current && content) {