@plannotator/ui 0.41.2 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/HANDOFF.md CHANGED
@@ -875,6 +875,7 @@ to fall back on:
875
875
 
876
876
  ## Publishing & versioning
877
877
 
878
+ - **core 0.25.5 / ui 0.42.0 (diagram FILES, `.mmd`/`.mermaid`/`.dot`/`.gv`): additive on both packages, so the next publish is core-first.** `@plannotator/core/annotatable` gains `DiagramRenderKind`, `diagramRenderKindForPath`, `isDiagramRenderKind` and `annotateDiagramRenderKind`, and its built-in annotatable sets now include the four diagram extensions (`shouldStripFrontmatter` returns false for them — Mermaid's `--- … ---` config block is content — and they can no longer be registered through `markdownExtensions`). `@plannotator/ui` gains `diagramDocumentBlocks(text, kind)` on `utils/parser` (the ONE `code` block a whole-file diagram source renders as), `shareableDocumentMarkdown(markdown, renderAs)` on `utils/sharing`, the `DocumentRenderAs` type on `types` (`'markdown' | 'html' | DiagramRenderKind`, re-exporting core's kind), and an optional `Block.diagramSourceLineOffset` that `DiagramBlock` prefers over `Block.startLine` when resolving a diagram comment's `sourceLine` (unset on every parser-produced fence, so fences are byte-identical). `useLinkedDoc`'s `renderAs`/`setRenderAs`/`LinkedDocLoadData.renderAs` widen from `'markdown' | 'html'` to `DocumentRenderAs` — source-compatible for a host that only ever passes the old two, but a host whose own state is typed `'markdown' | 'html'` must widen its setter. Since core changes, **publish `core` first** and update UI's exact core dependency before packing ui.
878
879
  - **The current pair is `@plannotator/ui` `0.41.2` on `@plannotator/core` `0.25.4`.** Core is UNCHANGED from 0.41.1, so 0.41.2 publishes alone (`ui` only; core 0.25.4 must already be published). 0.41.2 ships the palette-derived Mermaid node shadow at a default of 70% (`DEFAULT_MERMAID_SHADOW_AMOUNT`) and the Settings → Display "Diagram Shadow" control (0 / 40 / 70 / 100); see "Node shadow (the one thing that is not a colour)" under "Theme-aware Mermaid diagrams (0.40.0)" for the mapping — no API removal, only additive exports (`buildMermaidShadow`, `DEFAULT_MERMAID_SHADOW_AMOUNT`, `utils/diagramShadow`).
879
880
  - The pair 0.41.1 shipped as was `@plannotator/ui` `0.41.1` on `@plannotator/core` `0.25.4`. Core is UNCHANGED from 0.41.0, so 0.41.1 published alone (`ui` only; core 0.25.4 must already be published). 0.41.1 is two fixes over 0.41.0 with no API change — the diagram engine is loaded lazily by the first diagram fence instead of riding every document read, and a press on the canvas's own controls no longer comments on the part behind them; see "0.41.1 — the engine is lazy, and the controls are not part of the diagram". The 0.41.0 notes below still describe the engine itself.
880
881
  - **The pair 0.41.0 shipped as was `@plannotator/ui` `0.41.0` on `@plannotator/core` `0.25.4`. Publish `core` 0.25.4 first, then `ui` 0.41.0** (both by hand from `main` after merge; CI never publishes these packages). 0.41.0 is the diagram engine (see "Diagram engine (0.41.0)"): one renderer slot and one canvas behind `MermaidBlock` / `GraphvizBlock`, the `components/diagram` surface, the Graphviz runtime slot with `@viz-js/viz` pinned `3.30.0`, and `Annotation.diagramAnchor`; core 0.25.4 adds the `diagram-anchor` subpath ui imports, so a ui 0.41.0 on a published core 0.25.3 would fail to compile in a consumer.
@@ -292,7 +292,9 @@ export const DiagramBlock: React.FC<DiagramBlockProps & { kind: DiagramKind }> =
292
292
  onCreateComment: handleCreate,
293
293
  selectedCommentId,
294
294
  onSelectComment: onSelectAnnotation,
295
- sourceLineOffset: block.startLine,
295
+ // A fence's offset is its own opening line; a whole-file diagram source
296
+ // overrides it with 0 (see Block.diagramSourceLineOffset).
297
+ sourceLineOffset: block.diagramSourceLineOffset ?? block.startLine,
296
298
  retryToken,
