End review stops tracking; Pause first to stop external playback. Actual text changes pause playback when supported by Companion. Scrolling and cursor movement do not. Resume is always explicit. Start again after Companion registers a session for this book if the review began without one.
-Explicit sessions record browser engagement separately from elapsed time. Audio time requires consecutive player observations; playback does not prove attention. Overlapping browser and audio durations are not added together.
+ @if(Model.Unified){Explicit sessions record browser engagement separately from elapsed time. Audio time requires consecutive player observations; playback does not prove attention. Overlapping browser and audio durations are not added together.
Explicit sessions record browser engagement separately from elapsed time. Audio time requires consecutive player observations; playback does not prove attention. Overlapping browser and audio durations are not added together.
} + Writing Rhythm & Journey diff --git a/PlotLine/Views/Writer/Destination.cshtml b/PlotLine/Views/Writer/Destination.cshtml index d9d561dd..3d2e9778 100644 --- a/PlotLine/Views/Writer/Destination.cshtml +++ b/PlotLine/Views/Writer/Destination.cshtml @@ -26,6 +26,7 @@ @if(Model.Destination == "Write"){ + diff --git a/PlotLine/Views/Writer/_AuthoringSection.cshtml b/PlotLine/Views/Writer/_AuthoringSection.cshtml new file mode 100644 index 00000000..04601cdf --- /dev/null +++ b/PlotLine/Views/Writer/_AuthoringSection.cshtml @@ -0,0 +1,30 @@ +@model PlotLine.Models.AuthoringSection +@{ var add=Model.Kind.StartsWith("Add",StringComparison.Ordinal); var id="authoring-"+Model.Key; } + diff --git a/PlotLine/Views/Writer/_WriterAuthoring.cshtml b/PlotLine/Views/Writer/_WriterAuthoring.cshtml new file mode 100644 index 00000000..11a3688f --- /dev/null +++ b/PlotLine/Views/Writer/_WriterAuthoring.cshtml @@ -0,0 +1,48 @@ +@model PlotLine.Models.WriterAuthoringPage +@(Model.Scene?.SceneTitle??Model.Chapter.ChapterTitle) · @(Model.Scene==null?"Chapter focus":"Scene focus") · Recorded state: @(Model.Scene?.RevisionStatusName??Model.Chapter.RevisionStatusName). Manuscript prose stays in Word.
+There are no scenes yet. You can work at chapter level, or add a scene in the chapter editor.
} + @foreach(var scene in Model.Scenes){} +Chapter reminders live in the existing Things to include and Concerns fields above. Scene notes remain with their scenes; session return notes remain with sessions.
+ } +Unsynchronised Word edits are not shown by Reader.
} + else if(Model.SceneID.HasValue){Develop this recorded sceneReturn to Word for manuscript prose; this workspace edits supporting information.
} + else{Develop this chapter or add a scene} + +@Model.Chapter.ChapterTitle
@Model.Scenes.Count recorded scenes. Select a scene to see its saved people, setting and threads.
} + else{ +Setting: @(Model.Scene.PrimaryLocationID.HasValue?Model.Scene.PrimaryLocationName??"Recorded setting unavailable":"No location recorded")
+People: @(Model.Characters.Count==0?"No scene appearances recorded":string.Join(", ",Model.Characters.Take(6).Select(x=>x.CharacterName)))
+Threads: @(Model.Threads.Count==0?"No thread events recorded":string.Join("; ",Model.Threads.Take(4).Select(x=>$"{x.PlotLineName}: {x.ThreadTitle} — {x.EventTypeName}")))
+ var feeling=Model.Sections.First(x=>x.Kind=="Goals").Value("EmotionalGoal"); + @if(!string.IsNullOrWhiteSpace(feeling)){Chapter feeling intention: @feeling
} +Relationships: @(Model.Relationships.Count==0?"No verified relationship events recorded":string.Join("; ",Model.Relationships.Take(4).Select(x=>$"{x.CharacterAName} / {x.CharacterBName}: {x.RelationshipTypeName}")))
+ } +Saved records only; no manuscript analysis or inferred story facts. Open Context for the full reference categories and recorded metrics.
+Your current work
@if(focus != null && !editing){ -@focus.Activity
@if(focus.ChapterID.HasValue){Chapter: @focus.ChapterTitle
}Return to this saved task. Write manuscript text in Word, and use the chapter or scene tools for your plan and notes.
+@focus.Activity
@if(focus.ChapterID.HasValue){Chapter: @focus.ChapterTitle
}Write manuscript prose in Word; use the intentions and reminders below to guide your work.
diff --git a/PlotLine/wwwroot/css/writer3.css b/PlotLine/wwwroot/css/writer3.css index 5e66d8fc..14ca5cfe 100644 --- a/PlotLine/wwwroot/css/writer3.css +++ b/PlotLine/wwwroot/css/writer3.css @@ -58,3 +58,13 @@ .writer3-layout-tooltip{pointer-events:none} .writer3 [data-save-focus]{background:var(--pd-accent);border-color:var(--pd-accent);color:var(--pd-on-accent)!important} .writer3 [data-save-focus]:hover{background:var(--pd-accent-hover);border-color:var(--pd-accent-hover)} +.writer3-authoring{margin-top:1.4rem;border-top:1px solid var(--pd-border-subtle);padding-top:1.2rem} +.writer3-authoring-heading{display:flex;gap:.8rem;align-items:baseline;justify-content:space-between}.writer3-authoring-heading h3{margin:0}.writer3-authoring-card{padding:1rem 0;border-bottom:1px solid var(--pd-border-subtle)} +.writer3-recorded-field{margin-top:.7rem}.writer3-recorded-field strong{font-size:.84rem;color:var(--pd-muted);font-weight:500}.writer3-recorded-field p{white-space:pre-wrap;overflow-wrap:anywhere;margin:.3rem 0;max-width:75ch} +.writer3-inline-field{margin:.8rem 0}.writer3-inline-field label{display:block;margin-bottom:.35rem}.writer3-inline-field textarea{resize:vertical;min-height:5rem}.writer3-authoring-details{margin:1rem 0}.writer3-authoring-details>summary{padding:.7rem 0;color:var(--pd-accent);cursor:pointer} +.writer3-reference-summary{padding-bottom:1rem;border-bottom:1px solid var(--pd-border-subtle);font-size:.9rem}.writer3-reminder-preview{padding-left:1.2rem;white-space:pre-wrap}.writer3-reminder-preview li{margin:.5rem 0;max-width:75ch}.writer3-scene-choice{display:flex;flex-wrap:wrap;gap:.6rem;justify-content:space-between;align-items:center;padding:.6rem 0} +.writer3 [data-authoring-save]{background:var(--pd-accent);color:var(--pd-on-accent);border-color:var(--pd-accent)}.writer3 [data-authoring-error]{color:var(--pd-text);border-left:3px solid var(--pd-accent);padding:.7rem} +.writer3-main>.writer3-focus-kind{margin:.4rem 0}.writer3-main>.writer3-caption{margin:.4rem 0}.writer3-recording-about{font-size:.8rem;color:var(--pd-muted);margin:.6rem 0}.writer3-recording-about>summary{cursor:pointer;color:var(--pd-accent)} +/* Contain positioned accessibility labels within each scrolling panel, not the document viewport. */ +.writer3-split>.writer3-panel{position:relative} +.writer3-window-actions{margin:.8rem 0 1rem} diff --git a/PlotLine/wwwroot/js/writer-authoring.js b/PlotLine/wwwroot/js/writer-authoring.js new file mode 100644 index 00000000..1d2738fa --- /dev/null +++ b/PlotLine/wwwroot/js/writer-authoring.js @@ -0,0 +1,44 @@ +// Canonical authoring support only. Never changes Word position, session target or a reference selection. +(() => { + const root=document.querySelector('[data-writer-authoring]');if(!root)return; + const main=root.closest('.writer3-main'); + main.addEventListener('plotdirector:work-state',e=>{const block=e.target.closest('.writer3-session-block');if(!block)return;if(e.detail.session){if(block.nextElementSibling!==root)root.before(block);}else if(block.previousElementSibling!==root)root.after(block);}); + let allowLeave=false;const dirty=()=>[...root.querySelectorAll('[data-authoring-form]')].some(f=>f.dataset.dirty==='true'||f.dataset.busy==='true'); + const cardOf=n=>n.closest('[data-authoring-card]'); + const focusEditor=card=>card.querySelector('textarea,select,input:not([type=hidden])')?.focus(); + function bind(container){ + for(const form of container.querySelectorAll('[data-authoring-form]')){ + if(form.dataset.bound)continue;form.dataset.bound='true'; + const markDirty=()=>{form.dataset.dirty='true';cardOf(form).querySelector('[data-authoring-status]').textContent='';};form.addEventListener('input',markDirty);form.addEventListener('change',markDirty); + const card=cardOf(form),edit=card.querySelector('[data-authoring-edit]'),display=card.querySelector('[data-authoring-display]'),error=form.querySelector('[data-authoring-error]'); + edit.addEventListener('click',()=>{card.querySelector('[data-authoring-status]').textContent='';form.hidden=false;display.hidden=true;edit.hidden=true;edit.setAttribute('aria-expanded','true');focusEditor(card);}); + form.querySelector('[data-authoring-cancel]').addEventListener('click',()=>{if(form.dataset.busy==='true')return;form.reset();card.querySelector('[data-authoring-status]').textContent='';form.dataset.dirty='false';form.hidden=true;display.hidden=false;edit.hidden=false;edit.setAttribute('aria-expanded','false');error.hidden=true;edit.focus();}); + form.querySelector('[data-authoring-reload]').addEventListener('click',async()=>{if(!confirm('Reload the recorded version? Copy any text you want to keep first.'))return;try{const doc=await read();replaceCard(card,doc);}catch{error.textContent='Could not reload. Your text is still here.';}}); + form.addEventListener('submit',async e=>{ + e.preventDefault();if(form.dataset.busy==='true')return;form.dataset.busy='true';const save=form.querySelector('[data-authoring-save]'),cancel=form.querySelector('[data-authoring-cancel]'),reload=form.querySelector('[data-authoring-reload]');let committed=false;save.disabled=true;cancel.disabled=true;reload.disabled=true;error.hidden=true; + const data=new FormData(form);for(const input of form.querySelectorAll('input[type=checkbox]'))data.set(input.name,String(input.checked)); + try{const response=await fetch(form.action,{method:'POST',body:data,headers:{'X-Requested-With':'XMLHttpRequest'}});if(!response.ok){const body=await response.json().catch(()=>null);error.textContent=body?.message||'Could not save. Your text is still here.';error.hidden=false;if(response.status===409)form.querySelector('[data-authoring-reload]').hidden=false;return;} + // A committed save is not retried if the following read fails (especially for newly created rows). + const result=await response.json().catch(()=>null);if(result?.success!==true)throw Error('Save was not confirmed'); + committed=true;form.dataset.dirty='false';const doc=await read();const isAdd=card.dataset.kind.startsWith('Add');replaceCard(card,doc); + const preview=root.querySelector('.writer3-reminder-preview'),freshPreview=doc.querySelector('.writer3-reminder-preview');if(preview&&freshPreview)preview.replaceWith(freshPreview.cloneNode(true)); + const next=root.querySelector('[data-authoring-next-area]'),freshNext=doc.querySelector('[data-authoring-next-area]');if(next&&freshNext){const clone=freshNext.cloneNode(true);next.replaceWith(clone);bind(clone);} + const refs=document.querySelector('[data-authoring-references]'),template=doc.querySelector('[data-authoring-companion]');if(refs&&template)refs.replaceChildren(template.content.cloneNode(true)); + if(isAdd){for(const fresh of doc.querySelectorAll('[data-authoring-card]'))if(!root.querySelector(`[data-key="${CSS.escape(fresh.dataset.key)}"]`)){const clone=fresh.cloneNode(true);root.querySelector('[data-authoring-new-records]')?.append(clone);bind(clone.parentElement);}} + }catch{error.textContent=committed?'Saved, but the refreshed record could not load. Your text is retained. Reload the recorded version.':'Save was not confirmed. Your text is retained. Reload the recorded version to check before trying again.';error.hidden=false;form.querySelector('[data-authoring-reload]').hidden=false;} + finally{form.dataset.busy='false';save.disabled=committed&&form.isConnected;cancel.disabled=committed&&form.isConnected;reload.disabled=false;} + }); + } + for(const details of container.querySelectorAll('details'))if(!details.dataset.authoringBound){details.dataset.authoringBound='true';details.addEventListener('toggle',()=>{if(!details.open&&[...details.querySelectorAll('[data-authoring-form]')].some(f=>f.dataset.dirty==='true')){details.open=true;const pending=details.querySelector('[data-authoring-form][data-dirty="true"]');if(pending)cardOf(pending).querySelector('[data-authoring-status]').textContent='Save or Cancel this editor before closing the section.';}});} + for(const button of container.querySelectorAll('[data-authoring-next]'))button.addEventListener('click',()=>root.querySelector(`[data-key="${CSS.escape(button.dataset.authoringNext)}"] [data-authoring-edit]`)?.click()); + for(const input of container.querySelectorAll('.writer3-scene-choice [name=Activity]'))input.value=document.querySelector('[data-writer-focus]').dataset.savedActivity; + } + function replaceCard(card,doc){const fresh=doc.querySelector(`[data-key="${CSS.escape(card.dataset.key)}"]`);if(!fresh)throw Error('Saved record is not available');const clone=fresh.cloneNode(true),parent=card.parentElement;card.replaceWith(clone);bind(parent);clone.querySelector('[data-authoring-status]').textContent='Saved.';clone.querySelector('[data-authoring-edit]')?.focus();} + async function read(){const response=await fetch(root.dataset.inspectUrl,{cache:'no-store'});if(!response.ok)throw Error('Recorded information is unavailable');const doc=new DOMParser().parseFromString(await response.text(),'text/html');if(!doc.querySelector('[data-authoring-content]'))throw Error('Authorisation or recorded information is unavailable');return doc;} + async function load(){try{const doc=await read();root.replaceChildren(...doc.body.childNodes);bind(root);const references=document.querySelector('[data-authoring-references]'),template=root.querySelector('[data-authoring-companion]');if(references&&template)references.replaceChildren(template.content.cloneNode(true));} + catch{root.replaceChildren();const p=document.createElement('p');p.textContent='Recorded information could not load. Your current work and existing editors remain available.';const retry=document.createElement('button');retry.type='button';retry.className='btn btn-outline-secondary';retry.textContent='Try again';retry.addEventListener('click',load);root.append(p,retry);}} + window.addEventListener('beforeunload',e=>{if(dirty()&&!allowLeave){e.preventDefault();e.returnValue='';}}); + function guard(e){if(!dirty())return;const target=e.target.closest('a,form,[data-plan-focus]');if(!target||target.matches('[data-authoring-form],[data-work-start]')||target.target==='_blank'||target.hasAttribute('download'))return;if(target.tagName==='A'&&new URL(target.href,location.href).pathname===location.pathname&&new URL(target.href,location.href).search===location.search&&target.hash)return;if(!confirm(root.querySelector('[data-busy="true"]')?'A save is in progress and may finish after you leave. Leave this page?':'Leave without saving your inline edits?')){e.preventDefault();e.stopImmediatePropagation();}else allowLeave=true;} + document.addEventListener('click',e=>{if(e.target.closest('a,[data-plan-focus]'))guard(e);},true);document.addEventListener('submit',guard,true);window.addEventListener('pageshow',()=>allowLeave=false); + load(); +})(); diff --git a/PlotLine/wwwroot/js/writer-focus.js b/PlotLine/wwwroot/js/writer-focus.js index 37edd534..dbeb85ae 100644 --- a/PlotLine/wwwroot/js/writer-focus.js +++ b/PlotLine/wwwroot/js/writer-focus.js @@ -15,7 +15,7 @@ root.addEventListener('plotdirector:work-start-finished',()=>{pending=false;render();}); activity?.addEventListener('change',()=>{if(kindChoice)kindChoice.value='';render();});kindChoice?.addEventListener('change',render); record?.addEventListener('click',()=>{if(active||pending||!known)return;const s=selection(),k=kind();if(!k){message.textContent='Choose a compatible session activity before recording.';kindChoice?.focus();return;}if(k==='AudioReview'&&!s.chapter){message.textContent='Choose a chapter for Audio Review.';chapter?.focus();return;}message.textContent='';pending=true;render();root.querySelector('[data-writer-work]').dispatchEvent(new CustomEvent('plotdirector:record-focus',{detail:{kind:k,chapter:s.chapter}}));}); - form?.addEventListener('submit',e=>{if(saving||!objectives.includes(selection().activity)){e.preventDefault();return;}saving=true;render();}); + form?.addEventListener('submit',e=>{if(e.defaultPrevented)return;if(saving||!objectives.includes(selection().activity)){e.preventDefault();return;}saving=true;render();}); root.querySelector('[data-plan-focus]')?.addEventListener('click',()=>{const url=new URL(root.dataset.planUrl,location.origin);url.searchParams.set('focusActivity',selection().activity);location.assign(url);}); render(); })();