Implement TextTool.ts
This commit is contained in:
@@ -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 };
|
||||
Reference in New Issue
Block a user