Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ How most packages work, so the bullets below don't repeat it:
- Only the HTML renderer exists. Notes are Markdown, and Vue, React, and Svelte versions would each copy the whole figure template.
- The output reads without a script. The zoom and carousel scripts and all styles are inlined once per document.
- A screenshot zooms with `comark-zoom`, and `::compare` is a two-column `comark-carousel`. Marks are not links, so a click anywhere on a screenshot zooms it.
- A table cell can't hold a block, so `thumbnails()` in `src/read.ts` moves the `::screenshot` a cell names with `:screenshot{of="id"}` into that cell, marked `data-thumbnail`. The renderer draws it as `.ca-thumb`: the image at comark-zoom's thumbnail size with a dot at each mark. Every thumbnail rule is scoped `:not(.cz-dialog *)`, so the zoomed copy is the full figure, laid out at the width in `data-zoom-width`.
- A table cell can't hold a block, so `thumbnails()` in `src/read.ts` moves the `::screenshot` a cell names with `:screenshot{of="id"}` into that cell, marked `data-thumbnail`, and marks a `:screenshot` written in a cell with its own `src` the same way. The renderer draws it as `.ca-thumb`: the image at comark-zoom's thumbnail size with a dot at each mark. Every thumbnail rule is scoped `:not(.cz-dialog *)`, so the zoomed copy is the full figure, laid out at the width in `data-zoom-width`.
- Each screenshot's `<img>` gets its `viewport` as `width` and `height`, or the size comark-zoom's `measure()` reads from the file while rendering, so the page keeps its room before the image loads.
- `packages/badge` is `comark-badge`.
- Prose badges normalize to `color` plus inline content. Image badges normalize to `src` and `label`: a local SVG data URI, drawn from the live npm or GitHub Actions data the parse fetched, or a hosted URL when that data is unavailable or `download` is `false`.
Expand Down
2 changes: 1 addition & 1 deletion packages/annotate/docs/components/screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Captured on the staging dashboard, after the filter fix.

### In a table

A table cell holds one line, so it can't hold a screenshot block and its annotations. Give a standalone `::screenshot` an id and name it in the cell with `:screenshot{of="id"}`. The screenshot moves into that cell as a thumbnail, with a dot where each mark sits, and opens with its marks and notes at full size. Without JavaScript, the cell shows the full figure instead. Nothing is drawn where the block was written. Screenshots inside `::compare` are not eligible: they stay in their comparisons.
A table cell holds one line, so it can't hold a screenshot block and its annotations. Give a standalone `::screenshot` an id and name it in the cell with `:screenshot{of="id"}`. The screenshot moves into that cell as a thumbnail, with a dot where each mark sits, and opens with its marks and notes at full size. Without JavaScript, the cell shows the full figure instead. Nothing is drawn where the block was written. A screenshot with nothing to annotate can go in the cell itself, as `:screenshot{src="/cart.png" alt="The cart"}`. Screenshots inside `::compare` are not eligible: they stay in their comparisons.

::example
```md
Expand Down
2 changes: 2 additions & 0 deletions packages/annotate/src/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ export function thumbnails(nodes: Node[]): Issue[] {
if (tag === "screenshot") {
const id = text(attrs.id);
if (attrs.of !== undefined) names.push({ node, parent, cell });
// One written in the cell itself, with its `src`, is a thumbnail there, and never the block another cell names.
else if (cell) attrs[THUMBNAIL] = "";
else if (id && !blocks.has(id)) blocks.set(id, { node, parent });
} else if (tag !== "compare" && tag !== "annotation")
walk(childrenOf(node), node, cell || tag === "td" || tag === "th");
Expand Down
11 changes: 11 additions & 0 deletions packages/annotate/test/annotate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,17 @@ The caption.
expect(html.split('id="shot"')).toHaveLength(2);
});

it("draws a screenshot written in the cell as a thumbnail, and never as the block another cell names", async () => {
const { issues, html: page } = await run(
'| A | B |\n| --- | --- |\n| :screenshot{#shot src="a.png" alt="A" viewport="900x600"} | :screenshot{of="shot"} |',
);
expect(issues).toHaveLength(1);
expect(issues[0]).toContain('`:screenshot{of="shot"}` names no standalone screenshot');
const html = page.replace(/<style>.*?<\/style>\s*/gs, "");
expect(html.split('class="ca ca-thumb"')).toHaveLength(2);
expect(html).not.toContain("data-comark-frame");
});

it("reports a name with no block, and one outside a table, and draws neither", async () => {
const {
issues,
Expand Down
2 changes: 1 addition & 1 deletion skills/comark-ui/references/annotate.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Moon phase and vibes don't fit, so the toolbar wraps and pushes the table down.
- `::annotation`: `x y w h` are required percentages of the image, numbers from 0 to 100 without `%`. `mark` is `box` (default), `circle`, `underline`, `line` (straight through the middle, along the longer side), `highlight`, `bracket` (down the side of a box at least twice as tall as it is wide, and across a wide one, whatever its `side`), `cross`, `check`, or `none`, which needs a `side`. `color` is `violet` (default) to point something out, `red` for a problem, `amber` for a warning, `green` for a fix, `blue` for a second voice, `gray` for neutral, or a 3- or 6-digit hex color. `side` is `top`, `bottom`, `left`, or `right`; keep top or bottom notes at least a quarter of the image apart and left or right notes an eighth apart.
- `at` moves a side note along its margin, as a percentage of the image (across for top and bottom, down for left and right). A note set off from its point reads away from it, so put it on the side with room: a top note at `at=40` pointing left of 40 reads to the right. `to="x,y"` is the point the arrow lands on, measured like the box; without it the arrow meets the middle of the mark's facing edge. Both need a `side`.
- Annotations must be direct children of a screenshot.
- In a table cell, write `:screenshot{of="id"}` and put a standalone `::screenshot{#id …}` block with its annotations elsewhere in the document, outside any `::compare`. The block moves into the cell as a thumbnail that opens with its marks and notes. Without JavaScript the cell shows the full figure. Set `viewport` so the row keeps its height. Outside a table, write the block itself.
- In a table cell, write `:screenshot{of="id"}` and put a standalone `::screenshot{#id …}` block with its annotations elsewhere in the document, outside any `::compare`. The block moves into the cell as a thumbnail that opens with its marks and notes. Without JavaScript the cell shows the full figure. A screenshot with no annotations can be written in the cell itself, as `:screenshot{src alt}`. Set `viewport` so the row keeps its height. Outside a table, write the block itself.
Comment thread
vite-hub[bot] marked this conversation as resolved.
Resolved

## Measure every mark

Expand Down
Loading