Skip to content

Repository files navigation

TypstPad

A simple and elegant online Typst formula editor with real-time preview.

theme-comparison

License ghcr pulls

✨ Features

  • 🎨 Real-time Preview - See your Typst formulas rendered instantly
  • πŸ“ Monaco Editor - Professional code editing experience with syntax highlighting
  • πŸ”€ Auto Complete - Intelligent Typst symbol and function suggestions
  • πŸŒ“ Theme Support - Light, dark, and system theme modes
  • πŸ“€ Multiple Export Formats
    • PNG (transparent background)
    • JPG (white background)
    • SVG (vector graphics)
    • HTML
    • Typst source code
  • πŸ“‹ Clipboard Support - Copy images and code directly to clipboard
  • πŸ”Ž Image to Typst (Experimental) - Recognize a tightly cropped printed formula locally in your browser
  • πŸ”— Share Links - Generate shareable URLs with encoded formulas
  • πŸ’Ύ Formula Library - Save and manage your formulas locally
    • Auto-save draft for seamless workflow
    • Save, load, rename, and delete formulas
  • βš™οΈ Customizable Settings
    • Adjustable font size
    • Line numbers toggle
    • PNG export scale (1x-4x)
    • Dark mode preview options

πŸš€ Quick Start

Prerequisites

  • Node.js 20+
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/dbccccccc/TypstPad.git

# Navigate to project directory
cd TypstPad

# Install dependencies
npm install

Development

# Start development server
npm run dev

Visit http://localhost:5173 to see the application.

Build

# Build for production
npm run build

# Preview production build
npm run preview

🐳 Docker Deployment

Using Pre-built Image

Pull and run the latest stable version from GitHub Container Registry:

# Pull the latest image
docker pull ghcr.io/dbccccccc/typstpad:latest

# Run the container
docker run -d -p 8080:80 --name typstpad ghcr.io/dbccccccc/typstpad:latest

# Access the application
# Open http://localhost:8080 in your browser

Using Specific Version

# Pull a specific version
docker pull ghcr.io/dbccccccc/typstpad:v1.0.0

# Run the container
docker run -d -p 8080:80 ghcr.io/dbccccccc/typstpad:v1.0.0

Build Docker Image Locally

# Build the image
docker build -t typstpad .

# Run the container
docker run -d -p 8080:80 --name typstpad typstpad

# Stop the container
docker stop typstpad

# Remove the container
docker rm typstpad

Docker Compose

Create a docker-compose.yml file:

version: '3.8'

services:
  typstpad:
    image: ghcr.io/dbccccccc/typstpad:latest
    ports:
      - "8080:80"
    restart: unless-stopped

Then run:

docker-compose up -d

Important Notes

  • The Docker image includes Nginx with required CORS headers for SharedArrayBuffer support
  • Default port is 80 inside the container, map it to any host port you prefer
  • Currently supports linux/amd64 platform

πŸ› οΈ Tech Stack

  • Frontend Framework: React 18
  • Language: TypeScript
  • Build Tool: Vite
  • Styling: Tailwind CSS
  • Editor: Monaco Editor
  • Syntax Highlighting: Shiki
  • Typst Rendering: Typst 0.14.2 via @myriaddreamin/typst.ts 0.7
  • UI Components: Radix UI
  • Icons: Lucide React

πŸ“ Project Structure

typstpad/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ Editor/           # Monaco editor component
β”‚   β”‚   β”œβ”€β”€ Preview/          # Typst preview component
β”‚   β”‚   β”œβ”€β”€ ExportPanel/      # Export and share functionality
β”‚   β”‚   β”œβ”€β”€ SettingsDialog/   # Settings configuration
β”‚   β”‚   β”œβ”€β”€ Header/           # Application header
β”‚   β”‚   β”œβ”€β”€ ErrorDisplay/     # Error message display
β”‚   β”‚   └── ui/               # Reusable UI components
β”‚   β”œβ”€β”€ contexts/
β”‚   β”‚   └── ThemeContext.tsx  # Theme management
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── typst.ts          # Typst compilation service
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ export.ts         # Export utilities
β”‚   β”‚   β”œβ”€β”€ share.ts          # Share URL generation
β”‚   β”‚   └── shikiSetup.ts     # Syntax highlighting setup
β”‚   β”œβ”€β”€ grammars/
β”‚   β”‚   └── typst.tmLanguage.json  # Typst language grammar
β”‚   β”œβ”€β”€ App.tsx               # Main application component
β”‚   β”œβ”€β”€ main.tsx              # Application entry point
β”‚   └── index.css             # Global styles
β”œβ”€β”€ public/                   # Static assets
β”œβ”€β”€ index.html                # HTML template
β”œβ”€β”€ package.json              # Dependencies and scripts
β”œβ”€β”€ tsconfig.json             # TypeScript configuration
β”œβ”€β”€ vite.config.ts            # Vite configuration
└── tailwind.config.js        # Tailwind CSS configuration

πŸ“– Usage

Basic Example

  1. Enter your Typst formula in the editor:

    $ sum_(i=1)^n i = (n(n+1))/2 $
  2. See the rendered preview in real-time

  3. Export or share:

    • Click "Export Image" to download as PNG/JPG/SVG
    • Click "Export Code" to copy/download the source code
    • Click "Share" to generate a shareable URL

Image to Typst (Experimental)

Select Image to Typst in the input panel, then choose, drop, or paste a PNG, JPEG, or WebP image containing one tightly cropped printed formula. Recognition runs locally in the browser; the image is not uploaded. Review every generated token before placing the draft in the editor.

The included Phase 10 IBEM model is experimental and is substantially less accurate on long or displayed formulas. It is not intended for handwriting, full-page segmentation, photographs, or arbitrary screenshots. See the bundled model card and third-party notices under public/im2typst for qualification, provenance, and license details.

Settings

Access settings by clicking the gear icon in the header.

Keyboard Shortcuts

  • Standard Monaco editor shortcuts apply
  • See Monaco Editor documentation for complete list

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ—ΊοΈ Roadmap

  • Formula library for saving and managing formulas
  • Multi-language support
  • More export format support

Made with ❀️ using Typst

About

TypstPad is an online Typst formula editor for creating, previewing, and exporting math formulas.

Topics

Resources

Stars

31 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages