Skip to content

dbccccccc/TypstPad

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
  • πŸŒ“ 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
  • πŸ”— 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 18+ (20+ recommended)
  • 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: @myriaddreamin/typst.ts
  • 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

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

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

Topics

Resources

License

Stars

Watchers

Forks

Packages