feat: modularize block system (#718)
This commit is contained in:
parent
5e8cddc886
commit
38527ff92e
18 changed files with 684 additions and 604 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue