Skip to content

Add Markdown Rendering and Preview to the Notes Editor #11

Description

@rishabhx29

Description

The Notes editor in Notes.tsx is a plain <textarea> that renders saved content as whitespace-pre-wrap text. Notes are primarily used to record algorithm insights, time complexities, and code snippets — all of which benefit greatly from markdown formatting. The project already has both react-markdown and remark-gfm installed in app/package.json.

Requirements

  • Add an Edit / Preview toggle to the note editor header.
  • In Edit mode, the existing <textarea> is shown.
  • In Preview mode, content is rendered via <ReactMarkdown> with remark-gfm plugins.
  • Code blocks in the preview should be syntax-highlighted.
  • On lg: breakpoints, show both panels side-by-side.
  • No new mandatory dependencies — use the already-installed react-markdown and remark-gfm.

Expected Behavior

Edit Mode — Raw markdown text input in the existing <textarea>.

Preview Mode — Rendered HTML with formatted headings, lists, code blocks, and bold/italic text. Code blocks are syntax-highlighted.

Large Screens (lg: and above) — Editor on the left, live preview on the right, no toggle needed.

Tasks

  • Add an isPreview boolean state to the note editor.
  • Add an "Edit / Preview" toggle button in the editor header.
  • Replace the static whitespace-pre-wrap div in note view with <ReactMarkdown remarkPlugins={[remarkGfm]}>.
  • Add syntax highlighting for code blocks (use prism or react-syntax-highlighter).
  • On lg: screens, use a CSS grid to show editor and preview side-by-side.
  • Ensure save/cancel flow is not disrupted by the new toggle state.

Acceptance Criteria

  • Markdown content renders correctly: headings, lists, bold, italic, tables, and code blocks.
  • Code blocks are syntax-highlighted in preview.
  • Edit/Preview toggle works on all screen sizes.
  • Notes saved in markdown display correctly when re-opened and viewed.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions