Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion components/vim-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function VimInput({ onSubmit, onCommand, isCommandKOpen, setIsCommandKOpe
const searchInputRef = React.useRef<HTMLInputElement>(null)
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([])

// Context-aware undo: text undo when the input has content, block undo otherwise
const handleUndo = React.useCallback(() => {
if (value && mainInputRef.current) {
mainInputRef.current.focus()
document.execCommand("undo")
} else {
onUndo?.()
}
}, [value, onUndo])

// ── Items (mod-key aware) ───────────────────────────────────────────────

const VIEW_ITEMS = React.useMemo(() => [
Expand Down Expand Up @@ -368,7 +378,7 @@ export function VimInput({ onSubmit, onCommand, isCommandKOpen, setIsCommandKOpe
<div className="flex items-center gap-3">
<button
type="button"
onClick={onUndo}
onClick={handleUndo}
className="flex items-center gap-2 rounded px-1 py-0.5 hover:bg-white/[0.06] active:scale-95 transition-all"
>
<kbd className="flex h-5 items-center rounded border border-white/10 bg-white/5 px-1.5 font-mono text-[9px] text-white/60">
Expand Down
7 changes: 6 additions & 1 deletion plugin/src/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,13 @@ function NodepadApp({ plugin, initialData, fileName, folderPath, onSave, onMenuC
copyToClipboard(md)
new Notice("Copied to clipboard")
}
else if (cmd === "synthesis-doc") {
setSynthSourceAnchors(getSourceAnchors(blocks))
setSynthConfirmOpen(true)
}
else if (cmd === "task" && text) addBlock(text, "task")
else if (cmd === "thesis" && text) addBlock(text, "thesis")
}, [clearBlocks, addBlock, fileName, folderPath, plugin])
}, [clearBlocks, addBlock, fileName, folderPath, plugin, blocks])

// ── Render ────────────────────────────────────────────────────────────────

Expand Down Expand Up @@ -814,6 +818,7 @@ function NodepadApp({ plugin, initialData, fileName, folderPath, onSave, onMenuC
onCommand={handleCommand}
isCommandKOpen={isCommandKOpen}
setIsCommandKOpen={setIsCommandKOpen}
onUndo={undo}
isPlugin
/>
</div>
Expand Down