Skip to content

fix(image): persist dialog changes in nested editors - #994

Merged
petyosi merged 2 commits into
mdx-editor:mainfrom
huyanxius:fix/991-persist-table-image-dialog
Oct 13, 2026
Merged

petyosi merged 2 commits into
mdx-editor:mainfrom
huyanxius:fix/991-persist-table-image-dialog

Conversation

@huyanxius

@huyanxius huyanxius commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #991.

Problem

An image inserted through ImageDialog can exist in a table cell's Lexical state while getMarkdown() and onChange still omit it. Opening the dialog has already moved focus out of that cell, so moving directly to another cell after saving does not provide another blur to synchronize the image.

Changes

  • Dispatch the existing nested-editor update command after image insertion/editing commits, so parent serialization reads the committed state.
  • Keep the existing dialog and focus behavior; no new focus restoration or table-wide update listener.
  • Add nine component cases covering URL insertion followed by cell/root navigation, actual unmount/reload, image source/alt/title/dimension edits, asynchronous upload completion, Cancel/Escape, root insertion, and nested directives.
  • Add a small bug-991 example and a focused Playwright regression. The example's reload button remounts the editor from the saved Markdown.

Verification

On unchanged main 122347c, the final focused suite has four expected failures: new URL insertion with cell/root navigation, asynchronous upload, and nested directive insertion. The same nine cases pass with this change. The assertions inspect getMarkdown() and onChange before moving focus, so an extra blur cannot rescue the test.

Passed locally:

  • npm run typecheck
  • npm run lint
  • npm run test:once -- --maxWorkers=1 --minWorkers=1: 131 passed; the existing 1 skipped and 1 todo remain
  • npm run build
  • npm run test:lexical-versions: 24 packages at 0.48.0
  • npm run build:docs:api (existing TypeDoc warnings)
  • Focused browser-spec TypeScript check, Ladle static build, and git diff --check

Browser and package verification

Current fork CI passed all four existing jobs for exact head 336ed63a6c08c7a24355a28b508847334f200c6d:

  • Chromium, Firefox, and WebKit: 99/99 cases passed, including this image insertion/save/remount regression in all three engines. Retries remain disabled.
  • Packed React 18 and React 19 declarations, bundle, styles, runtime, and public-ref output passed.
  • Cross-version Markdown replay (0.35 input → packed 0.48 output → published 4.0.4/0.35 reader) passed.
  • Lint, typecheck, 131 unit tests, build, documentation, and the Lexical dependency graph passed.

The initial browser run passed 98/99 cases. WebKit also renders a src-less img as a Lexical managed linebreak, so the test's bare img locator matched two elements. The follow-up scopes the assertion to content images with a source and requires exactly one, preserving the URL, saved Markdown, and reload checks. Production code was unchanged for that follow-up.

Local native-browser execution was unavailable, so the browser and package-runtime results above come from the standard GitHub-hosted runner. Upstream CI for this head still awaits maintainer approval. The PR remains draft.

This change does not alter pending-upload cancellation semantics, clipboard/drop insertion, or the separate nested-JSX import work in #989.

Synchronize nested editors after image insertion and editing commits, so table cells do not depend on another blur to save dialog changes.

Add component regressions for URL and async uploads, image editing, cancellation, root/directive editors, and reload, plus a focused browser fixture.
@petyosi
petyosi merged commit 69563b6 into mdx-editor:main Oct 13, 2026
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The image is not saved after being inserted into the table

2 participants