Skip to content

Add typing animation preview/export for code snippets #426

Description

@djoga98

Summary

I'd like to contribute typing animation support to ray.so, so code snippets can be
previewed and exported as short videos in addition to static images.

The main goal is to let users turn the current snippet into a polished typing animation
with configurable timing and export it as a browser-generated WebM video.

Before opening a PR, I wanted to check whether this direction is aligned with the project.

Proposed feature

Add typing animation support for code snippets with:

  • preview playback on the existing code frame
  • configurable duration
  • configurable frame rate
  • optional typing cursor
  • configurable export size
  • WebM export

What I have in mind

From an implementation perspective, the feature would include:

  • a typing animation dialog with preview/export controls
  • deterministic frame-based rendering instead of real-time recording
  • fixed-timestamp WebM export using WebCodecs
  • a render-state handshake with the highlighted code layer, so export waits for syntax
    rendering before capturing each frame
  • a faster export path by caching the static frame and only re-rendering the dynamic code
    layer for each typing step

UX / product direction

I also explored a cleaner separation between static and animated outputs:

  • Code Images for PNG/SVG/link export
  • Code Videos for typing animation preview/export

The idea there is to keep both experiences focused while sharing the same rendering core.

That said, I understand this may be too large for a first PR. If preferred, I can scope
the initial contribution down to:

  • adding typing animation export inside the existing code tool
  • keeping Code Videos / route split as a follow-up discussion

Notes

A few implementation details I already ran into:

  • MediaRecorder / real-time capture produced incorrect timing and stutter
  • the more reliable approach was fixed-frame export with explicit timestamps
  • webm-muxer appears deprecated, so I switched to Mediabunny for WebM output

Questions

Would you be open to this feature?

If yes, would you prefer:

  1. a smaller first PR that adds typing animation export inside the current Code Images
    flow
  2. a larger refactor that introduces a separate Code Videos surface with shared
    rendering infrastructure

I'm happy to scope it however you'd prefer before opening the PR.

Screenshots / Demo

I can also attach a short demo of the current prototype.

Suggested attachments:

  • a screenshot of the typing animation export dialog
  • a short GIF/video showing the typing preview or exported result

Image
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Severity

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions