Skip to content

修复 Mermaid 预览生命周期并发布图片预览 v1.2.9 - #21

Merged
bifrost-proxy merged 2 commits into
mainfrom
codex/image-preview-stable-mermaid-overlay
Aug 17, 2026
Merged

bifrost-proxy merged 2 commits into
mainfrom
codex/image-preview-stable-mermaid-overlay

Conversation

@bifrost-proxy

Copy link
Copy Markdown
Owner

What changed

  • add click-to-open previews for Markdown images and standalone image files
  • reuse the Mermaid zoom/pan toolbar for image previews, including trackpad zoom, reset, Escape, and close
  • render the preview through a document-body portal and clone Mermaid SVG content without moving or unmounting the editor DOM
  • stop changing body overflow and restore focus with preventScroll so closing the overlay does not shift the editor
  • bump the release metadata and changelog to BifrostWrite 1.2.9

Root cause

The Mermaid overlay changed global body layout and restored focus without preventing browser scrolling. That could force editor layout/scroll corrections when the overlay closed. Images also had no shared media-overlay entry point.

Validation

  • 197 test files passed
  • 2407 tests passed, 7 skipped
  • ESLint passed
  • renderer production build passed
  • native Tauri release compilation and macOS app bundling passed; local DMG packaging was blocked by an unrelated already-mounted disk image in the host environment
  • version metadata contract passed for 1.2.9

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f3ce27d12

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 133 to +134
useEffect(() => {
if (!svgSource) return;

const previousOverflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
viewportRef.current?.focus();
if (!content) return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move focus into the preview when it opens

When the preview is opened while CodeMirror or another background control retains focus, this effect now installs only the Escape handler and no longer focuses viewportRef; ordinary keystrokes and editor shortcuts can therefore continue acting on the hidden editor behind the modal. Restore initial focus to the viewport or another control inside the dialog after content is mounted.

Useful? React with 👍 / 👎.

Comment on lines +490 to +494
img.addEventListener("click", (event) => {
event.preventDefault();
event.stopPropagation();
openImagePreview(this.src, this.alt);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve link activation for linked Markdown images

For linked-image syntax such as [![alt](image.png)](https://example.com), this listener stops the click before the existing .cm-inline-image-link activation path in livePreview.ts can call openUrl. As a result, a normal pointer click now opens only the image preview and the image's hyperlink is no longer reachable by clicking it; skip this handler when this.href is set or provide a separate preview affordance.

Useful? React with 👍 / 👎.

Comment on lines +487 to +489
img.tabIndex = 0;
img.setAttribute("role", "button");
img.setAttribute("aria-label", translate("Open image preview"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain image alt text in the preview button's accessible name

For Markdown images with meaningful alt text, this explicit generic aria-label overrides the native accessible name supplied by img.alt, so every rendered image is announced only as “Open image preview” and screen-reader users lose the image's description. Include this.alt in the button label (with a sensible fallback when it is empty) instead of replacing it entirely.

Useful? React with 👍 / 👎.

@bifrost-proxy
bifrost-proxy merged commit 28979bf into main Aug 17, 2026
12 of 13 checks passed
@bifrost-proxy
bifrost-proxy deleted the codex/image-preview-stable-mermaid-overlay branch August 17, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants