ELNOR REPO READER TEXT MIRROR Original path: Current Specs/DOC20/DOC20_ADDENDUM_B_MS_WORD_VIEWER_CAPABILITIES_R3.md Source repo: /Users/OpenClaw1/Elnor/Elnor Specs Git branch: main Git commit: dbaa25962edc11ab30e8d4ca1715f9ae5bf77331 Generated: 2026-06-09T01:23:58.539Z --- # DOC20 Addendum B: Document Viewer & Editor Capabilities (R3) **Date:** 2026-04-10 **Version:** R3 — copy-on-write system policy for agent edits, tracked changes always in copies, enforcement at system level **Status:** Front-end build specification — designed for immediate implementation before backend/EC specs are complete **Scope:** Document viewing and editing capabilities for .docx (and .pdf) files within Q Dashboard's Electron app **Dependencies:** OnlyOffice Document Server (bundled), Microsoft Graph API, Azure AD app registration --- ## 0. Implementation Context **This addendum is intended for the front-end build phase.** It does not rely on any ELNOR backend infrastructure (EC, OpenClaw, DOC16 M365 integration). Everything described here runs locally in Electron or connects directly to Microsoft's APIs using OAuth tokens stored locally. When the full backend is built later: - DOC16 Entry 16.7 will add Elnor's `elnor@schallfirm.com` agentic identity for M365 — this layers on top without changing anything built here - EC will manage document state and metadata — the Document Viewer component doesn't change, it just gets richer context - DOC72 will extract entities from documents — this reads the same files Q already accesses **Nothing built in this addendum needs to be reworked later.** --- ## 1. Architecture Overview ### 1.1 Three-Tier Document Editor When a user clicks a .docx file anywhere in Q (browser results, Places, bookmarks bar, file drop, chat attachment), the Document Viewer opens with OnlyOffice as the default editor. Two additional editing options are available via toolbar buttons. | Tier | Engine | Capability | When to Use | |------|--------|-----------|-------------| | **Default Editor** | OnlyOffice Document Editor | Full local editing — tracked changes, comments, styles, line numbering, tables, footers, headers. Works offline. No internet required. | Default on click. Handles 90% of cases. | | **Word Online** | Microsoft Word Online (in Q web tab) | Full Microsoft rendering engine. Perfect formatting fidelity. Requires internet + OneDrive. | Click "Open in Word Online" button. For formatting-critical final documents. | | **Desktop Word** | Native Microsoft Word app | Full native Word. Launches externally. | Click "Open in Desktop Word" button. Nuclear option. | ### 1.2 File Location Detection Every .docx file falls into one of three categories based on its local path: | Location | Detection | OnlyOffice Edit | Word Online Edit | |----------|-----------|-----------------|-----------------| | **Firm OneDrive** | Path contains `OneDrive-SharedLibraries-schallfirm.com` | ✅ Opens immediately (local file) | ✅ Resolves to SharePoint URL | | **Personal OneDrive** | Path contains `OneDrive-Personal` or `OneDrive` (user's personal sync) | ✅ Opens immediately (local file) | ✅ Resolves to SharePoint URL | | **Local-only** | Path does not match any OneDrive sync folder | ✅ Opens immediately (local file) | ✅ Auto-uploads to ELNOR Working folder first | Note: OnlyOffice opens ALL files immediately regardless of location. Word Online requires OneDrive, so local-only files need uploading first. ### 1.3 PDF Viewing | Format | Engine | Capabilities | |--------|--------|-------------| | .pdf | PDF.js | View, zoom, search, text selection, clip-to-note, print. No annotation (future: evaluate PSPDFKit for annotation/redaction). | --- ## 2. OnlyOffice Integration ### 2.1 Architecture OnlyOffice has two components that must be bundled with Q: 1. **OnlyOffice Document Server** — a backend service (Node.js) that handles document rendering, conversion, and real-time collaboration. Runs as a child process on localhost. 2. **OnlyOffice Document Editor** — a web-based frontend loaded in an iframe, pointed at the local Document Server. ``` Q Electron App ├── Main Process │ ├── Electron BrowserWindow │ └── OnlyOffice Document Server (child process, localhost:8443) └── Renderer Process └── Document Viewer Component └──