feat: re-emit changed mermaid diagrams through mermaidDiff in the built-in preview (plan T7 §2.6, INV-29 parity)
Task 7 scoped out reusing the F7.1 (#22) intra-diagram mermaid diff in the built-in Markdown preview's mermaid fence rendering; Task 8 then deleted the webview that still had it, leaving mermaidDiff.ts/mermaidFlowchartDiff.ts/ mermaidSequenceDiff.ts production-dead. Wires diffMermaid into cowritingMarkdownItPlugin's options.highlight override via a per-render mermaid-fence queue (built in the core rule where state.env is visible, consumed by highlight in fence-encounter order — highlight itself has no env param) so a mermaid fence changed since the F6/F7 baseline is re-emitted with classDef/class/linkStyle styling directives + legend before mermaid.js ever sees it, reusing diffBlocks' baseline/current block pairing (same pairing renderReview used). Unchanged diagrams, disabled annotations, no baseline, and pinned-zero-diff all pass through verbatim. Ports the substance of the 6 mermaid-diff assertions Task 8 deleted with the webview's E2E suite as pure unit tests in previewAnnotations.test.ts instead (DOM-free, source-level). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+14
-10
@@ -16,16 +16,20 @@
|
||||
* in-place content updates that don't reload the script (mirrors the proven
|
||||
* `bierner.markdown-mermaid` extension's own approach).
|
||||
*
|
||||
* SCOPE NOTE (Q4 finding, recorded per the migration plan's Task 7 Step 2.6):
|
||||
* this renders the CURRENT diagram only — it does NOT re-emit a changed
|
||||
* diagram through `mermaidDiff.ts`'s intra-diagram diff/legend augmentation
|
||||
* (the F7.1 feature the sealed webview preview has). That augmentation needs a
|
||||
* block-level (not word-hunk-level) diff pass wired into `annotateSource`,
|
||||
* which was judged out of scope for this increment — it cannot be verified by
|
||||
* the automated E2E harness (the built-in preview's DOM/CSP sandbox isn't
|
||||
* queryable from a host test) and shipping it unverified risked a silent
|
||||
* regression. Basic mermaid rendering (this file) IS wired and is exercised by
|
||||
* the same proven pattern as the real `bierner.markdown-mermaid` extension.
|
||||
* RESOLVED SCOPE NOTE (Q4 finding, migration plan Task 7 Step 2.6; wired in a
|
||||
* cross-task review follow-up): this script itself only turns `pre.mermaid`
|
||||
* nodes into diagrams — it never sees a diff. The intra-diagram diff/legend
|
||||
* augmentation (F7.1, INV-29..31) happens one step earlier, source-side,
|
||||
* where it CAN be unit-tested without a DOM: `previewAnnotations.ts`'s
|
||||
* `cowritingMarkdownItPlugin` re-emits a CHANGED mermaid fence's source
|
||||
* through `mermaidDiff.ts` (`buildMermaidQueue`, block-level `diffBlocks`
|
||||
* pairing against the F6/F7 baseline) before this script ever runs, so the
|
||||
* `pre.mermaid` node this script hands to `mermaid.run` already carries the
|
||||
* `classDef`/`class`/`linkStyle` styling directives — this script needn't (and
|
||||
* can't, DOM-less-ly) know a diagram changed at all. Basic mermaid rendering
|
||||
* (this file) is exercised by the same proven pattern as the real
|
||||
* `bierner.markdown-mermaid` extension; the augmentation upstream is exercised
|
||||
* by pure unit tests (`test/previewAnnotations.test.ts`).
|
||||
*/
|
||||
import mermaid from "mermaid";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user