Implement Writer Phase 2B viewport split workspaces and device preferences

This commit is contained in:
Nick Beckley 2026-11-16 16:44:16 +00:00
parent 4dc50e1204
commit 10bf9db906
14 changed files with 369 additions and 7 deletions

View File

@ -82,3 +82,7 @@ Phase1: corrected workspace/queue/goal guidance; added workingContext and writin
| writer3.dashboard | Writer Dashboard | Existing HelpIconTagHelper micro/quick metadata, browser popup, PWA promoted Help/drawer, full Help article; qualification in Phase2A report |
Existing workspace.overview now describes the preserved Writing desk at /Writer/Overview. Shared workingContext and writingPlans articles remain authoritative for selection and task semantics. No competing Help implementation.
## Phase 2B layout Help
`writer3.layout` uses the existing Markdown tag helper beside each split-destination heading. Covers pointer/keyboard resizing, minimum widths, collapse/restore, independent device preferences, responsive overlay/focus, storage failure and standalone-window separation. The five destination articles also explain the controls. Browser popup, PWA drawer and full article are qualification gates.

View File

@ -1,6 +1,6 @@
# Writer 3.0 implementation tracker
Baseline: `9a8b9a3`, shared branch `codex/word-companion-native-phase1-20261104`, 16 November 2026. The original kickoff authorised Phase 1 implementation and Development deployment; the master specification governs product direction even though its header says Proposed. The subsequent Phase2A kickoff explicitly authorised Home, navigation, destination shells and Development deployment; Phase2B still requires acceptance. No feature is retired. Unrelated investigation file is preserved.
Baseline: `9a8b9a3`, shared branch `codex/word-companion-native-phase1-20261104`, 16 November 2026. The original kickoff authorised Phase 1 implementation and Development deployment; the master specification governs product direction even though its header says Proposed. The subsequent Phase2A kickoff explicitly authorised Home, navigation, destination shells and Development deployment; Phase2B was subsequently explicitly authorised for layout infrastructure and Development deployment; Phase2C remains unauthorised. No feature is retired. Unrelated investigation file is preserved.
## Phase 1 screen and interaction states before implementation
@ -24,7 +24,7 @@ No new workspace shell in this phase. Existing Overview/Journey/Workspaces route
### Phase 2 — Writer Home and workspace shell
- Objective/deliverables: Three Home actions and five destinations; resizable workspace/companion; contextual ribbon and return state.
- Current authorised batches: 2A.1 routes/ribbon; 2A.2 Home; 2A.3 destination shells; 2A.4 Help/testing/Development. Phase2B resizable companion work remains unstarted; this supersedes the original provisional batch labels.
- Current authorised batches: 2A.1 routes/ribbon; 2A.2 Home; 2A.3 destination shells; 2A.4 Help/testing/Development. Phase2B resizable companion work is authorised and in progress; this supersedes the original provisional batch labels.
- Reuse: ApplicationNavigation/Ribbon, existing theme/PWA shell and workspace maximise conventions
- New/change: implement the batch deliverables inside the existing MVC application; no parallel Writer.
- Database: None assumed.
@ -32,7 +32,7 @@ No new workspace shell in this phase. Existing Overview/Journey/Workspaces route
- Acceptance: New author entry; existing deep links; keyboard resizing; mobile/PWA; all preservation mappings reachable.
- Preservation: all mapped F/I capabilities below; reader/source/privacy/native safeguards remain authoritative.
- Help: review existing Markdown keys for affected capabilities; update tooltip, popup and full article together; register coverage.
- Status / Development deployment: Phase2A Development-qualified; application commit f96259a, release f96259a-20261116T155614Z. Phase2B not started. See Phase2A-Report.md for qualification and physical acceptance limits.
- Status / Development deployment: Phase2A Development-qualified; application commit f96259a, release f96259a-20261116T155614Z. Phase2B authorised and in progress; see Phase2B-Execution.md. See Phase2A-Report.md for qualification and physical acceptance limits.
### Phase 3 — Write and Review integration
@ -328,3 +328,7 @@ User authorised2A only after Phase1 acceptance. [Execution breakdown and layouts
## Phase 2A completion — 16 November 2026
Home, five destination shells, Plan/Reflect Dashboard and contextual existing ribbon are implemented. Entire old desk remains at Overview; Workspaces/Journey/Display Setup, native windows and specialist routes are preserved. Seven Markdown Help articles use the existing tooltip/popup/PWA drawer/full article infrastructure. No schema or native protocol changes. Build: zero warnings/errors; full harness:584 PASS; responsive navigation:168 combinations; preserved desk:48 combinations; Reader/Intent/Context/native-follow simulations/chapter goals/audio state suites passed. Authenticated Development browser and simulated PWA tests passed; scoped author-data hashes identical before/after navigation; disposable account and projects removed (RemainingSyntheticAccounts=0). Deployed DLL hash and commit metadata match. Physical Windows Word, installed PWA, actual playback and monitor placement remain manual. [Completion report](Phase2A-Report.md). Phase2B has not begun.
## Phase 2B authorised scope
[Execution and layout contract](Phase2B-Execution.md). Five viewport workspaces, reusable resize/collapse/overlay infrastructure and per-actor/per-destination device preferences; preserve current task/session/audio controls and independent standalone windows. No story data/schema/native protocol changes. Home spacing refinements only. Phase2C not started. Qualification and deployment pending.

View File

@ -0,0 +1,21 @@
# Phase 2B execution and layout contract
Authorised by the Phase2B kickoff after Development screenshot acceptance of2A. Scope is layout infrastructure only; no Phase2C/Phase3/Phase4 feature integration.
- **2B.1:** Enhance the five existing destination grids progressively. Measure the root’s actual top against the visual viewport, observe shell/header/help-container size, and respond to ribbon, resize and fullscreen events. CSS flex/grid handles the remaining header/tool/panel allocation; no fixed ribbon offset. Panels scroll independently. In exceptionally short or heavily scaled windows use unclipped document flow.
- **2B.2:** Accessible vertical separator, pointer capture/interruption cleanup, keyboard Left/Right/Shift/Home/End, minimum main440px and companion280px, proportional constraints on wider screens. Collapse hides the original DOM; no replacement rendering, reload or session teardown.
- **2B.3:** Below900px actual workspace width, use one primary column and a non-modal contextual overlay. Escape/Back restores toggle focus; leaving the overlay by keyboard closes it without trapping application ribbon or Help. A temporary overlay does not overwrite desktop collapse preference.
- **2B.4:** Five destination contents and standalone launchers remain intact. No new companion sections are invented. Home card spacing is reduced and aligned; Dashboard remains the existing Plan/Reflect overview. Existing Markdown Help covers layout controls and their limits.
- **2B.5:** Full build/harness, rendered responsive/browser/simulated-PWA layout and preservation suites; authenticated Development interactions with scoped author-data comparison; rollback archive, screenshots and report.
## Device preferences
`plotdirector.writerLayout.v1.<signed-in actor ID>.<destination>` in localStorage, matching existing non-sensitive device layout conventions. JSON contains only schema version, companion-width fraction and desktop collapsed flag. Different destinations/authors use independent keys; book/story IDs, scene selections, session/native state and prose are absent. No database or server preference writes. No companion tabs exist in these shells, so no selected-section field is applicable; later integration must explicitly define bounded section keys rather than storing story context.
Saved widths are constrained on read and to the current usable track width on render. Malformed/unknown versions default safely; denied storage disables persistence but leaves controls available. The desired width fraction survives temporary small-window clamping. Current layout content remains in the original DOM during collapse/overlay changes, preserving local values and existing handlers.
## Independent context
Layout actions do not call application APIs. Working, exploration, pinned, Reader, verified Word and active-session authorities remain those documented in Context-Contract.md. Standalone Context/Intent windows keep their own state and placement protocols. Opening/hiding the contextual companion never launches/closes them or navigates Word.
Actual qualification and deployment results are recorded in Phase2B-Report.md after execution. Physical Windows/installed PWA/real media/multi-monitor checks must remain explicitly manual when unavailable.

View File

@ -0,0 +1,93 @@
// Rendered MVC/shell qualification. Optional live mode requires a dedicated Development fixture identity.
const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs');
const live=!!process.env.PD_WRITER3_IDENTITY;
const base=live?'https://dev.plotdirector.com':'http://127.0.0.1:5238';
const identity=live?JSON.parse(fs.readFileSync(process.env.PD_WRITER3_IDENTITY)):null;
if(live)assert(identity.Database==='PlotDirector_Development'&&identity.Email.endsWith('@example.invalid'));
const book=identity?.book||12,project=identity?.project||7;
const url=d=>`${base}/Writer/${d}?projectId=${project}&bookId=${book}${live?'':'&objective=true&populated=true'}`;
const settle=p=>p.evaluate(()=>new Promise(r=>requestAnimationFrame(()=>requestAnimationFrame(r))));
const width=p=>p.locator('.writer3-reference').evaluate(n=>n.getBoundingClientRect().width);
(async()=>{const browser=await chromium.launch();let combinations=0;try{
for(const pwa of [false,true]){
const context=await browser.newContext({viewport:{width:1440,height:1000}});
if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));
await context.route('**/signalr.min.js',r=>r.fulfill({contentType:'application/javascript',body:fs.readFileSync(require.resolve('@microsoft/signalr/dist/browser/signalr.min.js'))}));
const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));
if(live){await page.goto(base+'/Account/Login');await page.locator('[name=Email]').fill(identity.Email);await page.locator('[name=Password]').fill(identity.Password);await Promise.all([page.waitForURL('**/Projects'),page.locator('button[type=submit]').click()]);}
else await context.route('**/Writer/Work/State?*',r=>r.fulfill({contentType:'application/json',body:JSON.stringify({session:null,defaultPauseOnEdit:true})}));
for(const d of ['Write','Explore','Plan','Review','Reflect']){
await page.setViewportSize({width:1440,height:1000});await page.goto(url(d));await settle(page);
const divider=page.getByRole('separator',{name:'Resize contextual companion'}),toggle=page.locator('.writer3-layout-tools button').first();
assert(await divider.isVisible(),d+' divider');
const initial=await width(page);assert(initial>340&&initial<600);
await divider.focus();assert(await divider.evaluate(n=>n.matches(':focus-visible')));
await page.keyboard.press('Shift+ArrowLeft');assert((await width(page))>=initial+45);
await page.keyboard.press('Home');const min=await width(page);assert(min>=280);
await page.keyboard.press('End');const max=await width(page);assert(max>min+100);
const box=await divider.boundingBox();await page.mouse.move(box.x+box.width/2,box.y+80);await page.mouse.down();await page.mouse.move(box.x+box.width/2+120,box.y+80,{steps:12});await page.mouse.up();
const dragged=await width(page);assert(dragged<max-90);await page.reload();await settle(page);assert(Math.abs(await width(page)-dragged)<=3,'reload width');
const href=await page.locator('.writer3-main a').first().getAttribute('href');
await toggle.click();assert(await page.locator('.writer3-reference').isHidden());assert(await divider.isHidden());
await page.reload();await settle(page);assert(await page.locator('.writer3-reference').isHidden(),'collapse persists');
await page.locator('.writer3-layout-tools button').first().click();assert(await page.locator('.writer3-reference').isVisible());assert.equal(await page.locator('.writer3-main a').first().getAttribute('href'),href);
// Unsaved notes and the existing session DOM survive collapse, without a layout-triggered POST.
if(d==='Write'){
const note=page.locator('[data-work-note]');if(await note.count()){await note.evaluate(n=>n.value='Unsaved local session note');await page.locator('.writer3-layout-tools button').first().click();await page.locator('.writer3-layout-tools button').first().click();assert.equal(await note.inputValue(),'Unsaved local session note');}
}
await page.setViewportSize({width:390,height:844});await settle(page);assert(await divider.isHidden());assert(await page.locator('.writer3-reference').isHidden());
await page.locator('.writer3-layout-tools button').first().click();assert(await page.locator('.writer3-reference').isVisible());assert(await page.locator('.writer3-companion-close').evaluate(n=>n===document.activeElement));
if(!pwa&&d==='Explore'&&process.env.PD_WRITER3_SCREENSHOTS){fs.mkdirSync(process.env.PD_WRITER3_SCREENSHOTS,{recursive:true});await page.screenshot({path:`${process.env.PD_WRITER3_SCREENSHOTS}/Explore-narrow.png`});}
await page.keyboard.press('Escape');assert(await page.locator('.writer3-reference').isHidden());assert(await page.locator('.writer3-layout-tools button').first().evaluate(n=>n===document.activeElement));
await page.locator('.writer3-layout-tools button').first().click();await page.locator('.writer3-companion-close').click();assert(await page.locator('.writer3-reference').isHidden());
await page.setViewportSize({width:1440,height:1000});await settle(page);assert(await page.locator('.writer3-reference').isVisible(),'temporary narrow overlay never overwrites desktop preference');
await page.locator('.writer3-layout-tools button').first().click();await page.setViewportSize({width:390,height:844});await settle(page);await page.locator('.writer3-layout-tools button').first().click();await page.setViewportSize({width:1440,height:1000});await settle(page);assert(await page.locator('.writer3-reference').isHidden());assert(await page.locator('.writer3-layout-tools button').first().evaluate(n=>n===document.activeElement),'responsive close restores focus when desktop preference is collapsed');await page.locator('.writer3-layout-tools button').first().click();
if(!pwa&&process.env.PD_WRITER3_SCREENSHOTS){await page.evaluate(()=>window.PlotDirectorApplyApplicationTheme('modern-dark'));fs.mkdirSync(process.env.PD_WRITER3_SCREENSHOTS,{recursive:true});await page.mouse.move(0,0);await page.screenshot({path:`${process.env.PD_WRITER3_SCREENSHOTS}/${d}.png`});}
}
if(!live){
for(const kind of ['Writing','AudioReview']){
const posts=[];const session={sessionID:'11111111-1111-1111-1111-111111111111',kind,bookID:12,chapterID:21,chapterTitle:'Bound chapter',startedUtc:new Date().toISOString(),engagedSeconds:60,playbackSeconds:20,uniqueSeconds:10,pauseOnEdit:true,live:true,playbackState:'playing',capabilities:'play,pause,back15,forward15',sequence:1};
await page.route('**/Writer/Work/**',r=>{if(r.request().method()==='POST'){posts.push(new URL(r.request().url()).pathname);return r.fulfill({status:200,body:''});}return r.fulfill({json:{session,defaultPauseOnEdit:true}});});
await page.goto(url('Write'));await page.locator('[data-work-current]:visible').waitFor();await page.locator('[data-work-note]').fill('Keep unsaved note');
const before=await page.locator('[data-work-current]').elementHandle();await page.locator('.writer3-layout-tools button').first().click();await page.locator('.writer3-layout-tools button').first().click();
await page.getByRole('separator',{name:'Resize contextual companion'}).focus();await page.keyboard.press('ArrowLeft');
assert(await before.evaluate(n=>n===document.querySelector('[data-work-current]')));assert.equal(await page.locator('[data-work-note]').inputValue(),'Keep unsaved note');
assert((await page.locator('[data-work-label]').textContent()).includes(kind));if(kind==='AudioReview'){assert(await page.locator('[data-work-audio]').isVisible());assert((await page.locator('[data-audio-chapter]').textContent()).includes('Bound chapter'));}
assert.deepEqual(posts,[],'layout never posts a session start/end/preference/media command');await page.unroute('**/Writer/Work/**');
}
await page.goto(url('Explore'));const sep=page.getByRole('separator',{name:'Resize contextual companion'});const box=await sep.boundingBox();
await page.mouse.move(box.x+box.width/2,box.y+60);await page.mouse.down();await page.dispatchEvent('.writer3-divider','pointercancel',{pointerId:1});await page.mouse.up();assert(!await page.locator('.writer3').evaluate(n=>n.classList.contains('writer3-dragging')));
const cdp=await context.newCDPSession(page);const touch=await sep.boundingBox();const x=touch.x+touch.width/2,y=touch.y+100,oldWidth=await width(page);
await cdp.send('Input.dispatchTouchEvent',{type:'touchStart',touchPoints:[{x,y}]});await cdp.send('Input.dispatchTouchEvent',{type:'touchMove',touchPoints:[{x:x-70,y}]});await cdp.send('Input.dispatchTouchEvent',{type:'touchEnd',touchPoints:[]});await settle(page);assert(await width(page)>oldWidth+40,'touch pointer drag');
const fullscreen=await page.evaluate(async()=>{try{await document.documentElement.requestFullscreen();return !!document.fullscreenElement;}catch{return false;}});assert(fullscreen,'headless Chromium fullscreen request');await settle(page);await page.evaluate(()=>document.exitFullscreen());await settle(page);
}
// Independent destination preferences, safe malformed/outdated payload and storage refusal.
await page.goto(url('Explore'));await page.getByRole('separator',{name:'Resize contextual companion'}).focus();await page.keyboard.press('End');await page.locator('.writer3-layout-tools button').first().click();
await page.goto(url('Plan'));assert(await page.locator('.writer3-reference').isVisible());await page.goto(url('Explore'));assert(await page.locator('.writer3-reference').isHidden());
await page.evaluate(()=>{for(const k of Object.keys(localStorage).filter(k=>k.startsWith('plotdirector.writerLayout.')))localStorage.setItem(k,'{invalid');});await page.reload();assert(await page.locator('.writer3-reference').isVisible());
await page.evaluate(()=>{for(const k of Object.keys(localStorage).filter(k=>k.startsWith('plotdirector.writerLayout.')))localStorage.setItem(k,JSON.stringify({version:99,width:1e9,collapsed:true}));});await page.reload();assert(await page.locator('.writer3-reference').isVisible());
await page.evaluate(()=>{for(const k of Object.keys(localStorage).filter(k=>k.startsWith('plotdirector.writerLayout.')))localStorage.setItem(k,JSON.stringify({version:1,width:1e9,collapsed:'false'}));});await page.reload();assert((await width(page))<800);assert(await page.locator('.writer3-reference').isVisible());
await page.evaluate(()=>{for(const k of Object.keys(localStorage).filter(k=>k.startsWith('plotdirector.writerLayout.')))localStorage.removeItem(k);});
for(const theme of ['modern-dark','modern-light','warm-dark','plotdirector'])for(const size of [{width:390,height:844},{width:1024,height:768},{width:1440,height:900},{width:1920,height:1080},{width:2560,height:1440}])for(const d of ['Write','Explore','Plan','Review','Reflect']){
await page.setViewportSize(size);await page.goto(url(d));await page.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);await settle(page);
const geometry=await page.evaluate(()=>({x:document.documentElement.scrollWidth-innerWidth,y:document.documentElement.scrollHeight-innerHeight,bottom:document.querySelector('.writer3-workspace').getBoundingClientRect().bottom}));
assert(geometry.x<=2,`${d}/${theme}/${size.width} horizontal overflow`);assert(geometry.y<=3,`${d}/${theme}/${size.width} unnecessary page scroll ${JSON.stringify(geometry)}`);
assert(geometry.bottom<=size.height+2);combinations++;
}
await page.setViewportSize({width:1440,height:1000});await page.goto(url('Review'));await settle(page);
if(await page.locator('[data-ribbon-shell]').getAttribute('data-collapsed')==='true'){await page.locator('[data-ribbon-collapse]').click();await page.waitForFunction(()=>!document.querySelector('[data-ribbon-collapse]').disabled);await settle(page);}
const before=await page.locator('.writer3-split').evaluate(n=>n.clientHeight);
// Drive real shell collapse; isolate fixture appearance persistence from unrelated endpoint absence.
if(!live){const endpoint=await page.locator('[data-appearance-form]').getAttribute('data-ribbon-url');await page.route('**'+endpoint,r=>r.fulfill({status:200,body:'{}'}));}
await page.locator('[data-ribbon-collapse]').click();await page.waitForFunction(()=>!document.querySelector('[data-ribbon-collapse]').disabled);await settle(page);
const after=await page.locator('.writer3-split').evaluate(n=>n.clientHeight);assert(after>before+25,'ribbon collapse increases working height');
await page.setViewportSize({width:1440,height:500});await page.evaluate(()=>document.documentElement.style.fontSize='200%');await settle(page);assert(await page.locator('.writer3').evaluate(n=>n.classList.contains('writer3-flow')),'high text scale uses accessible flow');await page.evaluate(()=>window.scrollTo(0,500));await page.setViewportSize({width:1440,height:1000});await page.evaluate(()=>document.documentElement.style.fontSize='');await page.waitForFunction(()=>!document.querySelector('.writer3-flow')&&document.documentElement.scrollHeight<=innerHeight+3);
await page.goto(url('Review'));
if(pwa){await page.locator('[data-help-open="writer3.layout"]:visible').click();await page.waitForFunction(()=>document.querySelector('[data-help-drawer]')?.textContent.includes('Workspace Layout'));}
else{await page.locator('[data-help-key="writer3.layout"] button').click();await page.locator('.plotline-help-popover').waitFor();}
assert.equal((await page.request.get(base+'/Help/Article/writer3.layout')).status(),200);
if(!live){const blocked=await browser.newContext({viewport:{width:1440,height:1000}});await blocked.addInitScript(()=>{Storage.prototype.getItem=()=>{throw Error('blocked')};Storage.prototype.setItem=()=>{throw Error('blocked')};});const p=await blocked.newPage();await p.goto(url('Explore'));await p.locator('.writer3-layout-tools button').first().click();assert(await p.locator('.writer3-reference').isHidden());await blocked.close();}
assert.deepEqual(errors,[]);await context.close();
}
console.log(`PASS Writer3 workspace: ${combinations} rendered destination/theme/viewport/browser/simulated-PWA cases; pointer/keyboard limits, collapse, reload, independent preferences, invalid/stale values, storage refusal, responsive overlay/Escape/focus, ribbon height, text scaling, preserved local notes and Help. ${live?'Authenticated Development fixture.':'Isolated MVC fixture.'} Physical Windows/installed PWA/multi-monitor not tested.`);
}finally{await browser.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1});

