Implement TextTool.ts

This commit is contained in:
2026-06-22 07:23:46 +00:00
parent b8a8464636
commit 976403f5fa
+32
View File
@@ -0,0 +1,32 @@
import { Tool } from '../Tool';
import { YjsDocument } from '../../crdt/YjsDocument';
class TextTool extends Tool {
constructor(yjsDoc: YjsDocument) {
super(yjsDoc);
this.name = 'TextTool';
}
onMouseDown(event: MouseEvent): void {
// Get text input from user
const text = prompt('Enter text:');
if (text !== null && text !== '') {
// Create text element in Yjs document
this.yjsDoc.createText(event.clientX, event.clientY, text);
}
}
onMouseMove(event: MouseEvent): void {
// No preview needed for text tool
}
onMouseUp(event: MouseEvent): void {
// Handle mouse up if needed
}
onKeyUp(event: KeyboardEvent): void {
// Handle key up events
}
}
export { TextTool };