mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -34,6 +34,7 @@ export default function LessonPageBuilder() {
|
||||
const [previewOpen, setPreviewOpen] = useState(false);
|
||||
|
||||
const headerRef = useRef(null);
|
||||
const editorPaneRef = useRef(null);
|
||||
const blocksSeeded = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -69,6 +70,21 @@ export default function LessonPageBuilder() {
|
||||
return () => window.removeEventListener("resize", update);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const el = editorPaneRef.current;
|
||||
if (!el) return;
|
||||
const applyHeight = () => {
|
||||
if (window.innerWidth >= 1024 && previewVisible) {
|
||||
el.style.height = `calc(100vh - var(--navbar-h) - var(--builder-h, 0px))`;
|
||||
} else {
|
||||
el.style.height = "auto";
|
||||
}
|
||||
};
|
||||
applyHeight();
|
||||
window.addEventListener("resize", applyHeight);
|
||||
return () => window.removeEventListener("resize", applyHeight);
|
||||
}, [previewVisible]);
|
||||
|
||||
const addBlock = (type) => setBlocks((prev) => [...prev, makeBlock(type)]);
|
||||
const updateBlock = (id, content) => setBlocks((prev) => prev.map((b) => b.id === id ? { ...b, content } : b));
|
||||
const deleteBlock = (id) => setBlocks((prev) => prev.filter((b) => b.id !== id));
|
||||
@@ -164,18 +180,7 @@ export default function LessonPageBuilder() {
|
||||
"flex flex-col gap-3 p-4 pb-10",
|
||||
previewVisible && "lg:overflow-y-auto"
|
||||
)}
|
||||
ref={(el) => {
|
||||
if (!el) return;
|
||||
const applyHeight = () => {
|
||||
if (window.innerWidth >= 1024 && previewVisible) {
|
||||
el.style.height = `calc(100vh - var(--navbar-h) - var(--builder-h, 0px))`;
|
||||
} else {
|
||||
el.style.height = "auto";
|
||||
}
|
||||
};
|
||||
applyHeight();
|
||||
window.addEventListener("resize", applyHeight);
|
||||
}}
|
||||
ref={editorPaneRef}
|
||||
>
|
||||
<div className="flex items-center gap-2 text-sm font-medium text-muted-foreground pt-1">
|
||||
<Pencil className="h-4 w-4" />
|
||||
|
||||
Reference in New Issue
Block a user