Make Review a permanent resizable editorial workspace with ribbon commands
This commit is contained in:
parent
9493e737d6
commit
c43fe5d12d
20
PlotLine.Tests/Browser/review-layout-checks.cjs
Normal file
20
PlotLine.Tests/Browser/review-layout-checks.cjs
Normal file
@ -0,0 +1,20 @@
|
||||
const assert=require('node:assert/strict');
|
||||
// Uses rendered user content; no transport interception or layout substitutes.
|
||||
module.exports=async function reviewLayout(page,pwa,shot=async()=>{}){
|
||||
await page.waitForLoadState('networkidle');await page.evaluate(()=>scrollTo(0,0));await page.waitForTimeout(120);const columns=page.locator('[data-review-columns]'),left=page.locator('#review-chapter-notes'),right=page.locator('#review-scene-notes');
|
||||
const measure=()=>page.evaluate(()=>{const root=document.querySelector('[data-review-columns]');return [...root.children].map(n=>({x:n.getBoundingClientRect().x,width:n.getBoundingClientRect().width,top:n.getBoundingClientRect().top,bottom:n.getBoundingClientRect().bottom}));});
|
||||
assert.equal(await columns.getAttribute('data-compact'),'false');assert.equal(await page.locator('[data-editorial-toggle]').count(),0);assert.equal(await page.locator('.writer3-reference').count(),0);
|
||||
let boxes=await measure(),width=await columns.evaluate(n=>n.clientWidth-16);assert(Math.abs(boxes[0].width/width-.25)<.02);assert(Math.abs(boxes[4].width/width-.25)<.02);assert(boxes[0].x<boxes[2].x&&boxes[2].x<boxes[4].x);
|
||||
for(const [which,offset] of [['left',35],['right',-25]]){const divider=page.locator('[data-review-divider='+which+']'),b=await divider.boundingBox();await page.mouse.move(b.x+b.width/2,b.y+25);await page.mouse.down();await page.mouse.move(b.x+b.width/2+offset,b.y+25,{steps:8});await page.mouse.up();}
|
||||
boxes=await measure();const saved=[boxes[0].width,boxes[4].width];assert(saved[0]>width*.25+20&&saved[1]>width*.25+10,'both pointer dividers resize '+JSON.stringify({saved,width}));await page.reload();await page.locator('[data-review-panel]').waitFor();await page.waitForTimeout(100);boxes=await measure();assert(Math.abs(boxes[0].width-saved[0])<3&&Math.abs(boxes[4].width-saved[1])<3,'widths persist after refresh');
|
||||
const divider=page.locator('[data-review-divider=left]');await divider.focus();await divider.press('ArrowLeft');assert(Number(await divider.getAttribute('aria-valuenow'))<saved[0],'keyboard resizing');await page.evaluate(()=>scrollTo(0,0));await shot('Review-top');
|
||||
for(const position of await page.locator('#reader-content').evaluate(n=>n.offsetHeight>innerHeight*2)?['middle','bottom']:[]){await page.evaluate(position=>{const a=document.querySelector('#reader-content');scrollTo(0,position==='middle'?a.offsetTop+a.offsetHeight/2:document.documentElement.scrollHeight-innerHeight-8);},position);await page.waitForTimeout(160);boxes=await measure();const header=await page.locator('.pd-application-header').boundingBox();for(const index of [0,4])assert(boxes[index].top>=Math.min(8,header?.bottom||8)-2&&boxes[index].top<400,'notes remain visible '+position);assert(await left.isVisible()&&await right.isVisible());await shot('Review-'+position,false);}
|
||||
for(const note of [left,right]){const overflow=await note.evaluate(n=>n.scrollHeight>n.clientHeight);if(overflow){const moved=await note.evaluate(n=>{const before=scrollY;n.scrollTop=80;return {before,after:scrollY,notes:n.scrollTop};});assert(moved.notes>0);assert.equal(moved.after,moved.before,'notes scroll independently');}}
|
||||
await page.evaluate(()=>scrollTo(0,0));await page.locator('[data-review-diagnostics-open]').click();assert.equal(await page.locator('[data-review-diagnostics]').evaluate(n=>n.open),true);assert(await page.locator('[data-writer-word]').isVisible());await page.locator('[data-review-diagnostics] summary').first().click();
|
||||
if(pwa){for(const id of ['reader-focus','reader-audio','reader-pause-toggle']){assert.equal(await page.locator('.pd-context-command[data-command-identity="handler:'+id+'"]').count(),1);assert.equal(await page.locator('#'+id).isVisible(),false,'native command suppressed only after ribbon composition');}await page.locator('.pd-context-command[data-command-identity="handler:reader-pause-toggle"]').click();assert.equal(await page.locator('#reader-pause').isChecked(),true);assert.equal(await page.locator('.pd-context-command[data-command-identity="handler:reader-pause-toggle"]').getAttribute('aria-pressed'),'true');await page.locator('.pd-context-command[data-command-identity="handler:reader-pause-toggle"]').click();}
|
||||
const focus=pwa?page.locator('.pd-context-command[data-command-identity="handler:reader-focus"]'):page.locator('#reader-focus');await focus.click();assert.equal(await left.isVisible(),false);assert.equal(await right.isVisible(),false);assert(await page.locator('#reader-focus').isVisible());await page.locator('#reader-focus').click();assert(await left.isVisible()&&await right.isVisible());
|
||||
const audio=pwa?page.locator('.pd-context-command[data-command-identity="handler:reader-audio"]'):page.locator('#reader-audio');await audio.click();assert(await page.locator('#reader-audio-dialog').isVisible());await page.locator('[data-reader-audio-close]').click();
|
||||
for(const width of [1666,1366,1024,800]){await page.setViewportSize({width,height:1100});await page.waitForTimeout(120);assert(await left.isVisible()&&await right.isVisible());assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),'no horizontal overflow '+width);if(width===800){assert.equal(await columns.getAttribute('data-compact'),'true');assert((await page.locator('.writer21-manuscript').boundingBox()).width>600);}await shot('Review-width-'+width);}
|
||||
for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']){await page.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),'theme '+theme);await shot('Review-'+theme);}
|
||||
await page.setViewportSize({width:1920,height:1100});await page.evaluate(()=>scrollTo(0,0));
|
||||
};
|
||||
@ -3,7 +3,7 @@ const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('nod
|
||||
const who=JSON.parse(fs.readFileSync(process.env.PD_PHASE21_IDENTITY)),s=JSON.parse(fs.readFileSync(process.env.PD_PHASE21_SCOPE)),base='https://dev.plotdirector.com',out=process.env.PD_PHASE21_SCREENSHOTS;
|
||||
assert(who.Database==='PlotDirector_Development'&&/^pwa-browser-.*@example\.invalid$/.test(who.Email));
|
||||
(async()=>{const browser=await chromium.launch();try{for(const pwa of [false,true]){const label=String(pwa)+'-'+crypto.randomUUID().slice(0,6);const c=await browser.newContext({viewport:{width:1920,height:1100}});await c.addInitScript(({user,pwa})=>{localStorage.setItem('plotdirector.desktop.v1.'+user,JSON.stringify({dismissedAt:Date.now()}));if(pwa)Object.defineProperty(navigator,'standalone',{value:true});},{user:who.UserID,pwa});const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));p.on('dialog',d=>d.accept());let popups=0;c.on('page',page=>{if(page!==p)popups++;});const url=(d,b=s.book)=>`${base}/Writer/${d}?bookId=${b}&projectId=${s.project}`;
|
||||
const shot=async name=>{if(!out||pwa)return;fs.mkdirSync(out,{recursive:true});await p.waitForTimeout(220);await p.evaluate(()=>window.scrollTo(0,0));await p.mouse.move(1,1090);await p.waitForTimeout(80);await p.screenshot({path:out+'/'+name+'.png',animations:'disabled'});};
|
||||
const shot=async (name,reset=true)=>{if(!out||pwa)return;fs.mkdirSync(out,{recursive:true});await p.waitForTimeout(220);if(reset)await p.evaluate(()=>window.scrollTo(0,0));await p.mouse.move(1,1090);await p.waitForTimeout(80);await p.screenshot({path:out+'/'+name+'.png',animations:'disabled'});};
|
||||
await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(who.Email);await p.locator('[name=Password]').fill(who.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);
|
||||
await p.goto(url('Write'));if(await p.locator('[data-ribbon-collapse]').getAttribute('aria-expanded')==='false')await p.locator('[data-ribbon-collapse]').click();const exportSessions=async()=>await(await p.request.get(base+'/Writer/Work/Export?bookId='+s.book)).json();const before=await exportSessions();
|
||||
if(!await p.locator('[data-focus-wizard]').isVisible())await p.locator('[data-change-focus]').click();const focus=p.locator('[data-focus-wizard]');await focus.locator('[name=Activity]').selectOption('Revising');await focus.locator('[data-focus-next]').click();await focus.locator('[name=ChapterID]').selectOption(String(s.chapter));await focus.locator('[name=SceneID]').selectOption(String(s.scene));await focus.locator('[data-focus-next]').click();await focus.locator('[name=Intention]').fill('Phase21 selected arrival');await focus.locator('[data-save-focus]').click();await p.locator('[data-focus-summary]').filter({hasText:'Phase21 selected arrival'}).waitFor();assert((await p.locator('[data-focus-summary] a').getAttribute('href')).endsWith('/Scenes/Edit/'+s.scene));assert.deepEqual(await exportSessions(),before);
|
||||
@ -32,9 +32,9 @@ await p.goto(url('Review')+'&chapterId='+s.chapter);await p.locator('[data-revie
|
||||
const para=p.locator('#reader-content [data-scene-id="'+s.scene+'"]').first();await para.click();await p.waitForFunction(scene=>document.querySelector('[data-review-panel]')?.dataset.selectedScene===String(scene),s.scene);for(const scope of ['Scene','Passage']){await p.locator('[data-review-new]').click();await form.locator('[name=Scope]').selectOption(scope);await form.locator('[name=Observation]').fill(scope+' editorial note '+label);await form.locator('[name=Classification]').selectOption('Pacing');await form.locator('[data-review-save]').click();await p.locator('[data-observation]').filter({hasText:scope+' editorial note '+label}).waitFor();}
|
||||
const note=p.locator('[data-observation]').filter({hasText:'Passage editorial note '+label});await note.locator('[data-review-edit]').click();await form.locator('[name=Classification]').selectOption('Research');await form.locator('[name=Status]').selectOption('Resolved');await form.locator('[data-review-save]').click();await p.locator('[data-observation][data-status=Resolved]').filter({hasText:'Passage editorial note '+label}).waitFor();await note.locator('[data-review-revisit]').click();await p.evaluate(()=>scrollTo(0,0));await shot('Review-both-notes');
|
||||
const chapterCard=p.locator('#review-chapter-notes [data-authoring-card][data-kind=Chapter]');await chapterCard.locator('[data-authoring-edit]').click();await chapterCard.locator('[name=Summary]').fill('Synthetic chapter summary edited directly in Review');await chapterCard.locator('[data-authoring-save]').click();await chapterCard.locator('[data-authoring-display]').filter({hasText:'Synthetic chapter summary edited directly in Review'}).waitFor();
|
||||
const companion=p.locator('[data-writer-companion-toggle]');if(await companion.getAttribute('aria-expanded')==='true')await companion.click();await shot('Review-word-hidden');for(const b of await p.locator('[data-editorial-toggle]').all()){await b.click();await b.click();}
|
||||
await require('./review-layout-checks.cjs')(p,pwa,shot);
|
||||
const records=await(await p.request.get(base+'/InvestigationCompanion/Saved?bookId='+s.book)).json();const selected=records.find(r=>r.id===investigation)||records[0];assert.equal((await p.request.post(base+'/InvestigationCompanion/Update',{headers:{'X-Requested-With':'XMLHttpRequest'},form:{bookId:s.book,id:selected.id,version:selected.guidanceVersion,operation:'activate',__RequestVerificationToken:token}})).status(),200);
|
||||
await p.goto(url('Review')+'&chapterId='+s.chapter);await p.locator('[data-review-panel]').waitFor();await p.waitForFunction(()=>window.PlotDirectorGuidanceSummary?.active);if(await p.locator('[data-guidance-open]').isVisible())await p.locator('[data-guidance-open]').click();await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.review'));await p.locator('.help-drawer-article').waitFor();await shot('Review-investigation-and-help');if(await p.locator('#review-scene-notes').isHidden())await p.locator('[data-editorial-toggle=review-scene-notes]').click();await shot('Review-help-scene-notes');if(await p.locator('#review-scene-notes [data-editorial-close]').isVisible())await p.locator('#review-scene-notes [data-editorial-close]').click();await p.locator('#reader-focus').click();await shot('Focus-reading');await p.locator('a[rel=next]').first().click();await p.waitForURL(new RegExp('chapterId='+s.secondChapter));assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await p.locator('a[rel=prev]').first().click();await p.waitForURL(new RegExp('chapterId='+s.chapter));assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');
|
||||
await p.goto(url('Review')+'&chapterId='+s.chapter);await p.locator('[data-review-panel]').waitFor();await p.waitForFunction(()=>window.PlotDirectorGuidanceSummary?.active);if(await p.locator('[data-guidance-open]').isVisible())await p.locator('[data-guidance-open]').click();await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.review'));await p.locator('.help-drawer-article').waitFor();await shot('Review-investigation-and-help');assert(await p.locator('#review-scene-notes').isVisible());assert(await p.locator('#review-chapter-notes').isVisible());await p.evaluate(()=>document.querySelector('#reader-focus').click());await shot('Focus-reading');await p.locator('a[rel=next]').first().click();await p.waitForURL(new RegExp('chapterId='+s.secondChapter));assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await p.locator('a[rel=prev]').first().click();await p.waitForURL(new RegExp('chapterId='+s.chapter));assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');
|
||||
await p.goto(url('Reflect'));await p.locator('.writer-month-grid').waitFor();assert.equal(await p.locator('[data-tab=calendar]').getAttribute('aria-selected'),'true');await shot('Reflect-calendar');await p.locator('[data-tab=sessions]').click();assert(await p.locator('[data-session-history]').isVisible());await p.locator('[data-session-filter]').fill('Synthetic session history');assert(await p.locator('[data-session-history]').evaluate(n=>n.scrollHeight>n.clientHeight));await shot('Reflect-sessions');
|
||||
await p.goto(url('Review')+'&chapterId='+s.secondChapter);await p.locator('.manuscript-reader').waitFor();await p.goto(url('Plan'));if(await p.locator('[data-ribbon-collapse]').getAttribute('aria-expanded')==='false')await p.locator('[data-ribbon-collapse]').click();await p.locator('#ribbon-panel-writer a[data-command-operation="writer.review"]').click();await p.waitForURL(new RegExp('chapterId='+s.secondChapter));assert.equal(await p.locator('.manuscript-reader').getAttribute('data-chapter-id'),String(s.secondChapter),'Review retains its own valid chapter while moving between workspaces');
|
||||
await p.goto(base+'/Writer/Journey?bookId='+s.book+'&year=2026&month=10&day=2026-10-15');assert.equal(new URL(p.url()).pathname,'/Writer/Reflect');assert(new URL(p.url()).searchParams.get('month')==='10');
|
||||
|
||||
@ -3,6 +3,5 @@ const {chromium}=require('playwright'),assert=require('node:assert/strict');
|
||||
assert.equal(await page.locator('.writer21-editorial').count(),1);const form=page.locator('[data-review-form]');await page.locator('[data-review-scope-new=Chapter]').click();await form.locator('[name=Observation]').fill('Chapter annotation Phase21 '+label);await form.locator('[name=Classification]').selectOption('Continuity');await form.locator('[data-review-save]').click();await page.locator('[data-chapter-annotations] [data-observation]').filter({hasText:'Chapter annotation Phase21 '+label}).waitFor();
|
||||
const paragraph=page.locator('#reader-content [data-paragraph-id][data-scene-id="31"]').first();await paragraph.click();await page.waitForFunction(()=>document.querySelector('[data-review-panel]').dataset.selectedScene==='31');await page.locator('[data-review-new]').click();await form.locator('[name=Scope]').selectOption('Scene');await form.locator('[name=Observation]').fill('Scene annotation Phase21 '+label);await form.locator('[data-review-save]').click();const scene=page.locator('[data-observation][data-scope=Scene]').filter({hasText:'Scene annotation Phase21 '+label});await scene.waitFor();await scene.locator('[data-review-edit]').click();await form.locator('[name=Status]').selectOption('Resolved');await form.locator('[name=Classification]').selectOption('Revision needed');await form.locator('[data-review-save]').click();await page.locator('[data-observation][data-status=Resolved][data-classification="Revision needed"]').filter({hasText:'Scene annotation Phase21 '+label}).waitFor();
|
||||
await paragraph.click();await page.locator('[data-review-new]').click();await form.locator('[name=Scope]').selectOption('Passage');await form.locator('[name=Observation]').fill('Paragraph annotation Phase21 '+label);await form.locator('[data-review-save]').click();const passage=page.locator('[data-observation][data-scope=Passage]').filter({hasText:'Paragraph annotation Phase21 '+label});await passage.waitFor();await passage.locator('[data-review-revisit]').click();
|
||||
for(const theme of ['modern-light','modern-dark','warm-light','warm-dark'])for(const width of [1920,1440,800]){await page.setViewportSize({width,height:1100});await page.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);for(const b of await page.locator('[data-editorial-toggle]').all()){await b.click();await b.click();}assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),theme+width);}
|
||||
await page.locator('[data-editorial-toggle=review-scene-notes]').click();const utility=page.locator('#review-scene-notes');assert.equal(await page.locator('.writer21-editorial').getAttribute('data-note-overlay'),'true');assert((await utility.boundingBox()).width>=250);const scrollBeforeClose=await page.evaluate(()=>scrollY);await utility.locator('[data-editorial-close]').click();assert(Math.abs((await page.evaluate(()=>scrollY))-scrollBeforeClose)<2,'closing note utility preserves manuscript scroll');
|
||||
await page.locator('#reader-focus').click();await page.locator('a[rel=next]').first().click();await page.waitForURL(/chapterId=22/);assert.equal(await page.locator('.manuscript-reader').getAttribute('data-focus'),'true');await page.locator('a[rel=prev]').first().click();await page.waitForURL(/chapterId=21/);assert.equal(await page.locator('.manuscript-reader').getAttribute('data-focus'),'true');assert.deepEqual(errors,[]);await context.close();}console.log('PASS Phase21 Review chapter/scene/passage annotations, classification/resolution, four themes, three widths, panels and Focus navigation; canonical/Word transport simulated');}finally{await browser.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1;});
|
||||
await require('./review-layout-checks.cjs')(page,pwa);
|
||||
await page.evaluate(()=>document.querySelector('#reader-focus').click());await page.locator('a[rel=next]').first().click();await page.waitForURL(/chapterId=22/);assert.equal(await page.locator('.manuscript-reader').getAttribute('data-focus'),'true');await page.locator('a[rel=prev]').first().click();await page.waitForURL(/chapterId=21/);assert.equal(await page.locator('.manuscript-reader').getAttribute('data-focus'),'true');assert.deepEqual(errors,[]);await context.close();}console.log('PASS Phase21 Review chapter/scene/passage annotations, classification/resolution, four themes, three widths, panels and Focus navigation; canonical/Word transport simulated');}finally{await browser.close();}})().catch(e=>{console.error(e.stack);process.exitCode=1;});
|
||||
|
||||
@ -38,7 +38,7 @@ public static class WriterNavigation
|
||||
"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", new("Guided investigation","point","Writer","Explore","writerBook"), 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("Reading mode","bible","ManuscriptReader","Index","writerBook"), new("Writing Dashboard","metrics","Writer","Dashboard","writerBook")),
|
||||
"Review" => new RibbonGroup("Writing tools", new RibbonCommand("Writing Dashboard","metrics","Writer","Dashboard","writerBook")),
|
||||
"Reflect" => new RibbonGroup("Writing history", new RibbonCommand("Reports","metrics","WritingActivity","Index","writerBook",OwnerOnly:true)),
|
||||
_ => new RibbonGroup("Your writing", new RibbonCommand("Writing Dashboard","metrics","Writer","Dashboard","writerBook"))
|
||||
};
|
||||
|
||||
@ -19,12 +19,12 @@
|
||||
<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>
|
||||
<div class="reader-mode-controls"><a data-pwa-context="Reading & Review" data-pwa-label="Reading mode" title="Switch between reading and review mode" 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" asp-route-reading="@Model.ReadingMode" rel="prev">← Previous chapter</a> }
|
||||
else { <span class="btn btn-outline-secondary disabled" aria-disabled="true">← Previous chapter</span> }
|
||||
{ <a id="reader-prev" data-pwa-context="Reading & Review" data-pwa-label="Previous" title="Read the previous chapter" 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 { <button id="reader-prev" type="button" data-pwa-context="Reading & Review" data-pwa-label="Previous" title="Read the previous chapter" class="btn btn-outline-secondary" disabled>← Previous chapter</button> }
|
||||
<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()" />
|
||||
@ -37,16 +37,16 @@
|
||||
<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" 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>
|
||||
{ <a id="reader-next" data-pwa-context="Reading & Review" data-pwa-label="Next" title="Read the next chapter" 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 { <button id="reader-next" type="button" data-pwa-context="Reading & Review" data-pwa-label="Next" title="Read the next chapter" class="btn btn-outline-secondary" disabled>Next chapter →</button> }
|
||||
<button type="button" class="btn btn-outline-secondary" id="reader-focus" data-pwa-context="Reading & Review" data-pwa-keep-visible="true" title="Enter or exit Focused Reading" aria-pressed="@Model.FocusReading.ToString().ToLowerInvariant()" hidden>Focus reading</button>
|
||||
</nav>
|
||||
@if(Model.IntegratedReview){<button type="button" class="btn btn-outline-primary" data-review-record>Record an observation</button>}
|
||||
@if(Model.IntegratedReview){<button type="button" class="btn btn-outline-primary" data-review-record data-pwa-context="Annotations" data-pwa-label="Add annotation" title="Record a chapter, verified scene or selected passage annotation">Record an observation</button>}
|
||||
<p class="reader-status" role="status" id="reader-loading" hidden>Loading chapter…</p>
|
||||
<div class="reader-status reader-live-controls" hidden>
|
||||
<label><input type="checkbox" id="reader-pause" /> Pause automatic updates while listening</label>
|
||||
<input type="checkbox" id="reader-pause" hidden /><button type="button" id="reader-pause-toggle" class="btn btn-outline-secondary btn-sm" aria-pressed="false" data-pwa-context="Synchronisation" title="Pause automatic accepted manuscript updates">Pause updates</button>
|
||||
<span role="status" aria-live="polite" id="reader-update-status"></span>
|
||||
<button type="button" id="reader-apply-update" class="btn btn-outline-secondary btn-sm" hidden>Show updated chapter</button>
|
||||
<button type="button" id="reader-apply-update" data-pwa-context="Synchronisation" data-pwa-keep-visible="true" title="Show the newly accepted chapter" class="btn btn-outline-secondary btn-sm" hidden>Show updated chapter</button>
|
||||
</div>
|
||||
<details class="reader-metadata" open="@(!Model.IntegratedReview)"><summary>Accepted manuscript details</summary><div class="reader-status muted" id="reader-timestamps">
|
||||
@if (Model.LastSuccessfulSyncUtc is DateTime sync)
|
||||
@ -57,7 +57,8 @@
|
||||
<p>Showing accepted server text. Changes are checked automatically while this page is visible.</p>
|
||||
</div>
|
||||
</details>
|
||||
<details><summary>Reading & Audio Review</summary><partial name="_WriterWorkToolbar" model="reviewToolbar" /></details>
|
||||
<button type="button" id="reader-audio" class="btn btn-outline-secondary btn-sm" data-pwa-context="Reading & Review" title="Open Reading and Audio Review controls">Reading & Audio</button>
|
||||
<dialog id="reader-audio-dialog" class="reader-audio-dialog" aria-labelledby="reader-audio-title"><h2 id="reader-audio-title">Reading & Audio Review</h2><button type="button" class="btn btn-outline-secondary" data-reader-audio-close>Close</button><partial name="_WriterWorkToolbar" model="reviewToolbar" /></dialog>
|
||||
@if(!Model.IntegratedReview){<a asp-controller="Writer" asp-action="Write" asp-route-bookId="@Model.Book.BookID">Return to Writing</a>}
|
||||
<div id="reader-content">
|
||||
@if (Model.Paragraphs.Count == 0)
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<script src="~/js/writing-workspace-launcher.js" asp-append-version="true"></script>
|
||||
@if(Model.Destination=="Plan"){<script src="~/js/writer-planner.js" asp-append-version="true"></script>}
|
||||
@if(Model.Destination=="Explore"){<script src="~/js/writer-explore.js" asp-append-version="true"></script>}
|
||||
@if(Model.Destination=="Review"){<script src="~/js/manuscript-reader.js" asp-append-version="true"></script><script src="~/js/review-authoring.js" asp-append-version="true"></script><script src="~/js/writer-review.js" asp-append-version="true"></script><script src="~/js/writer-work.js" asp-append-version="true"></script>}
|
||||
@if(Model.Destination=="Review"){<link rel="stylesheet" href="~/css/writer-review-layout.css" asp-append-version="true" /><script src="~/js/writer-review-layout.js" asp-append-version="true"></script><script src="~/js/manuscript-reader.js" asp-append-version="true"></script><script src="~/js/review-authoring.js" asp-append-version="true"></script><script src="~/js/writer-review.js" asp-append-version="true"></script><script src="~/js/writer-work.js" asp-append-version="true"></script>}
|
||||
@if(Model.Destination is "Write" or "Plan"){
|
||||
|
||||
<script src="~/js/writer-authoring.js" asp-append-version="true"></script>
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
@model PlotLine.Models.AuthoringSection
|
||||
@{ var add=Model.Kind.StartsWith("Add",StringComparison.Ordinal); var id="authoring-"+Model.Key; }
|
||||
@{ var add=Model.Kind.StartsWith("Add",StringComparison.Ordinal); var id="authoring-"+Model.Key;var compact=ViewData["CompactEditorial"] is true; }
|
||||
<section class="writer3-authoring-card" data-authoring-card data-key="@Model.Key" data-kind="@Model.Kind">
|
||||
<div class="writer3-authoring-heading"><h3>@Model.Title</h3><button type="button" class="btn btn-sm btn-outline-secondary" data-authoring-edit aria-controls="@id" aria-expanded="false">@(add?"Add":"Edit")<span class="visually-hidden"> @Model.Title</span></button></div>
|
||||
<div data-authoring-display>
|
||||
@if(Model.Kind=="Checklist"){<label><input type="checkbox" data-checklist-toggle checked="@(Model.Value("IsCompleted")=="true")" /> @Model.Value("ItemText")</label>}
|
||||
@if(add){<p class="muted">Optional — keep a useful detail here when you need it.</p>}
|
||||
else if(Model.Kind!="Checklist"){
|
||||
var readable=Model.Fields.Where(x=>!string.IsNullOrWhiteSpace(Model.Value(x.Name)) && Model.Value(x.Name)!="false").ToArray();
|
||||
@if(readable.Length==0){<p class="muted">Nothing recorded yet. Add this when it helps your writing.</p>}
|
||||
@if(add&&!compact){<p class="muted">Optional — keep a useful detail here when you need it.</p>}
|
||||
else if(!add&&Model.Kind!="Checklist"){
|
||||
var readable=Model.Fields.Where(x=>(!compact||x.Name!="SortOrder")&&!string.IsNullOrWhiteSpace(Model.Value(x.Name)) && Model.Value(x.Name)!="false").ToArray();
|
||||
@if(readable.Length==0&&!compact){<p class="muted">Nothing recorded yet. Add this when it helps your writing.</p>}
|
||||
@foreach(var f in (Model.Kind=="Goals"?readable.Take(1):readable)){var value=Model.Value(f.Name);<div class="writer3-recorded-field">@if(f.Label!=Model.Title){<strong>@f.Label</strong>}@if(f.Type=="textarea"&&value.Length>280){<p>@value[..280]…</p><details><summary>Read complete text</summary><p>@value</p></details>}else{<p>@(f.Type=="checkbox"?"Yes":f.Type=="purpose"?Model.Purposes.FirstOrDefault(x=>x.Value==value).Label??"Recorded purpose":f.Type=="noteType"?Model.NoteTypes.FirstOrDefault(x=>x.Value==value).Label??"Recorded note":value)</p>}</div>}
|
||||
@if(Model.Kind=="Goals"&&readable.Length>1){<details><summary>More chapter intentions</summary>@foreach(var f in readable.Skip(1)){<div class="writer3-recorded-field"><strong>@f.Label</strong><p>@Model.Value(f.Name)</p></div>}</details>}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
@model PlotLine.Services.Writer.ReviewPanel
|
||||
@{var data=Model.Intentions;}
|
||||
@{var data=Model.Intentions;ViewData["CompactEditorial"]=true;}
|
||||
<div data-review-panel data-selected-scene="@data.SceneID">
|
||||
<div data-review-intentions>
|
||||
<p>@data.Chapter.ChapterTitle</p>
|
||||
|
||||
@ -1,30 +1,36 @@
|
||||
@model WriterDashboardViewModel
|
||||
@{var reader=Model.ReviewReader;var word=new WriterDashboardViewModel{BookID=Model.BookID,ProjectID=Model.ProjectID,WordNavigationContext="review",Objective=reader?.Chapter==null?null:new(){ChapterID=reader.Chapter.ChapterID,ChapterTitle=reader.Chapter.ChapterTitle,Activity="Revising"}};}
|
||||
<div class="writer3-workspace" aria-label="Manuscript review">
|
||||
<section class="writer3-panel writer3-main" tabindex="0" aria-label="Editorial review">
|
||||
<div class="button-row"><button type="button" class="btn btn-outline-secondary" data-editorial-toggle="review-chapter-notes" aria-expanded="true">Chapter notes</button><button type="button" class="btn btn-outline-secondary" data-editorial-toggle="review-scene-notes" aria-expanded="true">Scene notes</button></div>
|
||||
<div class="writer21-editorial">
|
||||
<section class="writer21-notes" id="review-chapter-notes" aria-label="Chapter notes"><h2>Chapter notes</h2><button type="button" class="btn btn-outline-primary" data-review-scope-new="Chapter">Add chapter annotation</button><div data-review-intentions-slot><p>Loading chapter notes…</p></div><div data-chapter-annotations></div></section>
|
||||
<section class="writer21-manuscript" aria-label="Accepted manuscript">@if(reader!=null){<partial name="~/Views/ManuscriptReader/_Reader.cshtml" model="reader" />}else{<p>Select a book with chapters to review.</p>}</section>
|
||||
<section class="writer21-notes" id="review-scene-notes" aria-label="Scene notes"><h2>Scene notes</h2><div data-review-scene-context></div>
|
||||
<div class="writer3-workspace writer2-single" aria-label="Manuscript review">
|
||||
<section class="writer3-panel writer3-main review-editorial-main" aria-label="Editorial review">
|
||||
<div class="writer21-editorial" data-review-columns data-layout-owner="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value">
|
||||
<aside class="writer21-notes" id="review-chapter-notes" aria-label="Chapter notes"><h2>Chapter Notes</h2><button type="button" class="btn btn-sm btn-outline-primary" data-review-scope-new="Chapter">Add chapter annotation</button><div data-chapter-editor-slot></div><div data-review-intentions-slot><p>Loading chapter notes…</p></div><div data-chapter-annotations></div></aside>
|
||||
<div class="review-column-divider" data-review-divider="left" role="separator" aria-label="Resize chapter notes and manuscript" aria-orientation="vertical" tabindex="0"></div>
|
||||
<section class="writer21-manuscript" aria-label="Accepted manuscript"> <p class="review-word-warning writer3-caption"><span data-review-word-warning>Review shows accepted text.</span> <button type="button" class="btn btn-sm btn-link" data-review-diagnostics-open>Connection details</button></p> <details data-review-diagnostics><summary>Word connection and update diagnostics</summary><partial name="_WriterWord" model="word" /></details>@if(reader!=null){<partial name="~/Views/ManuscriptReader/_Reader.cshtml" model="reader" />}else{<p>Select a book with chapters to review.</p>}
|
||||
|
||||
|
||||
<details class="review-secondary-tools"><summary>Saved assessments and story tools</summary><a asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID">Open saved analysis and review tools</a></details>
|
||||
</section>
|
||||
<div class="review-column-divider" data-review-divider="right" role="separator" aria-label="Resize scene notes and manuscript" aria-orientation="vertical" tabindex="0"></div>
|
||||
<aside class="writer21-notes" id="review-scene-notes" aria-label="Scene notes"><h2>Scene Notes</h2><div data-review-scene-context></div>
|
||||
@if(reader?.Chapter!=null){
|
||||
<div data-writer-review data-book="@Model.BookID" data-chapter="@reader.Chapter.ChapterID" data-panel-url="@Url.Action("Panel","WriterReview")">
|
||||
<p data-review-reference>Chapter observation · select text or a paragraph for a passage reference.</p><p data-review-message role="status"></p>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" data-review-new>Add annotation</button>
|
||||
<div data-scene-editor-slot><div data-review-editor>
|
||||
<p data-review-reference>Chapter observation · select text or a paragraph for a passage reference.</p><p data-review-message role="status"></p>
|
||||
<form asp-controller="WriterReview" asp-action="Save" method="post" data-review-form hidden>
|
||||
<input type="hidden" name="BookID" value="@Model.BookID"/><input type="hidden" name="ChapterID" value="@reader.Chapter.ChapterID"/><input type="hidden" name="ID"/><input type="hidden" name="Version" value="0"/><input type="hidden" name="ContentVersion"/><input type="hidden" name="SceneID"/>
|
||||
<input type="hidden" name="StartParagraph"/><input type="hidden" name="EndParagraph"/><input type="hidden" name="StartOffset"/><input type="hidden" name="EndOffset"/>
|
||||
<div class="writer3-inline-field"><label for="review-observation">What have you noticed?</label><textarea id="review-observation" name="Observation" class="form-control" maxlength="10000" rows="4" required></textarea></div>
|
||||
<div class="writer3-inline-field"><label for="review-decision">What would you like to change? (optional)</label><textarea id="review-decision" name="Decision" class="form-control" maxlength="10000" rows="3"></textarea></div>
|
||||
<label for="review-scope">Scope</label><select id="review-scope" name="Scope" class="form-select"><option value="Chapter">Whole chapter</option><option value="Scene">Verified scene</option><option value="Passage">Selected accepted passage</option></select><p class="writer3-caption">Saved references stay attached to their original accepted version. Create another annotation to choose a different reference.</p>
|
||||
<label for="review-scope">Scope</label><select id="review-scope" name="Scope" class="form-select" required><option value="">Choose annotation scope</option><option value="Chapter">Whole chapter</option><option value="Scene">Verified scene</option><option value="Passage">Selected accepted passage</option></select><p class="writer3-caption">Saved references stay attached to their original accepted version. Create another annotation to choose a different reference.</p>
|
||||
<label for="review-classification">Classification</label><select id="review-classification" name="Classification" class="form-select">@foreach(var classification in PlotLine.Services.Writer.ReviewSave.Classifications){<option>@classification</option>}</select>
|
||||
<label for="review-status">Your decision</label><select name="Status" id="review-status" class="form-select"><option value="Open">Needs attention</option><option value="Working">Working on it</option><option value="Resolved">Resolved</option><option value="Dismissed">Dismissed</option></select>
|
||||
<p data-review-error role="alert" hidden></p><div class="button-row"><button class="btn btn-primary" type="submit" data-review-save>Save observation</button><button type="button" class="btn btn-outline-secondary" data-review-cancel>Cancel</button></div>
|
||||
</form>
|
||||
<button type="button" class="btn btn-sm btn-link" data-review-chapter>Use a chapter-level reference</button>
|
||||
</form>
|
||||
</div></div>
|
||||
<div data-review-context aria-live="polite"><p>Loading recorded intentions and observations…</p></div>
|
||||
</div>
|
||||
}
|
||||
</section></div></section>
|
||||
<aside class="writer3-panel writer3-reference" tabindex="0" aria-label="Word Companion"><partial name="_WriterWord" model="word" /><details><summary>Saved assessments & story tools</summary><p>Annotations remain separate from automated findings. Opening Review runs no analysis.</p><a asp-controller="Books" asp-action="Details" asp-route-id="@Model.BookID">Saved analysis and review tools</a></details></aside>
|
||||
</aside></div></section>
|
||||
</div>
|
||||
|
||||
43
PlotLine/wwwroot/css/writer-review-layout.css
Normal file
43
PlotLine/wwwroot/css/writer-review-layout.css
Normal file
@ -0,0 +1,43 @@
|
||||
/* One editorial layout: permanent notes around a continuous canonical reader. */
|
||||
.review-editorial-main{min-width:0;padding:1rem!important}
|
||||
.writer21-editorial{display:grid;grid-template-columns:minmax(0,1fr) 8px minmax(0,2fr) 8px minmax(0,1fr);align-items:start;gap:0;--review-sticky-top:12px}
|
||||
.writer21-editorial>.writer21-notes{min-width:0;position:sticky;top:var(--review-sticky-top);max-height:calc(100dvh - var(--review-sticky-top) - 12px);overflow-y:auto;overscroll-behavior:contain;padding:0 .7rem .7rem;scrollbar-gutter:stable}
|
||||
.writer21-editorial>.writer21-manuscript{min-width:0;padding-inline:.8rem}
|
||||
.writer21-manuscript .reader-page{margin-inline:auto;max-width:72ch}
|
||||
.writer21-notes>h2{font-size:1.15rem;margin:0 0 .5rem}
|
||||
.writer21-notes .writer3-authoring-heading{align-items:flex-start;gap:.4rem}
|
||||
.writer21-notes .writer3-authoring-heading h3{min-width:0;font-size:.95rem}
|
||||
.writer21-notes .writer3-authoring-heading button{flex:none;min-width:3.5rem}
|
||||
.writer21-notes .writer3-authoring-card{padding:.65rem 0;margin-block:.4rem}
|
||||
.writer21-notes :is(select,input,textarea){max-width:100%;min-width:0}
|
||||
.writer21-notes :is([data-review-reference],.writer3-caption){font-size:.78rem}
|
||||
.review-column-divider{align-self:start;position:sticky;top:var(--review-sticky-top);height:calc(100dvh - var(--review-sticky-top) - 12px);cursor:col-resize;touch-action:none;border-inline:1px solid var(--pd-border-subtle,var(--bs-border-color));background:var(--pd-chrome-secondary,var(--bs-body-bg));border-radius:3px}
|
||||
.review-column-divider:focus-visible{outline:2px solid var(--pd-focus);outline-offset:1px}
|
||||
.review-columns-dragging{user-select:none;cursor:col-resize}
|
||||
.writer21-editorial[data-compact=true]{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;grid-template-areas:'chapter scene' 'reader reader';gap:.75rem}
|
||||
.writer21-editorial[data-compact=true]>#review-chapter-notes{grid-area:chapter}
|
||||
.writer21-editorial[data-compact=true]>#review-scene-notes{grid-area:scene}
|
||||
.writer21-editorial[data-compact=true]>.writer21-manuscript{grid-area:reader;width:100%;padding:0}
|
||||
.writer21-editorial[data-compact=true]>.writer21-notes{max-height:min(28vh,16rem);z-index:2;background:var(--pd-surface,var(--bs-body-bg));border-bottom:1px solid var(--pd-border,var(--bs-border-color))}
|
||||
.writer21-editorial[data-compact=true]>.review-column-divider{display:none}
|
||||
.writer21-editorial[data-compact=true] [data-paragraph-id]{scroll-margin-top:calc(var(--review-sticky-top) + min(28vh,16rem) + 16px)}
|
||||
.review-word-warning{font-size:.8rem;margin:.3rem 0}
|
||||
.review-word-warning .btn{padding:0 .2rem}
|
||||
.review-secondary-tools, [data-review-diagnostics]{font-size:.85rem;margin-block:.4rem}
|
||||
[data-review-diagnostics] .writer3-word{margin-block:.4rem}
|
||||
.writer21-manuscript .reader-controls{display:flex;flex-wrap:wrap;gap:.4rem;margin:.25rem 0 .5rem}
|
||||
.writer21-manuscript .reader-controls form{margin:0;flex:1;min-width:0}
|
||||
.writer21-manuscript .reader-controls label{white-space:nowrap}
|
||||
.writer21-manuscript .reader-live-controls{margin:.2rem 0;font-size:.78rem}
|
||||
.reader-audio-dialog{max-width:min(650px,calc(100vw - 24px));max-height:85dvh;overflow:auto;background:var(--pd-surface,var(--bs-body-bg));color:var(--pd-text,var(--bs-body-color));border:1px solid var(--pd-border,var(--bs-border-color));border-radius:.6rem;padding:1rem}
|
||||
.reader-audio-dialog::backdrop{background:color-mix(in srgb,var(--pd-text) 40%,transparent)}
|
||||
.review-reference-highlight{outline:2px solid var(--pd-focus);outline-offset:4px;background:var(--pd-selected,var(--bs-secondary-bg));transition:background .2s}
|
||||
html[data-standalone=true] .writer21-manuscript .reader-mode-controls{display:none}
|
||||
body:has(.manuscript-reader[data-focus=true]) .writer21-editorial>.writer21-notes,body:has(.manuscript-reader[data-focus=true]) .review-column-divider{display:none!important}
|
||||
body:has(.manuscript-reader[data-focus=true]) .writer21-editorial{display:block!important}
|
||||
body .manuscript-reader[data-focus=true] #reader-focus,body .manuscript-reader[data-focus=true] #reader-prev,body .manuscript-reader[data-focus=true] #reader-next,body .manuscript-reader[data-focus=true] #reader-apply-update:not([hidden]){display:inline-flex!important}
|
||||
.manuscript-reader[data-focus=true] #reader-audio-dialog:not([open]){display:none}
|
||||
@media(prefers-reduced-motion:reduce){.review-reference-highlight{transition:none}}
|
||||
|
||||
.manuscript-reader[data-focus=true]>#reader-audio,.manuscript-reader[data-focus=true] #reader-pause-toggle{display:none!important}
|
||||
.writer21-editorial>.writer21-notes,.review-column-divider{overflow-anchor:none}
|
||||
@ -9,27 +9,10 @@
|
||||
.writer3-workspace.writer21-investigating{grid-template-columns:minmax(0,1fr) minmax(0,3fr)}
|
||||
.investigation-journey{display:grid;grid-template-columns:minmax(0,2fr) minmax(12rem,1fr);gap:1rem}
|
||||
.investigation-journey>.writer3-panel{padding:.7rem;min-width:0}
|
||||
.writer21-editorial{display:flex;gap:1rem;align-items:flex-start}
|
||||
.writer21-editorial>.writer21-notes{flex:1 1 24%;min-width:0}
|
||||
.writer21-editorial>.writer21-manuscript{flex:2 1 50%;min-width:0;margin-inline:auto}
|
||||
.writer21-editorial .reader-document{margin-inline:auto}
|
||||
.writer21-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:1rem}
|
||||
.writer21-planner form textarea{max-width:60ch}
|
||||
.writer21-task{padding:1rem;border:1px solid var(--bs-border-color);border-radius:.5rem;margin-block:.7rem}
|
||||
.writer21-task form{display:inline-block;margin:.2rem}
|
||||
.writer21-task p{white-space:pre-wrap}
|
||||
@media(max-width:1150px){.investigation-journey{grid-template-columns:1fr}.writer21-editorial{flex-wrap:wrap}.writer21-editorial>.writer21-manuscript{order:-1;flex-basis:100%}.writer21-board{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
||||
@media(max-width:800px){.writer3-workspace:has([data-explore-investigation]),.writer3-workspace.writer21-investigating{grid-template-columns:minmax(0,1fr)}.writer21-editorial>.writer21-notes{flex-basis:100%}.writer21-board{grid-template-columns:1fr}}
|
||||
body:has(.manuscript-reader[data-focus=true]) .writer21-notes,body:has(.manuscript-reader[data-focus=true]) [data-editorial-toggle]{display:none!important}
|
||||
|
||||
body:has(.manuscript-reader[data-reading=true]) .writer21-notes{display:none}
|
||||
.writer21-manuscript .reader-page{margin-inline:auto;max-width:72ch}
|
||||
|
||||
/* Utility note panels adapt to the actual reading region, including both outer side panels. */
|
||||
.writer21-editorial:not([data-note-overlay=true]) [data-editorial-close]{display:none}
|
||||
.writer21-editorial[data-note-overlay=true]{display:block}
|
||||
.writer21-editorial[data-note-overlay=true]>.writer21-manuscript{width:100%;margin-inline:auto}
|
||||
.writer21-editorial[data-note-overlay=true]>.writer21-notes{position:fixed;z-index:1040;top:var(--editorial-note-top,var(--writer-sticky-top,12px));bottom:12px;width:min(380px,var(--editorial-width));max-width:calc(100vw - 24px);overflow-y:auto;padding:1rem;background:var(--pd-surface,var(--bs-body-bg));border:1px solid var(--pd-border,var(--bs-border-color));border-radius:.5rem;box-shadow:0 8px 24px var(--pd-border)}
|
||||
.writer21-editorial[data-note-overlay=true]>#review-chapter-notes{left:var(--editorial-left)}
|
||||
.writer21-editorial[data-note-overlay=true]>#review-scene-notes{right:var(--editorial-right)}
|
||||
.writer21-editorial [data-editorial-close]{position:sticky;top:0;margin-bottom:.6rem;z-index:1;background:var(--pd-surface,var(--bs-body-bg))}
|
||||
@media(max-width:1150px){.investigation-journey{grid-template-columns:1fr}.writer21-board{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
||||
@media(max-width:800px){.writer3-workspace:has([data-explore-investigation]),.writer3-workspace.writer21-investigating{grid-template-columns:minmax(0,1fr)}.writer21-board{grid-template-columns:1fr}}
|
||||
|
||||
@ -252,6 +252,7 @@
|
||||
});
|
||||
} else { node.type = 'button'; node.addEventListener('click', () => invoke(source, node)); }
|
||||
const key = iconKey(source);
|
||||
node.title=source.title||source.getAttribute('aria-label')||source.textContent.trim();node.setAttribute('aria-label',source.getAttribute('aria-label')||node.title);
|
||||
node.dataset.ribbonIcon = key; decorate(node, caption(source), key);
|
||||
if (source.matches('.text-danger, .btn-outline-danger') || source.closest('form[data-confirm-message]')) node.classList.add('pd-context-destructive');
|
||||
group.element.append(node);
|
||||
|
||||
@ -20,6 +20,9 @@
|
||||
|
||||
const subdued=new Map();
|
||||
const setFocus = enabled => {
|
||||
const changing=root.dataset.focus!==String(enabled), viewport=root.dataset.focus==='true'?root.getBoundingClientRect().top:Math.max(0,document.querySelector('.pd-application-header')?.getBoundingClientRect().bottom||0);
|
||||
const visible=changing?[...content.querySelectorAll('[data-paragraph-id]')].find(n=>n.getBoundingClientRect().bottom>viewport):null;
|
||||
const offset=visible?visible.getBoundingClientRect().top-viewport:0;
|
||||
if(enabled){for(const node of document.querySelectorAll('.pd-application-header,.writer3-header,.writer3-reference,.pd-investigation,.pd-investigation-splitter,.plotline-help-drawer,.plotline-help-splitter')){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);
|
||||
@ -38,7 +41,8 @@
|
||||
// Keep the current Reader URL consistent for reload/back without persisting focus outside it.
|
||||
const url = new URL(location.href);
|
||||
if (enabled) url.searchParams.set('focus', 'true'); else url.searchParams.delete('focus');
|
||||
history.replaceState(history.state, '', url);
|
||||
history.replaceState(history.state, '', url);root.dispatchEvent(new Event('reader:focus-mode',{bubbles:true}));
|
||||
if(visible)requestAnimationFrame(()=>{const top=enabled?root.getBoundingClientRect().top:Math.max(0,document.querySelector('.pd-application-header')?.getBoundingClientRect().bottom||0),delta=visible.getBoundingClientRect().top-top-offset;if(enabled)root.scrollBy({top:delta,behavior:'instant'});else window.scrollBy({top:delta,behavior:'instant'});});
|
||||
};
|
||||
focus.hidden = false;
|
||||
setFocus(root.dataset.focus === 'true');
|
||||
@ -49,6 +53,8 @@
|
||||
if (event.target.closest('a') && !event.ctrlKey && !event.metaKey && !event.shiftKey && event.button === 0) stop();
|
||||
});
|
||||
|
||||
const audio=root.querySelector('#reader-audio-dialog');if(audio){on(root.querySelector('#reader-audio'),'click',()=>audio.showModal());on(audio.querySelector('[data-reader-audio-close]'),'click',()=>audio.close());}
|
||||
const pauseToggle=root.querySelector('#reader-pause-toggle');if(pauseToggle)on(pauseToggle,'click',()=>{pause.checked=!pause.checked;pause.dispatchEvent(new Event('change'));});
|
||||
const hasSelection = () => {
|
||||
const selection = window.getSelection();
|
||||
// A selection anywhere on the page is a reason to defer; extensions may select outside prose.
|
||||
@ -56,7 +62,7 @@
|
||||
};
|
||||
const pending = () => observedVersion !== displayedVersion;
|
||||
const indicate = () => {
|
||||
apply.hidden = !pending();
|
||||
apply.hidden = !pending();if(pauseToggle){pauseToggle.setAttribute('aria-pressed',String(pause.checked));pauseToggle.textContent=pause.checked?'Resume updates':'Pause updates';pauseToggle.title=pause.checked?'Resume automatic accepted manuscript updates':'Pause automatic accepted manuscript updates';}
|
||||
if (!pending()) message.textContent = pause.checked ? "Automatic updates paused." : "Checking for accepted chapter changes automatically.";
|
||||
else message.textContent = hasSelection()
|
||||
? 'Updated chapter available. It will appear after you clear the text selection.'
|
||||
|
||||
13
PlotLine/wwwroot/js/writer-review-layout.js
Normal file
13
PlotLine/wwwroot/js/writer-review-layout.js
Normal file
@ -0,0 +1,13 @@
|
||||
// Persist presentation only. No chapter, scene, focus, annotation or manuscript mutation.
|
||||
(()=>{const root=document.querySelector('[data-review-columns]');if(!root)return;
|
||||
const left=root.querySelector('#review-chapter-notes'),right=root.querySelector('#review-scene-notes'),dividers=[...root.querySelectorAll('[data-review-divider]')],key='plotdirector.reviewColumns.v1.'+(root.dataset.layoutOwner||'device');let preference={left:.25,right:.25},drag=null,frame=0,compact=false;
|
||||
try{const saved=JSON.parse(localStorage.getItem(key));if(saved&&Number.isFinite(saved.left)&&Number.isFinite(saved.right))preference={left:Math.max(.15,Math.min(.4,saved.left)),right:Math.max(.15,Math.min(.4,saved.right))};}catch{}
|
||||
const save=()=>{try{localStorage.setItem(key,JSON.stringify(preference));}catch{}};
|
||||
function render(){frame=0;const shell=document.querySelector('.pd-application-header'),sticky=shell&&getComputedStyle(shell).position==='sticky'?Math.max(8,shell.getBoundingClientRect().bottom+8):8;root.style.setProperty('--review-sticky-top',sticky+'px');const width=Math.max(0,root.clientWidth-16);compact=width<960;root.dataset.compact=String(compact);if(compact){dividers.forEach(d=>d.tabIndex=-1);return;}
|
||||
const minimum=220,centre=440;let l=Math.max(minimum,Math.min(width*preference.left,width-centre-minimum)),r=Math.max(minimum,Math.min(width*preference.right,width-centre-l));l=Math.min(l,width-centre-r);root.style.gridTemplateColumns=`${Math.round(l)}px 8px minmax(0,1fr) 8px ${Math.round(r)}px`;
|
||||
for(const [index,d] of dividers.entries()){const value=index?r:l;d.tabIndex=0;d.setAttribute('aria-valuemin','220');d.setAttribute('aria-valuemax',String(Math.floor(width-centre-(index?l:r))));d.setAttribute('aria-valuenow',String(Math.round(value)));d.setAttribute('aria-valuetext',Math.round(value/width*100)+' percent notes width');}}
|
||||
const schedule=()=>{if(!frame)frame=requestAnimationFrame(render);};
|
||||
function resize(which,pixels){const width=root.clientWidth-16;if(compact||width<=0)return;const other=which==='left'?right.getBoundingClientRect().width:left.getBoundingClientRect().width;preference[which]=Math.max(220,Math.min(width-440-other,pixels))/width;render();}
|
||||
for(const divider of dividers){divider.addEventListener('pointerdown',event=>{if(!event.isPrimary||event.button!==0||compact)return;event.preventDefault();divider.focus();drag={node:divider,id:event.pointerId,which:divider.dataset.reviewDivider};divider.setPointerCapture(event.pointerId);root.classList.add('review-columns-dragging');});divider.addEventListener('pointermove',event=>{if(!drag||event.pointerId!==drag.id)return;const box=root.getBoundingClientRect();resize(drag.which,drag.which==='left'?event.clientX-box.left:box.right-event.clientX);});const end=()=>{if(!drag)return;drag=null;root.classList.remove('review-columns-dragging');save();};for(const name of['pointerup','pointercancel','lostpointercapture'])divider.addEventListener(name,end);divider.addEventListener('keydown',event=>{if(event.altKey||event.ctrlKey||event.metaKey||!['ArrowLeft','ArrowRight','Home','End'].includes(event.key))return;event.preventDefault();const which=divider.dataset.reviewDivider,width=(which==='left'?left:right).getBoundingClientRect().width,step=event.shiftKey?40:10;resize(which,event.key==='Home'?220:event.key==='End'?root.clientWidth:width+(event.key==='ArrowRight'?(which==='left'?step:-step):(which==='left'?-step:step)));save();});}
|
||||
new ResizeObserver(schedule).observe(root);const header=document.querySelector('.pd-application-header');if(header)new ResizeObserver(schedule).observe(header);window.addEventListener('resize',schedule);window.addEventListener('plotdirector:ribbon-layout-changed',schedule);document.addEventListener('reader:focus-mode',schedule);window.addEventListener('blur',()=>{if(drag){drag=null;root.classList.remove('review-columns-dragging');save();}});render();
|
||||
})();
|
||||
@ -1,6 +1,6 @@
|
||||
// Author actions only. Selection never navigates Word, creates a record or changes working/session focus.
|
||||
(()=>{'use strict';const root=document.querySelector('[data-writer-review]'),reader=document.querySelector('.manuscript-reader');if(!root||!reader)return;
|
||||
const editorial=root.closest('.writer21-editorial')||root;const form=root.querySelector('[data-review-form]'),context=root.querySelector('[data-review-context]'),message=root.querySelector('[data-review-message]'),reference=root.querySelector('[data-review-reference]'),error=root.querySelector('[data-review-error]'),newButton=root.querySelector('[data-review-new]');
|
||||
const editor=root.querySelector('[data-review-editor]');const editorial=root.closest('.writer21-editorial')||root;const form=root.querySelector('[data-review-form]'),context=root.querySelector('[data-review-context]'),message=root.querySelector('[data-review-message]'),reference=root.querySelector('[data-review-reference]'),error=root.querySelector('[data-review-error]'),newButton=root.querySelector('[data-review-new]');
|
||||
let anchor=null,selected=null,page=1,dirty=false,busy=false,loading=false,allowLeave=false,pauseBefore=false,controller=null,generation=0,selectionTimer=null,lastContext='';
|
||||
const field=n=>form.elements.namedItem(n),readerContent=reader.querySelector('#reader-content'),word=document.querySelector('[data-writer-word]');
|
||||
const nodeParagraph=n=>(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest('[data-paragraph-id]');
|
||||
@ -14,22 +14,24 @@ const sceneID=panel.dataset.selectedScene||'';if(word){word.dataset.sceneId=scen
|
||||
for(const note of panel.querySelectorAll('[data-observation]'))if(note.dataset.scope==='Scene')note.hidden=note.dataset.scene!==sceneID;
|
||||
window.dispatchEvent(new Event('review:context-loaded'));lastContext=key;requestAnimationFrame(()=>preserve?.());}}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('.writer21-notes')||root.closest('.writer3-reference');if(aside?.hidden)document.querySelector('[data-editorial-toggle=review-scene-notes]')?.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';field('Scope').disabled=false;field('Scope').value=anchor?'Passage':'Chapter';field('Classification').value='Observation';field('SceneID').value=document.querySelector('[data-review-panel]')?.dataset.selectedScene||'';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();}
|
||||
function placeEditor(){document.querySelector(field('Scope').value==='Chapter'?'[data-chapter-editor-slot]':'[data-scene-editor-slot]')?.append(editor);}
|
||||
function showEditor(){placeEditor();if(reader.dataset.focus==='true'){const restore=reader.readerPreserveView?.();reader.querySelector('#reader-focus').click();restore?.();}form.hidden=false;newButton.hidden=true;field('Observation').focus();}
|
||||
function begin(scope){scope=typeof scope==='string'?scope:'';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';field('Scope').disabled=false;field('Scope').value=scope||(anchor?'Passage':'');field('Classification').value='Observation';field('SceneID').value=document.querySelector('[data-review-panel]')?.dataset.selectedScene||'';error.hidden=true;pause(true);dirty=true;reference.textContent=anchor?'Observation linked to the selected accepted paragraph(s).':scope==='Chapter'?'Chapter-level observation; no exact passage is claimed.':'Choose the annotation scope before saving.';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.';showEditor();}},true);
|
||||
function finish(){form.hidden=true;newButton.hidden=false;dirty=false;error.hidden=true;pause(false);newButton.focus();}
|
||||
newButton.addEventListener('click',begin);document.querySelector('[data-review-record]')?.addEventListener('click',begin);
|
||||
const markDirty=()=>{if(!form.hidden&&!busy)dirty=true;};form.addEventListener('input',markDirty);form.addEventListener('change',markDirty);root.querySelector('[data-review-cancel]').addEventListener('click',()=>{if(!busy){finish();message.textContent='Observation cancelled; no changes saved.';}});
|
||||
root.querySelector('[data-review-chapter]').addEventListener('click',()=>{if(busy)return;if(dirty&&Number(field('Version').value)>0){message.textContent='A saved observation keeps its original reference. Create a new chapter observation instead.';return;}anchor=null;selected=null;wordReference(null);for(const n of['StartParagraph','EndParagraph','StartOffset','EndOffset'])field(n).value='';reference.textContent='Chapter-level reference; no exact passage is claimed.';if(!dirty)void load();});
|
||||
form.addEventListener('submit',async e=>{e.preventDefault();if(busy)return;const data=new FormData(form);data.set('Scope',field('Scope').value);if(Number(field('Version').value)===0&&field('Scope').value!=='Passage')for(const name of ['StartParagraph','EndParagraph','StartOffset','EndOffset'])data.set(name,'');const creating=Number(field('Version').value)===0;busy=true;for(const input of form.querySelectorAll('textarea,select'))input.disabled=true;const button=root.querySelector('[data-review-save]'),cancel=root.querySelector('[data-review-cancel]');button.disabled=true;cancel.disabled=true;error.hidden=true;try{const response=await fetch(form.action,{method:'POST',body:data,headers:{'X-Requested-With':'XMLHttpRequest'}});const result=await response.json().catch(()=>null);if(!response.ok||result?.success!==true){error.textContent=result?.message||'Save was not confirmed. Your text is retained. Reload observations to check before retrying.';error.hidden=false;return;}finish();if(creating)page=1;message.textContent='Observation saved. Manuscript and scene revision state are unchanged.';await load();}catch{error.textContent='Save was not confirmed. Your text is retained; reload recorded observations before retrying.';error.hidden=false;}finally{busy=false;for(const input of form.querySelectorAll('textarea,select'))input.disabled=false;field('Scope').disabled=Number(field('Version').value)>0;button.disabled=false;cancel.disabled=false;}});
|
||||
const markDirty=()=>{if(!form.hidden&&!busy)dirty=true;};form.addEventListener('input',markDirty);form.addEventListener('change',markDirty);form.querySelector('[data-review-cancel]').addEventListener('click',()=>{if(!busy){finish();message.textContent='Observation cancelled; no changes saved.';}});
|
||||
editor.querySelector('[data-review-chapter]').addEventListener('click',()=>{if(busy)return;if(dirty&&Number(field('Version').value)>0){message.textContent='A saved observation keeps its original reference. Create a new chapter observation instead.';return;}field('Scope').value='Chapter';placeEditor();anchor=null;selected=null;wordReference(null);for(const n of['StartParagraph','EndParagraph','StartOffset','EndOffset'])field(n).value='';reference.textContent='Chapter-level reference; no exact passage is claimed.';if(!dirty)void load();});
|
||||
field('Scope').addEventListener('change',placeEditor);
|
||||
form.addEventListener('submit',async e=>{e.preventDefault();if(busy)return;const data=new FormData(form);data.set('Scope',field('Scope').value);if(Number(field('Version').value)===0&&field('Scope').value!=='Passage')for(const name of ['StartParagraph','EndParagraph','StartOffset','EndOffset'])data.set(name,'');const creating=Number(field('Version').value)===0;busy=true;for(const input of form.querySelectorAll('textarea,select'))input.disabled=true;const button=form.querySelector('[data-review-save]'),cancel=form.querySelector('[data-review-cancel]');button.disabled=true;cancel.disabled=true;error.hidden=true;try{const response=await fetch(form.action,{method:'POST',body:data,headers:{'X-Requested-With':'XMLHttpRequest'}});const result=await response.json().catch(()=>null);if(!response.ok||result?.success!==true){error.textContent=result?.message||'Save was not confirmed. Your text is retained. Reload observations to check before retrying.';error.hidden=false;return;}finish();if(creating)page=1;message.textContent='Observation saved. Manuscript and scene revision state are unchanged.';await load();}catch{error.textContent='Save was not confirmed. Your text is retained; reload recorded observations before retrying.';error.hidden=false;}finally{busy=false;for(const input of form.querySelectorAll('textarea,select'))input.disabled=false;field('Scope').disabled=Number(field('Version').value)>0;button.disabled=false;cancel.disabled=false;}});
|
||||
editorial.addEventListener('click',e=>{const row=e.target.closest('[data-observation]');if(e.target.closest('[data-review-reload]')){if(dirty){message.textContent='Save or Cancel the editor before reloading observations.';return;}void load();}const pager=e.target.closest('[data-review-page]');if(pager){if(dirty){message.textContent='Save or Cancel before changing observation pages.';return;}page=Number(pager.dataset.reviewPage);void load();}
|
||||
if(!row)return;if(e.target.closest('[data-review-edit]')){if(dirty){message.textContent='Save or Cancel your current observation first.';return;}field('ContentVersion').value=reader.dataset.version;field('ID').value=row.dataset.id;field('Version').value=row.dataset.version;field('Observation').value=row.querySelector('[data-observation-text]').textContent;field('Decision').value=row.querySelector('[data-decision-text]').textContent;field('Status').value=row.querySelector('[data-review-edit]').dataset.state;field('Classification').value=row.dataset.classification;field('Scope').value=row.dataset.scope;field('SceneID').value=row.dataset.scene||'';field('Scope').disabled=true;pause(true);dirty=true;reference.textContent='Editing a recorded observation; its original accepted-version reference is retained.';showEditor();}
|
||||
if(e.target.closest('[data-review-revisit]')){if(dirty){message.textContent='Save or Cancel before revisiting another reference.';return;}const target=readerContent.querySelector(`[data-paragraph-id="${CSS.escape(row.dataset.first)}"]`);if(!target){wordReference(null);message.textContent='The original paragraph is missing. Its reference is retained; use the verified chapter action in Word.';return;}target.scrollIntoView({block:'center'});selected=row.dataset.first;anchor=null;wordReference(row.dataset.anchor==='Current'?selected:null);message.textContent=row.dataset.anchor==='Current'?'Original paragraph reference selected. Word has not moved.':'The referenced paragraph changed. Its original reference is retained; exact Word handoff is unavailable. Use the chapter action.';void load();}});
|
||||
if(e.target.closest('[data-review-revisit]')){if(dirty){message.textContent='Save or Cancel before revisiting another reference.';return;}const target=readerContent.querySelector(`[data-paragraph-id="${CSS.escape(row.dataset.first)}"]`);if(!target){wordReference(null);message.textContent='The original paragraph is missing. Its reference is retained; use the verified chapter action in Word.';return;}target.scrollIntoView({block:'center'});target.classList.add('review-reference-highlight');setTimeout(()=>target.classList.remove('review-reference-highlight'),1800);selected=row.dataset.first;anchor=null;wordReference(row.dataset.anchor==='Current'?selected:null);message.textContent=row.dataset.anchor==='Current'?'Original paragraph reference selected. Word has not moved.':'The referenced paragraph changed. Its original reference is retained; exact Word handoff is unavailable. Use the chapter action.';void load();}});
|
||||
editorial.addEventListener('change',event=>{if(!event.target.matches('[data-annotation-filter]'))return;const type=root.querySelector('[data-annotation-filter=classification]')?.value,status=root.querySelector('[data-annotation-filter=status]')?.value;for(const note of editorial.querySelectorAll('[data-observation]'))note.hidden=!!(type&¬e.dataset.classification!==type||status&¬e.dataset.status!==status||note.dataset.scope==='Scene'&¬e.dataset.scene!==document.querySelector('[data-review-panel]')?.dataset.selectedScene);});
|
||||
readerContent.addEventListener('click',e=>{if(dirty||busy)return;const p=e.target.closest('[data-paragraph-id]');if(!p)return;anchor=capture()||{StartParagraph:p.dataset.paragraphId,EndParagraph:p.dataset.paragraphId,StartOffset:0,EndOffset:p.textContent.length};selected=anchor.StartParagraph;reference.textContent='Accepted paragraph selected; nothing is saved until you record an observation.';wordReference(selected);queueContext();});
|
||||
readerContent.addEventListener('keyup',()=>{if(dirty||busy)return;const choice=capture();if(choice){anchor=choice;selected=choice.StartParagraph;wordReference(selected);queueContext();}});
|
||||
reader.addEventListener('reader:metadata',()=>{if(!dirty)wordReference(selected);});
|
||||
reader.addEventListener('reader:updated',()=>{if(dirty)return;if(selected&&!readerContent.querySelector(`[data-paragraph-id="${CSS.escape(selected)}"]`)){selected=null;anchor=null;wordReference(null);message.textContent='The selected paragraph is no longer in the accepted chapter. Original observation references remain recorded.';}else wordReference(selected);void load();});
|
||||
function guard(e){if(!dirty&&!busy)return;const target=e.target.closest('a,form');if(!target||target===form||target.matches('[data-work-start]')||target.target==='_blank'||target.matches('.plotline-help-more')&&window.PlotLineHelpDrawer)return;if(!confirm(busy?'An observation save may still finish. Leave this Review page?':'Leave without saving your review observation?')){e.preventDefault();e.stopImmediatePropagation();}else allowLeave=true;}
|
||||
document.addEventListener('click',e=>{if(e.target.closest('a'))guard(e);},true);document.addEventListener('submit',guard,true);window.addEventListener('beforeunload',e=>{if((dirty||busy)&&!allowLeave){e.preventDefault();e.returnValue='';}});window.addEventListener('pageshow',e=>{allowLeave=false;if(e.persisted&&!dirty)void load();});window.addEventListener('pagehide',()=>{clearTimeout(selectionTimer);controller?.abort();});for(const b of document.querySelectorAll('[data-review-scope-new]'))b.addEventListener('click',()=>{begin();field('Scope').value=b.dataset.reviewScopeNew;});window.addEventListener('review:notes-saved',()=>void load());void load();
|
||||
document.addEventListener('click',e=>{if(e.target.closest('a'))guard(e);},true);document.addEventListener('submit',guard,true);window.addEventListener('beforeunload',e=>{if((dirty||busy)&&!allowLeave){e.preventDefault();e.returnValue='';}});window.addEventListener('pageshow',e=>{allowLeave=false;if(e.persisted&&!dirty)void load();});window.addEventListener('pagehide',()=>{clearTimeout(selectionTimer);controller?.abort();});for(const b of document.querySelectorAll('[data-review-scope-new]'))b.addEventListener('click',()=>{begin(b.dataset.reviewScopeNew);});window.addEventListener('review:notes-saved',()=>void load());void load();
|
||||
})();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// Consumes the existing native presence/status stream. No second background poller or global selection.
|
||||
(()=>{'use strict';let root=document.querySelector('[data-writer-word]');if(root?.dataset.bound)return;if(!root){const template=document.querySelector('[data-word-fallback]');if(!template)return;const holder=document.createElement('details');holder.className='writer3-inset';holder.dataset.wordFallbackProvider='true';holder.hidden=!Number(template.content.querySelector('[data-writer-word]')?.dataset.chapterId);const summary=document.createElement('summary');summary.textContent='Word connection and manuscript';holder.append(summary,template.content.cloneNode(true));document.querySelector('main')?.append(holder);root=holder.querySelector('[data-writer-word]');}if(!root)return;root.dataset.bound='true';
|
||||
document.querySelector('[data-review-diagnostics-open]')?.addEventListener('click',()=>{document.querySelector('[data-review-diagnostics]').open=true;});
|
||||
const book=Number(root.dataset.bookId);let chapter=Number(root.dataset.chapterId),scene=Number(root.dataset.sceneId);const state=root.querySelector('[data-word-state]'),position=root.querySelector('[data-word-position]'),freshness=root.querySelector('[data-word-freshness]'),message=root.querySelector('[data-word-command]'),choose=root.querySelector('[data-word-choose]'),select=root.querySelector('[data-word-document]'),nav=root.querySelector('[data-word-navigate]'),sceneNav=root.querySelector('[data-word-scene]'),adopt=root.querySelector('[data-word-adopt]');
|
||||
const reviewing=root.dataset.wordContext==='review',paragraphButton=root.querySelector('[data-word-paragraph]');
|
||||
let availabilityKey='',availability={},availabilityEpoch=0,availabilityChecked=0;let packet=null,current=null,busy=false,abort=null,checkBusy=false,syncPending=null;const sync=root.querySelector('[data-word-sync]');
|
||||
@ -13,7 +14,7 @@ const identity=current&&data.canonical?.manuscriptID===current.manuscriptId;cons
|
||||
state.textContent=data.unavailable?'Word Companion status unavailable. Your saved work is retained.':!current?(leases.length>1?'Choose the correct Word manuscript.':(data.leases||[]).some(l=>l.wordAvailable)?'The open Word manuscript is for another book.':'Word Companion is not connected to this manuscript.'):!identity?'Word is connected, but this manuscript has not been verified.':`Manuscript: ${current.documentTitle}`;
|
||||
position.textContent=observed?`Word is showing ${observed.chapterTitle||'the verified chapter'}${observed.sceneId&&observed.sceneTitle?' · '+observed.sceneTitle:''}. ${observed.chapterId!==chapter?(reviewing?'Your review selection is separate.':'Your working focus is separate.'):''}`:current?.wordSaved===false?'Word has unsaved changes. Current positions await verification; no save will be forced.':'Word position has not been verified.';
|
||||
let status=!identity?'Your latest changes have not yet been confirmed in PlotDirector.':current.chapterProgress?.state==='Needs review'||current.chapterIssue==='needs_review'?'Manuscript checking needs attention in Companion. Accepted content is retained.':current.paragraphTransfer?.state==='failed'?'Manuscript update failed. Accepted content is retained.':current.chapterProgress?.state==='Synchronised'&¤t.wordSaved===true?'The last manuscript check completed. Later edits may still be pending.':current.chapterProgress?.state?`${current.chapterProgress.state}: ${current.chapterProgress.message||'Latest changes are not yet confirmed.'}`:'Latest changes are not yet confirmed. Check synchronisation in Companion.';
|
||||
if(data.canonical?.chapterAcceptedUtc)status+=' This chapter last accepted: '+new Date(data.canonical.chapterAcceptedUtc).toLocaleString()+'.';else if(data.canonical?.snapshotUtc)status+=' Accepted snapshot recorded: '+new Date(data.canonical.snapshotUtc).toLocaleString()+'.';freshness.textContent=status;
|
||||
if(data.canonical?.chapterAcceptedUtc)status+=' This chapter last accepted: '+new Date(data.canonical.chapterAcceptedUtc).toLocaleString()+'.';else if(data.canonical?.snapshotUtc)status+=' Accepted snapshot recorded: '+new Date(data.canonical.snapshotUtc).toLocaleString()+'.';freshness.textContent=status;const warning=document.querySelector('[data-review-word-warning]');if(warning)warning.textContent='Showing accepted text. '+(!current?state.textContent:current.wordSaved===false?'Word has unsaved changes; they are not shown here.':status);
|
||||
sync.disabled=busy||!!syncPending||!identity||current.wordSaved!==true||!(current.canChapterSync||current.canParagraphSync);
|
||||
for(const button of [nav,sceneNav,paragraphButton])if(button)button.disabled=busy||!!syncPending||!identity||current.wordSaved!==true||!current.canAcknowledgeNavigation;
|
||||
if(identity&&!current.canAcknowledgeNavigation)position.textContent+=' Update the Word add-in and Companion together to enable confirmed navigation.';
|
||||
|
||||
@ -2,12 +2,4 @@
|
||||
if(destination?.dataset.bookId){const key='plotdirector.reviewChapter.v1.'+destination.dataset.layoutOwner+'.'+destination.dataset.bookId;try{if(reader?.dataset.chapterId)sessionStorage.setItem(key,reader.dataset.chapterId);const selected=sessionStorage.getItem(key),valid=(destination.dataset.reviewChapters||'').split(',');if(selected&&valid.includes(selected))for(const link of document.querySelectorAll('a[href]')){const url=new URL(link.href,location.href);if(url.origin===location.origin&&url.pathname.toLowerCase()==='/writer/review'&&url.searchParams.get('bookId')===destination.dataset.bookId&&!url.searchParams.has('chapterId')){url.searchParams.set('chapterId',selected);link.href=url;}}}catch{}}
|
||||
for(const root of document.querySelectorAll('[data-workspace-tabs]'))for(const button of root.querySelectorAll('[data-tab]'))button.addEventListener('click',()=>{for(const b of root.querySelectorAll('[data-tab]'))b.setAttribute('aria-selected',String(b===button));for(const panel of root.querySelectorAll('[data-pane]'))panel.hidden=panel.dataset.pane!==button.dataset.tab;});
|
||||
document.querySelector('[data-session-filter]')?.addEventListener('input',event=>{for(const row of document.querySelectorAll('[data-session-history] article'))row.hidden=!row.textContent.toLowerCase().includes(event.target.value.toLowerCase());});
|
||||
const editorial=document.querySelector('.writer21-editorial');
|
||||
if(editorial){const toggles=[...document.querySelectorAll('[data-editorial-toggle]')],panels=toggles.map(button=>document.getElementById(button.dataset.editorialToggle));let narrow=null,wideVisible=panels.map(panel=>!panel.hidden);
|
||||
const sync=()=>toggles.forEach((button,index)=>button.setAttribute('aria-expanded',String(!panels[index].hidden)));
|
||||
const close=index=>{if(panels[index].contains(document.activeElement))toggles[index].focus({preventScroll:true});panels[index].hidden=true;sync();};
|
||||
for(const [index,button] of toggles.entries()){button.setAttribute('aria-controls',panels[index].id);button.addEventListener('click',()=>{const show=panels[index].hidden;if(narrow&&show)panels.forEach((panel,other)=>{if(other!==index)close(other);});panels[index].hidden=!show;if(!narrow)wideVisible=panels.map(panel=>!panel.hidden);sync();if(narrow&&show)panels[index].querySelector('button,textarea,input,select')?.focus({preventScroll:true});});const closeButton=document.createElement('button');closeButton.type='button';closeButton.className='btn btn-outline-secondary';closeButton.dataset.editorialClose='';closeButton.textContent='Close '+(index===0?'chapter':'scene')+' notes';closeButton.addEventListener('click',()=>close(index));panels[index].prepend(closeButton);panels[index].addEventListener('keydown',event=>{if(event.key==='Escape'&&narrow){event.preventDefault();close(index);}});}
|
||||
let frame=0;const measure=()=>{frame=0;const box=editorial.getBoundingClientRect(),next=box.width<1050,sticky=parseFloat(getComputedStyle(destination||editorial).getPropertyValue('--writer-sticky-top'))||12;editorial.style.setProperty('--editorial-note-top',Math.max(sticky,Math.min(box.top,Math.max(sticky,innerHeight-200)))+'px');editorial.style.setProperty('--editorial-left',Math.max(8,box.left)+'px');editorial.style.setProperty('--editorial-right',Math.max(8,innerWidth-box.right)+'px');editorial.style.setProperty('--editorial-width',Math.max(240,box.width-16)+'px');if(next!==narrow){if(next){if(narrow===false)wideVisible=panels.map(panel=>!panel.hidden);panels.forEach((_,index)=>close(index));}else panels.forEach((panel,index)=>panel.hidden=!wideVisible[index]);narrow=next;editorial.dataset.noteOverlay=String(next);sync();}};
|
||||
const schedule=()=>{if(!frame)frame=requestAnimationFrame(measure);};new ResizeObserver(schedule).observe(editorial);window.addEventListener('resize',schedule);window.addEventListener('scroll',schedule,{passive:true});measure();
|
||||
}
|
||||
})();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user