diff --git a/PlotLine/Controllers/ChaptersController.cs b/PlotLine/Controllers/ChaptersController.cs index 0902560f..5b102767 100644 --- a/PlotLine/Controllers/ChaptersController.cs +++ b/PlotLine/Controllers/ChaptersController.cs @@ -20,16 +20,18 @@ public sealed class ChaptersController(IChapterService chapters) : Controller return model is null ? NotFound() : View("Edit", model); } - public async Task Edit(int id) + public async Task Edit(int id,string? returnUrl=null) { + ViewData["ReturnUrl"]=Url.IsLocalUrl(returnUrl)?returnUrl:null; var model = await chapters.GetEditAsync(id); return model is null ? NotFound() : View(model); } [HttpPost] [ValidateAntiForgeryToken] - public async Task Save(ChapterEditViewModel model) + public async Task Save(ChapterEditViewModel model,string? returnUrl=null) { + ViewData["ReturnUrl"]=Url.IsLocalUrl(returnUrl)?returnUrl:null; if (!ModelState.IsValid) { return View("Edit", model); @@ -57,7 +59,7 @@ public sealed class ChaptersController(IChapterService chapters) : Controller return View("Edit", createModel); } - return RedirectToAction(nameof(Details), new { id = chapterId }); + return Url.IsLocalUrl(returnUrl)?LocalRedirect(returnUrl!):RedirectToAction(nameof(Details), new { id = chapterId }); } [HttpPost] diff --git a/PlotLine/Services/Writer/WriterReviewService.cs b/PlotLine/Services/Writer/WriterReviewService.cs index 9c52cfba..13385b52 100644 --- a/PlotLine/Services/Writer/WriterReviewService.cs +++ b/PlotLine/Services/Writer/WriterReviewService.cs @@ -13,12 +13,17 @@ public sealed class ReviewObservation public Guid? StartParagraph{get;set;}public Guid? EndParagraph{get;set;}public int? StartOffset{get;set;}public int? EndOffset{get;set;}public string? AnchorHash{get;set;}public int? SceneID{get;set;} public string Observation{get;set;}="";public string? Decision{get;set;}public string Status{get;set;}="Open";public int Version{get;set;}public DateTime CreatedUtc{get;set;}public DateTime UpdatedUtc{get;set;} public string AnchorState{get;set;}="Chapter"; + public string? Scope{get;set;}public string? Classification{get;set;} + public string EffectiveScope=>Scope??(StartParagraph.HasValue?"Passage":"Chapter"); + public string EffectiveClassification=>Classification??"Observation"; } public sealed class ReviewSave { public int BookID{get;set;}public int ChapterID{get;set;}public Guid ID{get;set;}public int Version{get;set;} public string ContentVersion{get;set;}="";public Guid? StartParagraph{get;set;}public Guid? EndParagraph{get;set;}public int? StartOffset{get;set;}public int? EndOffset{get;set;} public string Observation{get;set;}="";public string? Decision{get;set;}public string Status{get;set;}="Open"; + public string Scope{get;set;}="";public string Classification{get;set;}="Observation";public int? SceneID{get;set;} + public static readonly string[] Classifications=["Observation","Revision needed","Continuity","Research","Character","Plot","Pacing","Reminder","General note"]; } public sealed record ReviewPanel(WriterAuthoringPage Intentions,IReadOnlyList Observations,int Page,bool HasMore,string ReferenceMessage); public interface IWriterReviewService @@ -29,7 +34,7 @@ public interface IWriterReviewService public sealed class WriterReviewService(ISqlConnectionFactory factory,ManuscriptReaderService reader,IWriterAuthoringService intentions):IWriterReviewService { public static string Hash(IEnumerable paragraphs){using var buffer=new MemoryStream();using(var writer=new BinaryWriter(buffer,Encoding.UTF8,true))foreach(var p in paragraphs){writer.Write(p.Id.ToByteArray());writer.Write(p.Text);}return Convert.ToHexString(SHA256.HashData(buffer.ToArray()));} - public static string Validate(ReviewSave r)=>r.ID==Guid.Empty||r.Version<0?"Choose a valid observation.":r.Status is not("Open" or "Working" or "Resolved")?"Choose a valid observation state.":string.IsNullOrWhiteSpace(r.Observation)?"Record what you noticed before saving.":r.Observation.Length>10000||(r.Decision?.Length??0)>10000?"Keep each observation and decision within 10,000 characters.":""; + public static string Validate(ReviewSave r)=>r.ID==Guid.Empty||r.Version<0?"Choose a valid observation.":!ReviewSave.Classifications.Contains(r.Classification)?"Choose an annotation classification.":r.Status is not("Open" or "Working" or "Resolved" or "Dismissed")?"Choose a valid observation state.":string.IsNullOrWhiteSpace(r.Observation)?"Record what you noticed before saving.":r.Observation.Length>10000||(r.Decision?.Length??0)>10000?"Keep each observation and decision within 10,000 characters.":""; public static ReaderParagraph[] Anchor(ManuscriptReaderModel model,Guid? first,Guid? last,int? start,int? end){ if(first==null&&last==null&&start==null&&end==null)return []; var rows=model.Paragraphs.ToArray();var from=Array.FindIndex(rows,p=>p.Id==first);var to=Array.FindIndex(rows,p=>p.Id==last); @@ -55,8 +60,13 @@ public sealed class WriterReviewService(ISqlConnectionFactory factory,Manuscript public async Task Save(int actor,ReviewSave r){ var error=Validate(r);if(error.Length>0)throw new ArgumentException(error); ManuscriptReaderModel? source=null;ReaderParagraph[] rows=[]; - if(r.Version==0){source=await reader.Read(actor,r.BookID,r.ChapterID)??throw new KeyNotFoundException();if(r.ContentVersion!=source.ContentVersion)throw new AuthoringConflictException("The accepted chapter changed. Your observation text is retained. Refresh the manuscript before choosing its reference again.");rows=Anchor(source,r.StartParagraph,r.EndParagraph,r.StartOffset,r.EndOffset);} - int? scene=rows.Length>0&&rows[0].SceneID.HasValue&&rows.All(p=>p.SceneID==rows[0].SceneID)?rows[0].SceneID:null; - using var db=factory.CreateConnection();try{return await db.QuerySingleAsync("dbo.WriterReview_Observations",new{Action=r.Version==0?"create":"update",UserID=actor,r.BookID,r.ChapterID,r.ID,r.Version,ManuscriptID=source?.ManuscriptID,SnapshotRevision=source?.Revision,ContentVersion=source?.ContentVersion,r.StartParagraph,r.EndParagraph,r.StartOffset,r.EndOffset,AnchorHash=rows.Length>0?Hash(rows):null,SceneID=scene,r.Observation,r.Decision,r.Status},commandType:CommandType.StoredProcedure);}catch(Microsoft.Data.SqlClient.SqlException e)when(e.Number==51002){throw new AuthoringConflictException("The observation or accepted manuscript changed. Your text is retained. Reload the recorded observations before retrying.",e);} + if(r.Version==0){source=await reader.Read(actor,r.BookID,r.ChapterID)??throw new KeyNotFoundException();if(r.ContentVersion!=source.ContentVersion)throw new AuthoringConflictException("The accepted chapter changed. Your observation text is retained. Refresh the manuscript before choosing its reference again.");if(r.Scope=="")r.Scope=r.StartParagraph.HasValue?"Passage":"Chapter"; + if(r.Scope is not("Chapter" or "Scene" or "Passage"))throw new ArgumentException("Choose an annotation scope."); + if(r.Scope=="Passage")rows=Anchor(source,r.StartParagraph,r.EndParagraph,r.StartOffset,r.EndOffset); + else if(r.StartParagraph.HasValue||r.EndParagraph.HasValue)throw new ArgumentException("Choose the reference explicitly for this scope."); + if(r.Scope=="Passage"&&rows.Length==0)throw new ArgumentException("Select an accepted passage first."); + if(r.Scope=="Scene"&&(!r.SceneID.HasValue||!source.Paragraphs.Any(p=>p.SceneID==r.SceneID)))throw new ArgumentException("Select a paragraph with a verified scene before adding a scene annotation.");} + int? scene=r.Version==0&&r.Scope=="Scene"?r.SceneID:rows.Length>0&&rows[0].SceneID.HasValue&&rows.All(p=>p.SceneID==rows[0].SceneID)?rows[0].SceneID:null; + using var db=factory.CreateConnection();try{return await db.QuerySingleAsync("dbo.WriterReview_Observations",new{Action=r.Version==0?"create":"update",UserID=actor,r.BookID,r.ChapterID,r.ID,r.Version,ManuscriptID=source?.ManuscriptID,SnapshotRevision=source?.Revision,ContentVersion=source?.ContentVersion,r.StartParagraph,r.EndParagraph,r.StartOffset,r.EndOffset,AnchorHash=rows.Length>0?Hash(rows):null,SceneID=scene,r.Observation,r.Decision,r.Status,r.Scope,r.Classification},commandType:CommandType.StoredProcedure);}catch(Microsoft.Data.SqlClient.SqlException e)when(e.Number==51002){throw new AuthoringConflictException("The observation or accepted manuscript changed. Your text is retained. Reload the recorded observations before retrying.",e);} } } diff --git a/PlotLine/Sql/282_WriterEditorialAnnotations.sql b/PlotLine/Sql/282_WriterEditorialAnnotations.sql new file mode 100644 index 00000000..af26e7a1 --- /dev/null +++ b/PlotLine/Sql/282_WriterEditorialAnnotations.sql @@ -0,0 +1,47 @@ +-- Extend existing editorial observations without rewriting existing records or anchors. +SET ANSI_NULLS ON; +SET QUOTED_IDENTIFIER ON; +GO +IF COL_LENGTH('dbo.WriterReviewObservations','Scope') IS NULL ALTER TABLE dbo.WriterReviewObservations ADD Scope varchar(10) NULL,Classification varchar(30) NULL; +GO +IF EXISTS(SELECT 1 FROM sys.check_constraints WHERE name='CK_WriterReview_Status') ALTER TABLE dbo.WriterReviewObservations DROP CONSTRAINT CK_WriterReview_Status; +ALTER TABLE dbo.WriterReviewObservations ADD CONSTRAINT CK_WriterReview_Status CHECK(Status IN('Open','Working','Resolved','Dismissed')); +GO +CREATE OR ALTER PROCEDURE dbo.WriterReview_Observations @Action varchar(12),@UserID int,@BookID int,@ChapterID int,@ID uniqueidentifier=NULL,@Version int=0, + @ManuscriptID uniqueidentifier=NULL,@SnapshotRevision bigint=NULL,@ContentVersion char(64)=NULL, + @StartParagraph uniqueidentifier=NULL,@EndParagraph uniqueidentifier=NULL,@StartOffset int=NULL,@EndOffset int=NULL,@AnchorHash char(64)=NULL,@SceneID int=NULL, + @Observation nvarchar(max)=NULL,@Decision nvarchar(max)=NULL,@Status varchar(16)='Open',@Page int=1,@Scope varchar(10)=NULL,@Classification varchar(30)='Observation' +AS +BEGIN + SET NOCOUNT ON;SET XACT_ABORT ON; + IF NOT EXISTS(SELECT 1 FROM dbo.Books b JOIN dbo.Chapters c ON c.BookID=b.BookID AND c.ChapterID=@ChapterID AND c.IsArchived=0 JOIN dbo.ProjectUserAccess a ON a.ProjectID=b.ProjectID AND a.UserID=@UserID AND a.IsActive=1 WHERE b.BookID=@BookID AND b.IsArchived=0) THROW 51000,'Review scope unavailable',1; + IF @Action='list' BEGIN + IF @Page<1 OR @Page>100000 THROW 51000,'Invalid review page',1; + SELECT * FROM dbo.WriterReviewObservations WHERE UserID=@UserID AND BookID=@BookID AND ChapterID=@ChapterID ORDER BY CreatedUtc DESC,ID OFFSET ((@Page-1)*50) ROWS FETCH NEXT 51 ROWS ONLY;RETURN; + END; + IF @Action NOT IN('create','update') OR @ID IS NULL OR @Status NOT IN('Open','Working','Resolved','Dismissed') OR LEN(TRIM(COALESCE(@Observation,N'')))=0 OR LEN(@Observation)>10000 OR LEN(COALESCE(@Decision,N''))>10000 THROW 51000,'Invalid observation',1; + IF @Classification NOT IN('Observation','Revision needed','Continuity','Research','Character','Plot','Pacing','Reminder','General note') THROW 51000,'Invalid classification',1; + SET @Scope=COALESCE(NULLIF(@Scope,''),CASE WHEN @StartParagraph IS NULL THEN 'Chapter' ELSE 'Passage' END); + IF @Action='create' AND (@Scope NOT IN('Chapter','Scene','Passage') OR (@Scope='Scene' AND @SceneID IS NULL) OR (@Scope='Passage' AND @StartParagraph IS NULL) OR (@Scope<>'Passage' AND @StartParagraph IS NOT NULL)) THROW 51000,'Invalid annotation scope',1; + IF @Action='create' AND @Scope='Scene' AND NOT EXISTS(SELECT 1 FROM dbo.Scenes WHERE SceneID=@SceneID AND ChapterID=@ChapterID AND IsArchived=0) THROW 51000,'Scene unavailable',1; + BEGIN TRANSACTION; + IF @Action='create' + BEGIN + IF EXISTS(SELECT 1 FROM dbo.WriterReviewObservations WITH(UPDLOCK,HOLDLOCK) WHERE ID=@ID) + BEGIN + IF NOT EXISTS(SELECT 1 FROM dbo.WriterReviewObservations WHERE ID=@ID AND UserID=@UserID AND BookID=@BookID AND ChapterID=@ChapterID AND Observation=@Observation AND ISNULL(Decision,N'')=ISNULL(@Decision,N'') AND ContentVersion=@ContentVersion AND Status=@Status AND ISNULL(Classification,'Observation')=@Classification AND ISNULL(Scope,CASE WHEN StartParagraph IS NULL THEN 'Chapter' ELSE 'Passage' END)=@Scope AND ISNULL(SceneID,0)=ISNULL(@SceneID,0) AND ISNULL(CONVERT(varchar(36),StartParagraph),'')=ISNULL(CONVERT(varchar(36),@StartParagraph),'') AND ISNULL(CONVERT(varchar(36),EndParagraph),'')=ISNULL(CONVERT(varchar(36),@EndParagraph),'') AND ISNULL(StartOffset,-1)=ISNULL(@StartOffset,-1) AND ISNULL(EndOffset,-1)=ISNULL(@EndOffset,-1)) THROW 51002,'This observation changed; reload before retrying',1; + END ELSE BEGIN + DECLARE @CurrentRevision bigint,@CurrentManuscript uniqueidentifier; + SELECT @CurrentRevision=Revision,@CurrentManuscript=ManuscriptID FROM dbo.BookParagraphManuscripts WITH(UPDLOCK,HOLDLOCK) WHERE BookID=@BookID; + IF ISNULL(@CurrentRevision,-1)<>@SnapshotRevision OR ISNULL(@CurrentManuscript,'00000000-0000-0000-0000-000000000000')<>ISNULL(@ManuscriptID,'00000000-0000-0000-0000-000000000000') THROW 51002,'Accepted manuscript changed; your text has been retained',1; + INSERT dbo.WriterReviewObservations(ID,UserID,BookID,ChapterID,ManuscriptID,SnapshotRevision,ContentVersion,StartParagraph,EndParagraph,StartOffset,EndOffset,AnchorHash,SceneID,Observation,Decision,Status,Scope,Classification) + VALUES(@ID,@UserID,@BookID,@ChapterID,@ManuscriptID,@SnapshotRevision,@ContentVersion,@StartParagraph,@EndParagraph,@StartOffset,@EndOffset,@AnchorHash,@SceneID,@Observation,@Decision,@Status,@Scope,@Classification); + END; + END ELSE BEGIN + UPDATE dbo.WriterReviewObservations SET Observation=@Observation,Decision=@Decision,Status=@Status,Classification=@Classification,Version=Version+1,UpdatedUtc=SYSUTCDATETIME() WHERE ID=@ID AND UserID=@UserID AND BookID=@BookID AND ChapterID=@ChapterID AND Version=@Version; + IF @@ROWCOUNT<>1 THROW 51002,'Another window changed this observation; your text has been retained',1; + END; + SELECT * FROM dbo.WriterReviewObservations WHERE ID=@ID AND UserID=@UserID AND BookID=@BookID AND ChapterID=@ChapterID; + COMMIT; +END; +GO diff --git a/PlotLine/Views/Chapters/Edit.cshtml b/PlotLine/Views/Chapters/Edit.cshtml index 89d845f6..0509057d 100644 --- a/PlotLine/Views/Chapters/Edit.cshtml +++ b/PlotLine/Views/Chapters/Edit.cshtml @@ -12,7 +12,9 @@ Back to book +@if(ViewData["ReturnUrl"] is string back){Return to Review}
+ diff --git a/PlotLine/Views/Writer/Destination.cshtml b/PlotLine/Views/Writer/Destination.cshtml index a08c8d44..e70757f1 100644 --- a/PlotLine/Views/Writer/Destination.cshtml +++ b/PlotLine/Views/Writer/Destination.cshtml @@ -1,11 +1,11 @@ @model WriterDashboardViewModel @{ - ViewData["Title"] = Model.Destination == "Dashboard" ? "Writing Dashboard" : $"Writer · {Model.Destination}"; + ViewData["Title"] = Model.Destination == "Dashboard" ? "Writing Dashboard" : $"{Model.Destination}{(Model.Book == null ? "" : " · " + Model.Book.BookDisplayTitle)}"; ViewData["ProjectSection"] = "Writer"; ViewData["ShellClass"] = "pd-writer writer3-shell"; } - +
x.ChapterID).Distinct())" data-layout-owner="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID"> @if(!Model.BookID.HasValue && Model.Destination != "Explore"){ @@ -22,13 +22,16 @@ }
@section Scripts { + - @if(Model.Destination=="Review"){} + @if(Model.Destination=="Plan"){} + @if(Model.Destination=="Explore"){} + @if(Model.Destination=="Review"){} @if(Model.Destination is "Write" or "Plan"){ - + diff --git a/PlotLine/Views/Writer/_JourneyCalendar.cshtml b/PlotLine/Views/Writer/_JourneyCalendar.cshtml index 5a25db5c..8223ece9 100644 --- a/PlotLine/Views/Writer/_JourneyCalendar.cshtml +++ b/PlotLine/Views/Writer/_JourneyCalendar.cshtml @@ -6,9 +6,6 @@
@work.Year year overview
@for(var date=new DateTime(work.Year,1,1);date.Year==work.Year;date=date.AddDays(1)){days.TryGetValue(date,out var day);}
@if(work.Day is {} selected){days.TryGetValue(selected.Date,out var observed);

@selected.ToString("d MMMM yyyy")

@if(observed==null){

No retained observation for this day. This does not establish that no work took place.

}else{

@observed.Changes accepted changes · +@observed.Added / −@observed.Removed words · @(observed.Added-observed.Removed) net.

@Math.Floor(observed.EngagedSeconds/60d) browser-engaged minutes · @Math.Floor(observed.PlaybackSeconds/60) observed playback minutes. These may overlap and are not added.

}Accepted-change evidence} -

@(work.Day.HasValue?"Sessions on this day":"Recent sessions")

- @foreach(var session in work.Sessions.Take(20)){
@session.Kind · @(session.ChapterTitle??"Across the book")

@session.StartedUtc.ToString("d MMM yyyy HH:mm") · @(session.EndedUtc.HasValue?Math.Round((session.EndedUtc.Value-session.StartedUtc).TotalMinutes)+" minutes elapsed":"Session open")

@if(!string.IsNullOrWhiteSpace(session.Note)){

@session.Note

}
Recording details

This session was started explicitly. Elapsed time is not active time. @Math.Floor(session.EngagedSeconds/60d) browser-engaged minutes and @Math.Floor(session.PlaybackSeconds/60) observed playback minutes may overlap and are not added. Dates use UTC.

@if(session.ChangesDuringSession>0){

@session.ChangesDuringSession accepted manuscript changes were recorded during this interval; this association does not establish what caused them.

}
} - Export recent session evidence (up to 50) @if(Model.WritingSchedule.UpcomingTasks.Count>0||Model.PlannedActivities.Count>0){

Planned work ahead

    @foreach(var task in Model.WritingSchedule.UpcomingTasks){
  • @task.ScheduledDate.ToString("d MMM") · @task.SceneTitle · @task.TaskType
  • }@foreach(var task in Model.PlannedActivities){
  • @task.ScheduledDate.ToString("d MMM") · @if(task.SceneID.HasValue){@task.Title}else{@task.Title} · @task.Kind · @task.Minutes planned minutes
  • }
} diff --git a/PlotLine/Views/Writer/_ReviewContext.cshtml b/PlotLine/Views/Writer/_ReviewContext.cshtml index fd9857ce..856f1ac1 100644 --- a/PlotLine/Views/Writer/_ReviewContext.cshtml +++ b/PlotLine/Views/Writer/_ReviewContext.cshtml @@ -1,25 +1,24 @@ @model PlotLine.Services.Writer.ReviewPanel -@{var data=Model.Intentions;var goal=data.Sections.First(x=>x.Kind=="Goals");var scene=data.Sections.FirstOrDefault(x=>x.Kind=="Scene");string Compact(string value)=>value.Length>360?value[..360]+"…":value;} -

@Model.ReferenceMessage

-

Chapter and scene intentions

- @if(scene!=null){

@data.Scene?.SceneTitle

@(string.IsNullOrWhiteSpace(scene.Value("ScenePurposeNotes"))?"No scene intention recorded.":Compact(scene.Value("ScenePurposeNotes")))

@Compact(scene.Value("SceneOutcomeNotes"))

Recorded scene state: @data.Scene?.RevisionStatusName

} -

@(string.IsNullOrWhiteSpace(goal.Value("GoalSummary"))?"No chapter intention recorded. You can review without one.":Compact(goal.Value("GoalSummary")))

-
Chapter details, reminders & editing - @foreach(var section in data.Sections.Where(x=>x.Kind is "Chapter" or "Goals")){@foreach(var field in section.Fields){var value=section.Value(field.Name);if(field.Type=="purpose"&&!string.IsNullOrWhiteSpace(value))value=section.Purposes.FirstOrDefault(p=>p.Value==value).Label??"Recorded purpose is unavailable";@if(!string.IsNullOrWhiteSpace(value)){

@field.Label@value

}}} - @foreach(var note in data.Sections.Where(x=>x.Kind=="Note"&&x.Value("IsResolved")!="true"||x.Kind=="Checklist"&&x.Value("IsCompleted")!="true").Take(10)){

@(note.Kind=="Note"?note.Value("NoteText"):note.Value("ItemText"))

} - @{var flow=data.Sections.FirstOrDefault(x=>x.Kind=="Workflow");}@if(flow!=null){

Priority: @flow.Value("Priority"). @flow.Value("BlockedReason")

} - Edit chapter intentions in the existing editor - @if(data.SceneID.HasValue){Edit scene intentions, notes and working details} -
-

Your observations

- @if(Model.Observations.Count==0){

No observations on this page. Record something when it helps your review.

} - @foreach(var row in Model.Observations){ -
-

@(row.Status=="Open"?"Needs attention":row.Status=="Working"?"Working on it":"Resolved")

-

@row.Observation

@row.Decision

-

@row.AnchorState reference · @(row.SnapshotRevision<0?"No accepted version at capture":"Accepted version "+row.SnapshotRevision) · created @row.CreatedUtc.ToString("dd MMM yyyy HH:mm:ss") UTC · updated @row.UpdatedUtc.ToString("dd MMM yyyy HH:mm:ss") UTC

-
@if(row.StartParagraph.HasValue){}
+@{var data=Model.Intentions;} +
+
+

@data.Chapter.ChapterTitle

+ @foreach(var section in data.Sections.Where(x=>x.Kind is "Chapter" or "Goals")){} + Structural chapter properties +
+
+

@Model.ReferenceMessage

+ @if(data.SceneID.HasValue){

@data.Scene?.SceneTitle

@foreach(var section in data.Sections.Where(x=>x.Kind is "Scene" or "Note" or "Checklist" or "AddNote" or "AddChecklist")){}} + else{

No verified scene selected. Select an accepted paragraph with an assigned scene. No association is guessed.

} +
+

Editorial annotations

+ + @if(Model.Observations.Count==0){

No annotations on this page.

} + @foreach(var row in Model.Observations){
+

@row.EffectiveScope · @row.EffectiveClassification

@(row.Status=="Working"?"In progress":row.Status)

+

@row.Observation

@row.Decision

@row.AnchorState reference · accepted revision @row.SnapshotRevision · updated @row.UpdatedUtc.ToString("d MMM yyyy HH:mm") UTC

+ @if(row.StartParagraph.HasValue){}
} -
@if(Model.Page>1){}@if(Model.HasMore){}
+
@if(Model.Page>1){}@if(Model.HasMore){}
diff --git a/PlotLine/Views/Writer/_SessionHistory.cshtml b/PlotLine/Views/Writer/_SessionHistory.cshtml new file mode 100644 index 00000000..0ce44c1e --- /dev/null +++ b/PlotLine/Views/Writer/_SessionHistory.cshtml @@ -0,0 +1,8 @@ +@model WriterDashboardViewModel +@{var work=Model.Work??new PlotLine.Models.WriterWorkPage{BookID=Model.BookID??0};} +
+

@(work.Day.HasValue?"Sessions on this day":"Recent sessions")

+ @foreach(var session in work.Sessions.Take(20)){
@session.Kind · @(session.ChapterTitle??"Across the book")

@session.StartedUtc.ToString("d MMM yyyy HH:mm") · @(session.EndedUtc.HasValue?Math.Round((session.EndedUtc.Value-session.StartedUtc).TotalMinutes)+" minutes elapsed":"Session open")

@if(!string.IsNullOrWhiteSpace(session.Note)){

@session.Note

}
Recording details

This session was started explicitly. Elapsed time is not active time. @Math.Floor(session.EngagedSeconds/60d) browser-engaged minutes and @Math.Floor(session.PlaybackSeconds/60) observed playback minutes may overlap and are not added. Dates use UTC.

@if(session.ChangesDuringSession>0){

@session.ChangesDuringSession accepted manuscript changes were recorded during this interval; this association does not establish what caused them.

}
} + + Export recent session evidence (up to 50) +
\ No newline at end of file diff --git a/PlotLine/Views/Writer/_WriterReflect.cshtml b/PlotLine/Views/Writer/_WriterReflect.cshtml index 5048a5e1..1254fde1 100644 --- a/PlotLine/Views/Writer/_WriterReflect.cshtml +++ b/PlotLine/Views/Writer/_WriterReflect.cshtml @@ -2,9 +2,9 @@
@if(Model.ActivityIsPrivate){

Recorded activity is private to the book owner. Your chapter and scene tools remain available.

} else{ -

Your writing journey

Look back at recorded work, explore a day, or notice how your writing has changed over time.

+
@if(Model.Work?.Days.Any(x=>x.Intensity>0)!=true&&Model.Work?.Sessions.Count==0){

Your journey will grow as writing sessions and manuscript changes are recorded. Quiet days here do not mean you did no writing.

} - +
Recorded manuscript progress
}
diff --git a/PlotLine/Views/Writer/_WriterReview.cshtml b/PlotLine/Views/Writer/_WriterReview.cshtml index 03a85d67..7671b21e 100644 --- a/PlotLine/Views/Writer/_WriterReview.cshtml +++ b/PlotLine/Views/Writer/_WriterReview.cshtml @@ -1,30 +1,30 @@ @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"}};}
-
- @if(reader?.Chapter!=null){
Chapter intentions and verified scene context

Loading recorded intentions…

} - @if(reader!=null){} - else{

Read the accepted manuscript

Select a book with chapters to review your accepted writing.

Open your book} -
- + } +
+ diff --git a/PlotLine/wwwroot/css/writer21.css b/PlotLine/wwwroot/css/writer21.css new file mode 100644 index 00000000..0bf7e8e6 --- /dev/null +++ b/PlotLine/wwwroot/css/writer21.css @@ -0,0 +1,26 @@ +/* Workspace composition uses existing theme tokens and natural manuscript scrolling. */ +.writer3-destination{padding-block-start:.6rem} +.writer21-tabs{display:flex;gap:.5rem;flex-wrap:wrap;margin-bottom:1rem;border-bottom:1px solid var(--bs-border-color)} +.writer21-tabs button{border:0;background:transparent;color:inherit;padding:.6rem .9rem;border-bottom:3px solid transparent} +.writer21-tabs button[aria-selected=true]{border-bottom-color:var(--bs-primary);font-weight:700} +.writer21-bounded{max-height:32rem;overflow-y:auto;overscroll-behavior:contain;padding:.3rem} +.writer21-bounded article{padding:.75rem 0;border-bottom:1px solid var(--bs-border-color)} +.writer3-workspace:has([data-explore-investigation]){grid-template-columns:minmax(0,1fr) minmax(0,1fr)} +.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} diff --git a/PlotLine/wwwroot/js/review-authoring.js b/PlotLine/wwwroot/js/review-authoring.js new file mode 100644 index 00000000..f4df9c12 --- /dev/null +++ b/PlotLine/wwwroot/js/review-authoring.js @@ -0,0 +1,10 @@ +// Inline compatibility editors retain canonical chapter/scene note records and field tokens. +(()=>{const editorial=document.querySelector('.writer21-editorial');if(!editorial)return;let busy=false; +const cardOf=node=>node.closest('[data-authoring-card]'); +editorial.addEventListener('input',event=>{const form=event.target.closest('[data-authoring-form]');if(form)form.dataset.dirty='true';}); +editorial.addEventListener('change',async event=>{const card=cardOf(event.target);if(!card)return;const form=card.querySelector('form');if(event.target.matches('[data-checklist-toggle]')){if(busy){event.target.checked=!event.target.checked;return;}form.querySelector('[name=IsCompleted]').checked=event.target.checked;await save(form);}else if(event.target.closest('form'))form.dataset.dirty='true';}); +editorial.addEventListener('click',event=>{const card=cardOf(event.target);if(!card)return;const form=card.querySelector('form'),display=card.querySelector('[data-authoring-display]');if(event.target.closest('[data-authoring-edit]')){form.hidden=false;display.hidden=true;form.querySelector('textarea,input:not([type=hidden])')?.focus();}if(event.target.closest('[data-authoring-cancel]')&&!busy){form.reset();form.dataset.dirty='false';form.hidden=true;display.hidden=false;}if(event.target.closest('[data-authoring-reload]')&&confirm('Reload recorded notes? Copy any text to keep first.')){form.dataset.dirty='false';window.dispatchEvent(new Event('review:notes-saved'));}}); +editorial.addEventListener('submit',event=>{const form=event.target;if(!form.matches('[data-authoring-form]'))return;event.preventDefault();void save(form);}); +async function save(form){if(busy)return;busy=true;const card=cardOf(form),status=card.querySelector('[data-authoring-status]'),data=new FormData(form);for(const box of form.querySelectorAll('input[type=checkbox]'))data.set(box.name,String(box.checked));status.textContent='Saving…';form.dataset.busy='true';let committed=false;try{const response=await fetch(form.action,{method:'POST',body:data});const result=await response.json().catch(()=>null);if(!response.ok||result?.success!==true)throw Error(result?.message||'Save was not confirmed. Reload the recorded version before retrying.');committed=true;form.dataset.dirty='false';status.textContent='Saved.';window.dispatchEvent(new Event('review:notes-saved'));}catch(error){status.textContent=error.message;form.hidden=false;form.dataset.dirty='true';form.querySelector('[data-authoring-reload]').hidden=false;}finally{form.dataset.busy='false';busy=false;if(committed)form.querySelector('[data-authoring-save]').disabled=true;}} +window.addEventListener('beforeunload',event=>{if(busy||editorial.querySelector('[data-authoring-form][data-dirty=true]')){event.preventDefault();event.returnValue='';}}); +})(); diff --git a/PlotLine/wwwroot/js/writer-review.js b/PlotLine/wwwroot/js/writer-review.js index 3e3285cf..712bcdeb 100644 --- a/PlotLine/wwwroot/js/writer-review.js +++ b/PlotLine/wwwroot/js/writer-review.js @@ -1,29 +1,35 @@ // 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 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 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]'); function capture(){const s=getSelection();if(!s||s.isCollapsed||s.rangeCount!==1)return null;const r=s.getRangeAt(0),first=nodeParagraph(r.startContainer),last=nodeParagraph(r.endContainer);if(!first||!last||!readerContent.contains(first)||!readerContent.contains(last))return null;const before=document.createRange();before.selectNodeContents(first);before.setEnd(r.startContainer,r.startOffset);const after=document.createRange();after.selectNodeContents(last);after.setEnd(r.endContainer,r.endOffset);return{StartParagraph:first.dataset.paragraphId,EndParagraph:last.dataset.paragraphId,StartOffset:before.toString().length,EndOffset:after.toString().length};} function wordReference(id){if(!word)return;word.dataset.paragraphId=id||'';word.dataset.acceptedRevision=reader.dataset.revision;window.dispatchEvent(new Event('review-reference-changed'));} function queueContext(){clearTimeout(selectionTimer);selectionTimer=setTimeout(()=>void load(false),180);} -async function load(force=true){clearTimeout(selectionTimer);const key=[selected,anchor?.EndParagraph,reader.dataset.version,page].join(':');if(!force&&key===lastContext)return;const mine=++generation;controller?.abort();controller=new AbortController();loading=true;const url=new URL(root.dataset.panelUrl,location.href);url.search=new URLSearchParams({bookId:root.dataset.book,chapterId:root.dataset.chapter,version:reader.dataset.version,page:String(page),...(selected?{paragraphId:selected,endParagraphId:anchor?.EndParagraph||selected}:{})});try{const response=await fetch(url,{cache:'no-store',signal:controller.signal});if(!response.ok)throw Error();const doc=new DOMParser().parseFromString(await response.text(),'text/html'),panel=doc.querySelector('[data-review-panel]');if(!panel)throw Error();if(mine===generation){context.replaceChildren(panel);const slot=document.querySelector('[data-review-intentions-slot]');if(slot&&panel.querySelector('[data-review-intentions]'))slot.replaceChildren(panel.querySelector('[data-review-intentions]'));lastContext=key;}}catch(e){if(e.name!=='AbortError'&&mine===generation){message.textContent='Recorded review information could not load. Your observation text is retained.';}}finally{if(mine===generation)loading=false;}} +async function load(force=true){if(editorial.querySelector('[data-authoring-form][data-dirty="true"]')){message.textContent="Save or Cancel your chapter/scene note editor before changing review context.";return;}clearTimeout(selectionTimer);const key=[selected,anchor?.EndParagraph,reader.dataset.version,page].join(':');if(!force&&key===lastContext)return;const mine=++generation;controller?.abort();controller=new AbortController();loading=true;const url=new URL(root.dataset.panelUrl,location.href);url.search=new URLSearchParams({bookId:root.dataset.book,chapterId:root.dataset.chapter,version:reader.dataset.version,page:String(page),...(selected?{paragraphId:selected,endParagraphId:anchor?.EndParagraph||selected}:{})});try{const response=await fetch(url,{cache:'no-store',signal:controller.signal});if(!response.ok)throw Error();const doc=new DOMParser().parseFromString(await response.text(),'text/html'),panel=doc.querySelector('[data-review-panel]');if(!panel)throw Error();if(mine===generation){context.replaceChildren(panel);const slot=document.querySelector('[data-review-intentions-slot]');if(slot&&panel.querySelector('[data-review-intentions]'))slot.replaceChildren(panel.querySelector('[data-review-intentions]')); +const sceneSlot=document.querySelector('[data-review-scene-context]');if(sceneSlot)sceneSlot.replaceChildren(panel.querySelector('[data-review-scene-intentions]')); +const chapterAnnotations=document.querySelector('[data-chapter-annotations]');if(chapterAnnotations){chapterAnnotations.replaceChildren();for(const note of panel.querySelectorAll('[data-observation][data-scope="Chapter"]'))chapterAnnotations.append(note);} +const sceneID=panel.dataset.selectedScene||'';if(word){word.dataset.sceneId=sceneID;window.dispatchEvent(new Event('review-reference-changed'));} +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;}}catch(e){if(e.name!=='AbortError'&&mine===generation){message.textContent='Recorded review information could not load. Your observation text is retained.';}}finally{if(mine===generation)loading=false;}} function pause(enabled){const input=reader.querySelector('#reader-pause');if(enabled){pauseBefore=input.checked;input.checked=true;}else input.checked=pauseBefore;input.dispatchEvent(new Event('change'));} -function showEditor(){if(reader.dataset.focus==='true'){const restore=reader.readerPreserveView?.();reader.querySelector('#reader-focus').click();restore?.();}const aside=root.closest('.writer3-reference');if(aside.hidden)document.querySelector('[data-writer-companion-toggle]')?.click();form.hidden=false;newButton.hidden=true;field('Observation').focus();} -function begin(){if(busy)return;if(dirty){field('Observation').focus();return;}anchor=capture()||anchor;selected=anchor?.StartParagraph||null;wordReference(selected);void load();field('ID').value=crypto.randomUUID();field('Version').value='0';field('ContentVersion').value=reader.dataset.version;for(const n of['StartParagraph','EndParagraph','StartOffset','EndOffset'])field(n).value=anchor?.[n]??'';field('Observation').value='';field('Decision').value='';field('Status').value='Open';error.hidden=true;pause(true);dirty=true;reference.textContent=anchor?'Observation linked to the selected accepted paragraph(s).':'Chapter-level observation; no exact passage is claimed.';showEditor();} +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); 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),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;button.disabled=false;cancel.disabled=false;}}); -root.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;pause(true);dirty=true;reference.textContent='Editing a recorded observation; its original accepted-version reference is retained.';showEditor();} +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;}}); +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();}}); +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();});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();field('Scope').value=b.dataset.reviewScopeNew;});window.addEventListener('review:notes-saved',()=>void load());void load(); })(); diff --git a/PlotLine/wwwroot/js/writer21.js b/PlotLine/wwwroot/js/writer21.js new file mode 100644 index 00000000..8c0a32f6 --- /dev/null +++ b/PlotLine/wwwroot/js/writer21.js @@ -0,0 +1,4 @@ +(()=>{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));}); +})();