Skip to content

feat: add markdown rendering and preview to notes editor#66

Open
arcgod-design wants to merge 2 commits into
rishabhx29:mainfrom
arcgod-design:feat/issue-11-markdown-preview
Open

feat: add markdown rendering and preview to notes editor#66
arcgod-design wants to merge 2 commits into
rishabhx29:mainfrom
arcgod-design:feat/issue-11-markdown-preview

Conversation

@arcgod-design

@arcgod-design arcgod-design commented Jun 30, 2026

Copy link
Copy Markdown

Description

Adds markdown rendering and preview to the Notes editor, allowing users to write and preview markdown-formatted notes with syntax highlighting.

Changes

  • Edit/Preview toggle: Added toggle button in editor header to switch between edit and preview modes
  • Side-by-side view: On lg: screens, editor and preview are shown side-by-side using CSS grid
  • Markdown rendering: Notes are rendered via ReactMarkdown with remark-gfm for tables, strikethrough, and task lists
  • Syntax highlighting: Code blocks are highlighted using prism-react-renderer with the Night Owl theme
  • Backward compatibility: getAllProblems API returns all problems when no pagination params are provided

Files Changed

  • app/src/sections/Notes.tsx — Added preview toggle, side-by-side layout, ReactMarkdown + syntax highlighting
  • app/src/api/content.ts — Made pagination params optional for backward compat
  • backend/src/controllers/contentController.ts — Made pagination optional (returns all when no params)
  • app/package.json — Added prism-react-renderer dependency

Testing

  • Edit/Preview toggle works on all screen sizes
  • Side-by-side view on lg: screens
  • Markdown renders correctly (headings, lists, bold, italic, tables, code blocks)
  • Code blocks are syntax-highlighted
  • Save/cancel flow not disrupted
  • Notes saved in markdown display correctly when re-opened

Closes #11

Summary by CodeRabbit

  • New Features

    • Notes can now be edited in a split view with live Markdown preview and code highlighting.
    • Added an easy toggle between edit and preview modes for notes.
    • Problem lists now support pagination, improving browsing performance for larger sets.
  • Bug Fixes

    • Note content now renders more consistently in read-only view with Markdown support and formatted code blocks.

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the rishabhjtripathi2903-3434's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • app/package-lock.json is excluded by !**/package-lock.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 30c4997d-ab52-4b7f-97a6-4618753e7598

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds an Edit/Preview markdown mode to the Notes editor using react-markdown, remark-gfm, and prism-react-renderer for syntax-highlighted code blocks, and introduces optional page/limit pagination support to getAllProblems in both the backend controller and frontend API client.

Changes

Notes Markdown Editor Preview

Layer / File(s) Summary
Markdown rendering dependencies and imports
app/package.json, app/src/sections/Notes.tsx
Adds prism-react-renderer dependency and imports Eye, Code2, react-markdown, remark-gfm, and Highlight/themes in Notes.tsx.
Preview state and toggle control
app/src/sections/Notes.tsx
Adds isPreview state, resets it on create/edit flows, and adds an Edit/Preview toggle button.
Editor split-pane and markdown rendering
app/src/sections/Notes.tsx
Renders a responsive editor/preview split pane and switches the read-only note view to ReactMarkdown with syntax-highlighted code blocks.

Problems List Pagination

Layer / File(s) Summary
Backend pagination logic
backend/src/controllers/contentController.ts
getAllProblems conditionally returns all problems or a paginated response (problems, total, page, limit, totalPages) based on optional page/limit query params.
Frontend API pagination support
app/src/api/content.ts
getAllProblems client function accepts optional page/limit arguments and appends a query string to the request URL.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant NotesUI as Notes.tsx
  participant ReactMarkdown
  participant Highlight

  User->>NotesUI: Click Edit/Preview toggle
  NotesUI->>NotesUI: Set isPreview state
  alt isPreview true
    NotesUI->>ReactMarkdown: Render editForm.content with remarkGfm
    ReactMarkdown->>Highlight: Render code blocks with themes.nightOwl
    Highlight-->>NotesUI: Highlighted code HTML
    ReactMarkdown-->>NotesUI: Rendered markdown HTML
  else isPreview false
    NotesUI-->>User: Show raw textarea
  end
Loading
sequenceDiagram
  participant Frontend as content.ts
  participant Backend as contentController.ts
  participant DB as Database

  Frontend->>Backend: GET /api/content/problems?page&limit
  alt page and limit provided
    Backend->>Backend: Clamp page/limit values
    Backend->>DB: Fetch paged problems (skip/take) and total count
    DB-->>Backend: Problems page + total count
    Backend-->>Frontend: {problems, total, page, limit, totalPages}
  else no pagination params
    Backend->>DB: Fetch all problems ordered by order_index
    DB-->>Backend: All problems
    Backend-->>Frontend: Array of problems
  end
