Skip to content

feat(slides): add MDX support for JSX-powered slides - #3

Merged
rikkarth merged 7 commits into
mainfrom
feat/support-mdx
Mar 21, 2026
Merged

rikkarth merged 7 commits into
mainfrom
feat/support-mdx

Conversation

@rikkarth

@rikkarth rikkarth commented Mar 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Runtime MDX compilation via @mdx-js/mdx with two-layer caching (processor + output). .mdx slides render JSX with inline styles alongside standard markdown.
  • Graceful fallback: compilation errors fall back to plain markdown rendering; unknown components render as nothing via recma-mdx-escape-missing-components; React error boundary catches render-time crashes.
  • Opt-in per slide: rename .md to .mdx. Existing markdown slides work unchanged.
  • Format chooser in slide navigator — create new slides as Markdown (.md) or MDX (.mdx).
  • MDX-aware exports — PDF and HTML SPA pre-render MDX slides to static HTML with markdown regex fallback.
  • Safety guards: WYSIWYG editor bypassed for MDX (TipTap can't handle JSX); auto sub-slide splitting disabled for MDX.
  • Bug fix: Vite full-page reload on content file saves (pre-existing, affected all slides) — fixed via hasUnsavedChanges guard + chokidar function filter.

New files

  • MdxRenderer.tsx — compile/run/cache/error-boundary pipeline
  • ContentRenderer.tsx — routes isMdx to MdxRenderer or SlideRenderer
  • slide-utils.ts — shared resolveImageSrc()
  • 06-mdx.mdx, 07-lecta-overview.mdx — example MDX slides

Modified (key changes)

  • LoadedSlide.isMdx flag set from .mdx extension during load
  • All 6 SlideRenderer consumer sites → ContentRenderer
  • useSubSlides skips splitting for MDX
  • SlidePanel visual mode shows rendered canvas for MDX
  • Export handlers compile MDX to static HTML
  • IPC/preload/store/MCP accept format param for slide creation

Test plan

  • Open hello-world deck — all .md slides render identically to before
  • Navigate to MDX slide (06-mdx) — gradient cards render
  • Switch between Visual/Markdown modes on MDX slide — no crash
  • Edit MDX content in Markdown mode — preview updates after debounce
  • Introduce syntax error in MDX — error panel shows, text content visible as fallback
  • Use <UnknownComponent /> in MDX — renders as nothing, no crash
  • Create new slide via "+" button — format chooser shows MD/MDX options
  • Export PDF with mixed deck — MDX slides show static rendered content
  • Export HTML with mixed deck — navigation works, MDX slides pre-rendered
  • Presenter mode (F5) with MDX slides — renders in both presenter and audience windows
  • Editor blur on .md slide without edits — no page reload

Ricardo Mendes and others added 6 commits March 21, 2026 17:11
Runtime MDX compilation via @mdx-js/mdx with two-layer caching
(processor + output). MDX slides render JSX with inline styles
alongside standard markdown. Graceful fallback to plain markdown
on compilation errors. Missing components render as nothing via
recma-mdx-escape-missing-components.

Key changes:
- MdxRenderer with compile/run/cache/error-boundary pipeline
- ContentRenderer wrapper routes isMdx to MdxRenderer
- isMdx flag set during slide loading from .mdx extension
- WYSIWYG disabled for MDX slides (TipTap can't handle JSX)
- Auto sub-slide splitting disabled for MDX
- Format chooser (md/mdx) in slide navigator
- MDX-aware PDF and HTML SPA export
- Example MDX slide in hello-world deck

EXPERIMENTAL: Visual mode editing and stability under active work.
Content file writes (slides, yaml, mdx) during save-on-blur triggered
Vite's file watcher, causing a full page navigation back to HomeScreen.

Two fixes:
- Skip save on editor blur when there are no unsaved changes
- Add chokidar function filter to ignore non-source file changes
  (glob patterns are unreliable per chokidar known issues)

Also adds global error/rejection handlers and debug logging for
save pipeline and store reset to aid future debugging.
The format chooser dropdown (md/mdx) was clipped by overflow-hidden
parents. Switch to fixed positioning using button bounding rect so
the menu floats above all content at z-[9999].
- Added support for specifying slide file format (md/mdx) in the create and edit slide functions.
- Updated the add_slide tool description to reflect support for both Markdown and MDX formats.
- Implemented file renaming logic in editSlide to convert between formats as needed.
- Enhanced MdxRenderer to handle inline styles by converting them to JSX style objects during rendering.

These changes improve the flexibility and functionality of slide management and rendering, particularly for MDX content.
…orts

- Updated MdxRenderer to implement a caching mechanism for the MDX processor and runtime imports, improving performance by reducing redundant imports.
- Introduced a new function to handle runtime and cached imports, streamlining the compilation process.
- Replaced the previous cache key generation method with a simple string hash for better efficiency.
- Removed inline style handling logic, relying on the updated runtime for JSX style conversion.

These changes enhance the efficiency and maintainability of the MDX rendering process.
Strip console.log/warn/trace statements added during MDX debugging
from SlidePanel and presentation-store. Retains only the existing
error-level log in the saveSlideContent catch block.
@vercel

vercel Bot commented Mar 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lecta Ready Ready Preview, Comment Mar 21, 2026 10:49pm

…est cases

- Added Vitest as a testing framework to enhance testing capabilities across the project.
- Created configuration files for Vitest in both the root and mcp-server packages.
- Implemented initial test cases for various utilities and components, ensuring functionality and reliability.
- Updated package.json scripts to include test commands for running and watching tests.

These changes establish a robust testing foundation, improving code quality and maintainability.
@rikkarth
rikkarth merged commit 383eda2 into main Mar 21, 2026
2 checks passed

This branch was successfully deployed

1 active deployment
Preview — e16b4a87 Deployed Mar 21, 2026 by vercel[bot]
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.

2 participants