View File

@ -16,3 +16,7 @@ Explore offers real entry points to the existing Problem Solver questionnaire, i
You can use the Problem Solver before you have a project or scenes. Its questions and editorial guidance are separate from manuscript-aware evidence assessment. Saved character, relationship, plot, map, floor-plan and metric tools are linked directly when a project is selected. Some of those tools are project-wide and may include other books.
The full specialist workspaces retain their existing editing, permissions and source records. No suggested interpretation silently updates a story fact. Guided idea capture and richer manuscript-aware journeys are later work, not simulated controls here.
# Arrange your workspace
Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows.

View File

@ -0,0 +1,34 @@
---
title: Writer Workspace Layout
category: Workspace
tags: writer, layout, resize, companion, accessibility
contextKey: writer3.layout
micro: Resize or hide the contextual companion without changing your writing focus.
quickTitle: Workspace layout
quickSummary: Drag the divider or use its arrow keys. Each destination remembers its own companion width and visibility on this browser.
screenshot:
---
# Make room for your work
Write, Explore, Plan, Review and Reflect fill the available space below the application ribbon. The main workspace and contextual companion scroll independently. Collapse the ribbon to gain more room. At very high text scaling or in a very short window, the page uses normal scrolling so nothing is clipped. Home keeps its three simple choices.
# Resize with a pointer or keyboard
Drag the handle between the panels with a mouse or touch pointer. Panel widths stay within usable limits. Tab to “Resize contextual companion” and use Left arrow to widen the companion or Right arrow to narrow it. Hold Shift for larger steps. Home selects the narrowest width; End selects the widest. The separator announces its width to assistive technology.
# Hide and restore
Use Hide companion to give the main task the full width, then Show companion to restore it. Hiding keeps the existing content in place; it does not reload the page, save a story record, end a session or close standalone reference windows.
# Narrow windows
When two usable columns do not fit, Show companion opens the same contextual content over the workspace. Back to workspace or Escape returns you to the main task and restores focus to Show companion. This is a non-modal overlay: the application ribbon and Help remain accessible. Moving keyboard focus outside the companion closes the overlay. Its temporary open state is separate from your desktop collapse preference.
# Remembered preferences
Width and desktop visibility are stored independently for each destination and signed-in author on this browser/device. They survive navigation and reload but do not synchronise between devices. Missing or invalid preferences fall back safely; a saved width is constrained to fit the current window. Blocking browser storage leaves all controls usable but prevents persistence. These panels do not currently have selectable sections; later section preferences must remain layout-only.
# Separate reference windows
The contextual companion currently contains existing tool links and summaries. Open Context and Open Intent still launch the independent reference windows, with their own pinned selections, Word following and Display Setup. Resizing or hiding this panel does not change working focus, Reader selection, verified Word position or active session binding. Full integrated Context and Intent editing is a later phase.

