Skip to content

feat: restore cursor position when reopening notes#78

Merged
j4rviscmd merged 2 commits intomainfrom
feat/cursor-restore
Mar 27, 2026
Merged

feat: restore cursor position when reopening notes#78
j4rviscmd merged 2 commits intomainfrom
feat/cursor-restore

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

  • Persist the focused BlockNote block ID per note in editorStateStore (editor-state.json) and restore the cursor to that block's end when a note's content finishes loading
  • Falls back to the first block's end when no saved position exists
  • Handles app startup focus by observing splash screen DOM removal via MutationObserver

Changes

  • New: src/shared/lib/cursorPosition.ts — Pure functions for cursor position operations (getFocusedBlockId, placeCursorAtBlockEnd, placeCursorAtFirstBlock)
  • New: src/shared/hooks/useCursorMemory.ts — Hook that persists/restores cursor positions per note using tauri-plugin-store, mirrors the existing useBlockScrollMemory pattern
  • Modified: src/App.tsx — Integrated useCursorMemory into the editor lifecycle; cursor position is saved on note switch and visibility change, restored via onContentLoaded callback

Test plan

  • Switch between multiple notes and verify cursor restores to the last-edited block's end
  • Restart the app and verify cursor restores to the previously focused block
  • Create a new note and verify cursor falls back to the first block's end
  • Delete a block that had a saved cursor position and verify fallback to first block
  • Verify splash screen dismissal does not steal focus from the editor on startup

🤖 Generated with Claude Code

j4rviscmd and others added 2 commits March 27, 2026 20:58
Persist the focused block ID per note in editorStateStore and restore
the cursor to that block's end when a note's content finishes loading.
Falls back to the first block when no saved position exists. Handles
app startup focus by observing splash screen DOM removal via
MutationObserver.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@j4rviscmd j4rviscmd merged commit 6e687a7 into main Mar 27, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the feat/cursor-restore branch March 27, 2026 12:04
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