diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Desk-alias.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Desk-alias.png new file mode 100644 index 00000000..dec5c33a Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Desk-alias.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Explore-hidden.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Explore-hidden.png new file mode 100644 index 00000000..0b89e7c8 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Explore-hidden.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Explore-shown.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Explore-shown.png new file mode 100644 index 00000000..03da4880 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Explore-shown.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Home.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Home.png new file mode 100644 index 00000000..6d00da30 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Home.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-hidden.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-hidden.png new file mode 100644 index 00000000..b9e97248 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-hidden.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-shown.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-shown.png new file mode 100644 index 00000000..1af4a59e Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-shown.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reader-alias.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reader-alias.png new file mode 100644 index 00000000..2dbef82b Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reader-alias.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reflect-hidden.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reflect-hidden.png new file mode 100644 index 00000000..4b9d6cee Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reflect-hidden.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reflect-shown.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reflect-shown.png new file mode 100644 index 00000000..79643a58 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Reflect-shown.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Review-hidden.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Review-hidden.png new file mode 100644 index 00000000..877e883f Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Review-hidden.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Review-shown.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Review-shown.png new file mode 100644 index 00000000..836bf5d6 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Review-shown.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Scene-queues.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Scene-queues.png new file mode 100644 index 00000000..b92d2338 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Scene-queues.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Write-hidden.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Write-hidden.png new file mode 100644 index 00000000..859e1d6b Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Write-hidden.png differ diff --git a/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Write-shown.png b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Write-shown.png new file mode 100644 index 00000000..24c3a036 Binary files /dev/null and b/Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Write-shown.png differ diff --git a/PlotLine.Tests/Browser/application-history.cjs b/PlotLine.Tests/Browser/application-history.cjs new file mode 100644 index 00000000..65179891 --- /dev/null +++ b/PlotLine.Tests/Browser/application-history.cjs @@ -0,0 +1,9 @@ +// Native browser history edge cases exercised with the actual production history/unsaved-guard scripts. +const{chromium}=require('playwright'),fs=require('fs'),assert=require('node:assert/strict'); +const http=require('node:http'); +const history=fs.readFileSync('PlotLine/wwwroot/js/application-history.js','utf8'),guard=fs.readFileSync('PlotLine/wwwroot/js/form-navigation-guard.js','utf8'); +(async()=>{const server=http.createServer((req,res)=>{const u=new URL(req.url,'http://127.0.0.1');if(u.pathname==='/redirect'){res.writeHead(302,{location:'/c?bookId=22'});return res.end();}res.writeHead(200,{'content-type':'text/html'});res.end(`BCD
`);});await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));const base='http://127.0.0.1:'+server.address().port;const b=await chromium.launch();try{for(const fallback of[false,true]){const c=await b.newContext();if(fallback)await c.addInitScript(()=>Object.defineProperty(window,'navigation',{value:undefined}));const p=await c.newPage();await p.goto(base+'/a?bookId=12');assert(await p.locator('[data-app-back]').isDisabled());await p.getByRole('link',{name:'B',exact:true}).click();await p.waitForURL('**/b?bookId=22');await p.reload();assert(await p.locator('[data-app-back]').isEnabled());await p.getByRole('link',{name:'C',exact:true}).click();await p.waitForURL('**/c?bookId=22');assert(p.url().endsWith('/c?bookId=22'));await p.locator('[data-app-back]').click();await p.waitForURL('**/b?bookId=22');await p.locator('[data-app-back]').click();await p.waitForURL('**/a?bookId=12');assert(await p.locator('[data-app-back]').isDisabled());await p.goForward();await p.waitForURL('**/b?bookId=22');assert(await p.locator('[data-app-back]').isEnabled()); + await p.evaluate(()=>{history.pushState({existing:'kept'},'', '?bookId=22&filter=one');history.replaceState({...history.state,another:'kept'},'', '?bookId=22&filter=two');});assert.equal(await p.evaluate(()=>history.state.existing),'kept');assert.equal(await p.evaluate(()=>history.state.another),'kept');await p.locator('[data-app-back]').click();await p.waitForURL('**/b?bookId=22'); + await p.getByRole('link',{name:'D',exact:true}).click();await p.waitForURL('**/d?bookId=22');await p.locator('[name=title]').fill('unsaved draft');const dialogPromise=p.waitForEvent('dialog');const click=p.locator('[data-app-back]').click();const dialog=await dialogPromise;assert.equal(dialog.type(),'beforeunload');await dialog.dismiss();await click;assert(p.url().endsWith('/d?bookId=22'));assert.equal(await p.locator('[name=title]').inputValue(),'unsaved draft');await p.locator('[name=title]').fill('original'); + await c.route('http://outside.invalid/**',r=>r.fulfill({contentType:'text/html',body:`Enter`}));await p.goto('http://outside.invalid/');await p.getByText('Enter').click();assert(await p.locator('[data-app-back]').isDisabled());assert(p.url().startsWith(base)); + console.log('PASS global Back '+(fallback?'conservative fallback':'Navigation API')+': direct/empty/external boundary, repeat Back, redirect, refresh, Forward, push/replace state preservation, book queries and native unsaved guard');await c.close();}}finally{await b.close();server.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1}); diff --git a/PlotLine.Tests/Browser/manuscript-reader.cjs b/PlotLine.Tests/Browser/manuscript-reader.cjs index 078ce9c5..1888de6b 100644 --- a/PlotLine.Tests/Browser/manuscript-reader.cjs +++ b/PlotLine.Tests/Browser/manuscript-reader.cjs @@ -14,6 +14,7 @@ const base = process.env.PD_BROWSER_FIXTURE_URL || 'http://127.0.0.1:5238'; assert.match(response.headers()['cache-control'],/no-store/); assert.match(response.headers()['x-robots-tag'],/noindex/); await page.evaluate(theme => PlotDirectorApplyApplicationTheme(theme), theme); + await page.locator('.writer3-flow').waitFor(); // The reader alias now uses the measured shared workspace. const paragraphs = page.locator('.reader-paragraph'); assert.equal(await paragraphs.count(),3); assert.match(await paragraphs.nth(1).textContent(), /First paragraph: @if (User.Identity?.IsAuthenticated == true) { + @if (!isMarketingPage) { diff --git a/PlotLine/Views/Writer/Index.cshtml b/PlotLine/Views/Writer/Index.cshtml index 6282a6ed..d2271c08 100644 --- a/PlotLine/Views/Writer/Index.cshtml +++ b/PlotLine/Views/Writer/Index.cshtml @@ -6,7 +6,7 @@ var focus = Model.Objective?.SceneTitle ?? Model.Objective?.ChapterTitle; } -
+
@if(!Model.BookID.HasValue){

Select a project and book in the application bar, or open your projects to begin. You can explore writing problems before you have a manuscript.

}
diff --git a/PlotLine/Views/Writer/Legacy.cshtml b/PlotLine/Views/Writer/Legacy.cshtml index b7480503..0a6fb880 100644 --- a/PlotLine/Views/Writer/Legacy.cshtml +++ b/PlotLine/Views/Writer/Legacy.cshtml @@ -12,6 +12,7 @@ var showOpportunity = Model.Objective != null || opportunity != null || Model.PlannedActivities.Count > 0; var totals=Model.Activity?.Totals.HasAcceptedEvidence==true?Model.Activity.Totals:null; var showWorkspace = Context.Request.RouteValues["action"]?.ToString() == "Workspaces"; + if(showWorkspace)ViewData["Title"]="Scene queues"; var queues=new[]{("WriteNext","Write Next",Model.WriteNext),("InProgress","In Progress",Model.ContinueWriting),("Revision","Revision",Model.RevisionQueue),("FinalPass","Final Pass",Model.PolishingQueue)}; var latestAccepted = Model.Activity?.Events.FirstOrDefault(e => e.Kind != "Observation"); var manuscriptWords = latestAccepted?.WordsAfter ?? Model.Book?.CurrentWordCount; @@ -20,10 +21,10 @@ } -
+
@if(!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){Cover of @bookTitle}else{} -

@(Model.Journey?"Writing Journey":"Your writing desk")

@bookTitle

@(Model.Journey?"Accepted activity and the work ahead.":"Continue your manuscript, review your work, or choose what comes next.")

+

@(Model.Journey?"Writing Journey":showWorkspace?"Workflow":"Legacy writing tools")

@(showWorkspace?"Scene queues":bookTitle)

@(Model.Journey?"Accepted activity and the work ahead.":"Continue your manuscript, review your work, or choose what comes next.")

Companion Checking…Connection & Display Setup
@if(TempData["WriterWorkspaceMessage"] is string message){

@message

} diff --git a/PlotLine/Views/Writer/_Writer3Header.cshtml b/PlotLine/Views/Writer/_Writer3Header.cshtml index df7e4e7d..2cec71b1 100644 --- a/PlotLine/Views/Writer/_Writer3Header.cshtml +++ b/PlotLine/Views/Writer/_Writer3Header.cshtml @@ -5,15 +5,15 @@ var heading = home ? title : Model.Destination == "Dashboard" ? "Writing Dashboard" : Model.Destination; }
- @if(!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){ + @if(home&&!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){ Cover of @title - }else{} + }else if(home){}
-

@(home ? "Writer Home" : title)

-

@heading

@if(!home && Model.Destination != "Dashboard"){}
+

@(home ? "Writer Home" : "Writer")

+

@heading

@WriterNavigation.Purpose(Model.Destination)

-
Companion Checking…Connection & Display Setup
+
@if(TempData["WriterWorkspaceMessage"] is string message){

@message

} @if(TempData["WriterWorkspaceError"] is string error){} diff --git a/PlotLine/wwwroot/css/application-shell.css b/PlotLine/wwwroot/css/application-shell.css index fa8f149a..663f67ea 100644 --- a/PlotLine/wwwroot/css/application-shell.css +++ b/PlotLine/wwwroot/css/application-shell.css @@ -737,3 +737,9 @@ html[data-app-theme] .writing-context-page .writing-workspace-role-indicator { max-width: 100%; white-space: normal; border-color: var(--pd-border); background: var(--pd-selected); color: var(--pd-text); } + +.pd-history-back{display:inline-flex;align-items:center;gap:.3rem;border:0;background:transparent;color:var(--pd-text);padding:.5rem;flex:none} +.pd-history-back svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8} +.pd-history-back:disabled{opacity:.4}.pd-history-back:focus-visible{outline:2px solid var(--pd-focus)} +.app-layout .plotline-shell.writer3-shell{max-width:none;width:100%;padding-inline:clamp(8px,1.2vw,24px)} +@media(max-width:700px){.pd-history-back span{display:none}} diff --git a/PlotLine/wwwroot/css/manuscript-reader.css b/PlotLine/wwwroot/css/manuscript-reader.css index 8a6845c7..455497ce 100644 --- a/PlotLine/wwwroot/css/manuscript-reader.css +++ b/PlotLine/wwwroot/css/manuscript-reader.css @@ -18,3 +18,15 @@ body:has(.manuscript-reader[data-focus="true"]) { overflow: hidden; } .reader-live-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; color: var(--plotline-muted); } .reader-live-controls[hidden] { display: none; } .reader-paragraph { overflow-anchor: none; } + +/* Navigation is a full-width working toolbar; only prose has a reading measure. */ +.reader-controls{width:100%;max-width:none;display:grid;grid-template-columns:auto minmax(12rem,1fr) auto auto;align-items:center} +.reader-controls form{min-width:0;flex-wrap:nowrap} +.reader-controls select{min-width:0;width:100%} +.reader-page,.reader-empty{margin-inline:auto} +.manuscript-reader[data-focus=true]>.reader-mode-controls,.manuscript-reader[data-focus=true]>details,.manuscript-reader[data-focus=true]>footer,.manuscript-reader[data-focus=true]>[data-review-record]{display:none} +.manuscript-reader[data-focus=true]>.reader-controls{position:sticky;top:0;background:var(--plotline-paper);padding:.5rem;z-index:1} +@media(max-width:900px){.reader-controls{grid-template-columns:1fr 1fr}.reader-controls form{grid-column:1/-1;grid-row:1}.reader-controls #reader-focus{grid-column:1/-1}} +.manuscript-reader{container-type:inline-size} +@container(max-width:800px){.reader-controls{grid-template-columns:1fr 1fr}.reader-controls form{grid-column:1/-1;grid-row:1}.reader-controls #reader-focus{grid-column:1/-1}} +.manuscript-reader[data-focus=true] .reader-live-controls label,.manuscript-reader[data-focus=true] .reader-live-controls:has(#reader-apply-update[hidden]){display:none} diff --git a/PlotLine/wwwroot/css/writer-dashboard.css b/PlotLine/wwwroot/css/writer-dashboard.css index 2c854f13..8b5217d4 100644 --- a/PlotLine/wwwroot/css/writer-dashboard.css +++ b/PlotLine/wwwroot/css/writer-dashboard.css @@ -10,3 +10,6 @@ .writer-next-grid{grid-template-columns:minmax(0,2fr) minmax(230px,1fr)}.writer-start{border-top:4px solid var(--pd-primary,#576b78)}.writer-start-paths{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem;margin:1.3rem 0}.writer-path{display:flex;flex-direction:column;gap:.6rem;padding:1rem;border-left:3px solid var(--pd-primary,#576b78);background:var(--surface-alt,#8881);text-decoration:none;color:inherit}.writer-path:hover{background:#8882}.writer-path span{font-size:.9rem}.writer-objective-form{display:grid;gap:1rem;margin-top:1rem}.writer-objective-form label{display:grid;gap:.4rem}.writer-progress{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin:1rem 0}.writer-progress .writer-workflow-strip{grid-column:1/-1}.writer-workflow-strip{display:flex;flex-wrap:wrap;gap:1rem}.writer-workflow-strip a{text-decoration:none;padding:.5rem .8rem;background:#8881;border-radius:20px}.writer-workflow-strip strong{font-size:1.2rem;margin-right:.3rem}.writer-change-track{height:22px;display:flex;border-radius:12px;overflow:hidden;background:#8882;margin:1rem 0}.writer-change-added{background:#418a73}.writer-change-removed{background:#bd795d}.writer-journey-compact .writer-calendar{display:flex;gap:5px;flex-wrap:wrap}.writer-journey-compact .writer-day{width:18px;height:18px;min-height:18px;padding:0;border-radius:4px}.writer-journey-compact .writer-empty{margin-bottom:.5rem} @media(max-width:900px){.writer-next-grid{grid-template-columns:1fr}.writer-start-paths{grid-template-columns:1fr}.writer-progress{grid-template-columns:1fr}.writer-heading{flex-wrap:wrap}.writer-heading .writer-connection{width:100%}.writer-book-cover{width:52px;height:74px}} .writer-progress{border:0;background:linear-gradient(120deg,var(--pd-surface,#ffffff10),#8881);padding-block:1.5rem}.writer-progress h2{font-size:1.65rem}.writer-workflow-progress{display:flex;height:9px;border-radius:8px;overflow:hidden;grid-column:1/-1;background:#8882}.writer-stage-WriteNext{background:#9eabc2}.writer-stage-InProgress{background:#ad8a55}.writer-stage-Revision{background:#916884}.writer-stage-FinalPass{background:#538879}.writer-journey-compact{border:0;background:transparent;padding:1rem 0;box-shadow:none}.writer-journey-compact h2{font-size:1.4rem}.writer-journey-compact .writer-section-heading{margin-bottom:.7rem}.writer-queue-details>summary{cursor:pointer;margin-block:.8rem}.writer-queue-details[open]>summary{margin-bottom:1.2rem}.writer-next-grid>article:not(.writer-current):not(.writer-start){border:0;border-left:1px solid #8885;border-radius:0;background:transparent;box-shadow:none} + +/* The Workspaces compatibility route is the scene-queue activity. */ +.writer-studio[data-writer-queues-view=true]>:not(.writer-heading):not(.writer-workspaces){display:none} diff --git a/PlotLine/wwwroot/css/writer3.css b/PlotLine/wwwroot/css/writer3.css index 12c32263..bc8095e8 100644 --- a/PlotLine/wwwroot/css/writer3.css +++ b/PlotLine/wwwroot/css/writer3.css @@ -16,12 +16,12 @@ .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{height:auto;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-split>.writer3-panel{min-height:0;max-height:none;height:auto;overflow:visible;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)} @@ -46,7 +46,7 @@ .writer3-explore-paths>a>div{min-width:0} .writer3-layout-tools{align-items:center} .writer3-layout-tools .plotline-help-icon-wrapper{margin:0} -.writer3-split[data-collapsed=true]>.writer3-main>*{max-width:80ch} + .writer3-session-block{margin-top:1.4rem;padding-top:1.1rem;border-top:1px solid var(--pd-border-subtle)} .writer3 .writer3-session-block .writer-work-toolbar{margin:0;padding:.4rem 0 0;border:0} .writer3 .writer-work-toolbar .muted{max-width:80ch} @@ -87,12 +87,21 @@ [data-review-error]{border-left:3px solid var(--pd-accent);padding:.6rem} .writer3 .reader-metadata summary{font-size:.82rem;color:var(--pd-muted)} -/* Phase3D.1F: continuous manuscript reading uses the document, not a viewport panel. */ -.writer3-destination[data-writer-destination=Review]{height:auto;overflow:visible} -.writer3-destination[data-writer-destination=Review] .writer3-split{flex:none;align-items:start} -.writer3-destination[data-writer-destination=Review] .writer3-main{height:auto;max-height:none;overflow:visible;scrollbar-gutter:auto} -.writer3-destination[data-writer-destination=Review] .writer3-reference{position:sticky;top:1rem;height:auto;max-height:calc(100dvh - 2rem);overflow:auto} -.writer3-destination[data-writer-destination=Review] .writer3-divider{position:sticky;top:1rem;height:calc(100dvh - 2rem);align-self:start} -.writer3-destination[data-writer-destination=Review] .writer3-split[data-narrow=true][data-overlay=true]>.writer3-reference{position:fixed;inset:1rem 1rem 1rem auto;width:min(calc(100% - 2rem),520px);height:auto;max-height:calc(100dvh - 2rem);z-index:1040} .investigation{max-width:1200px;margin:1rem auto;padding:0 1rem}.investigation-choice{display:flex;gap:.7rem;padding:.8rem;border:1px solid var(--pd-border);border-radius:8px;margin:.6rem 0;align-items:baseline}.investigation-choice:has(input:checked){border-color:var(--pd-accent)}.investigation-actions{display:flex;flex-wrap:wrap;align-items:center;gap:.7rem;margin:1rem 0}.investigation textarea{margin:.6rem 0}.investigation pre{max-height:28rem;overflow:auto}.investigation fieldset{min-width:0} @media(max-width:800px){.investigation>.writer3-workspace{grid-template-columns:minmax(0,1fr)}} + +/* Writer Workspace Layout Phase1: fluid working surfaces, measured sticky chrome, document scrolling. */ +.writer3-destination{max-width:none;width:100%;height:auto;overflow:visible} +.writer3-destination .writer3-header{padding:0;margin-bottom:.75rem} +.writer3-destination .writer3-header .eyebrow,.writer3-destination .writer3-header>.writer3-cover,.writer3-destination .writer3-header>.writer3-cover-empty{display:none} +.writer3-destination .writer3-header h1{font-size:1.5rem} +.writer3-destination .writer3-header .muted{margin:.2rem 0;font-size:.9rem} +.writer3-destination .writer3-split{flex:none;align-items:start} +.writer3-destination .writer3-split>.writer3-main{height:auto;max-height:none;overflow:visible;scrollbar-gutter:auto;width:100%} +.writer3-destination .writer3-split>.writer3-reference{position:sticky;top:var(--writer-sticky-top,8px);height:auto;max-height:calc(100dvh - var(--writer-sticky-top,8px) - 8px);overflow:auto;align-self:start} +.writer3-destination .writer3-divider{position:sticky;top:var(--writer-sticky-top,8px);height:var(--writer-divider-height,44px);align-self:start} +.writer3-destination .writer3-split[data-narrow=true][data-overlay=true]>.writer3-reference{position:fixed;inset:var(--writer-sticky-top,8px) 8px 8px auto;max-height:calc(100dvh - var(--writer-sticky-top,8px) - 16px);height:auto;width:min(calc(100% - 16px),520px)} +.writer3-destination .writer3-main .writer3-inset,.writer3-destination .writer3-main .writer3-session-block,.writer3-destination .writer3-main .manuscript-reader{width:100%;max-width:none} +.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer3-split{grid-template-columns:minmax(0,1fr)} +.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer3-reference,.writer3-destination:has(.manuscript-reader[data-reading=true]) .writer3-divider{display:none!important} +.writer3-destination:has(.manuscript-reader[data-reading=true]) [data-review-record],.manuscript-reader[data-reading=true]>.reader-metadata,.manuscript-reader[data-reading=true]>details,.manuscript-reader[data-reading=true]>footer{display:none} diff --git a/PlotLine/wwwroot/js/application-history.js b/PlotLine/wwwroot/js/application-history.js new file mode 100644 index 00000000..8174f450 --- /dev/null +++ b/PlotLine/wwwroot/js/application-history.js @@ -0,0 +1,31 @@ +// Native history, with a conservative same-tab fallback when Navigation API is unavailable. +(() => { + const button=document.querySelector('[data-app-back]');if(!button)return; + const key='plotdirector.history.v1',field='plotdirectorHistory'; + let state={entries:{},current:null};try{state=JSON.parse(sessionStorage.getItem(key))||state;}catch{} + if(!state.entries||typeof state.entries!=='object')state={entries:{},current:null}; + const nativeReplace=history.replaceState.bind(history),nativePush=history.pushState.bind(history); + const internal=url=>{try{return typeof url==='string'&&url.length>0&&new URL(url,location.href).origin===location.origin;}catch{return false;}}; + const save=()=>{try{sessionStorage.setItem(key,JSON.stringify(state));}catch{}}; + function register(previous){ + if(history.state!=null&&(typeof history.state!=='object'||Array.isArray(history.state)))return; + const id=globalThis.crypto?.randomUUID?.()||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;state.entries[id]={url:location.href,previous,length:history.length};state.current=id; + nativeReplace({...history.state,[field]:id},'',location.href);state.entries[id].navigationKey=window.navigation?.currentEntry?.key;save(); + } + const known=history.state?.[field]; + if(known&&state.entries[known]){state.current=known;state.entries[known].url=location.href;state.entries[known].navigationKey=window.navigation?.currentEntry?.key;save();} + else {const prior=state.entries[state.current];let same=false;try{same=!!document.referrer&&internal(document.referrer)&&new URL(document.referrer).pathname+new URL(document.referrer).search===new URL(prior?.url).pathname+new URL(prior?.url).search;}catch{}register(same&&history.length>prior.length?state.current:null);} + function previous(){ + if(window.navigation?.entries){const rows=navigation.entries(),i=rows.findIndex(e=>e.key===navigation.currentEntry?.key);return i>0&&internal(rows[i-1].url)&&Object.values(state.entries).some(e=>e.navigationKey===rows[i-1].key&&e.url===rows[i-1].url);} + const entry=state.entries[history.state?.[field]];return !!entry?.previous&&!!state.entries[entry.previous]&&internal(state.entries[entry.previous].url); + } + const render=()=>button.disabled=!previous(); + history.pushState=function(...args){const prior=state.current;nativePush(...args);register(prior);render();}; + history.replaceState=function(value,title,url){const id=history.state?.[field];nativeReplace(value&&typeof value==='object'&&!Array.isArray(value)?{...value,...(id?{[field]:id}:{})}:value,title,url);if(id&&state.entries[id]){state.entries[id].url=location.href;state.entries[id].navigationKey=window.navigation?.currentEntry?.key;save();}render();}; + window.addEventListener('popstate',()=>{try{state=JSON.parse(sessionStorage.getItem(key))||state;}catch{}state.current=history.state?.[field]||null;save();render();}); + window.addEventListener('pageshow',()=>{try{state=JSON.parse(sessionStorage.getItem(key))||state;}catch{}state.current=history.state?.[field]||null;save();render();}); + window.addEventListener('hashchange',()=>{const id=history.state?.[field];if(!id||state.entries[id]?.url!==location.href)register(id||state.current);render();}); + window.navigation?.addEventListener('currententrychange',render); + button.addEventListener('click',()=>{if(previous())history.back();else render();}); + render(); +})(); diff --git a/PlotLine/wwwroot/js/manuscript-reader.js b/PlotLine/wwwroot/js/manuscript-reader.js index c86b81b0..20531cb8 100644 --- a/PlotLine/wwwroot/js/manuscript-reader.js +++ b/PlotLine/wwwroot/js/manuscript-reader.js @@ -18,13 +18,17 @@ let timer, request, busy = false, stopped = false, blocked = false, resumePending = false; const interval = 12000; + const subdued=new Map(); const setFocus = enabled => { + if(enabled){for(const node of document.querySelectorAll('.pd-application-header,.writer3-header,.writer3-reference')){if(!subdued.has(node))subdued.set(node,node.inert);node.inert=true;}} + else{for(const [node,previous] of subdued)node.inert=previous;subdued.clear();} root.dataset.focus = String(enabled); + const exit=root.querySelector('[data-reader-exit-focus]');if(exit)exit.hidden=true; // Link remains a no-script exit; the live toolbar has its own focus toggle. document.body.classList.toggle('reader-focused', enabled); focus.setAttribute('aria-pressed', String(enabled)); focus.textContent = enabled ? 'Exit focus reading' : 'Focus reading'; root.querySelector('input[name="focus"]').value = String(enabled); - root.querySelectorAll('a').forEach(link => { + root.querySelectorAll('a:not([data-reader-exit-focus])').forEach(link => { const url = new URL(link.href); if (url.origin === location.origin && url.pathname.replace(/\/$/, '').toLowerCase() === location.pathname.replace(/\/$/, '').toLowerCase()) { if (enabled) url.searchParams.set('focus', 'true'); else url.searchParams.delete('focus'); diff --git a/PlotLine/wwwroot/js/writer-review.js b/PlotLine/wwwroot/js/writer-review.js index 8ca38c55..da0ca5ea 100644 --- a/PlotLine/wwwroot/js/writer-review.js +++ b/PlotLine/wwwroot/js/writer-review.js @@ -9,7 +9,7 @@ function wordReference(id){if(!word)return;word.dataset.paragraphId=id||'';word. function queueContext(){clearTimeout(selectionTimer);selectionTimer=setTimeout(()=>void load(false),180);} async function load(force=true){clearTimeout(selectionTimer);const key=[selected,anchor?.EndParagraph,reader.dataset.version,page].join(':');if(!force&&key===lastContext)return;const mine=++generation;controller?.abort();controller=new AbortController();loading=true;const url=new URL(root.dataset.panelUrl,location.href);url.search=new URLSearchParams({bookId:root.dataset.book,chapterId:root.dataset.chapter,version:reader.dataset.version,page:String(page),...(selected?{paragraphId:selected,endParagraphId:anchor?.EndParagraph||selected}:{})});try{const response=await fetch(url,{cache:'no-store',signal:controller.signal});if(!response.ok)throw Error();const doc=new DOMParser().parseFromString(await response.text(),'text/html'),panel=doc.querySelector('[data-review-panel]');if(!panel)throw Error();if(mine===generation){context.replaceChildren(panel);lastContext=key;}}catch(e){if(e.name!=='AbortError'&&mine===generation){message.textContent='Recorded review information could not load. Your observation text is retained.';}}finally{if(mine===generation)loading=false;}} function pause(enabled){const input=reader.querySelector('#reader-pause');if(enabled){pauseBefore=input.checked;input.checked=true;}else input.checked=pauseBefore;input.dispatchEvent(new Event('change'));} -function showEditor(){if(reader.dataset.focus==='true'){const restore=reader.readerPreserveView?.();reader.querySelector('#reader-focus').click();restore?.();}const aside=root.closest('.writer3-reference');if(aside.hidden)document.querySelector('.writer3-layout-tools button').click();form.hidden=false;newButton.hidden=true;field('Observation').focus();} +function showEditor(){if(reader.dataset.focus==='true'){const restore=reader.readerPreserveView?.();reader.querySelector('#reader-focus').click();restore?.();}const aside=root.closest('.writer3-reference');if(aside.hidden)document.querySelector('[data-writer-companion-toggle]')?.click();form.hidden=false;newButton.hidden=true;field('Observation').focus();} function begin(){if(busy)return;if(dirty){field('Observation').focus();return;}anchor=capture()||anchor;selected=anchor?.StartParagraph||null;wordReference(selected);void load();field('ID').value=crypto.randomUUID();field('Version').value='0';field('ContentVersion').value=reader.dataset.version;for(const n of['StartParagraph','EndParagraph','StartOffset','EndOffset'])field(n).value=anchor?.[n]??'';field('Observation').value='';field('Decision').value='';field('Status').value='Open';error.hidden=true;pause(true);dirty=true;reference.textContent=anchor?'Observation linked to the selected accepted paragraph(s).':'Chapter-level observation; no exact passage is claimed.';showEditor();} reader.querySelector('#reader-focus').addEventListener('click',e=>{if(dirty&&reader.dataset.focus!=='true'){e.preventDefault();e.stopImmediatePropagation();message.textContent='Save or Cancel the observation before entering Focused Reading.';}},true); function finish(){form.hidden=true;newButton.hidden=false;dirty=false;error.hidden=true;pause(false);newButton.focus();} diff --git a/PlotLine/wwwroot/js/writer3-navigation.js b/PlotLine/wwwroot/js/writer3-navigation.js index f3d1b929..91f034b1 100644 --- a/PlotLine/wwwroot/js/writer3-navigation.js +++ b/PlotLine/wwwroot/js/writer3-navigation.js @@ -5,7 +5,7 @@ if(!home)return; const restore=()=>{ const hash=location.hash; - const path=['#display-setup','#workspaces'].includes(hash)?home.dataset.writerLegacyUrl: + const path=hash==='#workspaces'?home.dataset.writerQueuesUrl:hash==='#display-setup'?home.dataset.writerLegacyUrl: ['#working-focus','#working-objective','#objective-setup'].includes(hash)?home.dataset.writerWriteUrl:null; if(path){const target=new URL(path,location.origin);if(hash!=='#working-focus'&&path===home.dataset.writerWriteUrl)target.searchParams.set('setup','true');target.hash=hash;location.replace(target.pathname+target.search+target.hash);} }; diff --git a/PlotLine/wwwroot/js/writer3-workspace.js b/PlotLine/wwwroot/js/writer3-workspace.js index f2c2e850..d97864a1 100644 --- a/PlotLine/wwwroot/js/writer3-workspace.js +++ b/PlotLine/wwwroot/js/writer3-workspace.js @@ -17,30 +17,11 @@ } } 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); - // Keep the existing Markdown tooltip/popover beside the labelled layout controls. - const layoutArticle = root.querySelector('[data-help-key="writer3.layout"]'); - if (layoutArticle) { - toolbar.append(layoutArticle); - layoutArticle.addEventListener('shown.bs.tooltip', event => { - const tip = document.getElementById(event.target.getAttribute('aria-describedby')); - tip?.classList.add('writer3-layout-tooltip'); - }); - } - workspace.before(toolbar); + const toggle = document.querySelector('[data-writer-companion-toggle]'); + if(!toggle)return; + toggle.hidden=false; + const toolbar=toggle.closest('.pd-ribbon-group'); 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'); @@ -63,12 +44,17 @@ workspace.dataset.collapsed = String(preference.collapsed); workspace.dataset.narrow = String(narrow); workspace.dataset.overlay = String(overlay); - const visible = narrow ? overlay : !preference.collapsed; + const reading=root.querySelector('.manuscript-reader')?.dataset.reading==='true'; + const visible = !reading && (narrow ? overlay : !preference.collapsed); + toggle.disabled=reading; companion.hidden = !visible; divider.hidden = narrow || preference.collapsed; - toggle.textContent = visible ? 'Hide companion' : 'Show companion'; + const top=parseFloat(getComputedStyle(root).getPropertyValue('--writer-sticky-top'))||8; + const panelHeight=Math.max(main.offsetHeight,companion.offsetHeight); + workspace.style.setProperty('--writer-divider-height',`${Math.max(44,Math.min(panelHeight,(window.visualViewport?.height||innerHeight)-top-8))}px`); + toggle.querySelector('span').textContent = reading ? 'Companion (Review mode)' : visible ? 'Hide companion' : 'Show companion'; + toggle.setAttribute('aria-pressed',String(visible)); 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))); @@ -92,19 +78,10 @@ } function measure() { frame = 0; - const viewport = window.visualViewport; - const bottom = viewport ? viewport.height + viewport.offsetTop : innerHeight; - const top = root.getBoundingClientRect().top; - // 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', destination === 'Review' || available < chrome + 160); - root.style.setProperty('--writer-workspace-height', `${Math.max(0, Math.floor(available))}px`); + const shell=document.querySelector('.pd-application-header'); + const sticky=shell&&getComputedStyle(shell).position==='sticky'?shell.getBoundingClientRect().height:0; + root.style.setProperty('--writer-sticky-top',`${Math.ceil(sticky)+8}px`); + root.classList.add('writer3-flow'); const next = workspace.clientWidth < 900; if (next !== narrow) { if (companion.contains(document.activeElement) && (next || preference.collapsed)) toggle.focus(); @@ -121,10 +98,9 @@ toggle.addEventListener('click', () => { if (narrow) { overlay = !overlay; opener = toggle; render(); - if (overlay) close.focus(); + if (overlay) companion.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(); } }); @@ -164,7 +140,7 @@ 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); + for (const node of [main,companion,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(); })();