Add text edit - #185
Conversation
text edit added via double click
|
@dubstar-04 ready for review |
|
Will fix lint in the morning |
|
Linked issue #88 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds text editing functionality via double-click interaction, allowing users to edit text entities directly on the canvas by double-clicking them. The implementation includes state management for text editing mode, command line integration for input handling, and proper cleanup on confirmation or cancellation.
- Adds text editing mode triggered by double-clicking on Text entities
- Implements command line integration for live text editing with Enter to confirm and Escape to cancel
- Adds state tracking and boundary checking for text editing operations
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/entities/text.test.js | Adds test coverage for the new isBeingEdited() method on Text entities |
| core/lib/inputManager.js | Implements text editing state management, including start/confirm/cancel operations and keyboard handling |
| core/lib/commandLine.js | Integrates text editing mode with command line input, including space key handling |
| core/lib/canvas.js | Adds double-click handler to detect and initiate text editing on Text entities |
| core/entities/text.js | Adds isBeingEdited() helper method to check if a text entity is currently being edited |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @param {string} input - the input text | ||
| */ | ||
| handleTextEditInput(input) { | ||
| if (!this.textEditing || !this.editingTextItem || this.editingTextIndex === undefined) { |
There was a problem hiding this comment.
The condition this.editingTextIndex === undefined should use strict inequality (!== undefined) for consistency with the other checks, or consider checking for null as well since the property is initialized as undefined but could potentially be set to null. This same pattern appears in multiple methods (handleTextEditInput, confirmTextEdit, cancelTextEdit).
| const originalCore = DesignCore._core; | ||
| DesignCore._core = { | ||
| scene: mockScene | ||
| }; |
There was a problem hiding this comment.
Directly manipulating private properties (indicated by the _core naming convention) in tests creates tight coupling and fragility. Consider providing a proper mocking mechanism or test utility method in DesignCore for testing purposes.
|
Super impressive PR. I will have a proper look at it later this week. I need to have a look at how commercial CAD manages text editing. I think double clicking a text element invokes the TEXTEDIT (ED) command. #186 https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-B184DB8A-7566-4756-A78E-3721960D86DE |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #185 +/- ##
==========================================
- Coverage 61.59% 60.90% -0.69%
==========================================
Files 72 72
Lines 4892 4967 +75
Branches 935 949 +14
==========================================
+ Hits 3013 3025 +12
- Misses 1684 1740 +56
- Partials 195 202 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
text edit added via double click
Screencast from 27-10-25 23_55_11.webm