From caf5ea509cb79ea354de2e0cb3bb56b897b59a87 Mon Sep 17 00:00:00 2001 From: Rob Date: Tue, 20 Oct 2026 11:23:18 +0100 Subject: [PATCH 01/80] Web: a ?host=parent bridge for pages that keep WordCraft's files 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 --- apps/wordcraft-web/Cargo.toml | 2 +- apps/wordcraft-web/src/host.rs | 158 +++++++++++++++++++++++++++++++++ apps/wordcraft-web/src/main.rs | 5 ++ apps/wordcraft-web/src/web.rs | 30 ++++++- crates/ui-egui/src/lib.rs | 113 ++++++++++++++++++++++- 5 files changed, 300 insertions(+), 8 deletions(-) create mode 100644 apps/wordcraft-web/src/host.rs diff --git a/apps/wordcraft-web/Cargo.toml b/apps/wordcraft-web/Cargo.toml index 9152db333..4a2a9d014 100644 --- a/apps/wordcraft-web/Cargo.toml +++ b/apps/wordcraft-web/Cargo.toml @@ -29,4 +29,4 @@ rfd = { workspace = true } wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" js-sys = "0.3" -web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlAnchorElement", "HtmlIFrameElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Event", "EventTarget", "BeforeUnloadEvent", "ClipboardEvent", "DataTransfer", "FileList", "File", "DomStringList", "IdbFactory", "IdbOpenDbRequest", "IdbRequest", "IdbDatabase", "IdbObjectStore", "IdbTransaction", "IdbTransactionMode", "MediaQueryList", "Storage"] } +web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlAnchorElement", "HtmlIFrameElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Event", "EventTarget", "BeforeUnloadEvent", "ClipboardEvent", "DataTransfer", "FileList", "File", "DomStringList", "IdbFactory", "IdbOpenDbRequest", "IdbRequest", "IdbDatabase", "IdbObjectStore", "IdbTransaction", "IdbTransactionMode", "MediaQueryList", "Storage", "MessageEvent", "UrlSearchParams"] } diff --git a/apps/wordcraft-web/src/host.rs b/apps/wordcraft-web/src/host.rs new file mode 100644 index 000000000..6a0bd8859 --- /dev/null +++ b/apps/wordcraft-web/src/host.rs @@ -0,0 +1,158 @@ +//! The `postMessage` bridge to a same-origin parent page (`?host=parent`), for pages that embed +//! WordCraft in an `