mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
feat(renderer): editor buffer content feeds preview store (300ms debounce)
This commit is contained in:
@@ -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 (
|
||||||
@@ -22,4 +29,4 @@ export function EditorPane() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user