MCPcopy
hub / github.com/ranuts/document

github.com/ranuts/document @v0.0.4 sqlite

repository ↗ · DeepWiki ↗ · release v0.0.4 ↗
9,209 symbols 22,997 edges 57 files 72 documented · 1%
README

OnlyOffice Web

CI Status License Version Live Demo

English | 中文

A privacy-first, browser-based document editor powered by OnlyOffice. Edit DOCX, XLSX, PPTX, and CSV files directly in your browser — no server, no uploads, no account required.


✨ Features

  • 🔒 Privacy-first — all processing happens locally, nothing is uploaded
  • 📝 Multi-format — DOCX, XLSX, PPTX, CSV and more
  • 🚀 No server required — pure frontend, deploy anywhere
  • 🌐 Open from URL — load documents via ?src= or ?file= parameters
  • 📦 PWA support — install and use offline
  • 🌍 Multi-language — English, Chinese, and more
  • 🧩 Embeddable — full postMessage API for iframe integration

🚀 Quick Start

Try it online: ranuts.github.io/document

Run with Docker:

docker run -d --name document -p 8080:80 ghcr.io/ranuts/document:latest

Run locally:

git clone https://github.com/ranuts/document.git
cd document
pnpm install
pnpm run dev

📖 Usage

Open a document

  1. Click the upload button to open a local file, or
  2. Pass a URL via query parameter: ?src=https://example.com/document.docx

Remote URLs must support CORS.

URL parameters

Parameter Description Priority
src Open document from URL (recommended) Low
file Open document from URL (legacy) High
locale Set interface language (en, zh)

When both src and file are present, file takes priority.

PWA offline usage

Visit the editor over HTTPS (or localhost), then click the Install icon in the address bar. Once installed, the editor works without an internet connection.

Service Workers don't work over file://. Use a local server or the installed PWA.

As a component library

This project powers the document preview component in @ranui/preview.

📚 Preview component docs


🧩 Embedding via iframe

Embed the editor in your application and control it via postMessage. The recommended pattern is: the parent system handles auth and file upload; the iframe handles editing only.

<iframe
  id="documentEditor"
  src="https://your-deployment/?embed=1"
  style="width: 100%; height: 720px; border: 0"
></iframe>
// Open a document
iframe.contentWindow.postMessage(
  { id: '1', type: 'document:open-url', payload: { url: 'https://example.com/doc.xlsx' } },
  'https://your-deployment',
);

// Listen for the result
window.addEventListener('message', (e) => {
  if (e.data?.type === 'document:opened') console.log('Ready to edit');
  if (e.data?.type === 'document:saved') uploadFile(e.data.payload.file);
});

Full API reference — all message types, options, and examples including auth, read-only mode, and save flow.


🚀 Deployment

This is a pure static app — build once, deploy anywhere.

pnpm build   # outputs to dist/

GitHub Pages

Push to main and the included workflow (.github/workflows/pages-build-site.yml) builds and deploys automatically. Enable GitHub Pages in your repo settings and set the source to GitHub Actions.

Static hosting (Nginx, Vercel, Netlify, Cloudflare Pages…)

Upload the contents of dist/ to any static host. No server-side runtime needed.

For Nginx, serve index.html as the fallback for all routes:

location / {
  root /var/www/document;
  try_files $uri $uri/ /index.html;
}

Docker

# Basic
docker run -d --name document -p 8080:80 ghcr.io/ranuts/document:latest

# With HTTPS and basic auth
docker run -d --name document -p 443:443 \
  -v /path/to/certs:/ssl \
  -e SERVER_BASIC_AUTH='user:$2y$...' \
  -e SERVER_HTTP2_TLS=true \
  -e SERVER_HTTP2_TLS_CERT=/ssl/cert.pem \
  -e SERVER_HTTP2_TLS_KEY=/ssl/key.pem \
  ghcr.io/ranuts/document:latest

SERVER_BASIC_AUTH uses BCrypt-hashed passwords. Replace $ with $$ in the hash for shell escaping.


🔤 Fonts

This project does not include proprietary fonts (Arial, Times New Roman, etc.) to comply with open-source licensing. Font name references are preserved for document compatibility.

Font management guide — how to add fonts by index.


📚 References

🤝 Contributing

Issues and pull requests are welcome!

📄 License

AGPL-3.0

Extension points exported contracts — how you extend this code

Window (Interface)
(no doc)
index.ts
PluginConfig (Interface)
(no doc)
types/editor.d.ts
EmscriptenFileSystem (Interface)
(no doc)
lib/document-types.ts
RenderOfficeData (Interface)
(no doc)
lib/events.ts
I18nMessages (Interface)
(no doc)
lib/i18n.ts
DocEditorConfig (Interface)
(no doc)
types/editor.d.ts
EmscriptenModule (Interface)
(no doc)
lib/document-types.ts
SaveEvent (Interface)
(no doc)
types/editor.d.ts

Core symbols most depended-on inside this repo

$
called by 4039
public/sdkjs/word/sdk-all-min.js
get
called by 3299
public/wasm/x2t/x2t.js
e
called by 399
public/sdkjs/cell/sdk-all.js
U
called by 393
public/sdkjs/cell/sdk-all.js
K
called by 389
public/sdkjs/slide/sdk-all.js
A
called by 370
public/sdkjs/word/sdk-all.js
e
called by 356
public/sdkjs/slide/sdk-all.js
e
called by 334
public/sdkjs/word/sdk-all.js

Shape

Function 9,116
Method 64
Interface 17
Class 10
Enum 2

Languages

TypeScript100%

Modules by API surface

public/sdkjs/cell/sdk-all.js2,477 symbols
public/sdkjs/word/sdk-all.js2,288 symbols
public/sdkjs/slide/sdk-all.js2,255 symbols
public/libs/sheetjs/xlsx.full.min.js965 symbols
public/wasm/x2t/x2t.js326 symbols
public/sdkjs/cell/sdk-all-min.js113 symbols
public/sdkjs/word/sdk-all-min.js112 symbols
public/sdkjs/slide/sdk-all-min.js111 symbols
public/web-apps/apps/documenteditor/main/app.js109 symbols
public/web-apps/apps/spreadsheeteditor/main/app.js108 symbols
public/web-apps/apps/presentationeditor/main/app.js108 symbols
public/sdkjs/common/Native/jquery_native.js32 symbols

Dependencies from manifests, versioned

@khmyznikov/pwa-install0.6.3 · 1×
@playwright/test1.60.0 · 1×
@types/node25.9.1 · 1×
@vitest/coverage-v84.1.7 · 1×
jsdom29.1.1 · 1×
oxlint1.67.0 · 1×
postcss8.5.15 · 1×
prettier3.8.3 · 1×
ranui0.1.10-alpha-27 · 1×
ranuts0.1.0-alpha-23 · 1×
tailwindcss4.3.0 · 1×

For agents

$ claude mcp add document \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact