From a2f7cd444101b6a7ef98c5fa781c8c984fed6d72 Mon Sep 17 00:00:00 2001 From: onmax Date: Wed, 18 Nov 2026 10:36:10 +0100 Subject: [PATCH 1/3] fix(zoom): keep the zoomed view's column to the screen's width The dialog's grid set no column, so its implicit column grew to the one-line caption's width. On a 390px phone a long alt text pushed the close button about 280px off screen. --- e2e/zoom.e2e.ts | 17 +++++++++++++++++ packages/zoom/src/styles.ts | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/e2e/zoom.e2e.ts b/e2e/zoom.e2e.ts index 9edc4412..b0768e07 100644 --- a/e2e/zoom.e2e.ts +++ b/e2e/zoom.e2e.ts @@ -695,3 +695,20 @@ test("Up and Down move between the page's figures, scroll a tall one first, and const first = page.locator("main [data-zoom-gallery] [data-zoom]").first(); await expect(first).toBeInViewport(); }); + +test("on a phone, a long title stays on the screen and keeps the close button there", async ({ + page, +}) => { + await page.setViewportSize({ width: 390, height: 844 }); + await fixture( + page, + await render( + "![The booking page with the departure station, the arrival station, and the travel date filled in](/dashboard.png)", + ), + ); + await page.locator("main img[data-zoom]").click(); + await expect(page.locator(".cz-dialog")).toBeVisible(); + for (const part of [".cz-stage", ".cz-header"]) + expect((await rect(page, part)).right).toBeLessThanOrEqual(390); + expect((await rect(page, ".cz-close")).right).toBeLessThanOrEqual(390); +}); diff --git a/packages/zoom/src/styles.ts b/packages/zoom/src/styles.ts index 1163307f..7ded7be9 100644 --- a/packages/zoom/src/styles.ts +++ b/packages/zoom/src/styles.ts @@ -14,7 +14,7 @@ export const css = `@layer comark{${[ "[data-zoom]:focus-visible{outline:2px solid var(--_comark-ring);outline-offset:3px}", // The dialog fills the window in place of the browser's centered box. Its styles keep it shown after a close, so the // closing animation runs to its end whatever closed it. - ".cz-dialog{position:fixed;inset:0;z-index:2147483000;display:grid;grid-template-rows:auto minmax(0,1fr) auto;width:auto;height:auto;max-width:none;max-height:none;margin:0;padding:0;overflow:visible;border:0;background:none;color:var(--_comark-foreground);font:13px/1.4 var(--_comark-font);outline:none}", + ".cz-dialog{position:fixed;inset:0;z-index:2147483000;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;width:auto;height:auto;max-width:none;max-height:none;margin:0;padding:0;overflow:visible;border:0;background:none;color:var(--_comark-foreground);font:13px/1.4 var(--_comark-font);outline:none}", // .cz-backdrop is the backdrop, so it fades with the rest of the view. ".cz-dialog::backdrop{background:none}", ".cz-backdrop{position:absolute;inset:0;background:var(--cz-backdrop,color-mix(in srgb,var(--_comark-background) var(--cz-backdrop-opacity,96%),transparent))}", From 10f7a8a8e95944964ac4660695ac1b0d933397b7 Mon Sep 17 00:00:00 2001 From: onmax Date: Wed, 18 Nov 2026 10:36:10 +0100 Subject: [PATCH 2/3] fix(zoom): zoom images inside a block named carousel unless comark-carousel draws it The plugin left the images inside any carousel, slide, screenshot or compare block alone, since comark-carousel and comark-annotate zoom those as a whole. An app with its own ::carousel component lost image zoom inside it. The plugin now skips those blocks only when state.options.plugins registers the plugin that draws them, in either order. --- AGENTS.md | 2 +- packages/carousel/test/carousel.test.ts | 14 ++++++++++++++ packages/zoom/README.md | 2 +- packages/zoom/docs/index.md | 2 +- packages/zoom/src/index.ts | 19 ++++++++++++++----- packages/zoom/test/zoom.test.ts | 6 ++++++ skills/comark-ui/references/zoom.md | 2 +- 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 02e4369e..70a0e0e8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -200,7 +200,7 @@ How most packages work, so the bullets below don't repeat it: - Its output is plain elements, so it has no renderers and ships no styles. - Pandoc's `@fig-x` isn't read, since `@name` is a mention in comark-chips and comark-github. - `packages/zoom` is `comark-zoom`. - - `src/index.ts` is the parse plugin. It marks content images and adds one `zoom-runtime` node to a document with anything to zoom. Unless `size` is `false`, it gives every image without both sides its `width` and `height` from `measure()`, so the page keeps the image's room before it loads. + - `src/index.ts` is the parse plugin. It marks content images and adds one `zoom-runtime` node to a document with anything to zoom. It leaves the images inside `::zoom` alone, and inside carousel's and annotate's blocks when `state.options.plugins` registers that plugin, so an app's own `::carousel` still zooms its images. Unless `size` is `false`, it gives every image without both sides its `width` and `height` from `measure()`, so the page keeps the image's room before it loads. - `src/size.ts` is `comark-zoom/size`. `measure()` reads a picture's or a video's size from the first 64 KB of a URL (a range request) or from a data URI, cached per URL. `sizeOf()` reads it from bytes (PNG, JPEG, GIF, WebP, SVG, AVIF, MP4, MOV, WebM), turned by EXIF orientation or the track's matrix. A relative path, a format it doesn't know, or a file that doesn't answer within 5 seconds gets nothing. - comark-media and comark-annotate bundle `size` the way they bundle the theme, so every block that loads a picture or a video keeps its room. - `src/script.ts` is the browser script. `script()` is self-contained because the HTML renderer inlines its source. `src/client.ts` exports `start()`, which runs it with the bundled styles. The Vue, React, and Svelte components call it on mount and stop it on unmount. diff --git a/packages/carousel/test/carousel.test.ts b/packages/carousel/test/carousel.test.ts index 711947d3..eb1cac36 100644 --- a/packages/carousel/test/carousel.test.ts +++ b/packages/carousel/test/carousel.test.ts @@ -33,6 +33,20 @@ describe("comark-carousel", () => { expect(html.match(/