297
299
  };
298
300
 
@@ -8,7 +8,8 @@
8
8
 
9
9
  import { useState, useCallback, useRef } from "react";
10
10
  import { normalizeBrowserPath } from "@plannotator/core/browser-paths";
11
- import type { Annotation, ImageAttachment } from "../types";
11
+ import { isDiagramRenderKind } from "@plannotator/core/annotatable";
12
+ import type { Annotation, DocumentRenderAs, ImageAttachment } from "../types";
12
13
  import type { ViewerHandle } from "../components/Viewer";
13
14
  import type { SidebarTab } from "./useSidebar";
14
15
  import type { SourceSaveCapability } from "@plannotator/core/source-save";
@@ -18,7 +19,7 @@ export interface LinkedDocLoadData {
18
19
  markdown?: string;
19
20
  filepath?: string;
20
21
  isConverted?: boolean;
21
- renderAs?: 'markdown' | 'html';
22
+ renderAs?: DocumentRenderAs;
22
23
  rawHtml?: string;
23
24
  shareHtml?: string;
24
25
  sourceSave?: SourceSaveCapability;
@@ -72,10 +73,10 @@ export interface UseLinkedDocOptions {
72
73
  setGlobalAttachments: (att: ImageAttachment[]) => void;
73
74
  /** Current render mode + raw HTML of the base document. An HTML linked/folder file
74
75
  * swaps these to render raw; back() restores the base values from this snapshot. */
75
- renderAs: 'markdown' | 'html';
76
+ renderAs: DocumentRenderAs;
76
77
  rawHtml: string;
77
78
  shareHtml: string;
78
- setRenderAs: (r: 'markdown' | 'html') => void;
79
+ setRenderAs: (r: DocumentRenderAs) => void;
79
80
  setRawHtml: (html: string) => void;
80
81
  setShareHtml: (html: string) => void;
81
82
  viewerRef: React.RefObject<ViewerHandle | null>;
@@ -105,7 +106,7 @@ interface SavedPlanState {
105
106
  annotations: Annotation[];
106
107
  selectedAnnotationId: string | null;
107
108
  globalAttachments: ImageAttachment[];
108
- renderAs: 'markdown' | 'html';
109
+ renderAs: DocumentRenderAs;
109
110
  rawHtml: string;
110
111
  shareHtml: string;
111
112
  }
@@ -382,7 +383,11 @@ export function useLinkedDoc(options: UseLinkedDocOptions): UseLinkedDocReturn {
382
383
  // Swap to linked doc — an .html file renders raw (HtmlViewer), a markdown
383
384
  // file parses to blocks (Viewer). Drive renderAs/rawHtml per file so the
384
385
  // App's renderAs === 'html' ? HtmlViewer : Viewer switch flips automatically.
385
- const docRenderAs = data.renderAs === 'html' ? 'html' : 'markdown';
386
+ // A diagram source (.mmd/.dot) keeps the markdown state path — the raw
387
+ // text is the document body — but names its engine so the App renders it
388
+ // as one diagram instead of parsing it as markdown.
389
+ const docRenderAs: DocumentRenderAs =
390
+ data.renderAs === 'html' ? 'html' : isDiagramRenderKind(data.renderAs) ? data.renderAs : 'markdown';
386
391
  const hostMarkdown = docRenderAs === 'html' || !notifyDocumentLoaded ? undefined : onDocumentLoaded?.(data);
387
392
  const nextMarkdown = notifyDocumentLoaded
388
393
  ? hostMarkdown ?? cached?.markdown ?? data.markdown ?? ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plannotator/ui",
3
- "version": "0.41.2",
3
+ "version": "0.42.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./components/*": "./components/*.tsx",
@@ -76,7 +76,7 @@
76
76
  "@lezer/highlight": "^1.2.3",
77
77
  "@pierre/diffs": "1.3.6",
78
78
  "@plannotator/atomic-editor": "^0.8.0",
79
- "@plannotator/core": "0.25.4",
79
+ "@plannotator/core": "0.25.5",
80
80
  "@plannotator/markdown-editor": "^0.4.0",
81
81
  "@plannotator/web-highlighter": "^0.8.1",
82
82
  "@tanstack/react-table": "^8.21.3",