diff --git a/Cargo.lock b/Cargo.lock index c1ad344..5cadfa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -921,7 +921,7 @@ dependencies = [ [[package]] name = "pdf-presenter" -version = "0.1.7" +version = "0.1.8" dependencies = [ "font8x8", "softbuffer", diff --git a/Cargo.toml b/Cargo.toml index f7830f1..3d88311 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/pdf-presenter"] resolver = "3" [workspace.package] -version = "0.1.7" +version = "0.1.8" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/pdf-presenter" diff --git a/docs/changelog.md b/docs/changelog.md index ef250e7..e49e3d4 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,15 @@ ## Unreleased +### 0.1.8 + +- Add explicit project/all-project layout saves to the HTML concept using browser + storage. Project overrides take precedence; a reset-to-default action removes only + the current override. Two demo projects allow reviewing scope and reload behavior. + Invalid/unavailable storage reports a failure without interrupting layout editing. + Native settings remain unimplemented. Validation: JavaScript syntax, Firefox + visual inspection and 17 browser checks for scope, restoration and storage errors. + ### 0.1.7 - Extend the HTML presenter concept with a live layout panel: independently hide/show diff --git a/docs/design/presenter-menu.html b/docs/design/presenter-menu.html index fa69f09..153405e 100644 --- a/docs/design/presenter-menu.html +++ b/docs/design/presenter-menu.html @@ -10,11 +10,12 @@ header{flex-wrap:wrap}.toolbar{flex-wrap:wrap}.clock-widget{display:flex;flex-direction:column;align-items:center;min-width:0}.clock-widget small{font-size:10px;text-transform:uppercase;letter-spacing:1px}.timer{line-height:1.15;padding:0 6px}.layout-button[aria-expanded="true"]{border-color:var(--accent);color:var(--accent)} main{display:flex;flex-direction:column;min-height:430px;max-width:none}.previews{flex:1;min-height:100px;align-items:stretch;gap:16px}.previews>section{min-width:0;min-height:0;display:flex;flex-direction:column;container-type:inline-size}.previews .slide{flex:1;min-height:0;aspect-ratio:auto;padding:8%;}.slide h1,.next h1{font-size:clamp(15px,8cqw,64px);letter-spacing:-1px;margin:12px 0}.slide .eyebrow{font-size:clamp(7px,2cqw,14px)}.slide p{font-size:clamp(9px,3cqw,20px)}.slide-foot{font-size:clamp(6px,1.5cqw,10px)}.previous-preview .slide{background:#253438;color:#b4c7c9}.notes{flex:0 0 28%;min-height:70px;display:flex;flex-direction:column;margin-top:16px}.note-box{height:auto;min-height:0;flex:1}footer{flex-shrink:0;flex-wrap:wrap;margin-top:14px}#toast{flex-shrink:0}.next-hint{display:none}.caption{flex-wrap:wrap;gap:6px}.notes-tools{flex-wrap:wrap}.layout-panel{position:fixed;right:0;top:0;bottom:0;width:330px;background:#192528;border-left:1px solid #4c6368;z-index:5;padding:24px;overflow:auto;box-shadow:-15px 0 60px #0004}.layout-panel h2{font-size:22px}.layout-panel p{font-size:13px;line-height:1.5;color:var(--muted)}.layout-panel .heading{display:flex;justify-content:space-between;align-items:start}.layout-control{padding:16px 0;border-bottom:1px solid var(--line)}.layout-control>label{display:flex;align-items:center;gap:8px;font-weight:600}.layout-control input[type=checkbox]{accent-color:var(--accent);width:17px;height:17px}.size-control{display:flex;align-items:center;gap:12px;margin-top:12px;color:var(--muted);font-size:12px}.size-control input{min-width:0;width:100%;accent-color:var(--accent)}.size-control output{min-width:44px;text-align:right}.layout-panel .presets{display:flex;gap:6px;flex-wrap:wrap;margin:18px 0}.presets button{font-size:12px;padding:8px}.layout-open header,.layout-open main{margin-right:330px}.layout-panel button.close{padding:5px 9px}.layout-panel small{line-height:1.6;display:block;margin-top:18px}@media(max-width:850px){.layout-open header,.layout-open main{margin-right:0}.layout-panel{width:min(330px,90vw)}.concept{padding:8px 14px}main{padding:14px}.slide .eyebrow,.slide-foot,.slide p{display:none}.toolbar{gap:6px}.toolbar button{padding:8px}.notes{padding:12px}.kbd{display:none}} .slide-stage{flex:1;min-height:0;display:grid;place-items:center;container-type:size;background:#121c1f;border-radius:10px}.previews .slide-stage .slide{flex:none;width:min(100cqw,calc(100cqh * 16 / 9));height:auto;aspect-ratio:16/9;padding:7%;container-type:inline-size}.slide-stage .slide h1{font-size:clamp(12px,8cqw,64px)} +.layout-save{position:sticky;bottom:-24px;background:#192528;padding:16px 0 24px;border-top:1px solid var(--line);margin-top:18px;display:grid;gap:8px}.layout-save button{font-size:12px}.layout-save p{margin:0;font-size:12px}.project-picker{display:flex;gap:8px;align-items:center}.project-picker select{max-width:180px} -
INTERACTIVE CONCEPT · Mock slides and screens. No real display or system settings change.
-
P
Making room for ideasdemo.pdf · 12 slides
Elapsed00:00
Time00:00
+
INTERACTIVE CONCEPT · Mock slides and screens. No real display or system settings change.
+
P
Making room for ideasdemo.pdf · 12 slides
Elapsed00:00
Time00:00
PREVIOUS
LOOKING BACK

Start of presentation

CURRENT · 1 / 12PRESENTATION VISIBLE
BEFFROI / FIELD NOTES

Making room
for ideas.

A clear view. A little space. A better presentation.

DESIGN SESSION · NOVEMBER 2026
NEXT2 / 12
THE STARTING POINT

Keep the
focus.

Your slides go to Screen 3 · Epson projector.
Menus and notes stay on the presenter screen.
PRESENTER NOTES · auto-fit

@@ -25,10 +26,11 @@ main{display:flex;flex-direction:column;min-height:430px;max-width:none}.preview
Preview sizes share the available width. Notes size controls their share of the height; text always fits. Clock sizes control their text size. -Demo choices last while this page is open. The native app will remember visibility and sizes in your global configuration. +Project layouts override the default for all projects. Saved layouts persist in this browser; native configuration remains planned. +

Where should each view go?

Presenter = your controls and notes. Presentation = slides for viewers.
CONNECTED SCREENS · SIMULATED
Choose destinations, then Apply. Unused screens stay untouched.
Changes apply together.
-

Settings

Proposed app behavior · not operating-system settings
Remember your screens
Keep preferred screen identities, fullscreen choices and notes layout in a per-user configuration. Temporary fallback does not replace your preferred setup.
Configuration location
Linux: $XDG_CONFIG_HOME/pdf-presenter/settings.toml
Defaults to ~/.config/pdf-presenter/settings.toml
Windows: %APPDATA%\Beffroi\PdfPresenter\settings.toml
macOS: ~/Library/Application Support/Beffroi/PdfPresenter/settings.toml
Keep screens awake during presentation
Planned native feature. Includes paused and blanked output; this HTML does not inhibit sleep.
This demo remembers choices only while this page is open. The native app's global configuration is not implemented yet.
+

Settings

Proposed app behavior · not operating-system settings
Remember your screens
Keep preferred screen identities, fullscreen choices and notes layout in a per-user configuration. Temporary fallback does not replace your preferred setup.
Configuration location
Linux: $XDG_CONFIG_HOME/pdf-presenter/settings.toml
Defaults to ~/.config/pdf-presenter/settings.toml
Windows: %APPDATA%\Beffroi\PdfPresenter\settings.toml
macOS: ~/Library/Application Support/Beffroi/PdfPresenter/settings.toml
Keep screens awake during presentation
Planned native feature. Includes paused and blanked output; this HTML does not inhibit sleep.
Saved layouts persist in this browser, with project overrides above the all-projects default. Screen assignments remain session-only. The native app's global configuration is not implemented yet.
diff --git a/docs/development/tasks.md b/docs/development/tasks.md index fd65ff6..f3678a0 100644 --- a/docs/development/tasks.md +++ b/docs/development/tasks.md @@ -90,7 +90,9 @@ Depends on usable PDF output and acknowledged displayed-slide state. - [ ] T16: Show current/next previews, page selection and keyboard controls. Distinguish requested/preparing/displayed slides and blank state; keep every dialog on presenter. Let the speaker independently show/hide and resize previous/next previews, notes, - elapsed time and local HH:MM time. Hidden widgets reclaim space. Keep complete + elapsed time and local HH:MM time. Hidden widgets reclaim space. + Provide explicit project and all-project saves; project layouts override the global + default, with an action to remove the current project override. Keep complete notes fitted, and persist layout visibility/sizes in the global settings contract. Review the [interactive layout concept](../design/presenter-menu.html) before implementation. - [ ] T17: Extract available notes asynchronously and support explicit notes-page diff --git a/docs/interfaces/README.md b/docs/interfaces/README.md index 85cad06..f928ca3 100644 --- a/docs/interfaces/README.md +++ b/docs/interfaces/README.md @@ -1,6 +1,6 @@ # Persistent interfaces -The foundation writes no user settings, project files or exports. Presentation state +The native foundation writes no user settings, project files or exports. Presentation state is in memory only: page indices are zero-based and blanking retains the selected page. No file compatibility promise exists yet. @@ -13,3 +13,5 @@ Source PDFs always remain unchanged. pre-rendered image/`extraction.json` direction; its schema is not implemented yet. - [Picture folders and notes requirements](picture-folders.md) (planned). + +- [HTML concept layout storage](html-layout-storage.md) documents browser-only saved layouts. diff --git a/docs/interfaces/html-layout-storage.md b/docs/interfaces/html-layout-storage.md new file mode 100644 index 0000000..7125bdc --- /dev/null +++ b/docs/interfaces/html-layout-storage.md @@ -0,0 +1,48 @@ +# HTML concept layout storage — version 1 + +Applies only to `docs/design/presenter-menu.html`, not the native application. +The page uses browser localStorage key `pdf-presenter.menu-layouts.v1`. Storage is +scoped by the browser to the page origin; file-URL handling is browser-dependent. +It is not the native global configuration or a file saved alongside a PDF. + +The JSON envelope contains `version: 1`, `global` (null or a layout) and `projects` +(an object mapping the fixed mock project IDs `ideas` and `workshop` to layouts). +Each layout contains `previous`, `current`, `next`, `notes`, `elapsed` and `clock`. +Each widget has a boolean `show` and an integer `size`. Current is always visible. +Preview sizes are relative width weights: previous/next 30–160, current 60–200. +Notes size is a height percentage 12–65; elapsed/clock sizes are CSS pixels 16–72. +No document contents, notes, screen assignments or elapsed time are persisted. + +Load precedence: project override, global default, built-in balanced layout. +Edits and presets only affect the live view until explicitly saved. Project save +replaces that project's entire layout. All-project save replaces the global default +and preserves all project overrides. “Use all-projects default” removes the current +project override and loads the global or built-in default. Changing demo projects +or reloading discards unsaved edits. The existing Reset demo action reloads the page; +it does not erase saved layouts. + +Example (a complete all-project default without overrides): + +```json +{"version":1,"global":{"previous":{"show":true,"size":60},"current":{"show":true,"size":130},"next":{"show":true,"size":75},"notes":{"show":true,"size":28},"elapsed":{"show":true,"size":28},"clock":{"show":true,"size":28}},"projects":{}} +``` + +Reject unsupported versions, malformed envelopes, missing widgets, wrong types, +non-integer/out-of-range sizes and a hidden current slide. Limit input to 20,000 +JavaScript string code units. Ignore unknown fields/project IDs when normalizing. +Failed reads load built-in defaults with a visible status. Failed saves/removals +leave the current view and existing storage untouched; do not report success. +Unsupported/corrupt records are not overwritten by save; removing this specific +browser storage key allows recovery. No migration from other versions exists. + +The native implementation must define real project identity and per-user settings +storage separately; the mock's two project IDs are not a native compatibility contract. + +## Validation + +`tests/browser/layout-storage.js` is an explicitly invoked browser regression harness. +Append it as a script before `` in a temporary copy of the concept HTML and +open that copy in an isolated Firefox profile. It displays a PASS/FAIL report and +restores the original storage record. Covers round trips, project/global precedence, +override removal, unsaved changes, unsupported/corrupt records and failed storage. +It is not a native-application or physical-display acceptance test. diff --git a/tests/browser/layout-storage.js b/tests/browser/layout-storage.js new file mode 100644 index 0000000..1391fc6 --- /dev/null +++ b/tests/browser/layout-storage.js @@ -0,0 +1,73 @@ +// Manual browser regression harness: append to a temporary copy of the HTML concept. +// Run only in an isolated browser profile. It restores the original storage record. +window.addEventListener('load', () => { + const results = []; + const originalGet = Storage.prototype.getItem; + const originalSet = Storage.prototype.setItem; + let original; + const check = (condition, label) => { + if (!condition) throw Error(label); + results.push(label); + }; + try { + original = localStorage.getItem(layoutStorageKey); + localStorage.removeItem(layoutStorageKey); + restoreLayout(); + check(layout.notes.size === 28, 'Built-in default without saved settings'); + layout.notes.size = 42; + saveLayout('global'); + check(readLayouts().global.notes.size === 42, 'All-project default round-trips'); + layout.notes.size = 60; + layout.clock.show = false; + saveLayout('project'); + layout = structuredClone(layoutDefaults); + restoreLayout(); + check(layout.notes.size === 60 && !layout.clock.show, 'Project size and visibility restored'); + $('demoProject').value = 'workshop'; + $('demoProject').dispatchEvent(new Event('change')); + check(layout.notes.size === 42 && layout.clock.show, 'Other project inherits global default'); + layout.notes.size = 35; + saveLayout('global'); + $('demoProject').value = 'ideas'; + $('demoProject').dispatchEvent(new Event('change')); + check(layout.notes.size === 60, 'Global save preserves project override'); + $('useGlobalLayout').click(); + check(layout.notes.size === 35 && !readLayouts().projects.ideas, 'Remove override restores global default'); + layout.notes.size = 55; + restoreLayout(); + check(layout.notes.size === 35, 'Unsaved edits are not persisted'); + const saved = localStorage.getItem(layoutStorageKey); + Storage.prototype.setItem = () => { throw Error('Quota exceeded'); }; + saveLayout('project'); + check($('layoutSaveStatus').textContent.startsWith('Could not save'), 'Write failure never reports success'); + Storage.prototype.setItem = originalSet; + check(localStorage.getItem(layoutStorageKey) === saved, 'Failed save preserves stored data'); + for (const invalid of ['{', '{"version":2,"global":null,"projects":{}}', JSON.stringify({version:1,global:{},projects:{}})]) { + localStorage.setItem(layoutStorageKey, invalid); + restoreLayout(); + check(layout.notes.size === 28 && $('layoutSaveStatus').textContent.includes('could not be read'), 'Invalid/unsupported record falls back visibly'); + saveLayout('global'); + check(localStorage.getItem(layoutStorageKey) === invalid, 'Invalid saved data is not overwritten'); + } + const invalidWidget = structuredClone(layoutDefaults); + invalidWidget.clock.size = 999; + let rejected = false; + try { validateLayout(invalidWidget); } catch { rejected = true; } + check(rejected, 'Out-of-range widget rejected'); + Storage.prototype.getItem = () => { throw Error('Storage denied'); }; + restoreLayout(); + check(layout.notes.size === 28, 'Unavailable storage keeps editor usable'); + Storage.prototype.getItem = originalGet; + const report = document.createElement('pre'); + report.style = 'position:fixed;inset:0;background:#102820;color:white;padding:24px;z-index:100;font:16px monospace;overflow:auto'; + report.textContent = `PASS · ${results.length} browser checks\n\n${results.join('\n')}`; + document.body.append(report); + } catch (error) { + document.body.textContent = 'FAIL: ' + error.message; + } finally { + Storage.prototype.getItem = originalGet; + Storage.prototype.setItem = originalSet; + if (original === null) localStorage.removeItem(layoutStorageKey); + else if (original !== undefined) localStorage.setItem(layoutStorageKey, original); + } +});