{
// 멀티 선택(MVP): Cmd/Ctrl+클릭 시 선택 토글, 그 외에는 단일 선택으로 전환한다.
const isMeta = event.metaKey || event.ctrlKey;
if (isMeta) {
event.stopPropagation();
setSelectedBlockIds((prev) => {
if (prev.includes(block.id)) {
return prev.filter((id) => id !== block.id);
}
return [...prev, block.id];
});
return;
}
// 일반 클릭: 현재 블록만 단일 선택으로 유지한다.
event.stopPropagation();
setSelectedBlockIds([block.id]);
selectBlock(block.id);
}}
onDoubleClick={(event) => {
if (block.type === "text") {
// 더블클릭 시 텍스트 블록 인라인 편집 모드로 진입한다.
event.stopPropagation();
startEditing(block.id, (block.props as TextBlockProps).text);
}
}}
>
{block.type === "text" && (
isEditing ? (
);
}
interface BlockDropzoneProps {
id: string;
testId?: string;
}
function BlockDropzone({ id, testId }: BlockDropzoneProps) {
const { setNodeRef, isOver } = useDroppable({ id });
return (
);
}
interface ColumnDroppableProps {
id: string;
sectionId: string;
columnId: string;
basis: string;
blocks: Block[];
renderBlocks: (targetBlocks: Block[]) => ReactNode;
span: number;
}
function ColumnDroppable({ id, sectionId, columnId, basis, blocks, renderBlocks, span }: ColumnDroppableProps) {
const { setNodeRef } = useDroppable({ id });
const { over } = useDndContext();
// 현재 드롭 대상이 이 컬럼이거나, 이 컬럼 안 블록들의 dropzone-before / dropzone-after 인 경우
// 컬럼 박스를 강조해서 사용자가 어느 컬럼으로 이동 중인지 명확히 보여준다.
const overId = over?.id ? String(over.id) : null;
const isActiveColumn = (() => {
if (!overId) return false;
// 0) 섹션 블록 자체 위에 있는 경우: 해당 섹션의 컬럼 전체를 하이라이트한다.
if (overId === sectionId) return true;
// 1) 이 컬럼 droppable 자체 위에 있는 경우
if (overId === id) return true;
// 2) 이 컬럼 안 블록들 앞 드롭존 또는 섹션 바로 위 드롭존: dropzone-before:*
if (overId.startsWith("dropzone-before:")) {
const [, targetId] = overId.split(":");
// 섹션 바로 위 루트 드롭존(dropzone-before:sectionId)도 이 섹션의 컬럼을 활성화한다.
if (targetId === sectionId) {
return true;
}
if (targetId && blocks.some((b) => b.id === targetId)) {
return true;
}
}
// 3) 이 컬럼 맨 아래 드롭존: dropzone-after:sectionId:columnId
if (overId === `dropzone-after:${sectionId}:${columnId}`) {
return true;
}
return false;
})();
return (