Skip to content

Fixed image editor component pattern#7586

Merged
martinjagodic merged 1 commit intodecaporg:mainfrom
juagonala:fix/update-editor-image-component-regex
Sep 1, 2025
Merged

Fixed image editor component pattern#7586
martinjagodic merged 1 commit intodecaporg:mainfrom
juagonala:fix/update-editor-image-component-regex

Conversation

@juagonala
Copy link
Contributor

Summary

This PR updates the pattern prop of the Image editor component and fixes the issue #7575.

The problem was that the previous regex pattern expected the image Markdown to occupy the entire string, using ^ at the start and $ at the end. As a result, images embedded in Markdown blocks with preceding or trailing text, blank lines, or paragraphs were not detected, breaking the editor preview for these images.

The proposed solution removes the $ anchor at the end and uses a global regex that matches images anywhere in the Markdown block. This ensures that images like:

Lorem ipsum text

![Alternative text](/media/foo.png)

More text

are correctly recognized by the Image editor component and rendered in both the rich text editor and preview pane.

Test plan

  • Verified that Markdown containing images between paragraphs renders correctly in the editor.
  • Confirmed that newly uploaded images (blobs) appear immediately in the preview.
  • Existing images continue to render correctly without changes to Markdown.

Here is an example of the Docusaurus demo content with an image between paragraphs:

decap-fix-7575

Checklist

Please add a x inside each checkbox:

@juagonala juagonala requested a review from a team as a code owner August 28, 2025 10:41
@martinjagodic martinjagodic enabled auto-merge (squash) September 1, 2025 08:50
@martinjagodic martinjagodic merged commit fd217c2 into decaporg:main Sep 1, 2025
8 checks passed
martinjagodic pushed a commit to poslovnimediji/decap-cms that referenced this pull request Sep 4, 2025
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