Skip to content

feat: add note lock feature to prevent editing#101

Merged
j4rviscmd merged 2 commits intomainfrom
feat/note-lock
Mar 28, 2026
Merged

feat: add note lock feature to prevent editing#101
j4rviscmd merged 2 commits intomainfrom
feat/note-lock

Conversation

@j4rviscmd
Copy link
Copy Markdown
Owner

Summary

  • Add lock/unlock toggle for notes that prevents content editing while still allowing text selection for copying
  • Uses a ProseMirror filterTransaction plugin (readOnlyGuard) to block all editing transactions when locked, keeping contentEditable="true" so WebKit text selection works
  • Hides editing UI elements (drag handles, side menu, formatting toolbar) via CSS [data-locked] attribute
  • Hides text caret with caret-color: transparent when locked for a read-only feel

Changes

Backend (Rust)

  • Add is_locked column to SQLite notes table with migration
  • Add toggle_lock Tauri command
  • Extract NOTE_COLUMNS constant to DRY up SELECT statements

Frontend (TypeScript/React)

  • Add readOnlyGuard ProseMirror extension that blocks doc-changing transactions
  • Add data-locked attribute to editor wrapper for CSS targeting
  • Show FileLock icon in sidebar for locked notes
  • Show lock indicator in SaveStatusIndicator
  • Reset lock state on note switch to prevent stale UI
  • Remove redundant locked guard from handleChange (plugin handles it)

CSS

  • Hide drag handles, side menu, add-block button, suggestion menu when locked
  • Override cursor to default and hide caret when locked

Test plan

  • Lock a note via context menu → verify editing is blocked
  • Lock a note → verify text selection still works for copying
  • Lock a note → verify drag handles, side menu, formatting toolbar are hidden
  • Lock a note → verify text caret is hidden (no blinking I-beam)
  • Unlock a note → verify editing is restored
  • Switch from locked note to unlocked note → verify lock state resets
  • Verify FileLock icon shows in sidebar for locked notes
  • Verify lock indicator shows in header save status area

🤖 Generated with Claude Code

j4rviscmd and others added 2 commits March 28, 2026 14:59
Add a lock/unlock toggle for notes that prevents content editing while
still allowing text selection for copying. Uses a ProseMirror
filterTransaction plugin to block editing transactions and CSS to hide
editing UI elements when locked.

- Add `is_locked` column to SQLite notes table with migration
- Add `toggle_lock` Tauri command and frontend API
- Add ProseMirror readOnlyGuard extension to block edits
- Hide drag handles, side menu, and formatting toolbar when locked
- Show FileLock icon in sidebar for locked notes
- Show lock indicator in SaveStatusIndicator
- Reset lock state on note switch
- Hide text caret with caret-color: transparent when locked

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@j4rviscmd j4rviscmd added the enhancement New feature or request label Mar 28, 2026
@j4rviscmd j4rviscmd merged commit 3bb3ea9 into main Mar 28, 2026
2 checks passed
@j4rviscmd j4rviscmd deleted the feat/note-lock branch March 28, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant