mirror of
https://github.com/coaidev/coai.git
synced 2025-06-06 22:00:25 +09:00
fix editor in production env
This commit is contained in:
parent
0c885dc611
commit
af2e1ef3d7
@ -35,12 +35,16 @@ function RichEditor({
|
|||||||
const [openPreview, setOpenPreview] = useState(!mobile);
|
const [openPreview, setOpenPreview] = useState(!mobile);
|
||||||
const [openInput, setOpenInput] = useState(true);
|
const [openInput, setOpenInput] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
const handler = () => {
|
||||||
if (!input.current) return;
|
if (!input.current) return;
|
||||||
const target = input.current as HTMLElement;
|
const target = input.current as HTMLElement;
|
||||||
const preview = target.parentElement?.querySelector(
|
const preview = target.parentElement?.querySelector(
|
||||||
".editor-preview",
|
".editor-preview",
|
||||||
) as HTMLElement;
|
) as HTMLElement | null;
|
||||||
|
if (!preview) {
|
||||||
|
setTimeout(handler, 100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const listener = () => {
|
const listener = () => {
|
||||||
preview.style.height = `${target.clientHeight}px`;
|
preview.style.height = `${target.clientHeight}px`;
|
||||||
@ -54,7 +58,8 @@ function RichEditor({
|
|||||||
preview.style.height = `${target.clientHeight}px`;
|
preview.style.height = `${target.clientHeight}px`;
|
||||||
|
|
||||||
if (openInput) target.focus();
|
if (openInput) target.focus();
|
||||||
}, [input]);
|
};
|
||||||
|
useEffect(handler, [input]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`editor-container`}>
|
<div className={`editor-container`}>
|
||||||
|
Loading…
Reference in New Issue
Block a user