feat(renderer): editor buffer content feeds preview store (300ms debounce)

This commit is contained in:
2026-06-05 13:09:34 +05:30
parent b75f436aaa
commit 8624257c1f
@@ -1,9 +1,16 @@
import { useEffect } from 'react';
import { CodeMirrorEditor } from './CodeMirrorEditor'; import { CodeMirrorEditor } from './CodeMirrorEditor';
import { useEditorStore } from '@/stores/editor-store'; import { useEditorStore } from '@/stores/editor-store';
import { usePreviewStore } from '@/stores/preview-store';
export function EditorPane() { export function EditorPane() {
const { buffers, activeId } = useEditorStore(); const { buffers, activeId } = useEditorStore();
const buf = activeId ? buffers.get(activeId) : null; const buf = activeId ? buffers.get(activeId) : null;
const setPreviewSource = usePreviewStore((s) => s.setSource);
useEffect(() => {
if (buf) setPreviewSource(buf.content);
}, [buf?.id, buf?.content, buf, setPreviewSource]);
if (!buf) { if (!buf) {
return ( return (