Save presenter layouts per project or as the global default

This commit is contained in:
Dandaedre 2026-11-19 16:32:18 +01:00
parent 5162bce0a6
commit d171dd51c9
8 changed files with 175 additions and 9 deletions

2
Cargo.lock generated
View File

@ -921,7 +921,7 @@ dependencies = [
[[package]]
name = "pdf-presenter"
version = "0.1.7"
version = "0.1.8"
dependencies = [
"font8x8",
"softbuffer",

View File

@ -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"

View File

@ -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

View File

@ -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}
</style>
</head>
<body>
<div class="concept"><span><strong>INTERACTIVE CONCEPT</strong> · Mock slides and screens. No real display or system settings change.</span><label>Test setup <select id="topology"><option value="3">3 screens</option><option value="4">4 screens</option><option value="2">Projector disconnected</option><option value="1">Laptop only</option></select></label></div>
<header><span class="brand">P</span><button id="menuButton" aria-expanded="false" aria-controls="menu">☰ Menu</button><div class="doc"><b>Making room for ideas</b><small>demo.pdf · 12 slides</small></div><div class="toolbar"><button id="displayButton">Displays · 1 → 3</button><button id="blankButton">Blank presentation</button><button id="layoutButton" class="layout-button" aria-controls="layoutPanel" aria-expanded="false">Layout</button><div id="elapsedWidget" class="clock-widget"><small>Elapsed</small><span class="timer" id="timer">00:00</span></div><div id="clockWidget" class="clock-widget"><small>Time</small><span class="timer" id="wallClock">00:00</span></div></div></header>
<div class="concept"><span><strong>INTERACTIVE CONCEPT</strong> · Mock slides and screens. No real display or system settings change.</span><label class="project-picker">Demo project <select id="demoProject"><option value="ideas">Making room for ideas</option><option value="workshop">Workshop</option></select></label><label>Test setup <select id="topology"><option value="3">3 screens</option><option value="4">4 screens</option><option value="2">Projector disconnected</option><option value="1">Laptop only</option></select></label></div>
<header><span class="brand">P</span><button id="menuButton" aria-expanded="false" aria-controls="menu">☰ Menu</button><div class="doc"><b id="projectTitle">Making room for ideas</b><small>demo.pdf · 12 slides</small></div><div class="toolbar"><button id="displayButton">Displays · 1 → 3</button><button id="blankButton">Blank presentation</button><button id="layoutButton" class="layout-button" aria-controls="layoutPanel" aria-expanded="false">Layout</button><div id="elapsedWidget" class="clock-widget"><small>Elapsed</small><span class="timer" id="timer">00:00</span></div><div id="clockWidget" class="clock-widget"><small>Time</small><span class="timer" id="wallClock">00:00</span></div></div></header>
<nav id="menu" class="menu" aria-label="Presenter menu" hidden><button disabled>Open PDF… <small>Planned</small></button><button disabled>Open picture folder… <small>Planned</small></button><hr><button id="menuDisplays">Displays <small>Assign screens</small></button><button id="menuLayout">Layout <small>Show, hide & resize</small></button><button id="menuSettings">Settings <small>Preview</small></button><hr><button id="resetTimer">Reset timer</button><button id="resetDemo">Reset demo</button></nav>
<main><div class="previews" id="previews"><section id="previousPreview" class="previous-preview"><div class="caption"><span>PREVIOUS</span><span id="previousCount"></span></div><div class="slide"><span class="eyebrow">LOOKING BACK</span><h1 id="previousTitle">Start of presentation</h1><div class="orb"></div></div></section><section id="currentPreview"><div class="caption"><span>CURRENT · <span id="currentCount">1 / 12</span></span><b id="outputBadge">PRESENTATION VISIBLE</b></div><div class="slide"><span class="eyebrow">BEFFROI / FIELD NOTES</span><h1 id="currentTitle">Making room<br>for ideas.</h1><p id="currentSubtitle">A clear view. A little space. A better presentation.</p><div class="orb"></div><span class="slide-foot">DESIGN SESSION · NOVEMBER 2026</span></div></section><section class="next" id="nextPreview"><div class="caption"><span>NEXT</span><span id="nextCount">2 / 12</span></div><div class="slide"><span class="eyebrow">THE STARTING POINT</span><h1 id="nextTitle">Keep the<br>focus.</h1><div class="orb"></div></div><div class="next-hint">Your slides go to <strong id="destination">Screen 3 · Epson projector</strong>.<br>Menus and notes stay on the presenter screen.</div></section></div>
<section class="notes" id="notesWidget"><div class="caption"><span>PRESENTER NOTES <small> · auto-fit</small></span><div class="notes-tools"><button id="longNotes">Try long notes</button><button id="notesLayout">Resize & visibility</button></div></div><div class="note-box" id="noteBox"><p class="note-text" id="noteText"></p></div></section>
@ -25,10 +26,11 @@ main{display:flex;flex-direction:column;min-height:430px;max-width:none}.preview
<div class="presets"><button id="balancedLayout">Balanced</button><button id="focusLayout">Slide focus</button><button id="speakerLayout">Notes first</button></div>
<div id="layoutControls"></div>
<small>Preview sizes share the available width. Notes size controls their share of the height; text always fits. Clock sizes control their text size.</small>
<small>Demo choices last while this page is open. The native app will remember visibility and sizes in your global configuration.</small>
<small>Project layouts override the default for all projects. Saved layouts persist in this browser; native configuration remains planned.</small>
<div class="layout-save"><button class="primary" id="saveProjectLayout">Save layout · This project</button><button id="saveGlobalLayout">Save layout · All projects</button><button id="useGlobalLayout">Use all-projects default</button><p id="layoutSaveStatus" role="status" aria-live="polite"></p></div>
</aside>
<dialog id="displayDialog" aria-labelledby="displayTitle"><div class="dialog-head"><div><h2 id="displayTitle">Where should each view go?</h2><small>Presenter = your controls and notes. Presentation = slides for viewers.</small></div><button aria-label="Close displays" data-close="displayDialog">✕</button></div><div class="dialog-body"><div style="display:flex;justify-content:space-between;align-items:center"><span class="pill">CONNECTED SCREENS · SIMULATED</span><button id="identify">Identify screens</button></div><div class="map" id="screenMap"></div><div class="assignments"><div class="field"><label for="presenterSelect">Presenter screen</label><select id="presenterSelect"></select></div><button id="swap">⇄ Swap</button><div class="field"><label for="presentationSelect">Presentation screen</label><select id="presentationSelect"></select></div></div><div class="checks"><label><input id="presenterFull" type="checkbox" checked> Presenter fullscreen</label><label><input id="presentationFull" type="checkbox" checked> Presentation fullscreen</label><label><input id="remember" type="checkbox" checked> Remember this setup</label></div><div class="notice" id="displayNotice">Choose destinations, then Apply. Unused screens stay untouched.</div></div><div class="dialog-actions"><small>Changes apply together.</small><button data-close="displayDialog">Cancel</button><button class="primary" id="apply">Apply setup</button></div></dialog>
<dialog id="settingsDialog" aria-labelledby="settingsTitle"><div class="dialog-head"><div><h2 id="settingsTitle">Settings</h2><small>Proposed app behavior · not operating-system settings</small></div><button aria-label="Close settings" data-close="settingsDialog">✕</button></div><div class="dialog-body"><div class="settings-row"><b>Remember your screens</b><br><span class="muted">Keep preferred screen identities, fullscreen choices and notes layout in a per-user configuration. Temporary fallback does not replace your preferred setup.</span></div><div class="settings-row"><b>Configuration location</b><br><code>Linux: $XDG_CONFIG_HOME/pdf-presenter/settings.toml</code><br><small>Defaults to ~/.config/pdf-presenter/settings.toml</small><br><code>Windows: %APPDATA%\Beffroi\PdfPresenter\settings.toml</code><br><code>macOS: ~/Library/Application Support/Beffroi/PdfPresenter/settings.toml</code></div><div class="settings-row"><b>Keep screens awake during presentation</b><br><span class="muted">Planned native feature. Includes paused and blanked output; this HTML does not inhibit sleep.</span></div><div class="notice">This demo remembers choices only while this page is open. The native app's global configuration is not implemented yet.</div></div><div class="dialog-actions"><button class="primary" data-close="settingsDialog">Done</button></div></dialog>
<dialog id="settingsDialog" aria-labelledby="settingsTitle"><div class="dialog-head"><div><h2 id="settingsTitle">Settings</h2><small>Proposed app behavior · not operating-system settings</small></div><button aria-label="Close settings" data-close="settingsDialog">✕</button></div><div class="dialog-body"><div class="settings-row"><b>Remember your screens</b><br><span class="muted">Keep preferred screen identities, fullscreen choices and notes layout in a per-user configuration. Temporary fallback does not replace your preferred setup.</span></div><div class="settings-row"><b>Configuration location</b><br><code>Linux: $XDG_CONFIG_HOME/pdf-presenter/settings.toml</code><br><small>Defaults to ~/.config/pdf-presenter/settings.toml</small><br><code>Windows: %APPDATA%\Beffroi\PdfPresenter\settings.toml</code><br><code>macOS: ~/Library/Application Support/Beffroi/PdfPresenter/settings.toml</code></div><div class="settings-row"><b>Keep screens awake during presentation</b><br><span class="muted">Planned native feature. Includes paused and blanked output; this HTML does not inhibit sleep.</span></div><div class="notice">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.</div></div><div class="dialog-actions"><button class="primary" data-close="settingsDialog">Done</button></div></dialog>
<script>
'use strict';
const $=id=>document.getElementById(id);
@ -40,9 +42,39 @@ document.querySelectorAll('.previews .slide').forEach(slide=>{const stage=docume
const layoutDefaults={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}};
let layout=structuredClone(layoutDefaults);
const layoutSpecs=[['previous','Previous slide',30,160,'weight'],['current','Current slide',60,200,'weight'],['next','Next slide',30,160,'weight'],['notes','Notes',12,65,'%'],['elapsed','Elapsed time',16,72,'px'],['clock','Time · HH:MM',16,72,'px']];
const layoutStorageKey='pdf-presenter.menu-layouts.v1';
let projectId='ideas';
const emptyLayouts=()=>({version:1,global:null,projects:{}});
function validateLayout(value){
if(!value||typeof value!=='object')throw Error('Invalid layout');
const clean={};
for(const [key,,min,max] of layoutSpecs){const entry=value[key];if(!entry||typeof entry.show!=='boolean'||!Number.isInteger(entry.size)||entry.size<min||entry.size>max||(key==='current'&&!entry.show))throw Error('Invalid layout widget');clean[key]={show:entry.show,size:entry.size};}
return clean;
}
function readLayouts(){
const raw=localStorage.getItem(layoutStorageKey);if(raw===null)return emptyLayouts();
if(raw.length>20000)throw Error('Layout settings too large');
const data=JSON.parse(raw);if(data?.version!==1||!data.projects||typeof data.projects!=='object'||Array.isArray(data.projects))throw Error('Unsupported layout settings');
const clean=emptyLayouts();if(data.global!==null)clean.global=validateLayout(data.global);
for(const id of ['ideas','workshop'])if(Object.hasOwn(data.projects,id))clean.projects[id]=validateLayout(data.projects[id]);
return clean;
}
function layoutStatus(text){$('layoutSaveStatus').textContent=text;}
function restoreLayout(){
try{const saved=readLayouts();layout=structuredClone(saved.projects[projectId]||saved.global||layoutDefaults);applyLayout();layoutStatus(saved.projects[projectId]?'Loaded this project’s saved layout.':saved.global?'Using the saved all-projects default.':'Using the built-in layout.');}
catch{layout=structuredClone(layoutDefaults);applyLayout();layoutStatus('Saved layouts could not be read. Using the built-in layout; stored settings were not changed.');}
}
function saveLayout(scope){
try{const saved=readLayouts();if(scope==='project')saved.projects[projectId]=validateLayout(layout);else saved.global=validateLayout(layout);localStorage.setItem(layoutStorageKey,JSON.stringify(saved));layoutStatus(scope==='project'?'Saved for this project.':saved.projects[projectId]?'Default saved for all projects. This project still has its own saved layout; use the default below to replace it.':'Saved as the default for all projects. Existing project overrides are preserved.');}
catch{layoutStatus('Could not save layout. Browser storage may be unavailable or saved settings invalid. Your current layout is still usable.');}
}
$('saveProjectLayout').onclick=()=>saveLayout('project');$('saveGlobalLayout').onclick=()=>saveLayout('global');
$('useGlobalLayout').onclick=()=>{try{const saved=readLayouts();delete saved.projects[projectId];localStorage.setItem(layoutStorageKey,JSON.stringify(saved));restoreLayout();}catch{layoutStatus('Could not remove this project’s override. Your current layout is unchanged.');}};
$('demoProject').onchange=()=>{projectId=$('demoProject').value;$('projectTitle').textContent=$('demoProject').selectedOptions[0].textContent;restoreLayout();message('Demo project switched. Unsaved layout edits were discarded.');};
const widgets={previous:'previousPreview',current:'currentPreview',next:'nextPreview',notes:'notesWidget',elapsed:'elapsedWidget',clock:'clockWidget'};
function availableHeight(){const main=document.querySelector('main');main.style.height=Math.max(430,innerHeight-main.getBoundingClientRect().top)+'px';}
function applyLayout(){
layoutStatus('Layout changes are not saved until you choose a save scope.');
for(const [key] of layoutSpecs){$(widgets[key]).hidden=!layout[key].show;const toggle=$('show-'+key);if(toggle)toggle.checked=layout[key].show;$('size-'+key).value=layout[key].size;$('size-'+key).disabled=!layout[key].show;$('value-'+key).textContent=layout[key].size+(key==='notes'?'%':['clock','elapsed'].includes(key)?'px':'');}
$('previews').style.gridTemplateColumns=['previous','current','next'].filter(k=>layout[k].show).map(k=>`minmax(0, ${layout[k].size}fr)`).join(' ');
$('notesWidget').style.flexBasis=layout.notes.size+'%';$('timer').style.fontSize=layout.elapsed.size+'px';$('wallClock').style.fontSize=layout.clock.size+'px';availableHeight();fitNotes();
@ -74,6 +106,6 @@ $('swap').onclick=()=>{[draft.presenter,draft.presentation]=[draft.presentation,
$('identify').onclick=()=>{$('screenMap').classList.add('identify');$('displayNotice').textContent='Native app: briefly overlay these numbers on the physical screens. Here: simulated labels only.';setTimeout(()=>$('screenMap').classList.remove('identify'),1800);};
$('apply').onclick=()=>{draft.presenterFull=$('presenterFull').checked;draft.presentationFull=$('presentationFull').checked;active={...draft};if($('remember').checked)preferred={...active};$('displayDialog').close();render();message($('remember').checked?'Setup applied and remembered for this demo session.':'Setup applied for this session without changing your preferred setup.');};
$('topology').onchange=()=>{count=Number($('topology').value);const available=id=>id>0&&id<=count;const p=available(preferred.presenter)?preferred.presenter:1;const output=available(preferred.presentation)&&preferred.presentation!==p?preferred.presentation:screens.slice(0,count).find(s=>s.id!==p)?.id||0;active={...preferred,presenter:p,presentation:output};blank=true;render();message('Simulated display change: presentation blanked. Review the fallback in Displays; your preferred setup is retained.');if($('displayDialog').open)openDisplays();};
$('menuSettings').onclick=()=>{closeMenu();$('settingsDialog').showModal();};$('menuLayout').onclick=openLayout;$('resetTimer').onclick=()=>{start=Date.now();closeMenu();};$('resetDemo').onclick=()=>location.reload();document.querySelectorAll('[data-close]').forEach(b=>b.onclick=()=>$(b.dataset.close).close());document.addEventListener('pointerdown',e=>{if(!$('menu').contains(e.target)&&!$('menuButton').contains(e.target))closeMenu();});document.addEventListener('keydown',e=>{if(e.key==='Escape'){closeMenu();if(!$('layoutPanel').hidden){setLayoutOpen(false);$('layoutButton').focus();}return;}if(document.querySelector('dialog[open]')||['INPUT','SELECT','BUTTON'].includes(document.activeElement.tagName)||!$('menu').hidden)return;if(e.key==='ArrowRight'||e.key===' '){e.preventDefault();move(1);}if(e.key==='ArrowLeft'){e.preventDefault();move(-1);}if(e.key.toLowerCase()==='b'&&active.presentation){blank=!blank;render();}});function updateClocks(){const seconds=Math.floor((Date.now()-start)/1000);$('timer').textContent=String(Math.floor(seconds/60)).padStart(2,'0')+':'+String(seconds%60).padStart(2,'0');const now=new Date();$('wallClock').textContent=String(now.getHours()).padStart(2,'0')+':'+String(now.getMinutes()).padStart(2,'0');}setInterval(updateClocks,1000);updateClocks();applyLayout();render();
$('menuSettings').onclick=()=>{closeMenu();$('settingsDialog').showModal();};$('menuLayout').onclick=openLayout;$('resetTimer').onclick=()=>{start=Date.now();closeMenu();};$('resetDemo').onclick=()=>location.reload();document.querySelectorAll('[data-close]').forEach(b=>b.onclick=()=>$(b.dataset.close).close());document.addEventListener('pointerdown',e=>{if(!$('menu').contains(e.target)&&!$('menuButton').contains(e.target))closeMenu();});document.addEventListener('keydown',e=>{if(e.key==='Escape'){closeMenu();if(!$('layoutPanel').hidden){setLayoutOpen(false);$('layoutButton').focus();}return;}if(document.querySelector('dialog[open]')||['INPUT','SELECT','BUTTON'].includes(document.activeElement.tagName)||!$('menu').hidden)return;if(e.key==='ArrowRight'||e.key===' '){e.preventDefault();move(1);}if(e.key==='ArrowLeft'){e.preventDefault();move(-1);}if(e.key.toLowerCase()==='b'&&active.presentation){blank=!blank;render();}});function updateClocks(){const seconds=Math.floor((Date.now()-start)/1000);$('timer').textContent=String(Math.floor(seconds/60)).padStart(2,'0')+':'+String(seconds%60).padStart(2,'0');const now=new Date();$('wallClock').textContent=String(now.getHours()).padStart(2,'0')+':'+String(now.getMinutes()).padStart(2,'0');}setInterval(updateClocks,1000);updateClocks();restoreLayout();render();
</script>
</body></html>

View File

@ -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

View File

@ -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.

View File

@ -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 `</body>` 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.

View File

@ -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);
}
});