Skip to content

Repository files navigation

📝 OpenWord

OpenWord is a professional, high-fidelity, client-side word processor built with React, TypeScript, and Tiptap. It simulates a premium Microsoft Word desktop interface directly in your browser, featuring virtual pagination, dynamic margins, a responsive floating ribbon menu, auto-saving, dark mode support, and a hybrid local AI engine.

🚀 Use Live or Run Locally

  • ⚡ Launch the App Live: You can use the fully featured word processor directly in your browser with zero setup: Use OpenWord Live on GitHub Pages.
  • 💻 Download & Customize: The project is 100% open-source. You can clone the repository, run it locally, adapt the components, or host it yourself under your own domain.

Live Demo Buy Me A Coffee React Version TypeScript Vite License: MIT

OpenWord Workspace Preview - Light Mode

OpenWord Workspace Preview - Dark Mode


🚀 The Value Proposition: 100% Client-Side & Private

Unlike standard cloud word processors, OpenWord is an offline-first, zero-server application.

  • Privacy-First: Your documents are never uploaded to any external server. All text processing, imports, database updates, and document compilation occur directly in your browser sandbox.
  • No Accounts Needed: Start drafting immediately. Your workspace recovers itself automatically on restart using client-side IndexedDB persistence.
  • Local AI Execution: Generative AI features run 100% locally on your computer's GPU/CPU (via WebGPU or a local Ollama daemon), meaning your text prompts never leave your device.

✨ Features Breakdown

📁 Page Layout & Print Precision

  • Virtual A4/Letter Pagination: Visual page breaks that automatically calculate paragraph and node heights in real-time, inserting clean page lines exactly like a physical layout.
  • Zoom-Scaled Margin Ruler: Drag-and-drop margin handles to adjust left and right margins dynamically. The cursor tracking scales mathematically to match your current document zoom level.
  • Dynamic Headers & Footers: Set customized running header and footer text zones that automatically overlay relative to page margins.

🎨 Premium Desktop Aesthetics

  • Auto-Collapsing Ribbon: An interactive ribbon toolbar matching Microsoft Word's layout. It collapses into tabs automatically to maximize vertical reading space and slides open on hover.
  • Direct Title Bar Renaming: Edit the document filename directly inside the Windows-styled Title Bar input.
  • Sidebar Navigation Outline: Auto-updating outline list based on heading tags to navigate large documents quickly.
  • Aesthetic Theme Selector: Seamless light-to-dark canvas transition via the bottom Status Bar.

🤖 Local Offline AI Copilot

OpenWord hosts a highly advanced local AI client supporting two execution modes:

  1. Ollama mode (Local Daemon): Connects to a local Ollama instance running on port 11434. Includes automated hardware checking (profiling GPU VRAM to recommend models) and one-click daemon launching.
  2. WebGPU mode (In-Browser): Runs models directly inside your browser tab without any native backend software.
  • Hybrid WebGPU Engines:
    • Google LiteRT-LM (TFLite): Automatically routes Gemma 4 E2B to Google's official, highly optimized LiteRT runtime. It streams .litertlm model weights, caches them in Cache Storage for instant startup, and utilizes optimized shaders to prevent browser OOM crashes.
    • WebWorker MLC Engine: Runs Llama 3.2 1B, Gemma 2 2B, Qwen, and Phi models off the main thread.
  • Web Worker Offloading: Moving 100% of WebGPU execution, model compilation, and downloading to a background thread to keep the user interface fully responsive at 60fps.
  • Mobile memory safeguards: Automatically detects mobile user agents to cap context windows to 1024 tokens and sliding windows to -1 to avoid VRAM exhaustion crashes. Includes warnings for high-memory models.
  • Ollama Fallback Switcher: If Ollama is offline or the user lacks VRAM (under 3GB), the UI suggests switching to WebGPU mode to run lighter models (Llama 3.2 1B) in-browser.
  • Dual Document-Editing Modes:
    • Direct Edit Mode (Real-Time): Streams AI edits directly into the document editor in real-time.
    • Proposal Mode (Visual Diff): Streams changes to a sidebar visual diff card (rendered with green/red additions/deletions), allowing you to review edits and click Accept & Apply or Reject before mutating the document.
  • Robust XML Tool Actions: Parses structural document actions (<edit_block>, <insert_block>, <delete_block>) dynamically, supporting arbitrary attribute order, spacing, and quote styles.

