Document Editor
Relevant source files
The following files were used as context for generating this wiki page:
The Document Editor is a core component of OpenHWP designed to provide editing capabilities for Korean HWP and HWPX documents. It is architected as a thin desktop shell built with Deno that delegates heavy document processing, parsing, and rendering to the rhwp engine, which is a Rust-based toolset compiled to WebAssembly.
Currently, the project is in an early development phase. While the document viewer functionality is the primary focus, the editor is a major milestone on the roadmap. The editor is intended to be implemented by embedding the @rhwp/editor package, which provides a full editing UI within an iframe, and wiring it to native file system operations via the File System Access API.
Sources: README.en.md:5-13, README.en.md:70-73
Architecture and Components
The Document Editor follows a decoupled architecture that separates the platform-specific "shell" from the platform-independent "document engine."
High-Level Architecture
The diagram shows the separation between the Deno-based desktop shell and the rhwp document engine.
Sources: README.en.md:15-22, README.md:13-19
Key Components
| Component | Description |
|---|---|
| Desktop Shell | Built using deno desktop. It serves the application UI via Deno.serve() and displays it in a native window's webview. |
| CEF Backend | Uses Chromium Embedded Framework to ensure identical rendering across macOS, Windows, and Linux while enabling modern Web APIs. |
| rhwp Engine | The core logic for HWP/HWPX parsing and rendering. The editor specifically utilizes the @rhwp/editor package. |
| File System Access API | A standard web API used to open, read, and write document files directly to the local disk without a separate native bridge. |
Sources: README.en.md:17-30, README.md:15-26
Editor Implementation Logic
The editor is integrated into the application by initializing the @rhwp/editor module and mounting it to a DOM element. This module provides a complete UI that runs within an iframe context.
import { createEditor } from "@rhwp/editor";
// Initialize and mount the editor to the #editor container
const editor = await createEditor("#editor");
Sources: README.en.md:43-47, README.md:41-45
Data Flow for File Operations
The editor leverages the File System Access API to interact with the local file system. This allows for persistent file handles, enabling "Save" functionality without repeated user prompts.
The sequence diagram illustrates the flow from picking a file to writing edited content back to the disk.
Sources: README.en.md:52-64, README.md:51-64
Development and Deployment
The Document Editor is managed through a Deno-centric toolchain. There is no dependency on Node.js or other JavaScript runtimes.
Tooling and Workflow
- Runtime: Deno ≥ 2.9.0 is required for
deno desktopfeatures. - Tasks:
deno task devis used for development, whiledeno desktop main.ts --backend cefbuilds the standalone binary. - Linting/Formatting: Standard Deno tools (
deno lint,deno fmt) ensure code quality.
Sources: CONTRIBUTING.md:12-16, CONTRIBUTING.md:23-27, README.en.md:77-85, orca.yaml:12-16
Roadmap Milestones
The full realization of the Document Editor includes:
- Embedding: Integrating
@rhwp/editorinto the Deno shell. - Persistence: Wiring "Save" and "Save As" actions to
FileSystemFileHandle. - UI Integration: Supporting native menus and multiple document windows.
- Exporting: Providing PDF export capabilities through the rhwp engine and the webview print path.
Sources: README.en.md:70-73, README.md:70-73
The Document Editor represents the transition of OpenHWP from a viewing utility to a productive office application, leveraging modern web standards and high-performance Rust components.