Reflow editorial notes for constrained reading regions without losing manuscript position
This commit is contained in:
parent
cbffe9c0b1
commit
7793f04ced
@ -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.mouse.move(1,1090);await p.waitForTimeout(120);await p.screenshot({path:out+'/'+name+'.png',animations:'disabled'});};
|
||||
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'});};
|
||||
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);
|
||||
@ -17,6 +17,10 @@ const investigation=new URL(p.url()).searchParams.get('investigation');assert(in
|
||||
if(!pwa)for(let n=0;n<26;n++){const response=await p.request.post(base+'/Writer/Explore/Investigate/Start',{headers:{'X-Writer-Explore':'inline'},form:{bookId:s.book,concern,requestId:crypto.randomUUID(),__RequestVerificationToken:token}});assert.equal(response.status(),200);}
|
||||
await p.locator('[data-explore-tab=saved]').click();await p.waitForFunction(()=>document.querySelectorAll('[data-explore-saved] article').length>=26);const saved=p.locator('[data-explore-saved]');assert(await saved.evaluate(n=>n.scrollHeight>n.clientHeight));await saved.evaluate(n=>n.scrollTop=200);await p.locator('[data-explore-tab=new]').click();await p.locator('[data-explore-tab=saved]').click();await p.waitForTimeout(150);assert((await saved.evaluate(n=>n.scrollTop))>0);await shot('Explore-saved-scroll');await saved.locator('a').first().click();await p.locator('[data-inline-investigation]').waitFor();assert.equal(new URL(p.url()).pathname,'/Writer/Explore');
|
||||
await p.goto(url('Plan'));await p.locator('[data-planner-view]').waitFor();const planner=p.locator('[data-activity-planner]');const countBefore=(await exportSessions()).length;
|
||||
// Archive only this disposable fixture's earlier qualification activities, retaining their history.
|
||||
const previousActivities=await planner.locator('[data-activity-id]').evaluateAll(nodes=>nodes.map(n=>({id:n.dataset.activityId,version:n.querySelector('[name=version]').value})));
|
||||
for(const previous of previousActivities)assert.equal((await p.request.post(base+'/WriterActivities/Change',{form:{bookId:s.book,id:previous.id,version:previous.version,operation:'archive',confirm:'true',__RequestVerificationToken:token}})).status(),200);
|
||||
if(previousActivities.length){await p.goto(url('Plan'));await planner.locator('[data-planner-view]').waitFor();}
|
||||
for(const [title,kind,entity,date] of [['Revise arrival '+label,'Editing','Scene:'+s.scene,''],['Review crossing '+label,'Review','Chapter:'+s.chapter,new Date().toISOString().slice(0,10)],['Think about the route '+label,'Planning','','']]){const add=planner.locator('details').filter({has: p.locator('summary').filter({hasText:'Add planned activity'})}).first();await add.locator('summary').click();const f=add.locator('form');await f.locator('[name=Title]').fill(title);await f.locator('[name=Kind]').selectOption(kind);await f.locator('[name=EntityKey]').selectOption(entity);await f.locator('[name=Notes]').fill('Synthetic intended work, not a recording');if(date)await f.locator('[name=TargetDate]').fill(date);await f.locator('button[type=submit]').click();await planner.locator('[data-activity-id]').filter({hasText:title}).waitFor();}
|
||||
for(const view of ['list','board','schedule']){await planner.locator('[data-planner-tab='+view+']').click();await planner.locator('[data-planner-view='+view+']').waitFor();assert((await planner.locator('[data-activity-id]').count())>=3);if(view==='schedule')assert((await planner.textContent()).includes('Undated activities'));await shot('Plan-'+view);}
|
||||
await planner.locator('[data-planner-tab=list]').click();await planner.locator('[data-planner-view=list]').waitFor();const task=planner.locator('[data-activity-id]').filter({hasText:'Revise arrival '+label}).first();await task.locator('details').filter({has:p.locator('summary').filter({hasText:'Edit activity'})}).locator('summary').click();const edit=task.locator('[data-activity-save]');await edit.locator('[name=Notes]').fill('Clarify the turning point before leaving');await edit.locator('button[type=submit]').click();await task.filter({hasText:'Clarify the turning point before leaving'}).waitFor();
|
||||
@ -29,7 +33,7 @@ const note=p.locator('[data-observation]').filter({hasText:'Passage editorial no
|
||||
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();}
|
||||
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');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');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('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(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');
|
||||
for(const width of [1440,900,800])for(const destination of ['Write','Explore','Plan','Review','Reflect']){await p.setViewportSize({width,height:1000});await p.goto(url(destination));await p.waitForTimeout(120);assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),destination+' overflow '+width);assert((await p.title()).includes(destination));assert(await p.locator('.writer3-header').count()===0,destination+' redundant intro');}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
const {chromium}=require('playwright'),assert=require('node:assert/strict');
|
||||
(async()=>{const browser=await chromium.launch();try{for(const pwa of [false,true]){const context=await browser.newContext({viewport:{width:1920,height:1100}});await context.addInitScript(()=>localStorage.setItem('plotdirector.desktop.v1.4',JSON.stringify({dismissedAt:Date.now()})));if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));await context.route('**/Writer/Work/State?*',r=>r.fulfill({json:{session:null,defaultPauseOnEdit:true}}));await context.route('**/native-companion/status*',r=>r.fulfill({json:{leases:[]}}));const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));await page.goto('http://127.0.0.1:5238/Writer/Review?projectId=7&bookId=12&chapterId=21');await page.locator('[data-review-panel]').waitFor();
|
||||
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 '+pwa);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 '+pwa}).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 '+pwa);await form.locator('[data-review-save]').click();const scene=page.locator('[data-observation][data-scope=Scene]').filter({hasText:'Scene annotation Phase21 '+pwa});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 '+pwa}).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 '+pwa);await form.locator('[data-review-save]').click();const passage=page.locator('[data-observation][data-scope=Passage]').filter({hasText:'Paragraph annotation Phase21 '+pwa});await passage.waitFor();await passage.locator('[data-review-revisit]').click();
|
||||
(async()=>{const browser=await chromium.launch();try{for(const pwa of [false,true]){const label=String(pwa)+'-'+Date.now();const context=await browser.newContext({viewport:{width:1920,height:1100}});await context.addInitScript(()=>localStorage.setItem('plotdirector.desktop.v1.4',JSON.stringify({dismissedAt:Date.now()})));if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));await context.route('**/Writer/Work/State?*',r=>r.fulfill({json:{session:null,defaultPauseOnEdit:true}}));await context.route('**/native-companion/status*',r=>r.fulfill({json:{leases:[]}}));const page=await context.newPage(),errors=[];page.on('pageerror',e=>errors.push(e.message));await page.goto('http://127.0.0.1:5238/Writer/Review?projectId=7&bookId=12&chapterId=21');await page.locator('[data-review-panel]').waitFor();
|
||||
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;});
|
||||
|
||||
@ -30,6 +30,7 @@ public sealed class WriterController(
|
||||
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){
|
||||
if(!chapterId.HasValue&&model.Objective?.ChapterID is int workingChapter&&model.ObjectiveChoices.Any(x=>x.ChapterID==workingChapter))chapterId=workingChapter;
|
||||
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();}
|
||||
|
||||
@ -24,3 +24,12 @@ body:has(.manuscript-reader[data-focus=true]) .writer21-notes,body:has(.manuscri
|
||||
|
||||
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))}
|
||||
|
||||
@ -16,7 +16,7 @@ window.dispatchEvent(new Event('review:context-loaded'));lastContext=key;request
|
||||
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();}
|
||||
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);
|
||||
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.';}});
|
||||
|
||||
@ -1,4 +1,13 @@
|
||||
(()=>{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;});
|
||||
(()=>{const destination=document.querySelector('.writer3-destination'),reader=document.querySelector('.manuscript-reader');
|
||||
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());});
|
||||
for(const button of document.querySelectorAll('[data-editorial-toggle]'))button.addEventListener('click',()=>{const panel=document.getElementById(button.dataset.editorialToggle);panel.hidden=!panel.hidden;button.setAttribute('aria-expanded',String(!panel.hidden));});
|
||||
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