🔒 Client-Side Storage & IO

  • IndexedDB Autosave: Background saving to IndexedDB (v2) with an automatic session recovery dialog on startup.
  • Zero-Server Exports: Export documents directly to Microsoft Word .docx format using client-side XML packaging.
  • Mammoth HTML Importer: Import local document formats directly into the editor canvas.

⚙️ Architecture & Data Flow

OpenWord separates UI rendering from document state and heavy AI workloads using Web Workers and Service Caches:

                                 +--------------------------------+
                                 |       Tiptap/ProseMirror       |
                                 +--------------------------------+
                                                 |
                                       (onUpdate Event / JSON)
                                                 v
                                 +--------------------------------+
                                 |  React DocumentContext State   |
                                 +--------------------------------+
                                    /           |              \
                                   /            |               \
                   (Debounced 5s) /             | (150ms Break)  \ (Chat Prompts)
                                 v              v                 v
                  +---------------+  +---------------+  +--------------------------+
                  |   IndexedDB   |  |   Pagination  |  |  AI Switcher Controller  |
                  |    Storage    |  |   Extension   |  |     (webllm.ts helper)   |
                  +---------------+  +---------------+  +--------------------------+
                                                           /                    \
                                                  (Provider: 'webllm')    (Provider: 'litert')
                                                         /                        \
                                                        v                          v
                                           +-----------------------+     +--------------------+
                                           | WebWorker MLC Engine  |     |  Google LiteRT-LM  |
                                           |  (WASM Background)    |     |   (Object URL)     |
                                           +-----------------------+     +--------------------+
                                                        |                          |
                                                        v                          v
                                                 [Cache Storage]            [Cache Storage]
                                                  (webllm-cache)            (litert-lm-cache)

📂 Directory Structure

├── public/                 # Static assets (Favicons, screenshots)
├── src/
│   ├── assets/             # Brand logos and SVGs
│   ├── components/         # Workspace UI layout blocks
│   │   ├── Editor/         # Custom extensions and pagination logic
│   │   ├── Ribbon/         # Toolbar operations (Font, spacing, view)
│   │   ├── Ruler/          # Interactive margin ruler
│   │   ├── Sidebar/        # Outline & local AI Copilot panel
│   │   └── StatusBar/      # Page counter, layout toggles, theme switcher
│   ├── context/            # Global Document layout & editing state
│   ├── styles/             # Harmony CSS variables & dark theme tokens
│   ├── utils/              # Exporters, DB helpers, Web Worker handlers, LiteRT-LM wrappers
│   ├── App.tsx             # Application shell
│   └── main.tsx            # App bootstrapping
├── package.json            # Deployment scripts and dependencies
└── vite.config.ts          # Vite build config & subpath routing

🛠️ Getting Started

Prerequisites

Make sure you have Node.js installed.

Installation

  1. Clone the repository:

    git clone https://github.com/RorriMaesu/OpenWord.git
    cd OpenWord
  2. Install dependencies:

    npm install
  3. Start local development server:

    npm run dev

    Open http://localhost:5173 in your browser.

Building for Production

npm run build

This generates a static website inside the dist/ directory.

Deploying to GitHub Pages

npm run deploy

This builds the application and deploys the static files to your repository's gh-pages branch.


🗺️ Roadmap

  • Custom margin presets (Narrow, Moderate, Wide).
  • Full Page-Break rendering inside document export (.docx parser compatibility).
  • Custom page dimensions selector (Letter, Legal, Executive, A4).
  • Advanced keyboard shortcuts helper card.

📄 License

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

About

A premium, offline-first document editor powered by an autonomous local AI agent. Connects to Ollama (Llama/Gemma) to autonomously edit paragraphs, delete blocks, or insert headings directly in the editor with real-time visual diff previews.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages