feat(canvas): refine connections, text styles and icon editing
This commit is contained in:
@@ -49,12 +49,16 @@ test("all eight handles resize cards while retaining the opposite local anchor,
|
||||
}
|
||||
});
|
||||
|
||||
test("plain text resizing keeps aspect ratio and scales the font", () => {
|
||||
test("plain text width and height resize independently without changing the font", () => {
|
||||
const node = new PlainTextElement({ x: 0, y: 0 }).toNode();
|
||||
const patch = resizeFromPointer(node, "bottom-right", { x: 240, y: 72 });
|
||||
close(patch.width, 480); close(patch.height, 144); close(patch.fontSize, 48);
|
||||
close(patch.width, 480); close(patch.height, 144); assert.equal(patch.fontSize, undefined);
|
||||
const widthOnly = resizeFromPointer(node, "bottom-right", { x: 120, y: 0 });
|
||||
close(widthOnly.width, 360); close(widthOnly.height, 72);
|
||||
const heightOnly = resizeFromPointer(node, "bottom-right", { x: 0, y: 60 });
|
||||
close(heightOnly.width, 240); close(heightOnly.height, 132);
|
||||
const min = resizeFromPointer(node, "bottom-right", { x: -10000, y: -10000 });
|
||||
assert(min.width >= 60); assert(min.height >= 24); assert(min.fontSize >= 8);
|
||||
assert(min.width >= 60); assert(min.height >= 24); assert.equal(min.fontSize, undefined);
|
||||
});
|
||||
|
||||
test("rotation follows the pointer, supports 15-degree snapping and normalizes the angle", () => {
|
||||
@@ -73,8 +77,8 @@ test("geometry and plain-text type survive save/restore and transforms undo as o
|
||||
state = canvasReducer(state, { type: "checkpoint" });
|
||||
state = canvasReducer(state, { type: "transform", id: node.id, transform: { ...resizeFromPointer(node, "right", { x: 120, y: 0 }), rotation: 45 } });
|
||||
const restored = decodeCanvas(JSON.stringify(state.present)).nodes[0];
|
||||
assert.equal(restored.type, "plainText"); close(restored.width, 360); close(restored.height, 108);
|
||||
close(restored.data.rotation, 45); close(restored.data.fontSize, 36);
|
||||
assert.equal(restored.type, "plainText"); close(restored.width, 360); close(restored.height, 72);
|
||||
close(restored.data.rotation, 45); close(restored.data.fontSize, 24);
|
||||
const undo = canvasReducer(state, { type: "undo" });
|
||||
assert.deepEqual(nodeSize(undo.present.nodes[0]), { width: 240, height: 72 });
|
||||
close(undo.present.nodes[0].data.rotation, 0);
|
||||
|
||||
Reference in New Issue
Block a user