Files
web-cad/frontend/src/tools/drawing/ChairTool.ts
T
Agent Zero 05ccebad8d Replace frontend with deployed TS version from a08dd73
- Restore TS frontend source (canvas, tools, CRDT, components, services)
- Keep 5 JSX components that TS code depends on (CADCanvas, LayerPanel, BlockLibrary, PluginRegistry, Toolbar)
- Keep JS services (api.js, blockService.js) that components depend on
- Fix vite/plugin-react version mismatch (downgrade to v4 for vite 6)
- Add axios dependency
- Skip tsc in build script (vite/esbuild handles transpilation)
- Fix index.html lang=de, favicon path
- Add vite proxy config for /api and /ws
- Backend unchanged (already from deployed containers)
2026-06-28 02:16:58 +02:00

58 lines
1.3 KiB
TypeScript

import { Tool } from '../Tool';
import { YjsDocument } from '../../crdt/YjsDocument';
class ChairTool extends Tool {
private width: number = 45; // Default chair width
private height: number = 45; // Default chair height
constructor(yjsDoc: YjsDocument) {
super(yjsDoc);
this.name = 'ChairTool';
}
onMouseDown(event: MouseEvent): void {
// Create chair element at click position
const x = event.clientX - this.width / 2;
const y = event.clientY - this.height / 2;
this.yjsDoc.createElement({
id: crypto.randomUUID(),
type: 'chair',
layerId: 'default',
x,
y,
width: this.width,
height: this.height,
properties: {
// Chair-specific properties can be added here
}
});
}
onMouseMove(event: MouseEvent): void {
// Preview chair at cursor position
}
onMouseUp(event: MouseEvent): void {
// Handle mouse up if needed
}
onKeyUp(event: KeyboardEvent): void {
// Handle key up events
if (event.key === 'Escape') {
this.reset();
}
}
reset(): void {
// Reset any state if needed
}
// Set chair dimensions
setDimensions(width: number, height: number): void {
this.width = width;
this.height = height;
}
}
export { ChairTool };