mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-27 04:06:52 -06:00
web: parse ?chrome= so an embedding host can leave out the title bar and File tab
#1877 added Chrome to SheetApp for hosts that embed the sheet natively, but the web build never set it: an iframe host that owns the files still draws the title bar it duplicates, and Backstage's Open/Save As can replace the document behind the host's back. Parse the flag where the other URL flags are parsed; the UI already honours Chrome, so nothing else changes. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Code
parent
3099df934e
commit
276cd0fe78
@@ -11,8 +11,9 @@
|
||||
//! URL query flags: `?webgl` forces WebGL2; `?sample=sales|budget|grades` opens a sample;
|
||||
//! `?host=parent` (inside an `<iframe>`) talks to a same-origin parent page instead: it sends the
|
||||
//! workbook to open and stores what GridCraft saves (`host`), and `&author=` names the user for
|
||||
//! notes and comments. Preferences (theme, interface size, editing options…) are kept in
|
||||
//! `localStorage` (`prefs`).
|
||||
//! notes and comments. `?chrome=none|notitlebar|nofiletab` leaves the title bar and/or the File tab
|
||||
//! undrawn for a host that embeds the sheet in its own window (see `Chrome`). Preferences (theme,
|
||||
//! interface size, editing options…) are kept in `localStorage` (`prefs`).
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
||||
@@ -60,6 +60,17 @@ pub fn start() {
|
||||
}
|
||||
let mut app = SheetApp::new(session, services);
|
||||
app.ui.system_theme = true;
|
||||
// `?chrome=none|notitlebar|nofiletab`: a host that embeds the sheet in its own window and owns the files
|
||||
// can leave the title bar and/or the File tab undrawn (`Chrome`, #1877). An unknown value keeps
|
||||
// everything, as the default does.
|
||||
if let Some(chrome) = query_param("chrome") {
|
||||
match chrome.as_str() {
|
||||
"none" => app.chrome = gridcraft_ui_egui::Chrome { title_bar: false, file_tab: false },
|
||||
"notitlebar" => app.chrome.title_bar = false,
|
||||
"nofiletab" => app.chrome.file_tab = false,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
// Follow the browser's language, except a CJK one: the web build has no system
|
||||
// CJK fonts (none are bundled), so that interface would render as tofu.
|
||||
let browser = gridcraft_ui_egui::i18n::Language::system();
|
||||
|
||||
@@ -72,6 +72,10 @@ Local test: `python3 -m http.server 8765` inside the folder, then open http://lo
|
||||
`allow-same-origin` there's no storage. Without `allow-downloads`, Save and Export (browser
|
||||
downloads) are blocked.
|
||||
- Don't send `X-Frame-Options: DENY` or a `frame-ancestors` CSP that excludes the embedding page.
|
||||
- **Window chrome:** `?chrome=none` on the iframe `src` leaves out the title bar and the File tab
|
||||
(whose Backstage view then never opens); `?chrome=notitlebar` or `?chrome=nofiletab` leave out just
|
||||
one. Use them when the host window already shows the file name and owns the files, so the sheet's
|
||||
own Open or Save As cannot replace what the host thinks is open. Everything stays on by default.
|
||||
|
||||
## Renderer selection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user