A modern Typst editor built entirely in Rust using WebAssembly. Available as both a web application and a native desktop app (via Tauri). Write and preview Typst documents with real-time compilation, syntax highlighting, and multi-page support.
- π 100% Rust + WASM - No JavaScript required, fully compiled to WebAssembly
- π Live Preview - Real-time Typst compilation as you type
- π¨ Syntax Highlighting - VSCode Dark+ theme with comprehensive Typst syntax support
- π Multi-page Documents - Proper rendering of documents with multiple pages
- π Bibliography Support - Dynamic Hayagriva YAML bibliography with file resolver integration
- πΌοΈ Image Gallery - Upload, manage, and embed images with IndexedDB storage and sequential IDs (001-999)
- π₯ PDF Export - Download your documents as PDF files
- πΎ Auto-save - Automatic localStorage persistence of your work
- π Dark Theme - Eye-friendly dark editor interface
- π± Responsive - Works on desktop and mobile devices
- π IEEE Templates - Built-in support for IEEE-style academic papers
- π Dual Mode Editor - Switch between source code and visual editing modes
- π Web App - Run in any modern browser, deploy to GitHub Pages/Netlify
- π₯οΈ Desktop App - Native application for Windows, Linux, and macOS via Tauri
- π¦ Same Codebase - Single codebase for both web and desktop deployments
- Rust - Systems programming language
- Leptos 0.8 - Reactive web framework for Rust
- typst-as-lib - Typst compilation engine
- Tailwind CSS + DaisyUI - Styling framework
- Iconify - Icon library
- Trunk - WASM web application bundler
- Tauri 2.8 - Native desktop application framework
Before you begin, ensure you have the following installed:
- Rust (nightly toolchain)
- wasm32-unknown-unknown target
- Trunk - WASM bundler
# Install Rust nightly
rustup toolchain install nightly --allow-downgrade
# Add WASM target
rustup target add wasm32-unknown-unknown
# Install Trunk
cargo install trunk
π TL;DR? See QUICK_START.md for a concise command reference.
Clone the repository and start the web development server:
# Install Node dependencies (for Tailwind CSS)
npm install
# Build Tailwind CSS
npm run build-css
# Start web development server
trunk serve --open
This will:
- Compile the Rust code to WASM
- Start a local server at
http://localhost:1420
- Open the app in your default browser
- Watch for file changes and auto-reload
Run as a native desktop application:
# Install dependencies (first time only)
npm install
# Start desktop app with hot-reload
npm run tauri:dev
# or
cargo tauri dev
This will:
- Start trunk serve automatically
- Compile the Tauri backend
- Open a native desktop window
- Enable hot-reload for both frontend and backend
Build an optimized web version:
# Build for production (GitHub Pages)
trunk build --config Trunk-release.toml
# Or for standard release
trunk build --release
The compiled files will be available in the docs/
directory (GitHub Pages) or dist/
directory (standard), ready to be deployed to any static hosting service.
GitHub Pages Deployment: The project includes a GitHub Actions workflow (.github/workflows/deploy.yml
) that automatically builds and deploys to GitHub Pages on push to main/master branch.
Build native desktop installers:
# Build desktop app for your platform
npm run tauri:build
# or
cargo tauri build
The installers will be generated in src-tauri/target/release/bundle/
:
- Linux:
.deb
,.AppImage
,.rpm
- Windows:
.msi
,.exe
- macOS:
.dmg
,.app
Installer Size: ~85-100 MB (includes Tauri runtime + WASM bundle)
wasm-typst-studio-rs/
βββ src/ # Frontend Leptos app (shared by web & desktop)
β βββ lib.rs # Main application entry point
β βββ main.rs # WASM entry point
β βββ compiler/
β β βββ typst.rs # Typst compilation wrapper with static file resolver
β β βββ mod.rs
β βββ components/ # UI components
β β βββ editor.rs
β β βββ preview.rs
β β βββ image_gallery.rs
β β βββ mod.rs
β βββ utils/
β βββ highlight.rs # Syntax highlighting implementation
β βββ image_manager.rs # Image management with sequential IDs
β βββ image_storage.rs # IndexedDB for image storage
β βββ mod.rs
βββ src-tauri/ # Tauri backend (desktop only)
β βββ src/
β β βββ main.rs # Desktop app entry point
β β βββ lib.rs # Tauri setup and configuration
β βββ Cargo.toml # Backend dependencies
β βββ tauri.conf.json # Tauri configuration
β βββ build.rs # Build script
β βββ capabilities/ # Permission system
β βββ icons/ # App icons for different platforms
βββ public/
β βββ favicon.ico
βββ examples/
β βββ example.typ # Default example document
β βββ example2.typ # IEEE template example
β βββ refs.yml # Bibliography in Hayagriva YAML format
βββ .github/
β βββ workflows/
β βββ deploy.yml # GitHub Pages deployment workflow
βββ index.html # HTML template (web)
βββ tailwind.css # Tailwind CSS with custom styles
βββ tailwind.config.js # Tailwind configuration
βββ Trunk.toml # Trunk configuration (development)
βββ Trunk-release.toml # Trunk configuration (production/GitHub Pages)
βββ Cargo.toml # Frontend Rust dependencies
βββ package.json # Node dependencies (Tailwind + scripts)
βββ rust-toolchain.toml # Rust toolchain version
βββ README.md # This file
βββ TAURI_INTEGRATION.md # Detailed Tauri integration guide
- Type your Typst markup in the left panel (Source)
- See the live preview in the right panel (Preview)
- Your work is automatically saved to localStorage
- Click the "Images" button in the toolbar to open the Image Gallery
- Upload an image file (PNG, JPG, JPEG, GIF, WebP, SVG)
- Images are automatically assigned sequential IDs (001, 002, ..., 999)
- Click "Copy ID" to copy the image ID
- Use it in your Typst code:
#figure( image("001.png"), caption: [Your image caption] )
Image Gallery Features:
- Sequential 3-digit IDs for easy reference
- Preview thumbnails with filename display
- Copy ID and delete operations
- Persistent storage using IndexedDB
- Drag-and-drop upload support
- Click the "Bibliography" button in the toolbar to open the Bibliography Manager
- Edit your references in Hayagriva YAML format:
netwok2020: type: article title: "The Challenges of Scientific Typesetting" author: ["Network, A.", "Smith, B."] date: 2020 journal: "Journal of Academic Publishing"
- Reference them in your document:
According to @netwok2020, this is correct. = References #bibliography("refs.yml")
How it works:
- Bibliography is stored in localStorage and registered as a virtual file (
refs.yml
) - Uses typst-as-lib's static file resolver to provide the file to the compiler
- Supports all Hayagriva YAML entry types (article, book, web, etc.)
Click the "PDF" button in the toolbar to download your document as a PDF file.
The editor comes pre-loaded with comprehensive examples including:
- Text Formatting - Bold, italic, strikethrough, colors, sizes
- Lists - Unordered, ordered, nested, term lists
- Code Blocks - Syntax-highlighted code in multiple languages
- Mathematics - Inline and display formulas, matrices, equations
- Tables - Simple and styled tables
- Figures - Images and captions with cross-references
- Advanced Layout - Columns, boxes, blocks
Development configuration with local URLs:
[build]
target = "index.html"
dist = "dist"
public_url = "/"
[serve]
port = 3000
Production configuration for GitHub Pages:
[build]
target = "index.html"
dist = "docs"
public_url = "/wasm-typst-studio-rs/" # Must match your repository name
release = true
minify = "always"
To build for GitHub Pages:
trunk build --config Trunk-release.toml
Specify the Rust toolchain version:
[toolchain]
channel = "nightly-2025-01-01"
targets = ["wasm32-unknown-unknown"]
- System Fonts - Not available in WASM; uses embedded fonts only
- File System - No direct file system access; uses IndexedDB for images and virtual file resolver for bibliography
- Large Documents - Very large documents may experience performance degradation
- Image Limit - Maximum 999 images per session (sequential ID constraint)
- External Resources - Cannot load external files or packages (all resources must be embedded)
- Most web limitations are resolved or can be addressed with Tauri APIs
- File System Access - Can be added via Tauri commands (see
TAURI_INTEGRATION.md
) - Native Dialogs - Open/Save dialogs available
- System Fonts - Still limited by WASM constraints in current implementation
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly:
trunk serve
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Rust conventions and use
cargo fmt
- Ensure all code compiles without warnings:
cargo check
- Test WASM compilation:
trunk build
- Keep dependencies minimal and well-justified
- Document public APIs and complex logic
This project is licensed under the MIT License - see the LICENSE file for details.
- Typst - The amazing typesetting system
- Leptos - Reactive Rust web framework
- typst.ts - Typst WASM integration
- Trunk - WASM build tooling
- Tauri Documentation
- Tauri + Leptos Guide
- TAURI_INTEGRATION.md - Detailed integration guide for this project
- Tauri API Reference
This project supports both web and desktop deployments from the same codebase. For detailed information about:
- Desktop-specific features
- Tauri configuration
- Native API integration
- File system access
- Building and distributing desktop apps
See TAURI_INTEGRATION.md for the complete guide.
- README.md - Main documentation (this file)
- QUICK_START.md - Quick command reference
- TAURI_INTEGRATION.md - Desktop app integration guide
- info/BUILD_REQUIREMENTS.md - System requirements and packages for each OS
- info/OPTIMIZATION_REPORT.md - Complete optimization analysis and recommendations
- info/OPTIMIZATIONS_APPLIED.md - Implemented optimizations details
- info/OPTIMIZATIONS_SUMMARY.md - Quick optimization results overview
Built with β€οΈ using Rust, WebAssembly, and Tauri