forked from 1b-agent/opencadstudio-upstream
feat(mtext): edit text directly in the preview with a caret
The rendered MText preview is now an editable surface: it shows a text caret, click to position it between glyphs, and type/Backspace/Delete/Enter to edit. Left/Right arrows move the caret; drag-selection + toolbar formatting still work and typing replaces a selection. Keystrokes are routed by mapping visible-character offsets to byte spans in the value (raw newlines count as paragraph breaks, matching the layout). While the preview is open the command line releases its on_input so typed glyphs reach the preview instead, and the caret starts at the end of the text so typing works without a click first. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
50115c55d8
commit
7190df8274
5 files changed
+280
-5
No files matched your search
@@ -744,6 +744,14 @@ pub enum Message {
|
||||
MTextSelStart(usize),
|
||||
/// Extend the preview selection to the given visible-character offset.
|
||||
MTextSelTo(usize),
|
||||
/// Type text at the preview caret (replacing any selection).
|
||||
MTextType(String),
|
||||
/// Backspace at the preview caret.
|
||||
MTextBackspace,
|
||||
/// Delete-forward at the preview caret.
|
||||
MTextDelete,
|
||||
/// Move the preview caret by N visible characters.
|
||||
MTextCaretMove(i32),
|
||||
/// Commit the editor: create or update the MText entity.
|
||||
MTextOk,
|
||||
/// Discard the editor without creating / changing the entity.
|
||||
|
||||
Reference in new issue
Block a user