"use client"; import { ChangeEvent } from "react"; import { Lock, LockOpen, Menu, Minus, Plus, X } from "lucide-react"; import { Action, IBlock, ILine } from "@/lib/editorReducer"; import IconOnlyButton from "./IconOnlyButton"; import LineInput from "./LineInput"; export default function Block({ block, dispatch, }: { block: IBlock; dispatch: React.Dispatch; }) { const handleAddLine = () => { dispatch({ type: "add_line", blockId: block.id }); } const handleDeleteLine = () => { dispatch({ type: "delete_line", blockId: block.id }); } const handleTagUpdate = (e: ChangeEvent) => { dispatch({ type: "update_tag", blockId: block.id, tag: e.target.value }); } const handleLineUpdate = (e: ChangeEvent, line: ILine) => { dispatch({ type: "update_line_text", blockId: block.id, lineId: line.id, text: e.target.value }); } const handleDeleteBlock = () => { dispatch({ type: "delete_block", blockId: block.id }); } const handleToggleLock = () => { dispatch({ type: "toggle_lock", blockId: block.id }); } return (
{block.lines.map((line) => ( handleLineUpdate(e, line)} /> ))}
} /> } />
} /> : } alwaysOn={block.locked} /> } />
); }