View File

@ -18,3 +18,7 @@ Create a writing plan saves availability first, then asks you to review actual c
Preview and manage links preserve the book and include project-wide All Books plans. The visual scheduling engine, editable calendar and richer adjustments are later work. Current adjustment controls remain in the existing Edit Plan and review screens.
[Writing plans and recorded work](/Help/Article/workspace.writingPlans)
# Arrange your workspace
Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows.

View File

@ -16,3 +16,7 @@ Reflect displays retained accepted additions, removals and net change for the la
Writing Journey opens the existing month/year/day calendar, work sessions and return notes. Reports, privacy & exports opens owner-private evidence and existing recording/retention/erasure controls. Collaborators do not gain private report access through this page.
No retained evidence does not mean no writing took place. A baseline starts from accepted manuscript content; prior activity is not reconstructed. Writing Process and reflective insights are forthcoming; no writing style is inferred or presented as a result in this release.
# Arrange your workspace
Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows.

View File

@ -20,3 +20,7 @@ Open the Reader and expand Reading & Audio Review. Select/start the activity exp
# Intent and evidence
Open Intent uses the existing standalone reference window. Its Evidence tab loads saved evidence or explicitly assesses saved scene prose and saved intentions when permitted. Intentions, AI interpretation and author-confirmed checklist completion remain separate. Scenes marked for revision opens the existing Revision workspace. No synchronisation or evidence contract is replaced by this shell.
# Arrange your workspace
Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows.

