feat(text-tool): add Delete/Backspace key to remove empty text objects
Users can now delete text objects by: 1. Click on a text to edit it 2. Clear all text content (or start with empty text) 3. Press Delete or Backspace to remove the entire text object This provides an intuitive way to remove unwanted text without requiring a separate delete tool or context menu. Keyboard shortcuts: - Ctrl+Enter: Commit text - Escape: Cancel editing - Delete/Backspace (on empty text): Delete entire text object 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,7 @@ export function OnCanvasTextEditor() {
|
||||
deactivateOnCanvasEditor,
|
||||
addTextObject,
|
||||
updateTextObject,
|
||||
deleteTextObject,
|
||||
setText,
|
||||
} = useTextStore();
|
||||
|
||||
@@ -201,9 +202,14 @@ export function OnCanvasTextEditor() {
|
||||
} else if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
deactivateOnCanvasEditor();
|
||||
} else if ((e.key === 'Delete' || e.key === 'Backspace') && editingTextId && !editorText.trim()) {
|
||||
// Delete the entire text object if it's empty and we're editing an existing text
|
||||
e.preventDefault();
|
||||
deleteTextObject(editingTextId);
|
||||
deactivateOnCanvasEditor();
|
||||
}
|
||||
},
|
||||
[commitText, deactivateOnCanvasEditor]
|
||||
[commitText, deactivateOnCanvasEditor, editingTextId, editorText, deleteTextObject]
|
||||
);
|
||||
|
||||
// Handle drag start
|
||||
|
||||
Reference in New Issue
Block a user