Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
2026-07-11 12:12:40 +08:00
parent 01a2c63b06
commit 71f758fe0b
66 changed files with 3055 additions and 939 deletions
@@ -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" />