Unify Writer workspace layout, ribbon navigation and reader modes
BIN
Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Desk-alias.png
Normal file
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 287 KiB |
BIN
Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Home.png
Normal file
|
After Width: | Height: | Size: 182 KiB |
|
After Width: | Height: | Size: 87 KiB |
BIN
Docs/Writer/Writer3/Evidence/Layout-Phase1/Before/Plan-shown.png
Normal file
|
After Width: | Height: | Size: 244 KiB |
|
After Width: | Height: | Size: 140 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 239 KiB |
|
After Width: | Height: | Size: 160 KiB |
|
After Width: | Height: | Size: 351 KiB |
|
After Width: | Height: | Size: 221 KiB |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 322 KiB |
9
PlotLine.Tests/Browser/application-history.cjs
Normal file
@ -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(`<button data-app-back disabled>Back</button><a href="/b?bookId=22">B</a><a href="/redirect">C</a><a href="/d?bookId=22">D</a><form data-unsaved-form method="post"><input name="title" value="original"></form><script>${history}</script><script>${guard}</script>`);});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:`<a href="${base}/a?bookId=99">Enter</a>`}));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});
|
||||
@ -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: <script>unsafe\(\)<\/script>/);
|
||||
|
||||
36
PlotLine.Tests/Browser/writer-layout-phase1.cjs
Normal file
@ -0,0 +1,36 @@
|
||||
const{chromium}=require('playwright'),fs=require('fs'),assert=require('node:assert/strict');
|
||||
const identity=process.env.PD_LAYOUT_IDENTITY?JSON.parse(fs.readFileSync(process.env.PD_LAYOUT_IDENTITY)):null,w=identity||{UserID:4,project:7,book:12,chapter:21,chapter2:22};
|
||||
const base=identity?'https://dev.plotdirector.com':'http://127.0.0.1:5238',before=process.env.PD_LAYOUT_STAGE==='before',out=process.env.PD_LAYOUT_SCREENSHOTS;
|
||||
const paths=['Write','Explore','Plan','Review','Reflect'];
|
||||
(async()=>{const b=await chromium.launch();const results=[];try{for(const pwa of(before?[true]:[false,true])){
|
||||
const c=await b.newContext({viewport:{width:1440,height:1000}});await c.addInitScript(({u,pwa})=>{localStorage.setItem('plotdirector.desktop.v1.'+u,JSON.stringify({dismissedAt:Date.now()}));if(pwa)Object.defineProperty(navigator,'standalone',{value:true});},{u:w.UserID,pwa});const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));
|
||||
if(identity){await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);}
|
||||
const expand=async()=>{const x=p.locator('[data-ribbon-collapse]');if(await x.getAttribute('aria-expanded')==='false')await x.click();await p.waitForFunction(()=>!document.querySelector('[data-ribbon-collapse]').disabled);};
|
||||
const snap=async name=>{if(out&&pwa){fs.mkdirSync(out,{recursive:true});await p.screenshot({path:out+'/'+name+'.png',animations:'disabled'});}};
|
||||
for(const d of paths){await p.goto(`${base}/Writer/${d}?projectId=${w.project}&bookId=${w.book}`);await p.evaluate(()=>{for(const k of Object.keys(localStorage).filter(k=>k.startsWith('plotdirector.writerLayout.')))localStorage.removeItem(k)});await p.reload();if(!before)await expand();await p.waitForTimeout(150);const toggle=p.locator(before?'.writer3-layout-tools button':'[data-writer-companion-toggle]').first();assert(await p.locator('.writer3-reference').isVisible());const measure=()=>p.locator('.writer3-main').evaluate(n=>({working:(n.querySelector('.writer-objective-form,.writer3-explore-paths,.reader-controls,.writer3-stat-grid,.writer3-inset')||n).getBoundingClientRect().width,width:n.clientWidth,scroll:getComputedStyle(n).overflowY,child:[...n.children].filter(n=>n.getBoundingClientRect().width>0).map(n=>n.getBoundingClientRect().width),max:Math.max(...[...n.children].map(n=>n.getBoundingClientRect().width))}));const shown=await measure();await snap(d+'-shown');await toggle.click();await p.waitForTimeout(100);assert(await p.locator('.writer3-reference').isHidden());const hidden=await measure();await snap(d+'-hidden');
|
||||
if(!before){assert(hidden.width>shown.width+200);assert(hidden.working>shown.working+150,d+' internal working surface reflow');assert.equal(hidden.scroll,'visible');assert.equal(await p.locator('.writer3-layout-tools').count(),0);assert.equal(await p.locator('.writer3-header .writer3-cover').count(),0);assert.equal(await p.locator('.writer3-connection').count(),0);assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));await p.reload();assert(await p.locator('.writer3-reference').isHidden());await p.locator('[data-writer-companion-toggle]').click();assert(await p.locator('.writer3-reference').isVisible());const divider=p.locator('.writer3-divider');await divider.focus();const a=await p.locator('.writer3-reference').evaluate(n=>n.getBoundingClientRect().width);await p.keyboard.press('ArrowLeft');const z=await p.locator('.writer3-reference').evaluate(n=>n.getBoundingClientRect().width);assert(z>=a+5);await p.locator('[data-help-key="writer3.layout"] button').click();await p.locator('.plotline-help-popover').waitFor();await p.keyboard.press('Escape');}
|
||||
results.push({pwa,d,shown,hidden});
|
||||
}
|
||||
for(const [name,path]of[['Home','/Writer/Index'],['Desk-alias','/Writer/Overview'],['Scene-queues','/Writer/Workspaces'],['Reader-alias','/manuscript/reader']]){await p.goto(`${base}${path}?projectId=${w.project}&bookId=${w.book}&chapterId=${w.chapter}`);await snap(name);if(!before&&name==='Scene-queues'){assert(await p.locator('.writer-workspaces').isVisible());assert.equal(await p.locator('.writer-studio').evaluate(n=>[...n.children].filter(c=>getComputedStyle(c).display!=='none'&&!c.matches('.writer-heading,.writer-workspaces')).length),0);}if(!before&&name==='Reader-alias'){assert(p.url().includes('/Writer/Review'));assert(await p.locator('.manuscript-reader[data-reading=true]').count());}}
|
||||
if(!before){
|
||||
await p.goto(`${base}/Writer/Review?bookId=${w.book}&chapterId=${w.chapter}`);const t=p.locator('[data-writer-companion-toggle]');if(await p.locator('.writer3-reference').isVisible())await t.click();const centred=await p.locator('.reader-page').evaluate(n=>{const a=n.getBoundingClientRect(),b=n.closest('.writer3-main').getBoundingClientRect();return Math.abs((a.left+a.right-b.left-b.right)/2)});assert(centred<3);const nav=await p.locator('.reader-controls').evaluate(n=>({width:n.getBoundingClientRect().width,main:n.closest('.writer3-main').clientWidth}));assert(nav.width>nav.main*.9);await snap('Review-centred-toolbar');await p.locator('.reader-mode-controls a').click();assert(await p.locator('.writer3-reference').isHidden());await snap('Reading-mode');await p.locator('#reader-focus').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await snap('Focus-reading');await p.locator('.reader-controls a[rel=next]').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');assert.equal(await p.locator('.manuscript-reader').getAttribute('data-chapter-id'),String(w.chapter2));await snap('Focus-next-chapter');await p.locator('#reader-focus').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'false');
|
||||
for(const width of[1920,1024,800]){await p.setViewportSize({width,height:1000});await p.goto(`${base}/Writer/Review?bookId=${w.book}`);assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));await snap('Review-'+width);}
|
||||
await p.setViewportSize({width:1440,height:1000});await p.goto(`${base}/Writer/Review?bookId=${w.book}`);if(await p.locator('.writer3-reference').isHidden())await p.locator('[data-writer-companion-toggle]').click();for(const collapsed of[false,true]){const collapse=p.locator('[data-ribbon-collapse]');if((await collapse.getAttribute('aria-expanded')==='false')!==collapsed)await collapse.click();await p.evaluate(()=>window.scrollTo(0,1100));await p.waitForTimeout(200);const pos=await p.evaluate(()=>({top:document.querySelector('.writer3-reference').getBoundingClientRect().top,bottom:document.querySelector('.pd-application-header').getBoundingClientRect().bottom}));if(pwa)assert(pos.top>=pos.bottom-1);await snap(collapsed?'Sticky-collapsed':'Sticky-expanded');await p.evaluate(()=>window.scrollTo(0,0));}
|
||||
// An external history boundary must be disabled; all subsequent Back actions stay native/internal.
|
||||
await c.route('http://outside.invalid/**',r=>r.fulfill({contentType:'text/html',body:`<a href="${base}/Writer/Index?projectId=${w.project}&bookId=${w.book}">Enter</a>`}));await p.goto('http://outside.invalid/start');await p.getByText('Enter').click();await expand();assert(await p.locator('[data-app-back]').isDisabled());
|
||||
for(const d of['Write','Explore','Plan'])await p.locator('#ribbon-panel-writer').getByRole('link',{name:d,exact:true}).click();await p.locator('[data-ribbon-collapse]').click();for(const d of['Explore','Write','Index']){await p.locator('[data-app-back]').click();await p.waitForURL(u=>u.pathname.toLowerCase()==='/writer/'+d.toLowerCase());}assert(await p.locator('[data-app-back]').isDisabled());await snap('Ribbon-back-boundary');
|
||||
if(identity){
|
||||
// Follow actual authenticated ribbon links and nested entry points across modules.
|
||||
const trail=[];
|
||||
for(const [tab,label]of[['Characters','Characters'],['World','Locations'],['Book','Book overview'],['Writer','Review']]){
|
||||
await expand();await p.getByRole('tab',{name:tab,exact:true}).click();if(tab==='Writer'){await p.waitForURL(u=>u.pathname==='/Writer'||u.pathname==='/Writer/Index');trail.push(p.url());await expand();}
|
||||
await p.locator('.pd-ribbon-panel:not([hidden])').getByRole('link',{name:label,exact:true}).first().click();
|
||||
await p.waitForLoadState('load');trail.push(p.url());assert(await p.locator('[data-app-back]').isEnabled());
|
||||
}
|
||||
for(const expected of trail.slice(0,-1).reverse()){await p.locator('[data-app-back]').click();await p.waitForURL(expected);}
|
||||
await snap('Back-across-sections');results.push({pwa,crossSectionTrail:trail.map(u=>new URL(u).pathname)});
|
||||
}
|
||||
|
||||
}
|
||||
assert.deepEqual(errors,[]);await c.close();}
|
||||
console.log(JSON.stringify(results,null,2));console.log('PASS Writer layout Phase1: rendered reflow, persistent ribbon companion, divider, help, shared reading/focus, sticky chrome and native safe Back; before='+before);}finally{await b.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1});
|
||||
@ -111,6 +111,11 @@ internal static class ManuscriptReaderTests
|
||||
var cache = (ResponseCacheAttribute)System.Attribute.GetCustomAttribute(typeof(ManuscriptReaderController), typeof(ResponseCacheAttribute))!;
|
||||
Check(cache.NoStore && cache.Location == ResponseCacheLocation.None, "Private manuscript responses cannot be cached");
|
||||
Check(controller.Response.Headers["X-Robots-Tag"] == "noindex, nofollow, noarchive", "Manuscript indexing disabled");
|
||||
var authorisedUser=NativeWorkflowTests.Proxy<ICurrentUserService>((_,_)=>4);
|
||||
var compatible=new ManuscriptReaderController(service,authorisedUser,NullLogger<ManuscriptReaderController>.Instance){ControllerContext=new(){HttpContext=new DefaultHttpContext()}};
|
||||
var alias=(RedirectToActionResult)await compatible.Index(12,21,true);
|
||||
Check(alias.ControllerName=="Writer"&&alias.ActionName=="Review"&&(bool)alias.RouteValues!["reading"]!&&(bool)alias.RouteValues["focus"]!&&(int)alias.RouteValues["chapterId"]! ==21,"Reader bookmark resolves authorised shared reading mode and preserves Focus/chapter");
|
||||
var hash=first.ContentVersion;first.ReadingMode=true;first.FocusReading=true;Check(first.ContentVersion==hash,"presentation never changes manuscript identity or fingerprint");
|
||||
Console.WriteLine("PASS Manuscript Reader: scoped read-only retrieval, ordering, navigation, empty snapshot, accepted updates, pending isolation and accurate timestamps");
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ internal static class WriterDashboardTests
|
||||
var books=Proxy<IBookRepository>((method,args)=>method switch{"ListByProjectAsync"=>Task.FromResult<IReadOnlyList<Book>>([new(){BookID=2,ProjectID=1},new(){BookID=3,ProjectID=1}]),"GetAsync"=>Task.FromResult<Book?>(new(){BookID=(int)args![0]!,ProjectID=1}),_=>throw new Exception(method)});
|
||||
var access=Proxy<IProjectAccessService>((method,args)=>Task.FromResult(allowed));
|
||||
var controller=new WriterController(workspace,schedule,books,access);
|
||||
var result=(ViewResult)await controller.Index(1,3,"Revision");var model=(WriterDashboardViewModel)result.Model!;
|
||||
var result=(ViewResult)await controller.Workspaces(1,3,"Revision");var model=(WriterDashboardViewModel)result.Model!;
|
||||
Check(model.BookID==3&&model.WriteNext.Single().SceneID==30&&model.WritingSchedule.TodayTasks.Single().SceneID==30,"book selection filters queues and tasks consistently");
|
||||
Check(scheduledBook==3&&model.Workspace=="Revision","book scope reaches schedule service before selection and active workspace persists");
|
||||
Check(await controller.Index(1,999) is NotFoundResult,"unknown book cannot fall back to another book");
|
||||
@ -25,7 +25,7 @@ internal static class WriterDashboardTests
|
||||
Check(await controller.ScheduleSetup(99, 3) is NotFoundResult, "plan setup refuses conflicting project and book");
|
||||
allowed=false;Check(await controller.Index(null,3) is NotFoundResult,"book-only deep link checks access before metadata");
|
||||
Check(controller.LegacyWrite(1,3) is RedirectToActionResult redirect&&(int?)redirect.RouteValues!["bookId"]==3,"legacy Write redirect preserves book scope");
|
||||
var commands=WriterNavigation.RibbonGroups("Reflect").SelectMany(g=>g.Commands);Check(commands.Any(c=>c.Action=="Workspaces")&&commands.Any(c=>c.Controller=="WritingActivity"),"Writer contextual commands target implemented workspaces and evidence");
|
||||
var commands=WriterNavigation.RibbonGroups("Reflect").SelectMany(g=>g.Commands);Check(WriterNavigation.RibbonGroups("Write").SelectMany(g=>g.Commands).Any(c=>c.Action=="Workspaces"&&c.Label=="Scene queues")&&commands.Any(c=>c.Controller=="WritingActivity"),"Writer contextual commands target implemented workspaces and evidence");
|
||||
}
|
||||
private static T Proxy<T>(Func<string,object?[]?,object?> action)where T:class {var value=DispatchProxy.Create<T,WriterProxy>();((WriterProxy)(object)value).Action=action;return value;}
|
||||
public class WriterProxy:DispatchProxy
|
||||
|
||||
@ -37,13 +37,14 @@ internal static class WriterNavigationTests
|
||||
Check(model.BookID==13&&model.Objective==null&&model.WorkingContext?.Working==null,"destination "+destination+" never carries a focus into another book");
|
||||
Check(await load(999) is NotFoundResult,"destination "+destination+" refuses unavailable book");
|
||||
}
|
||||
Check(((ViewResult)await controller.Index(7,12,workspace:"Revision")).ViewName=="Legacy"&&((ViewResult)await controller.Index(7,12,journey:true)).ViewName=="Legacy","legacy query routes still reach their actual workspaces/calendar");
|
||||
Check((await controller.Index(7,12,workspace:"Revision") is RedirectToActionResult queueAlias&&queueAlias.ActionName=="Workspaces"&&(string?)queueAlias.RouteValues!["workspace"]=="Revision")&&((ViewResult)await controller.Index(7,12,journey:true)).ViewName=="Legacy","legacy query routes still reach their actual workspaces/calendar");
|
||||
Check(((WriterDashboardViewModel)((ViewResult)await controller.Index(7,12,setup:true)).Model!).Destination=="Write","old objective setup URL reaches Write");
|
||||
Check(((ViewResult)await controller.Workspaces(7,12)).ViewName=="Legacy"&&((ViewResult)await controller.Journey(7,12)).ViewName=="Legacy"&&((ViewResult)await controller.Overview(7,12)).ViewName=="Legacy","full legacy desk, Journey and Workspaces remain rendered, not retired");
|
||||
allowed=false;Check(await controller.Write(null,12) is NotFoundResult&&await controller.Explore(null,12) is NotFoundResult,"book-only new route checks access before metadata");
|
||||
foreach(var destination in WriterNavigation.Destinations){
|
||||
Check(WriterNavigation.BookSwitchAction(destination)==destination,"book switching retains "+destination+" without chapter parameters");
|
||||
var groups=WriterNavigation.RibbonGroups(destination);
|
||||
Check(!groups.Any(g=>g.Label=="Utilities"&&g.Commands.Any(c=>c.Action=="Workspaces"))&&!groups.SelectMany(g=>g.Commands).Any(c=>c.Label=="Writing desk"),"no duplicate desk/workspace destinations on "+destination);
|
||||
Check(groups[0].Commands.Select(x=>x.Action).SequenceEqual(new[]{"Index","Write","Explore","Plan","Review","Reflect"}),"single existing ribbon exposes all destinations on "+destination);
|
||||
}
|
||||
Check(WriterNavigation.BookSwitchAction("write")=="Write" && WriterNavigation.DestinationForAction("schedulepreview")=="Plan","case-insensitive bookmarked routes retain destination context");
|
||||
|
||||
@ -23,7 +23,7 @@ public sealed class ManuscriptReaderController(ManuscriptReaderService reader, I
|
||||
var model = await reader.Read(user, bookId, chapterId);
|
||||
if (model is null) return NotFound();
|
||||
model.FocusReading = focus;
|
||||
return View(model);
|
||||
return RedirectToAction("Review","Writer",new{bookId,chapterId,focus,reading=true});
|
||||
}
|
||||
catch (UnauthorizedAccessException) { return NotFound(); }
|
||||
catch (SqlException e) when (e.Number == 51000) { return NotFound(); }
|
||||
|
||||
@ -15,17 +15,21 @@ public sealed class WriterController(
|
||||
IBookRepository? bookRepository=null, IProjectAccessService? access=null, WritingActivityRepository? activity=null, WriterObjectiveRepository? objectives=null, WriterWorkRepository? work=null, PlotLine.Services.Writer.IWriterSuggestionProvider? suggestions=null, WriterPlanningRepository? planning=null) : Controller
|
||||
{
|
||||
public Task<IActionResult> Index(int? projectId, int? bookId = null, string? workspace = null, bool journey = false, int? year = null, int? month = null, DateTime? day = null, bool setup = false)
|
||||
=> LoadDestination(setup ? "Write" : journey || workspace != null ? "Legacy" : "Home", projectId, bookId, workspace, journey, year, month, day);
|
||||
{
|
||||
if(!setup&&!journey&&workspace!=null)return Task.FromResult<IActionResult>(RedirectToAction(nameof(Workspaces),new{projectId,bookId,workspace}));
|
||||
return LoadDestination(setup ? "Write" : journey ? "Legacy" : "Home", projectId, bookId, workspace, journey, year, month, day);
|
||||
}
|
||||
|
||||
public Task<IActionResult> Write(int? projectId, int? bookId = null) => LoadDestination("Write", projectId, bookId);
|
||||
public Task<IActionResult> Explore(int? projectId, int? bookId = null) => LoadDestination("Explore", projectId, bookId);
|
||||
public Task<IActionResult> Plan(int? projectId, int? bookId = null) => LoadDestination("Plan", projectId, bookId);
|
||||
[ResponseCache(NoStore=true,Location=ResponseCacheLocation.None)]
|
||||
public async Task<IActionResult> Review(int? projectId,int? bookId=null,int? chapterId=null,bool focus=false,[FromServices] PlotLine.Services.Manuscript.ManuscriptReaderService? reader=null)
|
||||
public async Task<IActionResult> Review(int? projectId,int? bookId=null,int? chapterId=null,bool focus=false,bool reading=false,[FromServices] PlotLine.Services.Manuscript.ManuscriptReaderService? reader=null)
|
||||
{
|
||||
Response.Headers["X-Robots-Tag"]="noindex, nofollow, noarchive";
|
||||
var result=await LoadDestination("Review",projectId,bookId);
|
||||
if(result is ViewResult {Model:WriterDashboardViewModel model}&&model.BookID.HasValue&&reader!=null){
|
||||
try{model.ReviewReader=await reader.Read(int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!),model.BookID.Value,chapterId);if(model.ReviewReader==null)return NotFound();model.ReviewReader.FocusReading=focus;model.ReviewReader.IntegratedReview=true;}
|
||||
try{model.ReviewReader=await reader.Read(int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!),model.BookID.Value,chapterId);if(model.ReviewReader==null)return NotFound();model.ReviewReader.FocusReading=focus;model.ReviewReader.IntegratedReview=true;model.ReviewReader.ReadingMode=reading;}
|
||||
catch(UnauthorizedAccessException){return NotFound();}
|
||||
catch(SqlException e)when(e.Number==51000){return NotFound();}
|
||||
catch(Exception e)when(e is SqlException or TimeoutException or System.Text.Json.JsonException){Response.StatusCode=503;return View("~/Views/ManuscriptReader/Unavailable.cshtml",new{BookId=model.BookID,ChapterId=chapterId});}
|
||||
|
||||
@ -11,7 +11,7 @@ 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.
|
||||
Write, Explore, Plan, Review and Reflect fill the available space below the application ribbon. The main work grows naturally and scrolls with the page. The companion stays below the visible ribbon and can scroll independently. Collapse the ribbon to gain more room. Normal page scrolling keeps dynamic content available, including at high text scaling. Home keeps its three simple choices.
|
||||
|
||||
# Resize with a pointer or keyboard
|
||||
|
||||
@ -19,11 +19,11 @@ Drag the handle between the panels with a mouse or touch pointer. Panel widths s
|
||||
|
||||
# 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.
|
||||
Use Hide companion in the ribbon’s Utilities group 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.
|
||||
When two usable columns do not fit, Show companion opens the same contextual content over the workspace. The ribbon action 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
|
||||
|
||||
@ -35,4 +35,4 @@ The contextual companion currently contains existing tool links and summaries. O
|
||||
|
||||
# Find layout Help
|
||||
|
||||
Layout Help and its adjacent question-mark icon sit with Show/Hide companion. The icon provides the existing tooltip and quick popup; Layout Help opens the full drawer. The question mark beside the destination title explains that destination. On PWA, Page Help remains in the contextual ribbon; expand the ribbon when it is collapsed.
|
||||
The circular Help icon beside Show/Hide companion in the ribbon’s Utilities group provides the existing tooltip and quick popup; Read more opens the full drawer. The question mark beside the destination title explains that destination. On PWA, Page Help remains in the contextual ribbon; expand the ribbon when it is collapsed.
|
||||
|
||||
@ -13,6 +13,7 @@ public sealed class ManuscriptReaderModel
|
||||
public long Revision { get; init; } = -1;
|
||||
public bool FocusReading { get; set; }
|
||||
public bool IntegratedReview {get;set;}
|
||||
public bool ReadingMode {get;set;}
|
||||
public Guid? ManuscriptID {get;init;}
|
||||
public string ContentVersion => Fingerprint(Paragraphs,ManuscriptID);
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ public static class RibbonPresentation
|
||||
return null;
|
||||
}
|
||||
public static IReadOnlyList<RibbonIcon> AdditionalIcons { get; } = [
|
||||
new("back", "M19 12H5m7-7-7 7 7 7", "planning"),
|
||||
new("undo", "M9 4L3 10l6 6 M3 10h10a7 7 0 0 1 7 7v3", "planning"),
|
||||
new("redo", "M15 4l6 6-6 6 M21 10H11a7 7 0 0 0-7 7v3", "planning"),
|
||||
new("previous", "M15 4l-8 8 8 8 M4 4v16", "calendar"),
|
||||
|
||||
@ -4,7 +4,7 @@ namespace PlotLine.Services;
|
||||
public static class WriterNavigation
|
||||
{
|
||||
public static IReadOnlyList<string> Destinations { get; } = Array.AsReadOnly(new[] { "Write", "Explore", "Plan", "Review", "Reflect" });
|
||||
private static readonly string[] BookSwitchActions = ["Write", "Explore", "Plan", "Review", "Reflect", "Dashboard", "Overview"];
|
||||
private static readonly string[] BookSwitchActions = ["Write", "Explore", "Plan", "Review", "Reflect", "Dashboard", "Overview", "Workspaces"];
|
||||
public static string BookSwitchAction(string? action) => BookSwitchActions.FirstOrDefault(x => string.Equals(x, action, StringComparison.OrdinalIgnoreCase)) ?? "Index";
|
||||
public static string DestinationForAction(string? action) => action?.ToLowerInvariant() switch
|
||||
{
|
||||
@ -35,15 +35,15 @@ public static class WriterNavigation
|
||||
};
|
||||
var context = destination switch
|
||||
{
|
||||
"Write" => new RibbonGroup("Current work", new("Chapters","bible","Books","Details","book"), new("Writing desk","writer","Writer","Overview","writerBook"), new("Writing Plan","calendar","Writer","WritingPlans","writerBook")),
|
||||
"Write" => new RibbonGroup("Current work", new("Chapters","bible","Books","Details","book"), new("Scene queues","threads","Writer","Workspaces","writerBook"), new("Writing Dashboard","metrics","Writer","Dashboard","writerBook"), new("Writing Plan","calendar","Writer","WritingPlans","writerBook")),
|
||||
"Explore" => new RibbonGroup("Story exploration", investigation ? new("Guided investigation","point","WriterInvestigations","Index","writerBook") : new("Problem Solver","point","WritingProblems","Index","global"), new("Story overview","timeline","Timeline","Index","writerBook")),
|
||||
"Plan" => new RibbonGroup("Writing plans", new("Writing Plan","calendar","Writer","WritingPlans","writerBook"), new("Schedule Preview","calendar","Writer","SchedulePreview","writerBook")),
|
||||
"Review" => new RibbonGroup("Reading & review", new("Manuscript Reader","bible","ManuscriptReader","Index","writerBook"), new("Writing desk","writer","Writer","Overview","writerBook")),
|
||||
"Review" => new RibbonGroup("Reading & review", new("Reading mode","bible","ManuscriptReader","Index","writerBook"), new("Writing Dashboard","metrics","Writer","Dashboard","writerBook")),
|
||||
"Reflect" => new RibbonGroup("Writing history", new("Writing Journey","calendar","Writer","Journey","writerBook"), new("Reports","metrics","WritingActivity","Index","writerBook",OwnerOnly:true)),
|
||||
_ => new RibbonGroup("Your writing", new("Writing Dashboard","metrics","Writer","Dashboard","writerBook"), new("Writing desk","writer","Writer","Overview","writerBook"))
|
||||
_ => new RibbonGroup("Your writing", new RibbonCommand("Writing Dashboard","metrics","Writer","Dashboard","writerBook"))
|
||||
};
|
||||
groups.Add(context);
|
||||
groups.Add(new("Utilities", new("Workspaces","threads","Writer","Workspaces","writerBook"), new("Display Setup","maps","Writer","DisplaySetup","writerBook")));
|
||||
groups.Add(new("Utilities", new RibbonCommand("Display Setup","maps","Writer","DisplaySetup","writerBook")));
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<div class="manuscript-reader" data-focus="@(Model.FocusReading ? "true" : "false")"
|
||||
data-book-id="@Model.Book.BookID" data-chapter-id="@Model.Chapter?.ChapterID" data-chapter-number="@Model.Chapter?.ChapterNumber"
|
||||
data-revision="@Model.Revision" data-version="@Model.ContentVersion"
|
||||
data-integrated-review="@Model.IntegratedReview.ToString().ToLowerInvariant()" data-check-url="@Url.Action("Changes","ManuscriptReader")" data-chapter-url="@Url.Action("Chapter","ManuscriptReader")">
|
||||
data-reading="@Model.ReadingMode.ToString().ToLowerInvariant()" data-integrated-review="@Model.IntegratedReview.ToString().ToLowerInvariant()" data-check-url="@Url.Action("Changes","ManuscriptReader")" data-chapter-url="@Url.Action("Chapter","ManuscriptReader")">
|
||||
@if(!Model.IntegratedReview){
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
<a asp-controller="Books" asp-action="Details" asp-route-id="@Model.Book.BookID">@Model.Book.BookTitle · Chapters</a>
|
||||
@ -19,11 +19,14 @@
|
||||
<div><p class="eyebrow">@Model.Book.BookTitle</p><h1>Manuscript Reader</h1><span class="status-pill">Read only</span></div>
|
||||
</header>
|
||||
}
|
||||
<div class="reader-mode-controls"><a asp-controller="Writer" asp-action="Review" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@Model.Chapter?.ChapterID" asp-route-reading="@(!Model.ReadingMode)">@(Model.ReadingMode?"Review mode":"Reading mode")</a></div>
|
||||
<a data-reader-exit-focus hidden="@(!Model.FocusReading)" class="btn btn-outline-secondary" asp-controller="Writer" asp-action="Review" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@Model.Chapter?.ChapterID" asp-route-reading="@Model.ReadingMode">Exit Focus Reading</a>
|
||||
<nav class="reader-controls" aria-label="Chapter navigation">
|
||||
@if (Model.PreviousId is int previous)
|
||||
{ <a class="btn btn-outline-secondary" asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@previous" asp-route-focus="@Model.FocusReading" rel="prev">← Previous chapter</a> }
|
||||
{ <a class="btn btn-outline-secondary" asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@previous" asp-route-focus="@Model.FocusReading" asp-route-reading="@Model.ReadingMode" rel="prev">← Previous chapter</a> }
|
||||
else { <span class="btn btn-outline-secondary disabled" aria-disabled="true">← Previous chapter</span> }
|
||||
<form method="get" asp-controller="@routeController" asp-action="@routeAction">
|
||||
<input type="hidden" name="reading" value="@Model.ReadingMode.ToString().ToLowerInvariant()" />
|
||||
<input type="hidden" name="focus" value="@Model.FocusReading.ToString().ToLowerInvariant()" />
|
||||
<input type="hidden" name="bookId" value="@Model.Book.BookID" />
|
||||
<label for="reader-chapter">Chapter</label>
|
||||
@ -34,7 +37,7 @@
|
||||
<button class="btn btn-outline-secondary" type="submit">Read</button>
|
||||
</form>
|
||||
@if (Model.NextId is int next)
|
||||
{ <a class="btn btn-outline-secondary" asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@next" asp-route-focus="@Model.FocusReading" rel="next">Next chapter →</a> }
|
||||
{ <a class="btn btn-outline-secondary" asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@next" asp-route-focus="@Model.FocusReading" asp-route-reading="@Model.ReadingMode" rel="next">Next chapter →</a> }
|
||||
else { <span class="btn btn-outline-secondary disabled" aria-disabled="true">Next chapter →</span> }
|
||||
<button type="button" class="btn btn-outline-secondary" id="reader-focus" aria-pressed="@Model.FocusReading.ToString().ToLowerInvariant()" hidden>Focus reading</button>
|
||||
</nav>
|
||||
@ -61,7 +64,7 @@
|
||||
{
|
||||
<section class="reader-empty" role="status"><h2>@(Model.Chapter?.ChapterTitle ?? "No chapters yet")</h2>
|
||||
<p>No accepted manuscript text is available for this chapter. Save and successfully synchronise it using Word Companion, then refresh this page.</p>
|
||||
<a class="btn btn-outline-secondary" asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@Model.Chapter?.ChapterID" asp-route-focus="@Model.FocusReading">Refresh manuscript</a>
|
||||
<a class="btn btn-outline-secondary" asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@Model.Chapter?.ChapterID" asp-route-focus="@Model.FocusReading" asp-route-reading="@Model.ReadingMode">Refresh manuscript</a>
|
||||
</section>
|
||||
}
|
||||
else
|
||||
@ -77,6 +80,6 @@
|
||||
</div>
|
||||
<footer class="reader-status muted"><p>Captured paragraph text and headings are preserved. Word formatting such as bold, italics, images and page layout is not available in this capture.</p>
|
||||
<a asp-controller="Books" asp-action="Details" asp-route-id="@Model.Book.BookID">Return to Chapters</a>
|
||||
<a asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@Model.Chapter?.ChapterID" asp-route-focus="@Model.FocusReading">Refresh manuscript</a>
|
||||
<a asp-controller="@routeController" asp-action="@routeAction" asp-route-bookId="@Model.Book.BookID" asp-route-chapterId="@Model.Chapter?.ChapterID" asp-route-focus="@Model.FocusReading" asp-route-reading="@Model.ReadingMode">Refresh manuscript</a>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@ -113,6 +113,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="pd-ribbon-heading">
|
||||
<button type="button" class="pd-history-back" data-app-back disabled aria-label="Back" title="Back to previous PlotDirector page"><svg class="pd-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@ApplicationRibbon.Icon("back").IconPath" /></svg><span>Back</span></button>
|
||||
<div class="pd-ribbon-tabs" role="tablist" aria-label="Command categories">
|
||||
@foreach (var category in ApplicationRibbon.Categories)
|
||||
{
|
||||
@ -158,6 +159,9 @@
|
||||
</a>
|
||||
}
|
||||
}
|
||||
@if(category.Key=="writer"&&group.Label=="Utilities"){
|
||||
<button type="button" class="pd-ribbon-command" data-writer-companion-toggle hidden aria-pressed="false"><svg class="pd-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@ApplicationRibbon.Icon("threads").IconPath" /></svg><span>Companion</span></button><help-icon key="writer3.layout" />
|
||||
}
|
||||
</div>
|
||||
<span class="pd-ribbon-group-label">@group.Label</span>
|
||||
</div>
|
||||
|
||||
@ -341,6 +341,7 @@
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@if (User.Identity?.IsAuthenticated == true)
|
||||
{
|
||||
<script src="~/js/application-history.js" asp-append-version="true"></script>
|
||||
<script src="~/js/application-navigation.js" asp-append-version="true"></script>
|
||||
@if (!isMarketingPage)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
var focus = Model.Objective?.SceneTitle ?? Model.Objective?.ChapterTitle;
|
||||
}
|
||||
<link rel="stylesheet" href="~/css/writer3.css" asp-append-version="true" />
|
||||
<div class="writer3 writer3-home" data-writer-destination="Home" data-writer-legacy-url="@Url.Action("Overview",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writer-write-url="@Url.Action("Write",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID">
|
||||
<div class="writer3 writer3-home" data-writer-destination="Home" data-writer-queues-url="@Url.Action("Workspaces",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writer-legacy-url="@Url.Action("Overview",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writer-write-url="@Url.Action("Write",new{projectId=Model.ProjectID,bookId=Model.BookID})" 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){<p class="writer3-scope-notice">Select a project and book in the application bar, or <a asp-controller="Projects" asp-action="Index">open your projects</a> to begin. You can explore writing problems before you have a manuscript.</p>}
|
||||
<section class="writer3-home-choices" aria-label="Choose where to begin">
|
||||
|
||||
@ -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 @@
|
||||
}
|
||||
<link rel="stylesheet" href="~/css/writer-work.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/writer-dashboard.css" asp-append-version="true" />
|
||||
<div class="writer-studio" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@bookId">
|
||||
<div class="writer-studio" data-writer-queues-view="@showWorkspace.ToString().ToLowerInvariant()" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@bookId">
|
||||
<header class="writer-heading" data-pwa-task>
|
||||
@if(!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){<img class="writer-book-cover" src="@Url.Content(Model.Book.CoverThumbnailPath)" alt="Cover of @bookTitle" />}else{<div class="writer-book-cover writer-cover-fallback" aria-hidden="true">@(bookTitle[..1])</div>}
|
||||
<div><p class="eyebrow">@(Model.Journey?"Writing Journey":"Your writing desk")</p><h1>@bookTitle</h1><help-icon key="workspace.overview" /><p class="muted">@(Model.Journey?"Accepted activity and the work ahead.":"Continue your manuscript, review your work, or choose what comes next.")</p></div>
|
||||
<div><p class="eyebrow">@(Model.Journey?"Writing Journey":showWorkspace?"Workflow":"Legacy writing tools")</p><h1>@(showWorkspace?"Scene queues":bookTitle)</h1><help-icon key="workspace.overview" /><p class="muted">@(Model.Journey?"Accepted activity and the work ahead.":"Continue your manuscript, review your work, or choose what comes next.")</p></div>
|
||||
<div class="writer-connection"><span class="writer-status-dot" aria-hidden="true"></span>Companion <strong data-writing-workspace-word aria-live="polite">Checking…</strong><a href="#display-setup">Connection & Display Setup</a></div>
|
||||
</header>
|
||||
@if(TempData["WriterWorkspaceMessage"] is string message){<p class="alert alert-info" role="status">@message</p>}
|
||||
|
||||
@ -5,15 +5,15 @@
|
||||
var heading = home ? title : Model.Destination == "Dashboard" ? "Writing Dashboard" : Model.Destination;
|
||||
}
|
||||
<header class="writer3-header" data-pwa-task>
|
||||
@if(!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){
|
||||
@if(home&&!string.IsNullOrWhiteSpace(Model.Book?.CoverThumbnailPath)){
|
||||
<img class="writer3-cover" src="@Url.Content(Model.Book.CoverThumbnailPath)" alt="Cover of @title" />
|
||||
}else{<div class="writer3-cover writer3-cover-empty" aria-hidden="true">@title[..1]</div>}
|
||||
}else if(home){<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>@if(!home && Model.Destination != "Dashboard"){<help-icon key="writer3.layout" />}</div>
|
||||
<p class="eyebrow">@(home ? "Writer Home" : "Writer")</p>
|
||||
<div class="writer3-title"><h1>@heading <help-icon key="@($"writer3.{Model.Destination.ToLowerInvariant()}")" /></h1></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 & Display Setup</a></div>
|
||||
|
||||
</header>
|
||||
@if(TempData["WriterWorkspaceMessage"] is string message){<p class="alert alert-info" role="status">@message</p>}
|
||||
@if(TempData["WriterWorkspaceError"] is string error){<p class="alert alert-warning" role="alert">@error</p>}
|
||||
|
||||
@ -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}}
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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}
|
||||
|
||||
@ -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}
|
||||
|
||||
31
PlotLine/wwwroot/js/application-history.js
Normal file
@ -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();
|
||||
})();
|
||||
@ -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');
|
||||
|
||||
@ -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();}
|
||||
|
||||
@ -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);}
|
||||
};
|
||||
|
||||
@ -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();
|
||||
})();
|
||||
|
||||