View File

@ -20,3 +20,7 @@ The existing session controls are available to the book owner. Starting and endi
# Change focus
Change objective opens the existing activity/chapter/scene form. Saving it changes your return target, not manuscript text or scene Revision Status. A scene must belong to the selected chapter/book. You may choose the whole manuscript. Book switching loads that book’s objective rather than retaining stale IDs.
# Arrange your workspace
Drag the divider or focus it and use Left/Right arrow keys to resize the contextual companion. Hide companion gives your main task the full width; Show companion restores it. Each destination remembers its width and desktop visibility on this browser. In narrow windows the companion opens as an overlay; use Back to workspace or Escape to return. Workspace Layout Help beside the heading explains keyboard controls, storage and the independent standalone Context/Intent windows.

View File

@ -6,7 +6,7 @@
}
<link rel="stylesheet" href="~/css/writer-work.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/writer3.css" asp-append-version="true" />
<div class="writer3 writer3-destination" data-writer-destination="@Model.Destination" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID">
<div class="writer3 writer3-destination" data-writer-destination="@Model.Destination" data-layout-owner="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID">
<partial name="_Writer3Header" model="Model" />
@if(!Model.BookID.HasValue && Model.Destination != "Explore"){
<section class="writer3-panel writer3-empty"><h2>Begin with a book</h2><p>Select a project and book in the application bar. Your chapters, writing focus and recorded work will stay with that book.</p><a class="btn btn-primary writer3-cta" asp-controller="Projects" asp-action="Index">Open your projects <span aria-hidden="true">→</span></a></section>
@ -22,6 +22,7 @@
}
</div>
@section Scripts {
<script src="~/js/writer3-workspace.js" asp-append-version="true"></script>
<script src="~/js/writing-workspace.js" asp-append-version="true"></script>
<script src="~/js/writing-workspace-launcher.js" asp-append-version="true"></script>
@if(Model.Destination == "Write"){

View File

@ -10,7 +10,7 @@
}else{<div class="writer3-cover writer3-cover-empty" aria-hidden="true">@title[..1]</div>}
<div class="writer3-identity">
<p class="eyebrow">@(home ? "Writer Home" : title)</p>
<div class="writer3-title"><h1>@heading <help-icon key="@($"writer3.{Model.Destination.ToLowerInvariant()}")" /></h1></div>
<div class="writer3-title"><h1>@heading <help-icon key="@($"writer3.{Model.Destination.ToLowerInvariant()}")" /></h1>@if(!home && Model.Destination != "Dashboard"){<help-icon key="writer3.layout" />}</div>
<p class="muted">@WriterNavigation.Purpose(Model.Destination)</p>
</div>
<div class="writer3-connection"><span>Companion <strong data-writing-workspace-word aria-live="polite">Checking…</strong></span><a asp-action="DisplaySetup" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">Connection &amp; Display Setup</a></div>

View File

@ -2,11 +2,11 @@
.writer3{color:var(--pd-text);max-width:1540px;margin:0 auto;padding:clamp(1rem,2.2vw,2rem) clamp(.5rem,1.5vw,1.5rem) 1.5rem;min-width:0}
.writer3-header{display:flex;align-items:center;gap:1.1rem;margin-bottom:1.6rem;min-width:0}.writer3-cover{width:54px;height:78px;object-fit:cover;flex-shrink:0;border-radius:5px;box-shadow:var(--pd-shadow)}.writer3-cover-empty{display:grid;place-items:center;color:var(--pd-on-accent);background:linear-gradient(145deg,var(--pd-accent),var(--pd-accent-hover));border-left:4px solid color-mix(in srgb,var(--pd-on-accent) 30%,transparent);font-size:1.8rem}
.writer3-identity{min-width:0;flex:1}.writer3-title{display:flex;align-items:center;gap:.6rem}.writer3-title h1{font-size:clamp(1.55rem,2.6vw,2.15rem);margin:0;color:var(--pd-heading);overflow-wrap:anywhere}.writer3-header .eyebrow{margin:0 0 .3rem}.writer3-header .muted{margin:.4rem 0 0;font-size:.95rem}.writer3-connection{max-width:270px;display:grid;gap:.3rem;text-align:right;font-size:.78rem;color:var(--pd-muted)}.writer3-connection a{color:var(--pd-accent)}
.writer3-home-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(1rem,1.8vw,1.8rem)}.writer3-choice{display:flex;align-items:center;flex-direction:column;text-align:center;justify-content:flex-start;gap:.8rem;padding:clamp(1.4rem,3vw,2.4rem) 1.3rem;min-height:clamp(250px,34vh,330px);color:var(--pd-text);text-decoration:none;background:linear-gradient(140deg,var(--pd-surface-2),var(--pd-surface));border:1px solid color-mix(in srgb,var(--pd-accent) 60%,var(--pd-border));border-radius:12px;box-shadow:var(--pd-shadow);transition:border-color .15s,background .15s}.writer3-choice:hover{color:var(--pd-text);border-color:var(--pd-accent);background:var(--pd-hover)}.writer3-choice h2{font-size:1.35rem;margin:0;color:var(--pd-heading)}.writer3-choice p{margin:0;font-size:1rem;line-height:1.55}.writer3-choice small{display:block;min-height:2.4em;font-size:.82rem;color:var(--pd-muted);max-width:32ch}.writer3-choice-icon{width:34px;height:34px;stroke:var(--pd-accent);stroke-width:1.6;fill:none;stroke-linecap:round;stroke-linejoin:round;margin-bottom:.2rem}.writer3-cta{display:inline-flex;align-items:center;justify-content:center;gap:.8rem;padding:.65rem 1.2rem;border:1px solid var(--pd-accent);background:var(--pd-accent);color:var(--pd-on-accent);border-radius:24px;text-decoration:none;font-weight:600;font-size:.9rem;width:fit-content}.writer3-cta:hover{color:var(--pd-on-accent);background:var(--pd-accent-hover);border-color:var(--pd-accent-hover)}.writer3-choice .writer3-cta{margin-top:auto}
.writer3-home-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(1rem,1.8vw,1.8rem)}.writer3-choice{display:flex;align-items:center;flex-direction:column;text-align:center;justify-content:flex-start;gap:.8rem;padding:clamp(1.3rem,2vw,1.8rem) 1.3rem;min-height:260px;color:var(--pd-text);text-decoration:none;background:linear-gradient(140deg,var(--pd-surface-2),var(--pd-surface));border:1px solid color-mix(in srgb,var(--pd-accent) 60%,var(--pd-border));border-radius:12px;box-shadow:var(--pd-shadow);transition:border-color .15s,background .15s}.writer3-choice:hover{color:var(--pd-text);border-color:var(--pd-accent);background:var(--pd-hover)}.writer3-choice h2{font-size:1.35rem;margin:0;color:var(--pd-heading)}.writer3-choice p{margin:0;font-size:1rem;line-height:1.55}.writer3-choice small{display:block;min-height:2.4em;font-size:.82rem;color:var(--pd-muted);max-width:32ch}.writer3-choice-icon{width:34px;height:34px;stroke:var(--pd-accent);stroke-width:1.6;fill:none;stroke-linecap:round;stroke-linejoin:round;margin-bottom:.2rem}.writer3-cta{display:inline-flex;align-items:center;justify-content:center;gap:.8rem;padding:.65rem 1.2rem;border:1px solid var(--pd-accent);background:var(--pd-accent);color:var(--pd-on-accent);border-radius:24px;text-decoration:none;font-weight:600;font-size:.9rem;width:fit-content}.writer3-cta:hover{color:var(--pd-on-accent);background:var(--pd-accent-hover);border-color:var(--pd-accent-hover)}.writer3-choice .writer3-cta{margin-top:auto}
.writer3-scope-notice{color:var(--pd-muted);margin-bottom:1.5rem}.writer3-workspace{display:grid;grid-template-columns:minmax(0,1.65fr) minmax(280px,1fr);align-items:start;gap:1.4rem}.writer3-panel{min-width:0;border:1px solid var(--pd-border);border-radius:12px;padding:clamp(1.1rem,2vw,1.8rem);background:var(--pd-surface);box-shadow:var(--pd-shadow)}.writer3-panel h2{font-size:1.45rem;color:var(--pd-heading);margin:0 0 .8rem}.writer3-panel h3{font-size:1.05rem;color:var(--pd-heading);margin:0 0 .5rem}.writer3-panel>p{line-height:1.6;max-width:70ch}.writer3-main{border-top-color:color-mix(in srgb,var(--pd-accent) 70%,var(--pd-border))}.writer3-reference{background:linear-gradient(145deg,var(--pd-surface),var(--pd-surface-2))}.writer3-caption{font-size:.82rem;line-height:1.6;color:var(--pd-muted);margin:1.1rem 0 0}.writer3-inset{margin:1.3rem 0;padding-top:1.2rem;border-top:1px solid var(--pd-border-subtle)}.writer3-inset:last-child{margin-bottom:0}.writer3-inset p{margin-bottom:.6rem}.writer3-link-list{display:grid;gap:0}.writer3-link-list>a,.writer3-link-list>button{display:flex;align-items:center;justify-content:space-between;gap:.6rem;width:100%;padding:.85rem 0;color:var(--pd-text);background:transparent;border:0;border-bottom:1px solid var(--pd-border-subtle);font:inherit;font-size:.95rem;text-align:left;text-decoration:none}.writer3-link-list>a:hover,.writer3-link-list>button:hover{color:var(--pd-accent)}.writer3-link-list>a>span,.writer3-link-list>button>span{color:var(--pd-accent)}
.writer3-explore-paths{display:grid;gap:.8rem;margin:1.3rem 0}.writer3-explore-paths>a{display:flex;align-items:center;gap:1.1rem;padding:1rem;border:1px solid var(--pd-border-subtle);background:var(--pd-surface-2);border-radius:8px;color:var(--pd-text);text-decoration:none}.writer3-explore-paths>a:hover{border-color:var(--pd-accent)}.writer3-explore-paths p{font-size:.87rem;margin:0;line-height:1.5;color:var(--pd-muted)}.writer3-path-mark{font-size:.85rem;color:var(--pd-accent);font-variant-numeric:tabular-nums}.writer3-explore-paths>a>span:last-child{margin-left:auto;color:var(--pd-accent)}.writer3-focus-kind{color:var(--pd-accent);font-weight:600}.writer3 .writer-objective-form{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem}.writer3 .writer-objective-form label{display:grid;gap:.5rem;font-size:.9rem}.writer3 .writer-objective-form>.button-row{grid-column:1/-1;flex-wrap:wrap}.writer3 .button-row{display:flex;align-items:center;gap:1rem;flex-wrap:wrap}.writer3 .writer-work-toolbar{padding:1rem 0 0;margin:1.4rem 0 0;border-bottom:0;background:transparent}.writer3 .writer-work-toolbar .muted{font-size:.79rem}.writer3 .writer-work-toolbar .button-row{gap:.75rem}.writer3-upcoming{list-style:none;padding:0;margin:1rem 0}.writer3-upcoming li{display:flex;gap:1rem;padding:.7rem 0;border-bottom:1px solid var(--pd-border-subtle)}.writer3-upcoming time{font-size:.8rem;color:var(--pd-muted);min-width:85px}.writer3-upcoming small{display:block;color:var(--pd-muted);font-size:.8rem;margin-top:.25rem}.writer3-stat-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.75rem;margin:1.5rem 0}.writer3-stat-grid strong{font-size:clamp(1.2rem,2vw,1.9rem);font-weight:600;display:block}.writer3-stat-grid span{font-size:.85rem;color:var(--pd-muted)}
.writer3 a:focus-visible,.writer3 button:focus-visible,.writer3 select:focus-visible{outline:3px solid var(--pd-focus);outline-offset:4px}.writer3 a:not(.writer3-choice):not(.writer3-cta){text-underline-offset:.2em}
@media(min-width:1100px) and (min-height:800px){.writer3-home{padding-top:2.5rem}.writer3-home-choices{margin-top:2rem}.writer3-destination .writer3-panel{max-height:calc(100dvh - 355px);overflow:auto;scrollbar-gutter:stable}}
@media(min-width:1100px) and (min-height:800px){.writer3-home{padding-top:clamp(1.4rem,4vh,3rem)}.writer3-home-choices{margin-top:1.4rem}}
@media(max-width:1000px){.writer3-workspace{grid-template-columns:minmax(0,1.3fr) minmax(240px,1fr);gap:1rem}.writer3-connection{max-width:210px}.writer3-choice h2{font-size:1.2rem}.writer3-desktop-break{display:none}}
@media(max-width:760px){.writer3{padding:.9rem .25rem 1.3rem}.writer3-header{flex-wrap:wrap;gap:.8rem;margin-bottom:1.2rem}.writer3-cover{width:42px;height:61px}.writer3-connection{width:100%;max-width:none;text-align:left;display:flex;flex-wrap:wrap;gap:.8rem;padding-left:0}.writer3-home-choices,.writer3-workspace{grid-template-columns:1fr;gap:1rem}.writer3-choice{min-height:0;gap:.65rem;padding:1.3rem}.writer3-choice small{min-height:0}.writer3-choice-icon{width:28px;height:28px}.writer3 .writer-objective-form{grid-template-columns:1fr}.writer3-stat-grid{gap:.4rem}.writer3-stat-grid strong{font-size:1.2rem}}
@media(prefers-reduced-motion:reduce){.writer3-choice{transition:none}}
@ -14,3 +14,29 @@
.writer3-panel:focus-visible{outline:3px solid var(--pd-focus);outline-offset:3px}
.writer3 .writer3-choice p{color:var(--pd-text)}
/* Enhanced destination workspace; without script the original fluid panels remain available. */
.writer3-viewport{height:var(--writer-workspace-height);display:flex;flex-direction:column;box-sizing:border-box;padding-top:1rem;padding-bottom:.6rem;overflow:visible}
.writer3-viewport>.writer3-header{flex:none;margin-bottom:.6rem}
.writer3-layout-tools{display:flex;justify-content:flex-end;gap:.5rem;flex:none;padding:0 0 .5rem}
.writer3-layout-tools button,.writer3-companion-close{min-height:40px}
.writer3-split{--writer-divider-size:18px;flex:1;min-height:0;position:relative;grid-template-columns:minmax(0,1fr) var(--writer-divider-size) var(--writer-companion-width);gap:0;align-items:stretch}
.writer3-split>.writer3-panel{min-height:0;max-height:none;height:100%;overflow:auto;scrollbar-gutter:stable;overflow-wrap:anywhere}
.writer3-divider{cursor:col-resize;touch-action:none;position:relative;border-radius:4px;align-self:stretch;min-height:44px}
.writer3-divider::after{content:"";position:absolute;left:7px;top:calc(50% - 24px);height:48px;width:4px;background:var(--pd-muted);border-radius:4px}
.writer3-divider:hover::after,.writer3-divider:focus-visible::after{background:var(--pd-accent)}
.writer3-divider:focus-visible{outline:2px solid var(--pd-focus);outline-offset:-3px}
.writer3-dragging,.writer3-dragging *{user-select:none!important;cursor:col-resize!important}
.writer3-split[data-collapsed=true],.writer3-split[data-narrow=true]{grid-template-columns:minmax(0,1fr)}
.writer3-split[data-narrow=true][data-overlay=true]>.writer3-reference{position:absolute;inset:0 0 0 auto;width:min(100%,520px);z-index:20;box-shadow:var(--pd-shadow);background:var(--pd-surface);border:2px solid var(--pd-accent)}
.writer3-companion-close{display:none;margin:0 0 1rem auto}
.writer3-flow{height:auto;min-height:0}
.writer3-flow .writer3-split{flex:none;min-height:0}
.writer3-flow .writer3-split>.writer3-panel{height:auto;overflow:visible}
.writer3-flow .writer3-split[data-overlay=true]>.writer3-reference{height:100%;overflow:auto}
.writer3-viewport [hidden]{display:none!important}
@media(pointer:coarse){.writer3-split:not([data-narrow=true]):not([data-collapsed=true]){--writer-divider-size:44px;grid-template-columns:minmax(0,1fr) var(--writer-divider-size) var(--writer-companion-width)}.writer3-divider::after{left:20px}.writer3-layout-tools button,.writer3-companion-close{min-height:44px}}
.writer3-shell:has(.writer3-viewport){padding-bottom:0;margin-bottom:0}
.writer3-shell:has(.writer3-viewport)>main{padding-bottom:0!important}
.writer3-split[data-narrow=true] .writer3-companion-close{display:block}

