mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-10 12:20:12 -06:00
A same-origin page that frames wordcraft-web (a Nextcloud app, a personal
file server) can now hand it a document and store what it saves, with the
same postMessage protocol as GridCraft's and PdfCraft's bridges:
wordcraft:ready / open / save {name, saveAs, bytes} / dirty / failed.
In host mode Save, Save As and Export go to the parent instead of the save
picker or a download (Services::host_save, with whether it was Save As).
Save writes the opened file under its own name and format, as the desktop
app does (an import-only .doc still becomes a .docx), and a Save or Save
As that keeps everything makes that name the document's file, so the next
Save goes to it. The parent guards leaving the page; ?author= names the
user for comments and tracked changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
//! WordCraft in the browser.
|
||
//!
|
||
//! Runs the same [`wordcraft_ui_egui::WordApp`] as the desktop app through eframe's web runner
|
||
//! (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release` from this
|
||
//! directory (output in `dist/web`).
|
||
//!
|
||
//! Differences from the desktop app: no TCP control channel; Open and Insert › Pictures use the
|
||
//! browser file picker (bytes arrive through `Services::inbox`); Save and Export download.
|
||
//! Preferences (theme, interface size, editing options…) are kept in `localStorage` (`prefs`).
|
||
//! URL flags: `?webgl` forces WebGL2; `?sample` opens the sample document.
|
||
//! `?host=parent` (inside an `<iframe>`) talks to a same-origin parent page instead: it sends the
|
||
//! document to open and stores what WordCraft saves (`host`), and `&author=` names the user for
|
||
//! comments and tracked changes.
|
||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||
|
||
#[cfg(any(target_arch = "wasm32", test))]
|
||
mod prefs;
|
||
#[cfg(any(target_arch = "wasm32", test))]
|
||
mod save_fallback;
|
||
|
||
#[cfg(target_arch = "wasm32")]
|
||
mod host;
|
||
#[cfg(target_arch = "wasm32")]
|
||
mod web;
|
||
|
||
#[cfg(target_arch = "wasm32")]
|
||
fn main() {
|
||
web::start();
|
||
}
|
||
|
||
#[cfg(not(target_arch = "wasm32"))]
|
||
fn main() {
|
||
eprintln!("wordcraft-web only runs in the browser: build it with `trunk build --release` in apps/wordcraft-web");
|
||
}
|