CodingNic

Bookmarks, Highlights & Notes

Create and Edit Notes

Bookmarks, Highlights & Notes 20 min read

Create and Edit Notes

Create and Edit Notes

Task

Add persistent notes attached to a Highlight or reading position.

Use the existing Note model and scope mutations to the authenticated user.

A note update should verify ownership before changing its text:

ts
const result = await prisma.note.updateMany({
  where: {
    id: noteId,
    userId: user.id,
  },
  data: {
    content,
  },
});

Connect the prepared note editor to create and update routes.

Keep note editing local until save succeeds, then update the visible UI and show the existing success toast.

Test

Create a note from a Highlight, edit it, reload the page, and confirm the text persists.

Try editing a note that belongs to another user.

Checkpoint

Notes are real persistent records associated with the user’s reading context.