Skip to content

fix(keystatic): preserve external image URLs in MDX and Markdoc editors (#1625) - #1663

Open
thinhnx128 wants to merge 1 commit into
Thinkmill:mainfrom
thinhnx128:fix/issue-1625-mdx-external-image-urls
Open

thinhnx128 wants to merge 1 commit into
Thinkmill:mainfrom
thinhnx128:fix/issue-1625-mdx-external-image-urls

Conversation

@thinhnx128

Copy link
Copy Markdown

Summary

Preserves external http:// / https:// image URLs when parsing, editing, and serializing MDX and Markdoc documents in @keystatic/core instead of attempting to load them as local repository blobs.

Root Cause

When fields.mdx or fields.markdoc was configured with an image directory, parse and serialize unconditionally treated all image src attributes as local asset filenames, causing external URLs (https://...) to fail asset lookup and be stripped on save.

Changes

  • packages/keystatic/src/form/fields/markdoc/editor/mdx/parse.ts & serialize.ts: bypass local asset path resolution and preserve external src URLs.
  • packages/keystatic/src/form/fields/markdoc/editor/markdoc/parse.ts & serialize.ts: preserve external image src strings during Markdoc round-tripping.
  • packages/keystatic/src/form/fields/markdoc/editor/schema.tsx & packages/keystatic/src/app/useItemData.ts: support external URLs in editor image preview and item hydration.
  • packages/keystatic/src/form/fields/markdoc/editor/tests/mdx.test.tsx: add unit test verifying external image URL round-trip in MDX.
  • .changeset/fix-mdx-external-image-urls.md: add patch changeset for @keystatic/core.

Testing

  • pnpm --filter @keystatic/core test packages/keystatic/src/form/fields/markdoc/editor/tests/mdx.test.tsx

Fixes #1625

…tom TrackedMap deletions

Fixes Thinkmill#1625

Signed-off-by: Xuan Thinh Nguyen <thinhnx128@gmail.com>
@thinhnx128
thinhnx128 requested a review from emmatown as a code owner November 11, 2026 10:11
@changeset-bot

changeset-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c04e688

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@keystatic/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

fields.mdx(): external https:// image URL treated as local asset, corrupts body on save, causes GraphQL deletion error (v0.6.9)

1 participant