Add quick parse notation for critical editor

This commit is contained in:
2026-03-15 12:58:26 +01:00
parent d1ad95e861
commit 7b07477133
12 changed files with 666 additions and 35 deletions

View File

@@ -71,16 +71,26 @@
<section class="critical-editor-section">
<div class="critical-editor-section-header">
<div>
<h4>Raw Text</h4>
<p class="muted">Update the source text, then correct the visible result rows below.</p>
<h4>Quick Parse Input</h4>
<p class="muted">First line is the result prose. Later lines are base affixes or <code>condition: ...</code> lines with comma-separated shorthand.</p>
</div>
<button type="button" class="btn-ritual" @onclick="OnReparse" disabled="@IsSaving || IsReparsing">
@(IsReparsing ? "Re-Parsing..." : "Re-Parse Raw Text")
@(IsReparsing ? "Generating..." : "Generate From Quick Input")
</button>
</div>
<div class="field-shell">
<label>Raw Cell Text</label>
<InputTextArea class="input-shell critical-editor-textarea tall" @bind-Value="Model.RawCellText" />
<label>Quick Parse Input</label>
<InputTextArea class="input-shell critical-editor-textarea tall" @bind-Value="Model.QuickParseInput" />
</div>
<p class="muted critical-editor-advanced-hint">Example: <code>Foe brings his guard up, frightened by your display.</code> then <code>+5, 1mp</code> or <code>w/o shield: glancing blow, +15, 3s, 3np</code>.</p>
<div class="critical-editor-quick-legend">
@foreach (var entry in QuickParseLegendEntries)
{
<div class="critical-editor-quick-legend-item">
<code>@entry.Token</code>
<span class="muted">@entry.Meaning</span>
</div>
}
</div>
@if (Model.ValidationMessages.Count > 0)
{
@@ -88,7 +98,7 @@
}
@if (HasComparisonDifferences(Model, ComparisonBaseline))
{
<p class="muted critical-editor-advanced-hint">Fresh parsing differs from the current edited card. Review Generated Compare before saving if you want to keep the overrides.</p>
<p class="muted critical-editor-advanced-hint">Fresh generation differs from the current edited card. Review Generated Compare before saving if you want to keep the overrides.</p>
}
<div class="field-shell">
<label>Result Text</label>
@@ -203,7 +213,7 @@
<div class="critical-editor-card-header">
<div>
<strong>Generated Compare</strong>
<p class="muted critical-editor-inline-copy">Compare the current edited card against the fresh parser output from the raw text.</p>
<p class="muted critical-editor-inline-copy">Compare the current edited card against the fresh generated result from the quick parse input.</p>
</div>
</div>
@@ -222,8 +232,8 @@
Effects="@BuildPreviewEffects(GetComparisonSourceModel(Model, ComparisonBaseline))"
Branches="@BuildPreviewBranches(GetComparisonSourceModel(Model, ComparisonBaseline))" />
<CriticalResultPreviewCard
Title="Generated From Raw Text"
Caption="This is the fresh parser output before override preservation."
Title="Generated From Quick Input"
Caption="This is the fresh generated output before override preservation."
Description="@Model.GeneratedState.DescriptionText"
Effects="@Model.GeneratedState.Effects"
Branches="@Model.GeneratedState.Branches"
@@ -250,6 +260,10 @@
</div>
<dl class="critical-editor-diagnostic-grid">
<div>
<dt>OCR Source</dt>
<dd>@(string.IsNullOrWhiteSpace(Model.RawCellText) ? "—" : Model.RawCellText)</dd>
</div>
<div>
<dt>Parse Status</dt>
<dd>@Model.ParseStatus</dd>
@@ -371,6 +385,18 @@
{
WriteIndented = true
};
private static readonly IReadOnlyList<(string Token, string Meaning)> QuickParseLegendEntries =
[
("+15", "Direct hits"),
("3s", "Stunned 3 rounds"),
("1mp", "Must parry 1 round"),
("3np", "No parry 3 rounds"),
("1hpr", "Bleed 1 hit per round"),
("-20", "Foe penalty"),
("+20b", "Attacker bonus next round"),
("+2d10-3pp", "Power-point modifier"),
("w/o shield: +15, 3s", "Conditional line")
];
private IJSObjectReference? jsModule;
private bool isBackdropPointerDown;
@@ -610,8 +636,8 @@
private static string GetParserNoteSummary(int noteCount) =>
noteCount == 1
? "1 parser note is available under Advanced Diagnostics."
: $"{noteCount} parser notes are available under Advanced Diagnostics.";
? "1 parser note is available under Advanced Review & Diagnostics."
: $"{noteCount} parser notes are available under Advanced Review & Diagnostics.";
private static string FormatJson(string json)
{