Loading

Possibly related issues

Suggested reviewers: Rishabhworkspace

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The API/controller pagination changes in content.ts and contentController.ts are unrelated to the Notes markdown preview work. Move the getAllProblems pagination changes into a separate PR so this one stays focused on the Notes editor markdown/preview feature.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main notes editor markdown/preview change.
Linked Issues check ✅ Passed The Notes editor gains edit/preview mode, markdown rendering, code highlighting, and responsive split layout as required.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rishabhx29 rishabhx29 added enhancement New feature or request SSoC26 Medium labels Jul 4, 2026
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
algo-forge-2-0 Error Error Jul 4, 2026 9:16am

@arcgod-design arcgod-design force-pushed the feat/issue-11-markdown-preview branch from 9dde333 to d0b592f Compare July 5, 2026 09:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
app/src/sections/Notes.tsx (1)

409-470: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared markdown renderer and register typography styles.

  • ReactMarkdown + custom code rendering is duplicated in the editor preview and read-only note view; move it into a shared component to keep both render paths in sync.
  • prose prose-invert prose-sm depends on @tailwindcss/typography, but app/tailwind.config.js doesn’t include that plugin, so the markdown styling won’t apply.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/sections/Notes.tsx` around lines 409 - 470, The markdown preview
rendering is duplicated in the Notes view, including the ReactMarkdown setup and
custom code block handling, so extract that into a shared markdown renderer
component and reuse it for both the editor preview and the read-only note
display. Also update the Tailwind setup in the app config to register the
typography plugin so the prose/prose-invert/prose-sm classes used by the
markdown renderer actually apply.
app/src/api/content.ts (1)

54-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Function has no explicit return type despite a shape that changes based on args.

getAllProblems returns either a plain array or a paginated object depending on whether page/limit are passed, but the function signature is untyped (implicit any via response.data). Nothing prevents a future caller from passing page/limit and mistakenly treating the result as an array (or vice versa), which would only surface as a runtime bug.

♻️ Suggested typed overloads
+interface PaginatedProblems {
+  problems: Problem[];
+  total: number;
+  page: number;
+  limit: number;
+  totalPages: number;
+}
+
+export function getAllProblems(): Promise<Problem[]>;
+export function getAllProblems(page: number, limit?: number): Promise<PaginatedProblems>;
 export const getAllProblems = async (page?: number, limit?: number) => {
     const params = new URLSearchParams();
     if (page) params.set('page', String(page));
     if (limit) params.set('limit', String(limit));
     const qs = params.toString();
     const response = await axios.get(`${API_BASE_URL}/api/content/problems${qs ? `?${qs}` : ''}`);
     return response.data;
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/api/content.ts` around lines 54 - 61, getAllProblems currently
returns different shapes depending on whether page/limit are provided, but its
signature is untyped and lets callers assume the wrong result shape. Add
explicit typed overloads (or a discriminated union return type) on
getAllProblems so the no-args case and paginated case are each represented
correctly, and make the axios response typed instead of relying on response.data
inference.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@app/src/api/content.ts`:
- Around line 54-61: getAllProblems currently returns different shapes depending
on whether page/limit are provided, but its signature is untyped and lets
callers assume the wrong result shape. Add explicit typed overloads (or a
discriminated union return type) on getAllProblems so the no-args case and
paginated case are each represented correctly, and make the axios response typed
instead of relying on response.data inference.

In `@app/src/sections/Notes.tsx`:
- Around line 409-470: The markdown preview rendering is duplicated in the Notes
view, including the ReactMarkdown setup and custom code block handling, so
extract that into a shared markdown renderer component and reuse it for both the
editor preview and the read-only note display. Also update the Tailwind setup in
the app config to register the typography plugin so the
prose/prose-invert/prose-sm classes used by the markdown renderer actually
apply.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ae71c85-ba03-4188-99b5-295a0db1dc26

📥 Commits

Reviewing files that changed from the base of the PR and between 8e41fd8 and d0b592f.

⛔ Files ignored due to path filters (1)
  • app/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • app/package.json
  • app/src/api/content.ts
  • app/src/sections/Notes.tsx
  • backend/src/controllers/contentController.ts

@arcgod-design

Copy link
Copy Markdown
Author

Closes #11

@arcgod-design

Copy link
Copy Markdown
Author

Hey @Rishabhworkspace, this PR has been ready for review for a while -- offering this friendly bump. The implementation matches the issue's specified behavior and CI is passing.

PR: #66
Title: feat: markdown rendering and preview to notes editor
Issue: #11

When you have a moment, a review would be much appreciated. I am happy to iterate on any feedback. If the timing is not right, no worries at all -- just a gentle nudge from a contributor who has been waiting patiently. �

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Medium SSoC26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Markdown Rendering and Preview to the Notes Editor

2 participants