Skip to content

Bug: inline images are not being exported to Markdown at all (verified in playground) and image captions are not exported to Markdown/DOM (instead some other text is used in alt) #5474

Closed

Description

@vadimkantorov

I went to https://playground.lexical.dev/, inserted an inline image, it gets displayed okay. I then press the button for converting to Markdown. The markdown string contains no info about the image.

I understand that there often is no 1:1 correspondence between the JSON editor state and markdown, but images (inline or URL-based) can somehow be represented by markdown (e.g. by slightly abusing Markdown and using datauri in the ![](imagedatauri) syntax or by returning a dictionary of attachment files along with markdown string which are then addressed by image tags)

I've checked, regular "Insert Image" (non-inline) gets converted to markdown using the datauri syntax, but somehow inline image is not. I think it'd be better in this case to trim the precise inline formatting and still preserve the presence of image instead of the current behavior of completely stripping the image (probably a markdown transformer for InlineImageNode would need to be added to packages/lexical-playground/src/plugins/MarkdownTransformers/index.ts).

( Basically, I'm looking to create some basic rich-text editor like https://telegra.ph (quill-based), but using markdown + file attachments as backend (e.g. thing a GitHub repo containing images and markdown files) )

Activity

  1. changed the title [-]Bug: inline images are not exported to Markdown[/-] [+]Bug: inline images are not exported to Markdown in the playground[/+] on Jan 11, 2024
  2. vadimkantorov commented on Jun 12, 2024

    @vadimkantorov
    Author

    Maybe the better compromise would be to convert these inline images in Markdown as regular images (even if at inverse conversion they would be come regular images and not inline images), or maybe as images with some minor custom HTML

  3. vadimkantorov commented on Jun 27, 2024

    @vadimkantorov
    Author

    image

    After clicking on M↓ nothing gets exported to markdown at all:
    image

  4. changed the title [-]Bug: inline images are not exported to Markdown in the playground[/-] [+]Bug: inline images are not being exported to Markdown at all (verified in playground)[/+] on Jun 27, 2024
  5. vadimkantorov commented on Jun 27, 2024

    @vadimkantorov
    Author

    Also, caption is not being exported to DOM for non-inline images:
    image

    I would propose an option that image caption be exported as alt (at least for markdown it makes more sense). For DOM, maybe it can be exported as <figure><figcaption>...</figcaption><img ... /></figure>

  6. changed the title [-]Bug: inline images are not being exported to Markdown at all (verified in playground)[/-] [+]Bug: inline images are not being exported to Markdown at all (verified in playground) and image captions are not exported to Markdown/DOM (instead some other text is used in alt)[/+] on Jun 27, 2024
  7. kevinfairclough commented on Jul 17, 2024

    @kevinfairclough

    Needs a FigurePlugin

  8. Kepron commented on Sep 13, 2025

    @Kepron
    Contributor

    Is there any update about this?

  9. vadimkantorov commented on Sep 21, 2025

    @vadimkantorov
    Author

    At least would be good to export image caption as alt for img tag (and for markdown).

    But better would be ImageNode export as figure (at least if caption is set) or alternatively - maybe for now delete caption property from ImageNode

  10. etrepum commented on Sep 21, 2025

    @etrepum
    Collaborator

    This is a closed issue about InlineImageNode which no longer exists. If you have feedback about ImageNode you can create a new issue and/or submit a PR. The playground is just demo code, right now adding HTML import/export support for the caption is an exercise for the reader just like other things you would have to do for a production quality ImageNode (e.g. some sort of server-side uploading). Unlike server-side code, it would be straightforward for someone to contribute a less lossy HTML import/export, but commenting on closed issues is one of the worst ways to go about that.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions