Skip to content

Markdown editor for item notes#187

Merged
brianorwhatever merged 8 commits into
mainfrom
markdown-editor
Jun 22, 2026
Merged

Markdown editor for item notes#187
brianorwhatever merged 8 commits into
mainfrom
markdown-editor

Conversation

@brianorwhatever

Copy link
Copy Markdown
Contributor

Summary

  • New full-page markdown editor at /note/:itemId — one big textarea with an Edit/Preview toggle (react-markdown + remark-gfm), debounced autosave, and a save-status indicator.
  • Reuses the existing items.description field (no schema change). New Convex query getItemForEditor loads the item with permission gating; updateItem now caps descriptions at 50k.
  • The item-details modal's inline notes textarea is replaced by a tap-to-open rendered-markdown preview, so the dedicated page is the single editing surface.
  • Pure helpers (MAX_NOTE_LENGTH, clampNote, shouldPersist) in src/lib/noteEditor.ts with unit tests.

Design notes

  • Editing state uses the Convex query as the source of truth with a local override only while typing (draft: string | null), so a saved note resumes tracking the server value rather than holding stale text.
  • Markdown preview renders without rehype-raw/dangerouslySetInnerHTML — pasted HTML/<script> is inert.
  • In the current permission model there is no viewer-only role, so a non-editor on /note/:itemId gets "note not available" rather than an unreachable read-only branch.

Test Plan

  • bun test scripts/ — 68 pass (incl. new note-editor tests)
  • npx tsc -b clean; npx eslint clean on new files; vite build succeeds
  • Manual: create item → open notes → type markdown → Saving→Saved → toggle Preview → Back → reopen modal shows rendered preview; reload persists
  • Manual: paste <script>alert(1)</script>, Preview renders it inert
  • Manual: visit /note/<bad-id> → "This note isn't available."

🤖 Generated with Claude Code

@brianorwhatever brianorwhatever merged commit 80a7692 into main Jun 22, 2026
4 of 6 checks passed
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