View File

@ -0,0 +1,159 @@
// Device-only layout preferences. Never contains or changes a story selection/session/native binding.
(() => {
const root = document.querySelector('.writer3-destination');
const destination = root?.dataset.writerDestination;
if (!['Write', 'Explore', 'Plan', 'Review', 'Reflect'].includes(destination)) return;
const workspace = root.querySelector('.writer3-workspace');
const main = workspace?.querySelector('.writer3-main');
const companion = workspace?.querySelector('.writer3-reference');
if (!workspace || !main || !companion) return; // Empty-book page remains accessible without a split.
const key = `plotdirector.writerLayout.v1.${root.dataset.layoutOwner || 'device'}.${destination}`;
let preference = { version: 1, width: .33, collapsed: false };
try {
const saved = JSON.parse(localStorage.getItem(key));
if (saved?.version === 1) {
if (typeof saved.width === 'number' && Number.isFinite(saved.width)) preference.width = Math.max(.15, Math.min(.6, saved.width));
if (typeof saved.collapsed === 'boolean') preference.collapsed = saved.collapsed;
}
} catch { /* Blocked storage and malformed/old preferences use safe defaults. */ }
function save() { try { localStorage.setItem(key, JSON.stringify(preference)); } catch { } }
const toolbar = document.createElement('div');
toolbar.className = 'writer3-layout-tools';
const toggle = document.createElement('button');
toggle.type = 'button'; toggle.className = 'btn btn-sm btn-outline-secondary';
toggle.setAttribute('aria-controls', 'writer3-companion');
toolbar.append(toggle);
const layoutHelp = document.createElement('button');
layoutHelp.type = 'button'; layoutHelp.className = 'btn btn-sm btn-outline-secondary';
layoutHelp.textContent = 'Layout Help'; layoutHelp.dataset.helpOpen = 'writer3.layout';
toolbar.append(layoutHelp); workspace.before(toolbar);
companion.id = 'writer3-companion';
const close = document.createElement('button');
close.type = 'button'; close.className = 'writer3-companion-close btn btn-sm btn-outline-secondary';
close.textContent = 'Hide companion'; companion.prepend(close);
const divider = document.createElement('div');
divider.className = 'writer3-divider'; divider.tabIndex = 0;
divider.setAttribute('role', 'separator'); divider.setAttribute('aria-orientation', 'vertical');
divider.setAttribute('aria-label', 'Resize contextual companion');
divider.setAttribute('aria-controls', 'writer3-companion');
divider.setAttribute('aria-describedby', 'writer3-resize-help');
const help = document.createElement('span'); help.id = 'writer3-resize-help'; help.className = 'visually-hidden';
help.textContent = 'Left arrow widens the companion; Right arrow narrows it. Shift changes in larger steps. Home narrows and End widens to the limit.';
toolbar.append(help); main.after(divider);
root.classList.add('writer3-viewport'); workspace.classList.add('writer3-split');
let narrow = false, overlay = false, frame = 0, drag = null, opener = toggle;
function bounds() {
const width = workspace.clientWidth - parseFloat(getComputedStyle(workspace).getPropertyValue('--writer-divider-size'));
return { width, min: Math.max(280, width * .22), max: Math.min(width * .55, width - 440) };
}
function render() {
const b = bounds();
const size = Math.max(b.min, Math.min(b.max, b.width * preference.width));
workspace.style.setProperty('--writer-companion-width', `${Math.round(size)}px`);
workspace.dataset.collapsed = String(preference.collapsed);
workspace.dataset.narrow = String(narrow);
workspace.dataset.overlay = String(overlay);
const visible = narrow ? overlay : !preference.collapsed;
companion.hidden = !visible;
divider.hidden = narrow || preference.collapsed;
toggle.textContent = visible ? 'Hide companion' : 'Show companion';
toggle.setAttribute('aria-expanded', String(visible));
close.textContent = narrow ? 'Back to workspace' : 'Hide companion';
divider.setAttribute('aria-valuemin', String(Math.round(b.min)));
divider.setAttribute('aria-valuemax', String(Math.max(Math.round(b.min), Math.round(b.max))));
divider.setAttribute('aria-valuenow', String(Math.round(size)));
divider.setAttribute('aria-valuetext', `${Math.round(size)} pixels, ${Math.round(size / b.width * 100)} percent companion width`);
}
let pointerFrame = 0, pointerX = null;
function applyPointer() {
pointerFrame = 0;
if (!drag || pointerX === null) return;
const b = bounds(), right = workspace.getBoundingClientRect().right;
preference.width = Math.max(b.min, Math.min(b.max, right - pointerX)) / b.width;
pointerX = null; render();
}
function endDrag(event) {
if (!drag || (event?.pointerId != null && drag.id !== event.pointerId)) return;
if (pointerFrame) cancelAnimationFrame(pointerFrame);
applyPointer();
const id = drag.id; drag = null; root.classList.remove('writer3-dragging');
if (divider.hasPointerCapture(id)) divider.releasePointerCapture(id);
save();
}
function measure() {
frame = 0;
const viewport = window.visualViewport;
const bottom = viewport ? viewport.height + viewport.offsetTop : innerHeight;
const top = root.getBoundingClientRect().top + window.scrollY;
// Read the actual shell/header position, including ribbon, banners and PWA chrome; no fixed offset.
const available = bottom - top;
// At very high text scaling / very short windows use document flow, never clip the heading/tools.
const header = root.querySelector('.writer3-header');
const style = getComputedStyle(root), headerStyle = header && getComputedStyle(header);
const chrome = (header?.getBoundingClientRect().height || 0) + toolbar.getBoundingClientRect().height
+ parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)
+ (headerStyle ? parseFloat(headerStyle.marginBottom) : 0);
root.classList.toggle('writer3-flow', available < chrome + 160);
root.style.setProperty('--writer-workspace-height', `${Math.max(0, Math.floor(available))}px`);
const next = workspace.clientWidth < 900;
if (next !== narrow) {
if (companion.contains(document.activeElement) && (next || preference.collapsed)) toggle.focus();
overlay = false; narrow = next; endDrag();
}
render();
}
function schedule() { if (!frame) frame = requestAnimationFrame(measure); }
function hide() {
if (companion.contains(document.activeElement)) toggle.focus();
if (narrow) overlay = false; else { preference.collapsed = true; save(); }
render();
}
toggle.addEventListener('click', () => {
if (narrow) {
overlay = !overlay; opener = toggle; render();
if (overlay) close.focus();
} else { preference.collapsed = !preference.collapsed; save(); render(); }
});
close.addEventListener('click', hide);
companion.addEventListener('keydown', event => {
if (event.key === 'Escape' && narrow && overlay) { event.preventDefault(); hide(); opener.focus(); }
});
// Non-modal contextual overlay: the application ribbon and Help remain usable; no focus trap.
root.addEventListener('focusout', () => {
if (narrow && overlay) queueMicrotask(() => {
if (!companion.contains(document.activeElement) && document.activeElement !== toggle) { overlay = false; render(); }
});
});
divider.addEventListener('keydown', event => {
const b = bounds(); let size = Math.max(b.min, Math.min(b.max, b.width * preference.width));
const step = event.shiftKey ? 50 : 10;
if (event.key === 'ArrowLeft') size += step;
else if (event.key === 'ArrowRight') size -= step;
else if (event.key === 'Home') size = b.min;
else if (event.key === 'End') size = b.max;
else return;
event.preventDefault(); preference.width = Math.max(b.min, Math.min(b.max, size)) / b.width; render(); save();
});
divider.addEventListener('pointerdown', event => {
if (!event.isPrimary || event.button !== 0) return;
event.preventDefault(); divider.focus();
drag = { id: event.pointerId }; divider.setPointerCapture(event.pointerId); root.classList.add('writer3-dragging');
});
divider.addEventListener('pointermove', event => {
if (drag?.id !== event.pointerId) return;
pointerX = event.clientX;
if (!pointerFrame) pointerFrame = requestAnimationFrame(applyPointer);
});
for (const name of ['pointerup', 'pointercancel', 'lostpointercapture']) divider.addEventListener(name, endDrag);
window.addEventListener('blur', () => endDrag());
window.addEventListener('pagehide', () => endDrag());
window.addEventListener('resize', () => { endDrag(); schedule(); });
window.addEventListener('plotdirector:ribbon-layout-changed', schedule);
document.addEventListener('fullscreenchange', schedule);
window.visualViewport?.addEventListener('resize', schedule);
window.visualViewport?.addEventListener('scroll', schedule);
const observer = new ResizeObserver(schedule);
for (const node of [root.querySelector('.writer3-header'), document.querySelector('[data-ribbon-shell]'), root.parentElement, document.querySelector('[data-help-layout]')]) if (node) observer.observe(node);
document.fonts?.ready.then(schedule);
measure();
})();