|
|
@@ -149,7 +149,10 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
// set to ref
|
|
|
initialValueRef.current = initialValue;
|
|
|
}, [initialValue]);
|
|
|
- const [markdownToPreview, setMarkdownToPreview] = useState<string>(initialValue);
|
|
|
+
|
|
|
+ const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(GlobalCodeMirrorEditorKey.MAIN);
|
|
|
+
|
|
|
+ const [markdownToPreview, setMarkdownToPreview] = useState<string>(codeMirrorEditor?.getDoc() ?? '');
|
|
|
const setMarkdownPreviewWithDebounce = useMemo(() => debounce(100, throttle(150, (value: string) => {
|
|
|
setMarkdownToPreview(value);
|
|
|
})), []);
|
|
|
@@ -159,8 +162,6 @@ export const PageEditor = React.memo((props: Props): JSX.Element => {
|
|
|
}, [setMarkdownPreviewWithDebounce]);
|
|
|
|
|
|
|
|
|
- const { data: codeMirrorEditor } = useCodeMirrorEditorIsolated(GlobalCodeMirrorEditorKey.MAIN);
|
|
|
-
|
|
|
const { scrollEditorHandler, scrollPreviewHandler } = useScrollSync(GlobalCodeMirrorEditorKey.MAIN, previewRef);
|
|
|
|
|
|
const scrollEditorHandlerThrottle = useMemo(() => throttle(25, scrollEditorHandler), [scrollEditorHandler]);
|