- 새 tools/annotate/place-table-tool.ts — PLACETABLE: 부모가 보낸 표를 커서에 붙여 미리보기 · 누르면 그 자리(왼쪽 위) · Esc 그만 · 놓기 = 되돌리기 한 걸음
- 새 integration/aislo-table-bridge.ts — place-table{entity, link} = style.연결 단 표로 놓기 시작 · update-table{link, cells} = 연결 같은 표 칸만 갈기(자리 · 크기 그대로) → table-updated{link, count} · 확정 · 보기 전용이면 안 함
- TableEntity style.연결 · replaceCells · bridge 갈래 한 줄 · 명령 PLACETABLE
- 시험 aislo-table-bridge.test.ts(놓기 · 연결 남음 · 칸 갈기 · 넘침 · 없는 연결)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UoSr2sqvYtBf1dtQdus88s
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
/**
|
|
* 표 놓기(PLACETABLE · M02 41장) — 부모 화면이 보낸 표(면적산출 범위)를 커서에 붙여 따라오게
|
|
* 그리고, 누르면 그 자리(표 왼쪽 위)에 놓는다. Esc = 그만 · 놓기는 되돌리기 한 걸음.
|
|
* 놓을 표는 브리지(`integration/aislo-table-bridge.ts`)가 `setPendingTable` 로 맡긴 뒤 이 명령을 켠다.
|
|
*/
|
|
import type { Point } from '@flatten-js/core';
|
|
import { TableEntity } from '../../entities/TableEntity';
|
|
import { addEntities, getActiveLayerId } from '../../state';
|
|
import { Tool } from '../../tools';
|
|
import { createSequenceTool } from '../factories/sequence-tool';
|
|
|
|
let pending: TableEntity | null = null;
|
|
|
|
/** 다음 PLACETABLE 이 놓을 표 — 놓으면 비워진다 */
|
|
export function setPendingTable(table: TableEntity | null): void {
|
|
pending = table;
|
|
}
|
|
|
|
export function getPendingTable(): TableEntity | null {
|
|
return pending;
|
|
}
|
|
|
|
/** `table` 과 같은 꼴(칸 · 크기 · style.연결)을 `at`(왼쪽 위)에 둔 새 표 */
|
|
export function tableAt(table: TableEntity, at: Point, layerId: string): TableEntity {
|
|
const placed = new TableEntity(
|
|
layerId,
|
|
at.clone(),
|
|
table.getColumnWidths(),
|
|
table.getRowHeights(),
|
|
table.getCells().map((row) => row.map((cell) => (cell ? { ...cell } : null))),
|
|
table.getStyle()
|
|
);
|
|
placed.lineColor = table.lineColor;
|
|
placed.lineWidth = table.lineWidth;
|
|
return placed;
|
|
}
|
|
|
|
export const placeTableToolStateMachine = createSequenceTool({
|
|
tool: Tool.PLACETABLE,
|
|
steps: [{ kind: 'point', instructions: '표를 놓을 자리(왼쪽 위)를 누르십시오 · Esc 그만.' }],
|
|
helpers: true,
|
|
restart: false,
|
|
preview: (input) => (pending ? [tableAt(pending, input.cursor, getActiveLayerId())] : []),
|
|
commit: (input) => {
|
|
if (!pending) return;
|
|
addEntities([tableAt(pending, input.point(0), getActiveLayerId())], true);
|
|
pending = null;
|
|
},
|
|
});
|