Skip to content

fix: synthesis button, undo button, and plugin command handler#5

Merged
Dev-020 merged 3 commits into
mainfrom
feat/synthesis-document-plan
May 11, 2026
Merged

fix: synthesis button, undo button, and plugin command handler#5
Dev-020 merged 3 commits into
mainfrom
feat/synthesis-document-plan

Conversation

@Dev-020
Copy link
Copy Markdown
Owner

@Dev-020 Dev-020 commented May 11, 2026

Summary

Three fixes discovered during testing after PR #4 was merged:

1. Synthesis button did nothing in the plugin

Clicking "Synthesis · document" in the plugin's Ctrl+K palette closed the palette but nothing else happened. The VimInput fires onCommand("synthesis-doc") but the plugin's handleCommand function had no case for it. The synthesisTriggerRef only handled the external Obsidian Ctrl+P command, not the internal VimInput click.

Fix: Added "synthesis-doc" case to handleCommand in NodepadApp (plugin/src/view.tsx).

2. Undo button was a no-op in the plugin

The undo function exists in NodepadApp and works via keyboard, but was not passed as onUndo to VimInput. Tapping the button did nothing on touch devices.

Fix: Pass onUndo={undo} to VimInput in the plugin render.

3. Undo button showed "Nothing to undo" when typing (web-app + plugin)

The undo button always called onUndo() which is the canvas block-level undo. When the user has text typed in the input and taps Undo, the relevant undo is the browser's native text undo — the same thing Ctrl+Z does on the input field. Block-level undo has nothing to revert, so it showed "Nothing to undo".

Fix: handleUndo in VimInput now checks context:

  • Input has content → focus the input and call document.execCommand("undo") (browser native text undo)
  • Input is empty → call onUndo() for canvas block undo

Files changed

File Change
plugin/src/view.tsx Add "synthesis-doc" to handleCommand; pass onUndo={undo} to VimInput
components/vim-input.tsx Context-aware handleUndo — text undo vs block undo

🤖 Generated with Claude Code

Dev-020 and others added 3 commits May 11, 2026 23:31
The synthesisTriggerRef only handled external Obsidian command palette
triggers (Ctrl+P). Clicking the Synthesis button in the VimInput fires
onCommand("synthesis-doc") which had no case in handleCommand, so
nothing happened. Add the missing branch to open the confirm dialog.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The undo function already exists in NodepadApp (Cmd+Z keyboard
shortcut handler), but was not passed to VimInput's onUndo prop.
Tapping the undo button was a no-op. Now passes undo directly so
mobile/tablet users can tap to undo without a keyboard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously the button always called onUndo() which is the canvas
block-level undo — so tapping it while typing showed "Nothing to
undo" even though there was text to undo.

handleUndo now checks: if the input has content, focus it and call
document.execCommand("undo") to trigger the browser's native text
undo (same effect as Ctrl+Z on the field). If the input is empty,
fall back to block-level undo as before.

This makes the button useful in both contexts without a keyboard.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Dev-020 Dev-020 merged commit 9c1ebe0 into main May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant