feat(canvas): 多角度贴节点、宫格切分菜单与多选虚线框跟随

把多角度改成贴在图片节点下方的 3D 编辑器并跟随拖动;宫格切分并入图片工具,自定义面板不关菜单;切分后子图按网格排开;多选虚线框随拖动预览平移。
This commit is contained in:
soonstudio-ai committed 2026-09-14 17:19:56 +08:00
1 parent 4b0e9d8965
commit 818a3aa6f4
26 files changed
+1431 -153

No files matched your search

@@ -0,0 +1,32 @@
import { describe, expect, test } from "bun:test";
import { clampGridSplitSize, isValidGridSplit, layoutGridSplitCells } from "./canvas-grid-split";
describe("canvas-grid-split", () => {
test("clamps size into 1..5", () => {
expect(clampGridSplitSize(0)).toBe(1);
expect(clampGridSplitSize(8)).toBe(5);
expect(clampGridSplitSize(2.6)).toBe(3);
});
test("rejects a single cell", () => {
expect(isValidGridSplit({ rows: 1, columns: 1 })).toBe(false);
expect(isValidGridSplit({ rows: 1, columns: 2 })).toBe(true);
expect(isValidGridSplit({ rows: 3, columns: 2 })).toBe(true);
});
test("lays out fitted cells without overlap", () => {
const cells = [
{ row: 0, column: 0, width: 592, height: 432 },
{ row: 0, column: 1, width: 592, height: 432 },
{ row: 1, column: 0, width: 592, height: 432 },
{ row: 1, column: 1, width: 592, height: 432 },
];
const positions = layoutGridSplitCells({ x: 100, y: 40 }, cells, 48);
expect(positions[1]).toEqual({ x: 100 + 592 + 48, y: 40 });
expect(positions[2]).toEqual({ x: 100, y: 40 + 432 + 48 });
expect(positions[3]).toEqual({ x: 100 + 592 + 48, y: 40 + 432 + 48 });
expect(positions[1]!.x).toBeGreaterThanOrEqual(positions[0]!.x + cells[0]!.width + 48);
expect(positions[2]!.y).toBeGreaterThanOrEqual(positions[0]!.y + cells[0]!.height + 48);
});
});